Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose multiId field in subscriptions #4

Merged
merged 1 commit into from
Nov 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/ULog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ export type ULogHeader = {
definitions: Map<string, MessageDefinition>;
};

export type Subscription = MessageDefinition & Pick<MessageAddLogged, "multiId">;

const MAGIC = [0x55, 0x4c, 0x6f, 0x67, 0x01, 0x12, 0x35];

type IndexEntry = [timestamp: bigint, logPosition: number, messae: DataSectionMessage];
Expand All @@ -42,7 +44,7 @@ export class ULog {
private _dataEnd?: number;
private _header?: ULogHeader;
private _appendedOffsets?: [number, number, number];
private _subscriptions = new Map<number, MessageDefinition>();
private _subscriptions = new Map<number, Subscription>();
private _timeIndex?: IndexEntry[];
private _dataMessageCounts?: Map<number, number>;
private _logMessageCount?: number;
Expand All @@ -55,7 +57,7 @@ export class ULog {
return this._header;
}

get subscriptions(): Map<number, MessageDefinition> {
get subscriptions(): Map<number, Subscription> {
return this._subscriptions;
}

Expand Down Expand Up @@ -300,7 +302,7 @@ export class ULog {
if (!definition) {
throw new Error(`AddLogged unknown message_name: ${subscribe.messageName}`);
}
this._subscriptions.set(subscribe.msgId, definition);
this._subscriptions.set(subscribe.msgId, { ...definition, multiId: subscribe.multiId });
}
}

Expand Down
Loading