@vehicle-sil/gui-client 0.2.0-rc.1 → 0.2.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 CHANGED
@@ -59,6 +59,24 @@ GUI サーバーは、2 つの `.mjs` のファイルも、トークンなしで
59
59
 
60
60
  公開 API は狭く始めます(追加は互換を保ち、削除は互換を壊すため)。必要なものが公開のエントリーポイントにないときは、`internal` に頼らず、追加するかを決めます。
61
61
 
62
+ ## 自作画面の波形と変数編集
63
+
64
+ `createWaveforms` は選択順に各信号の履歴を返します。選択を変更しても共通の信号の履歴を保持し、実行が替わると履歴を消します。既定は信号ごとに600点です。点の描画と別タブ間の同期は画面で行います。
65
+
66
+ `createVariableEditor` は変数の定義、表示値、書き込みの結果を `state` に公開します。数値・真偽値・列挙値を定義に照らして検査します。真偽値は適用の通知を受けてから、読み戻しが届くまで最長500 ms、次の操作を待ちます。`setVisible` で値の購読を切り替え、使い終えたら両方とも `close()` を呼びます。
67
+
68
+ ```ts
69
+ import { connect, createVariableEditor, createWaveforms } from '@vehicle-sil/gui-client';
70
+
71
+ const front = await connect();
72
+ const ref = { peer: 'Engine', name: 'engine.throttle' };
73
+ const waves = createWaveforms(front.low, { periodMs: 20 });
74
+ waves.setSignals([ref]);
75
+ const editor = createVariableEditor(front, ref);
76
+ editor.setVisible(true);
77
+ // Render waves.series and editor.state. Call editor.write(value) on commit.
78
+ ```
79
+
62
80
  ## 公開 API
63
81
 
64
82
  `src/index.ts` が公開する名前を、グループごとに挙げます。括弧の中は、そのオブジェクトのメンバーです。
@@ -100,20 +118,26 @@ GUI サーバーは、2 つの `.mjs` のファイルも、トークンなしで
100
118
 
101
119
  ### セッションのコピー
102
120
 
103
- | 種類 | 名前 |
104
- | ---- | ----------------------------------------------------------------------------------------------------------------------------------------------- |
105
- | 型 | `ClientSession`(`session`、`ready`、`allowed`、`lastEventAt`、`notices`、`rejected`、`incompatible`、`onMessages`、`report`、`dismissNotice`) |
106
- | 型 | `Notice`、`SessionView`、`ParticipantView`、`LauncherView`、`LogLine`、`LogSource`、`TimeView`、`CommandView`、`RunOutcome`、`LauncherAnswer` |
107
- | 関数 | `runOutcome`、`phaseIndex`、`isHolding`、`launcherAnswer` |
121
+ | 種類 | 名前 |
122
+ | ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
123
+ | 型 | `ClientSession`(`session`、`currentTarget`、`currentInstance`、`ready`、`allowed`、`lastEventAt`、`notices`、`rejected`、`incompatible`、`onMessages`、`report`、`dismissNotice`) |
124
+ | 型 | `Notice`、`SessionView`、`ParticipantView`、`LauncherView`、`LogLine`、`LogSource`、`TimeView`、`CommandView`、`RunOutcome`、`LauncherAnswer` |
125
+ | 関数 | `runOutcome`、`phaseIndex`、`isHolding`、`launcherAnswer` |
108
126
 
109
127
  `ClientSession.allowed` は、GUI サーバーがいま受けるものです(`start`、`stop`、`force`。それぞれ `ok`、理由のコード `reason`、文 `message`。`rev` の大きい方が勝ちます。サーバーが言うまでは `null`)。`SessionView.launcherState` は、ランチャーの最後の `state` イベントです(実行の状態と、いま受けるもの。`rev` の大きい方が勝ちます。届くまでは `null`)。`launcherAnswer(launcherState, name)` は、1 つの操作(`write`、`pause` など)について、それが言うことを読みます: `reason`(受けるなら `null`)と `caution`。まだ言っていないランチャー(`state` がまだない、その操作の項目がない)は、受けないものとします(`unsupported`)。正面の口の `controls` と `variables.bind` は、これでランチャーを読みます。
110
128
 
