wpilog-parser 2.3.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -2
- package/dist/{catalog-CYDrFwrh.mjs → catalog-BT6geQr0.mjs} +521 -249
- package/dist/cli.mjs +20 -10
- package/dist/index.d.mts +79 -67
- package/dist/index.mjs +2 -2
- package/package.json +13 -5
- package/skills/analyze-wpilog/SKILL.md +8 -8
package/dist/cli.mjs
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { o as readRecords, t as catalogEntries, u as diagnostics } from "./catalog-BT6geQr0.mjs";
|
|
3
|
+
import { Diagnostic, formatDiagnostic } from "nostics";
|
|
3
4
|
import { cac } from "cac";
|
|
4
5
|
import { readFile } from "node:fs/promises";
|
|
5
6
|
import { encode } from "@toon-format/toon";
|
|
6
7
|
//#region package.json
|
|
7
|
-
var version = "2.
|
|
8
|
+
var version = "2.4.1";
|
|
8
9
|
//#endregion
|
|
9
10
|
//#region src/cli/catalog.ts
|
|
10
11
|
async function catalogFile(filePath) {
|
|
@@ -12,10 +13,18 @@ async function catalogFile(filePath) {
|
|
|
12
13
|
try {
|
|
13
14
|
bytes = await readFile(filePath);
|
|
14
15
|
} catch (error) {
|
|
15
|
-
if (error instanceof Error && "code" in error && error.code === "ENOENT") throw
|
|
16
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") throw diagnostics.WPILOG_C0003({
|
|
17
|
+
filePath,
|
|
18
|
+
cause: error
|
|
19
|
+
});
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
return Array.from(catalogEntries(readRecords(bytes)));
|
|
24
|
+
} catch (error) {
|
|
25
|
+
if (error instanceof Diagnostic) error.sources = [filePath, ...error.sources ?? []];
|
|
16
26
|
throw error;
|
|
17
27
|
}
|
|
18
|
-
return Array.from(catalogEntries(readRecords(bytes)));
|
|
19
28
|
}
|
|
20
29
|
function selectCatalogFormat(options) {
|
|
21
30
|
const selected = [
|
|
@@ -23,7 +32,7 @@ function selectCatalogFormat(options) {
|
|
|
23
32
|
(options.jsonl || options.ndjson) && "jsonl",
|
|
24
33
|
options.csv && "csv"
|
|
25
34
|
].filter((format) => Boolean(format));
|
|
26
|
-
if (selected.length > 1) throw
|
|
35
|
+
if (selected.length > 1) throw diagnostics.WPILOG_C0002();
|
|
27
36
|
return selected[0] ?? "toon";
|
|
28
37
|
}
|
|
29
38
|
function escapeCsv(value) {
|
|
@@ -57,15 +66,16 @@ cli.command("catalog <file>", "List the entries available in a WPILOG file").opt
|
|
|
57
66
|
cli.help();
|
|
58
67
|
cli.version(version);
|
|
59
68
|
try {
|
|
60
|
-
const parsed = cli.parse(process.argv, { run:
|
|
69
|
+
const parsed = cli.parse(process.argv, { run: false });
|
|
70
|
+
await cli.runMatchedCommand();
|
|
61
71
|
if (!cli.matchedCommand && !parsed.options.help && !parsed.options.version) {
|
|
62
|
-
if (parsed.args[0]) throw
|
|
72
|
+
if (parsed.args[0]) throw diagnostics.WPILOG_C0001({ command: parsed.args[0] });
|
|
63
73
|
cli.outputHelp();
|
|
64
74
|
}
|
|
65
75
|
} catch (error) {
|
|
66
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
67
|
-
console.error(`wpilog: ${message}`);
|
|
68
|
-
process.
|
|
76
|
+
const message = error instanceof Diagnostic ? formatDiagnostic(error) : error instanceof Error ? error.message : String(error);
|
|
77
|
+
console.error(error instanceof Diagnostic ? message : `wpilog: ${message}`);
|
|
78
|
+
process.exitCode = 1;
|
|
69
79
|
}
|
|
70
80
|
//#endregion
|
|
71
81
|
export {};
|
package/dist/index.d.mts
CHANGED
|
@@ -8,14 +8,15 @@ type DataLogHeader = {
|
|
|
8
8
|
extraHeader: string;
|
|
9
9
|
};
|
|
10
10
|
/** Control record types in the WPILOG format. */
|
|
11
|
-
declare
|
|
12
|
-
Start
|
|
13
|
-
Finish
|
|
14
|
-
SetMetadata
|
|
15
|
-
}
|
|
11
|
+
export declare const ControlRecordType: {
|
|
12
|
+
readonly Start: 0;
|
|
13
|
+
readonly Finish: 1;
|
|
14
|
+
readonly SetMetadata: 2;
|
|
15
|
+
};
|
|
16
|
+
export type ControlRecordType = (typeof ControlRecordType)[keyof typeof ControlRecordType];
|
|
16
17
|
/** A control record that starts a new entry. */
|
|
17
18
|
type StartControlRecord = {
|
|
18
|
-
controlRecordType: ControlRecordType.Start;
|
|
19
|
+
controlRecordType: typeof ControlRecordType.Start;
|
|
19
20
|
entryId: number;
|
|
20
21
|
entryName: string;
|
|
21
22
|
entryType: string;
|
|
@@ -23,12 +24,12 @@ type StartControlRecord = {
|
|
|
23
24
|
};
|
|
24
25
|
/** A control record that finishes an entry. */
|
|
25
26
|
type FinishControlRecord = {
|
|
26
|
-
controlRecordType: ControlRecordType.Finish;
|
|
27
|
+
controlRecordType: typeof ControlRecordType.Finish;
|
|
27
28
|
entryId: number;
|
|
28
29
|
};
|
|
29
30
|
/** A control record that sets metadata on an entry. */
|
|
30
31
|
type SetMetadataControlRecord = {
|
|
31
|
-
controlRecordType: ControlRecordType.SetMetadata;
|
|
32
|
+
controlRecordType: typeof ControlRecordType.SetMetadata;
|
|
32
33
|
entryId: number;
|
|
33
34
|
entryMetadata: string;
|
|
34
35
|
};
|
|
@@ -42,22 +43,23 @@ type RawRecord = {
|
|
|
42
43
|
payload: Uint8Array;
|
|
43
44
|
};
|
|
44
45
|
/** Discriminated union tag for decoded record types. */
|
|
45
|
-
declare
|
|
46
|
-
Control
|
|
47
|
-
Boolean
|
|
48
|
-
Int64
|
|
49
|
-
Float
|
|
50
|
-
Double
|
|
51
|
-
String
|
|
52
|
-
BooleanArray
|
|
53
|
-
Int64Array
|
|
54
|
-
FloatArray
|
|
55
|
-
DoubleArray
|
|
56
|
-
StringArray
|
|
57
|
-
Struct
|
|
58
|
-
StructArray
|
|
59
|
-
Raw
|
|
60
|
-
}
|
|
46
|
+
export declare const RecordType: {
|
|
47
|
+
readonly Control: 'control';
|
|
48
|
+
readonly Boolean: 'boolean';
|
|
49
|
+
readonly Int64: 'int64';
|
|
50
|
+
readonly Float: 'float';
|
|
51
|
+
readonly Double: 'double';
|
|
52
|
+
readonly String: 'string';
|
|
53
|
+
readonly BooleanArray: 'boolean[]';
|
|
54
|
+
readonly Int64Array: 'int64[]';
|
|
55
|
+
readonly FloatArray: 'float[]';
|
|
56
|
+
readonly DoubleArray: 'double[]';
|
|
57
|
+
readonly StringArray: 'string[]';
|
|
58
|
+
readonly Struct: 'struct';
|
|
59
|
+
readonly StructArray: 'struct[]';
|
|
60
|
+
readonly Raw: 'raw';
|
|
61
|
+
};
|
|
62
|
+
export type RecordType = (typeof RecordType)[keyof typeof RecordType];
|
|
61
63
|
/** Decoded struct payload — a map of field names to values. */
|
|
62
64
|
type StructPayload = Map<string, number | boolean | bigint | string | StructPayload | number[] | boolean[] | bigint[] | StructPayload[]>;
|
|
63
65
|
/** A decoded data record (excludes control records). */
|
|
@@ -66,60 +68,60 @@ type DataRecord = Extract<DecodedRecord, {
|
|
|
66
68
|
}>;
|
|
67
69
|
/** A decoded control record. */
|
|
68
70
|
type ControlRecord = Extract<DecodedRecord, {
|
|
69
|
-
type: RecordType.Control;
|
|
71
|
+
type: typeof RecordType.Control;
|
|
70
72
|
}>;
|
|
71
73
|
/** Type guard that narrows a {@link DecodedRecord} to a {@link DataRecord}. */
|
|
72
|
-
declare function isDataRecord(record: DecodedRecord): record is DataRecord;
|
|
74
|
+
export declare function isDataRecord(record: DecodedRecord): record is DataRecord;
|
|
73
75
|
/** A decoded data log record. */
|
|
74
76
|
type DecodedRecord = {
|
|
75
77
|
entryId: number;
|
|
76
78
|
/** Timestamp in microseconds. */
|
|
77
79
|
timestamp: bigint;
|
|
78
80
|
} & ({
|
|
79
|
-
type: RecordType.Control;
|
|
81
|
+
type: typeof RecordType.Control;
|
|
80
82
|
payload: ControlRecordPayload;
|
|
81
83
|
} | ({
|
|
82
84
|
name: string;
|
|
83
85
|
metadata: string;
|
|
84
86
|
} & ({
|
|
85
|
-
type: RecordType.Raw;
|
|
87
|
+
type: typeof RecordType.Raw;
|
|
86
88
|
payload: Uint8Array;
|
|
87
89
|
} | {
|
|
88
|
-
type: RecordType.Boolean;
|
|
90
|
+
type: typeof RecordType.Boolean;
|
|
89
91
|
payload: boolean;
|
|
90
92
|
} | {
|
|
91
|
-
type: RecordType.Int64;
|
|
93
|
+
type: typeof RecordType.Int64;
|
|
92
94
|
payload: bigint;
|
|
93
95
|
} | {
|
|
94
|
-
type: RecordType.Float;
|
|
96
|
+
type: typeof RecordType.Float;
|
|
95
97
|
payload: number;
|
|
96
98
|
} | {
|
|
97
|
-
type: RecordType.Double;
|
|
99
|
+
type: typeof RecordType.Double;
|
|
98
100
|
payload: number;
|
|
99
101
|
} | {
|
|
100
|
-
type: RecordType.String;
|
|
102
|
+
type: typeof RecordType.String;
|
|
101
103
|
payload: string;
|
|
102
104
|
} | {
|
|
103
|
-
type: RecordType.BooleanArray;
|
|
105
|
+
type: typeof RecordType.BooleanArray;
|
|
104
106
|
payload: boolean[];
|
|
105
107
|
} | {
|
|
106
|
-
type: RecordType.Int64Array;
|
|
108
|
+
type: typeof RecordType.Int64Array;
|
|
107
109
|
payload: bigint[];
|
|
108
110
|
} | {
|
|
109
|
-
type: RecordType.FloatArray;
|
|
111
|
+
type: typeof RecordType.FloatArray;
|
|
110
112
|
payload: number[];
|
|
111
113
|
} | {
|
|
112
|
-
type: RecordType.DoubleArray;
|
|
114
|
+
type: typeof RecordType.DoubleArray;
|
|
113
115
|
payload: number[];
|
|
114
116
|
} | {
|
|
115
|
-
type: RecordType.StringArray;
|
|
117
|
+
type: typeof RecordType.StringArray;
|
|
116
118
|
payload: string[];
|
|
117
119
|
} | {
|
|
118
|
-
type: RecordType.Struct;
|
|
120
|
+
type: typeof RecordType.Struct;
|
|
119
121
|
structName: string;
|
|
120
122
|
payload: StructPayload;
|
|
121
123
|
} | {
|
|
122
|
-
type: RecordType.StructArray;
|
|
124
|
+
type: typeof RecordType.StructArray;
|
|
123
125
|
structName: string;
|
|
124
126
|
payload: StructPayload[];
|
|
125
127
|
})));
|
|
@@ -138,18 +140,19 @@ type ReadRecord = {
|
|
|
138
140
|
kind: 'data';
|
|
139
141
|
record: RawRecord;
|
|
140
142
|
};
|
|
141
|
-
/** Accepted input types for {@link readRecords}
|
|
143
|
+
/** Accepted input types for {@link readRecords} and `parseDataLog`. */
|
|
142
144
|
type DataLogInput = Uint8Array | ArrayBuffer;
|
|
143
145
|
/**
|
|
144
146
|
* Read raw WPILOG records from an in-memory buffer.
|
|
145
147
|
*
|
|
146
148
|
* Yields a header record first, then control and data records in order.
|
|
147
|
-
* Data record payloads are not decoded
|
|
149
|
+
* Data record payloads are not decoded. Prefer `parseDataLog` when raw records
|
|
150
|
+
* or an intermediate transformation are not needed.
|
|
148
151
|
*/
|
|
149
|
-
declare function readRecords(input: DataLogInput): Generator<ReadRecord>;
|
|
152
|
+
export declare function readRecords(input: DataLogInput): Generator<ReadRecord>;
|
|
150
153
|
//#endregion
|
|
151
154
|
//#region src/decode-records.d.ts
|
|
152
|
-
/** Options for {@link decodeRecords}. */
|
|
155
|
+
/** Options for {@link decodeRecords} and {@link parseDataLog}. */
|
|
153
156
|
type DecodeRecordsOptions = {
|
|
154
157
|
/**
|
|
155
158
|
* When `true`, throw if a data record references an entry ID with no preceding
|
|
@@ -167,11 +170,19 @@ type DecodeRecordsOptions = {
|
|
|
167
170
|
* By default, data records that reference an entry ID with no preceding Start
|
|
168
171
|
* control record are silently skipped. Pass `{ strict: true }` to throw instead.
|
|
169
172
|
*/
|
|
170
|
-
declare function decodeRecords(records: Iterable<ReadRecord>, options?: DecodeRecordsOptions): Generator<DecodedRecord>;
|
|
173
|
+
export declare function decodeRecords(records: Iterable<ReadRecord>, options?: DecodeRecordsOptions): Generator<DecodedRecord>;
|
|
174
|
+
/**
|
|
175
|
+
* Read and decode a WPILOG buffer in a single pass.
|
|
176
|
+
*
|
|
177
|
+
* This is the preferred API for fully decoded records. It avoids allocating the
|
|
178
|
+
* intermediate records produced by composing {@link readRecords} and
|
|
179
|
+
* {@link decodeRecords} while preserving the same output and strict-mode behavior.
|
|
180
|
+
*/
|
|
181
|
+
export declare function parseDataLog(input: DataLogInput, options?: DecodeRecordsOptions): Generator<DecodedRecord>;
|
|
171
182
|
//#endregion
|
|
172
183
|
//#region src/struct-payload-to-json.d.ts
|
|
173
184
|
/** Convert a {@link StructPayload} Map to a plain JSON-compatible object. */
|
|
174
|
-
declare function structPayloadToJson(payload: StructPayload): object;
|
|
185
|
+
export declare function structPayloadToJson(payload: StructPayload): object;
|
|
175
186
|
//#endregion
|
|
176
187
|
//#region src/catalog.d.ts
|
|
177
188
|
/** An entry definition from the WPILOG catalog. */
|
|
@@ -186,30 +197,31 @@ type CatalogEntry = {
|
|
|
186
197
|
*
|
|
187
198
|
* Iterates through records, collecting Start control records.
|
|
188
199
|
* Data record bytes are still read from the stream but not decoded,
|
|
189
|
-
* making this much cheaper than full decoding via {@link
|
|
200
|
+
* making this much cheaper than full decoding via {@link parseDataLog}.
|
|
190
201
|
*/
|
|
191
|
-
declare function catalogEntries(records: Iterable<ReadRecord>): Generator<CatalogEntry>;
|
|
202
|
+
export declare function catalogEntries(records: Iterable<ReadRecord>): Generator<CatalogEntry>;
|
|
192
203
|
//#endregion
|
|
193
204
|
//#region src/struct/types.d.ts
|
|
194
|
-
declare
|
|
195
|
-
Boolean
|
|
196
|
-
Character
|
|
197
|
-
Int8
|
|
198
|
-
Int16
|
|
199
|
-
Int32
|
|
200
|
-
Int64
|
|
201
|
-
Uint8
|
|
202
|
-
Uint16
|
|
203
|
-
Uint32
|
|
204
|
-
Uint64
|
|
205
|
-
Float32
|
|
205
|
+
export declare const KnownStructTypeName: {
|
|
206
|
+
readonly Boolean: 'bool';
|
|
207
|
+
readonly Character: 'char';
|
|
208
|
+
readonly Int8: 'int8';
|
|
209
|
+
readonly Int16: 'int16';
|
|
210
|
+
readonly Int32: 'int32';
|
|
211
|
+
readonly Int64: 'int64';
|
|
212
|
+
readonly Uint8: 'uint8';
|
|
213
|
+
readonly Uint16: 'uint16';
|
|
214
|
+
readonly Uint32: 'uint32';
|
|
215
|
+
readonly Uint64: 'uint64';
|
|
216
|
+
readonly Float32: 'float32';
|
|
206
217
|
/** Equivalent to {@link KnownStructTypeName.Float32} */
|
|
207
|
-
Float
|
|
208
|
-
Float64
|
|
218
|
+
readonly Float: 'float';
|
|
219
|
+
readonly Float64: 'float64';
|
|
209
220
|
/** Equivalent to {@link KnownStructTypeName.Float64} */
|
|
210
|
-
Double
|
|
211
|
-
}
|
|
212
|
-
type
|
|
221
|
+
readonly Double: 'double';
|
|
222
|
+
};
|
|
223
|
+
export type KnownStructTypeName = (typeof KnownStructTypeName)[keyof typeof KnownStructTypeName];
|
|
224
|
+
type StructTypeName = string;
|
|
213
225
|
type EnumSpecification = Map<string, bigint>;
|
|
214
226
|
type StructSpecification = StructDeclaration[];
|
|
215
227
|
type StructDeclaration = {
|
|
@@ -222,6 +234,6 @@ type StructDeclaration = {
|
|
|
222
234
|
//#endregion
|
|
223
235
|
//#region src/struct/parse-struct.d.ts
|
|
224
236
|
/** Parse a WPILib struct specification string into declarations. */
|
|
225
|
-
declare function parseStructSpecification(declaration: string): StructDeclaration[];
|
|
237
|
+
export declare function parseStructSpecification(declaration: string): StructDeclaration[];
|
|
226
238
|
//#endregion
|
|
227
|
-
export {
|
|
239
|
+
export type { CatalogEntry, ControlRecord, ControlRecordPayload, DataLogHeader, DataLogInput, DataRecord, DecodeRecordsOptions, DecodedRecord, EnumSpecification, FinishControlRecord, RawRecord, ReadRecord, SetMetadataControlRecord, StartControlRecord, StructDeclaration, StructPayload, StructSpecification, StructTypeName };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as KnownStructTypeName, c as RecordType, i as parseStructSpecification, l as isDataRecord, n as decodeRecords, o as readRecords, r as parseDataLog, s as ControlRecordType, t as catalogEntries } from "./catalog-BT6geQr0.mjs";
|
|
2
2
|
//#region src/struct-payload-to-json.ts
|
|
3
3
|
/** Convert a {@link StructPayload} Map to a plain JSON-compatible object. */
|
|
4
4
|
function structPayloadToJson(payload) {
|
|
@@ -9,4 +9,4 @@ function structPayloadToJson(payload) {
|
|
|
9
9
|
return result;
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
|
12
|
-
export { ControlRecordType, KnownStructTypeName, RecordType, catalogEntries, decodeRecords, isDataRecord, parseStructSpecification, readRecords, structPayloadToJson };
|
|
12
|
+
export { ControlRecordType, KnownStructTypeName, RecordType, catalogEntries, decodeRecords, isDataRecord, parseDataLog, parseStructSpecification, readRecords, structPayloadToJson };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wpilog-parser",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.1",
|
|
4
4
|
"description": "Read WPILib wpilog data log files in TypeScript & JavaScript",
|
|
5
5
|
"homepage": "https://github.com/jonahsnider/wpilog-parser#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -42,14 +42,22 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@toon-format/toon": "^4.1.1",
|
|
44
44
|
"cac": "^7.0.0",
|
|
45
|
-
"chevrotain": "^13.0.0"
|
|
45
|
+
"chevrotain": "^13.0.0",
|
|
46
|
+
"nostics": "^1.3.0"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@codspeed/vitest-plugin": "5.7.1",
|
|
49
|
-
"@types/node": "26.
|
|
50
|
+
"@types/node": "26.6.3",
|
|
50
51
|
"@typescript/native-preview": "7.0.0-dev.20260707.2",
|
|
51
52
|
"typescript": "7.0.2",
|
|
52
|
-
"vite-plus": "
|
|
53
|
+
"vite-plus": "catalog:",
|
|
54
|
+
"vitest": "catalog:"
|
|
53
55
|
},
|
|
54
|
-
"
|
|
56
|
+
"devEngines": {
|
|
57
|
+
"runtime": {
|
|
58
|
+
"name": "node",
|
|
59
|
+
"version": "26.x"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"packageManager": "pnpm@12.6.0"
|
|
55
63
|
}
|
|
@@ -22,15 +22,15 @@ WPILOG is the binary log format used by logging libraries in the FRC ecosystem.
|
|
|
22
22
|
|
|
23
23
|
## Analyzing logs
|
|
24
24
|
|
|
25
|
-
Use `
|
|
25
|
+
Use `parseDataLog` to parse DataLog bytes. Filter by `name` and narrow on `type`:
|
|
26
26
|
|
|
27
27
|
```ts
|
|
28
28
|
import { readFile } from 'node:fs/promises';
|
|
29
|
-
import {
|
|
29
|
+
import { isDataRecord, parseDataLog, RecordType } from 'wpilog-parser';
|
|
30
30
|
|
|
31
31
|
const bytes = await readFile('./example.wpilog');
|
|
32
32
|
|
|
33
|
-
for (const record of
|
|
33
|
+
for (const record of parseDataLog(bytes)) {
|
|
34
34
|
if (!isDataRecord(record)) continue;
|
|
35
35
|
|
|
36
36
|
if (record.name === '/Robot/Intake/Voltage' && record.type === RecordType.Double) {
|
|
@@ -42,9 +42,9 @@ for (const record of decodeRecords(readRecords(bytes))) {
|
|
|
42
42
|
### Decoding structs
|
|
43
43
|
|
|
44
44
|
```ts
|
|
45
|
-
import {
|
|
45
|
+
import { parseDataLog, RecordType, structPayloadToJson } from 'wpilog-parser';
|
|
46
46
|
|
|
47
|
-
for (const record of
|
|
47
|
+
for (const record of parseDataLog(bytes)) {
|
|
48
48
|
if (record.type === RecordType.Struct && record.name === '/Robot/Localization/EstimatedPose') {
|
|
49
49
|
console.log(record.timestamp, structPayloadToJson(record.payload));
|
|
50
50
|
// 18688018n {
|
|
@@ -58,7 +58,7 @@ for (const record of decodeRecords(readRecords(bytes))) {
|
|
|
58
58
|
### Strict mode
|
|
59
59
|
|
|
60
60
|
```ts
|
|
61
|
-
for (const record of
|
|
61
|
+
for (const record of parseDataLog(bytes, { strict: true })) {
|
|
62
62
|
// throws on orphan data records instead of skipping
|
|
63
63
|
}
|
|
64
64
|
```
|
|
@@ -79,7 +79,7 @@ The mode flags (`autonomous`, `test`) reflect what the DS _would_ run if enabled
|
|
|
79
79
|
### Tracking enable/mode durations
|
|
80
80
|
|
|
81
81
|
```ts
|
|
82
|
-
import {
|
|
82
|
+
import { isDataRecord, parseDataLog, RecordType } from 'wpilog-parser';
|
|
83
83
|
|
|
84
84
|
type Mode = 'auto' | 'teleop' | 'test';
|
|
85
85
|
function modeOf(auto: boolean, test: boolean): Mode {
|
|
@@ -94,7 +94,7 @@ let test = false;
|
|
|
94
94
|
let enabledSince: bigint | null = null;
|
|
95
95
|
const totals = { auto: 0n, teleop: 0n, test: 0n };
|
|
96
96
|
|
|
97
|
-
for (const r of
|
|
97
|
+
for (const r of parseDataLog(bytes)) {
|
|
98
98
|
if (!isDataRecord(r) || r.type !== RecordType.Boolean) continue;
|
|
99
99
|
|
|
100
100
|
const wasEnabled = enabled;
|