@vehicle-sil/gui-client 0.1.0 → 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/README.ja.md +384 -92
- package/README.md +375 -85
- package/dist/elements.js +872 -0
- package/dist/index.js +1806 -133
- package/package.json +20 -2
- 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 +41 -5
- 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/index.d.ts +9 -5
- 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 +10 -972
- package/types/session-state.d.ts +44 -10
- package/types/session.d.ts +13 -1
- package/types/time.d.ts +16 -45
- package/types/variable-binding.d.ts +19 -5
- package/types/variable-state.d.ts +12 -6
- package/types/variables.d.ts +21 -1
package/types/session-state.d.ts
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
import { CheckResult, ControlLink, Dropped, Finding, LauncherEvent, ParticipantState, Phase, RunResult, ScenarioStatus, ScenarioStep, ServerProblem, SessionSummary, Speed, TimeReport } from './protocol.js';
|
|
1
|
+
import { CheckResult, ControlLink, Dropped, Finding, LauncherEvent, ParticipantState, Phase, RunResult, ScenarioStatus, ScenarioStep, ServerProblem, SessionSummary, Speed, StateReport, TimeReport } from './protocol.js';
|
|
2
|
+
/**
|
|
3
|
+
* A reason: a code that stays the same (an entry of the owner's reason codes, or one the client names) and one English
|
|
4
|
+
* sentence.
|
|
5
|
+
*/
|
|
6
|
+
export interface Reason {
|
|
7
|
+
code: string;
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
10
|
+
/** What the launcher says of one operation: why it does not accept it now (null if it does), and its warning. */
|
|
11
|
+
export interface LauncherAnswer {
|
|
12
|
+
reason: Reason | null;
|
|
13
|
+
caution: Reason | null;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* What the launcher's last `state` says of one operation (`allowed.<name>`, such as `write` or `pause`), as it wrote
|
|
17
|
+
* it. A launcher that has not said yet does not accept it (`unsupported`): no `state` yet (at the start of a run,
|
|
18
|
+
* before the launcher's first one), or a `state` with no entry for the operation.
|
|
19
|
+
* The one place the client reads `allowed` of the launcher: `controls` of the front door and `client.variables.bind`
|
|
20
|
+
* both use it.
|
|
21
|
+
*/
|
|
22
|
+
export declare function launcherAnswer(state: StateReport | null, name: string): LauncherAnswer;
|
|
2
23
|
/** Log lines kept per source (participant or launcher). The same number the server keeps. */
|
|
3
24
|
export declare const MAX_LOG_LINES_PER_SOURCE = 2000;
|
|
4
25
|
/** Log lines kept in total. Beyond this, the oldest lines of the source holding the most are dropped. */
|
|
@@ -87,17 +108,12 @@ export interface LauncherView {
|
|
|
87
108
|
silentSeconds: number | null;
|
|
88
109
|
}
|
|
89
110
|
/**
|
|
90
|
-
* Virtual time and how it
|
|
91
|
-
*
|
|
92
|
-
* and so on).
|
|
111
|
+
* Virtual time and how it keeps up (the last time event, or time of the summary). Fields that are not written are
|
|
112
|
+
* null. Whether the run is paused, and the speed set, are in the launcher's state (SessionView.launcherState).
|
|
93
113
|
*/
|
|
94
114
|
export interface TimeView {
|
|
95
115
|
simMs: number;
|
|
96
|
-
/**
|
|
97
|
-
speed: Speed;
|
|
98
|
-
/** Whether it is paused (null if not written). */
|
|
99
|
-
paused: boolean | null;
|
|
100
|
-
/** Actual speed over roughly the last second (null while paused and when starting to move). */
|
|
116
|
+
/** Actual speed over roughly the last second (null when starting to move, and in an event written while paused). */
|
|
101
117
|
actualSpeed: number | null;
|
|
102
118
|
/** Number of late time steps. */
|
|
103
119
|
lateSteps: number | null;
|
|
@@ -117,6 +133,8 @@ export interface CommandView {
|
|
|
117
133
|
message: string | null;
|
|
118
134
|
/** For an accepted step, the virtual time it actually advances (ms). */
|
|
119
135
|
ms: number | null;
|
|
136
|
+
/** For an accepted step or run_until, the virtual time at which the simulation pauses after it (ms). */
|
|
137
|
+
atMs: number | null;
|
|
120
138
|
/** seq of that event (-1 if unknown). Tells a new answer from the same answer arriving again in a summary. */
|
|
121
139
|
seq: number;
|
|
122
140
|
}
|
|
@@ -139,6 +157,11 @@ export interface ScenarioView {
|
|
|
139
157
|
status: ScenarioStatus | null;
|
|
140
158
|
/** Virtual time at which the scenario ended. */
|
|
141
159
|
overAtMs: number | null;
|
|
160
|
+
/**
|
|
161
|
+
* Where the server serves the run's timeline file (`api/timeline/<session id>`), once the run has ended with one;
|
|
162
|
+
* else null. The page `timeline/` of the server draws it (see "Timeline of a scenario run" in docs/gui.md).
|
|
163
|
+
*/
|
|
164
|
+
timelineUrl: string | null;
|
|
142
165
|
}
|
|
143
166
|
/** State of one session (one run of the launcher), as the screen sees it. */
|
|
144
167
|
export interface SessionView {
|
|
@@ -154,7 +177,7 @@ export interface SessionView {
|
|
|
154
177
|
* Participants the user chose on the screen to start themselves (manual: true in the configuration file is in check).
|
|
155
178
|
*/
|
|
156
179
|
manual: readonly string[];
|
|
157
|
-
/** Speed given at the start (null means as in the configuration file). The current speed is
|
|
180
|
+
/** Speed given at the start (null means as in the configuration file). The current speed is `speed` of launcherState. */
|
|
158
181
|
speed: Speed;
|
|
159
182
|
/** Whether the run started paused. */
|
|
160
183
|
startPaused: boolean;
|
|
@@ -184,6 +207,11 @@ export interface SessionView {
|
|
|
184
207
|
stopRequests: number;
|
|
185
208
|
/** The last command event received (whether it was accepted, and why not). */
|
|
186
209
|
lastCommand: CommandView | null;
|
|
210
|
+
/**
|
|
211
|
+
* What the launcher accepts now and where the run stands (the last `state` event, or `launcher_state` of the
|
|
212
|
+
* summary; the one with the larger `rev` wins). null until one arrives (and for a launcher without `state`).
|
|
213
|
+
*/
|
|
214
|
+
launcherState: StateReport | null;
|
|
187
215
|
result: RunResult | null;
|
|
188
216
|
launcher: LauncherView;
|
|
189
217
|
/** What the server noticed (shown in English, unchanged). */
|
|
@@ -219,6 +247,12 @@ export type RunOutcome =
|
|
|
219
247
|
| 'ended'
|
|
220
248
|
/** The launcher exited without a result. */
|
|
221
249
|
| 'crashed';
|
|
250
|
+
/**
|
|
251
|
+
* Whether the run waits before its first step (the step at time 0) for a resume or a step: the launcher's state says
|
|
252
|
+
* so (`holding`; a run started paused whose launcher has a Control Server). Meanwhile the launcher writes no time
|
|
253
|
+
* events, and a variable written is applied in the step at time 0.
|
|
254
|
+
*/
|
|
255
|
+
export declare function isHolding(session: SessionView | null): boolean;
|
|
222
256
|
export declare function runOutcome(session: SessionView): RunOutcome;
|
|
223
257
|
/** Builds a session from the server's summary (hello, a new session). The log arrives in the resend that follows. */
|
|
224
258
|
export declare function sessionFromSummary(summary: SessionSummary): SessionView;
|
package/types/session.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Connection } from './connection.js';
|
|
2
|
-
import { AuthMessage, ServerMessage, SessionSummary } from './protocol.js';
|
|
2
|
+
import { AuthMessage, ServerAllowed, ServerMessage, SessionSummary } from './protocol.js';
|
|
3
3
|
import { SessionView } from './session-state.js';
|
|
4
4
|
import { ErrorSink, Readable } from './values.js';
|
|
5
5
|
/** How many kinds of notices not tied to a session are kept. */
|
|
@@ -29,6 +29,11 @@ export interface ClientSession {
|
|
|
29
29
|
* own ready.
|
|
30
30
|
*/
|
|
31
31
|
readonly ready: Readable<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* What the server accepts now (start, stop, force and why not). null until it says (hello), and from a server that
|
|
34
|
+
* does not say. What the launcher accepts is `launcherState` of the session.
|
|
35
|
+
*/
|
|
36
|
+
readonly allowed: Readable<ServerAllowed | null>;
|
|
32
37
|
/** When an event was last applied (Date.now()). The starting point for advancing elapsed time with the clock. */
|
|
33
38
|
readonly lastEventAt: Readable<number>;
|
|
34
39
|
/**
|
|
@@ -79,6 +84,7 @@ export declare class SessionFeed implements ClientSession {
|
|
|
79
84
|
private readonly onError;
|
|
80
85
|
private readonly current;
|
|
81
86
|
private readonly synced;
|
|
87
|
+
private readonly allowedValue;
|
|
82
88
|
private readonly receivedAt;
|
|
83
89
|
private readonly noticeList;
|
|
84
90
|
private readonly rejectedValue;
|
|
@@ -88,6 +94,7 @@ export declare class SessionFeed implements ClientSession {
|
|
|
88
94
|
private stoppedFlag;
|
|
89
95
|
readonly session: Readable<SessionView | null>;
|
|
90
96
|
readonly ready: Readable<boolean>;
|
|
97
|
+
readonly allowed: Readable<ServerAllowed | null>;
|
|
91
98
|
readonly lastEventAt: Readable<number>;
|
|
92
99
|
readonly notices: Readable<readonly Notice[]>;
|
|
93
100
|
readonly rejected: Readable<boolean>;
|
|
@@ -109,6 +116,11 @@ export declare class SessionFeed implements ClientSession {
|
|
|
109
116
|
* run over a new one.
|
|
110
117
|
*/
|
|
111
118
|
adopt(summary: SessionSummary | null): void;
|
|
119
|
+
/**
|
|
120
|
+
* Takes what the server accepts (an HTTP answer or a notification): the one with the larger `rev` wins (rev 0 is a
|
|
121
|
+
* server that does not number it: the newest arrival wins). Used inside the library.
|
|
122
|
+
*/
|
|
123
|
+
adoptAllowed(allowed: ServerAllowed | null): void;
|
|
112
124
|
report(message: string, count?: number): void;
|
|
113
125
|
dismissNotice(id: number): void;
|
|
114
126
|
/** Reads and applies a batch from the connection. */
|
package/types/time.d.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { HttpTransport } from './http.js';
|
|
2
|
-
import {
|
|
2
|
+
import { TimeCommand, TimeCommandName } from './protocol.js';
|
|
3
3
|
import { CommandView, SessionView, TimeView } from './session-state.js';
|
|
4
4
|
import { ErrorSink, Readable } from './values.js';
|
|
5
|
-
import { VariablesState } from './variables.js';
|
|
6
|
-
/** The launcher features that concern time. */
|
|
7
|
-
export declare const FEATURE_SPEED = "speed";
|
|
8
|
-
export declare const FEATURE_START_PAUSED = "start-paused";
|
|
9
|
-
export declare const FEATURE_TIME_COMMANDS = "time-commands";
|
|
10
5
|
/**
|
|
11
6
|
* How long to wait for the launcher's answer (the command event) to a command sent (ms). After that, the client stops
|
|
12
7
|
* waiting, enables the controls again and reports the missing answer as an error (a launcher that does not read its
|
|
@@ -42,14 +37,14 @@ export interface Lateness {
|
|
|
42
37
|
lateMs: number;
|
|
43
38
|
}
|
|
44
39
|
/**
|
|
45
|
-
* Time state and the
|
|
40
|
+
* Time state: the virtual time, the lateness, and the answer to the last command. All values come from the session
|
|
41
|
+
* copy. Whether a command may be used now is not here: the launcher says it (`allowed` of
|
|
42
|
+
* its state, SessionView.launcherState), and `controls` of connect() puts it together with the connection.
|
|
46
43
|
*/
|
|
47
44
|
export interface TimeState {
|
|
48
|
-
/** Whether the launcher has time commands (pause, resume, step, speed). If not, no controls are shown. */
|
|
49
|
-
supported: boolean;
|
|
50
45
|
/** Time of the current session (null until a time event arrives). */
|
|
51
46
|
time: TimeView | null;
|
|
52
|
-
/** The speed is paced (a numeric speed). Lateness is not counted when running as fast as possible. */
|
|
47
|
+
/** The speed is paced (the launcher's state has a numeric speed). Lateness is not counted when running as fast as possible. */
|
|
53
48
|
paced: boolean;
|
|
54
49
|
/** Lateness figures (null when the launcher does not write them). */
|
|
55
50
|
lateness: Lateness | null;
|
|
@@ -61,38 +56,17 @@ export interface TimeState {
|
|
|
61
56
|
behind: boolean;
|
|
62
57
|
/** The last command event received (stop included). */
|
|
63
58
|
lastCommand: CommandView | null;
|
|
64
|
-
/**
|
|
65
|
-
* Whether time commands can be sent: the launcher supports them, the session copy is in sync, the phase is running,
|
|
66
|
-
* a time event has arrived, there is no result yet and no stop has been requested. Once the phase moves on to
|
|
67
|
-
* stopping, the launcher no longer accepts them. Commands can also be sent during beforeStart.
|
|
68
|
-
*/
|
|
69
|
-
controllable: boolean;
|
|
70
|
-
/**
|
|
71
|
-
* Whether the run is before its first step (not started yet), waiting for a resume or a step: a run started paused
|
|
72
|
-
* (start_paused) whose launcher has a Control Server (the variable status is not off) and that has not started
|
|
73
|
-
* moving. Meanwhile the launcher writes no time events but accepts resume and step (it accepts pause too, which
|
|
74
|
-
* changes nothing), and variables written are applied in the step at time 0.
|
|
75
|
-
*/
|
|
76
|
-
beforeStart: boolean;
|
|
77
59
|
/**
|
|
78
60
|
* A command sent whose answer has not been seen yet (waiting for the HTTP answer or the launcher's command event).
|
|
79
61
|
* Meanwhile no further command is sent (so a double click or a repeated Enter does not step twice).
|
|
80
62
|
*/
|
|
81
63
|
sending: TimeCommandName | null;
|
|
82
|
-
/** A step is in progress (meanwhile the launcher counts as paused and accepts resume and step). */
|
|
83
|
-
stepping: boolean;
|
|
84
|
-
/** Whether Pause can be used (while running, also during a step). */
|
|
85
|
-
canPause: boolean;
|
|
86
|
-
/** Whether Resume can be used (while paused, or during a step). */
|
|
87
|
-
canResume: boolean;
|
|
88
|
-
/** Whether Step can be used (the same as canResume; the launcher's rule). */
|
|
89
|
-
canStep: boolean;
|
|
90
64
|
/** The last command that went wrong. null once the run changes. */
|
|
91
65
|
failure: TimeFailure | null;
|
|
92
66
|
}
|
|
93
67
|
/** Read side and commands of time (GuiClient.time). */
|
|
94
68
|
export interface ClientTime {
|
|
95
|
-
/** Time state
|
|
69
|
+
/** Time state. */
|
|
96
70
|
readonly state: Readable<TimeState>;
|
|
97
71
|
/** How long to wait for the answer to a command (ms). */
|
|
98
72
|
readonly answerTimeoutMs: number;
|
|
@@ -105,9 +79,10 @@ export interface ClientTime {
|
|
|
105
79
|
/** Changes the speed (a pause stays in effect). */
|
|
106
80
|
setSpeed(value: number | 'max'): SendResult;
|
|
107
81
|
/**
|
|
108
|
-
* Sends a command. The result arrives as the launcher's command and time events. With no run, or while waiting for
|
|
109
|
-
* the answer to the previous command, nothing is sent and `{sent: false, reason}` is returned.
|
|
110
|
-
* command
|
|
82
|
+
* Sends a command. The result arrives as the launcher's command, state and time events. With no run, or while waiting for
|
|
83
|
+
* the answer to the previous command, nothing is sent and `{sent: false, reason}` is returned. Whether the launcher
|
|
84
|
+
* would accept the command is `allowed` of its state (or `controls` of connect()); a command it refuses comes back in
|
|
85
|
+
* lastCommand with the reason.
|
|
111
86
|
*/
|
|
112
87
|
send(command: TimeCommand): SendResult;
|
|
113
88
|
}
|
|
@@ -118,27 +93,23 @@ export interface ClientTime {
|
|
|
118
93
|
* - The state is built from the session copy (summary and launcher events; the summary is authoritative). A client
|
|
119
94
|
* that connects midway gets the same state from the summary.
|
|
120
95
|
* - The server passes commands to the launcher and returns at once. lastCommand shows whether the launcher accepted a
|
|
121
|
-
* command, time
|
|
96
|
+
* command; the launcher's state (a pause, a resume, the speed) and time (where it is) show that it took effect.
|
|
122
97
|
*/
|
|
123
98
|
export declare class TimeControl implements ClientTime {
|
|
124
99
|
private readonly session;
|
|
125
100
|
private readonly transport;
|
|
126
101
|
/** How long to wait for an answer (ms). */
|
|
127
102
|
readonly answerTimeoutMs: number;
|
|
128
|
-
/** Variable state (used to decide beforeStart; if absent, always false). */
|
|
129
|
-
private readonly variables;
|
|
130
103
|
private readonly inFlight;
|
|
131
104
|
private readonly pending;
|
|
132
105
|
private readonly failureValue;
|
|
133
106
|
private answerTimer;
|
|
134
107
|
private lastLateness;
|
|
135
|
-
/** Time state
|
|
108
|
+
/** Time state. */
|
|
136
109
|
readonly state: Readable<TimeState>;
|
|
137
|
-
constructor(session: Readable<SessionView | null>,
|
|
110
|
+
constructor(session: Readable<SessionView | null>, transport: HttpTransport,
|
|
138
111
|
/** How long to wait for an answer (ms). */
|
|
139
|
-
answerTimeoutMs?: number, onError?: ErrorSink
|
|
140
|
-
/** Variable state (used to decide beforeStart; if absent, always false). */
|
|
141
|
-
variables?: Readable<VariablesState> | null);
|
|
112
|
+
answerTimeoutMs?: number, onError?: ErrorSink);
|
|
142
113
|
pause(): SendResult;
|
|
143
114
|
resume(): SendResult;
|
|
144
115
|
/**
|
|
@@ -148,10 +119,10 @@ export declare class TimeControl implements ClientTime {
|
|
|
148
119
|
/** Changes the speed (a pause stays in effect). */
|
|
149
120
|
setSpeed(value: number | 'max'): SendResult;
|
|
150
121
|
/**
|
|
151
|
-
* Sends a command. The result arrives as the launcher's command and time events (the content of the HTTP answer is
|
|
122
|
+
* Sends a command. The result arrives as the launcher's command, state and time events (the content of the HTTP answer is
|
|
152
123
|
* not used). With no run, or while waiting for the answer to the previous command (sending), nothing is sent and
|
|
153
124
|
* `{sent: false, reason}` is returned. If no answer comes within answerTimeoutMs, stops waiting and reports it in
|
|
154
|
-
* failure.
|
|
125
|
+
* failure. Whether the launcher would accept the command is `allowed` of its state.
|
|
155
126
|
*/
|
|
156
127
|
send(command: TimeCommand): SendResult;
|
|
157
128
|
/** Stops the wait timer and stops waiting for the answer (when the client closes). */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { VariableAvailability } from './protocol.js';
|
|
1
2
|
import { ConnectionState } from './connection.js';
|
|
2
|
-
import { SessionView } from './session-state.js';
|
|
3
|
-
import { TimeState } from './time.js';
|
|
3
|
+
import { Reason, SessionView } from './session-state.js';
|
|
4
4
|
import { ErrorSink, Readable } from './values.js';
|
|
5
5
|
import { ValueCondition, WriteBlock, WriteStatus, WriteValue } from './variable-state.js';
|
|
6
6
|
import { HistoryPoint, OperationView, VariableInfo, VariableReading, VariableRef, VariableWatch, VariablesState, WatchOptions, WriteOptions } from './variables.js';
|
|
@@ -31,10 +31,20 @@ export interface BoundVariable {
|
|
|
31
31
|
readonly info: VariableInfo | undefined;
|
|
32
32
|
/** The last value (undefined if none yet, or if values are not received (visible is false)). */
|
|
33
33
|
readonly reading: VariableReading | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* Whether the ECU uses the variable now (`unknown` if the variable is not in the current run). Information only: it
|
|
36
|
+
* does not enter condition or block, and a disconnection does not change it.
|
|
37
|
+
*/
|
|
38
|
+
readonly availability: VariableAvailability;
|
|
34
39
|
/** State of the value (stale, none yet, the value at the paused time and so on). */
|
|
35
40
|
readonly condition: ValueCondition;
|
|
36
41
|
/** Why the variable cannot be written now (null if it can). */
|
|
37
42
|
readonly block: WriteBlock | null;
|
|
43
|
+
/**
|
|
44
|
+
* When block is `launcher`: the launcher's reason, as it wrote it in `allowed.write` of its `state` (`code`, such as
|
|
45
|
+
* `scenario-running`, and one English sentence). null otherwise.
|
|
46
|
+
*/
|
|
47
|
+
readonly launcherReason: Reason | null;
|
|
38
48
|
/**
|
|
39
49
|
* Status of the last write to this variable (in the current run). Every bind of the same variable sees the same
|
|
40
50
|
* status.
|
|
@@ -102,7 +112,6 @@ export interface BindingSources {
|
|
|
102
112
|
write(writes: Record<string, Record<string, number | boolean | string>>, options?: WriteOptions): Promise<OperationView>;
|
|
103
113
|
};
|
|
104
114
|
readonly connection: Readable<ConnectionState>;
|
|
105
|
-
readonly time: Readable<TimeState>;
|
|
106
115
|
readonly session: Readable<SessionView | null>;
|
|
107
116
|
readonly onError: ErrorSink;
|
|
108
117
|
}
|
|
@@ -133,10 +142,15 @@ export declare class VariableBinder {
|
|
|
133
142
|
/** Whether the connection between the client and the GUI server is open. */
|
|
134
143
|
connected(): boolean;
|
|
135
144
|
/**
|
|
136
|
-
* Why the variable cannot be written now (null if it can). Only the widget-independent reasons (Binding adds
|
|
137
|
-
*
|
|
145
|
+
* Why the variable cannot be written now (null if it can). Only the widget-independent reasons (Binding adds range
|
|
146
|
+
* and value).
|
|
138
147
|
*/
|
|
139
148
|
block(ref: VariableRef): WriteBlock | null;
|
|
149
|
+
/**
|
|
150
|
+
* Why the launcher does not take a write now (launcherAnswer of its last `state`; `unsupported` until a `state` says).
|
|
151
|
+
* The client keeps no rule of its own about it.
|
|
152
|
+
*/
|
|
153
|
+
launcherReason(): Reason | null;
|
|
140
154
|
/** Status of the last write to that variable in the current run. */
|
|
141
155
|
status(ref: VariableRef): WriteStatus;
|
|
142
156
|
/** The value sent whose result has not arrived yet (null if none). */
|
|
@@ -54,34 +54,40 @@ export declare function valueCondition(input: ConditionInput): ValueCondition;
|
|
|
54
54
|
/** Whether two value states are the same (kind, value, reason). */
|
|
55
55
|
export declare function sameCondition(a: ValueCondition, b: ValueCondition): boolean;
|
|
56
56
|
/**
|
|
57
|
-
* Why the variable cannot be written now (null if it can).
|
|
57
|
+
* Why the variable cannot be written now (null if it can). In this order: the facts of the variable and the run first,
|
|
58
|
+
* then the launcher's answer, then the client's prediction (parameter), then what the widget needs.
|
|
58
59
|
* - read-only: a read-only variable (role output).
|
|
59
60
|
* - disconnected: the connection between the client and the GUI server is down.
|
|
60
61
|
* - not-ready: the variable API is unavailable (not running, connecting, cannot connect).
|
|
61
62
|
* - ended: the run has ended.
|
|
62
63
|
* - missing: the variable is not in the current run.
|
|
63
64
|
* - peer-disconnected: that ECU is not connected to the Control Server.
|
|
64
|
-
* -
|
|
65
|
-
*
|
|
65
|
+
* - launcher: the launcher does not take a write now (`allowed.write` of its `state`, for example `scenario-running`
|
|
66
|
+
* while a scenario plays), or has not said yet that it does (no `state` yet: `unsupported`). Its reason, code and
|
|
67
|
+
* sentence, is BoundVariable.launcherReason (launcherAnswer of session-state.ts).
|
|
68
|
+
* - parameter: a parameter can only be written before the first step (the client's prediction of the ECU's rule: the
|
|
69
|
+
* launcher does not say it for each variable).
|
|
66
70
|
* - no-range: a widget that needs a range (slider) is bound to a variable without one (min and max)
|
|
67
71
|
* (BindOptions.needsRange).
|
|
68
72
|
* - no-value: there is no value yet, so a widget that moves from the value (slider) cannot move
|
|
69
73
|
* (BindOptions.needsValue).
|
|
70
74
|
*/
|
|
71
|
-
export type WriteBlock = 'read-only' | 'disconnected' | 'not-ready' | 'ended' | 'missing' | 'peer-disconnected' | 'parameter' | 'no-range' | 'no-value'
|
|
75
|
+
export type WriteBlock = 'read-only' | 'disconnected' | 'not-ready' | 'ended' | 'missing' | 'peer-disconnected' | 'launcher' | 'parameter' | 'no-range' | 'no-value';
|
|
72
76
|
/** Input of writeBlock. */
|
|
73
77
|
export interface WriteBlockInput {
|
|
74
78
|
info: VariableInfo | undefined;
|
|
75
79
|
status: VariablesStatus;
|
|
76
80
|
connected: boolean;
|
|
77
|
-
/** Whether a run started paused is waiting before the first step (
|
|
81
|
+
/** Whether a run started paused is waiting before the first step (isHolding() of the session: `holding` of the launcher's state). */
|
|
78
82
|
beforeStart: boolean;
|
|
79
83
|
/** Whether that ECU is connected to the Control Server. */
|
|
80
84
|
peerConnected: boolean;
|
|
85
|
+
/** Whether the launcher does not take a write now, or has not said that it does (launcherAnswer(state, 'write')). */
|
|
86
|
+
launcherRefuses: boolean;
|
|
81
87
|
}
|
|
82
88
|
/**
|
|
83
89
|
* Decides why the variable cannot be written now (null if it can). Only the reasons that do not depend on the widget:
|
|
84
|
-
* client.variables.bind adds
|
|
90
|
+
* client.variables.bind adds no-range and no-value.
|
|
85
91
|
*/
|
|
86
92
|
export declare function writeBlock(input: WriteBlockInput): WriteBlock | null;
|
|
87
93
|
/** Value to write: a boolean for bool, a number for numbers, an item's value (number) or name for enums. */
|
package/types/variables.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { HttpTransport } from './http.js';
|
|
2
2
|
import { Open } from './protocol.js';
|
|
3
|
+
import type { VariableAvailability } from './protocol.js';
|
|
3
4
|
import { ErrorSink, Readable } from './values.js';
|
|
4
5
|
import type { BindOptions, VariableBinding } from './variable-binding.js';
|
|
5
6
|
/**
|
|
@@ -54,6 +55,13 @@ export interface VariablesState {
|
|
|
54
55
|
/** Why the API is unavailable or cannot connect (the server's English text). null if none. */
|
|
55
56
|
reason: string | null;
|
|
56
57
|
peers: VariablePeer[];
|
|
58
|
+
/**
|
|
59
|
+
* Whether each ECU uses each variable now (participant, then variable name): information only (it changes neither
|
|
60
|
+
* how the variable is read nor whether it can be written). Kept apart from `peers`, which holds the declared
|
|
61
|
+
* definitions, so that a notification replaces this table and leaves `peers` as it is. Every variable in `peers` has
|
|
62
|
+
* an entry; `active` when the server does not say.
|
|
63
|
+
*/
|
|
64
|
+
availability: ReadonlyMap<string, ReadonlyMap<string, VariableAvailability>>;
|
|
57
65
|
/** Number of participants and variables beyond the limit that the server did not keep. */
|
|
58
66
|
peersOmitted: number;
|
|
59
67
|
variablesOmitted: number;
|
|
@@ -125,6 +133,13 @@ export interface OperationPeer {
|
|
|
125
133
|
late: boolean;
|
|
126
134
|
/** Why it went wrong (English text from the ECU or the Control Server). */
|
|
127
135
|
reason: string | null;
|
|
136
|
+
/**
|
|
137
|
+
* How many of this participant's writes took effect, counted from the first (its writes are those
|
|
138
|
+
* of the request for it, in order). null: not known.
|
|
139
|
+
*/
|
|
140
|
+
appliedWrites: number | null;
|
|
141
|
+
/** Position (from 0) of the write that `reason` is about. null: none, or not known. */
|
|
142
|
+
failedWrite: number | null;
|
|
128
143
|
}
|
|
129
144
|
/** Result of a write (operation). */
|
|
130
145
|
export interface OperationView {
|
|
@@ -199,7 +214,10 @@ export declare class WriteError extends Error {
|
|
|
199
214
|
export interface ClientVariables {
|
|
200
215
|
/** List and state of the variables. */
|
|
201
216
|
readonly state: Readable<VariablesState>;
|
|
202
|
-
/**
|
|
217
|
+
/**
|
|
218
|
+
* Recent operations (results of writes; oldest first, up to OPERATIONS_KEPT; includes other clients' writes, not a
|
|
219
|
+
* scenario's own writes).
|
|
220
|
+
*/
|
|
203
221
|
readonly operations: Readable<readonly OperationView[]>;
|
|
204
222
|
/**
|
|
205
223
|
* The server refused a watch (`invalid-watch`, `too-many-watches`; null if not). Values of the refused subscription
|
|
@@ -314,6 +332,8 @@ export declare class VariablesFeed implements Omit<ClientVariables, 'bind'> {
|
|
|
314
332
|
/** The client was closed: fail the pending writes (including those waiting for the HTTP answer). Watches stay. */
|
|
315
333
|
dispose(): void;
|
|
316
334
|
private receive;
|
|
335
|
+
/** Returns whether any state changed. Only the availability table changes: `peers` keeps its identity. */
|
|
336
|
+
private takeAvailability;
|
|
317
337
|
/** Applies the variables part of hello and of an HTTP summary (`session`). */
|
|
318
338
|
adoptSummary(summary: unknown): void;
|
|
319
339
|
/**
|