129
+ サーバーが付ける session と変数の revision は、HTTP と WebSocket の要約の前後関係を示します。旧サーバーには番号がないため、両者の順序は最善を尽くす扱いです。revision によって replay、コマンドの応答、確定済み操作結果は捨てません。
130
+
131
+ `currentTarget()` は現在の `{session, instance}` を返し、不明なら `null` を返します。`currentInstance()` は実行がなくても直近に認証したサーバーのインスタンスを返し、切断中も保持します。再接続ではサーバーが保持する履歴を先頭から再送してもらい、再起動前のカーソルを別のインスタンスに使いません。HTTP のみの利用者は、サーバー再起動後に `fetchSession()` でコピーを更新できます。
132
+
111
133
  ### 実行の操作
112
134
 
113
- | 種類 | 名前 |
114
- | ---- | ------------------------------------------------------------------------------------------------- |
115
- | 型 | `ClientRun`(`starting`、`stopping`、`stopWhileStarting`、`error`、`start`、`stop`、`forceStop`) |
116
- | 型 | `StopAction` |
135
+ | 種類 | 名前 |
136
+ | ---- | -------------------------------------------------------------------------------------------------------------------- |
137
+ | 型 | `ClientRun`(`starting`、`stopping`、`currentStopping`、`stopWhileStarting`、`error`、`start`、`stop`、`forceStop`) |
138
+ | 型 | `StopAction` |
139
+
140
+ `currentStopping` は現在のセッションまたは開始を対象とする応答待ちの停止だけを示し、`stopping` は前の実行の停止も含みます。停止と強制停止は、把握しているセッションとインスタンスを対象にします。確認画面は確認時の組を `front.run.forceStop(target)` に渡せます。対象が変わった場合や新しい開始が応答待ちの場合は断ります。このクライアントの開始中に停止を頼んだ場合は開始の応答を待ちます。応答が失われた場合は停止を送らず、その旨をエラーで知らせます。再試行する前に現在の実行を確認してください。対象付き停止に対応しない旧サーバーではエラーになり、同じクライアントからの重複した開始も断ります。
117
141
 
118
142
  ### 時間
119
143
 
@@ -123,6 +147,10 @@ GUI サーバーは、2 つの `.mjs` のファイルも、トークンなしで
123
147
  | 型 | `TimeState`、`TimeFailure`、`Lateness`、`SendResult`、`NotSentReason` |
124
148
  | 定数 | `ANSWER_TIMEOUT_MS` |
125
149
 
150
+ `front.time` と `client.time` は、把握している実行 ID とサーバーの識別子をコマンドに付けます。実行が切り替わった場合、サーバーはランチャーに送る前にコマンドを拒否します。この指定に対応していないサーバーはリクエストを拒否します。
151
+
152
+ 画面は、操作ボタンなどを描画した時点の `RunTarget` を `front.time` に渡せます。その対象が現在の実行と一致しなければ、クライアントが操作を拒否します。
153
+
126
154
  ### ECU の変数
127
155
 
128
156
  | 種類 | 名前 |
package/README.md CHANGED
@@ -59,6 +59,24 @@ The GUI server also serves the two `.mjs` files, without the token, as `/vsil/ve
59
59
 
60
60
  The public API is kept small, because adding to it keeps compatibility and removing from it breaks compatibility. If the public entry point lacks something you need, do not reach into `internal`; decide whether to add it to the public API.
61
61
 
62
+ ## Live waveforms and variable editing
63
+
64
+ `createWaveforms` returns live histories in selection order. Signals shared by two selections keep their history, and a new run clears the histories. It keeps up to 600 points per signal by default. The screen draws the points and handles cross-tab synchronization.
65
+
66
+ `createVariableEditor` exposes the variable definition, display value and write outcome in `state`. It validates numeric, Boolean and enum edits against the definition. After a Boolean edit is applied, it waits for readback for up to 500 ms before accepting another edit. Set visibility to subscribe to values, and call `close()` on both parts when done.
67
+
68
+ ```ts
69
+ import { connect, createVariableEditor, createWaveforms } from '@vehicle-sil/gui-client';
70
+
71
+ const front = await connect();
72
+ const ref = { peer: 'Engine', name: 'engine.throttle' };
73
+ const waves = createWaveforms(front.low, { periodMs: 20 });
74
+ waves.setSignals([ref]);
75
+ const editor = createVariableEditor(front, ref);
76
+ editor.setVisible(true);
77
+ // Render waves.series and editor.state. Call editor.write(value) on commit.
78
+ ```
79
+
62
80
  ## Public API
63
81
 
64
82
  The names that `src/index.ts` exports, by group. Parentheses list the members of the object.
@@ -100,20 +118,26 @@ In the browser, call `takeToken(window)`. It reads `#token=` from the URL, remov
100
118
 
