@kymoscope/sdk 0.20.0 → 0.21.0

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.
Files changed (34) hide show
  1. package/dist/assets/importer.worker-jzXF4fDD.js +1040 -0
  2. package/dist/importer-DhJq-CnQ.js +12 -0
  3. package/dist/importers-C8Byhb42.js +1036 -0
  4. package/dist/kymoscope-embed.js +104 -72
  5. package/dist/kymoscope-sdk.js +86 -86
  6. package/dist/types/engine/createEngine.d.ts +2 -0
  7. package/dist/types/engine/types.d.ts +2 -0
  8. package/dist/types/lib/beacon.d.ts +6 -0
  9. package/dist/types/lib/importers/ccsds/format.d.ts +2 -0
  10. package/dist/types/lib/importers/ccsds/frames.d.ts +67 -0
  11. package/dist/types/lib/importers/ccsds/importer.d.ts +2 -0
  12. package/dist/types/lib/importers/ccsds/packets.d.ts +49 -0
  13. package/dist/types/lib/importers/ccsds/xtce.d.ts +79 -0
  14. package/dist/types/lib/importers/ch10/format.d.ts +10 -0
  15. package/dist/types/lib/importers/ch10/importer.d.ts +2 -0
  16. package/dist/types/lib/importers/ch10/packets.d.ts +46 -0
  17. package/dist/types/lib/importers/ch10/pcm.d.ts +59 -0
  18. package/dist/types/lib/importers/ch10/tmats.d.ts +93 -0
  19. package/dist/types/lib/importers/combine.d.ts +2 -1
  20. package/dist/types/lib/importers/formats.d.ts +2 -0
  21. package/dist/types/lib/importers/iena/format.d.ts +9 -0
  22. package/dist/types/lib/importers/iena/importer.d.ts +2 -0
  23. package/dist/types/lib/importers/iena/layout.d.ts +58 -0
  24. package/dist/types/lib/importers/iena/pcap.d.ts +48 -0
  25. package/dist/types/lib/importers/iena/xidml.d.ts +29 -0
  26. package/dist/types/lib/importers/pqdif/records.d.ts +29 -9
  27. package/dist/types/lib/importers/table/long.d.ts +7 -0
  28. package/dist/types/lib/importers/table/table.d.ts +7 -0
  29. package/dist/types/lib/importers/types.d.ts +7 -1
  30. package/dist/types/types/loadedDataset.d.ts +4 -0
  31. package/package.json +3 -1
  32. package/dist/assets/importer.worker-B4rzpZKn.js +0 -1006
  33. package/dist/importer-D_Rxf-9b.js +0 -12
  34. package/dist/importers-D4cCElZQ.js +0 -1004
