nmea-web-serial 1.1.3 → 1.1.4
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/dist/nmea-web-serial.cjs +2 -4
- package/dist/nmea-web-serial.d.ts +107 -962
- package/dist/nmea-web-serial.js +247 -3395
- package/package.json +1 -2
- package/LICENSE +0 -21
- package/README.md +0 -275
- package/dist/nmea-web-serial.iife.js +0 -4
- package/dist/nmea-web-serial.umd.cjs +0 -4
|
@@ -1,19 +1,12 @@
|
|
|
1
|
-
import { ActionFunction } from 'xstate';
|
|
2
|
-
import { ActorRef } from 'xstate';
|
|
3
1
|
import { ActorRefFrom } from 'xstate';
|
|
4
2
|
import { ActorRefFromLogic } from 'xstate';
|
|
5
|
-
import { AnyActorRef } from 'xstate';
|
|
6
|
-
import { AnyEventObject } from 'xstate';
|
|
7
3
|
import { CallbackActorLogic } from 'xstate';
|
|
8
4
|
import { DBTPacket } from 'nmea-simple';
|
|
9
|
-
import { DoneActorEvent } from 'xstate';
|
|
10
|
-
import { ErrorActorEvent } from 'xstate';
|
|
11
5
|
import { EventObject } from 'xstate';
|
|
12
6
|
import { GGAPacket } from 'nmea-simple';
|
|
13
7
|
import { GLLPacket } from 'nmea-simple';
|
|
14
8
|
import { HDGPacket } from 'nmea-simple';
|
|
15
9
|
import { HDTPacket } from 'nmea-simple';
|
|
16
|
-
import { MachineSnapshot } from 'xstate';
|
|
17
10
|
import { MetaObject } from 'xstate';
|
|
18
11
|
import { NonReducibleUnknown } from 'xstate';
|
|
19
12
|
import { Packet } from 'nmea-simple';
|
|
@@ -21,9 +14,7 @@ import { PacketStub } from 'nmea-simple/dist/codecs/PacketStub';
|
|
|
21
14
|
import { PromiseActorLogic } from 'xstate';
|
|
22
15
|
import { RMCPacket } from 'nmea-simple';
|
|
23
16
|
import { StateMachine } from 'xstate';
|
|
24
|
-
import { StateValue } from 'xstate';
|
|
25
17
|
import { UnknownPacket } from 'nmea-simple/dist/codecs/UnknownPacket';
|
|
26
|
-
import { Values } from 'xstate';
|
|
27
18
|
import { VTGPacket } from 'nmea-simple';
|
|
28
19
|
import { ZDAPacket } from 'nmea-simple';
|
|
29
20
|
|
|
@@ -80,135 +71,109 @@ port: SerialPort;
|
|
|
80
71
|
}, EventObject>> | ActorRefFromLogic<PromiseActorLogic<void, {
|
|
81
72
|
port: SerialPort | null;
|
|
82
73
|
}, EventObject>> | undefined;
|
|
83
|
-
},
|
|
84
|
-
connectToSerial: {
|
|
74
|
+
}, {
|
|
85
75
|
src: "connectToSerial";
|
|
86
76
|
logic: PromiseActorLogic<SerialPort, {
|
|
87
77
|
baudRate: number;
|
|
88
78
|
}, EventObject>;
|
|
89
79
|
id: string | undefined;
|
|
90
|
-
}
|
|
91
|
-
readNmeaStream: {
|
|
80
|
+
} | {
|
|
92
81
|
src: "readNmeaStream";
|
|
93
82
|
logic: CallbackActorLogic<NmeaEvent, {
|
|
94
83
|
port: SerialPort;
|
|
95
84
|
}, EventObject>;
|
|
96
85
|
id: string | undefined;
|
|
97
|
-
}
|
|
98
|
-
closePort: {
|
|
86
|
+
} | {
|
|
99
87
|
src: "closePort";
|
|
100
88
|
logic: PromiseActorLogic<void, {
|
|
101
89
|
port: SerialPort | null;
|
|
102
90
|
}, EventObject>;
|
|
103
91
|
id: string | undefined;
|
|
104
|
-
}
|
|
105
|
-
}>, Values< {
|
|
106
|
-
setPort: {
|
|
92
|
+
}, {
|
|
107
93
|
type: "setPort";
|
|
108
94
|
params: {
|
|
109
95
|
port: SerialPort;
|
|
110
96
|
};
|
|
111
|
-
}
|
|
112
|
-
setError: {
|
|
97
|
+
} | {
|
|
113
98
|
type: "setError";
|
|
114
99
|
params: {
|
|
115
100
|
error: unknown;
|
|
116
101
|
};
|
|
117
|
-
}
|
|
118
|
-
logParsedData: {
|
|
102
|
+
} | {
|
|
119
103
|
type: "logParsedData";
|
|
120
104
|
params: {
|
|
121
105
|
packet: Packet;
|
|
122
106
|
};
|
|
123
|
-
}
|
|
124
|
-
storePacket: {
|
|
107
|
+
} | {
|
|
125
108
|
type: "storePacket";
|
|
126
109
|
params: {
|
|
127
110
|
packet: Packet;
|
|
128
111
|
};
|
|
129
|
-
}
|
|
130
|
-
clearError: {
|
|
112
|
+
} | {
|
|
131
113
|
type: "clearError";
|
|
132
114
|
params: {
|
|
133
115
|
error: string;
|
|
134
116
|
};
|
|
135
|
-
}
|
|
136
|
-
setFatalError: {
|
|
117
|
+
} | {
|
|
137
118
|
type: "setFatalError";
|
|
138
119
|
params: {
|
|
139
120
|
error: string;
|
|
140
121
|
};
|
|
141
|
-
}
|
|
142
|
-
disconnect: {
|
|
122
|
+
} | {
|
|
143
123
|
type: "disconnect";
|
|
144
124
|
params: NonReducibleUnknown;
|
|
145
|
-
}
|
|
146
|
-
setLogging: {
|
|
125
|
+
} | {
|
|
147
126
|
type: "setLogging";
|
|
148
127
|
params: {
|
|
149
128
|
enabled: boolean;
|
|
150
129
|
};
|
|
151
|
-
}
|
|
152
|
-
setBaudRate: {
|
|
130
|
+
} | {
|
|
153
131
|
type: "setBaudRate";
|
|
154
132
|
params: {
|
|
155
133
|
baudRate: number;
|
|
156
134
|
};
|
|
135
|
+
}, never, never, "error" | "disconnected" | "connecting" | "connected" | "disconnecting", string, NonReducibleUnknown, NonReducibleUnknown, EventObject, MetaObject, {
|
|
136
|
+
id: "nmea";
|
|
137
|
+
states: {
|
|
138
|
+
readonly disconnected: {};
|
|
139
|
+
readonly connecting: {};
|
|
140
|
+
readonly connected: {};
|
|
141
|
+
readonly disconnecting: {};
|
|
142
|
+
readonly error: {};
|
|
157
143
|
};
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
readonly type: "setBaudRate";
|
|
192
|
-
readonly params: ({ event }: {
|
|
193
|
-
context: NmeaContext<NavigationData, StoredPackets>;
|
|
194
|
-
event: {
|
|
195
|
-
type: "SET_BAUD_RATE";
|
|
196
|
-
baudRate: number;
|
|
197
|
-
};
|
|
198
|
-
}) => {
|
|
199
|
-
baudRate: number;
|
|
200
|
-
};
|
|
201
|
-
};
|
|
202
|
-
};
|
|
203
|
-
};
|
|
204
|
-
};
|
|
205
|
-
readonly connecting: {
|
|
206
|
-
readonly invoke: {
|
|
207
|
-
readonly id: "connectToSerial";
|
|
208
|
-
readonly src: "connectToSerial";
|
|
209
|
-
readonly input: ({ context }: {
|
|
210
|
-
context: NmeaContext<NavigationData, StoredPackets>;
|
|
211
|
-
event: {
|
|
144
|
+
}>;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Factory function to create an NMEA state machine with a generic adapter pattern.
|
|
148
|
+
*
|
|
149
|
+
* Creates an XState state machine that manages serial port connections, parses NMEA sentences,
|
|
150
|
+
* and transforms them into your application's data format using the provided adapter function.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* const machine = createNmeaMachine({
|
|
155
|
+
* adapter: computeNavigationData,
|
|
156
|
+
* allowedSentenceIds: ['GGA', 'RMC', 'VTG'],
|
|
157
|
+
* initialData: { time: null, position: null },
|
|
158
|
+
* initialPackets: {},
|
|
159
|
+
* });
|
|
160
|
+
*
|
|
161
|
+
* const actor = createActor(machine);
|
|
162
|
+
* actor.start();
|
|
163
|
+
* actor.send({ type: 'CONNECT' });
|
|
164
|
+
* ```
|
|
165
|
+
*
|
|
166
|
+
* @template TData - The type of computed/translated data stored in context.
|
|
167
|
+
* @template TPackets - The type of stored packets (typically a record of sentence ID to packet).
|
|
168
|
+
* @param config - Configuration for the machine including adapter function and initial values.
|
|
169
|
+
* @returns An XState state machine that can be used with `createActor` from XState.
|
|
170
|
+
*
|
|
171
|
+
* @remarks
|
|
172
|
+
* The returned machine is an XState state machine. Use it with XState's `createActor` to create
|
|
173
|
+
* an actor instance, or use the {@link NmeaClient} class for a simpler API that doesn't require
|
|
174
|
+
* direct XState knowledge.
|
|
175
|
+
*/
|
|
176
|
+
export declare function createNmeaMachine<TData, TPackets extends Record<string, PacketStub | undefined>>(config: NmeaMachineConfig<TData, TPackets>): StateMachine<NmeaContext<TData, TPackets>, {
|
|
212
177
|
type: "CONNECT";
|
|
213
178
|
} | {
|
|
214
179
|
type: "DISCONNECT";
|
|
@@ -231,903 +196,83 @@ enabled: boolean;
|
|
|
231
196
|
} | {
|
|
232
197
|
type: "SET_BAUD_RATE";
|
|
233
198
|
baudRate: number;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
type: "CONNECT";
|
|
237
|
-
} | {
|
|
238
|
-
type: "DISCONNECT";
|
|
239
|
-
} | {
|
|
240
|
-
type: "SERIAL.DATA";
|
|
241
|
-
data: Packet;
|
|
242
|
-
} | {
|
|
243
|
-
type: "SERIAL.ERROR";
|
|
244
|
-
error: string;
|
|
245
|
-
} | {
|
|
246
|
-
type: "FATAL_ERROR";
|
|
247
|
-
error: string;
|
|
248
|
-
} | {
|
|
249
|
-
type: "SERIAL.DISCONNECTED";
|
|
250
|
-
} | {
|
|
251
|
-
type: "STOP";
|
|
252
|
-
} | {
|
|
253
|
-
type: "SET_LOGGING";
|
|
254
|
-
enabled: boolean;
|
|
255
|
-
} | {
|
|
256
|
-
type: "SET_BAUD_RATE";
|
|
199
|
+
}, {
|
|
200
|
+
[x: string]: ActorRefFromLogic<PromiseActorLogic<SerialPort, {
|
|
257
201
|
baudRate: number;
|
|
258
|
-
},
|
|
259
|
-
|
|
260
|
-
} | {
|
|
261
|
-
|
|
262
|
-
} |
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
type: "FATAL_ERROR";
|
|
270
|
-
error: string;
|
|
271
|
-
} | {
|
|
272
|
-
type: "SERIAL.DISCONNECTED";
|
|
273
|
-
} | {
|
|
274
|
-
type: "STOP";
|
|
202
|
+
}, EventObject>> | ActorRefFromLogic<CallbackActorLogic<NmeaEvent, {
|
|
203
|
+
port: SerialPort;
|
|
204
|
+
}, EventObject>> | ActorRefFromLogic<PromiseActorLogic<void, {
|
|
205
|
+
port: SerialPort | null;
|
|
206
|
+
}, EventObject>> | undefined;
|
|
207
|
+
}, {
|
|
208
|
+
src: "connectToSerial";
|
|
209
|
+
logic: PromiseActorLogic<SerialPort, {
|
|
210
|
+
baudRate: number;
|
|
211
|
+
}, EventObject>;
|
|
212
|
+
id: string | undefined;
|
|
275
213
|
} | {
|
|
276
|
-
|
|
277
|
-
|
|
214
|
+
src: "readNmeaStream";
|
|
215
|
+
logic: CallbackActorLogic<NmeaEvent, {
|
|
216
|
+
port: SerialPort;
|
|
217
|
+
}, EventObject>;
|
|
218
|
+
id: string | undefined;
|
|
278
219
|
} | {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
readonly actions: {
|
|
288
|
-
readonly type: "setPort";
|
|
289
|
-
readonly params: ({ event }: {
|
|
290
|
-
context: NmeaContext<NavigationData, StoredPackets>;
|
|
291
|
-
event: DoneActorEvent<SerialPort, string>;
|
|
292
|
-
}) => {
|
|
220
|
+
src: "closePort";
|
|
221
|
+
logic: PromiseActorLogic<void, {
|
|
222
|
+
port: SerialPort | null;
|
|
223
|
+
}, EventObject>;
|
|
224
|
+
id: string | undefined;
|
|
225
|
+
}, {
|
|
226
|
+
type: "setPort";
|
|
227
|
+
params: {
|
|
293
228
|
port: SerialPort;
|
|
294
229
|
};
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
readonly target: "error";
|
|
299
|
-
readonly actions: {
|
|
300
|
-
readonly type: "setError";
|
|
301
|
-
readonly params: ({ event }: {
|
|
302
|
-
context: NmeaContext<NavigationData, StoredPackets>;
|
|
303
|
-
event: ErrorActorEvent<unknown, string>;
|
|
304
|
-
}) => {
|
|
230
|
+
} | {
|
|
231
|
+
type: "setError";
|
|
232
|
+
params: {
|
|
305
233
|
error: unknown;
|
|
306
234
|
};
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
};
|
|
311
|
-
readonly connected: {
|
|
312
|
-
readonly on: {
|
|
313
|
-
readonly 'SERIAL.DATA': {
|
|
314
|
-
readonly actions: readonly [{
|
|
315
|
-
readonly type: "logParsedData";
|
|
316
|
-
readonly params: ({ event }: {
|
|
317
|
-
context: NmeaContext<NavigationData, StoredPackets>;
|
|
318
|
-
event: {
|
|
319
|
-
type: "SERIAL.DATA";
|
|
320
|
-
data: Packet;
|
|
321
|
-
};
|
|
322
|
-
}) => {
|
|
235
|
+
} | {
|
|
236
|
+
type: "logParsedData";
|
|
237
|
+
params: {
|
|
323
238
|
packet: Packet;
|
|
324
239
|
};
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
context: NmeaContext<NavigationData, StoredPackets>;
|
|
329
|
-
event: {
|
|
330
|
-
type: "SERIAL.DATA";
|
|
331
|
-
data: Packet;
|
|
332
|
-
};
|
|
333
|
-
}) => {
|
|
240
|
+
} | {
|
|
241
|
+
type: "storePacket";
|
|
242
|
+
params: {
|
|
334
243
|
packet: Packet;
|
|
335
244
|
};
|
|
336
|
-
}];
|
|
337
|
-
};
|
|
338
|
-
readonly 'SERIAL.ERROR': {
|
|
339
|
-
readonly actions: {
|
|
340
|
-
readonly type: "clearError";
|
|
341
|
-
readonly params: ({ event }: {
|
|
342
|
-
context: NmeaContext<NavigationData, StoredPackets>;
|
|
343
|
-
event: {
|
|
344
|
-
type: "SERIAL.ERROR";
|
|
345
|
-
error: string;
|
|
346
|
-
};
|
|
347
|
-
}) => {
|
|
348
|
-
error: string;
|
|
349
|
-
};
|
|
350
|
-
};
|
|
351
|
-
};
|
|
352
|
-
readonly FATAL_ERROR: {
|
|
353
|
-
readonly target: "error";
|
|
354
|
-
readonly actions: {
|
|
355
|
-
readonly type: "setFatalError";
|
|
356
|
-
readonly params: ({ event }: {
|
|
357
|
-
context: NmeaContext<NavigationData, StoredPackets>;
|
|
358
|
-
event: {
|
|
359
|
-
type: "FATAL_ERROR";
|
|
360
|
-
error: string;
|
|
361
|
-
};
|
|
362
|
-
}) => {
|
|
363
|
-
error: string;
|
|
364
|
-
};
|
|
365
|
-
};
|
|
366
|
-
};
|
|
367
|
-
readonly 'SERIAL.DISCONNECTED': {
|
|
368
|
-
readonly target: "disconnecting";
|
|
369
|
-
};
|
|
370
|
-
readonly DISCONNECT: {
|
|
371
|
-
readonly actions: ActionFunction<NmeaContext<NavigationData, StoredPackets>, {
|
|
372
|
-
type: "DISCONNECT";
|
|
373
|
-
}, {
|
|
374
|
-
type: "CONNECT";
|
|
375
|
-
} | {
|
|
376
|
-
type: "DISCONNECT";
|
|
377
|
-
} | {
|
|
378
|
-
type: "SERIAL.DATA";
|
|
379
|
-
data: Packet;
|
|
380
|
-
} | {
|
|
381
|
-
type: "SERIAL.ERROR";
|
|
382
|
-
error: string;
|
|
383
245
|
} | {
|
|
384
|
-
type: "
|
|
246
|
+
type: "clearError";
|
|
247
|
+
params: {
|
|
385
248
|
error: string;
|
|
386
|
-
} | {
|
|
387
|
-
type: "SERIAL.DISCONNECTED";
|
|
388
|
-
} | {
|
|
389
|
-
type: "STOP";
|
|
390
|
-
} | {
|
|
391
|
-
type: "SET_LOGGING";
|
|
392
|
-
enabled: boolean;
|
|
393
|
-
} | {
|
|
394
|
-
type: "SET_BAUD_RATE";
|
|
395
|
-
baudRate: number;
|
|
396
|
-
}, undefined, never, never, never, never, never>;
|
|
397
249
|
};
|
|
398
|
-
};
|
|
399
|
-
readonly invoke: {
|
|
400
|
-
readonly id: "streamReader";
|
|
401
|
-
readonly src: "readNmeaStream";
|
|
402
|
-
readonly input: ({ context }: {
|
|
403
|
-
context: NmeaContext<NavigationData, StoredPackets>;
|
|
404
|
-
event: {
|
|
405
|
-
type: "CONNECT";
|
|
406
250
|
} | {
|
|
407
|
-
type: "
|
|
408
|
-
|
|
409
|
-
type: "SERIAL.DATA";
|
|
410
|
-
data: Packet;
|
|
411
|
-
} | {
|
|
412
|
-
type: "SERIAL.ERROR";
|
|
413
|
-
error: string;
|
|
414
|
-
} | {
|
|
415
|
-
type: "FATAL_ERROR";
|
|
251
|
+
type: "setFatalError";
|
|
252
|
+
params: {
|
|
416
253
|
error: string;
|
|
417
|
-
} | {
|
|
418
|
-
type: "SERIAL.DISCONNECTED";
|
|
419
|
-
} | {
|
|
420
|
-
type: "STOP";
|
|
421
|
-
} | {
|
|
422
|
-
type: "SET_LOGGING";
|
|
423
|
-
enabled: boolean;
|
|
424
|
-
} | {
|
|
425
|
-
type: "SET_BAUD_RATE";
|
|
426
|
-
baudRate: number;
|
|
427
254
|
};
|
|
428
|
-
self: ActorRef<MachineSnapshot<NmeaContext<NavigationData, StoredPackets>, {
|
|
429
|
-
type: "CONNECT";
|
|
430
|
-
} | {
|
|
431
|
-
type: "DISCONNECT";
|
|
432
|
-
} | {
|
|
433
|
-
type: "SERIAL.DATA";
|
|
434
|
-
data: Packet;
|
|
435
|
-
} | {
|
|
436
|
-
type: "SERIAL.ERROR";
|
|
437
|
-
error: string;
|
|
438
|
-
} | {
|
|
439
|
-
type: "FATAL_ERROR";
|
|
440
|
-
error: string;
|
|
441
|
-
} | {
|
|
442
|
-
type: "SERIAL.DISCONNECTED";
|
|
443
255
|
} | {
|
|
444
|
-
type: "
|
|
256
|
+
type: "disconnect";
|
|
257
|
+
params: NonReducibleUnknown;
|
|
445
258
|
} | {
|
|
446
|
-
type: "
|
|
259
|
+
type: "setLogging";
|
|
260
|
+
params: {
|
|
447
261
|
enabled: boolean;
|
|
262
|
+
};
|
|
448
263
|
} | {
|
|
449
|
-
type: "
|
|
264
|
+
type: "setBaudRate";
|
|
265
|
+
params: {
|
|
450
266
|
baudRate: number;
|
|
451
|
-
}, Record<string, AnyActorRef>, StateValue, string, unknown, any, any>, {
|
|
452
|
-
type: "CONNECT";
|
|
453
|
-
} | {
|
|
454
|
-
type: "DISCONNECT";
|
|
455
|
-
} | {
|
|
456
|
-
type: "SERIAL.DATA";
|
|
457
|
-
data: Packet;
|
|
458
|
-
} | {
|
|
459
|
-
type: "SERIAL.ERROR";
|
|
460
|
-
error: string;
|
|
461
|
-
} | {
|
|
462
|
-
type: "FATAL_ERROR";
|
|
463
|
-
error: string;
|
|
464
|
-
} | {
|
|
465
|
-
type: "SERIAL.DISCONNECTED";
|
|
466
|
-
} | {
|
|
467
|
-
type: "STOP";
|
|
468
|
-
} | {
|
|
469
|
-
type: "SET_LOGGING";
|
|
470
|
-
enabled: boolean;
|
|
471
|
-
} | {
|
|
472
|
-
type: "SET_BAUD_RATE";
|
|
473
|
-
baudRate: number;
|
|
474
|
-
}, AnyEventObject>;
|
|
475
|
-
}) => {
|
|
476
|
-
port: SerialPort;
|
|
477
|
-
};
|
|
478
|
-
};
|
|
479
|
-
};
|
|
480
|
-
readonly disconnecting: {
|
|
481
|
-
readonly invoke: {
|
|
482
|
-
readonly id: "closePort";
|
|
483
|
-
readonly src: "closePort";
|
|
484
|
-
readonly input: ({ context }: {
|
|
485
|
-
context: NmeaContext<NavigationData, StoredPackets>;
|
|
486
|
-
event: {
|
|
487
|
-
type: "CONNECT";
|
|
488
|
-
} | {
|
|
489
|
-
type: "DISCONNECT";
|
|
490
|
-
} | {
|
|
491
|
-
type: "SERIAL.DATA";
|
|
492
|
-
data: Packet;
|
|
493
|
-
} | {
|
|
494
|
-
type: "SERIAL.ERROR";
|
|
495
|
-
error: string;
|
|
496
|
-
} | {
|
|
497
|
-
type: "FATAL_ERROR";
|
|
498
|
-
error: string;
|
|
499
|
-
} | {
|
|
500
|
-
type: "SERIAL.DISCONNECTED";
|
|
501
|
-
} | {
|
|
502
|
-
type: "STOP";
|
|
503
|
-
} | {
|
|
504
|
-
type: "SET_LOGGING";
|
|
505
|
-
enabled: boolean;
|
|
506
|
-
} | {
|
|
507
|
-
type: "SET_BAUD_RATE";
|
|
508
|
-
baudRate: number;
|
|
509
|
-
};
|
|
510
|
-
self: ActorRef<MachineSnapshot<NmeaContext<NavigationData, StoredPackets>, {
|
|
511
|
-
type: "CONNECT";
|
|
512
|
-
} | {
|
|
513
|
-
type: "DISCONNECT";
|
|
514
|
-
} | {
|
|
515
|
-
type: "SERIAL.DATA";
|
|
516
|
-
data: Packet;
|
|
517
|
-
} | {
|
|
518
|
-
type: "SERIAL.ERROR";
|
|
519
|
-
error: string;
|
|
520
|
-
} | {
|
|
521
|
-
type: "FATAL_ERROR";
|
|
522
|
-
error: string;
|
|
523
|
-
} | {
|
|
524
|
-
type: "SERIAL.DISCONNECTED";
|
|
525
|
-
} | {
|
|
526
|
-
type: "STOP";
|
|
527
|
-
} | {
|
|
528
|
-
type: "SET_LOGGING";
|
|
529
|
-
enabled: boolean;
|
|
530
|
-
} | {
|
|
531
|
-
type: "SET_BAUD_RATE";
|
|
532
|
-
baudRate: number;
|
|
533
|
-
}, Record<string, AnyActorRef>, StateValue, string, unknown, any, any>, {
|
|
534
|
-
type: "CONNECT";
|
|
535
|
-
} | {
|
|
536
|
-
type: "DISCONNECT";
|
|
537
|
-
} | {
|
|
538
|
-
type: "SERIAL.DATA";
|
|
539
|
-
data: Packet;
|
|
540
|
-
} | {
|
|
541
|
-
type: "SERIAL.ERROR";
|
|
542
|
-
error: string;
|
|
543
|
-
} | {
|
|
544
|
-
type: "FATAL_ERROR";
|
|
545
|
-
error: string;
|
|
546
|
-
} | {
|
|
547
|
-
type: "SERIAL.DISCONNECTED";
|
|
548
|
-
} | {
|
|
549
|
-
type: "STOP";
|
|
550
|
-
} | {
|
|
551
|
-
type: "SET_LOGGING";
|
|
552
|
-
enabled: boolean;
|
|
553
|
-
} | {
|
|
554
|
-
type: "SET_BAUD_RATE";
|
|
555
|
-
baudRate: number;
|
|
556
|
-
}, AnyEventObject>;
|
|
557
|
-
}) => {
|
|
558
|
-
port: SerialPort | null;
|
|
559
|
-
};
|
|
560
|
-
readonly onDone: {
|
|
561
|
-
readonly target: "disconnected";
|
|
562
|
-
readonly actions: "disconnect";
|
|
563
|
-
};
|
|
564
|
-
readonly onError: {
|
|
565
|
-
readonly target: "disconnected";
|
|
566
|
-
readonly actions: "disconnect";
|
|
567
|
-
};
|
|
568
|
-
};
|
|
569
|
-
};
|
|
570
|
-
readonly error: {
|
|
571
|
-
readonly on: {
|
|
572
|
-
readonly CONNECT: "connecting";
|
|
573
|
-
};
|
|
574
|
-
};
|
|
575
|
-
};
|
|
576
|
-
}>;
|
|
577
|
-
|
|
578
|
-
/**
|
|
579
|
-
* Factory function to create an NMEA state machine with a generic adapter pattern.
|
|
580
|
-
*
|
|
581
|
-
* Creates an XState state machine that manages serial port connections, parses NMEA sentences,
|
|
582
|
-
* and transforms them into your application's data format using the provided adapter function.
|
|
583
|
-
*
|
|
584
|
-
* @example
|
|
585
|
-
* ```typescript
|
|
586
|
-
* const machine = createNmeaMachine({
|
|
587
|
-
* adapter: computeNavigationData,
|
|
588
|
-
* allowedSentenceIds: ['GGA', 'RMC', 'VTG'],
|
|
589
|
-
* initialData: { time: null, position: null },
|
|
590
|
-
* initialPackets: {},
|
|
591
|
-
* });
|
|
592
|
-
*
|
|
593
|
-
* const actor = createActor(machine);
|
|
594
|
-
* actor.start();
|
|
595
|
-
* actor.send({ type: 'CONNECT' });
|
|
596
|
-
* ```
|
|
597
|
-
*
|
|
598
|
-
* @template TData - The type of computed/translated data stored in context.
|
|
599
|
-
* @template TPackets - The type of stored packets (typically a record of sentence ID to packet).
|
|
600
|
-
* @param config - Configuration for the machine including adapter function and initial values.
|
|
601
|
-
* @returns An XState state machine that can be used with `createActor` from XState.
|
|
602
|
-
*
|
|
603
|
-
* @remarks
|
|
604
|
-
* The returned machine is an XState state machine. Use it with XState's `createActor` to create
|
|
605
|
-
* an actor instance, or use the {@link NmeaClient} class for a simpler API that doesn't require
|
|
606
|
-
* direct XState knowledge.
|
|
607
|
-
*/
|
|
608
|
-
export declare function createNmeaMachine<TData, TPackets extends Record<string, PacketStub | undefined>>(config: NmeaMachineConfig<TData, TPackets>): StateMachine<NmeaContext<TData, TPackets>, {
|
|
609
|
-
type: "CONNECT";
|
|
610
|
-
} | {
|
|
611
|
-
type: "DISCONNECT";
|
|
612
|
-
} | {
|
|
613
|
-
type: "SERIAL.DATA";
|
|
614
|
-
data: Packet;
|
|
615
|
-
} | {
|
|
616
|
-
type: "SERIAL.ERROR";
|
|
617
|
-
error: string;
|
|
618
|
-
} | {
|
|
619
|
-
type: "FATAL_ERROR";
|
|
620
|
-
error: string;
|
|
621
|
-
} | {
|
|
622
|
-
type: "SERIAL.DISCONNECTED";
|
|
623
|
-
} | {
|
|
624
|
-
type: "STOP";
|
|
625
|
-
} | {
|
|
626
|
-
type: "SET_LOGGING";
|
|
627
|
-
enabled: boolean;
|
|
628
|
-
} | {
|
|
629
|
-
type: "SET_BAUD_RATE";
|
|
630
|
-
baudRate: number;
|
|
631
|
-
}, {
|
|
632
|
-
[x: string]: ActorRefFromLogic<PromiseActorLogic<SerialPort, {
|
|
633
|
-
baudRate: number;
|
|
634
|
-
}, EventObject>> | ActorRefFromLogic<CallbackActorLogic<NmeaEvent, {
|
|
635
|
-
port: SerialPort;
|
|
636
|
-
}, EventObject>> | ActorRefFromLogic<PromiseActorLogic<void, {
|
|
637
|
-
port: SerialPort | null;
|
|
638
|
-
}, EventObject>> | undefined;
|
|
639
|
-
}, Values< {
|
|
640
|
-
connectToSerial: {
|
|
641
|
-
src: "connectToSerial";
|
|
642
|
-
logic: PromiseActorLogic<SerialPort, {
|
|
643
|
-
baudRate: number;
|
|
644
|
-
}, EventObject>;
|
|
645
|
-
id: string | undefined;
|
|
646
|
-
};
|
|
647
|
-
readNmeaStream: {
|
|
648
|
-
src: "readNmeaStream";
|
|
649
|
-
logic: CallbackActorLogic<NmeaEvent, {
|
|
650
|
-
port: SerialPort;
|
|
651
|
-
}, EventObject>;
|
|
652
|
-
id: string | undefined;
|
|
653
|
-
};
|
|
654
|
-
closePort: {
|
|
655
|
-
src: "closePort";
|
|
656
|
-
logic: PromiseActorLogic<void, {
|
|
657
|
-
port: SerialPort | null;
|
|
658
|
-
}, EventObject>;
|
|
659
|
-
id: string | undefined;
|
|
660
|
-
};
|
|
661
|
-
}>, Values< {
|
|
662
|
-
setPort: {
|
|
663
|
-
type: "setPort";
|
|
664
|
-
params: {
|
|
665
|
-
port: SerialPort;
|
|
666
|
-
};
|
|
667
|
-
};
|
|
668
|
-
setError: {
|
|
669
|
-
type: "setError";
|
|
670
|
-
params: {
|
|
671
|
-
error: unknown;
|
|
672
|
-
};
|
|
673
|
-
};
|
|
674
|
-
logParsedData: {
|
|
675
|
-
type: "logParsedData";
|
|
676
|
-
params: {
|
|
677
|
-
packet: Packet;
|
|
678
|
-
};
|
|
679
|
-
};
|
|
680
|
-
storePacket: {
|
|
681
|
-
type: "storePacket";
|
|
682
|
-
params: {
|
|
683
|
-
packet: Packet;
|
|
684
|
-
};
|
|
685
|
-
};
|
|
686
|
-
clearError: {
|
|
687
|
-
type: "clearError";
|
|
688
|
-
params: {
|
|
689
|
-
error: string;
|
|
690
|
-
};
|
|
691
|
-
};
|
|
692
|
-
setFatalError: {
|
|
693
|
-
type: "setFatalError";
|
|
694
|
-
params: {
|
|
695
|
-
error: string;
|
|
696
|
-
};
|
|
697
|
-
};
|
|
698
|
-
disconnect: {
|
|
699
|
-
type: "disconnect";
|
|
700
|
-
params: NonReducibleUnknown;
|
|
701
|
-
};
|
|
702
|
-
setLogging: {
|
|
703
|
-
type: "setLogging";
|
|
704
|
-
params: {
|
|
705
|
-
enabled: boolean;
|
|
706
|
-
};
|
|
707
|
-
};
|
|
708
|
-
setBaudRate: {
|
|
709
|
-
type: "setBaudRate";
|
|
710
|
-
params: {
|
|
711
|
-
baudRate: number;
|
|
712
|
-
};
|
|
713
|
-
};
|
|
714
|
-
}>, never, never, "error" | "disconnected" | "connecting" | "connected" | "disconnecting", string, NonReducibleUnknown, NonReducibleUnknown, EventObject, MetaObject, {
|
|
715
|
-
readonly id: "nmea";
|
|
716
|
-
readonly initial: "disconnected";
|
|
717
|
-
readonly context: {
|
|
718
|
-
readonly port: null;
|
|
719
|
-
readonly error: null;
|
|
720
|
-
readonly packets: TPackets;
|
|
721
|
-
readonly data: TData;
|
|
722
|
-
readonly enableLogging: false;
|
|
723
|
-
readonly baudRate: 4800;
|
|
724
|
-
};
|
|
725
|
-
readonly on: {
|
|
726
|
-
readonly SET_LOGGING: {
|
|
727
|
-
readonly actions: {
|
|
728
|
-
readonly type: "setLogging";
|
|
729
|
-
readonly params: ({ event }: {
|
|
730
|
-
context: NmeaContext<TData, TPackets>;
|
|
731
|
-
event: {
|
|
732
|
-
type: "SET_LOGGING";
|
|
733
|
-
enabled: boolean;
|
|
734
|
-
};
|
|
735
|
-
}) => {
|
|
736
|
-
enabled: boolean;
|
|
737
|
-
};
|
|
738
|
-
};
|
|
739
|
-
};
|
|
740
|
-
};
|
|
741
|
-
readonly states: {
|
|
742
|
-
readonly disconnected: {
|
|
743
|
-
readonly on: {
|
|
744
|
-
readonly CONNECT: "connecting";
|
|
745
|
-
readonly SET_BAUD_RATE: {
|
|
746
|
-
readonly actions: {
|
|
747
|
-
readonly type: "setBaudRate";
|
|
748
|
-
readonly params: ({ event }: {
|
|
749
|
-
context: NmeaContext<TData, TPackets>;
|
|
750
|
-
event: {
|
|
751
|
-
type: "SET_BAUD_RATE";
|
|
752
|
-
baudRate: number;
|
|
753
|
-
};
|
|
754
|
-
}) => {
|
|
755
|
-
baudRate: number;
|
|
756
|
-
};
|
|
757
|
-
};
|
|
758
|
-
};
|
|
759
|
-
};
|
|
760
|
-
};
|
|
761
|
-
readonly connecting: {
|
|
762
|
-
readonly invoke: {
|
|
763
|
-
readonly id: "connectToSerial";
|
|
764
|
-
readonly src: "connectToSerial";
|
|
765
|
-
readonly input: ({ context }: {
|
|
766
|
-
context: NmeaContext<TData, TPackets>;
|
|
767
|
-
event: {
|
|
768
|
-
type: "CONNECT";
|
|
769
|
-
} | {
|
|
770
|
-
type: "DISCONNECT";
|
|
771
|
-
} | {
|
|
772
|
-
type: "SERIAL.DATA";
|
|
773
|
-
data: Packet;
|
|
774
|
-
} | {
|
|
775
|
-
type: "SERIAL.ERROR";
|
|
776
|
-
error: string;
|
|
777
|
-
} | {
|
|
778
|
-
type: "FATAL_ERROR";
|
|
779
|
-
error: string;
|
|
780
|
-
} | {
|
|
781
|
-
type: "SERIAL.DISCONNECTED";
|
|
782
|
-
} | {
|
|
783
|
-
type: "STOP";
|
|
784
|
-
} | {
|
|
785
|
-
type: "SET_LOGGING";
|
|
786
|
-
enabled: boolean;
|
|
787
|
-
} | {
|
|
788
|
-
type: "SET_BAUD_RATE";
|
|
789
|
-
baudRate: number;
|
|
790
|
-
};
|
|
791
|
-
self: ActorRef<MachineSnapshot<NmeaContext<TData, TPackets>, {
|
|
792
|
-
type: "CONNECT";
|
|
793
|
-
} | {
|
|
794
|
-
type: "DISCONNECT";
|
|
795
|
-
} | {
|
|
796
|
-
type: "SERIAL.DATA";
|
|
797
|
-
data: Packet;
|
|
798
|
-
} | {
|
|
799
|
-
type: "SERIAL.ERROR";
|
|
800
|
-
error: string;
|
|
801
|
-
} | {
|
|
802
|
-
type: "FATAL_ERROR";
|
|
803
|
-
error: string;
|
|
804
|
-
} | {
|
|
805
|
-
type: "SERIAL.DISCONNECTED";
|
|
806
|
-
} | {
|
|
807
|
-
type: "STOP";
|
|
808
|
-
} | {
|
|
809
|
-
type: "SET_LOGGING";
|
|
810
|
-
enabled: boolean;
|
|
811
|
-
} | {
|
|
812
|
-
type: "SET_BAUD_RATE";
|
|
813
|
-
baudRate: number;
|
|
814
|
-
}, Record<string, AnyActorRef>, StateValue, string, unknown, any, any>, {
|
|
815
|
-
type: "CONNECT";
|
|
816
|
-
} | {
|
|
817
|
-
type: "DISCONNECT";
|
|
818
|
-
} | {
|
|
819
|
-
type: "SERIAL.DATA";
|
|
820
|
-
data: Packet;
|
|
821
|
-
} | {
|
|
822
|
-
type: "SERIAL.ERROR";
|
|
823
|
-
error: string;
|
|
824
|
-
} | {
|
|
825
|
-
type: "FATAL_ERROR";
|
|
826
|
-
error: string;
|
|
827
|
-
} | {
|
|
828
|
-
type: "SERIAL.DISCONNECTED";
|
|
829
|
-
} | {
|
|
830
|
-
type: "STOP";
|
|
831
|
-
} | {
|
|
832
|
-
type: "SET_LOGGING";
|
|
833
|
-
enabled: boolean;
|
|
834
|
-
} | {
|
|
835
|
-
type: "SET_BAUD_RATE";
|
|
836
|
-
baudRate: number;
|
|
837
|
-
}, AnyEventObject>;
|
|
838
|
-
}) => {
|
|
839
|
-
baudRate: number;
|
|
840
|
-
};
|
|
841
|
-
readonly onDone: {
|
|
842
|
-
readonly target: "connected";
|
|
843
|
-
readonly actions: {
|
|
844
|
-
readonly type: "setPort";
|
|
845
|
-
readonly params: ({ event }: {
|
|
846
|
-
context: NmeaContext<TData, TPackets>;
|
|
847
|
-
event: DoneActorEvent<SerialPort, string>;
|
|
848
|
-
}) => {
|
|
849
|
-
port: SerialPort;
|
|
850
|
-
};
|
|
851
|
-
};
|
|
852
|
-
};
|
|
853
|
-
readonly onError: {
|
|
854
|
-
readonly target: "error";
|
|
855
|
-
readonly actions: {
|
|
856
|
-
readonly type: "setError";
|
|
857
|
-
readonly params: ({ event }: {
|
|
858
|
-
context: NmeaContext<TData, TPackets>;
|
|
859
|
-
event: ErrorActorEvent<unknown, string>;
|
|
860
|
-
}) => {
|
|
861
|
-
error: unknown;
|
|
862
|
-
};
|
|
863
|
-
};
|
|
864
|
-
};
|
|
865
|
-
};
|
|
866
|
-
};
|
|
867
|
-
readonly connected: {
|
|
868
|
-
readonly on: {
|
|
869
|
-
readonly 'SERIAL.DATA': {
|
|
870
|
-
readonly actions: readonly [{
|
|
871
|
-
readonly type: "logParsedData";
|
|
872
|
-
readonly params: ({ event }: {
|
|
873
|
-
context: NmeaContext<TData, TPackets>;
|
|
874
|
-
event: {
|
|
875
|
-
type: "SERIAL.DATA";
|
|
876
|
-
data: Packet;
|
|
877
|
-
};
|
|
878
|
-
}) => {
|
|
879
|
-
packet: Packet;
|
|
880
|
-
};
|
|
881
|
-
}, {
|
|
882
|
-
readonly type: "storePacket";
|
|
883
|
-
readonly params: ({ event }: {
|
|
884
|
-
context: NmeaContext<TData, TPackets>;
|
|
885
|
-
event: {
|
|
886
|
-
type: "SERIAL.DATA";
|
|
887
|
-
data: Packet;
|
|
888
|
-
};
|
|
889
|
-
}) => {
|
|
890
|
-
packet: Packet;
|
|
891
|
-
};
|
|
892
|
-
}];
|
|
893
|
-
};
|
|
894
|
-
readonly 'SERIAL.ERROR': {
|
|
895
|
-
readonly actions: {
|
|
896
|
-
readonly type: "clearError";
|
|
897
|
-
readonly params: ({ event }: {
|
|
898
|
-
context: NmeaContext<TData, TPackets>;
|
|
899
|
-
event: {
|
|
900
|
-
type: "SERIAL.ERROR";
|
|
901
|
-
error: string;
|
|
902
|
-
};
|
|
903
|
-
}) => {
|
|
904
|
-
error: string;
|
|
905
|
-
};
|
|
906
|
-
};
|
|
907
|
-
};
|
|
908
|
-
readonly FATAL_ERROR: {
|
|
909
|
-
readonly target: "error";
|
|
910
|
-
readonly actions: {
|
|
911
|
-
readonly type: "setFatalError";
|
|
912
|
-
readonly params: ({ event }: {
|
|
913
|
-
context: NmeaContext<TData, TPackets>;
|
|
914
|
-
event: {
|
|
915
|
-
type: "FATAL_ERROR";
|
|
916
|
-
error: string;
|
|
917
|
-
};
|
|
918
|
-
}) => {
|
|
919
|
-
error: string;
|
|
920
|
-
};
|
|
921
|
-
};
|
|
922
|
-
};
|
|
923
|
-
readonly 'SERIAL.DISCONNECTED': {
|
|
924
|
-
readonly target: "disconnecting";
|
|
925
|
-
};
|
|
926
|
-
readonly DISCONNECT: {
|
|
927
|
-
readonly actions: ActionFunction<NmeaContext<TData, TPackets>, {
|
|
928
|
-
type: "DISCONNECT";
|
|
929
|
-
}, {
|
|
930
|
-
type: "CONNECT";
|
|
931
|
-
} | {
|
|
932
|
-
type: "DISCONNECT";
|
|
933
|
-
} | {
|
|
934
|
-
type: "SERIAL.DATA";
|
|
935
|
-
data: Packet;
|
|
936
|
-
} | {
|
|
937
|
-
type: "SERIAL.ERROR";
|
|
938
|
-
error: string;
|
|
939
|
-
} | {
|
|
940
|
-
type: "FATAL_ERROR";
|
|
941
|
-
error: string;
|
|
942
|
-
} | {
|
|
943
|
-
type: "SERIAL.DISCONNECTED";
|
|
944
|
-
} | {
|
|
945
|
-
type: "STOP";
|
|
946
|
-
} | {
|
|
947
|
-
type: "SET_LOGGING";
|
|
948
|
-
enabled: boolean;
|
|
949
|
-
} | {
|
|
950
|
-
type: "SET_BAUD_RATE";
|
|
951
|
-
baudRate: number;
|
|
952
|
-
}, undefined, never, never, never, never, never>;
|
|
953
|
-
};
|
|
954
|
-
};
|
|
955
|
-
readonly invoke: {
|
|
956
|
-
readonly id: "streamReader";
|
|
957
|
-
readonly src: "readNmeaStream";
|
|
958
|
-
readonly input: ({ context }: {
|
|
959
|
-
context: NmeaContext<TData, TPackets>;
|
|
960
|
-
event: {
|
|
961
|
-
type: "CONNECT";
|
|
962
|
-
} | {
|
|
963
|
-
type: "DISCONNECT";
|
|
964
|
-
} | {
|
|
965
|
-
type: "SERIAL.DATA";
|
|
966
|
-
data: Packet;
|
|
967
|
-
} | {
|
|
968
|
-
type: "SERIAL.ERROR";
|
|
969
|
-
error: string;
|
|
970
|
-
} | {
|
|
971
|
-
type: "FATAL_ERROR";
|
|
972
|
-
error: string;
|
|
973
|
-
} | {
|
|
974
|
-
type: "SERIAL.DISCONNECTED";
|
|
975
|
-
} | {
|
|
976
|
-
type: "STOP";
|
|
977
|
-
} | {
|
|
978
|
-
type: "SET_LOGGING";
|
|
979
|
-
enabled: boolean;
|
|
980
|
-
} | {
|
|
981
|
-
type: "SET_BAUD_RATE";
|
|
982
|
-
baudRate: number;
|
|
983
|
-
};
|
|
984
|
-
self: ActorRef<MachineSnapshot<NmeaContext<TData, TPackets>, {
|
|
985
|
-
type: "CONNECT";
|
|
986
|
-
} | {
|
|
987
|
-
type: "DISCONNECT";
|
|
988
|
-
} | {
|
|
989
|
-
type: "SERIAL.DATA";
|
|
990
|
-
data: Packet;
|
|
991
|
-
} | {
|
|
992
|
-
type: "SERIAL.ERROR";
|
|
993
|
-
error: string;
|
|
994
|
-
} | {
|
|
995
|
-
type: "FATAL_ERROR";
|
|
996
|
-
error: string;
|
|
997
|
-
} | {
|
|
998
|
-
type: "SERIAL.DISCONNECTED";
|
|
999
|
-
} | {
|
|
1000
|
-
type: "STOP";
|
|
1001
|
-
} | {
|
|
1002
|
-
type: "SET_LOGGING";
|
|
1003
|
-
enabled: boolean;
|
|
1004
|
-
} | {
|
|
1005
|
-
type: "SET_BAUD_RATE";
|
|
1006
|
-
baudRate: number;
|
|
1007
|
-
}, Record<string, AnyActorRef>, StateValue, string, unknown, any, any>, {
|
|
1008
|
-
type: "CONNECT";
|
|
1009
|
-
} | {
|
|
1010
|
-
type: "DISCONNECT";
|
|
1011
|
-
} | {
|
|
1012
|
-
type: "SERIAL.DATA";
|
|
1013
|
-
data: Packet;
|
|
1014
|
-
} | {
|
|
1015
|
-
type: "SERIAL.ERROR";
|
|
1016
|
-
error: string;
|
|
1017
|
-
} | {
|
|
1018
|
-
type: "FATAL_ERROR";
|
|
1019
|
-
error: string;
|
|
1020
|
-
} | {
|
|
1021
|
-
type: "SERIAL.DISCONNECTED";
|
|
1022
|
-
} | {
|
|
1023
|
-
type: "STOP";
|
|
1024
|
-
} | {
|
|
1025
|
-
type: "SET_LOGGING";
|
|
1026
|
-
enabled: boolean;
|
|
1027
|
-
} | {
|
|
1028
|
-
type: "SET_BAUD_RATE";
|
|
1029
|
-
baudRate: number;
|
|
1030
|
-
}, AnyEventObject>;
|
|
1031
|
-
}) => {
|
|
1032
|
-
port: SerialPort;
|
|
1033
|
-
};
|
|
1034
|
-
};
|
|
1035
|
-
};
|
|
1036
|
-
readonly disconnecting: {
|
|
1037
|
-
readonly invoke: {
|
|
1038
|
-
readonly id: "closePort";
|
|
1039
|
-
readonly src: "closePort";
|
|
1040
|
-
readonly input: ({ context }: {
|
|
1041
|
-
context: NmeaContext<TData, TPackets>;
|
|
1042
|
-
event: {
|
|
1043
|
-
type: "CONNECT";
|
|
1044
|
-
} | {
|
|
1045
|
-
type: "DISCONNECT";
|
|
1046
|
-
} | {
|
|
1047
|
-
type: "SERIAL.DATA";
|
|
1048
|
-
data: Packet;
|
|
1049
|
-
} | {
|
|
1050
|
-
type: "SERIAL.ERROR";
|
|
1051
|
-
error: string;
|
|
1052
|
-
} | {
|
|
1053
|
-
type: "FATAL_ERROR";
|
|
1054
|
-
error: string;
|
|
1055
|
-
} | {
|
|
1056
|
-
type: "SERIAL.DISCONNECTED";
|
|
1057
|
-
} | {
|
|
1058
|
-
type: "STOP";
|
|
1059
|
-
} | {
|
|
1060
|
-
type: "SET_LOGGING";
|
|
1061
|
-
enabled: boolean;
|
|
1062
|
-
} | {
|
|
1063
|
-
type: "SET_BAUD_RATE";
|
|
1064
|
-
baudRate: number;
|
|
1065
|
-
};
|
|
1066
|
-
self: ActorRef<MachineSnapshot<NmeaContext<TData, TPackets>, {
|
|
1067
|
-
type: "CONNECT";
|
|
1068
|
-
} | {
|
|
1069
|
-
type: "DISCONNECT";
|
|
1070
|
-
} | {
|
|
1071
|
-
type: "SERIAL.DATA";
|
|
1072
|
-
data: Packet;
|
|
1073
|
-
} | {
|
|
1074
|
-
type: "SERIAL.ERROR";
|
|
1075
|
-
error: string;
|
|
1076
|
-
} | {
|
|
1077
|
-
type: "FATAL_ERROR";
|
|
1078
|
-
error: string;
|
|
1079
|
-
} | {
|
|
1080
|
-
type: "SERIAL.DISCONNECTED";
|
|
1081
|
-
} | {
|
|
1082
|
-
type: "STOP";
|
|
1083
|
-
} | {
|
|
1084
|
-
type: "SET_LOGGING";
|
|
1085
|
-
enabled: boolean;
|
|
1086
|
-
} | {
|
|
1087
|
-
type: "SET_BAUD_RATE";
|
|
1088
|
-
baudRate: number;
|
|
1089
|
-
}, Record<string, AnyActorRef>, StateValue, string, unknown, any, any>, {
|
|
1090
|
-
type: "CONNECT";
|
|
1091
|
-
} | {
|
|
1092
|
-
type: "DISCONNECT";
|
|
1093
|
-
} | {
|
|
1094
|
-
type: "SERIAL.DATA";
|
|
1095
|
-
data: Packet;
|
|
1096
|
-
} | {
|
|
1097
|
-
type: "SERIAL.ERROR";
|
|
1098
|
-
error: string;
|
|
1099
|
-
} | {
|
|
1100
|
-
type: "FATAL_ERROR";
|
|
1101
|
-
error: string;
|
|
1102
|
-
} | {
|
|
1103
|
-
type: "SERIAL.DISCONNECTED";
|
|
1104
|
-
} | {
|
|
1105
|
-
type: "STOP";
|
|
1106
|
-
} | {
|
|
1107
|
-
type: "SET_LOGGING";
|
|
1108
|
-
enabled: boolean;
|
|
1109
|
-
} | {
|
|
1110
|
-
type: "SET_BAUD_RATE";
|
|
1111
|
-
baudRate: number;
|
|
1112
|
-
}, AnyEventObject>;
|
|
1113
|
-
}) => {
|
|
1114
|
-
port: SerialPort | null;
|
|
1115
|
-
};
|
|
1116
|
-
readonly onDone: {
|
|
1117
|
-
readonly target: "disconnected";
|
|
1118
|
-
readonly actions: "disconnect";
|
|
1119
|
-
};
|
|
1120
|
-
readonly onError: {
|
|
1121
|
-
readonly target: "disconnected";
|
|
1122
|
-
readonly actions: "disconnect";
|
|
1123
|
-
};
|
|
1124
|
-
};
|
|
1125
|
-
};
|
|
1126
|
-
readonly error: {
|
|
1127
|
-
readonly on: {
|
|
1128
|
-
readonly CONNECT: "connecting";
|
|
1129
|
-
};
|
|
1130
267
|
};
|
|
268
|
+
}, never, never, "error" | "disconnected" | "connecting" | "connected" | "disconnecting", string, NonReducibleUnknown, NonReducibleUnknown, EventObject, MetaObject, {
|
|
269
|
+
id: "nmea";
|
|
270
|
+
states: {
|
|
271
|
+
readonly disconnected: {};
|
|
272
|
+
readonly connecting: {};
|
|
273
|
+
readonly connected: {};
|
|
274
|
+
readonly disconnecting: {};
|
|
275
|
+
readonly error: {};
|
|
1131
276
|
};
|
|
1132
277
|
}>;
|
|
1133
278
|
|