@vehicle-sil/gui-client 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +67 -53
- package/README.md +67 -53
- package/dist/index.js +330 -78
- package/package.json +1 -1
- package/types/client.d.ts +11 -3
- package/types/front-types.d.ts +8 -2
- package/types/http.d.ts +2 -0
- package/types/index.d.ts +2 -2
- package/types/protocol/launcher.d.ts +17 -0
- package/types/protocol/server.d.ts +8 -0
- package/types/session-state.d.ts +8 -0
- package/types/session.d.ts +8 -2
- package/types/time.d.ts +8 -0
- package/types/variable-binding.d.ts +6 -2
- package/types/variable-state.d.ts +5 -0
- package/types/variables.d.ts +23 -0
package/README.md
CHANGED
|
@@ -43,6 +43,7 @@ The GUI server also serves the two `.mjs` files, without the token, as `/vsil/ve
|
|
|
43
43
|
|
|
44
44
|
- **Bundled file**: loads in the browser and in Node (22 or later). `scripts/verify-gui.py` runs an example that uses this file from Node against the replay launcher.
|
|
45
45
|
- **Package**: contains the bundled ESM, `.d.ts` files, `exports`, the README and the LICENSE (`pack.mjs` builds it). Its version is the same as the GUI server's. Its types use the browser types (`DOM` in `lib`). Its entry points are `.`, `./elements` and `./timeline` (`testing` and `internal` are not included).
|
|
46
|
+
- **Development server (Vite, `ng serve`, etc.)**: proxy `/api/`, `/vsil/` and `/ws` to the GUI server and start `vehicle-sil-gui` with `--dev-origin http://127.0.0.1:<port>` (and optionally `--no-auth` during local development to skip token rotation across restarts; see "[Use a development server](../../docs/gui.md#use-a-development-server)" in `docs/gui.md`).
|
|
46
47
|
|
|
47
48
|
## Entry points
|
|
48
49
|
|
|
@@ -122,11 +123,11 @@ In the browser, call `takeToken(window)`. It reads `#token=` from the URL, remov
|
|
|
122
123
|
| -------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
123
124
|
| Type | `ClientSession` (`session`, `currentTarget`, `currentInstance`, `ready`, `allowed`, `runtime`, `lastEventAt`, `notices`, `rejected`, `incompatible`, `onMessages`, `report`, `dismissNotice`) |
|
|
124
125
|
| Type | `Notice`, `SessionView`, `ParticipantView`, `LauncherView`, `LogLine`, `LogSource`, `TimeView`, `CommandView`, `RunOutcome`, `LauncherAnswer` |
|
|
125
|
-
| Function | `runOutcome`, `phaseIndex`, `isHolding`, `launcherAnswer`
|
|
126
|
+
| Function | `runOutcome`, `phaseIndex`, `isHolding`, `isScenarioHandedOver`, `isScenarioRunning`, `launcherAnswer` |
|
|
126
127
|
|
|
127
128
|
`ClientSession.allowed` is what the GUI server accepts now (`start`, `stop`, `force` and `save`, each with `ok`, a `reason` code and a `message`; `null` until the server says). `SessionView.launcherState` is the launcher's last `state` event (where the run stands and what it accepts; the larger `rev` wins; `null` until one arrives). `launcherAnswer(launcherState, name)` reads what it says of one operation (`write`, `pause`, ...): `reason` (`null` when the launcher accepts it) and `caution`. A launcher that has not said (no `state` yet, or no entry for the operation) does not accept it (`unsupported`). The front door's `controls` and `variables.bind` read the launcher with it.
|
|
128
129
|
|
|
129
|
-
Ordered notifications (`session`, `event`, `allowed`, `runtime`, `variables`, `availability`, `operation`, `error`, `
|
|
130
|
+
Ordered notifications (`session`, `event`, `allowed`, `runtime`, `variables`, `availability`, `operation`, `error`, `synced`) arrive over the single WebSocket stream ordered by `(instance, run_id, stream_seq)`. HTTP mutation endpoints (`api/run`, `api/stop-session`, `api/prepare`, `api/time`, `api/write`) return lightweight acknowledgements while state updates arrive on the WebSocket stream.
|
|
130
131
|
|
|
131
132
|
The `currentTarget()` method returns the current `{run_id, instance}` pair, or `null` when it is unknown. `currentInstance()` returns the last authenticated server instance even if no run exists, and retains it while disconnected. On reconnect to the same instance and run, the client sends `{instance, run_id, after_stream_seq}` so the server resends only log events after that cursor; when the server instance changes, it starts fresh from the new `hello`.
|
|
132
133
|
|
|
@@ -141,11 +142,11 @@ The `currentTarget()` method returns the current `{run_id, instance}` pair, or `
|
|
|
141
142
|
|
|
142
143
|
### Time
|
|
143
144
|
|
|
144
|
-
| Kind | Name
|
|
145
|
-
| -------- |
|
|
146
|
-
| Type | `ClientTime` (`state`, `answerTimeoutMs`, `pause`, `resume`, `step`, `setSpeed`, `send`) |
|
|
147
|
-
| Type | `TimeState`, `TimeFailure`, `Lateness`, `SendResult`, `NotSentReason`
|
|
148
|
-
| Constant | `ANSWER_TIMEOUT_MS`
|
|
145
|
+
| Kind | Name |
|
|
146
|
+
| -------- | ----------------------------------------------------------------------------------------------------- |
|
|
147
|
+
| Type | `ClientTime` (`state`, `answerTimeoutMs`, `pause`, `resume`, `step`, `runUntil?`, `setSpeed`, `send`) |
|
|
148
|
+
| Type | `TimeState`, `TimeFailure`, `Lateness`, `SendResult`, `NotSentReason` |
|
|
149
|
+
| Constant | `ANSWER_TIMEOUT_MS` |
|
|
149
150
|
|
|
150
151
|
Both `front.time` and `client.time` send commands with the known run ID and server instance. If the run is replaced, the server rejects the command before sending it to a launcher. Older servers that do not accept these fields reject the request.
|
|
151
152
|
|
|
@@ -211,8 +212,8 @@ Types for the shapes that `gui/protocol` defines, and the parsers to use when yo
|
|
|
211
212
|
| Parsers | `readServerMessage`, `readAppInfo`, `readConfigList`, `readConfigText`, `readSavedConfig`, `readCheckResponse`, `readConnections`, `readSessionResponse`, `readTimeResponse`, `readWriteResponse`, `readVariablesSummary`, `readDashboardResponse`, `readScenarioList`, `readRecording` |
|
|
212
213
|
| Shapes of the variable API | `VariablesSummary`, `VariableSummary`, `ValuesMessage`, `OperationReport`, `WatchMessage`, `WriteAnswer` |
|
|
213
214
|
| Dashboard files (`dashboard(file)`) | `DashboardResponse`, `DashboardFile`, `DashboardFileSection`, `DashboardFileItem`, `DashboardFileError`, `DashboardPanelModule`, `DashboardVariable` |
|
|
214
|
-
| Scenarios (`--scenario`, `scenarios(file)`, `recording()`) | `ScenarioStep`, `ScenarioStepStatus`, `ScenarioStatus`, `CheckScenario`, `ScenarioResult`, `SummaryScenario
|
|
215
|
-
| Request shapes | `CheckRequest`, `CheckTextRequest`, `DescribeRequest`, `SaveConfigRequest`, `RunRequest`, `ConnectionsRequest`, `Speed`, `StopRequest`, `TimeCommand`
|
|
215
|
+
| Scenarios (`--scenario`, `scenarios(file)`, `recording()`) | `ScenarioStep`, `ScenarioStepStatus`, `ScenarioStatus`, `CheckScenario`, `ScenarioResult`, `SummaryScenario` (includes optional `handed_over`), `ScenarioList`, `ScenarioFile`, `Recording` (includes `end_ms: number \| null`) |
|
|
216
|
+
| Request shapes | `AfterScenario`, `CheckRequest`, `CheckTextRequest`, `DescribeRequest`, `SaveConfigRequest`, `RunRequest`, `ConnectionsRequest`, `Speed`, `StopRequest`, `TimeCommand` |
|
|
216
217
|
| List of configuration files | `ConfigList`, `ConfigFile`, `ConfigText`, `SavedConfig` |
|
|
217
218
|
| Error shape | `ServerProblem` |
|
|
218
219
|
| Findings | `Finding`, `Severity` |
|
|
@@ -320,27 +321,35 @@ try {
|
|
|
320
321
|
}
|
|
321
322
|
```
|
|
322
323
|
|
|
323
|
-
| Name | What it is
|
|
324
|
-
| ------------------------------------------------------------------ |
|
|
325
|
-
| `status` | The one state to show: `link`, `run`, `file`, `result` and `problem` (below). Discrete values only
|
|
326
|
-
| `clock` | `sim_ms` (the virtual time in ms; `null` before a run), `speed`, `actual_speed` (the speed over about the last second; `null` while paused and right after the start) and `pacing` (`not-paced`, `on-time` or `late`). It changes often, so it is apart from `status`
|
|
327
|
-
| `controls` | Whether each operation can be used now: `start`, `stop`, `force_stop`, `pause`, `resume`, `step` (with `min_ms` and `max_ms`), `run_until`, `speed` (with `min`, `max` and `fastest`: whether `'max'` is accepted besides the numbers), and `save`
|
|
328
|
-
| `scenario` | The scenario of the current (or last) run: `file`, `name`, `status`, `steps`, `timeline_url`; `null` for a run without one
|
|
329
|
-
| `runtime` | Persistent hot / cold runtime status: `mode`, `state`, `config`, `reason`, `message`
|
|
330
|
-
| `prepare(options?)` | Pre-warms a persistent launcher for `file` (`POST api/prepare`) when eligible, or returns `cold` with `reason`
|
|
331
|
-
| `configs()` | Lists configuration files under the server root (`GET api/configs`)
|
|
332
|
-
| `recording()` | Returns applied writes of the current or last run as scenario YAML (`GET api/recording`), or `null` if none
|
|
333
|
-
| `outside` | The networks that the run's `connect` connected to a real bus ("Connecting a network outside" below)
|
|
334
|
-
| `connections({ network }, { file }?)`, `check(intent?, { file }?)` | Where a network can be connected, and the check of an intent without starting it ("Connecting a network outside" below)
|
|
335
|
-
| `readConfig({ file }?)` | The text of a configuration file as it is saved, with its `stamp` ("Editing the text of a configuration file" below)
|
|
336
|
-
| `check(intent?, { file, text }?)` | With `text`, the check of an unsaved text of the file (the same section)
|
|
337
|
-
| `describeAgain({ file, variant }?)` | Describes the participants of the saved file again, and returns that check (the same section)
|
|
338
|
-
| `saveConfig({ file, text, stamp })` | Saves a text as the file, with the `stamp` it was read with (`null`: a new file), and returns the new `stamp` (the same section)
|
|
339
|
-
| `run` | `start(intent?, { file, onStarted }?)`, `stop()` and `forceStop()`
|
|
340
|
-
| `time` | `pause()`, `resume()`, `step(ms)`, `setSpeed(value)` and `runUntil(ms)`
|
|
341
|
-
| `variable(ref)` | One variable, by `"ECU.variable"` (cut at the first dot) or `{ peer, name }` (for an ECU whose name has a dot)
|
|
342
|
-
| `low`, `close()` | The `GuiClient` of the same connection; `close()` disconnects (a shared connection is made again by the next `connect()`)
|
|
343
|
-
| `watch(source, fn)`, `until(source, test, options)` | `watch` calls `fn` now and on every change (several sources: `watch([a, b], (a, b) => ...)`) and returns the function that stops it. `until` resolves with the first value that satisfies `test`; it rejects with an `ActionError` (`timeout` or `aborted`, both `unknown`) |
|
|
324
|
+
| Name | What it is |
|
|
325
|
+
| ------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
326
|
+
| `status` | The one state to show: `link`, `run`, `file`, `result` and `problem` (below). Discrete values only |
|
|
327
|
+
| `clock` | `sim_ms` (the virtual time in ms; `null` before the first run, and retained after a run ends until the next run starts), `speed`, `actual_speed` (the speed over about the last second; `null` while paused and right after the start) and `pacing` (`not-paced`, `on-time` or `late`). It changes often, so it is apart from `status` |
|
|
328
|
+
| `controls` | Whether each operation can be used now: `start`, `stop`, `force_stop`, `pause`, `resume`, `step` (with `min_ms` and `max_ms`), `run_until`, `speed` (with `min`, `max` and `fastest`: whether `'max'` is accepted besides the numbers), and `save` |
|
|
329
|
+
| `scenario` | The scenario of the current (or last) run: `file`, `name`, `status`, `handed_over`, `over_at_ms`, `steps`, `timeline_url`; `null` for a run without one |
|
|
330
|
+
| `runtime` | Persistent hot / cold runtime status: `mode`, `state`, `config`, `reason`, `message` |
|
|
331
|
+
| `prepare(options?)` | Pre-warms a persistent launcher for `file` (`POST api/prepare`) when eligible, or returns `cold` with `reason` |
|
|
332
|
+
| `configs()` | Lists configuration files under the server root (`GET api/configs`) |
|
|
333
|
+
| `recording()` | Returns applied writes of the current or last run as scenario YAML (`GET api/recording`), or `null` if none |
|
|
334
|
+
| `outside` | The networks that the run's `connect` connected to a real bus ("Connecting a network outside" below) |
|
|
335
|
+
| `connections({ network }, { file }?)`, `check(intent?, { file }?)` | Where a network can be connected, and the check of an intent without starting it ("Connecting a network outside" below) |
|
|
336
|
+
| `readConfig({ file }?)` | The text of a configuration file as it is saved, with its `stamp` ("Editing the text of a configuration file" below) |
|
|
337
|
+
| `check(intent?, { file, text }?)` | With `text`, the check of an unsaved text of the file (the same section) |
|
|
338
|
+
| `describeAgain({ file, variant }?)` | Describes the participants of the saved file again, and returns that check (the same section) |
|
|
339
|
+
| `saveConfig({ file, text, stamp })` | Saves a text as the file, with the `stamp` it was read with (`null`: a new file), and returns the new `stamp` (the same section) |
|
|
340
|
+
| `run` | `start(intent?, { file, onStarted }?)`, `stop()` and `forceStop()` |
|
|
341
|
+
| `time` | `pause()`, `resume()`, `step(ms)`, `setSpeed(value)` and `runUntil(ms)` |
|
|
342
|
+
| `variable(ref)` | One variable, by `"ECU.variable"` (cut at the first dot) or `{ peer, name }` (for an ECU whose name has a dot) |
|
|
343
|
+
| `low`, `close()` | The `GuiClient` of the same connection; `close()` disconnects (a shared connection is made again by the next `connect()`) |
|
|
344
|
+
| `watch(source, fn)`, `until(source, test, options)` | `watch` calls `fn` now and on every change (several sources: `watch([a, b], (a, b) => ...)`) and returns the function that stops it. `until` resolves with the first value that satisfies `test`; pass `{ timeout_ms, signal }` to bound or cancel the wait, and it rejects with an `ActionError` (`timeout` or `aborted`, both `unknown`) |
|
|
345
|
+
|
|
346
|
+
```ts
|
|
347
|
+
const controller = new AbortController();
|
|
348
|
+
const settled = await until(client.status, (s) => s.run === 'ended' || s.run === 'crashed', {
|
|
349
|
+
timeout_ms: 10_000,
|
|
350
|
+
signal: controller.signal,
|
|
351
|
+
});
|
|
352
|
+
```
|
|
344
353
|
|
|
345
354
|
Data fields use the wire's names (`force_stop`, `sim_ms`); functions use JavaScript's (`forceStop`, `runUntil`). Every state is a `Readable`; `get()` returns the same object while nothing changed, and `get` and `subscribe` work without `this` (they can be passed to `useSyncExternalStore` as they are).
|
|
346
355
|
|
|
@@ -360,7 +369,7 @@ Data fields use the wire's names (`force_stop`, `sim_ms`); functions use JavaScr
|
|
|
360
369
|
|
|
361
370
|
### `controls`
|
|
362
371
|
|
|
363
|
-
Each entry is `{ ok, reason, caution }`: `reason` is `{ code, message }` when `ok` is false, `caution` is the same shape for an operation that is accepted with something to know first. The codes stay the same (a new code may be added; the meaning of one does not change);
|
|
372
|
+
Each entry is `{ ok, reason, caution }`: `reason` is `{ code, message }` when `ok` is false, `caution` is the same shape for an operation that is accepted with something to know first. The codes stay the same (a new code may be added; the meaning of one does not change); `message` is an English sentence for display whose wording may change, so branch on `code` rather than matching `message`.
|
|
364
373
|
|
|
365
374
|
| Entry | Comes from |
|
|
366
375
|
| ----------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -373,7 +382,7 @@ Each entry is `{ ok, reason, caution }`: `reason` is `{ code, message }` when `o
|
|
|
373
382
|
|
|
374
383
|
### Operations
|
|
375
384
|
|
|
376
|
-
`run.start(intent, { file })` takes the intent: `vehicle_sil_run_request` (1, optional), `variant`, `params`, `scenario`, `disable`, `enable`, `manual`, `strict`, `speed`, `start_paused`, `connect` and `time_policy`, as the launcher's request file names them (`scenario` is a `path` that `scenarios()` gave, relative to the GUI server's root; the request file's own `scenario` is relative to the configuration file's directory, and the server rewrites the path, so do not compose it) (any other field is refused with `unknown-field`; a choice that is not made is a key that is left out, never `null`); `file` defaults to the server's start-up file (`scenarios({ file })` and `connections()` default to it too: give the same `file` to each when a run uses another file). Every operation is a Promise. It rejects with an `ActionError`: `code`, a sentence (`message`), `findings` (for `check-failed`) and `outcome`: `refused` (the owner said no; nothing happened) or `unknown` (it may have been done: look at `status` and `clock` before you send it again).
|
|
385
|
+
`run.start(intent, { file })` takes the intent: `vehicle_sil_run_request` (1, optional), `variant`, `params`, `scenario`, `after_scenario` (`'stop' | 'pause'`, cannot be combined with `stop_at_ms`), `disable`, `enable`, `manual`, `strict`, `speed`, `start_paused`, `stop_at_ms`, `late_tolerance_ms`, `connect` and `time_policy`, as the launcher's request file names them (`scenario` is a `path` that `scenarios()` gave, relative to the GUI server's root; the request file's own `scenario` is relative to the configuration file's directory, and the server rewrites the path, so do not compose it) (any other field is refused with `unknown-field`; a choice that is not made is a key that is left out, never `null`); `file` defaults to the server's start-up file (`scenarios({ file })` and `connections()` default to it too: give the same `file` to each when a run uses another file). Every operation is a Promise. It rejects with an `ActionError`: `code`, a sentence (`message`), `findings` (for `check-failed`) and `outcome`: `refused` (the owner said no; nothing happened) or `unknown` (it may have been done: look at `status` and `clock` before you send it again).
|
|
377
386
|
|
|
378
387
|
| Operation | Resolves when | Rejects with |
|
|
379
388
|
| ---------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
@@ -400,7 +409,7 @@ const stop = watch(client.outside, (rows) => console.log(rows.map((r) => r.condi
|
|
|
400
409
|
|
|
401
410
|
- **`connections({ network }, { file }?)`** asks `POST api/connections` and lays the answer out as one list, in its order: `{ backend, value, label, detail, usable, reason }` for each target, and `{ backend, error }` (the launcher's sentence) for a backend whose bridge could not list, or for an error of the file. Tell the two apart with `'error' in entry`. A list that lacks a backend (exit code 1) is not a failure. It starts that network's bridge on the computer of the GUI server (on Windows, Npcap may ask to raise the rights there), so call it when the user opens the choice, not when the page opens. The list is that computer's, not the browser's. It rejects with an `ActionError` (`check-busy`, `unknown-network`, ...).
|
|
402
411
|
- **`intent.connect`** maps a network to a `value` that the list gave with `usable: true`, as written there; `'none'` keeps it on SIL Kit only, the same as leaving it out. The server refuses a value that its last list of that network did not give (`target-not-listed`): list the network again. **`intent.time_policy`** is `realtime` (the launcher's default: a connected run keeps real time) or `free`.
|
|
403
|
-
- **`check(intent?, { file, signal }?)`** returns the launcher's check result of what `run.start(intent)` would start (`findings`; `time_lock` and `networks[].outside` are in `raw`), or rejects with an `ActionError`. Its failure is not put into `status.problem`. It sends one check at a time: the next is sent after the answer to the one before (the server runs checks one at a time and refuses with `check-busy` when too many wait). A check of the same intent and file as one that waits or is on its way shares it, so the parts and the screen of a page that check the same page intent make one check. A check that waits is not sent when `signal` has aborted for every caller of it; it rejects with the signal's reason. A check on its way is shared too, and its answer reads the file as it was when it was sent: pass `fresh: true` when the user asks to check again (it shares only a check that waits). After `close()`, a check that waits is not sent and rejects with `closed`.
|
|
412
|
+
- **`check(intent?, { file, signal }?)`** returns the launcher's check result of what `run.start(intent)` would start (`findings`; `time_lock` and `networks[].outside` are in `raw`), or rejects with an `ActionError`. Its `participants[].variables[]` list carries each ECU's `--describe` metadata before a run starts (`unit`, `min`, `max`, `step`, `description`, enum `items` as `[{ name, value }]`, and `builtin`), so a screen can build ranges, labels and enum choices ahead of the first run. Its failure is not put into `status.problem`. It sends one check at a time: the next is sent after the answer to the one before (the server runs checks one at a time and refuses with `check-busy` when too many wait). A check of the same intent and file as one that waits or is on its way shares it, so the parts and the screen of a page that check the same page intent make one check. A check that waits is not sent when `signal` has aborted for every caller of it; it rejects with the signal's reason. A check on its way is shared too, and its answer reads the file as it was when it was sent: pass `fresh: true` when the user asks to check again (it shares only a check that waits). After `close()`, a check that waits is not sent and rejects with `closed`.
|
|
404
413
|
- **`outside`** has one row for each network that the run's `connect` connected: `network`, `target`, `participant`, `link` (Ethernet) or `bus` (CAN), `condition` (`ok`, `interrupted`, `degraded`), `reasons` (codes, in the launcher's order), `nothing_received` (apart from `condition`), and `to_outside` and `from_outside` (`null` until an `outside` event has arrived on this page). It is empty while no run is going, and in a run that a `role: bridge` participant of the file connects: do not read from it whether the run is connected outside (`time_lock.because` of the check says what makes the run keep real time). How the run ended, `connect-failed` and `connect-lost` included, is in `status`.
|
|
405
414
|
|
|
406
415
|
### Editing the text of a configuration file
|
|
@@ -463,8 +472,9 @@ stop(); // the last unsubscribe stops asking the server for values
|
|
|
463
472
|
The view has `value`, `text` (an enum shows the item's name), `unit`, `min`, `max`, `step`, `sim_ms`, `stale`, `note` (a sentence when the value is not a live one), `availability` (`unknown`, `active` or `inactive`: whether the ECU uses the variable now; information only, so `can_write`, `why` and `note` do not look at it, and a lost connection does not change it; `unknown` until the run's summary has the variable, then `active` with a GUI server that does not send it), `can_write` (the variable's own conditions and what the launcher accepts: `state.allowed.write`), `why` (a `{ code, message }` for what cannot be written: the variable's own reason first, then the launcher's), `writing`, `problem` (why the last write of this page did not go through), and the values of `client.low.variables.bind` (`condition`, `block`, `write_status`).
|
|
464
473
|
|
|
465
474
|
- The first subscription asks the server for the value, and the last unsubscribe stops it. There is no `close()`.
|
|
466
|
-
- `write(value)` needs no subscription (it sends that one write). It rejects with an `ActionError`; `no-answer` is `unknown`, and a write whose answer did not come is not sent again.
|
|
467
|
-
- The binding (`client.low.variables.bind`) holds back and merges writes while one is on its way (for sliders)
|
|
475
|
+
- `write(value, options?)` needs no subscription (it sends that one write). Pass `{ keepalive: true }` from a browser `pagehide` handler so `fetch()` can finish releasing a held input as the page unloads. It rejects with an `ActionError`; `no-answer` is `unknown`, and a write whose answer did not come is not sent again.
|
|
476
|
+
- The binding (`client.low.variables.bind`) holds back and merges writes while one is on its way (for sliders), and silently does nothing when `block !== null`; `write()` of the front door sends each call and rejects with `ActionError` if refused.
|
|
477
|
+
- Because `Readable` notifications are synchronous, avoid triggering unguarded reentrant writes inside a `subscribe()` callback (defer side effects or guard on state transitions). For momentary/held inputs, `keepalive`, scheduled `atMs` pulses, reconnect recovery and bus observation, see "[Held inputs, reconnect recovery, and bus observation](../../docs/gui.md#held-inputs-reconnect-recovery-and-bus-observation)" in `docs/gui.md`.
|
|
468
478
|
|
|
469
479
|
## Parts (custom elements)
|
|
470
480
|
|
|
@@ -525,7 +535,7 @@ A variable is written `ECU.variable` (cut at the first dot), as for `client.vari
|
|
|
525
535
|
|
|
526
536
|
The words are English. Attributes rename the buttons (`label-start` and the others in the table, and `label` of `<vsil-write>`). The sentences of reasons (a button that cannot be used, `caution`, the problem, why a variable cannot be written) come from the owner of the reason, in English; `setReasonText(fn)` replaces them: `fn(reason)` returns the sentence, or `null` or `undefined` to keep the English one, and `setReasonText(null)` removes it. Call it before the parts are in the page. The other words of the parts (`ready`, `writing…`, `(no scenario)`, `fastest`, `behind real time`, `Step (ms)`, `Until (ms)`, `Speed`, `-`, the default `on` and `off`, `SIL Kit only (not connected)`, the sentence of a choice taken back to SIL Kit only, and `link`, `bus`, `to outside`, `from outside` and `nothing received` of `<vsil-outside>`) cannot be changed.
|
|
527
537
|
|
|
528
|
-
The choosing parts and the start button are separate elements, so the module keeps what the page selected for the next run in `pageIntent` (`get()`, `subscribe(fn)` and `update(patch)`; a field set to `''` or `undefined` is removed). `<vsil-scenario-select>` writes `scenario`; `<vsil-run-controls>` starts with `{ ...pageIntent.get(), ...intent }`, so its `intent` property wins, and it starts the file that `status.file` names, the same file whose scenarios `<vsil-scenario-select>` lists (the server's start-up file when no run has been started). A screen that starts a run with its own code passes the intent to `client.run.start(intent)` itself; it writes the choices that the check sees into `pageIntent` too, so that `<vsil-connect>` checks what the screen will start.
|
|
538
|
+
The choosing parts and the start button are separate elements, so the module keeps what the page selected for the next run in `pageIntent` (`get()`, `subscribe(fn)` and `update(patch)`; a field set to `''` or `undefined` is removed). `pageIntent` always represents the intent for the **next** run—it is not overwritten by the currently running session's settings, so editing controls while a run is active prepares the next Start. `<vsil-scenario-select>` writes `scenario`; `<vsil-run-controls>` starts with `{ ...pageIntent.get(), ...intent }`, so its `intent` property wins, and it starts the file that `status.file` names, the same file whose scenarios `<vsil-scenario-select>` lists (the server's start-up file when no run has been started). A screen that starts a run with its own code passes the intent to `client.run.start(intent)` itself; it writes the choices that the check sees into `pageIntent` too, so that `<vsil-connect>` checks what the screen will start.
|
|
529
539
|
|
|
530
540
|
Start the GUI server with a configuration file (`vehicle-sil-gui --web my-screen simulation.yaml`). Without one the server has no start-up file, and a screen made of parts alone cannot start a run: `<vsil-status>` shows the refusal (`no-file`). Only your own code can name the file then: `client.run.start(intent, { file })`.
|
|
531
541
|
|
|
@@ -592,6 +602,9 @@ watch.close();
|
|
|
592
602
|
| True | The value at the paused time `simMs` (it includes the values of every step that started before that time) |
|
|
593
603
|
| False | The last value while the simulation runs |
|
|
594
604
|
|
|
605
|
+
- `watch.values` notifies whenever any watched variable's reading changes (including `simMs` or `paused` updates when the value itself did not change). Frames with `peers: {}` (such as a `start_paused` run before step 0) do not emit on `watch.values`.
|
|
606
|
+
- For pause or simulation-time state before the first sample, use `isHolding(session)` or `front.clock`; for raw `ValuesMessage` frames (including `peers: {}`), subscribe to `client.session.onMessages`.
|
|
607
|
+
|
|
595
608
|
**Subscriptions**:
|
|
596
609
|
|
|
597
610
|
- However many watches look at a variable, the server has one subscription per variable. A variable joins the subscription with the shortest period requested (periods are rounded to one of 20, 50, 100, 200, 500 ms …).
|
|
@@ -617,7 +630,7 @@ watch.close();
|
|
|
617
630
|
|
|
618
631
|
### Write values (`write`)
|
|
619
632
|
|
|
620
|
-
`write(writes, options)` sends the writes to the run that was current when you called it (`session` in `client.variables.state`, sent as `
|
|
633
|
+
`write(writes, options)` sends the writes to the run that was current when you called it (`session` in `client.variables.state`, sent as `run_id` in the body).
|
|
621
634
|
|
|
622
635
|
- The server rejects the writes if that run is no longer running (`session-changed`). A write sent while one run ends and the next starts is therefore never written to the next run.
|
|
623
636
|
- If the run is not known yet, the library does not send and rejects with `refused` (`not-running`).
|
|
@@ -669,6 +682,7 @@ The `kind` of a `WriteError`:
|
|
|
669
682
|
- Use `onAccepted` to show "accepted, waiting to be applied", and to know when you may send the next write. Writes through `bind` use it: a next value that comes before the server has received the previous write is kept instead of sent, and only the last value is sent once the server has it.
|
|
670
683
|
- `timeoutMs` (default `WRITE_TIMEOUT_MS`) counts from the HTTP response. `Infinity` sets no time limit (the write waits until the run changes or `close()` is called). Values above 2^31-1 ms (about 24.8 days) are capped there. Non-numbers and values of 0 or less mean the default.
|
|
671
684
|
- A write is applied in the step at the given virtual time (`atMs`; if omitted, the next step), so it does not complete while the simulation is paused. To write while paused, wait for `queued` in `client.variables.operations` before you advance (`examples/gui_client/variables.mjs`, in a clone of the repository).
|
|
685
|
+
- `keepalive` (`WriteOptions.keepalive`, forwarded via `HttpRequest.keepalive` to `fetch(..., { keepalive })`) lets a release write sent from a browser `pagehide` handler outlive page unload while keeping `Authorization` and `Origin` headers. See "[Held inputs, reconnect recovery, and bus observation](../../docs/gui.md#held-inputs-reconnect-recovery-and-bus-observation)" in `docs/gui.md` for held-input patterns and limits.
|
|
672
686
|
- `client.variables.operations` lists recent operations, including writes from other clients, but not a scenario's own writes.
|
|
673
687
|
|
|
674
688
|
### Write before the first step
|
|
@@ -728,12 +742,12 @@ Switch on `condition.kind`.
|
|
|
728
742
|
|
|
729
743
|
The `status` of `unavailable` is one of: not running, this run has no variables, connecting, cannot connect. The values of `why` for `stale`:
|
|
730
744
|
|
|
731
|
-
| `why` | Meaning
|
|
732
|
-
| -------------- |
|
|
733
|
-
| `connection` | The connection between the client and the server dropped |
|
|
734
|
-
| `reconnecting` | The server is reconnecting to the launcher
|
|
735
|
-
| `peer` | The ECU is disconnected
|
|
736
|
-
| `reading` | Reading values keeps failing
|
|
745
|
+
| `why` | Meaning |
|
|
746
|
+
| -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
747
|
+
| `connection` | The connection between the client and the server dropped, or a cached reading after reconnecting to the same run is still awaiting its first post-reconnect `values` sample |
|
|
748
|
+
| `reconnecting` | The server is reconnecting to the launcher |
|
|
749
|
+
| `peer` | The ECU is disconnected |
|
|
750
|
+
| `reading` | Reading values keeps failing |
|
|
737
751
|
|
|
738
752
|
### Why a write is blocked (`block`)
|
|
739
753
|
|
|
@@ -769,7 +783,7 @@ The facts of the variable and the run come first, then the launcher's answer (`l
|
|
|
769
783
|
| `refused`, `failed`, `no-answer`, `closed` | The `kind` of a `WriteError` (has `message` and `code`) |
|
|
770
784
|
|
|
771
785
|
- `isWriteError(writeStatus)` picks out the statuses that have a `message` (the ones that did not succeed).
|
|
772
|
-
- `message` is not localized.
|
|
786
|
+
- `message` is human-readable English whose wording may change (not localized). Branch on `kind` and `code`, and build localized text from them.
|
|
773
787
|
- If `pending` is set, show it instead of the read value (so a switch you clicked does not appear to flip back while it waits for the result).
|
|
774
788
|
|
|
775
789
|
### How `write(value)` behaves
|
|
@@ -812,15 +826,15 @@ If you create it with `{ history: 600 }`, `history()` returns the points, oldest
|
|
|
812
826
|
|
|
813
827
|
## Lifecycle
|
|
814
828
|
|
|
815
|
-
| Call | What it does
|
|
816
|
-
| --------------------------------------------------- |
|
|
817
|
-
| `createClient()` | Only creates the client; does not connect
|
|
818
|
-
| `connect()` | Connects over WebSocket (
|
|
819
|
-
| `connect()` while connected | Does nothing (also while waiting to reconnect)
|
|
820
|
-
| `close()` | Disconnects and does not reconnect (what it cleans up is below)
|
|
821
|
-
| `connect()` after `close()` | Connects again and subscribes the remaining watches again
|
|
822
|
-
| HTTP requests after `close()` | Work (`loadApp()`, `run.start()` and others can be sent without a connection)
|
|
823
|
-
| `connect()` after a rejection or a version mismatch | Does nothing (`session.rejected` and `session.incompatible` do not reset)
|
|
829
|
+
| Call | What it does |
|
|
830
|
+
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- |
|
|
831
|
+
| `createClient()` | Only creates the client; does not connect |
|
|
832
|
+
| `connect()` | Connects over WebSocket (without a token, sends `token: ''` for `--no-auth`, or is rejected with `unauthorized` when auth is enabled) |
|
|
833
|
+
| `connect()` while connected | Does nothing (also while waiting to reconnect) |
|
|
834
|
+
| `close()` | Disconnects and does not reconnect (what it cleans up is below) |
|
|
835
|
+
| `connect()` after `close()` | Connects again and subscribes the remaining watches again |
|
|
836
|
+
| HTTP requests after `close()` | Work (`loadApp()`, `run.start()` and others can be sent without a connection) |
|
|
837
|
+
| `connect()` after a rejection or a version mismatch | Does nothing (`session.rejected` and `session.incompatible` do not reset) |
|
|
824
838
|
|
|
825
839
|
- `close()` stops pending timers, stops waiting for responses to time commands, and rejects writes waiting for results with a `WriteError` (`closed`). Notifications in a batch being collected are discarded. Variable watches remain.
|
|
826
840
|
- After `close()` and `connect()`, the session copy is still there, and the library receives again from where its copy ends.
|