@vehicle-sil/gui-client 0.1.0 → 0.2.0-rc.2
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.ja.md +412 -96
- package/README.md +403 -89
- package/dist/elements.js +872 -0
- package/dist/index.js +2869 -259
- package/package.json +20 -2
- package/timeline/vehicle-sil-timeline.d.ts +108 -0
- package/timeline/vehicle-sil-timeline.js +4577 -0
- package/timeline/vehicle-sil-timeline.mjs +4579 -0
- package/types/client.d.ts +47 -7
- package/types/connection.d.ts +4 -0
- package/types/elements/index.d.ts +25 -0
- package/types/elements/outside-parts.d.ts +20 -0
- package/types/elements/page-intent.d.ts +10 -0
- package/types/elements/part.d.ts +48 -0
- package/types/elements/reasons.d.ts +12 -0
- package/types/elements/run-parts.d.ts +21 -0
- package/types/elements/scenario-parts.d.ts +18 -0
- package/types/elements/variable-parts.d.ts +28 -0
- package/types/front-actions.d.ts +130 -0
- package/types/front-compose.d.ts +61 -0
- package/types/front-outside.d.ts +19 -0
- package/types/front-types.d.ts +360 -0
- package/types/front-variable.d.ts +28 -0
- package/types/front.d.ts +50 -0
- package/types/index.d.ts +13 -5
- package/types/protocol/launcher.d.ts +581 -0
- package/types/protocol/read.d.ts +72 -0
- package/types/protocol/server.d.ts +780 -0
- package/types/protocol.d.ts +10 -972
- package/types/run.d.ts +21 -6
- package/types/session-state.d.ts +66 -10
- package/types/session.d.ts +48 -2
- package/types/time.d.ts +16 -45
- package/types/values.d.ts +2 -0
- package/types/variable-binding.d.ts +20 -5
- package/types/variable-editor.d.ts +25 -0
- package/types/variable-state.d.ts +12 -6
- package/types/variables.d.ts +36 -4
- package/types/waveforms.d.ts +14 -0
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes the launcher decides: `vehicle_sil_launch check --json`, `run --json` and the events of `run --events`.
|
|
3
|
+
* The GUI server passes them on unchanged (in the session summary, the `launcher` notification and api/check), so their
|
|
4
|
+
* versions are the launcher's. Rules of the parsers: read.ts. Every object these parsers return keeps the launcher's
|
|
5
|
+
* object in `raw` (FromLauncher), so a key that the types do not name still reaches screens and panels.
|
|
6
|
+
*/
|
|
7
|
+
import { Fields, Open, Reader, Unreadable } from './read.js';
|
|
8
|
+
/**
|
|
9
|
+
* Speed. 'max' is as fast as possible; a number is a factor (1 is real-time speed). null means the launcher's default
|
|
10
|
+
* (the value in the configuration file) when given at the start, and "not written" in a value the launcher writes.
|
|
11
|
+
*/
|
|
12
|
+
export type Speed = null | number | 'max';
|
|
13
|
+
export declare const readSpeed: Reader<Speed>;
|
|
14
|
+
/**
|
|
15
|
+
* A JSON object as the launcher wrote it. The library neither checks nor interprets its values: check the type of a
|
|
16
|
+
* value before using it, and insert it into a page as text, never as HTML.
|
|
17
|
+
*/
|
|
18
|
+
export type LauncherFields = Readonly<Record<string, unknown>>;
|
|
19
|
+
/**
|
|
20
|
+
* What every object read from the launcher's output has besides its typed fields. The typed fields follow the
|
|
21
|
+
* launcher's format versions (`vehicle_sil_check`, `vehicle_sil_run`, `vehicle_sil_events`), not the version of this
|
|
22
|
+
* library; a key that the launcher adds is in `raw` without a new version of the library.
|
|
23
|
+
*/
|
|
24
|
+
export interface FromLauncher {
|
|
25
|
+
/**
|
|
26
|
+
* The object the fields were read from, with every key, including those this type does not name (for the finding of
|
|
27
|
+
* a finding event, the step of a scenario_step event and the link of a control_link event: the event). Set by the
|
|
28
|
+
* parsers of this library, read-only and not enumerable (JSON.stringify, Object.keys, deep equality and spreading
|
|
29
|
+
* `{...x}` leave it out); absent on an object built by hand.
|
|
30
|
+
*/
|
|
31
|
+
readonly raw?: LauncherFields;
|
|
32
|
+
}
|
|
33
|
+
/** Severity of a finding. An unknown severity is treated as an error (severityRank). */
|
|
34
|
+
export type Severity = Open<'error' | 'warning' | 'note'>;
|
|
35
|
+
/** A finding of the check or the run. message and detail are shown in English, unchanged. */
|
|
36
|
+
export interface Finding extends FromLauncher {
|
|
37
|
+
/** Launcher event sequence on a finding kept by a GUI server, when available. */
|
|
38
|
+
event_seq?: number;
|
|
39
|
+
severity: Severity;
|
|
40
|
+
code: string;
|
|
41
|
+
file: string | null;
|
|
42
|
+
line: number | null;
|
|
43
|
+
participant: string | null;
|
|
44
|
+
network: string | null;
|
|
45
|
+
message: string;
|
|
46
|
+
detail: string | null;
|
|
47
|
+
}
|
|
48
|
+
/** Rank for sorting by severity, most severe first (error 0, warning 1, note 2; an unknown severity ranks as error). */
|
|
49
|
+
export declare function severityRank(severity: Severity): number;
|
|
50
|
+
/** Reads a finding. With u, part by part (if the severity and text cannot be read, the finding is unreadable). */
|
|
51
|
+
export declare const readFinding: (value: unknown, path: string, u?: Unreadable) => Finding;
|
|
52
|
+
/** A variable the ECU declared about itself (so panels can be drawn before the run). */
|
|
53
|
+
export interface Variable extends FromLauncher {
|
|
54
|
+
name: string;
|
|
55
|
+
type: Open<'bool' | 'integer' | 'real' | 'enum'>;
|
|
56
|
+
causality: Open<'input' | 'output' | 'parameter'>;
|
|
57
|
+
unit: string;
|
|
58
|
+
min: number | null;
|
|
59
|
+
max: number | null;
|
|
60
|
+
/**
|
|
61
|
+
* true for a variable vehicle-sil adds to every ECU (`ecu.connected` and so on), false for a variable the ECU
|
|
62
|
+
* declared. null from an older launcher that does not write it.
|
|
63
|
+
*/
|
|
64
|
+
builtin: boolean | null;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* State of a scenario step. running only appears in events (not in the steps of the result). skipped: the step
|
|
68
|
+
* uses a variable that this run does not have; it does not make the scenario fail.
|
|
69
|
+
*/
|
|
70
|
+
export type ScenarioStepStatus = Open<'running' | 'passed' | 'failed' | 'unfinished' | 'not_run' | 'skipped'>;
|
|
71
|
+
/** Overall result of a scenario. */
|
|
72
|
+
export type ScenarioStatus = Open<'passed' | 'failed' | 'incomplete' | 'not_run'>;
|
|
73
|
+
/**
|
|
74
|
+
* One scenario step (the `scenario_step` event, `scenario.steps[]` of the result, `scenario.steps[]` of the summary).
|
|
75
|
+
*/
|
|
76
|
+
export interface ScenarioStep extends FromLauncher {
|
|
77
|
+
/** From 1. */
|
|
78
|
+
index: number;
|
|
79
|
+
/** Line in the scenario file. */
|
|
80
|
+
line: number | null;
|
|
81
|
+
kind: Open<'set' | 'ramp' | 'wave' | 'dither' | 'expect' | 'wait_until'>;
|
|
82
|
+
/** Text of the step (shown in English, unchanged). */
|
|
83
|
+
text: string;
|
|
84
|
+
status: ScenarioStepStatus;
|
|
85
|
+
/** Time of the step (virtual time, ms). */
|
|
86
|
+
start_ms: number | null;
|
|
87
|
+
/** Virtual time at which the step's result was decided. */
|
|
88
|
+
at_ms: number | null;
|
|
89
|
+
/** Virtual time at which the step ends (null if not fixed). */
|
|
90
|
+
end_ms: number | null;
|
|
91
|
+
/** code and text of the failure finding (shown in English, unchanged). */
|
|
92
|
+
code: string | null;
|
|
93
|
+
message: string | null;
|
|
94
|
+
}
|
|
95
|
+
export declare const readScenarioStep: (value: unknown, path: string, u?: Unreadable) => ScenarioStep;
|
|
96
|
+
/** `scenario` of the check result (only with `--scenario`). */
|
|
97
|
+
export interface CheckScenario extends FromLauncher {
|
|
98
|
+
/** The scenario file (as passed to the launcher). */
|
|
99
|
+
file: string;
|
|
100
|
+
name: string | null;
|
|
101
|
+
/** Number of steps. */
|
|
102
|
+
steps: number;
|
|
103
|
+
}
|
|
104
|
+
/** `scenario` of the run result (only with `--scenario`). */
|
|
105
|
+
export interface ScenarioResult extends FromLauncher {
|
|
106
|
+
file: string;
|
|
107
|
+
name: string | null;
|
|
108
|
+
status: ScenarioStatus;
|
|
109
|
+
/** The controller step at which the scenario ended (passed and failed; null otherwise). */
|
|
110
|
+
over_at_ms: number | null;
|
|
111
|
+
steps: ScenarioStep[];
|
|
112
|
+
}
|
|
113
|
+
export type CheckStatus = Open<'described' | 'not_described' | 'not_checked' | 'failed' | 'skipped' | 'disabled'>;
|
|
114
|
+
/** What a participant is for (`role` in the configuration file, "Test participants and bridges" in docs/simulation-config.md). */
|
|
115
|
+
export type ParticipantRole = Open<'ecu' | 'test' | 'bridge'>;
|
|
116
|
+
export interface CheckParticipant extends FromLauncher {
|
|
117
|
+
/** null if unreadable. */
|
|
118
|
+
name: string | null;
|
|
119
|
+
line: number | null;
|
|
120
|
+
required: boolean | null;
|
|
121
|
+
enabled: boolean | null;
|
|
122
|
+
/**
|
|
123
|
+
* Started by the user (`manual: true` in the configuration file, or `--manual`). Older launchers do not write it, so
|
|
124
|
+
* false.
|
|
125
|
+
*/
|
|
126
|
+
manual: boolean;
|
|
127
|
+
step_ms: number | null;
|
|
128
|
+
status: CheckStatus;
|
|
129
|
+
/** Self-declared variables. null means unknown (not declared, left out, or unreadable); an empty array means none. */
|
|
130
|
+
variables: Variable[] | null;
|
|
131
|
+
/** How the ECU declared it exposes its variables. null if not declared, not checked, or from an older launcher. */
|
|
132
|
+
control: ControlOffer | null;
|
|
133
|
+
/** What the participant is for. null from an older launcher that does not write it (absent on an object built by hand). */
|
|
134
|
+
role?: ParticipantRole | null;
|
|
135
|
+
}
|
|
136
|
+
export interface CheckNetwork extends FromLauncher {
|
|
137
|
+
name: string | null;
|
|
138
|
+
kind: string | null;
|
|
139
|
+
/** Participant names in use (in configuration file order). */
|
|
140
|
+
participants: string[];
|
|
141
|
+
}
|
|
142
|
+
export type CheckOutcome = Open<'passed' | 'failed' | 'unreadable' | 'usage'>;
|
|
143
|
+
/** Result of `vehicle_sil_launch check --json` (format version 1). */
|
|
144
|
+
export interface CheckResult extends FromLauncher {
|
|
145
|
+
file: string | null;
|
|
146
|
+
result: CheckOutcome;
|
|
147
|
+
errors: number;
|
|
148
|
+
warnings: number;
|
|
149
|
+
notes: number;
|
|
150
|
+
stop_at_ms: number | null;
|
|
151
|
+
time_step_ms?: number | null;
|
|
152
|
+
participants: CheckParticipant[];
|
|
153
|
+
networks: CheckNetwork[];
|
|
154
|
+
findings: Finding[];
|
|
155
|
+
/** The scenario (only for a check with `--scenario`; null otherwise). */
|
|
156
|
+
scenario: CheckScenario | null;
|
|
157
|
+
}
|
|
158
|
+
/** Reads a check result. With u, part by part. */
|
|
159
|
+
export declare const readCheckResult: (value: unknown, path: string, u?: Unreadable) => CheckResult;
|
|
160
|
+
export interface RunParticipant extends FromLauncher {
|
|
161
|
+
name: string;
|
|
162
|
+
required: boolean;
|
|
163
|
+
enabled: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* A participant the user started (or is to start). ended stays not_started (the joined event tells whether it
|
|
166
|
+
* joined).
|
|
167
|
+
*/
|
|
168
|
+
manual: boolean;
|
|
169
|
+
ended: Open<'exited' | 'stopped' | 'killed' | 'not_started'>;
|
|
170
|
+
exit_code: number | null;
|
|
171
|
+
signal: string | null;
|
|
172
|
+
left_processes: boolean;
|
|
173
|
+
/** State of the connection to the ECU's variables at the start (null from older launchers, which do not write it). */
|
|
174
|
+
control_link: ControlLink | null;
|
|
175
|
+
/**
|
|
176
|
+
* The file the participant's output was written to (`--log-dir`). null without `--log-dir`, for a participant that
|
|
177
|
+
* was not started, or from an older launcher (absent on an object built by hand).
|
|
178
|
+
*/
|
|
179
|
+
log?: string | null;
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* State of the connection to the ECU's variables (the launcher's control links). The launcher's words appear only here
|
|
183
|
+
* (unknown values pass through as strings, in case names are added or changed).
|
|
184
|
+
* connected: variables can be read and written; no_hello: the ECU declared that it exposes variables but no hello
|
|
185
|
+
* came; version_mismatch: the format versions differ; not_offered: the ECU has variables but did not declare that it
|
|
186
|
+
* exposes them (--no-control, an older executable); none: not an ECU that exposes variables.
|
|
187
|
+
*/
|
|
188
|
+
export type ControlState = Open<'connected' | 'no_hello' | 'version_mismatch' | 'not_offered' | 'none'>;
|
|
189
|
+
/** Name of the launcher event (state of the connection to the ECU's variables). */
|
|
190
|
+
export declare const CONTROL_EVENT = "control_link";
|
|
191
|
+
/** Key (an object) for the variable interface's connection in participants[] of the launcher's result. */
|
|
192
|
+
export declare const CONTROL_RESULT_KEY = "control_link";
|
|
193
|
+
/**
|
|
194
|
+
* Field for the variable interface's connection in participants[] of the GUI server's summary (the event fields laid
|
|
195
|
+
* over each other).
|
|
196
|
+
*/
|
|
197
|
+
export declare const CONTROL_SUMMARY_KEY = "control_link";
|
|
198
|
+
/** Field in participants[] of the check result for how the ECU declared it exposes its variables. */
|
|
199
|
+
export declare const CONTROL_CHECK_KEY = "control";
|
|
200
|
+
/** How the ECU declared it exposes its variables (participants[].control of the check). */
|
|
201
|
+
export interface ControlOffer extends FromLauncher {
|
|
202
|
+
/** Transport (silkit for now). */
|
|
203
|
+
transport: string;
|
|
204
|
+
/** Format version of the messages. */
|
|
205
|
+
wire_version: number | null;
|
|
206
|
+
/** Revision of the format (null from a launcher that does not say). */
|
|
207
|
+
wire_revision: number | null;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* The launcher's control_link event and result (and control_link of a participant in the summary): how a participant's
|
|
211
|
+
* variable interface is connected.
|
|
212
|
+
*/
|
|
213
|
+
export interface ControlLink extends FromLauncher {
|
|
214
|
+
state: ControlState;
|
|
215
|
+
/** connected: number of variables the ECU exposes. */
|
|
216
|
+
variables: number | null;
|
|
217
|
+
/** version_mismatch: the other side's format version. */
|
|
218
|
+
version: number | null;
|
|
219
|
+
/** Number of messages that arrived later than promised (result only; events lack it, so null). */
|
|
220
|
+
late_messages: number | null;
|
|
221
|
+
}
|
|
222
|
+
export declare const readControlLink: (value: unknown, path: string, u?: Unreadable) => ControlLink;
|
|
223
|
+
/** Name of the run result (`result.result` of the `result` event). */
|
|
224
|
+
export type RunResultName = Open<'passed' | 'stopped' | 'incomplete' | 'failed' | 'interrupted' | 'check_failed' | 'unreadable' | 'setup_failed' | 'usage'>;
|
|
225
|
+
/** Why the run ended (`result.end` of the `result` event). */
|
|
226
|
+
export type RunEnd = Open<'completed' | 'stopped' | 'interrupted' | 'failed' | 'setup_failed'>;
|
|
227
|
+
/**
|
|
228
|
+
* The result's timing: how time advanced (the numbers are defined in "Running at a set speed (`speed`)" in
|
|
229
|
+
* docs/simulation-run.md). null in the result when nothing was started, or from an older launcher. Each field is null
|
|
230
|
+
* when it is missing or cannot be read.
|
|
231
|
+
*/
|
|
232
|
+
export interface RunTiming extends FromLauncher {
|
|
233
|
+
/** Speed at the end. */
|
|
234
|
+
speed: Speed;
|
|
235
|
+
/** The controller's time step (ms). A step command is rounded up to a multiple of it. */
|
|
236
|
+
time_step_ms: number | null;
|
|
237
|
+
ecu_step_ms: number | null;
|
|
238
|
+
/** Maximum by which an ECU step runs late because the time step is coarser than the ECU's step (ms). */
|
|
239
|
+
step_delay_ms: number | null;
|
|
240
|
+
late_tolerance_ms: number | null;
|
|
241
|
+
sim_ms: number | null;
|
|
242
|
+
/** Real time taken (including time spent paused). */
|
|
243
|
+
wall_ms: number | null;
|
|
244
|
+
actual_speed: number | null;
|
|
245
|
+
/** Number of paced time steps. 0 means it ran as fast as possible (lateness not counted). */
|
|
246
|
+
paced_steps: number | null;
|
|
247
|
+
late_steps: number | null;
|
|
248
|
+
max_late_ms: number | null;
|
|
249
|
+
slipped_ms: number | null;
|
|
250
|
+
late_ms: number | null;
|
|
251
|
+
paused_ms: number | null;
|
|
252
|
+
}
|
|
253
|
+
/** A participant of the run that the launcher does not know to be on a network (or on any network). */
|
|
254
|
+
export interface TrafficUnplaced extends FromLauncher {
|
|
255
|
+
participant: string;
|
|
256
|
+
/** Why (for example no_control_link, no_counters). */
|
|
257
|
+
reason: string;
|
|
258
|
+
}
|
|
259
|
+
/** The counts of one participant on one network. */
|
|
260
|
+
export interface TrafficParticipant extends FromLauncher {
|
|
261
|
+
name: string;
|
|
262
|
+
counted: boolean;
|
|
263
|
+
/** Why it was not counted (for example no_control_link, restarted, real_time); null when counted. */
|
|
264
|
+
not_counted: string | null;
|
|
265
|
+
/** Whether it runs in virtual time; null if its connection to the ECU variables did not connect. */
|
|
266
|
+
virtual_time: boolean | null;
|
|
267
|
+
/** Virtual time of the step whose counts were read (ms); null when not counted. */
|
|
268
|
+
at_ms: number | null;
|
|
269
|
+
/** Frames the port accepted for sending; null when not counted. */
|
|
270
|
+
frames_sent: number | null;
|
|
271
|
+
/** J1939 frames of other participants that the port delivered; null when not counted. */
|
|
272
|
+
frames_received: number | null;
|
|
273
|
+
}
|
|
274
|
+
/** The traffic on one network of the configuration file. */
|
|
275
|
+
export interface TrafficNetwork extends FromLauncher {
|
|
276
|
+
/** The simulation's name of the network. */
|
|
277
|
+
name: string;
|
|
278
|
+
kind: string | null;
|
|
279
|
+
/** Number of counted participants. */
|
|
280
|
+
counted: number;
|
|
281
|
+
/** How many counted participants sent one frame or more. */
|
|
282
|
+
senders: number;
|
|
283
|
+
/** How many counted participants received one frame or more. */
|
|
284
|
+
receivers: number;
|
|
285
|
+
/** true: sent frames arrived; false: a counted participant sent and none received them; null: cannot be decided. */
|
|
286
|
+
delivered: boolean | null;
|
|
287
|
+
/** Participants that may be on this network without the launcher knowing. */
|
|
288
|
+
unplaced: TrafficUnplaced[];
|
|
289
|
+
/** The participants known to be on the network, in configuration file order. */
|
|
290
|
+
participants: TrafficParticipant[];
|
|
291
|
+
}
|
|
292
|
+
/** `traffic` of the run result: whether J1939 frames arrived on each network. */
|
|
293
|
+
export interface RunTraffic extends FromLauncher {
|
|
294
|
+
/** The virtual time at which the run ended; the counts are from steps that started before it (ms). */
|
|
295
|
+
before_ms: number | null;
|
|
296
|
+
/** Participants of the run that the launcher knows on no network. */
|
|
297
|
+
unplaced: TrafficUnplaced[];
|
|
298
|
+
/** Every network of the configuration file, in its order. */
|
|
299
|
+
networks: TrafficNetwork[];
|
|
300
|
+
}
|
|
301
|
+
/** Result of `vehicle_sil_launch run --json` (format version 2). */
|
|
302
|
+
export interface RunResult extends FromLauncher {
|
|
303
|
+
file: string | null;
|
|
304
|
+
result: RunResultName;
|
|
305
|
+
/** Why the run ended. null if nothing was started (the check failed, the file or the command line was wrong). */
|
|
306
|
+
end: RunEnd | null;
|
|
307
|
+
/** Whether the result is a success (the launcher's exit code is 0). false if it cannot be read. */
|
|
308
|
+
ok: boolean;
|
|
309
|
+
/** One English sentence that says what the result is. '' if it cannot be read (or the server shrank the result). */
|
|
310
|
+
message: string;
|
|
311
|
+
errors: number;
|
|
312
|
+
warnings: number;
|
|
313
|
+
notes: number;
|
|
314
|
+
simulation: string | null;
|
|
315
|
+
interrupted_by: string | null;
|
|
316
|
+
/** How time advanced. null from older launchers, and when nothing was started. */
|
|
317
|
+
timing: RunTiming | null;
|
|
318
|
+
participants: RunParticipant[];
|
|
319
|
+
findings: Finding[];
|
|
320
|
+
check: CheckResult | null;
|
|
321
|
+
/** Result of the scenario (only for a run with `--scenario`; null otherwise). */
|
|
322
|
+
scenario: ScenarioResult | null;
|
|
323
|
+
/**
|
|
324
|
+
* Whether J1939 frames arrived on each network. null if the simulation did not start, from an older launcher, or in
|
|
325
|
+
* a result the server shrank (absent on an object built by hand).
|
|
326
|
+
*/
|
|
327
|
+
traffic?: RunTraffic | null;
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* Reads a run result. With u, part by part: a result the server shrank to fit its limits (only the short, non-nested
|
|
331
|
+
* fields) is still read as a result (participants and findings become empty and go into the unreadable parts). ''
|
|
332
|
+
* if the result's name cannot be read.
|
|
333
|
+
*/
|
|
334
|
+
export declare const readRunResult: (value: unknown, path: string, u?: Unreadable) => RunResult;
|
|
335
|
+
/** Phases. They advance in this order; one may be skipped, but they never go back. */
|
|
336
|
+
export declare const PHASES: readonly ["checking", "starting", "waiting", "running", "stopping", "ended"];
|
|
337
|
+
export type Phase = Open<(typeof PHASES)[number]>;
|
|
338
|
+
export type ParticipantState = Open<'disabled' | 'not_started' | 'started'
|
|
339
|
+
/** Not started because the user starts this participant (instead of started). joined follows once it joins. */
|
|
340
|
+
| 'manual' | 'joined' | 'failed' | 'ended' | 'stop_requested' | 'killed'>;
|
|
341
|
+
interface EventBase extends FromLauncher {
|
|
342
|
+
seq: number;
|
|
343
|
+
/** Real time since the launcher started (ms). Some events lack it (the server passes them through without it). */
|
|
344
|
+
t_ms: number | null;
|
|
345
|
+
/**
|
|
346
|
+
* Names of the fields that could not be read (prefixed with the event kind, as in `finding.code`). Absent if none.
|
|
347
|
+
*/
|
|
348
|
+
unreadable?: string[];
|
|
349
|
+
}
|
|
350
|
+
export type LauncherEvent = (EventBase & {
|
|
351
|
+
event: 'hello';
|
|
352
|
+
vehicle_sil_events: number;
|
|
353
|
+
vehicle_sil: string;
|
|
354
|
+
pid: number | null;
|
|
355
|
+
file: string | null;
|
|
356
|
+
arguments: string[];
|
|
357
|
+
}) | (EventBase & {
|
|
358
|
+
event: 'phase';
|
|
359
|
+
phase: Phase;
|
|
360
|
+
}) | (EventBase & {
|
|
361
|
+
event: 'check';
|
|
362
|
+
check: CheckResult | null;
|
|
363
|
+
}) | (EventBase & {
|
|
364
|
+
event: 'registry';
|
|
365
|
+
uri: string | null;
|
|
366
|
+
}) | (EventBase & {
|
|
367
|
+
event: 'participant';
|
|
368
|
+
name: string;
|
|
369
|
+
state: ParticipantState;
|
|
370
|
+
pid: number | null;
|
|
371
|
+
exit_code: number | null;
|
|
372
|
+
signal: string | null;
|
|
373
|
+
/**
|
|
374
|
+
* failed: why it was counted as failed (left_simulation, process_ended, ended_before_start; more may be added).
|
|
375
|
+
*/
|
|
376
|
+
reason: string | null;
|
|
377
|
+
/** not_started: why it could not be started. failed: the text of that finding (if decided). */
|
|
378
|
+
message: string | null;
|
|
379
|
+
/** manual: the command that starts it, as one line to paste into this OS's shell (as the launcher wrote it). */
|
|
380
|
+
command_line: string | null;
|
|
381
|
+
/** manual: the directory to run that command in. */
|
|
382
|
+
working_directory: string | null;
|
|
383
|
+
/**
|
|
384
|
+
* manual: environment variables to set when starting it (names and values). Only when the registry is not on a
|
|
385
|
+
* loopback address (`{"VEHICLE_SIL_LISTEN_ON_NETWORK": "1"}`). null if none.
|
|
386
|
+
*/
|
|
387
|
+
environment: Record<string, string> | null;
|
|
388
|
+
}) | (EventBase & {
|
|
389
|
+
event: 'log';
|
|
390
|
+
source: string;
|
|
391
|
+
line: string;
|
|
392
|
+
})
|
|
393
|
+
/** State of the connection to the ECU's variables (once per started participant, just before the start). */
|
|
394
|
+
| (EventBase & {
|
|
395
|
+
event: typeof CONTROL_EVENT;
|
|
396
|
+
name: string;
|
|
397
|
+
link: ControlLink;
|
|
398
|
+
})
|
|
399
|
+
/**
|
|
400
|
+
* Number of log lines the launcher could not write because the reader was slow (per source). Arrives at their
|
|
401
|
+
* position.
|
|
402
|
+
*/
|
|
403
|
+
| (EventBase & {
|
|
404
|
+
event: 'log_dropped';
|
|
405
|
+
count: number;
|
|
406
|
+
sources: Record<string, number>;
|
|
407
|
+
}) | (EventBase & {
|
|
408
|
+
event: 'finding';
|
|
409
|
+
finding: Finding;
|
|
410
|
+
}) | (EventBase & {
|
|
411
|
+
event: 'time';
|
|
412
|
+
} & TimeReport) | (EventBase & {
|
|
413
|
+
event: 'command';
|
|
414
|
+
} & CommandReport)
|
|
415
|
+
/** What the run accepts now (docs/simulation-events.md): written whenever that changes. */
|
|
416
|
+
| (EventBase & {
|
|
417
|
+
event: 'state';
|
|
418
|
+
} & StateReport)
|
|
419
|
+
/** The counts of a network that `--connect` connected (at most once a second for each network). */
|
|
420
|
+
| (EventBase & {
|
|
421
|
+
event: 'outside';
|
|
422
|
+
network: string;
|
|
423
|
+
to_outside: number;
|
|
424
|
+
from_outside: number;
|
|
425
|
+
})
|
|
426
|
+
/** A scenario step started (status running) or was decided. */
|
|
427
|
+
| (EventBase & {
|
|
428
|
+
event: 'scenario_step';
|
|
429
|
+
step: ScenarioStep;
|
|
430
|
+
}) | (EventBase & {
|
|
431
|
+
event: 'result';
|
|
432
|
+
result: RunResult;
|
|
433
|
+
});
|
|
434
|
+
/**
|
|
435
|
+
* The time event (and time of the summary): the virtual time the controller sees, and how it keeps up with real time.
|
|
436
|
+
* Whether the simulation is paused, and the speed set, are in the state event (StateReport). Fields that are absent
|
|
437
|
+
* or unreadable are null (the screen does not show null values).
|
|
438
|
+
*/
|
|
439
|
+
export interface TimeReport {
|
|
440
|
+
/** Virtual time (ms; never decreases). */
|
|
441
|
+
sim_ms: number;
|
|
442
|
+
/** Actual speed over roughly the last second. null when it has run only briefly, or in an event written while paused. */
|
|
443
|
+
actual_speed: number | null;
|
|
444
|
+
/** Number of late time steps so far (the value if it ended now; 0 when running as fast as possible). */
|
|
445
|
+
late_steps: number | null;
|
|
446
|
+
/** Max lateness so far (ms). */
|
|
447
|
+
max_late_ms: number | null;
|
|
448
|
+
/** Total slip so far (ms). */
|
|
449
|
+
slipped_ms: number | null;
|
|
450
|
+
/** Current lateness of a time step that is past its deadline and has not started yet (ms; 0 if none). */
|
|
451
|
+
late_ms: number | null;
|
|
452
|
+
}
|
|
453
|
+
export declare function readTimeFields(f: Fields, path: string, u?: Unreadable): TimeReport;
|
|
454
|
+
/** The command event (and last_command of the summary): whether the launcher accepted a command from stdin. */
|
|
455
|
+
export interface CommandReport {
|
|
456
|
+
/** Name of the command (null for an unreadable line). */
|
|
457
|
+
command: string | null;
|
|
458
|
+
/** stdin: arrived as a line; eof: end of stdin. */
|
|
459
|
+
source: Open<'stdin' | 'eof'>;
|
|
460
|
+
accepted: boolean;
|
|
461
|
+
/** Why it was not accepted (shown in English, unchanged). null if accepted. */
|
|
462
|
+
message: string | null;
|
|
463
|
+
/**
|
|
464
|
+
* For an accepted step, the virtual time it actually advances (rounded up to a multiple of the time step). null
|
|
465
|
+
* otherwise.
|
|
466
|
+
*/
|
|
467
|
+
ms: number | null;
|
|
468
|
+
/** Why it was not accepted, as a code that stays the same (an entry of `reason` in the launcher's documents). null if accepted. */
|
|
469
|
+
reason: string | null;
|
|
470
|
+
/**
|
|
471
|
+
* The `id` the line had (the GUI server passes the `id` of POST api/time on), so an answer is tied to the command it
|
|
472
|
+
* answers. null when the line had none, and from a launcher before `state`.
|
|
473
|
+
*/
|
|
474
|
+
id: number | null;
|
|
475
|
+
/**
|
|
476
|
+
* For an accepted `step`, `run_until` and `pause` with a time: the virtual time at which the simulation pauses (null
|
|
477
|
+
* otherwise, and from a launcher that does not write it).
|
|
478
|
+
*/
|
|
479
|
+
at_ms: number | null;
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* last_command of the summary: the event's fields and that event's seq (null from older servers, which do not write
|
|
483
|
+
* it).
|
|
484
|
+
*/
|
|
485
|
+
export type SummaryCommand = CommandReport & {
|
|
486
|
+
seq: number | null;
|
|
487
|
+
};
|
|
488
|
+
export declare function readCommandFields(f: Fields, path: string, u?: Unreadable): CommandReport;
|
|
489
|
+
/**
|
|
490
|
+
* A reason with an English sentence: the `caution` of an operation that is accepted with a warning (of the launcher's
|
|
491
|
+
* `allowed`, and of the GUI server's `allowed.save`).
|
|
492
|
+
*/
|
|
493
|
+
export interface Caution {
|
|
494
|
+
code: string;
|
|
495
|
+
message: string;
|
|
496
|
+
}
|
|
497
|
+
/** Reads a `caution` object (`{code, message}`). */
|
|
498
|
+
export declare const readCaution: Reader<Caution>;
|
|
499
|
+
/**
|
|
500
|
+
* Whether the launcher accepts one operation now (an entry of `allowed` in the `state` event). `ok` says "it would
|
|
501
|
+
* accept it", not "it would change something". The other keys of the entry (`min_ms`, `max_ms` of step, `min`, `max`
|
|
502
|
+
* of speed) are in `raw`.
|
|
503
|
+
*/
|
|
504
|
+
export interface LauncherAllowedItem extends FromLauncher {
|
|
505
|
+
ok: boolean;
|
|
506
|
+
/** Why not: a code that stays the same. null if ok. */
|
|
507
|
+
reason: string | null;
|
|
508
|
+
/** Why not, in one English sentence. null if ok. */
|
|
509
|
+
message: string | null;
|
|
510
|
+
/** Accepted, with a warning. null if none. */
|
|
511
|
+
caution: Caution | null;
|
|
512
|
+
}
|
|
513
|
+
/**
|
|
514
|
+
* One network that `--connect` connected to a real bus, as `outside[]` of the state event has it ("The state of the
|
|
515
|
+
* link and the bus" in docs/simulation-events.md). The counts are in the `outside` event.
|
|
516
|
+
*/
|
|
517
|
+
export interface OutsideState extends FromLauncher {
|
|
518
|
+
network: string;
|
|
519
|
+
/** What `--connect` gave for the network. */
|
|
520
|
+
target: string | null;
|
|
521
|
+
/** The bridge (`bridge.<network>`). */
|
|
522
|
+
participant: string | null;
|
|
523
|
+
/** Ethernet: up, down or unknown; null before the bridge has said. */
|
|
524
|
+
link: Open<'up' | 'down' | 'unknown'> | null;
|
|
525
|
+
/** CAN: active, passive, bus-off or unknown; null for Ethernet, or before the bridge has said. */
|
|
526
|
+
bus: Open<'active' | 'passive' | 'bus-off' | 'unknown'> | null;
|
|
527
|
+
/** Frames went to the bus and nothing came from a device there for 10 s. */
|
|
528
|
+
nothing_received: boolean;
|
|
529
|
+
condition: Open<'ok' | 'interrupted' | 'degraded'>;
|
|
530
|
+
/** Codes of why the condition is not ok, in the launcher's order (empty when it is). */
|
|
531
|
+
reasons: string[];
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* The state event: where the run stands and what it accepts now. The set of keys of `allowed` can grow.
|
|
535
|
+
*/
|
|
536
|
+
export interface StateReport {
|
|
537
|
+
/** Goes up with each change: tells a newer state from the same one sent again. */
|
|
538
|
+
rev: number;
|
|
539
|
+
/** The phase (as in the phase event). */
|
|
540
|
+
phase: string;
|
|
541
|
+
/** Whether the simulation stands still. null if not written. */
|
|
542
|
+
paused: boolean | null;
|
|
543
|
+
/**
|
|
544
|
+
* The virtual time (ms) at which it stands still. null while it does not, and while `paused` is true but the
|
|
545
|
+
* simulation has not come to a stand yet (before it starts; a pause at a time that has passed, until the next step).
|
|
546
|
+
*/
|
|
547
|
+
paused_at_ms: number | null;
|
|
548
|
+
/** Whether the run waits before the step at time 0 (a run started paused with a Control Server). null if not written. */
|
|
549
|
+
holding: boolean | null;
|
|
550
|
+
/** The speed that was asked for. null before the launcher knows it. */
|
|
551
|
+
speed: Speed;
|
|
552
|
+
/** Whether the run keeps to its speed: not-paced, on-time or late. */
|
|
553
|
+
pacing: Open<'not-paced' | 'on-time' | 'late'> | null;
|
|
554
|
+
/** The stop requests the run has had, and the first source. */
|
|
555
|
+
stop: {
|
|
556
|
+
requests: number;
|
|
557
|
+
by: string | null;
|
|
558
|
+
} | null;
|
|
559
|
+
/** Whether the run plays a scenario. */
|
|
560
|
+
scenario: boolean | null;
|
|
561
|
+
/** The operations: pause, resume, step, speed, run_until, stop, write. */
|
|
562
|
+
allowed: Record<string, LauncherAllowedItem>;
|
|
563
|
+
/**
|
|
564
|
+
* The networks that `--connect` connected, in the order of the bridges; empty without `--connect`, and in a run that
|
|
565
|
+
* a `role: bridge` participant of the file connects (so it does not tell whether the run is connected outside).
|
|
566
|
+
* The parsers always set it (empty from a launcher that does not write it); absent on an object built by hand.
|
|
567
|
+
*/
|
|
568
|
+
outside?: OutsideState[];
|
|
569
|
+
}
|
|
570
|
+
export declare function readStateFields(f: Fields, path: string, u?: Unreadable): StateReport;
|
|
571
|
+
/** The last state event, as the summary of the session keeps it: with that event's seq. */
|
|
572
|
+
export type SummaryState = StateReport & {
|
|
573
|
+
seq: number | null;
|
|
574
|
+
};
|
|
575
|
+
/**
|
|
576
|
+
* Reads one launcher event. An unknown event is null (skipped). If partly is true, reads part by part: an unreadable
|
|
577
|
+
* field gets its default value and its name goes into unreadable (throws only when the core seq and event, or the core
|
|
578
|
+
* fields of the event kind, cannot be read).
|
|
579
|
+
*/
|
|
580
|
+
export declare const readLauncherEvent: (value: unknown, path: string, partly?: boolean) => LauncherEvent | null;
|
|
581
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Building blocks of the parsers in launcher.ts and server.ts: the error, the readers of single values, and reading
|
|
3
|
+
* part by part (Unreadable). All parsers follow these rules:
|
|
4
|
+
* - Unknown fields are not read. The parsers of the launcher's objects (launcher.ts) keep the object they read in
|
|
5
|
+
* `raw` (withRaw), so a screen can still find them there; the other parsers ignore them. Unknown events and
|
|
6
|
+
* unknown notifications become null and are skipped.
|
|
7
|
+
* - Fields whose set of values may grow (phase, state, result and so on) pass unknown values through as strings.
|
|
8
|
+
* - Data of the wrong shape (missing field, wrong type, unknown format version) throws ProtocolError.
|
|
9
|
+
* - Exception: the session summary and launcher events are read part by part (readSessionSummary, readServerMessage).
|
|
10
|
+
* If a part that comes from the launcher (check, result, findings, participants) or a part the server shrank to fit
|
|
11
|
+
* its limits cannot be read, the readable parts are still used; an unreadable part gets its default value and its
|
|
12
|
+
* name goes into `unreadable`. Only when the summary core (id, state, launcher, stop) or the event core (seq, event)
|
|
13
|
+
* cannot be read is the whole thing unreadable.
|
|
14
|
+
*/
|
|
15
|
+
/** Data of an unreadable shape. path is where it broke (for example `event.participants[0].name`). */
|
|
16
|
+
export declare class ProtocolError extends Error {
|
|
17
|
+
readonly path: string;
|
|
18
|
+
readonly expected: string;
|
|
19
|
+
constructor(path: string, expected: string);
|
|
20
|
+
}
|
|
21
|
+
/** A string whose set of values may grow. Known values get completion; unknown values are allowed too. */
|
|
22
|
+
export type Open<T extends string> = T | (string & {});
|
|
23
|
+
/**
|
|
24
|
+
* Reads a received value. path is how the error location is shown (for example `message.session`). Throws ProtocolError
|
|
25
|
+
* on the wrong shape.
|
|
26
|
+
*/
|
|
27
|
+
export type Reader<T> = (value: unknown, path: string) => T;
|
|
28
|
+
export type Fields = Record<string, unknown>;
|
|
29
|
+
export declare function object(value: unknown, path: string): Fields;
|
|
30
|
+
export declare const string: Reader<string>;
|
|
31
|
+
export declare const number: Reader<number>;
|
|
32
|
+
export declare const integer: Reader<number>;
|
|
33
|
+
export declare const boolean: Reader<boolean>;
|
|
34
|
+
export declare function nullable<T>(read: Reader<T>): Reader<T | null>;
|
|
35
|
+
/** fallback when the field is absent (undefined). For fields that older launchers do not write yet. */
|
|
36
|
+
export declare function optional<T, F>(read: Reader<T>, fallback: F): Reader<T | F>;
|
|
37
|
+
export declare function array<T>(read: Reader<T>): Reader<T[]>;
|
|
38
|
+
export declare function field<T>(fields: Fields, path: string, key: string, read: Reader<T>): T;
|
|
39
|
+
/**
|
|
40
|
+
* Collects the names of the parts that could not be read when reading part by part. Names are relative to root,
|
|
41
|
+
* without array indexes (`message.session.participants[2].signal` → `participants.signal`).
|
|
42
|
+
*/
|
|
43
|
+
export declare class Unreadable {
|
|
44
|
+
private readonly root;
|
|
45
|
+
private readonly prefix;
|
|
46
|
+
private readonly names;
|
|
47
|
+
constructor(root: string, prefix?: string);
|
|
48
|
+
add(path: string): void;
|
|
49
|
+
get parts(): string[];
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* If unreadable, uses fallback and records the location in u (throws without u). An absent field counts as unreadable.
|
|
53
|
+
*/
|
|
54
|
+
export declare function lenient<T, F>(read: Reader<T>, fallback: F, u?: Unreadable): Reader<T | F>;
|
|
55
|
+
/**
|
|
56
|
+
* An absent field silently becomes fallback; a field of the wrong type becomes fallback and is recorded in u (throws
|
|
57
|
+
* without u).
|
|
58
|
+
*/
|
|
59
|
+
export declare function soft<T, F>(read: Reader<T>, fallback: F, u?: Unreadable): Reader<T | F>;
|
|
60
|
+
/** An array. With u, unreadable elements are skipped and recorded in u (empty if absent or not an array). */
|
|
61
|
+
export declare function items<T>(read: Reader<T>, u?: Unreadable): Reader<T[]>;
|
|
62
|
+
/**
|
|
63
|
+
* A format version field. An unknown version is not read (its meaning may have changed). When reading part by part
|
|
64
|
+
* (u), it is recorded as an unreadable part and the readable fields are still read.
|
|
65
|
+
*/
|
|
66
|
+
export declare function version(fields: Fields, path: string, key: string, expected: number, u?: Unreadable): void;
|
|
67
|
+
export declare function record<T>(read: Reader<T>): Reader<Record<string, T>>;
|
|
68
|
+
/**
|
|
69
|
+
* Gives read the object its fields were read from, as `raw`: read-only, and not enumerable, so that JSON.stringify,
|
|
70
|
+
* Object.keys and deep equality see the same fields as before (spreading `{...read}` does not copy it). Returns read.
|
|
71
|
+
*/
|
|
72
|
+
export declare function withRaw<T extends object>(raw: Fields, read: T): T;
|