@vehicle-sil/gui-client 0.0.0-stage → 0.2.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.ja.md +839 -0
- package/README.md +836 -2
- package/dist/elements.js +872 -0
- package/dist/index.js +5354 -0
- package/package.json +39 -4
- package/timeline/vehicle-sil-timeline.d.ts +108 -0
- package/timeline/vehicle-sil-timeline.js +4391 -0
- package/timeline/vehicle-sil-timeline.mjs +4393 -0
- package/types/client.d.ts +148 -0
- package/types/connection.d.ts +155 -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 +122 -0
- package/types/front-compose.d.ts +61 -0
- package/types/front-outside.d.ts +19 -0
- package/types/front-types.d.ts +353 -0
- package/types/front-variable.d.ts +28 -0
- package/types/front.d.ts +50 -0
- package/types/http.d.ts +71 -0
- package/types/index.d.ts +28 -0
- package/types/protocol/launcher.d.ts +578 -0
- package/types/protocol/read.d.ts +72 -0
- package/types/protocol/server.d.ts +758 -0
- package/types/protocol.d.ts +15 -0
- package/types/run.d.ts +74 -0
- package/types/session-state.d.ts +289 -0
- package/types/session.d.ts +130 -0
- package/types/time.d.ts +133 -0
- package/types/token.d.ts +35 -0
- package/types/urls.d.ts +8 -0
- package/types/values.d.ts +54 -0
- package/types/variable-binding.d.ts +181 -0
- package/types/variable-state.d.ts +134 -0
- package/types/variables.d.ts +382 -0
|
@@ -0,0 +1,758 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shapes the GUI server decides: the HTTP API (`api/*`), the WebSocket messages and the dashboard files. Parts that
|
|
3
|
+
* come from the launcher (check, result, events) have the shapes of launcher.ts. Rules of the parsers: read.ts.
|
|
4
|
+
*/
|
|
5
|
+
import { Open, Reader } from './read.js';
|
|
6
|
+
import { CheckResult, ControlLink, Finding, LauncherEvent, ParticipantState, Phase, RunResult, ScenarioStatus, ScenarioStep, Speed, SummaryCommand, SummaryState, TimeReport, Caution } from './launcher.js';
|
|
7
|
+
/**
|
|
8
|
+
* The version of the GUI server's API that this library reads (`vehicle_sil_gui` of `api/app` and `hello`). It does not
|
|
9
|
+
* read a hello or an api/app of another version (their fields may mean something else). When to raise the version:
|
|
10
|
+
* "Versioning and compatibility" in gui/protocol/README.md.
|
|
11
|
+
*/
|
|
12
|
+
export declare const PROTOCOL_VERSION = 2;
|
|
13
|
+
/**
|
|
14
|
+
* A server notice (an API error, a WebSocket error, problems of the session). message is shown in English, unchanged.
|
|
15
|
+
*/
|
|
16
|
+
export interface ServerProblem {
|
|
17
|
+
code: string;
|
|
18
|
+
message: string;
|
|
19
|
+
/** For launcher-stderr, the number of lines dropped at this point (`detail.skipped`). Other notices lack it. */
|
|
20
|
+
skipped?: number;
|
|
21
|
+
/** For `check-failed`, the findings of the check that refused the start (`detail.findings`; unreadable ones left out). */
|
|
22
|
+
findings?: Finding[];
|
|
23
|
+
}
|
|
24
|
+
/** Reads a server notice (`{code, message, detail}`). The `error` in an HTTP error has the same shape. */
|
|
25
|
+
export declare const readServerProblem: Reader<ServerProblem>;
|
|
26
|
+
/** GET api/app: versions of the server and the launcher, whether they are usable, and limits. */
|
|
27
|
+
export interface AppInfo {
|
|
28
|
+
version: string;
|
|
29
|
+
/** An identifier that changes every time the server starts. If it changed, the server restarted. */
|
|
30
|
+
instance: string;
|
|
31
|
+
/** Where configuration files can be chosen from (for display). */
|
|
32
|
+
root: string;
|
|
33
|
+
/** The configuration file given at start-up (relative to root). null if none. */
|
|
34
|
+
initial_file: string | null;
|
|
35
|
+
launcher: {
|
|
36
|
+
path: string | null;
|
|
37
|
+
/** Whether the launcher has the features the screen needs. */
|
|
38
|
+
usable: boolean;
|
|
39
|
+
/** Why it is unusable (shown in English, unchanged). */
|
|
40
|
+
problems: ServerProblem[];
|
|
41
|
+
features: string[];
|
|
42
|
+
};
|
|
43
|
+
limits: {
|
|
44
|
+
speed_min: number;
|
|
45
|
+
speed_max: number;
|
|
46
|
+
/** Upper limit of the ms of a step. Older servers do not write it, so the launcher's limit (10^12). */
|
|
47
|
+
step_ms_max: number;
|
|
48
|
+
/** Time limit of a check (s; `--check-timeout`). Older servers do not write it, so its default (120). */
|
|
49
|
+
check_timeout_s: number;
|
|
50
|
+
/**
|
|
51
|
+
* Variable watches: lower and upper limit of the interval (ms), number per connection, variables that can be named
|
|
52
|
+
* in one.
|
|
53
|
+
*/
|
|
54
|
+
watch_period_ms_min: number;
|
|
55
|
+
watch_period_ms_max: number;
|
|
56
|
+
watches: number;
|
|
57
|
+
watch_variables: number;
|
|
58
|
+
/** Limit on the variables in one write, and limit on the virtual time (ms) a write can name. */
|
|
59
|
+
writes_per_request: number;
|
|
60
|
+
write_at_ms_max: number;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Whether variables could be read and written if a run started now (the launcher has a Control Server and the GUI
|
|
64
|
+
* server has gRPC), and why not (shown in English, unchanged). Older servers do not write it (available is false,
|
|
65
|
+
* reason is null).
|
|
66
|
+
*/
|
|
67
|
+
variables: {
|
|
68
|
+
available: boolean;
|
|
69
|
+
reason: string | null;
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
export declare const readAppInfo: (value: unknown) => AppInfo;
|
|
73
|
+
/** One entry of GET api/configs. */
|
|
74
|
+
export interface ConfigFile {
|
|
75
|
+
/** Path relative to root (separator /). */
|
|
76
|
+
path: string;
|
|
77
|
+
}
|
|
78
|
+
/** GET api/configs: the configuration files under root. */
|
|
79
|
+
export interface ConfigList {
|
|
80
|
+
files: ConfigFile[];
|
|
81
|
+
/** Whether the list was cut off at the limit. */
|
|
82
|
+
truncated: boolean;
|
|
83
|
+
}
|
|
84
|
+
export declare const readConfigList: (value: unknown) => ConfigList;
|
|
85
|
+
/**
|
|
86
|
+
* Body of POST api/check: `file` (this server's field) and the keys of the request file that the launcher reads
|
|
87
|
+
* (`schema/run-request.schema.json`), with the same names and value forms. A key that is not wanted is left out: there
|
|
88
|
+
* is no null.
|
|
89
|
+
*/
|
|
90
|
+
export interface CheckRequest {
|
|
91
|
+
/** Path relative to root. */
|
|
92
|
+
file: string;
|
|
93
|
+
/** The format of the request file: 1, or left out. */
|
|
94
|
+
vehicle_sil_run_request?: 1;
|
|
95
|
+
/** Names of the participants to leave out (only names in the check result). */
|
|
96
|
+
disable: string[];
|
|
97
|
+
/** Names of the participants to take in although the configuration file disables them. */
|
|
98
|
+
enable?: string[];
|
|
99
|
+
/** Names of the participants the user starts (only names in the check result). */
|
|
100
|
+
manual?: string[];
|
|
101
|
+
/** The scenario (`path` from `GET api/scenarios`; only one in the list for that configuration file). */
|
|
102
|
+
scenario?: string;
|
|
103
|
+
/** The variant of the configuration file. */
|
|
104
|
+
variant?: string;
|
|
105
|
+
/** Values of the scenario's parameters (name to value); used only when a scenario runs. */
|
|
106
|
+
params?: Record<string, string | number | boolean>;
|
|
107
|
+
/** true: fail on warnings too. */
|
|
108
|
+
strict?: boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Where networks are connected outside the simulation: network name to target. For a network of the file, a target
|
|
111
|
+
* other than `none` must be a `value` that the last `POST api/connections` of that network gave with `usable: true`
|
|
112
|
+
* (else 400 target-not-listed); a network that the file lacks is left out by the launcher, with a note.
|
|
113
|
+
*/
|
|
114
|
+
connect?: Record<string, string>;
|
|
115
|
+
/** The time policy of a run connected outside (a name that the launcher takes, e.g. `free`; it decides what it allows). */
|
|
116
|
+
time_policy?: string;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Body of POST api/check with `text`: the text of `file` that is not saved yet. The check takes only the
|
|
120
|
+
* configuration (`variant`, `strict`), not the choices of a run, so there is no `disable` or `scenario` here.
|
|
121
|
+
*/
|
|
122
|
+
export interface CheckTextRequest {
|
|
123
|
+
/** Path relative to root: the file whose content `text` is (it must exist; its directory is where paths start). */
|
|
124
|
+
file: string;
|
|
125
|
+
/** The format of the request file: 1, or left out. */
|
|
126
|
+
vehicle_sil_run_request?: 1;
|
|
127
|
+
/** The content of the file as the screen has it (at most 1 MiB as UTF-8). */
|
|
128
|
+
text: string;
|
|
129
|
+
/** The variant of the configuration file. */
|
|
130
|
+
variant?: string;
|
|
131
|
+
/** true: fail on warnings too. */
|
|
132
|
+
strict?: boolean;
|
|
133
|
+
}
|
|
134
|
+
/** Body of POST api/describe: the saved file and the variant whose participants are described again. */
|
|
135
|
+
export interface DescribeRequest {
|
|
136
|
+
/** Path relative to root. */
|
|
137
|
+
file: string;
|
|
138
|
+
/** The variant of the configuration file (left out: none). */
|
|
139
|
+
variant?: string;
|
|
140
|
+
}
|
|
141
|
+
/** Body of POST api/connections: the configuration file and one of its networks (one the user opened). */
|
|
142
|
+
export interface ConnectionsRequest {
|
|
143
|
+
/** Path relative to root. */
|
|
144
|
+
file: string;
|
|
145
|
+
/** A name in `networks[].name` of the last check of `file`. */
|
|
146
|
+
network: string;
|
|
147
|
+
}
|
|
148
|
+
/** Answer of POST api/connections: where that network can be connected on this computer. */
|
|
149
|
+
export interface Connections {
|
|
150
|
+
file: string;
|
|
151
|
+
network: string;
|
|
152
|
+
/** The exit code of the launcher's `connections` (0: listed, 1: a list failed or the file has errors, 4: usage). */
|
|
153
|
+
exit_code: number;
|
|
154
|
+
/**
|
|
155
|
+
* The launcher's `connections --json` as it wrote it (`networks[].list.targets[]`: `value`, `label`, `detail`,
|
|
156
|
+
* `usable`, `reason`). A `value` with `usable: true` is what `connect` of api/check and api/run may give the network.
|
|
157
|
+
*/
|
|
158
|
+
connections: Record<string, unknown>;
|
|
159
|
+
}
|
|
160
|
+
/** Reads the answer of POST api/connections. */
|
|
161
|
+
export declare const readConnections: (value: unknown) => Connections;
|
|
162
|
+
/** One entry of GET api/scenarios. */
|
|
163
|
+
export interface ScenarioFile {
|
|
164
|
+
/** Path relative to root (send it as is in `scenario` of api/check and api/run). */
|
|
165
|
+
path: string;
|
|
166
|
+
/** File name. */
|
|
167
|
+
name: string;
|
|
168
|
+
}
|
|
169
|
+
/** GET api/scenarios: the .yaml and .yml files in `scenarios` next to the configuration file. */
|
|
170
|
+
export interface ScenarioList {
|
|
171
|
+
/** The configuration file (relative to root). */
|
|
172
|
+
file: string;
|
|
173
|
+
/** The scenario directory (relative to root). */
|
|
174
|
+
directory: string;
|
|
175
|
+
/** Whether the directory exists (a symbolic link to a directory counts as absent). */
|
|
176
|
+
found: boolean;
|
|
177
|
+
scenarios: ScenarioFile[];
|
|
178
|
+
truncated: boolean;
|
|
179
|
+
}
|
|
180
|
+
export declare const readScenarioList: (value: unknown) => ScenarioList;
|
|
181
|
+
/**
|
|
182
|
+
* GET api/recording: the values written through the GUI server and applied in the current (or last) run, as scenario
|
|
183
|
+
* YAML. The server writes no file (the screen hands it over as a browser download).
|
|
184
|
+
*/
|
|
185
|
+
export interface Recording {
|
|
186
|
+
session_id: number;
|
|
187
|
+
/** The run's configuration file (relative to root). */
|
|
188
|
+
file: string;
|
|
189
|
+
state: Open<'running' | 'ended'>;
|
|
190
|
+
/** Whether this run is being recorded (false for a run without variables and for a scenario run). */
|
|
191
|
+
available: boolean;
|
|
192
|
+
/** Why there is no yaml (shown in English, unchanged). */
|
|
193
|
+
reason: string | null;
|
|
194
|
+
/** Number of values put in the YAML. */
|
|
195
|
+
writes: number;
|
|
196
|
+
/** Number of values beyond the limit that were left out. */
|
|
197
|
+
omitted: number;
|
|
198
|
+
/** Number of steps (`set`) in the YAML. */
|
|
199
|
+
steps: number;
|
|
200
|
+
/** Scenario YAML. null while no write has been applied yet. */
|
|
201
|
+
yaml: string | null;
|
|
202
|
+
}
|
|
203
|
+
/** Answer of GET api/recording (null if there has been no run yet). */
|
|
204
|
+
export declare const readRecording: (value: unknown) => Recording | null;
|
|
205
|
+
/** Answer of GET api/config: the text of a configuration file as it is saved. */
|
|
206
|
+
export interface ConfigText {
|
|
207
|
+
/** Path relative to root. */
|
|
208
|
+
file: string;
|
|
209
|
+
/** The file's bytes read as UTF-8, as they are (a BOM and the line ends too). */
|
|
210
|
+
text: string;
|
|
211
|
+
/** SHA-256 of the file's bytes (64 lowercase hexadecimal digits). */
|
|
212
|
+
stamp: string;
|
|
213
|
+
}
|
|
214
|
+
/** Reads the answer of GET api/config. */
|
|
215
|
+
export declare const readConfigText: (value: unknown) => ConfigText;
|
|
216
|
+
/**
|
|
217
|
+
* Body of POST api/config: saves `text` as `file`. By default the server saves only an edit whose commands that run
|
|
218
|
+
* stay the same (the launcher's `check --compare-commands` says `"same"`); `allowed.save` says what applies.
|
|
219
|
+
*/
|
|
220
|
+
export interface SaveConfigRequest {
|
|
221
|
+
/** Path relative to root. */
|
|
222
|
+
file: string;
|
|
223
|
+
/** The whole content of the file (at most 1 MiB as UTF-8). Written as it is: a BOM and the line ends stay. */
|
|
224
|
+
text: string;
|
|
225
|
+
/** The `stamp` of GET api/config for the file as it was read, or null for a new file. */
|
|
226
|
+
stamp: string | null;
|
|
227
|
+
}
|
|
228
|
+
/** Answer of POST api/config: the file that was saved and the stamp of its new content. */
|
|
229
|
+
export interface SavedConfig {
|
|
230
|
+
/** Path relative to root. */
|
|
231
|
+
file: string;
|
|
232
|
+
/** SHA-256 of the bytes that were saved (the stamp to send with the next save). */
|
|
233
|
+
stamp: string;
|
|
234
|
+
}
|
|
235
|
+
/** Reads the answer of POST api/config. */
|
|
236
|
+
export declare const readSavedConfig: (value: unknown) => SavedConfig;
|
|
237
|
+
/** Takes the launcher's check result out of the answer to POST api/check (and POST api/describe). */
|
|
238
|
+
export declare const readCheckResponse: (value: unknown) => CheckResult;
|
|
239
|
+
/** Body of POST api/run. */
|
|
240
|
+
export interface RunRequest extends CheckRequest {
|
|
241
|
+
/** Simulation seconds per wall-clock second, or `max`; left out: as the configuration file says. */
|
|
242
|
+
speed?: number | 'max';
|
|
243
|
+
/** true: stand still at 0 until a resume or step; left out: no. */
|
|
244
|
+
start_paused?: boolean;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* A participant in the session summary (the participant events laid over each other per name; fields not received yet
|
|
248
|
+
* are null).
|
|
249
|
+
*/
|
|
250
|
+
export interface SummaryParticipant {
|
|
251
|
+
name: string;
|
|
252
|
+
state: ParticipantState | null;
|
|
253
|
+
pid: number | null;
|
|
254
|
+
exit_code: number | null;
|
|
255
|
+
signal: string | null;
|
|
256
|
+
/** reason of the failed event (why it was counted as failed; kept even if ended arrives later). */
|
|
257
|
+
reason: string | null;
|
|
258
|
+
/** The reason of not_started, or the text of the failed finding. */
|
|
259
|
+
message: string | null;
|
|
260
|
+
/** Names of fields too large to put in the summary (cleared once a later event delivers the field). */
|
|
261
|
+
omitted_fields: string[];
|
|
262
|
+
/** The launcher asked it to stop (a stop_requested event arrived; kept in later states). */
|
|
263
|
+
stop_requested: boolean;
|
|
264
|
+
/** command_line of the manual event (the command that starts it, as one line). null if none. */
|
|
265
|
+
command_line: string | null;
|
|
266
|
+
/** working_directory of the manual event. null if none. */
|
|
267
|
+
working_directory: string | null;
|
|
268
|
+
/** environment of the manual event (environment variables to set when starting it). null if none. */
|
|
269
|
+
environment: Record<string, string> | null;
|
|
270
|
+
/** State of the connection to the ECU's variables (the launcher's control_link event). null until it arrives. */
|
|
271
|
+
control_link: ControlLink | null;
|
|
272
|
+
}
|
|
273
|
+
/** launcher of the summary: whether the launcher process is running and, if it ended, how. */
|
|
274
|
+
export interface SummaryLauncher {
|
|
275
|
+
/**
|
|
276
|
+
* Whether it is running. Stays true after it printed the result, until the process exits. Decides whether it can be
|
|
277
|
+
* stopped.
|
|
278
|
+
*/
|
|
279
|
+
running: boolean;
|
|
280
|
+
exit_code: number | null;
|
|
281
|
+
/** Number of the signal that ended it (POSIX only). */
|
|
282
|
+
signal: number | null;
|
|
283
|
+
/**
|
|
284
|
+
* Running but has written nothing for longer than this many seconds (no heartbeat either; it may be stuck). null if
|
|
285
|
+
* not.
|
|
286
|
+
*/
|
|
287
|
+
silent_s: number | null;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* The stop the server requested from the launcher. none: not requested; requested: stop in order; forced: stop without
|
|
291
|
+
* waiting.
|
|
292
|
+
*/
|
|
293
|
+
export type StopRequest = Open<'none' | 'requested' | 'forced'>;
|
|
294
|
+
/** Per source, the number of lines the server holds and has dropped. */
|
|
295
|
+
export interface LogCounts {
|
|
296
|
+
kept: number;
|
|
297
|
+
dropped: number;
|
|
298
|
+
}
|
|
299
|
+
/**
|
|
300
|
+
* Summary of a server session (one run of the launcher). The screen rebuilds its state from it (the summary is
|
|
301
|
+
* authoritative).
|
|
302
|
+
*/
|
|
303
|
+
export interface SessionSummary {
|
|
304
|
+
id: number;
|
|
305
|
+
/** Path relative to root. */
|
|
306
|
+
file: string;
|
|
307
|
+
disable: string[];
|
|
308
|
+
/**
|
|
309
|
+
* Participants the user chose on the screen to start themselves (`--manual`; `manual: true` in the configuration file
|
|
310
|
+
* is in the check result).
|
|
311
|
+
*/
|
|
312
|
+
manual: string[];
|
|
313
|
+
/** Speed given at the start (null means as in the configuration file). The current speed is `speed` of launcher_state. */
|
|
314
|
+
speed: Speed;
|
|
315
|
+
/** Whether the run started paused. */
|
|
316
|
+
start_paused: boolean;
|
|
317
|
+
/** State as the server sees it. `ended` means the launcher has exited and its output has been read to the end. */
|
|
318
|
+
state: Open<'running' | 'ended'>;
|
|
319
|
+
launcher: SummaryLauncher;
|
|
320
|
+
stop: StopRequest;
|
|
321
|
+
phase: Phase | null;
|
|
322
|
+
last_seq: number | null;
|
|
323
|
+
/** t_ms of the last event received. */
|
|
324
|
+
last_t_ms: number | null;
|
|
325
|
+
/** Virtual time of the last time event. */
|
|
326
|
+
sim_ms: number | null;
|
|
327
|
+
/** Names of the fields of the last time event too large to put in the summary. */
|
|
328
|
+
time_omitted_fields: string[];
|
|
329
|
+
/** The last time event (virtual time, actual speed, lateness figures; whether it is paused, where, and the speed set are in launcher_state). null until it arrives. */
|
|
330
|
+
time: TimeReport | null;
|
|
331
|
+
/** The last command event (whether it was accepted, and why not). null until it arrives. */
|
|
332
|
+
last_command: SummaryCommand | null;
|
|
333
|
+
/**
|
|
334
|
+
* The last state event of the launcher (what it accepts now); only the last is kept. null until it arrives. The
|
|
335
|
+
* parsers always set it; it may be absent in a summary built by hand.
|
|
336
|
+
*/
|
|
337
|
+
launcher_state?: SummaryState | null;
|
|
338
|
+
/**
|
|
339
|
+
* What this server accepts now (start, stop, force). null from a server that does not say. The parsers always set
|
|
340
|
+
* it; it may be absent in a summary built by hand.
|
|
341
|
+
*/
|
|
342
|
+
allowed?: ServerAllowed | null;
|
|
343
|
+
/**
|
|
344
|
+
* The check result of this run (the check event). null until it arrives. The `session` notifications of a connection
|
|
345
|
+
* that asked for `session_without_check` lack the field and read it as null (the local check result is used as is).
|
|
346
|
+
*/
|
|
347
|
+
check: CheckResult | null;
|
|
348
|
+
participants: SummaryParticipant[];
|
|
349
|
+
findings: Finding[];
|
|
350
|
+
result: RunResult | null;
|
|
351
|
+
/** Per source, the number of lines the server holds and has dropped. */
|
|
352
|
+
log: Record<string, LogCounts>;
|
|
353
|
+
problems: ServerProblem[];
|
|
354
|
+
problems_omitted: number;
|
|
355
|
+
/** Progress of the scenario run (`scenario` of `api/run`). null for a run without a scenario. */
|
|
356
|
+
scenario: SummaryScenario | null;
|
|
357
|
+
/**
|
|
358
|
+
* Names of the parts that could not be read (`result.participants`, `findings.code` and so on; set by the screen,
|
|
359
|
+
* not a server field). The missing fields of a result shrunk to fit the limits go here too.
|
|
360
|
+
*/
|
|
361
|
+
unreadable: string[];
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* `scenario` of the summary: what the server put together from the check, the `scenario_step` events and the result.
|
|
365
|
+
*/
|
|
366
|
+
export interface SummaryScenario {
|
|
367
|
+
/** The scenario file (relative to root). */
|
|
368
|
+
file: string;
|
|
369
|
+
name: string | null;
|
|
370
|
+
/** Number of steps (from the check result; null until then). */
|
|
371
|
+
step_count: number | null;
|
|
372
|
+
/** Steps received (in index order). After the result, every step (not_run included). */
|
|
373
|
+
steps: ScenarioStep[];
|
|
374
|
+
/** Number of steps beyond the limit that were not kept. */
|
|
375
|
+
steps_omitted: number;
|
|
376
|
+
/** status of the result (null until there is a result). */
|
|
377
|
+
status: ScenarioStatus | null;
|
|
378
|
+
over_at_ms: number | null;
|
|
379
|
+
/**
|
|
380
|
+
* Where the server serves the run's timeline file (`api/timeline/<session id>`, relative to the server's URL; needs
|
|
381
|
+
* the token): set at the end of a run whose launcher wrote one, else null.
|
|
382
|
+
*/
|
|
383
|
+
timeline_url: string | null;
|
|
384
|
+
}
|
|
385
|
+
/**
|
|
386
|
+
* Reads a session summary part by part. Throws if the core (id, state, launcher, stop) cannot be read. Any other part
|
|
387
|
+
* that cannot be read gets its default value (null, empty) and its name goes into unreadable.
|
|
388
|
+
*/
|
|
389
|
+
export declare const readSessionSummary: Reader<SessionSummary>;
|
|
390
|
+
/**
|
|
391
|
+
* Whether this server takes one request now. `ok` says it would; `reason` is a code that stays the same (`null` if
|
|
392
|
+
* ok), `message` one English sentence (`null` if ok).
|
|
393
|
+
*/
|
|
394
|
+
export interface ServerAllowedItem {
|
|
395
|
+
ok: boolean;
|
|
396
|
+
reason: string | null;
|
|
397
|
+
message: string | null;
|
|
398
|
+
}
|
|
399
|
+
/** `save` of `allowed`: also `caution`, `{code, message}` when the server saves but there is something to know first. */
|
|
400
|
+
export interface ServerSaveItem extends ServerAllowedItem {
|
|
401
|
+
/** `command-changes-allowed`: the server also saves edits that change the commands that run, and new files. */
|
|
402
|
+
caution: Caution | null;
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* What this server accepts now (`allowed` of the summary, of `hello` and of `api/session`). start: reasons
|
|
406
|
+
* shutting-down, starting, already-running, launcher-unusable. stop and force: shutting-down, not-running,
|
|
407
|
+
* already-stopping (stop), already-forced (force). save: shutting-down, save-disabled. What the launcher accepts is
|
|
408
|
+
* `launcher_state.allowed`.
|
|
409
|
+
*/
|
|
410
|
+
export interface ServerAllowed {
|
|
411
|
+
/**
|
|
412
|
+
* Goes up by one each time what `allowed` says changes, the same in every place that carries it (`hello`,
|
|
413
|
+
* `api/session`, the summary, the `allowed` message): keep the one with the larger rev. 0 from a server that does not
|
|
414
|
+
* number it.
|
|
415
|
+
*/
|
|
416
|
+
rev: number;
|
|
417
|
+
start: ServerAllowedItem;
|
|
418
|
+
stop: ServerAllowedItem;
|
|
419
|
+
force: ServerAllowedItem;
|
|
420
|
+
/** POST api/config. */
|
|
421
|
+
save: ServerSaveItem;
|
|
422
|
+
}
|
|
423
|
+
export declare const readServerAllowed: Reader<ServerAllowed>;
|
|
424
|
+
/** Answer of GET api/session, POST api/run and POST api/stop (the current session; null if none). */
|
|
425
|
+
export declare const readSessionResponse: (value: unknown) => SessionSummary | null;
|
|
426
|
+
/** What the server accepts, from `allowed` of an `api/session` response: also there when there is no run. */
|
|
427
|
+
export declare const readSessionAllowed: (value: unknown) => ServerAllowed | null;
|
|
428
|
+
/**
|
|
429
|
+
* Body of POST api/stop. force: false stops in order (asking again has no further effect); true stops without waiting.
|
|
430
|
+
*/
|
|
431
|
+
export interface StopRequestBody {
|
|
432
|
+
force: boolean;
|
|
433
|
+
}
|
|
434
|
+
/** Names of the time commands (the launcher's stdin commands other than stop). */
|
|
435
|
+
export type TimeCommandName = 'pause' | 'resume' | 'step' | 'run_until' | 'speed';
|
|
436
|
+
/**
|
|
437
|
+
* Body of POST api/time. The server passes it to the launcher as one line and returns at once. Whether it was accepted
|
|
438
|
+
* arrives as a command event, and its effect as a time event.
|
|
439
|
+
*/
|
|
440
|
+
export type TimeCommand = ({
|
|
441
|
+
command: 'pause';
|
|
442
|
+
} | {
|
|
443
|
+
command: 'resume';
|
|
444
|
+
}
|
|
445
|
+
/** Only while paused. Advances by ms and pauses again (the launcher rounds up to a multiple of the time step). */
|
|
446
|
+
| {
|
|
447
|
+
command: 'step';
|
|
448
|
+
ms: number;
|
|
449
|
+
}
|
|
450
|
+
/** Runs on and pauses at at_ms (0 to limits.step_ms_max; the launcher rounds up to a multiple of the time step). */
|
|
451
|
+
| {
|
|
452
|
+
command: 'run_until';
|
|
453
|
+
at_ms: number;
|
|
454
|
+
} | {
|
|
455
|
+
command: 'speed';
|
|
456
|
+
value: number | 'max';
|
|
457
|
+
}) & {
|
|
458
|
+
/**
|
|
459
|
+
* A whole number from 0 to 2^53 of the sender's choice. The launcher returns it as `id` of the command event that
|
|
460
|
+
* answers this command, so the sender tells that answer from the answers to other commands. Needs a launcher with
|
|
461
|
+
* the feature `state`.
|
|
462
|
+
*/
|
|
463
|
+
id?: number;
|
|
464
|
+
};
|
|
465
|
+
/** Answer of POST api/time: the number of the run it was sent to, and the command passed to the launcher. */
|
|
466
|
+
export interface TimeAnswer {
|
|
467
|
+
session_id: number;
|
|
468
|
+
command: TimeCommandName;
|
|
469
|
+
/** The `id` the request had (null if none). */
|
|
470
|
+
id: number | null;
|
|
471
|
+
}
|
|
472
|
+
export declare const readTimeResponse: (value: unknown) => TimeAnswer;
|
|
473
|
+
/**
|
|
474
|
+
* The first message sent right after connecting. With session and from_seq, the server resends from where that left
|
|
475
|
+
* off.
|
|
476
|
+
*/
|
|
477
|
+
/**
|
|
478
|
+
* Whether the ECU uses a variable now (information only; it never changes how the variable is read or written).
|
|
479
|
+
* unknown: the ECU has not said yet; active: in use (also every variable that does not report it); inactive: not used
|
|
480
|
+
* by the ECU now.
|
|
481
|
+
*/
|
|
482
|
+
export type VariableAvailability = 'unknown' | 'active' | 'inactive';
|
|
483
|
+
/** Reads an availability. A value this library does not know, or none (an older server), is `active`. */
|
|
484
|
+
export declare const readAvailability: (value: unknown) => VariableAvailability;
|
|
485
|
+
/** Definition of one variable (`variables.peers[].variables[]` of the summary). */
|
|
486
|
+
export interface VariableSummary {
|
|
487
|
+
name: string;
|
|
488
|
+
type: Open<'bool' | 'integer' | 'real' | 'enum'>;
|
|
489
|
+
role: Open<'input' | 'output' | 'parameter'>;
|
|
490
|
+
writable: boolean;
|
|
491
|
+
unit: string;
|
|
492
|
+
min: number | null;
|
|
493
|
+
max: number | null;
|
|
494
|
+
step: number | null;
|
|
495
|
+
description: string;
|
|
496
|
+
/** Items of an enum (when type is enum; null otherwise). */
|
|
497
|
+
enum: {
|
|
498
|
+
name: string;
|
|
499
|
+
value: number;
|
|
500
|
+
}[] | null;
|
|
501
|
+
/** Whether the ECU uses it now (`active` from a server that does not say). */
|
|
502
|
+
availability: VariableAvailability;
|
|
503
|
+
}
|
|
504
|
+
/** Result of a write (the `operation` notification, and `variables.operations[]` of the summary). */
|
|
505
|
+
export interface OperationReport {
|
|
506
|
+
seq: number;
|
|
507
|
+
/** sent, queued (in progress). Once settled: applied, late, rejected, cancelled, invalid, busy, unknown, mixed. */
|
|
508
|
+
state: string;
|
|
509
|
+
done: boolean;
|
|
510
|
+
peers: Record<string, {
|
|
511
|
+
state: string;
|
|
512
|
+
applied_at_ms: number | null;
|
|
513
|
+
late: boolean;
|
|
514
|
+
reason: string | null;
|
|
515
|
+
/** How many of the participant's writes took effect, from the first (null: not known). */
|
|
516
|
+
applied_writes: number | null;
|
|
517
|
+
/** Position (from 0) of the write `reason` is about (null: none, or not known). */
|
|
518
|
+
failed_write: number | null;
|
|
519
|
+
}>;
|
|
520
|
+
}
|
|
521
|
+
/** `variables` of the summary: state of the variable API, variables per participant, recent operations. */
|
|
522
|
+
export interface VariablesSummary {
|
|
523
|
+
state: Open<'off' | 'connecting' | 'ready' | 'failed' | 'ended'>;
|
|
524
|
+
reason: string | null;
|
|
525
|
+
peers: {
|
|
526
|
+
name: string;
|
|
527
|
+
connected: boolean;
|
|
528
|
+
variables: VariableSummary[];
|
|
529
|
+
}[];
|
|
530
|
+
peers_omitted: number;
|
|
531
|
+
variables_omitted: number;
|
|
532
|
+
/** Every unsettled operation (those the server keeps), and the recent operations. */
|
|
533
|
+
operations: OperationReport[];
|
|
534
|
+
/** Every operation numbered at or above this is in operations (null from a server that does not say). */
|
|
535
|
+
operations_from_seq: number | null;
|
|
536
|
+
/** Number of unsettled operations the server could not keep (normally 0). */
|
|
537
|
+
operations_open_omitted: number;
|
|
538
|
+
}
|
|
539
|
+
/** Reads `variables` of a summary (present in `hello` and HTTP summaries, absent from `session` notifications). */
|
|
540
|
+
export declare const readVariablesSummary: (value: unknown) => VariablesSummary;
|
|
541
|
+
/** The `values` notification: the last values of the watched variables, and when they are from. */
|
|
542
|
+
export interface ValuesMessage {
|
|
543
|
+
type: 'values';
|
|
544
|
+
/** id of the watch. */
|
|
545
|
+
id: number;
|
|
546
|
+
session: number;
|
|
547
|
+
/** The controller's virtual time (ms; null if unknown). */
|
|
548
|
+
sim_ms: number | null;
|
|
549
|
+
/** true: paused, and the values include every step that began before sim_ms. */
|
|
550
|
+
paused: boolean;
|
|
551
|
+
/**
|
|
552
|
+
* Per participant, the virtual time of the step that read the values, and the values (null for a non-finite real).
|
|
553
|
+
*/
|
|
554
|
+
peers: Record<string, {
|
|
555
|
+
sample_ms: number;
|
|
556
|
+
values: Record<string, number | boolean | null>;
|
|
557
|
+
}>;
|
|
558
|
+
}
|
|
559
|
+
/** Answer of `api/write`. */
|
|
560
|
+
export interface WriteAnswer {
|
|
561
|
+
session_id: number;
|
|
562
|
+
/** Operation number. The result arrives in `operation` notifications. */
|
|
563
|
+
operation: number;
|
|
564
|
+
}
|
|
565
|
+
export declare const readWriteResponse: (value: unknown) => WriteAnswer;
|
|
566
|
+
/**
|
|
567
|
+
* One error in a dashboard file: line and column (from 1), location in the data (`sections[0].items[2].widget`), and
|
|
568
|
+
* English text that says how to fix it.
|
|
569
|
+
*/
|
|
570
|
+
export interface DashboardFileError {
|
|
571
|
+
line: number;
|
|
572
|
+
column: number;
|
|
573
|
+
at: string;
|
|
574
|
+
message: string;
|
|
575
|
+
}
|
|
576
|
+
/** A variable written in the file (`<participant>.<variable name>` split up). */
|
|
577
|
+
export interface DashboardVariable {
|
|
578
|
+
peer: string;
|
|
579
|
+
name: string;
|
|
580
|
+
}
|
|
581
|
+
/**
|
|
582
|
+
* An item in the file, of exactly one of these shapes (the parser drops items of an unknown shape).
|
|
583
|
+
* - variable: shows a variable with a widget (the default widget if widget is null).
|
|
584
|
+
* - panel: a custom panel (the name of a custom element).
|
|
585
|
+
* - auto: the variables of that participant not placed elsewhere in the file (with the default widgets).
|
|
586
|
+
*/
|
|
587
|
+
export type DashboardFileItem = {
|
|
588
|
+
variable: DashboardVariable;
|
|
589
|
+
widget: string | null;
|
|
590
|
+
label: string | null;
|
|
591
|
+
options: Record<string, unknown>;
|
|
592
|
+
} | {
|
|
593
|
+
panel: string;
|
|
594
|
+
label: string | null;
|
|
595
|
+
options: Record<string, unknown>;
|
|
596
|
+
variables: DashboardVariable[];
|
|
597
|
+
} | {
|
|
598
|
+
auto: string;
|
|
599
|
+
};
|
|
600
|
+
/** A section of the file. */
|
|
601
|
+
export interface DashboardFileSection {
|
|
602
|
+
title: string;
|
|
603
|
+
collapsed: boolean;
|
|
604
|
+
items: DashboardFileItem[];
|
|
605
|
+
}
|
|
606
|
+
/** A custom panel module: the name written in the file, and the URL to load (relative to the screen's base). */
|
|
607
|
+
export interface DashboardPanelModule {
|
|
608
|
+
module: string;
|
|
609
|
+
url: string;
|
|
610
|
+
}
|
|
611
|
+
/** Contents of a dashboard file, as checked by the server. */
|
|
612
|
+
export interface DashboardFile {
|
|
613
|
+
title: string | null;
|
|
614
|
+
panels: DashboardPanelModule[];
|
|
615
|
+
sections: DashboardFileSection[];
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* `GET api/dashboard?file=<configuration file>`: `<name>.dashboard.yaml` next to the configuration file. When there is
|
|
619
|
+
* none (found is false) or it has errors (errors; dashboard is null), the screen uses the automatic dashboard.
|
|
620
|
+
*/
|
|
621
|
+
export interface DashboardResponse {
|
|
622
|
+
/** The configuration file (relative to root). */
|
|
623
|
+
file: string;
|
|
624
|
+
/** The dashboard file (relative to root). */
|
|
625
|
+
path: string;
|
|
626
|
+
found: boolean;
|
|
627
|
+
errors: DashboardFileError[];
|
|
628
|
+
dashboard: DashboardFile | null;
|
|
629
|
+
}
|
|
630
|
+
export declare const readDashboardResponse: (value: unknown) => DashboardResponse;
|
|
631
|
+
/**
|
|
632
|
+
* Notifications the screen sends after authentication: start a variable watch (replacing one with the same id), or stop
|
|
633
|
+
* it.
|
|
634
|
+
*/
|
|
635
|
+
export type WatchMessage = {
|
|
636
|
+
type: 'watch';
|
|
637
|
+
id: number;
|
|
638
|
+
variables: 'all' | {
|
|
639
|
+
peer: string;
|
|
640
|
+
name: string;
|
|
641
|
+
}[];
|
|
642
|
+
period_ms?: number;
|
|
643
|
+
} | {
|
|
644
|
+
type: 'unwatch';
|
|
645
|
+
id: number;
|
|
646
|
+
};
|
|
647
|
+
export interface AuthMessage {
|
|
648
|
+
type: 'auth';
|
|
649
|
+
token: string;
|
|
650
|
+
session?: number;
|
|
651
|
+
from_seq?: number;
|
|
652
|
+
/**
|
|
653
|
+
* If true, the summaries in this connection's `session` notifications leave out `check` (it arrives in the `hello`
|
|
654
|
+
* summary and the `check` event), because the check result is large and does not change during the run.
|
|
655
|
+
*/
|
|
656
|
+
session_without_check?: boolean;
|
|
657
|
+
}
|
|
658
|
+
/** replay of hello: where the resend starts (null: from the beginning). */
|
|
659
|
+
export interface Replay {
|
|
660
|
+
from_seq: number | null;
|
|
661
|
+
}
|
|
662
|
+
/** dropped: how much was not sent to this screen. */
|
|
663
|
+
export interface Dropped {
|
|
664
|
+
type: 'dropped';
|
|
665
|
+
session: number | null;
|
|
666
|
+
/**
|
|
667
|
+
* not-kept: the server no longer holds it (before the resend); slow-client: the screen read too slowly and the server
|
|
668
|
+
* dropped some of what it was to send.
|
|
669
|
+
*/
|
|
670
|
+
reason: Open<'not-kept' | 'slow-client'>;
|
|
671
|
+
/** Per source, the number of log lines dropped. */
|
|
672
|
+
log: Record<string, number>;
|
|
673
|
+
/** Sources whose count is only a lower bound (more may have been dropped). */
|
|
674
|
+
at_least: string[];
|
|
675
|
+
/** Number of other events dropped. */
|
|
676
|
+
events: number;
|
|
677
|
+
}
|
|
678
|
+
export type ServerMessage =
|
|
679
|
+
/**
|
|
680
|
+
* Right after connecting (and after resync): summary of the current session, and a description of the resend that
|
|
681
|
+
* follows.
|
|
682
|
+
*/
|
|
683
|
+
{
|
|
684
|
+
type: 'hello';
|
|
685
|
+
instance: string;
|
|
686
|
+
session: SessionSummary | null;
|
|
687
|
+
/** What the server accepts now; also there when `session` is null. null from a server that does not say. */
|
|
688
|
+
allowed: ServerAllowed | null;
|
|
689
|
+
replay: Replay | null;
|
|
690
|
+
}
|
|
691
|
+
/**
|
|
692
|
+
* What the server accepts changed with no `session` to carry it (a start begins or fails, the server begins to end).
|
|
693
|
+
* session is the current run's id (null if none). Other changes arrive in the summary.
|
|
694
|
+
*/
|
|
695
|
+
| {
|
|
696
|
+
type: 'allowed';
|
|
697
|
+
session: number | null;
|
|
698
|
+
allowed: ServerAllowed;
|
|
699
|
+
}
|
|
700
|
+
/** A launcher event (resent log lines as well as new events). */
|
|
701
|
+
| {
|
|
702
|
+
type: 'event';
|
|
703
|
+
session: number;
|
|
704
|
+
event: LauncherEvent;
|
|
705
|
+
}
|
|
706
|
+
/** The resend has finished. */
|
|
707
|
+
| {
|
|
708
|
+
type: 'synced';
|
|
709
|
+
session: number | null;
|
|
710
|
+
last_seq: number | null;
|
|
711
|
+
}
|
|
712
|
+
/** The session summary changed (started, stop requested, the launcher exited, the run ended). */
|
|
713
|
+
| {
|
|
714
|
+
type: 'session';
|
|
715
|
+
session: SessionSummary;
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* A server notice (a gap in seq, an invalid line from the launcher, an end without a result, failed authentication
|
|
719
|
+
* and so on).
|
|
720
|
+
*/
|
|
721
|
+
| ({
|
|
722
|
+
type: 'error';
|
|
723
|
+
session: number | null;
|
|
724
|
+
} & ServerProblem)
|
|
725
|
+
/** How much was not sent. */
|
|
726
|
+
| Dropped
|
|
727
|
+
/** The screen read too slowly and messages were dropped. Everything is sent again, starting with hello. */
|
|
728
|
+
| {
|
|
729
|
+
type: 'resync';
|
|
730
|
+
message: string;
|
|
731
|
+
}
|
|
732
|
+
/** The state or the list of the variable API changed (also once right after a run starts). */
|
|
733
|
+
| {
|
|
734
|
+
type: 'variables';
|
|
735
|
+
session: number;
|
|
736
|
+
variables: VariablesSummary;
|
|
737
|
+
}
|
|
738
|
+
/** Values of the watched variables. */
|
|
739
|
+
| ValuesMessage
|
|
740
|
+
/** The result of a write changed. */
|
|
741
|
+
| ({
|
|
742
|
+
type: 'operation';
|
|
743
|
+
session: number;
|
|
744
|
+
} & OperationReport)
|
|
745
|
+
/**
|
|
746
|
+
* Whether ECUs use their variables changed. For each participant listed, the state of every variable it reports
|
|
747
|
+
* (replaces what came before for that participant; a variable not listed is `active`).
|
|
748
|
+
*/
|
|
749
|
+
| {
|
|
750
|
+
type: 'availability';
|
|
751
|
+
session: number;
|
|
752
|
+
peers: Record<string, Record<string, VariableAvailability>>;
|
|
753
|
+
};
|
|
754
|
+
/**
|
|
755
|
+
* Reads one WebSocket notification. Unknown notifications, and notifications wrapping an unknown event, are null
|
|
756
|
+
* (skipped).
|
|
757
|
+
*/
|
|
758
|
+
export declare const readServerMessage: (value: unknown) => ServerMessage | null;
|