101
119
  ### Session copy
102
120
 
103
- | Kind | Name |
104
- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
105
- | Type | `ClientSession` (`session`, `ready`, `allowed`, `lastEventAt`, `notices`, `rejected`, `incompatible`, `onMessages`, `report`, `dismissNotice`) |
106
- | Type | `Notice`, `SessionView`, `ParticipantView`, `LauncherView`, `LogLine`, `LogSource`, `TimeView`, `CommandView`, `RunOutcome`, `LauncherAnswer` |
107
- | Function | `runOutcome`, `phaseIndex`, `isHolding`, `launcherAnswer` |
121
+ | Kind | Name |
122
+ | -------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
123
+ | Type | `ClientSession` (`session`, `currentTarget`, `currentInstance`, `ready`, `allowed`, `lastEventAt`, `notices`, `rejected`, `incompatible`, `onMessages`, `report`, `dismissNotice`) |
124
+ | Type | `Notice`, `SessionView`, `ParticipantView`, `LauncherView`, `LogLine`, `LogSource`, `TimeView`, `CommandView`, `RunOutcome`, `LauncherAnswer` |
125
+ | Function | `runOutcome`, `phaseIndex`, `isHolding`, `launcherAnswer` |
108
126
 
109
127
  `ClientSession.allowed` is what the GUI server accepts now (`start`, `stop` and `force`, each with `ok`, a `reason` code and a `message`; the larger `rev` wins; `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.
110
128
 
129
+ Server-provided session and variable revisions order snapshots across HTTP and WebSocket; older servers omit them, so cross-transport ordering is best effort. Revisions do not suppress replay, command answers, or terminal operation results.
130
+
131
+ The `currentTarget()` method returns the current `{session, 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 the client requests the retained replay from the beginning, so a restarted server cannot apply a cursor from another instance. An HTTP-only client can refresh its copy with `fetchSession()` after a server restart.
132
+
111
133
  ### Run control
112
134
 
113
- | Kind | Name |
114
- | ---- | ------------------------------------------------------------------------------------------------ |
115
- | Type | `ClientRun` (`starting`, `stopping`, `stopWhileStarting`, `error`, `start`, `stop`, `forceStop`) |
116
- | Type | `StopAction` |
135
+ | Kind | Name |
136
+ | ---- | ------------------------------------------------------------------------------------------------------------------- |
137
+ | Type | `ClientRun` (`starting`, `stopping`, `currentStopping`, `stopWhileStarting`, `error`, `start`, `stop`, `forceStop`) |
138
+ | Type | `StopAction` |
139
+
140
+ `currentStopping` reports only pending stops of the current session or current start; `stopping` includes stops for earlier runs. Stop and force stop target the known session and instance. A confirmation can pass the captured pair to `front.run.forceStop(target)`; the action is refused if the target has changed or a new start is pending. A stop requested during this client’s start waits for its answer; if that answer is lost, the stop is not sent and the error says so. Check the current session before retrying. An old server without targeted stop is rejected; overlapping starts on one client are rejected.
117
141
 
118
142
  ### Time
119
143
 
@@ -123,6 +147,10 @@ In the browser, call `takeToken(window)`. It reads `#token=` from the URL, remov
123
147
  | Type | `TimeState`, `TimeFailure`, `Lateness`, `SendResult`, `NotSentReason` |
124
148
  | Constant | `ANSWER_TIMEOUT_MS` |
125
149
 
150
+ 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
+ A screen can pass the `RunTarget` it captured when rendering a control to `front.time`. The client rejects the action if that target no longer matches the current run.
153
+
126
154
  ### ECU variable API
127
155
 
128
156
  | Kind | Name |