@@ -140,6 +140,8 @@ export declare function createEngine(options?: EngineOptions): {
140
140
  combine(id: string): Promise<string>;
141
141
  /** A file opened with one channel per tag (one row per sample) opened again as the table it is. Returns the new ids. */
142
142
  openAsTable(id: string): Promise<string[]>;
143
+ /** A long-form file opened as a table (`openAsTable`) opened again as one channel per tag. Returns the new ids. */
144
+ openAsChannels(id: string): Promise<string[]>;
143
145
  /**
144
146
  * A cloud recording as a dataset: its encrypted chunks (KRC1, in order) decrypted with `keys` in the import
145
147
  * worker, in memory or out of core like a file. Returns the id.
@@ -112,6 +112,8 @@ export interface DatasetInfo {
112
112
  parseConfig: DatasetParseConfig | null;
113
113
  /** Binary files: format, start time, groups (with rates), events; null for text. */
114
114
  fileInfo: DatasetFileInfo | null;
115
+ /** A long-form file opened as a table (datasets.openAsTable): datasets.openAsChannels opens it again as one channel per tag. */
116
+ fromLong: boolean;
115
117
  beacon: BeaconConfig | null;
116
118
  /** The rule a dataset is cut by (datasets.cut), or null. */
117
119
  cut: {
@@ -47,6 +47,12 @@ export declare function guessBeaconChannel(rows: DatasetRow[], cols: string[]):
47
47
  * time channel (the lap time) when there is one, else by its own span.
48
48
  */
49
49
  export declare function suggestBeacon(rows: DatasetRow[], cols: string[], preferred?: BeaconConfig | null): BeaconConfig | null;
50
+ /**
51
+ * Counters by name: sequence counters, timestamps' fields (`header.stamp.nanosec`, a
52
+ * leaf named `sec`) and raw words or bytes (`RAW_W`, `… w3`, `raw/b12`). They wrap,
53
+ * so they look like cycles, but splitting on them means nothing.
54
+ */
55
+ export declare function counterName(col: string): boolean;
50
56
  /** `stat` of the numeric values of `col` in rows[start, end); null if none. */
51
57
  export declare function lapMetric(rows: DatasetRow[], lap: LapRange, col: string, stat: BeaconStat): number | null;
52
58
  /**
@@ -0,0 +1,2 @@
1
+ import type { FormatInfo } from '../formats';
2
+ export declare const CCSDS_FORMAT: FormatInfo;
@@ -0,0 +1,67 @@
1
+ import { type Segments } from './packets';
2
+ /**
3
+ * CCSDS TM Transfer Frames (132.0-B-3) after their attached sync marker (131.0-B-4, 9.3: 0x1ACFFC1D), optionally
4
+ * pseudo-randomized (131.0-B-4, 10: h(x) = x^8 + x^7 + x^5 + x^3 + 1, all ones at each frame's start; first bytes
5
+ * FF 48 0E C0 9A). Primary header: version (2 bits, 0), spacecraft id (10), VC id (3), OCF flag (1), master channel
6
+ * frame count (8), VC frame count (8), data field status (secondary header flag, sync flag, packet order flag, segment
7
+ * length id (2), first header pointer (11; 0x7FF no packet starts here, 0x7FE idle data)); an optional secondary header
8
+ * (its first byte: version (2), length − 1 (6)); the data field; the OCF (4 bytes); the FECF (2, CRC-16-CCITT).
9
+ * Reed-Solomon check symbols are not corrected (a CADU of 255·I + 4 bytes is read as a frame of 223·I or 239·I when
10
+ * its FECF or its first header pointers say so).
11
+ */
12
+ export declare const ASM: Uint8Array<ArrayBuffer>;
13
+ export declare const MIN_FRAME = 7;
14
+ export declare const MAX_FRAME = 65536;
15
+ export declare const PN: Uint8Array<ArrayBuffer>;
16
+ /** CRC-16-CCITT (polynomial 0x1021, initial 0xFFFF, no final XOR) over b[o, o + n); 0 over a frame with its FECF. */
17
+ export declare function crc16(b: Uint8Array, o: number, n: number): number;
18
+ export declare const asmAt: (b: Uint8Array, o: number) => boolean;
19
+ /** The next ASM at or after `from`, or -1. */
20
+ export declare function nextAsm(b: Uint8Array, from: number): number;
21
+ export interface Shape {
22
+ /** First ASM in the file. */
23
+ start: number;
24
+ cadu: number;
25
+ frame: number;
26
+ randomized: boolean;
27
+ fecf: boolean;
28
+ /** The transfer frame version the headers carry (0: TM; 1: AOS; 12 (4 bits): USLP). */
29
+ version: number;
30
+ scid: number;
31
+ }
32
+ /** An ASM at b[o] with at most 2 bits wrong. */
33
+ export declare function asmNear(b: Uint8Array, o: number): boolean;
34
+ /**
35
+ * A CADU stream: ASMs at one spacing (the smallest at which 90 % of the head's CADUs, three at least, carry one, a
36
+ * few bits wrong allowed); its frames plain or randomized, whichever gives TM headers of one spacecraft with frame
37
+ * counts stepping by one (or else AOS or USLP headers throughout, named to be refused); the frame length (spacing − 4,
38
+ * or 223·I or 239·I inside a Reed-Solomon CADU of 255·I + 4 bytes) the one whose FECF checks, else (Reed-Solomon
39
+ * sizes) the one whose first header pointers agree with the packets of the frame before, 223·I if none tells.
40
+ */
41
+ export declare function frameShape(head: Uint8Array): Shape | null;
42
+ export interface FrameStats {
43
+ frames: number;
44
+ vcs: Set<number>;
45
+ badFecf: number;
46
+ /** Frame-count gaps per VC: [gaps, frames missing]. */
47
+ gaps: Map<number, [number, number]>;
48
+ idleFrames: number;
49
+ /** Partial packets dropped (a gap, a frame skipped, a first header pointer that disagrees). */
50
+ partial: number;
51
+ /** Frames whose header or data field status cannot be right (another spacecraft or version, a pointer past the data). */
52
+ damaged: number;
53
+ /** Frames carrying VCA data (sync flag) rather than packets. */
54
+ notPackets: number;
55
+ /** Bytes between CADUs where no ASM was (sync lost). */
56
+ outOfSync: number;
57
+ /** Frames skipped for a damaged ASM (a few bits wrong where one should be). */
58
+ badSync: number;
59
+ }
60
+ export declare const newFrameStats: () => FrameStats;
61
+ /** Packets out of the frames of one spacecraft, reassembled per virtual channel. */
62
+ export declare class Frames {
63
+ #private;
64
+ constructor(shape: Shape, seg: Segments, stats: FrameStats);
65
+ /** One frame f[0, frame) (derandomized). */
66
+ frame(f: Uint8Array): void;
67
+ }
@@ -0,0 +1,2 @@
1
+ import { type Importer } from '../types';
2
+ export declare const ccsdsImporter: Importer;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * CCSDS Space Packets (CCSDS 133.0-B-2, 4.1): a 6-byte primary header, big-endian — version (3 bits, 0), type (1),
3
+ * secondary header flag (1), APID (11), sequence flags (2: 01 first, 00 continuation, 10 last, 11 unsegmented),
4
+ * sequence count (14), packet data length − 1 (16) — then the data field. APID 0x7FF: idle packets.
5
+ */
6
+ export declare const HEADER = 6;
7
+ /** 6 header bytes and at most 65,536 data bytes. */
8
+ export declare const MAX_PACKET = 65542;
9
+ export declare const IDLE_APID = 2047;
10
+ export declare const versionOk: (b: Uint8Array, o: number) => boolean;
11
+ export declare const apidOf: (b: Uint8Array, o: number) => number;
12
+ export declare const flagsOf: (b: Uint8Array, o: number) => number;
13
+ export declare const countOf: (b: Uint8Array, o: number) => number;
14
+ /** The whole packet's length in bytes. */
15
+ export declare const lengthOf: (b: Uint8Array, o: number) => number;
16
+ /** A complete packet b[o, o + n): its header from the first segment, its data field all segments' data fields. */
17
+ export type PacketSink = (b: Uint8Array, o: number, n: number) => void;
18
+ export interface PacketStats {
19
+ idle: number;
20
+ /** Segments that arrived out of order (a continuation with no first segment, a first one while one is open). */
21
+ segments: number;
22
+ /** Bytes of a packet file that hold no packet (skipped to resynchronise). */
23
+ skipped: number;
24
+ /** The file ends inside a packet or frame. */
25
+ cut: boolean;
26
+ }
27
+ export declare const newPacketStats: () => PacketStats;
28
+ /**
29
+ * Idle packets dropped, segmented packets reassembled per APID (bounded by 65,542 bytes each, so by the bytes read),
30
+ * every other packet handed on as it is.
31
+ */
32
+ export declare class Segments {
33
+ #private;
34
+ constructor(sink: PacketSink, stats: PacketStats);
35
+ push(b: Uint8Array, o: number, n: number): void;
36
+ }
37
+ /**
38
+ * Packets of a packet file's bytes b[0, end): consecutive headers chained by their lengths. A byte that cannot start
39
+ * a packet (version not 0) is skipped (counted); after a skip a header is trusted only when the next one chains too.
40
+ * Returns where it stopped: a packet that does not end inside b waits for more bytes (`last`: the file ends there).
41
+ */
42
+ export declare function splitPackets(b: Uint8Array, seg: Segments, stats: PacketStats, last: boolean, resync: {
43
+ on: boolean;
44
+ }): number;
45
+ /**
46
+ * At least `min` headers chained from b[0] through `b`'s first 4 KB (or its first `min` packets; version 0, each length leading to the next); and some APID's sequence count stepping by one, so zeros or a table of small
47
+ * records do not pass.
48
+ */
49
+ export declare function packetChain(b: Uint8Array, min?: number): boolean;
@@ -0,0 +1,79 @@
1
+ /**
2
+ * XTCE (OMG XML Telemetric and Command Exchange 1.2, also 1.1) as a packet dictionary — the subset read here:
3
+ * the SpaceSystem tree (references by path, relative or absolute, else by name); SequenceContainers with base
4
+ * containers and RestrictionCriteria (Comparison, ComparisonList, BooleanExpression of Conditions ANDed and ORed;
5
+ * a packet's container found depth-first, backing out of dead ends); ParameterRefEntry and ContainerRefEntry, at
6
+ * LocationInContainerInBits from the previous entry or the container start, with simple IncludeConditions;
7
+ * IntegerDataEncoding (unsigned, twosComplement (also spelt twosCompliment), signMagnitude, onesComplement; byte order), FloatDataEncoding (IEEE
8
+ * 754, 32 and 64 bits); Integer, Float, Boolean, Enumerated (numeric values) and AbsoluteTime / RelativeTime parameter
9
+ * types; units; Polynomial and Spline calibrators. Positions count from the packet's first bit (the root container
10
+ * describes the primary header); inherited entries share their container start, a ContainerRefEntry starts its own.
11
+ * Anything else is named in a note: a parameter it cannot decode but whose size is fixed is stepped over; one of no
12
+ * fixed size (or an entry it does not read) ends what the container's following entries can locate: those up to the
13
+ * next containerStart location are not channels (named in a note).
14
+ */
15
+ export declare class XtceError extends Error {
16
+ }
17
+ type Read = (b: Uint8Array, bit: number) => number;
18
+ export interface Param {
19
+ name: string;
20
+ unit: string;
21
+ /** Bits it takes; -1 when it has no fixed size. */
22
+ bits: number;
23
+ /** null: not decoded (stepped over when its size is fixed). */
24
+ read: Read | null;
25
+ cal: ((x: number) => number) | null;
26
+ kind: 'number' | 'enum' | 'bool' | 'time';
27
+ /** Enum labels; for a boolean its zero and one strings. */
28
+ labels: [string, number][];
29
+ /** An absolute time's seconds → Unix seconds (UTC). */
30
+ time: ((s: number) => number) | null;
31
+ }
32
+ interface Cmp {
33
+ p: number;
34
+ cal: boolean;
35
+ op: string;
36
+ v: number;
37
+ }
38
+ /** A comparison, or comparisons all (and) or any (not and) of which hold. */
39
+ type Cond = Cmp | {
40
+ and: boolean;
41
+ of: Cond[];
42
+ };
43
+ interface Entry {
44
+ p: number;
45
+ c: number;
46
+ abs: number;
47
+ rel: number;
48
+ cond: Cond | null;
49
+ stop: boolean;
50
+ }
51
+ export interface Container {
52
+ name: string;
53
+ abstract: boolean;
54
+ base: number;
55
+ never: boolean;
56
+ restrict: Cond | null;
57
+ entries: Entry[];
58
+ kids: number[];
59
+ }
60
+ export declare class Xtce {
61
+ #private;
62
+ params: Param[];
63
+ containers: Container[];
64
+ roots: number[];
65
+ /** Per container: its channels (parameter indices, the time parameter left out) and its time parameter (-1: none). */
66
+ chans: number[][];
67
+ timeParam: number[];
68
+ notes: string[];
69
+ /** The last packet ran past its end inside its container. */
70
+ short: boolean;
71
+ constructor(xml: string);
72
+ /** The concrete container a packet b[o, o + n) matches (its values decoded), or -1. */
73
+ decode(b: Uint8Array, o: number, n: number): number;
74
+ /** A parameter's value in the packet just decoded (calibrated; enums and booleans as numbers), NaN when absent. */
75
+ value(p: number): number;
76
+ /** The packet's time (Unix seconds) for container `c`; NaN without one. */
77
+ time(c: number): number;
78
+ }
79
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { FormatInfo } from '../formats';
2
+ /** Packet length bound (IRIG 106-17 11.2.1.1.d): 524,288 bytes; TMATS (data type 0x01) up to 128 MB. */
3
+ export declare const MAX_PACKET = 524288;
4
+ export declare const MAX_TMATS_PACKET: number;
5
+ /**
6
+ * A plausible packet header at `o` (IRIG 106-17 11.2.1.1): sync 0xEB25, the 16-bit sum of its first 11 words in
7
+ * the 12th, a packet length holding its headers and data.
8
+ */
9
+ export declare function headerAt(b: Uint8Array, o: number): boolean;
10
+ export declare const CH10_FORMAT: FormatInfo;
@@ -0,0 +1,2 @@
1
+ import { type Importer } from '../types';
2
+ export declare const ch10Importer: Importer;
@@ -0,0 +1,46 @@
1
+ import type { BlobReader } from '../blobReader';
2
+ /**
3
+ * Packets of a Chapter 10 file in file order (IRIG 106-17 11.2.1), read through 16 MB windows. A header that
4
+ * fails its checksum is skipped by resynchronising on the next sync with a valid header; a packet whose
5
+ * secondary header or data checksum fails is skipped whole. Both are counted. A valid header whose packet runs
6
+ * past the end of the file ends the walk (the file was cut).
7
+ * Deterministic: plan and stream see the same packets.
8
+ */
9
+ /** One packet; the object is reused, `b` valid only during the callback. */
10
+ export interface Packet {
11
+ b: Uint8Array;
12
+ dv: DataView;
13
+ /** Packet start in `b`; its body (channel-specific data word first) is at `o + hdr`. */
14
+ o: number;
15
+ at: number;
16
+ ch: number;
17
+ type: number;
18
+ flags: number;
19
+ rtc: number;
20
+ hdr: number;
21
+ dlen: number;
22
+ }
23
+ export interface WalkStats {
24
+ /** Header resynchronisations (damaged headers) and packets failing a checksum. */
25
+ damaged: number;
26
+ /** Bytes at the end that are not a whole packet. */
27
+ cut: boolean;
28
+ }
29
+ export declare function walk(io: BlobReader, on: (p: Packet) => void, stats: WalkStats, signal?: AbortSignal): AsyncGenerator<void>;
30
+ /**
31
+ * An intra-packet time stamp at `at` as a 10 MHz RTC value: the RTC itself, or (packet flags bit 6) the
32
+ * secondary-header time format, mapped through the packet's own secondary header time and RTC.
33
+ */
34
+ export declare function iptsRtc(p: Packet, at: number): number;
35
+ /**
36
+ * A time packet (data type 0x11, format 1): its clock time as ms since 1970, or null when its payload is not a
37
+ * time (format or source NONE, digits that are not BCD). Day-of-year time has no year: `doy.year` (from TMATS)
38
+ * is used, and the next one from the day the days start again at 1 after 365 or 366 (`doy.day`: the last day).
39
+ */
40
+ export declare function timeOf(p: Packet, doy: {
41
+ year: number;
42
+ day: number;
43
+ }): {
44
+ ms: number;
45
+ hasYear: boolean;
46
+ } | null;
@@ -0,0 +1,59 @@
1
+ import { type Conversion, type Param, type PcmFormat } from './tmats';
2
+ /**
3
+ * PCM minor frames (IRIG 106-17 11.2.2.2, Chapter 4): where each word is in a frame for each packing mode,
4
+ * frames found by their sync pattern in throughput mode, the minor frame number from the subframe ID counter,
5
+ * a parameter's value from its fragments.
6
+ *
7
+ * Bits are read msb first. Packet data is 16-bit (or 32-bit) little-endian words whose msb is the first bit
8
+ * sent, so the n-th byte of the bit stream is at `base + (n ^ xor)` (xor 1 or 3).
9
+ */
10
+ /**
11
+ * Bit offset of each word (sync first) in a frame, and the frame's bytes in the packet. Packed frames: the bits
12
+ * from `tail` on (the frame's last bits, short of a whole 16- or 32-bit unit) are `fill` bits further on.
13
+ */
14
+ export interface Layout {
15
+ offsets: number[];
16
+ frameBytes: number;
17
+ tail: number;
18
+ fill: number;
19
+ }
20
+ /**
21
+ * Packed (and throughput): words back to back. A frame that is not a whole number of 16- or 32-bit units ends
22
+ * in a unit holding its last bits in the low bits, filler in the high bits (IRIG 106-17 Tables 11-8, 11-9).
23
+ */
24
+ export declare function packedLayout(f: PcmFormat, align: number): Layout;
25
+ /**
26
+ * Unpacked: each word lsb-aligned in 16-bit units (a sync over 16 bits split in two words, over 32 in
27
+ * 16- or 32-bit words); in 32-bit alignment a zero 16-bit word makes the count even.
28
+ */
29
+ export declare function unpackedLayout(f: PcmFormat, align: number): Layout;
30
+ /** `n` (≤ 64) bits from bit `bit` of the stream, msb first; above 53 bits the lowest are lost. */
31
+ export declare function readBits(b: Uint8Array, base: number, xor: number, bit: number, n: number): number;
32
+ /** Little-endian bit field (analog packing, lsb first). */
33
+ export declare function readLE(b: Uint8Array, base: number, bit: number, n: number): number;
34
+ /** One frame in a buffer: its stream starts at `bit0` of `base` (bytes at `base + (n ^ xor)`); `Layout` tail. */
35
+ export interface Frame {
36
+ b: Uint8Array;
37
+ base: number;
38
+ xor: number;
39
+ bit0: number;
40
+ offsets: number[];
41
+ tail: number;
42
+ fill: number;
43
+ }
44
+ /** Word `w` (`n` bits) of a frame; a word running into a packed frame's tail is read in two parts. */
45
+ export declare function wordBits(fr: Frame, w: number, n: number): number;
46
+ /** A parameter compiled for reading: value of occurrence words → engineering units. */
47
+ export declare function paramReader(f: PcmFormat, p: Param, conv: Conversion | undefined): (fr: Frame, words: number[]) => number;
48
+ /** The minor frame number (1..mfn) from the subframe ID counter; 0 when the count is not one of the frame's. */
49
+ export declare function counterFrame(f: PcmFormat, fr: Frame): number;
50
+ /**
51
+ * Throughput mode: the bit stream of a channel across packets, minor frames found by their sync pattern
52
+ * (fixed pattern, 'X' bits not compared) and followed frame to frame while it repeats; a frame's time is its
53
+ * packet's time plus its bit offset over the bit rate.
54
+ */
55
+ export declare class Framer {
56
+ #private;
57
+ constructor(f: PcmFormat);
58
+ push(b: Uint8Array, base: number, nbytes: number, xor: number, sec: number, emit: (fr: Frame, sec: number) => void): void;
59
+ }
@@ -0,0 +1,93 @@
1
+ /**
2
+ * TMATS (IRIG 106-17 Chapter 9), computer-generated format: `CODE:value;` attributes. Read: G (program, date),
3
+ * R (recorder channels: ids, names, types, analog and discrete measurements), P (PCM formats), D (PCM
4
+ * measurement lists, word-and-frame locations), C (units, binary format, conversions). Everything else ignored.
5
+ */
6
+ /** Setup record text read at most (spec: 1 MB). */
7
+ export declare const MAX_TMATS: number;
8
+ export type Attrs = Map<string, string>;
9
+ export declare function parseTmats(text: string): Attrs;
10
+ /** The year of the setup record's dates (G\OD, else G\UD or G\RD; MM-DD-YYYY): day-of-year time has none. */
11
+ export declare function tmatsYear(a: Attrs): number | null;
12
+ export interface Conversion {
13
+ unit: string;
14
+ /** C-d\BFM (or the R-group's analog format): UNS, TWO, OFF, ONE, SIG, SIM, FPT, BCD, INT... */
15
+ bfm: string | null;
16
+ /** C-d\FPF when the format is FPT. */
17
+ fpf: string | null;
18
+ /** Engineering units from the raw value; null = none. */
19
+ apply: ((x: number) => number) | null;
20
+ /** What could not be applied (conversion or format), for a note. */
21
+ unsupported: string | null;
22
+ }
23
+ /** Conversions by measurement name (C-d\DCN). */
24
+ export declare function conversions(a: Attrs): Map<string, Conversion>;
25
+ /**
26
+ * A raw value of `n` bits in a binary format, as a number (NaN when the format cannot be read). Values above 53
27
+ * bits lose their lowest bits.
28
+ */
29
+ export declare function decodeFormat(v: number, n: number, bfm: string | null, fpf: string | null): number;
30
+ /** Formats `decodeFormat` reads ('FPT' only as IEEE 754 single precision). */
31
+ export declare const formatKnown: (bfm: string | null, fpf: string | null) => boolean;
32
+ export interface Measurement {
33
+ name: string; /** Bits used, from the msb (mask), or null for the full word. */
34
+ mask: string | null;
35
+ }
36
+ export interface RChannel {
37
+ id: number;
38
+ name: string;
39
+ type: string;
40
+ dln: string;
41
+ /** Analog sample rate of the fastest subchannel (R-x\ASR). */
42
+ rate: number | null;
43
+ /** Analog subchannels by number: measurement name and R-group format (R-x\AF as a C-group BFM). */
44
+ analog: Map<number, {
45
+ name: string;
46
+ bfm: string | null;
47
+ }>;
48
+ /** Discrete measurements (R-x\DMN, R-x\DMSK). */
49
+ discrete: Measurement[];
50
+ }
51
+ export declare function recorderChannels(a: Attrs): Map<number, RChannel>;
52
+ /** Where a parameter's value is in one minor frame: its words (most significant fragment first). */
53
+ export interface Occurrence {
54
+ frame: number;
55
+ words: number[];
56
+ }
57
+ export interface Param {
58
+ name: string;
59
+ /** Per fragment, most significant first: bit mask (msb-left, null = full word) and whether sent lsb first. */
60
+ frags: {
61
+ mask: string | null;
62
+ lsbFirst: boolean;
63
+ }[];
64
+ occ: Occurrence[];
65
+ }
66
+ export interface IdCounter {
67
+ word: number;
68
+ shift: number;
69
+ len: number;
70
+ lsbFirst: boolean;
71
+ init: number;
72
+ end: number;
73
+ initFrame: number;
74
+ dec: boolean;
75
+ }
76
+ export interface PcmFormat {
77
+ dln: string;
78
+ /** Minor frames per major frame. */
79
+ mfn: number;
80
+ /** Bit widths: [sync, word 1, ..., word MF1-1]. */
81
+ widths: number[];
82
+ /** Bits per minor frame (P-d\MF2, at least the words' sum). */
83
+ frameBits: number;
84
+ /** Sync pattern, msb first: '0', '1' or 'X'. */
85
+ sync: string;
86
+ bitRate: number | null;
87
+ /** Words sent lsb first by default (P-d\F2). */
88
+ lsbFirst: boolean;
89
+ idc: IdCounter | null;
90
+ params: Param[];
91
+ }
92
+ /** PCM formats by data link name; `skip` collects what was left out, with why. */
93
+ export declare function pcmFormats(a: Attrs, skip: (what: string) => void): Map<string, PcmFormat>;
@@ -21,7 +21,8 @@ export declare function batchTime(b: Batch, g: PlanGroup): Float64Array;
21
21
  /**
22
22
  * Groups onto one time base, streaming: the fastest regular group (most
23
23
  * samples) plus every irregular group (their union) are the time base; the
24
- * others hold their last value (zero-order hold). A chunk covers the rows up to
24
+ * others hold their last value (zero-order hold), and their rows after the
25
+ * time base ends join it. A chunk covers the rows up to
25
26
  * H, the earliest last-buffered time of the time-base groups, so memory stays
26
27
  * at about one batch per group whatever the file size. Returns the row count.
27
28
  */
@@ -14,6 +14,8 @@ export interface FormatInfo {
14
14
  anyName?: boolean;
15
15
  }[];
16
16
  sniff(head: Uint8Array, name: string): boolean;
17
+ /** Bytes `sniff` needs for a file whose first HEAD_BYTES it is given here (a capture's magic), when more than those. */
18
+ sniffBytes?(head: Uint8Array): number;
17
19
  }
18
20
  /** Bytes read from each file to recognise it. */
19
21
  export declare const HEAD_BYTES = 4096;
@@ -0,0 +1,9 @@
1
+ import type { FormatInfo } from '../formats';
2
+ /** The default IENA end field (Airbus IENA specification RP0701637, 2.5): "unique value for all keys", 0xDEAD. */
3
+ export declare const END = 57005;
4
+ /**
5
+ * An IENA packet filling the datagram b[o, o + n): a 14-byte header and the end field, its size field (16-bit words,
6
+ * header and end included) the datagram's length, its end field 0xDEAD or `end`.
7
+ */
8
+ export declare function isIena(b: Uint8Array, o: number, n: number, end?: number): boolean;
9
+ export declare const IENA_FORMAT: FormatInfo;
@@ -0,0 +1,2 @@
1
+ import { type Importer } from '../types';
2
+ export declare const ienaImporter: Importer;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * The dictionary model both XidML and the collector layout compile to, and the collector layout itself: the format of
3
+ * the collector's `udp` source (kymoscope_collector/udp_source.py: compile_layout, _from_csv, _decode), so one file
4
+ * decodes IENA from a capture and live. Offsets are from the start of the UDP payload, the IENA header included,
5
+ * exactly as the collector reads a datagram; the IENA key and time still come from the IENA header.
6
+ */
7
+ /** IENA parameter types (Airbus IENA specification RP0701637, 2.6). */
8
+ export type Kind = 'P' | 'D' | 'N' | 'M' | 'Q';
9
+ export interface Field {
10
+ name: string;
11
+ unit: string;
12
+ /** Bit offsets of its occurrences from the start of the packet. */
13
+ at: number[];
14
+ /** Occurrences equally spaced over the packet body (XidML Occurrences): at[0] + k * body bits / spread. */
15
+ spread?: number;
16
+ /** Bits read per occurrence. */
17
+ bits: number;
18
+ /** Occurrences are samples this many seconds apart (the collector's sample_rate_hz); else over the packet period. */
19
+ dt?: number;
20
+ /** The occurrence at absolute bit `bit` of `b` (inside the packet: the caller checks). */
21
+ read(b: Uint8Array, dv: DataView, bit: number): number;
22
+ }
23
+ export interface KeyDict {
24
+ name: string | null;
25
+ kind: Kind;
26
+ /** Positional parameters (XidML mappings, layout fields). */
27
+ fields: Field[];
28
+ /** A shorter packet is skipped (the collector drops it as "short packet"); 0: no check. */
29
+ minBytes: number;
30
+ /** Packets per second (XidML PackageRate). */
31
+ rate: number | null;
32
+ /** The end field, when not 0xDEAD. */
33
+ end: number | null;
34
+ }
35
+ export interface Dict {
36
+ source: 'XidML' | 'layout';
37
+ keys: Map<number, KeyDict>;
38
+ /** A layout without packet_id: every key. */
39
+ any: KeyDict | null;
40
+ /**
41
+ * A layout's packet_id: `keys` are its values, read from each datagram (its offset from the UDP payload start, type
42
+ * and endian), as the collector picks the packet; else `keys` are IENA keys.
43
+ */
44
+ pid?: {
45
+ off: number;
46
+ size: number;
47
+ read(dv: DataView, o: number): number;
48
+ };
49
+ notes: string[];
50
+ }
51
+ /** A dictionary file that is not one (or not one Kymoscope can use): noted, the capture read raw. */
52
+ export declare class DictError extends Error {
53
+ }
54
+ /** Parameter occurrences a dictionary may name in all (fields × counts × packets): a values budget per packet set. */
55
+ export declare const MAX_OCCURRENCES = 1000000;
56
+ export declare const tooMany: () => DictError;
57
+ /** A collector layout (.yaml / .yml / .csv) as a dictionary; DictError when it is not one. */
58
+ export declare function parseLayout(text: string, name: string): Dict;
@@ -0,0 +1,48 @@
1
+ import type { BlobReader } from '../blobReader';
2
+ /**
3
+ * UDP datagrams of a packet capture: pcap (both byte orders, µs and ns timestamps) and pcapng (SHB, IDB, EPB, SPB;
4
+ * per-interface link type, timestamp resolution and offset). Link types Ethernet (802.1Q / QinQ tags), Linux cooked
5
+ * (SLL, SLL2) and raw IP; IPv4 (fragments reassembled, bounded) and IPv6; UDP. One sync parser, fed windows of the
6
+ * file (16 MB, larger than any record it accepts) by `datagrams` or the head by the sniff. Deterministic.
7
+ */
8
+ /** Captured bytes per frame (snap length) accepted; a larger record is damage. */
9
+ export declare const MAX_SNAP: number;
10
+ /** One UDP datagram; `b` is valid only during the callback. */
11
+ export interface Datagram {
12
+ /** Capture time, ms since 1970 (NaN for a pcapng simple packet block before any timestamp). */
13
+ time: number;
14
+ sport: number;
15
+ dport: number;
16
+ b: Uint8Array;
17
+ /** Its payload: b[o, o + n). */
18
+ o: number;
19
+ n: number;
20
+ }
21
+ export interface CaptureStats {
22
+ frames: number;
23
+ /** Frames that are not UDP over IPv4/IPv6 (ARP, TCP, other link types). */
24
+ other: number;
25
+ /** Frames captured shorter than their IP/UDP lengths (snap length). */
26
+ truncated: number;
27
+ /** Fragmented datagrams never completed (or dropped from a full buffer). */
28
+ incomplete: number;
29
+ /** The capture ends inside a record. */
30
+ cut: boolean;
31
+ /** A record or block header the format does not allow: the rest of the file is not read. */
32
+ damagedAt: number | null;
33
+ }
34
+ export declare const newStats: () => CaptureStats;
35
+ export type CaptureKind = 'pcap' | 'pcapng';
36
+ export declare function captureKind(b: Uint8Array): CaptureKind | null;
37
+ export declare class Capture {
38
+ #private;
39
+ readonly stats: CaptureStats;
40
+ done: boolean;
41
+ constructor(on: (d: Datagram) => void, stats?: CaptureStats);
42
+ /** Parses the whole records of `b` (which starts at file offset `at`); returns the bytes it consumed. */
43
+ feed(b: Uint8Array, at: number): number;
44
+ /** The end of the file: datagrams still in pieces are incomplete. */
45
+ finish(): void;
46
+ }
47
+ /** Every UDP datagram of the capture, in file order; yields once per window. */
48
+ export declare function datagrams(io: BlobReader, on: (d: Datagram) => void, stats: CaptureStats, signal?: AbortSignal): AsyncGenerator<void>;
@@ -0,0 +1,29 @@
1
+ import { type Dict } from './layout';
2
+ /**
3
+ * XidML 3.x (xidml.org, XidML-3.0.1 schemas) as an IENA dictionary: `IENA` packages (and the older
4
+ * `IENA-Ethernet-UDP-Basic`) with their key, payload type, end word and rate; their mappings (parameter references or
5
+ * inline parameters at Offset_Words or Offset_Bits from the start of the packet, Occurrences equally spaced over the
6
+ * packet or several Location elements, NumberOfDataBits); parameters with size, data format (BitVector, OffsetBinary,
7
+ * TwosComplement, SignedMagnitude, BinaryCodedDecimal, IEEE-754 single and double), endianness, base unit, a
8
+ * ParameterUnit (scale, offset) and a Polynomial algorithm; a mapping's Justification, Mask and Complement. What else
9
+ * it names is noted, not read (Parity and FillValue are not checked).
10
+ */
11
+ export interface Node {
12
+ name: string;
13
+ attrs: string;
14
+ kids: Node[];
15
+ text: string;
16
+ }
17
+ /** A small XML tree (local names, no namespaces, DTDs skipped); linear in the text. */
18
+ export declare function parseXml(s: string): Node;
19
+ export declare const kid: (n: Node | undefined, name: string) => Node | undefined;
20
+ export declare const kidsOf: (n: Node | undefined, name: string) => Node[];
21
+ export declare const text: (n: Node | undefined, name: string) => string | undefined;
22
+ export declare const attr: (n: Node, name: string) => string | undefined;
23
+ /** Every descendant named `name` (iterative). */
24
+ export declare function all(n: Node, name: string): Node[];
25
+ export declare const numberOf: (s: string | undefined) => number | null;
26
+ /** Bits [pos, pos + n) of `b`, most significant first, as an unsigned number (n ≤ 53 exact). */
27
+ export declare function bitsAt(b: Uint8Array, pos: number, n: number): number;
28
+ export declare function parseXidml(xml: string): Dict;
29
+ export declare const hex: (k: number) => string;