Skip to content

Commit

Permalink
Expose multiId field in subscriptions (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
achim-k authored Nov 14, 2024
1 parent 5a0c107 commit f4fb7c6
Showing 1 changed file with 5 additions and 3 deletions.
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

0 comments on commit f4fb7c6

Please sign in to comment.