@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
|
@@ -0,0 +1,4393 @@
|
|
|
1
|
+
// vehicle-sil-timeline.js: the custom element <vehicle-sil-timeline>, which draws a timeline file of
|
|
2
|
+
// vehicle-sil (docs/gui.md, "Putting a timeline on your own screen"). Load it with <script src> or import it
|
|
3
|
+
// for its effect; vehicle-sil-timeline.d.ts has its types. Made by gui/timeline/bundle.js from messages.js,
|
|
4
|
+
// timeline.css and viewer.js: do not edit it, edit those and run bundle.js again.
|
|
5
|
+
|
|
6
|
+
// The words of the timeline page (timeline.html and viewer.js), in English and Japanese. Every text that the page
|
|
7
|
+
// shows comes from here; names, units, values and messages from the file and the launcher are shown as they are.
|
|
8
|
+
// A value is a string, a function of named arguments that returns a string, or (for a paragraph with markup) an
|
|
9
|
+
// array of strings and [tag, text] pairs. Both languages have the same keys (tests/viewer.test.js checks it).
|
|
10
|
+
// A plain script like viewer.js (no build), loaded before it (bundle.py puts both in vehicle-sil-timeline.js).
|
|
11
|
+
// A page adds a language or changes a text with the element's messages property, without changing this file.
|
|
12
|
+
(function (global) {
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
const en = {
|
|
16
|
+
// --- reading a file
|
|
17
|
+
'file.named': ({ name }) => `"${name}"`,
|
|
18
|
+
'file.this': 'The file',
|
|
19
|
+
'file.howToWrite':
|
|
20
|
+
'Open the file that "vehicle_sil_launch run <configuration> --scenario <scenario> --timeline <file>" wrote.',
|
|
21
|
+
'read.notJson': ({ label, error, how }) => `${label} is not JSON (${error}). ${how}`,
|
|
22
|
+
'read.notTimeline': ({ label, how }) =>
|
|
23
|
+
`${label} is not a timeline file: it has no "vehicle_sil_timeline" key. ${how}`,
|
|
24
|
+
'read.writtenBy': ({ version }) => ` (it was written by vehicle-sil ${version})`,
|
|
25
|
+
'read.otherFormat': ({ label, format, by, known }) =>
|
|
26
|
+
`${label} is timeline format ${format}${by}, and this page reads format ${known} only. ` +
|
|
27
|
+
'Open it with the timeline page of the vehicle-sil version that wrote it.',
|
|
28
|
+
'read.otherStage': ({ label, stage }) =>
|
|
29
|
+
`${label} has stage ${stage}, and this page draws only "run" (the record of a run). ` +
|
|
30
|
+
'Open it with the timeline page of the vehicle-sil version that wrote it.',
|
|
31
|
+
'read.noScenario': ({ label, how }) =>
|
|
32
|
+
`${label} has no "scenario" object, so it is not a whole timeline file. ${how}`,
|
|
33
|
+
'read.noArray': ({ label, key, how }) =>
|
|
34
|
+
`${label} has no "${key}" array, so it is not a whole timeline file. ${how}`,
|
|
35
|
+
'read.notObject': ({ label, key, index, how }) =>
|
|
36
|
+
`${label}: ${key}[${index}] is not an object, so the file cannot be read. ${how}`,
|
|
37
|
+
'read.noName': ({ label, how }) =>
|
|
38
|
+
`${label}: a variable has no "name", so the file cannot be read. ${how}`,
|
|
39
|
+
|
|
40
|
+
// --- what the page says about parts it does not draw
|
|
41
|
+
'compare.and': ' and ',
|
|
42
|
+
'type.real': 'a number',
|
|
43
|
+
'type.integer': 'an integer',
|
|
44
|
+
'type.bool': 'true or false',
|
|
45
|
+
'type.enum': 'the value of an item (an integer)',
|
|
46
|
+
'series.what': ({ source }) => `the ${source} series`,
|
|
47
|
+
'series.unknownSource': ({ what, source }) =>
|
|
48
|
+
`${what} is not drawn: this page does not know the source "${source}".`,
|
|
49
|
+
'series.unknownEncoding': ({ what, encoding }) =>
|
|
50
|
+
`${what} is not drawn: this page does not know the encoding "${encoding}".`,
|
|
51
|
+
'series.noPoints': ({ what }) => `${what} is not drawn: it has no "points" array.`,
|
|
52
|
+
'series.noColumns': ({ what }) =>
|
|
53
|
+
`${what} is not drawn: its "columns" have no "at_ms" or "value".`,
|
|
54
|
+
'series.badPoint': ({ what }) => `${what} is not drawn: a point is not [time, value].`,
|
|
55
|
+
'series.wrongType': ({ count, what, words, type, value, at }) =>
|
|
56
|
+
`${count} value${count === 1 ? '' : 's'} of ${what} ${count === 1 ? 'is' : 'are'} not ${words}, ` +
|
|
57
|
+
`as its type ${type} says, so ${count === 1 ? 'it is' : 'they are'} not drawn (the first: ${value} at ${at}).`,
|
|
58
|
+
'series.rounded': ({ count, what, max }) =>
|
|
59
|
+
`${count} value${count === 1 ? '' : 's'} of ${what} ${count === 1 ? 'is' : 'are'} beyond ` +
|
|
60
|
+
`±${max}, which this page cannot hold exactly: shown rounded.`,
|
|
61
|
+
'band.unknownMode': ({ step, mode }) =>
|
|
62
|
+
`the condition of step ${step} is not drawn: this page does not know the mode "${mode}".`,
|
|
63
|
+
'band.unknownOp': ({ step, op }) =>
|
|
64
|
+
`the condition of step ${step} is not drawn: this page does not know "${op}".`,
|
|
65
|
+
'variable.unknownType': ({ type }) =>
|
|
66
|
+
`its type "${type}" is not known to this page; the values are drawn as numbers.`,
|
|
67
|
+
'write.notComputed': 'not computed',
|
|
68
|
+
|
|
69
|
+
// --- the read-out beside a lane, and the states of sent values
|
|
70
|
+
'word.sent': 'sent',
|
|
71
|
+
'word.seen': 'seen',
|
|
72
|
+
'readout.missing': ({ word }) => `${word}: values dropped at the file's limits`,
|
|
73
|
+
'readout.wrongType': ({ word }) => `${word}: a value that is not of the type (see the note)`,
|
|
74
|
+
'readout.value': ({ word, value }) => `${word} ${value}`,
|
|
75
|
+
'readout.notKnown': ({ value }) => `${value} (not known whether the ECU applied it)`,
|
|
76
|
+
'readout.notAppliedLastSent': ({ value, last }) =>
|
|
77
|
+
`${value} (not applied; the ECU keeps what it had: the last value sent before is ${last}, ` +
|
|
78
|
+
'and the file does not say whether it was applied)',
|
|
79
|
+
'readout.notApplied': ({ value, has }) => `${value} (not applied; the ECU has ${has})`,
|
|
80
|
+
'readout.hasUnknown': 'a value that is not known',
|
|
81
|
+
'readout.hasEarlier': 'its earlier value',
|
|
82
|
+
|
|
83
|
+
// --- the writes of a failed step
|
|
84
|
+
'writes.heading': ({ at }) => `Writes for ${at}`,
|
|
85
|
+
'writes.explainApplied': 'Applied: in the ECU, although the step failed.',
|
|
86
|
+
'writes.explainNotApplied':
|
|
87
|
+
'Not applied: the ECU refused it, or it came after the refused write in the same command, or it was not sent.',
|
|
88
|
+
'writes.explainNotKnown': 'Not known: no result says whether the ECU applied it.',
|
|
89
|
+
'writes.pointDropped': "its point was dropped at the file's limits",
|
|
90
|
+
'writes.causeAnd': ({ what }) => `the cause of the failure; ${what}`,
|
|
91
|
+
'writes.notSentCause': 'not sent: the cause of the failure',
|
|
92
|
+
'writes.notSent': 'not sent',
|
|
93
|
+
'writes.cause': 'the cause of the failure',
|
|
94
|
+
'writes.applied': 'applied',
|
|
95
|
+
'writes.notApplied': 'not applied',
|
|
96
|
+
'writes.notKnown': 'not known',
|
|
97
|
+
'writes.colVariable': 'Variable',
|
|
98
|
+
'writes.colValue': 'Value',
|
|
99
|
+
'writes.colInEcu': 'In the ECU',
|
|
100
|
+
'writes.colCause': 'Cause',
|
|
101
|
+
|
|
102
|
+
// --- the page around the chart
|
|
103
|
+
'page.title': 'Scenario timeline',
|
|
104
|
+
'page.titleOf': ({ name }) => `${name} - timeline`,
|
|
105
|
+
'page.scenario': 'Scenario',
|
|
106
|
+
'page.open': 'Open a file',
|
|
107
|
+
'page.drop': [
|
|
108
|
+
['strong', 'Drop a timeline file here'],
|
|
109
|
+
', or choose one with ',
|
|
110
|
+
['em', 'Open a file'],
|
|
111
|
+
'.',
|
|
112
|
+
],
|
|
113
|
+
'page.what': [
|
|
114
|
+
'A timeline file is the JSON that ',
|
|
115
|
+
['code', 'vehicle_sil_launch run <configuration> --scenario <scenario> --timeline <file>'],
|
|
116
|
+
' writes. Nothing leaves this computer: the page reads the file in the browser.',
|
|
117
|
+
],
|
|
118
|
+
'page.showFailure': 'Show the failure',
|
|
119
|
+
'page.whole': 'Whole run',
|
|
120
|
+
'page.zoomOut': 'Zoom out',
|
|
121
|
+
'page.help':
|
|
122
|
+
"Steps: a bar from start to end, a tick where the result was decided, a thin line on to a wait's limit. " +
|
|
123
|
+
'Shaded: the values a condition allows (green: it held; red: it did not; grey: not decided by it). ' +
|
|
124
|
+
'Red dashed line: the failure. Grey on the right: after the end of the record. Sent values: red dashed where ' +
|
|
125
|
+
'the ECU did not apply them, orange dotted where that is not known, and a thick grey line for the value the ECU ' +
|
|
126
|
+
'kept where the file says that value was applied. Drag across the chart to zoom in, double-click for the whole ' +
|
|
127
|
+
'run; hover (or focus the chart and use the arrow keys, + and - to zoom) for the values at a time.',
|
|
128
|
+
'page.chartLabel':
|
|
129
|
+
"The scenario's steps and variables over virtual time. The tables below hold the same contents.",
|
|
130
|
+
'page.cannotShow': 'This file cannot be shown. ',
|
|
131
|
+
'page.noName': '(a scenario without a name)',
|
|
132
|
+
'fact.file': 'timeline file',
|
|
133
|
+
'fact.scenario': 'scenario',
|
|
134
|
+
'fact.configuration': 'configuration',
|
|
135
|
+
'fact.variant': 'variant',
|
|
136
|
+
'fact.timeStep': 'controller time step',
|
|
137
|
+
'fact.recordedTo': 'recorded to',
|
|
138
|
+
'fact.nothingRecorded': 'nothing recorded',
|
|
139
|
+
'fact.version': 'vehicle-sil',
|
|
140
|
+
'fact.param': 'param',
|
|
141
|
+
|
|
142
|
+
// --- statuses of steps and of the scenario (the file's words, as the GUI says them)
|
|
143
|
+
'status.passed': 'passed',
|
|
144
|
+
'status.failed': 'failed',
|
|
145
|
+
'status.unfinished': 'unfinished',
|
|
146
|
+
'status.not_run': 'not run',
|
|
147
|
+
'status.skipped': 'skipped',
|
|
148
|
+
'status.incomplete': 'incomplete',
|
|
149
|
+
|
|
150
|
+
// --- the summary above the chart
|
|
151
|
+
'failure.heading': ({ step, at }) => `Step ${step} failed at ${at}`,
|
|
152
|
+
'failure.where': ({ line, file }) => `line ${line} of ${file}`,
|
|
153
|
+
'passed.heading': ({ count }) => `Passed: ${count} step${count === 1 ? '' : 's'}`,
|
|
154
|
+
'passed.skipped': ({ count }) => `${count} skipped (see the table of steps).`,
|
|
155
|
+
'notDecided.heading': ({ status }) => `Scenario ${status}`,
|
|
156
|
+
'notDecided.notRun':
|
|
157
|
+
'The scenario did not run, so there is nothing to draw. The findings below say why.',
|
|
158
|
+
'notDecided.incomplete':
|
|
159
|
+
'The scenario ended partway (incomplete): the run stopped before the scenario was decided. ' +
|
|
160
|
+
'The findings below say why.',
|
|
161
|
+
'notDecided.unknown': ({ status }) =>
|
|
162
|
+
`The scenario ended with status "${status}", which this page does not know. ` +
|
|
163
|
+
'The steps and findings below show what the file says.',
|
|
164
|
+
'dropped.heading': 'Points are missing. ',
|
|
165
|
+
'dropped.text':
|
|
166
|
+
'The launcher dropped older points at the limits of the file, so these values are missing ' +
|
|
167
|
+
'(shown as a shaded box with a dashed border): ',
|
|
168
|
+
'dropped.item': ({ variable, source, count, from, to }) =>
|
|
169
|
+
`${variable} (${source}): ${count} points from ${from} to ${to}`,
|
|
170
|
+
'late.heading': 'ECU values arrived late in this run ',
|
|
171
|
+
'late.text':
|
|
172
|
+
'(control-link-late-values). The value series of another run of the same scenario can differ.',
|
|
173
|
+
'conditions.heading': 'Not met',
|
|
174
|
+
'conditions.was': ({ value }) => `it was ${value}`,
|
|
175
|
+
'conditions.sampleOf': ({ at }) => ` (sample of ${at})`,
|
|
176
|
+
'conditions.noSample': 'no sample came in the interval',
|
|
177
|
+
'conditions.noValue': 'it had no value yet',
|
|
178
|
+
'participants.label': 'Participants',
|
|
179
|
+
|
|
180
|
+
// --- the tables below the chart
|
|
181
|
+
'tables.steps': 'Steps',
|
|
182
|
+
'tables.lines': 'Input lines',
|
|
183
|
+
'tables.findings': 'Findings',
|
|
184
|
+
'tables.count': ({ caption, count }) => `${caption} (${count})`,
|
|
185
|
+
'tables.none': 'None.',
|
|
186
|
+
'col.index': '#',
|
|
187
|
+
'col.line': 'Line',
|
|
188
|
+
'col.kind': 'Kind',
|
|
189
|
+
'col.status': 'Status',
|
|
190
|
+
'col.start': 'Start',
|
|
191
|
+
'col.decided': 'Decided',
|
|
192
|
+
'col.end': 'End',
|
|
193
|
+
'col.step': 'Step',
|
|
194
|
+
'col.result': 'Result',
|
|
195
|
+
'col.variable': 'Variable',
|
|
196
|
+
'col.from': 'From',
|
|
197
|
+
'col.to': 'To',
|
|
198
|
+
'col.base': 'Base',
|
|
199
|
+
'col.text': 'Text',
|
|
200
|
+
'col.severity': 'Severity',
|
|
201
|
+
'col.code': 'Code',
|
|
202
|
+
'col.message': 'Message',
|
|
203
|
+
'step.expectSkipped': ({ why }) => `expect not checked: ${why}`,
|
|
204
|
+
'step.showOnChart': 'Show this step on the chart',
|
|
205
|
+
'line.inputs': 'inputs',
|
|
206
|
+
'finding.codeOnly': '(code only)',
|
|
207
|
+
|
|
208
|
+
// --- the chart
|
|
209
|
+
'chart.inputs': 'Inputs: what the scenario sent (and saw)',
|
|
210
|
+
'chart.others': 'Outputs and other variables: what the scenario saw',
|
|
211
|
+
'chart.noMatch': ({ names, have }) =>
|
|
212
|
+
`No variable of this file matches ${names} (the variables option), so it has no lane. The file has ${have}.`,
|
|
213
|
+
'chart.showing': ({ from, to, start, end }) => `Showing ${from} to ${to} of ${start} to ${end}`,
|
|
214
|
+
'chart.virtualTime': 'Virtual time',
|
|
215
|
+
'chart.cursor': ({ at }) => `Cursor ${at}`,
|
|
216
|
+
'chart.steps': 'Steps',
|
|
217
|
+
'step.title': ({ index, kind, line, status }) =>
|
|
218
|
+
`Step ${index} (${kind}, line ${line}): ${status}`,
|
|
219
|
+
'step.times': ({ start, decided, end }) => `start ${start}, decided ${decided}, end ${end}`,
|
|
220
|
+
'lane.range': ({ min, max }) => `${min} to ${max}`,
|
|
221
|
+
'lane.ecuStep': ({ ms }) => `step ${ms}`,
|
|
222
|
+
'lane.label': ({ name }) => `${name}: values over virtual time`,
|
|
223
|
+
'lane.note': ({ text }) => `Note: ${text}`,
|
|
224
|
+
'lane.noValues': 'no values recorded',
|
|
225
|
+
'lane.dropped': ({ count, source, from, to }) =>
|
|
226
|
+
`${count} points of the ${source} series were dropped at the file's limits: values are missing from ` +
|
|
227
|
+
`${from} to ${to}`,
|
|
228
|
+
'legend.sent': 'sent',
|
|
229
|
+
'legend.sentUpper': 'sent (upper)',
|
|
230
|
+
'legend.seen': 'seen',
|
|
231
|
+
'legend.seenLower': 'seen (lower)',
|
|
232
|
+
'legend.notApplied': 'not applied',
|
|
233
|
+
'legend.notKnown': 'not known',
|
|
234
|
+
'legend.held': 'kept in the ECU',
|
|
235
|
+
'legend.base': 'base',
|
|
236
|
+
'fit.toDeclared': 'Scale to the declared range (min to max)',
|
|
237
|
+
'fit.toValues': 'Scale to the values',
|
|
238
|
+
'fit.declared': 'declared range',
|
|
239
|
+
'fit.values': 'fit values',
|
|
240
|
+
'line.title': ({ text, where, line }) => `${text} (${where}, line ${line})`,
|
|
241
|
+
'line.step': ({ step }) => `step ${step}`,
|
|
242
|
+
'state.notApplied': 'Sent, and the ECU did not apply it',
|
|
243
|
+
'state.notKnown': 'Sent; not known whether the ECU applied it',
|
|
244
|
+
'state.held':
|
|
245
|
+
'The value that stayed in the ECU: it was applied, and the writes after it were not',
|
|
246
|
+
'state.at': ({ title, value, at }) => `${title}: ${value} at ${at}`,
|
|
247
|
+
'state.fromTo': ({ title, value, from, to }) => `${title}: ${value} from ${from} to ${to}`,
|
|
248
|
+
'state.from': ({ value, from }) => `${value} from ${from}`,
|
|
249
|
+
'state.notAppliedSuffix': ' (not applied)',
|
|
250
|
+
'state.notKnownSuffix': ' (not known)',
|
|
251
|
+
'band.at': ({ at }) => `at ${at}`,
|
|
252
|
+
'band.range': ({ from, to }) => `${from} to ${to}`,
|
|
253
|
+
'band.limit': ({ limit }) => `, limit ${limit}`,
|
|
254
|
+
'band.didNotHold': 'did not hold',
|
|
255
|
+
'band.held': 'held',
|
|
256
|
+
'band.stepStatus': ({ status }) => `step ${status}`,
|
|
257
|
+
'band.title': ({ step, mode, compare, range, limit, result }) =>
|
|
258
|
+
`Step ${step} (${mode}): ${compare}, ${range}${limit}: ${result}`,
|
|
259
|
+
'band.expect': ({ compare }) => `expect ${compare}`,
|
|
260
|
+
'mark.noValueAt': ({ at }) => `No value at ${at}`,
|
|
261
|
+
'mark.was': ({ value, at }) => `It was ${value} (sample of ${at}): the condition did not hold`,
|
|
262
|
+
'mark.noValue': 'no value',
|
|
263
|
+
'mark.applied': 'applied',
|
|
264
|
+
'mark.notSent': 'not sent',
|
|
265
|
+
'mark.notApplied': 'not applied',
|
|
266
|
+
'mark.notKnownWhether': 'not known whether applied',
|
|
267
|
+
'mark.notKnown': 'not known',
|
|
268
|
+
'mark.cause': ' (the cause of the failure)',
|
|
269
|
+
'mark.write': ({ value, at, word, cause }) => `Write of ${value} for ${at}: ${word}${cause}`,
|
|
270
|
+
'mark.label': ({ value, word }) => `${value} ${word}`,
|
|
271
|
+
|
|
272
|
+
// --- loading (the element: src, data and token are its properties)
|
|
273
|
+
'load.fileProtocol':
|
|
274
|
+
'src works only on a page that comes from a web server, and this page was opened as a file. ' +
|
|
275
|
+
'Give the file with the data property instead.',
|
|
276
|
+
'load.notAddress': ({ src }) =>
|
|
277
|
+
`src "${src}" is not an address. Name a timeline file on this page's own server.`,
|
|
278
|
+
'load.otherOrigin': ({ origin, other }) =>
|
|
279
|
+
`src must name a file on this page's own server (${origin}), and ${other} is another one, so the file ` +
|
|
280
|
+
'was not loaded. Fetch the file yourself and give it with the data property.',
|
|
281
|
+
'load.failed': ({ url, error }) => `${url} could not be loaded (${error}). Check the address.`,
|
|
282
|
+
'load.redirected': ({ url }) =>
|
|
283
|
+
`${url} answered with a redirect, and the element does not follow redirects (the token and the headers ` +
|
|
284
|
+
'must not go to another address). Give src the address that the file is at.',
|
|
285
|
+
'load.unauthorized':
|
|
286
|
+
'HTTP 401: the server did not accept the token. Give the element the token of the GUI server (its token ' +
|
|
287
|
+
'property), or open this screen from the GUI server: its screens keep the token in the tab, where the ' +
|
|
288
|
+
'element finds it.',
|
|
289
|
+
// --- loading on the timeline page (timeline.html): ?src=, a file dropped or chosen
|
|
290
|
+
'pageLoad.cannotRead': ({ name, error }) =>
|
|
291
|
+
`"${name}" could not be read (${error}). Choose the file again.`,
|
|
292
|
+
'pageLoad.fileProtocol':
|
|
293
|
+
'?src= works only when the page comes from a web server, and this page was opened as a file. ' +
|
|
294
|
+
'Drop the timeline file on the page instead.',
|
|
295
|
+
'pageLoad.notAddress': ({ src }) =>
|
|
296
|
+
`?src=${src} is not an address. Name the timeline file on this server, or drop the file on the page.`,
|
|
297
|
+
'pageLoad.otherOrigin': ({ origin, other }) =>
|
|
298
|
+
`?src= must name a file on this page's own server (${origin}), and ${other} is another one, so the file ` +
|
|
299
|
+
'was not loaded. Download the file and drop it on the page instead.',
|
|
300
|
+
'pageLoad.failed': ({ url, error }) =>
|
|
301
|
+
`${url} could not be loaded (${error}). Check the address, or drop the file on the page.`,
|
|
302
|
+
'pageLoad.unauthorized':
|
|
303
|
+
"HTTP 401: the GUI server did not accept this page's token. Open the timeline with a left click on the " +
|
|
304
|
+
'GUI\'s "Timeline" link (a middle click or "Open link in new tab" does not pass the token on), or add ' +
|
|
305
|
+
'"#token=<token>" from the address the GUI server printed to the end of this page\'s address.',
|
|
306
|
+
'load.http': ({ status, message }) => `HTTP ${status}${message ? `: ${message}` : ''}`,
|
|
307
|
+
|
|
308
|
+
// --- a value of an option that the element cannot use (in the browser's console)
|
|
309
|
+
'warn.number': ({ name, value }) =>
|
|
310
|
+
`<vehicle-sil-timeline>: ${name}="${value}" is not a number, so it is ignored. Write a number, such as 120.`,
|
|
311
|
+
'warn.range': ({ from, to }) =>
|
|
312
|
+
`<vehicle-sil-timeline>: from (${from}) is not before to (${to}), so the view does not change. ` +
|
|
313
|
+
'Give from a smaller number than to.',
|
|
314
|
+
'warn.hide': ({ value, known }) =>
|
|
315
|
+
`<vehicle-sil-timeline>: hide has "${value}", which is not a part, so it is ignored. The parts: ${known}.`,
|
|
316
|
+
'warn.theme': ({ value }) =>
|
|
317
|
+
`<vehicle-sil-timeline>: theme="${value}" is not light, dark or auto, so the colours follow the page (auto).`,
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
const ja = {
|
|
321
|
+
// --- ファイルを読む
|
|
322
|
+
'file.named': ({ name }) => `「${name}」`,
|
|
323
|
+
'file.this': 'このファイル',
|
|
324
|
+
'file.howToWrite':
|
|
325
|
+
'「vehicle_sil_launch run <構成ファイル> --scenario <シナリオ> --timeline <ファイル>」が書いたファイルを開いてください。',
|
|
326
|
+
'read.notJson': ({ label, error, how }) => `${label}は JSON ではありません(${error})。${how}`,
|
|
327
|
+
'read.notTimeline': ({ label, how }) =>
|
|
328
|
+
`${label}は時間の軸のファイルではありません。キー "vehicle_sil_timeline" がありません。${how}`,
|
|
329
|
+
'read.writtenBy': ({ version }) => `(vehicle-sil ${version} が書いたもの)`,
|
|
330
|
+
'read.otherFormat': ({ label, format, by, known }) =>
|
|
331
|
+
`${label}は時間の軸の形の版 ${format}${by}で、このページが読むのは版 ${known} だけです。` +
|
|
332
|
+
'ファイルを書いた版の vehicle-sil の、時間の軸のページで開いてください。',
|
|
333
|
+
'read.otherStage': ({ label, stage }) =>
|
|
334
|
+
`${label}の stage は ${stage} で、このページが描くのは "run"(実行の記録)だけです。` +
|
|
335
|
+
'ファイルを書いた版の vehicle-sil の、時間の軸のページで開いてください。',
|
|
336
|
+
'read.noScenario': ({ label, how }) =>
|
|
337
|
+
`${label}にはオブジェクト "scenario" がないので、時間の軸のファイルの全体ではありません。${how}`,
|
|
338
|
+
'read.noArray': ({ label, key, how }) =>
|
|
339
|
+
`${label}には配列 "${key}" がないので、時間の軸のファイルの全体ではありません。${how}`,
|
|
340
|
+
'read.notObject': ({ label, key, index, how }) =>
|
|
341
|
+
`${label}: ${key}[${index}] がオブジェクトではないので、ファイルを読めません。${how}`,
|
|
342
|
+
'read.noName': ({ label, how }) =>
|
|
343
|
+
`${label}: "name" のない変数があるので、ファイルを読めません。${how}`,
|
|
344
|
+
|
|
345
|
+
// --- 描かない部分について
|
|
346
|
+
'compare.and': ' かつ ',
|
|
347
|
+
'type.real': '数',
|
|
348
|
+
'type.integer': '整数',
|
|
349
|
+
'type.bool': 'true か false',
|
|
350
|
+
'type.enum': '項目の値(整数)',
|
|
351
|
+
'series.what': ({ source }) => `系列 ${source}`,
|
|
352
|
+
'series.unknownSource': ({ what, source }) =>
|
|
353
|
+
`${what}は描きません。このページは source "${source}" を知りません。`,
|
|
354
|
+
'series.unknownEncoding': ({ what, encoding }) =>
|
|
355
|
+
`${what}は描きません。このページは encoding "${encoding}" を知りません。`,
|
|
356
|
+
'series.noPoints': ({ what }) => `${what}は描きません。配列 "points" がありません。`,
|
|
357
|
+
'series.noColumns': ({ what }) =>
|
|
358
|
+
`${what}は描きません。"columns" に "at_ms" か "value" がありません。`,
|
|
359
|
+
'series.badPoint': ({ what }) => `${what}は描きません。[時刻, 値] でない点があります。`,
|
|
360
|
+
'series.wrongType': ({ count, what, words, type, value, at }) =>
|
|
361
|
+
`${what}の値のうち ${count} 個は、型 ${type} が言う${words}ではないので、描きません(最初のもの: ${at} の ${value})。`,
|
|
362
|
+
'series.rounded': ({ count, what, max }) =>
|
|
363
|
+
`${what}の値のうち ${count} 個は ±${max} を超えていて、このページでは正確に持てません。丸めて出します。`,
|
|
364
|
+
'band.unknownMode': ({ step, mode }) =>
|
|
365
|
+
`手順 ${step} の条件は描きません。このページは mode "${mode}" を知りません。`,
|
|
366
|
+
'band.unknownOp': ({ step, op }) =>
|
|
367
|
+
`手順 ${step} の条件は描きません。このページは "${op}" を知りません。`,
|
|
368
|
+
'variable.unknownType': ({ type }) =>
|
|
369
|
+
`型 "${type}" をこのページは知りません。値は数として描きます。`,
|
|
370
|
+
'write.notComputed': '計算されていない',
|
|
371
|
+
|
|
372
|
+
// --- 段の横の読み値と、送った値の状態
|
|
373
|
+
'word.sent': '送った値',
|
|
374
|
+
'word.seen': '見た値',
|
|
375
|
+
'readout.missing': ({ word }) => `${word}: ファイルの上限で捨てた値`,
|
|
376
|
+
'readout.wrongType': ({ word }) => `${word}: 型に合わない値(注記を見てください)`,
|
|
377
|
+
'readout.value': ({ word, value }) => `${word} ${value}`,
|
|
378
|
+
'readout.notKnown': ({ value }) => `${value}(ECU に入ったか不明)`,
|
|
379
|
+
'readout.notAppliedLastSent': ({ value, last }) =>
|
|
380
|
+
`${value}(入らなかった。ECU は前の値のまま。その前に送った最後の値は ${last} で、` +
|
|
381
|
+
'それが入ったかはファイルにありません)',
|
|
382
|
+
'readout.notApplied': ({ value, has }) => `${value}(入らなかった。ECU の値は ${has})`,
|
|
383
|
+
'readout.hasUnknown': 'わからない値',
|
|
384
|
+
'readout.hasEarlier': '前の値',
|
|
385
|
+
|
|
386
|
+
// --- 失敗した手順の書き込み
|
|
387
|
+
'writes.heading': ({ at }) => `${at} の書き込み`,
|
|
388
|
+
'writes.explainApplied': '入った: 手順は失敗したが、ECU に入った。',
|
|
389
|
+
'writes.explainNotApplied':
|
|
390
|
+
'入らなかった: ECU が断った、同じコマンドで断られた書き込みより後だった、または送っていない。',
|
|
391
|
+
'writes.explainNotKnown': '不明: ECU に入ったかを言う結果がない。',
|
|
392
|
+
'writes.pointDropped': 'その点はファイルの上限で捨てた',
|
|
393
|
+
'writes.causeAnd': ({ what }) => `失敗の原因。${what}`,
|
|
394
|
+
'writes.notSentCause': '送っていない: 失敗の原因',
|
|
395
|
+
'writes.notSent': '送っていない',
|
|
396
|
+
'writes.cause': '失敗の原因',
|
|
397
|
+
'writes.applied': '入った',
|
|
398
|
+
'writes.notApplied': '入らなかった',
|
|
399
|
+
'writes.notKnown': '不明',
|
|
400
|
+
'writes.colVariable': '変数',
|
|
401
|
+
'writes.colValue': '値',
|
|
402
|
+
'writes.colInEcu': 'ECU に',
|
|
403
|
+
'writes.colCause': '原因',
|
|
404
|
+
|
|
405
|
+
// --- 図のまわり
|
|
406
|
+
'page.title': 'シナリオの時間の軸',
|
|
407
|
+
'page.titleOf': ({ name }) => `${name} - 時間の軸`,
|
|
408
|
+
'page.scenario': 'シナリオ',
|
|
409
|
+
'page.open': 'ファイルを開く',
|
|
410
|
+
'page.drop': [
|
|
411
|
+
['strong', '時間の軸のファイルをここに落とす'],
|
|
412
|
+
'か、',
|
|
413
|
+
['em', 'ファイルを開く'],
|
|
414
|
+
'で選びます。',
|
|
415
|
+
],
|
|
416
|
+
'page.what': [
|
|
417
|
+
'時間の軸のファイルは、',
|
|
418
|
+
['code', 'vehicle_sil_launch run <構成ファイル> --scenario <シナリオ> --timeline <ファイル>'],
|
|
419
|
+
' が書く JSON です。ページはファイルをブラウザの中で読み、このコンピューターの外に何も送りません。',
|
|
420
|
+
],
|
|
421
|
+
'page.showFailure': '失敗の所',
|
|
422
|
+
'page.whole': '実行の全体',
|
|
423
|
+
'page.zoomOut': '縮小',
|
|
424
|
+
'page.help':
|
|
425
|
+
'手順: 始まりから終わりまでの棒、結果が決まった所の縦線、待つ手順の上限までの細い線。' +
|
|
426
|
+
'帯: 条件が許す値(緑は成り立った、赤は成り立たなかった、灰はその条件では決まらなかった)。' +
|
|
427
|
+
'赤の破線: 失敗の時刻。右の灰: 記録の終わりより後。送った値: ECU に入らなかったものは赤の破線、' +
|
|
428
|
+
'入ったか不明なものはオレンジの点線、入ったとファイルが言う値のうち ECU に残った値は太い灰の線。' +
|
|
429
|
+
'図の上をドラッグすると拡大し、ダブルクリックで実行の全体に戻ります。' +
|
|
430
|
+
'ある時刻の値は、図の上に置くと出ます(図にフォーカスして矢印キー、+ と - で拡大と縮小)。',
|
|
431
|
+
'page.chartLabel': 'シナリオの手順と変数を仮想時刻で並べた図。下の表に同じ内容があります。',
|
|
432
|
+
'page.cannotShow': 'このファイルは表示できません。',
|
|
433
|
+
'page.noName': '(名前のないシナリオ)',
|
|
434
|
+
'fact.file': '時間の軸のファイル',
|
|
435
|
+
'fact.scenario': 'シナリオ',
|
|
436
|
+
'fact.configuration': '構成ファイル',
|
|
437
|
+
'fact.variant': 'variant',
|
|
438
|
+
'fact.timeStep': 'コントローラーの時間の刻み',
|
|
439
|
+
'fact.recordedTo': '記録の終わり',
|
|
440
|
+
'fact.nothingRecorded': '記録なし',
|
|
441
|
+
'fact.version': 'vehicle-sil',
|
|
442
|
+
'fact.param': 'パラメーター',
|
|
443
|
+
|
|
444
|
+
// --- 手順とシナリオの状態(GUI と同じ言い方)
|
|
445
|
+
'status.passed': '通った',
|
|
446
|
+
'status.failed': '失敗',
|
|
447
|
+
'status.unfinished': '途中で終わった',
|
|
448
|
+
'status.not_run': '動かなかった',
|
|
449
|
+
'status.skipped': '飛ばした',
|
|
450
|
+
'status.incomplete': '終わる前に止まった',
|
|
451
|
+
|
|
452
|
+
// --- 図の上の要約
|
|
453
|
+
'failure.heading': ({ step, at }) => `手順 ${step} が ${at} で失敗しました`,
|
|
454
|
+
'failure.where': ({ line, file }) => `${file} の ${line} 行`,
|
|
455
|
+
'passed.heading': ({ count }) => `通りました: ${count} 個の手順`,
|
|
456
|
+
'passed.skipped': ({ count }) => `${count} 個を飛ばしました(手順の表を見てください)。`,
|
|
457
|
+
'notDecided.heading': ({ status }) => `シナリオ: ${status}`,
|
|
458
|
+
'notDecided.notRun':
|
|
459
|
+
'シナリオは動かなかったので、描くものがありません。理由は下の指摘にあります。',
|
|
460
|
+
'notDecided.incomplete':
|
|
461
|
+
'シナリオは途中で終わりました(incomplete)。シナリオの結果が決まる前に実行が止まりました。' +
|
|
462
|
+
'理由は下の指摘にあります。',
|
|
463
|
+
'notDecided.unknown': ({ status }) =>
|
|
464
|
+
`シナリオは状態 "${status}" で終わりましたが、このページはこの状態を知りません。` +
|
|
465
|
+
'ファイルにあるものを、下の手順と指摘に出します。',
|
|
466
|
+
'dropped.heading': '点が欠けています。',
|
|
467
|
+
'dropped.text':
|
|
468
|
+
'ランチャーがファイルの上限で古い点を捨てたので、次の値が欠けています(破線の枠の、塗った箱で示します): ',
|
|
469
|
+
'dropped.item': ({ variable, source, count, from, to }) =>
|
|
470
|
+
`${variable}(${source}): ${from} から ${to} までの ${count} 点`,
|
|
471
|
+
'late.heading': 'この実行では、ECU の値が遅れて届きました',
|
|
472
|
+
'late.text':
|
|
473
|
+
'(control-link-late-values)。同じシナリオの別の実行では、値の系列が違うことがあります。',
|
|
474
|
+
'conditions.heading': '成り立たなかった条件',
|
|
475
|
+
'conditions.was': ({ value }) => `値は ${value}`,
|
|
476
|
+
'conditions.sampleOf': ({ at }) => `(${at} のサンプル)`,
|
|
477
|
+
'conditions.noSample': '区間の中にサンプルが来なかった',
|
|
478
|
+
'conditions.noValue': 'まだ値がなかった',
|
|
479
|
+
'participants.label': 'participant',
|
|
480
|
+
|
|
481
|
+
// --- 図の下の表
|
|
482
|
+
'tables.steps': '手順',
|
|
483
|
+
'tables.lines': '入力の線',
|
|
484
|
+
'tables.findings': '指摘',
|
|
485
|
+
'tables.count': ({ caption, count }) => `${caption}(${count})`,
|
|
486
|
+
'tables.none': 'ありません。',
|
|
487
|
+
'col.index': '#',
|
|
488
|
+
'col.line': '行',
|
|
489
|
+
'col.kind': '種類',
|
|
490
|
+
'col.status': '状態',
|
|
491
|
+
'col.start': '始まり',
|
|
492
|
+
'col.decided': '決まった',
|
|
493
|
+
'col.end': '終わり',
|
|
494
|
+
'col.step': '手順',
|
|
495
|
+
'col.result': '結果',
|
|
496
|
+
'col.variable': '変数',
|
|
497
|
+
'col.from': 'から',
|
|
498
|
+
'col.to': 'まで',
|
|
499
|
+
'col.base': '基準',
|
|
500
|
+
'col.text': '文',
|
|
501
|
+
'col.severity': '重さ',
|
|
502
|
+
'col.code': 'code',
|
|
503
|
+
'col.message': '文面',
|
|
504
|
+
'step.expectSkipped': ({ why }) => `expect を確かめていない: ${why}`,
|
|
505
|
+
'step.showOnChart': 'この手順を図で見る',
|
|
506
|
+
'line.inputs': '入力',
|
|
507
|
+
'finding.codeOnly': '(code だけ)',
|
|
508
|
+
|
|
509
|
+
// --- 図
|
|
510
|
+
'chart.inputs': '入力: シナリオが送った値(と見た値)',
|
|
511
|
+
'chart.others': '出力とほかの変数: シナリオが見た値',
|
|
512
|
+
'chart.noMatch': ({ names, have }) =>
|
|
513
|
+
`${names} に当たる変数がこのファイルにないので(variables の設定)、そのレーンはありません。ファイルの変数: ${have}。`,
|
|
514
|
+
'chart.showing': ({ from, to, start, end }) =>
|
|
515
|
+
`${start} から ${end} のうち、${from} から ${to} を表示`,
|
|
516
|
+
'chart.virtualTime': '仮想時刻',
|
|
517
|
+
'chart.cursor': ({ at }) => `カーソル ${at}`,
|
|
518
|
+
'chart.steps': '手順',
|
|
519
|
+
'step.title': ({ index, kind, line, status }) =>
|
|
520
|
+
`手順 ${index}(${kind}、${line} 行): ${status}`,
|
|
521
|
+
'step.times': ({ start, decided, end }) =>
|
|
522
|
+
`始まり ${start}、決まった ${decided}、終わり ${end}`,
|
|
523
|
+
'lane.range': ({ min, max }) => `${min} から ${max}`,
|
|
524
|
+
'lane.ecuStep': ({ ms }) => `刻み ${ms}`,
|
|
525
|
+
'lane.label': ({ name }) => `${name}: 仮想時刻での値`,
|
|
526
|
+
'lane.note': ({ text }) => `注記: ${text}`,
|
|
527
|
+
'lane.noValues': '値の記録なし',
|
|
528
|
+
'lane.dropped': ({ count, source, from, to }) =>
|
|
529
|
+
`系列 ${source} の ${count} 点を、ファイルの上限で捨てました。${from} から ${to} までの値が欠けています`,
|
|
530
|
+
'legend.sent': '送った値',
|
|
531
|
+
'legend.sentUpper': '送った値(上)',
|
|
532
|
+
'legend.seen': '見た値',
|
|
533
|
+
'legend.seenLower': '見た値(下)',
|
|
534
|
+
'legend.notApplied': '入らなかった',
|
|
535
|
+
'legend.notKnown': '不明',
|
|
536
|
+
'legend.held': 'ECU に残った値',
|
|
537
|
+
'legend.base': '基準',
|
|
538
|
+
'fit.toDeclared': '宣言の範囲(min から max)に合わせる',
|
|
539
|
+
'fit.toValues': '値に合わせる',
|
|
540
|
+
'fit.declared': '宣言の範囲',
|
|
541
|
+
'fit.values': '値に合わせた',
|
|
542
|
+
'line.title': ({ text, where, line }) => `${text}(${where}、${line} 行)`,
|
|
543
|
+
'line.step': ({ step }) => `手順 ${step}`,
|
|
544
|
+
'state.notApplied': '送ったが、ECU に入らなかった',
|
|
545
|
+
'state.notKnown': '送ったが、ECU に入ったか不明',
|
|
546
|
+
'state.held': 'ECU に残った値: これは入り、その後の書き込みは入らなかった',
|
|
547
|
+
'state.at': ({ title, value, at }) => `${title}: ${at} の ${value}`,
|
|
548
|
+
'state.fromTo': ({ title, value, from, to }) => `${title}: ${from} から ${to} まで ${value}`,
|
|
549
|
+
'state.from': ({ value, from }) => `${from} から ${value}`,
|
|
550
|
+
'state.notAppliedSuffix': '(入らなかった)',
|
|
551
|
+
'state.notKnownSuffix': '(不明)',
|
|
552
|
+
'band.at': ({ at }) => `${at} で`,
|
|
553
|
+
'band.range': ({ from, to }) => `${from} から ${to}`,
|
|
554
|
+
'band.limit': ({ limit }) => `、上限 ${limit}`,
|
|
555
|
+
'band.didNotHold': '成り立たなかった',
|
|
556
|
+
'band.held': '成り立った',
|
|
557
|
+
'band.stepStatus': ({ status }) => `手順は ${status}`,
|
|
558
|
+
'band.title': ({ step, mode, compare, range, limit, result }) =>
|
|
559
|
+
`手順 ${step}(${mode}): ${compare}、${range}${limit}: ${result}`,
|
|
560
|
+
'band.expect': ({ compare }) => `expect ${compare}`,
|
|
561
|
+
'mark.noValueAt': ({ at }) => `${at} に値がない`,
|
|
562
|
+
'mark.was': ({ value, at }) => `値は ${value}(${at} のサンプル): 条件は成り立たなかった`,
|
|
563
|
+
'mark.noValue': '値なし',
|
|
564
|
+
'mark.applied': '入った',
|
|
565
|
+
'mark.notSent': '送っていない',
|
|
566
|
+
'mark.notApplied': '入らなかった',
|
|
567
|
+
'mark.notKnownWhether': '入ったか不明',
|
|
568
|
+
'mark.notKnown': '不明',
|
|
569
|
+
'mark.cause': '(失敗の原因)',
|
|
570
|
+
'mark.write': ({ value, at, word, cause }) => `${at} の ${value} の書き込み: ${word}${cause}`,
|
|
571
|
+
'mark.label': ({ value, word }) => `${value} ${word}`,
|
|
572
|
+
|
|
573
|
+
// --- 読み込み(要素: src、data、token は要素のプロパティ)
|
|
574
|
+
'load.fileProtocol':
|
|
575
|
+
'src は、Web サーバーから開いたページでだけ使えます。このページはファイルとして開いています。' +
|
|
576
|
+
'ファイルは data のプロパティで渡してください。',
|
|
577
|
+
'load.notAddress': ({ src }) =>
|
|
578
|
+
`src の「${src}」はアドレスではありません。このページと同じサーバーの時間の軸のファイルを指してください。`,
|
|
579
|
+
'load.otherOrigin': ({ origin, other }) =>
|
|
580
|
+
`src は、このページと同じサーバー(${origin})のファイルを指す必要があります。${other} は別のサーバーなので、` +
|
|
581
|
+
'読みませんでした。ファイルを自分で取得して、data のプロパティで渡してください。',
|
|
582
|
+
'load.failed': ({ url, error }) =>
|
|
583
|
+
`${url} を読み込めませんでした(${error})。アドレスを確かめてください。`,
|
|
584
|
+
'load.redirected': ({ url }) =>
|
|
585
|
+
`${url} は転送で答えました。要素は転送をたどりません(トークンとヘッダーを別のアドレスへ送らないため)。` +
|
|
586
|
+
'src には、ファイルのあるアドレスを書いてください。',
|
|
587
|
+
'load.unauthorized':
|
|
588
|
+
'HTTP 401: サーバーがトークンを受け付けませんでした。GUI サーバーのトークンを要素に渡すか(token のプロパティ)、' +
|
|
589
|
+
'この画面を GUI サーバーから開いてください。GUI サーバーの画面はトークンをタブに持ち、要素はそれを使います。',
|
|
590
|
+
// --- 時間の軸のページ(timeline.html)での読み込み: ?src=、落とした・選んだファイル
|
|
591
|
+
'pageLoad.cannotRead': ({ name, error }) =>
|
|
592
|
+
`「${name}」を読めませんでした(${error})。ファイルを選び直してください。`,
|
|
593
|
+
'pageLoad.fileProtocol':
|
|
594
|
+
'?src= は、ページを Web サーバーから開いたときだけ使えます。このページはファイルとして開いています。' +
|
|
595
|
+
'時間の軸のファイルをページに落としてください。',
|
|
596
|
+
'pageLoad.notAddress': ({ src }) =>
|
|
597
|
+
`?src=${src} はアドレスではありません。このサーバーの時間の軸のファイルを指すか、ファイルをページに落としてください。`,
|
|
598
|
+
'pageLoad.otherOrigin': ({ origin, other }) =>
|
|
599
|
+
`?src= は、このページと同じサーバー(${origin})のファイルを指す必要があります。${other} は別のサーバーなので、` +
|
|
600
|
+
'読みませんでした。ファイルをダウンロードして、ページに落としてください。',
|
|
601
|
+
'pageLoad.failed': ({ url, error }) =>
|
|
602
|
+
`${url} を読み込めませんでした(${error})。アドレスを確かめるか、ファイルをページに落としてください。`,
|
|
603
|
+
'pageLoad.unauthorized':
|
|
604
|
+
'HTTP 401: GUI サーバーが、このページのトークンを受け付けませんでした。GUI の「時間の軸」のリンクを左クリックで' +
|
|
605
|
+
'開いてください(中ボタンや「新しいタブで開く」では、トークンが渡りません)。または、GUI サーバーが表示した' +
|
|
606
|
+
'アドレスの「#token=<トークン>」を、このページのアドレスの末尾に付けてください。',
|
|
607
|
+
'load.http': ({ status, message }) => `HTTP ${status}${message ? `: ${message}` : ''}`,
|
|
608
|
+
|
|
609
|
+
// --- 要素が使えない設定の値(ブラウザーのコンソールに)
|
|
610
|
+
'warn.number': ({ name, value }) =>
|
|
611
|
+
`<vehicle-sil-timeline>: ${name}="${value}" は数でないので、使いません。120 のような数を書いてください。`,
|
|
612
|
+
'warn.range': ({ from, to }) =>
|
|
613
|
+
`<vehicle-sil-timeline>: from(${from})が to(${to})より前でないので、出す範囲を変えません。` +
|
|
614
|
+
'from には to より小さい数を書いてください。',
|
|
615
|
+
'warn.hide': ({ value, known }) =>
|
|
616
|
+
`<vehicle-sil-timeline>: hide の「${value}」は部分の名前でないので、使いません。部分: ${known}。`,
|
|
617
|
+
'warn.theme': ({ value }) =>
|
|
618
|
+
`<vehicle-sil-timeline>: theme="${value}" は light、dark、auto のどれでもないので、色はページに従います(auto)。`,
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
const MESSAGES = { en, ja };
|
|
622
|
+
global.VehicleSilTimelineMessages = MESSAGES;
|
|
623
|
+
})(globalThis);
|
|
624
|
+
|
|
625
|
+
// timeline.css, adopted by the shadow root of every element
|
|
626
|
+
(function (global) {
|
|
627
|
+
'use strict';
|
|
628
|
+
global.VehicleSilTimelineStyles = `
|
|
629
|
+
/* The look of <vehicle-sil-timeline> (viewer.js), inside its shadow root: nothing here reaches the page around it,
|
|
630
|
+
and the page's CSS does not reach in. bundle.js puts this file into vehicle-sil-timeline.js.
|
|
631
|
+
The colours: each is a public custom property --vst-<name> that a page sets on the element or on any element
|
|
632
|
+
around it (:root, for example), else the default below. They are read here into private --_<name> and never set
|
|
633
|
+
under their public names, so that a value from an ancestor reaches in (docs/gui.md lists them). light-dark()
|
|
634
|
+
picks the light or dark colour by the element's color-scheme: theme="light" and theme="dark" set it, theme="auto"
|
|
635
|
+
(no attribute) leaves the one it inherits from the page. The attributes theme, compact and hide are read here;
|
|
636
|
+
the element's script reads compact too, for the sizes of the lanes. */
|
|
637
|
+
:host {
|
|
638
|
+
--_bg: var(--vst-bg, light-dark(#f7f7f5, #131518));
|
|
639
|
+
--_panel: var(--vst-panel, light-dark(#ffffff, #1b1e22));
|
|
640
|
+
--_fg: var(--vst-fg, light-dark(#1b1d20, #e4e6e9));
|
|
641
|
+
--_muted: var(--vst-muted, light-dark(#5c636b, #9aa1aa));
|
|
642
|
+
--_border: var(--vst-border, light-dark(#d7dadd, #343940));
|
|
643
|
+
--_grid: var(--vst-grid, light-dark(#e9ebed, #262a2f));
|
|
644
|
+
--_sent: var(--vst-sent, light-dark(#1f5fc4, #79a8ff));
|
|
645
|
+
--_seen: var(--vst-seen, light-dark(#0b7c70, #3cc4b1));
|
|
646
|
+
--_base: var(--vst-base, light-dark(#8a5cc2, #b89af0));
|
|
647
|
+
--_ok: var(--vst-ok, light-dark(#1b7a39, #5cc97c));
|
|
648
|
+
--_ok-fill: var(--vst-ok-fill, light-dark(rgba(27, 122, 57, 0.12), rgba(92, 201, 124, 0.14)));
|
|
649
|
+
--_bad: var(--vst-bad, light-dark(#c42525, #ff6f6f));
|
|
650
|
+
--_bad-fill: var(--vst-bad-fill, light-dark(rgba(196, 37, 37, 0.13), rgba(255, 111, 111, 0.16)));
|
|
651
|
+
--_bad-bg: var(--vst-bad-bg, light-dark(#fdf0ef, #2c1a1b));
|
|
652
|
+
--_warn: var(--vst-warn, light-dark(#995400, #f0b04a));
|
|
653
|
+
--_warn-fill: var(--vst-warn-fill, light-dark(rgba(214, 138, 0, 0.16), rgba(240, 176, 74, 0.16)));
|
|
654
|
+
--_warn-bg: var(--vst-warn-bg, light-dark(#fdf6e8, #2a2317));
|
|
655
|
+
--_ok-bg: var(--vst-ok-bg, light-dark(#eef7f0, #18261c));
|
|
656
|
+
--_neutral: var(--vst-neutral, light-dark(#737a83, #8d949d));
|
|
657
|
+
--_neutral-fill: var(
|
|
658
|
+
--vst-neutral-fill,
|
|
659
|
+
light-dark(rgba(115, 122, 131, 0.14), rgba(141, 148, 157, 0.16))
|
|
660
|
+
);
|
|
661
|
+
--_unrecorded: var(
|
|
662
|
+
--vst-unrecorded,
|
|
663
|
+
light-dark(rgba(110, 110, 110, 0.1), rgba(160, 160, 160, 0.08))
|
|
664
|
+
);
|
|
665
|
+
--_true: var(--vst-true, light-dark(#1f5fc4, #79a8ff));
|
|
666
|
+
--_e0: var(--vst-e0, light-dark(#dfe6f3, #263248));
|
|
667
|
+
--_e1: var(--vst-e1, light-dark(#e7dff3, #33284a));
|
|
668
|
+
--_e2: var(--vst-e2, light-dark(#dff0ea, #1f3a33));
|
|
669
|
+
--_cursor: var(--vst-cursor, light-dark(#3b3f45, #c9cdd2));
|
|
670
|
+
--_selection: var(
|
|
671
|
+
--vst-selection,
|
|
672
|
+
light-dark(rgba(31, 95, 196, 0.15), rgba(121, 168, 255, 0.18))
|
|
673
|
+
);
|
|
674
|
+
|
|
675
|
+
display: block;
|
|
676
|
+
overflow: auto;
|
|
677
|
+
background: var(--_bg);
|
|
678
|
+
color: var(--_fg);
|
|
679
|
+
font:
|
|
680
|
+
14px/1.45 system-ui,
|
|
681
|
+
-apple-system,
|
|
682
|
+
'Segoe UI',
|
|
683
|
+
sans-serif;
|
|
684
|
+
}
|
|
685
|
+
:host([theme='light']) {
|
|
686
|
+
color-scheme: light;
|
|
687
|
+
}
|
|
688
|
+
:host([theme='dark']) {
|
|
689
|
+
color-scheme: dark;
|
|
690
|
+
}
|
|
691
|
+
:host([hidden]) {
|
|
692
|
+
display: none;
|
|
693
|
+
}
|
|
694
|
+
:host([compact]) {
|
|
695
|
+
font-size: 12px;
|
|
696
|
+
}
|
|
697
|
+
/* while src loads, the file shown before is dimmed */
|
|
698
|
+
:host([aria-busy='true']) #view {
|
|
699
|
+
opacity: 0.6;
|
|
700
|
+
}
|
|
701
|
+
/* hide="<parts>": the parts a screen does without */
|
|
702
|
+
:host([hide~='header']) #head,
|
|
703
|
+
:host([hide~='summary']) #summary,
|
|
704
|
+
:host([hide~='toolbar']) #toolbar,
|
|
705
|
+
:host([hide~='help']) #help,
|
|
706
|
+
:host([hide~='tables']) #tables,
|
|
707
|
+
:host([hide~='steps']) .lane.steps,
|
|
708
|
+
:host([hide~='readout']) .readout,
|
|
709
|
+
:host([hide~='legend']) .legend .key {
|
|
710
|
+
display: none !important;
|
|
711
|
+
}
|
|
712
|
+
:host([compact]) .lane {
|
|
713
|
+
grid-template-columns: 120px 1fr;
|
|
714
|
+
}
|
|
715
|
+
@container (max-width: 479px) {
|
|
716
|
+
:host([compact]) .lane {
|
|
717
|
+
grid-template-columns: 1fr;
|
|
718
|
+
}
|
|
719
|
+
:host([compact]) .lane-head {
|
|
720
|
+
border-right: none;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
* {
|
|
724
|
+
box-sizing: border-box;
|
|
725
|
+
}
|
|
726
|
+
code,
|
|
727
|
+
.message {
|
|
728
|
+
font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
|
|
729
|
+
font-size: 0.92em;
|
|
730
|
+
}
|
|
731
|
+
/* The element's title is an h2, so that it sits under the h1 of the page around it; its parts use h3 and h4 */
|
|
732
|
+
h2 {
|
|
733
|
+
font-size: 1.35rem;
|
|
734
|
+
margin: 0 0 6px;
|
|
735
|
+
overflow-wrap: anywhere;
|
|
736
|
+
}
|
|
737
|
+
h3 {
|
|
738
|
+
font-size: 1.1rem;
|
|
739
|
+
margin: 0 0 4px;
|
|
740
|
+
}
|
|
741
|
+
h4 {
|
|
742
|
+
font-size: 0.95rem;
|
|
743
|
+
margin: 10px 0 4px;
|
|
744
|
+
}
|
|
745
|
+
.muted {
|
|
746
|
+
color: var(--_muted);
|
|
747
|
+
}
|
|
748
|
+
.small {
|
|
749
|
+
font-size: 0.85rem;
|
|
750
|
+
}
|
|
751
|
+
#head {
|
|
752
|
+
display: flex;
|
|
753
|
+
flex-wrap: wrap;
|
|
754
|
+
gap: 8px 16px;
|
|
755
|
+
align-items: flex-start;
|
|
756
|
+
justify-content: space-between;
|
|
757
|
+
margin-bottom: 12px;
|
|
758
|
+
}
|
|
759
|
+
#head > div:first-child {
|
|
760
|
+
min-width: 0;
|
|
761
|
+
flex: 1 1 320px;
|
|
762
|
+
}
|
|
763
|
+
#facts {
|
|
764
|
+
display: flex;
|
|
765
|
+
flex-wrap: wrap;
|
|
766
|
+
gap: 4px 14px;
|
|
767
|
+
align-items: center;
|
|
768
|
+
}
|
|
769
|
+
.fact {
|
|
770
|
+
overflow-wrap: anywhere;
|
|
771
|
+
}
|
|
772
|
+
button {
|
|
773
|
+
font: inherit;
|
|
774
|
+
color: var(--_fg);
|
|
775
|
+
background: var(--_panel);
|
|
776
|
+
border: 1px solid var(--_border);
|
|
777
|
+
border-radius: 6px;
|
|
778
|
+
padding: 4px 10px;
|
|
779
|
+
cursor: pointer;
|
|
780
|
+
}
|
|
781
|
+
button:hover {
|
|
782
|
+
border-color: var(--_muted);
|
|
783
|
+
}
|
|
784
|
+
button:focus-visible,
|
|
785
|
+
#chart:focus-visible {
|
|
786
|
+
outline: 2px solid var(--_sent);
|
|
787
|
+
outline-offset: 2px;
|
|
788
|
+
}
|
|
789
|
+
button.link {
|
|
790
|
+
border: none;
|
|
791
|
+
background: none;
|
|
792
|
+
padding: 0;
|
|
793
|
+
color: var(--_sent);
|
|
794
|
+
text-decoration: underline;
|
|
795
|
+
}
|
|
796
|
+
.badge {
|
|
797
|
+
display: inline-block;
|
|
798
|
+
padding: 0 8px;
|
|
799
|
+
border-radius: 10px;
|
|
800
|
+
font-weight: 600;
|
|
801
|
+
border: 1px solid currentColor;
|
|
802
|
+
white-space: nowrap;
|
|
803
|
+
}
|
|
804
|
+
.st-passed {
|
|
805
|
+
color: var(--_ok);
|
|
806
|
+
}
|
|
807
|
+
.st-failed {
|
|
808
|
+
color: var(--_bad);
|
|
809
|
+
}
|
|
810
|
+
.st-incomplete,
|
|
811
|
+
.st-unfinished {
|
|
812
|
+
color: var(--_warn);
|
|
813
|
+
}
|
|
814
|
+
.st-not_run,
|
|
815
|
+
.st-skipped,
|
|
816
|
+
.st-unknown {
|
|
817
|
+
color: var(--_neutral);
|
|
818
|
+
}
|
|
819
|
+
.banner {
|
|
820
|
+
border: 1px solid var(--_border);
|
|
821
|
+
border-left-width: 5px;
|
|
822
|
+
border-radius: 6px;
|
|
823
|
+
padding: 10px 14px;
|
|
824
|
+
margin: 0 0 10px;
|
|
825
|
+
background: var(--_panel);
|
|
826
|
+
overflow-wrap: anywhere;
|
|
827
|
+
}
|
|
828
|
+
.banner.bad {
|
|
829
|
+
border-color: var(--_bad);
|
|
830
|
+
background: var(--_bad-bg);
|
|
831
|
+
}
|
|
832
|
+
.banner.bad h3 {
|
|
833
|
+
color: var(--_bad);
|
|
834
|
+
}
|
|
835
|
+
.banner.ok {
|
|
836
|
+
border-color: var(--_ok);
|
|
837
|
+
background: var(--_ok-bg);
|
|
838
|
+
}
|
|
839
|
+
.banner.ok h3 {
|
|
840
|
+
color: var(--_ok);
|
|
841
|
+
}
|
|
842
|
+
.banner.warn {
|
|
843
|
+
border-color: var(--_warn);
|
|
844
|
+
background: var(--_warn-bg);
|
|
845
|
+
}
|
|
846
|
+
.banner p {
|
|
847
|
+
margin: 4px 0;
|
|
848
|
+
}
|
|
849
|
+
.banner ul {
|
|
850
|
+
margin: 2px 0;
|
|
851
|
+
padding-left: 20px;
|
|
852
|
+
}
|
|
853
|
+
.message {
|
|
854
|
+
white-space: pre-wrap;
|
|
855
|
+
}
|
|
856
|
+
.actions {
|
|
857
|
+
display: flex;
|
|
858
|
+
flex-wrap: wrap;
|
|
859
|
+
gap: 8px;
|
|
860
|
+
margin-top: 8px !important;
|
|
861
|
+
}
|
|
862
|
+
table {
|
|
863
|
+
border-collapse: collapse;
|
|
864
|
+
width: 100%;
|
|
865
|
+
}
|
|
866
|
+
th,
|
|
867
|
+
td {
|
|
868
|
+
text-align: left;
|
|
869
|
+
vertical-align: top;
|
|
870
|
+
padding: 3px 8px;
|
|
871
|
+
border-bottom: 1px solid var(--_border);
|
|
872
|
+
}
|
|
873
|
+
th {
|
|
874
|
+
font-weight: 600;
|
|
875
|
+
color: var(--_muted);
|
|
876
|
+
}
|
|
877
|
+
td.num {
|
|
878
|
+
white-space: nowrap;
|
|
879
|
+
font-variant-numeric: tabular-nums;
|
|
880
|
+
}
|
|
881
|
+
table.writes {
|
|
882
|
+
width: auto;
|
|
883
|
+
max-width: 100%;
|
|
884
|
+
background: var(--_panel);
|
|
885
|
+
}
|
|
886
|
+
tr.cause td {
|
|
887
|
+
font-weight: 600;
|
|
888
|
+
}
|
|
889
|
+
tr.failed-row td {
|
|
890
|
+
background: var(--_bad-fill);
|
|
891
|
+
}
|
|
892
|
+
.applied-true {
|
|
893
|
+
color: var(--_ok);
|
|
894
|
+
}
|
|
895
|
+
.applied-false {
|
|
896
|
+
color: var(--_bad);
|
|
897
|
+
}
|
|
898
|
+
.applied-null {
|
|
899
|
+
color: var(--_warn);
|
|
900
|
+
}
|
|
901
|
+
.table-wrap {
|
|
902
|
+
overflow-x: auto;
|
|
903
|
+
}
|
|
904
|
+
details {
|
|
905
|
+
margin: 12px 0;
|
|
906
|
+
}
|
|
907
|
+
summary {
|
|
908
|
+
font-weight: 600;
|
|
909
|
+
cursor: pointer;
|
|
910
|
+
}
|
|
911
|
+
.toolbar {
|
|
912
|
+
display: flex;
|
|
913
|
+
flex-wrap: wrap;
|
|
914
|
+
gap: 6px 10px;
|
|
915
|
+
align-items: center;
|
|
916
|
+
margin: 8px 0;
|
|
917
|
+
}
|
|
918
|
+
#range {
|
|
919
|
+
margin-right: auto;
|
|
920
|
+
}
|
|
921
|
+
.chip {
|
|
922
|
+
border: 1px solid var(--_border);
|
|
923
|
+
border-radius: 12px;
|
|
924
|
+
padding: 1px 8px;
|
|
925
|
+
cursor: pointer;
|
|
926
|
+
}
|
|
927
|
+
#chart {
|
|
928
|
+
container-type: inline-size;
|
|
929
|
+
border: 1px solid var(--_border);
|
|
930
|
+
border-radius: 6px;
|
|
931
|
+
background: var(--_panel);
|
|
932
|
+
}
|
|
933
|
+
.lane {
|
|
934
|
+
display: grid;
|
|
935
|
+
grid-template-columns: 200px 1fr;
|
|
936
|
+
border-bottom: 1px solid var(--_grid);
|
|
937
|
+
}
|
|
938
|
+
.lane-head {
|
|
939
|
+
padding: 4px 8px;
|
|
940
|
+
border-right: 1px solid var(--_grid);
|
|
941
|
+
min-width: 0;
|
|
942
|
+
overflow-wrap: anywhere;
|
|
943
|
+
}
|
|
944
|
+
.lane.failing .lane-head {
|
|
945
|
+
box-shadow: inset 4px 0 0 var(--_bad);
|
|
946
|
+
}
|
|
947
|
+
.lane-plot {
|
|
948
|
+
min-width: 0;
|
|
949
|
+
overflow: hidden;
|
|
950
|
+
}
|
|
951
|
+
.lane.axis {
|
|
952
|
+
position: sticky;
|
|
953
|
+
top: 0;
|
|
954
|
+
z-index: 1;
|
|
955
|
+
background: var(--_panel);
|
|
956
|
+
}
|
|
957
|
+
.group {
|
|
958
|
+
padding: 4px 8px;
|
|
959
|
+
font-weight: 600;
|
|
960
|
+
font-size: 0.85rem;
|
|
961
|
+
color: var(--_muted);
|
|
962
|
+
background: var(--_bg);
|
|
963
|
+
border-bottom: 1px solid var(--_grid);
|
|
964
|
+
}
|
|
965
|
+
@container (max-width: 719px) {
|
|
966
|
+
:host(:not([compact])) .lane {
|
|
967
|
+
grid-template-columns: 1fr;
|
|
968
|
+
}
|
|
969
|
+
:host(:not([compact])) .lane-head {
|
|
970
|
+
border-right: none;
|
|
971
|
+
}
|
|
972
|
+
}
|
|
973
|
+
.var-name {
|
|
974
|
+
font-weight: 600;
|
|
975
|
+
}
|
|
976
|
+
.var-name.failing {
|
|
977
|
+
color: var(--_bad);
|
|
978
|
+
}
|
|
979
|
+
.legend {
|
|
980
|
+
display: flex;
|
|
981
|
+
flex-wrap: wrap;
|
|
982
|
+
gap: 2px 10px;
|
|
983
|
+
align-items: center;
|
|
984
|
+
}
|
|
985
|
+
.key::before {
|
|
986
|
+
content: '';
|
|
987
|
+
display: inline-block;
|
|
988
|
+
width: 14px;
|
|
989
|
+
height: 0;
|
|
990
|
+
margin-right: 4px;
|
|
991
|
+
vertical-align: middle;
|
|
992
|
+
border-top: 2px solid var(--_sent);
|
|
993
|
+
}
|
|
994
|
+
.key.seen::before {
|
|
995
|
+
border-top: 1.5px solid var(--_seen);
|
|
996
|
+
}
|
|
997
|
+
.key.base::before {
|
|
998
|
+
border-top: 1.5px dashed var(--_base);
|
|
999
|
+
}
|
|
1000
|
+
.key.not-applied::before {
|
|
1001
|
+
border-top: 2px dashed var(--_bad);
|
|
1002
|
+
}
|
|
1003
|
+
.key.not-known::before {
|
|
1004
|
+
border-top: 2px dotted var(--_warn);
|
|
1005
|
+
}
|
|
1006
|
+
.key.held::before {
|
|
1007
|
+
border-top: 4px solid var(--_neutral);
|
|
1008
|
+
}
|
|
1009
|
+
.readout {
|
|
1010
|
+
color: var(--_fg);
|
|
1011
|
+
font-variant-numeric: tabular-nums;
|
|
1012
|
+
min-height: 1.45em;
|
|
1013
|
+
overflow-wrap: anywhere;
|
|
1014
|
+
}
|
|
1015
|
+
.note {
|
|
1016
|
+
color: var(--_warn);
|
|
1017
|
+
}
|
|
1018
|
+
#error {
|
|
1019
|
+
border: 1px solid var(--_bad);
|
|
1020
|
+
border-left-width: 5px;
|
|
1021
|
+
border-radius: 6px;
|
|
1022
|
+
background: var(--_bad-bg);
|
|
1023
|
+
padding: 10px 14px;
|
|
1024
|
+
margin: 0 0 12px;
|
|
1025
|
+
overflow-wrap: anywhere;
|
|
1026
|
+
}
|
|
1027
|
+
/* the chart */
|
|
1028
|
+
svg.plot {
|
|
1029
|
+
display: block;
|
|
1030
|
+
touch-action: none;
|
|
1031
|
+
cursor: crosshair;
|
|
1032
|
+
user-select: none;
|
|
1033
|
+
}
|
|
1034
|
+
svg text {
|
|
1035
|
+
fill: var(--_fg);
|
|
1036
|
+
font-size: 11px;
|
|
1037
|
+
font-family: system-ui, sans-serif;
|
|
1038
|
+
}
|
|
1039
|
+
.tick {
|
|
1040
|
+
stroke: var(--_muted);
|
|
1041
|
+
}
|
|
1042
|
+
.tick-label,
|
|
1043
|
+
.range-label,
|
|
1044
|
+
.empty-label {
|
|
1045
|
+
fill: var(--_muted);
|
|
1046
|
+
}
|
|
1047
|
+
.range-label,
|
|
1048
|
+
.tick-label,
|
|
1049
|
+
.state-label,
|
|
1050
|
+
.mark text {
|
|
1051
|
+
paint-order: stroke;
|
|
1052
|
+
stroke: var(--_panel);
|
|
1053
|
+
stroke-width: 3px;
|
|
1054
|
+
stroke-linejoin: round;
|
|
1055
|
+
}
|
|
1056
|
+
.unrecorded {
|
|
1057
|
+
fill: var(--_unrecorded);
|
|
1058
|
+
}
|
|
1059
|
+
.dropped {
|
|
1060
|
+
fill: var(--_warn-fill);
|
|
1061
|
+
stroke: var(--_warn);
|
|
1062
|
+
stroke-dasharray: 3 3;
|
|
1063
|
+
}
|
|
1064
|
+
.cursor {
|
|
1065
|
+
stroke: var(--_cursor);
|
|
1066
|
+
stroke-width: 1;
|
|
1067
|
+
pointer-events: none;
|
|
1068
|
+
}
|
|
1069
|
+
.selection {
|
|
1070
|
+
fill: var(--_selection);
|
|
1071
|
+
}
|
|
1072
|
+
.fail-line {
|
|
1073
|
+
stroke: var(--_bad);
|
|
1074
|
+
stroke-width: 1.5;
|
|
1075
|
+
stroke-dasharray: 5 3;
|
|
1076
|
+
pointer-events: none;
|
|
1077
|
+
}
|
|
1078
|
+
.step .bar {
|
|
1079
|
+
fill: var(--_neutral-fill);
|
|
1080
|
+
stroke: currentColor;
|
|
1081
|
+
}
|
|
1082
|
+
.step.st-passed .bar {
|
|
1083
|
+
fill: var(--_ok-fill);
|
|
1084
|
+
}
|
|
1085
|
+
.step.st-failed .bar {
|
|
1086
|
+
fill: var(--_bad-fill);
|
|
1087
|
+
stroke-width: 2;
|
|
1088
|
+
}
|
|
1089
|
+
.step.st-unfinished .bar {
|
|
1090
|
+
fill: var(--_warn-fill);
|
|
1091
|
+
stroke-dasharray: 4 2;
|
|
1092
|
+
}
|
|
1093
|
+
.step .marker {
|
|
1094
|
+
fill: currentColor;
|
|
1095
|
+
}
|
|
1096
|
+
.step .skipped {
|
|
1097
|
+
fill: none;
|
|
1098
|
+
stroke: currentColor;
|
|
1099
|
+
stroke-dasharray: 2 2;
|
|
1100
|
+
}
|
|
1101
|
+
.step .open {
|
|
1102
|
+
fill: none;
|
|
1103
|
+
stroke: currentColor;
|
|
1104
|
+
stroke-width: 1.5;
|
|
1105
|
+
}
|
|
1106
|
+
.step .decided {
|
|
1107
|
+
stroke: currentColor;
|
|
1108
|
+
stroke-width: 2;
|
|
1109
|
+
}
|
|
1110
|
+
.step .limit {
|
|
1111
|
+
stroke: currentColor;
|
|
1112
|
+
stroke-width: 1;
|
|
1113
|
+
}
|
|
1114
|
+
.step.st-unknown {
|
|
1115
|
+
color: var(--_fg);
|
|
1116
|
+
}
|
|
1117
|
+
.step-label {
|
|
1118
|
+
font-weight: 600;
|
|
1119
|
+
}
|
|
1120
|
+
.series {
|
|
1121
|
+
fill: none;
|
|
1122
|
+
stroke-width: 2;
|
|
1123
|
+
stroke-linejoin: round;
|
|
1124
|
+
}
|
|
1125
|
+
.series.sent {
|
|
1126
|
+
stroke: var(--_sent);
|
|
1127
|
+
}
|
|
1128
|
+
.series.seen {
|
|
1129
|
+
stroke: var(--_seen);
|
|
1130
|
+
stroke-width: 1.25;
|
|
1131
|
+
}
|
|
1132
|
+
.series.held {
|
|
1133
|
+
stroke: var(--_neutral);
|
|
1134
|
+
stroke-width: 4;
|
|
1135
|
+
opacity: 0.6;
|
|
1136
|
+
}
|
|
1137
|
+
.series.not-applied {
|
|
1138
|
+
stroke: var(--_bad);
|
|
1139
|
+
stroke-dasharray: 4 3;
|
|
1140
|
+
stroke-width: 1.5;
|
|
1141
|
+
}
|
|
1142
|
+
.series.not-known {
|
|
1143
|
+
stroke: var(--_warn);
|
|
1144
|
+
stroke-dasharray: 1 3;
|
|
1145
|
+
stroke-linecap: round;
|
|
1146
|
+
stroke-width: 2;
|
|
1147
|
+
}
|
|
1148
|
+
.series.base {
|
|
1149
|
+
stroke: var(--_base);
|
|
1150
|
+
stroke-width: 1;
|
|
1151
|
+
stroke-dasharray: 4 2;
|
|
1152
|
+
}
|
|
1153
|
+
.pt.sent {
|
|
1154
|
+
fill: var(--_sent);
|
|
1155
|
+
}
|
|
1156
|
+
.pt.seen {
|
|
1157
|
+
fill: var(--_seen);
|
|
1158
|
+
}
|
|
1159
|
+
.pt.not-applied {
|
|
1160
|
+
fill: var(--_panel);
|
|
1161
|
+
stroke: var(--_bad);
|
|
1162
|
+
stroke-width: 1.5;
|
|
1163
|
+
}
|
|
1164
|
+
.pt.not-known {
|
|
1165
|
+
fill: var(--_panel);
|
|
1166
|
+
stroke: var(--_warn);
|
|
1167
|
+
stroke-width: 1.5;
|
|
1168
|
+
}
|
|
1169
|
+
.state {
|
|
1170
|
+
stroke: var(--_panel);
|
|
1171
|
+
stroke-width: 0.5;
|
|
1172
|
+
}
|
|
1173
|
+
.state.v-true {
|
|
1174
|
+
fill: var(--_true);
|
|
1175
|
+
opacity: 0.75;
|
|
1176
|
+
}
|
|
1177
|
+
.state.v-false {
|
|
1178
|
+
fill: var(--_grid);
|
|
1179
|
+
}
|
|
1180
|
+
.state.v-null,
|
|
1181
|
+
.state.v-mixed {
|
|
1182
|
+
fill: var(--_neutral-fill);
|
|
1183
|
+
}
|
|
1184
|
+
.state.v-e0 {
|
|
1185
|
+
fill: var(--_e0);
|
|
1186
|
+
}
|
|
1187
|
+
.state.v-e1 {
|
|
1188
|
+
fill: var(--_e1);
|
|
1189
|
+
}
|
|
1190
|
+
.state.v-e2 {
|
|
1191
|
+
fill: var(--_e2);
|
|
1192
|
+
}
|
|
1193
|
+
.state.not-applied {
|
|
1194
|
+
fill: var(--_bad-fill);
|
|
1195
|
+
stroke: var(--_bad);
|
|
1196
|
+
stroke-width: 1.5;
|
|
1197
|
+
stroke-dasharray: 4 3;
|
|
1198
|
+
}
|
|
1199
|
+
.state.not-known {
|
|
1200
|
+
fill: var(--_warn-fill);
|
|
1201
|
+
stroke: var(--_warn);
|
|
1202
|
+
stroke-width: 1.5;
|
|
1203
|
+
stroke-dasharray: 1.5 2.5;
|
|
1204
|
+
}
|
|
1205
|
+
.state.held {
|
|
1206
|
+
fill: var(--_neutral);
|
|
1207
|
+
opacity: 0.6;
|
|
1208
|
+
stroke: none;
|
|
1209
|
+
}
|
|
1210
|
+
.state-label {
|
|
1211
|
+
pointer-events: none;
|
|
1212
|
+
}
|
|
1213
|
+
.band .allowed {
|
|
1214
|
+
fill: var(--_neutral-fill);
|
|
1215
|
+
}
|
|
1216
|
+
.band.ok .allowed {
|
|
1217
|
+
fill: var(--_ok-fill);
|
|
1218
|
+
}
|
|
1219
|
+
.band.bad .allowed {
|
|
1220
|
+
fill: var(--_bad-fill);
|
|
1221
|
+
}
|
|
1222
|
+
.band .threshold {
|
|
1223
|
+
stroke: var(--_neutral);
|
|
1224
|
+
stroke-dasharray: 5 3;
|
|
1225
|
+
}
|
|
1226
|
+
.band.ok .threshold {
|
|
1227
|
+
stroke: var(--_ok);
|
|
1228
|
+
}
|
|
1229
|
+
.band.bad .threshold {
|
|
1230
|
+
stroke: var(--_bad);
|
|
1231
|
+
}
|
|
1232
|
+
.band .threshold.limit {
|
|
1233
|
+
stroke-width: 0.75;
|
|
1234
|
+
stroke-dasharray: 2 3;
|
|
1235
|
+
}
|
|
1236
|
+
.band .expect-box {
|
|
1237
|
+
fill: none;
|
|
1238
|
+
stroke: var(--_neutral);
|
|
1239
|
+
stroke-width: 1.5;
|
|
1240
|
+
}
|
|
1241
|
+
.band.ok .expect-box {
|
|
1242
|
+
stroke: var(--_ok);
|
|
1243
|
+
}
|
|
1244
|
+
.band.bad .expect-box {
|
|
1245
|
+
stroke: var(--_bad);
|
|
1246
|
+
stroke-width: 2;
|
|
1247
|
+
}
|
|
1248
|
+
.expect-label {
|
|
1249
|
+
font-size: 10px;
|
|
1250
|
+
}
|
|
1251
|
+
.mark circle {
|
|
1252
|
+
fill: var(--_bad);
|
|
1253
|
+
stroke: var(--_panel);
|
|
1254
|
+
stroke-width: 1.5;
|
|
1255
|
+
}
|
|
1256
|
+
.mark text {
|
|
1257
|
+
font-weight: 700;
|
|
1258
|
+
pointer-events: none;
|
|
1259
|
+
}
|
|
1260
|
+
.mark.bad text {
|
|
1261
|
+
fill: var(--_bad);
|
|
1262
|
+
}
|
|
1263
|
+
.mark.ok text {
|
|
1264
|
+
fill: var(--_ok);
|
|
1265
|
+
}
|
|
1266
|
+
.mark.warn text {
|
|
1267
|
+
fill: var(--_warn);
|
|
1268
|
+
}
|
|
1269
|
+
.mark.write rect {
|
|
1270
|
+
fill: var(--_panel);
|
|
1271
|
+
stroke-width: 1.5;
|
|
1272
|
+
}
|
|
1273
|
+
.mark.write.ok rect {
|
|
1274
|
+
stroke: var(--_ok);
|
|
1275
|
+
}
|
|
1276
|
+
.mark.write.bad rect {
|
|
1277
|
+
stroke: var(--_bad);
|
|
1278
|
+
}
|
|
1279
|
+
.mark.write.warn rect {
|
|
1280
|
+
stroke: var(--_warn);
|
|
1281
|
+
}
|
|
1282
|
+
.mark.write.cause rect {
|
|
1283
|
+
stroke-width: 3;
|
|
1284
|
+
}
|
|
1285
|
+
.mark .glyph {
|
|
1286
|
+
font-size: 10px;
|
|
1287
|
+
}
|
|
1288
|
+
.line-mark rect,
|
|
1289
|
+
.line-mark path {
|
|
1290
|
+
fill: var(--_neutral-fill);
|
|
1291
|
+
stroke: var(--_neutral);
|
|
1292
|
+
}
|
|
1293
|
+
.line-mark.line-set path {
|
|
1294
|
+
fill: var(--_sent);
|
|
1295
|
+
stroke: none;
|
|
1296
|
+
}
|
|
1297
|
+
.line-mark.line-dither rect {
|
|
1298
|
+
fill: none;
|
|
1299
|
+
stroke: var(--_base);
|
|
1300
|
+
stroke-dasharray: 2 2;
|
|
1301
|
+
}
|
|
1302
|
+
.line-mark.line-dither path {
|
|
1303
|
+
fill: none;
|
|
1304
|
+
stroke: var(--_base);
|
|
1305
|
+
}
|
|
1306
|
+
.line-mark.line-unknown line {
|
|
1307
|
+
stroke: var(--_fg);
|
|
1308
|
+
}
|
|
1309
|
+
.line-mark text {
|
|
1310
|
+
font-size: 9px;
|
|
1311
|
+
fill: var(--_muted);
|
|
1312
|
+
}
|
|
1313
|
+
/* the step chosen on the chart or in the table (the property step) */
|
|
1314
|
+
.step.selected .bar,
|
|
1315
|
+
.step.selected .marker,
|
|
1316
|
+
.step.selected .skipped {
|
|
1317
|
+
stroke-width: 3;
|
|
1318
|
+
}
|
|
1319
|
+
.step.selected .step-label {
|
|
1320
|
+
font-weight: 700;
|
|
1321
|
+
}
|
|
1322
|
+
tr.selected td {
|
|
1323
|
+
background: var(--_selection);
|
|
1324
|
+
}
|
|
1325
|
+
.var-label {
|
|
1326
|
+
font-weight: 600;
|
|
1327
|
+
margin-right: 6px;
|
|
1328
|
+
}
|
|
1329
|
+
`;
|
|
1330
|
+
})(globalThis);
|
|
1331
|
+
|
|
1332
|
+
// The timeline of vehicle-sil: draws a timeline file, the JSON that
|
|
1333
|
+
// `vehicle_sil_launch run <configuration> --scenario <scenario> --timeline <file>` writes.
|
|
1334
|
+
// The format is schema/timeline.schema.json and "Recording a scenario run on a timeline" in docs/simulation-run.md.
|
|
1335
|
+
//
|
|
1336
|
+
// It defines the custom element <vehicle-sil-timeline> (its attributes, properties and events: "Putting a timeline
|
|
1337
|
+
// on your own screen" in docs/gui.md, and vehicle-sil-timeline.d.ts). The element draws into its own shadow root,
|
|
1338
|
+
// so that the page's CSS and its own do not meet. timeline.html with page.js is the page that shows one element.
|
|
1339
|
+
//
|
|
1340
|
+
// One plain script: no framework, no build, no fonts or scripts from elsewhere. All text goes in with textContent
|
|
1341
|
+
// (never innerHTML), because names, units and messages come from users and ECUs. It must never contain the closing
|
|
1342
|
+
// tag of a script element, so that it can be put inline too.
|
|
1343
|
+
// Every text it shows comes from messages.js (English and Japanese), loaded before this script; a page adds or
|
|
1344
|
+
// changes texts with the element's messages property. Its CSS is timeline.css. bundle.js makes the one file that
|
|
1345
|
+
// users load, vehicle-sil-timeline.js, from messages.js, timeline.css and this file.
|
|
1346
|
+
// Everything above "The element" needs no DOM: tests/viewer.test.js runs it in Node.
|
|
1347
|
+
(function (global) {
|
|
1348
|
+
'use strict';
|
|
1349
|
+
|
|
1350
|
+
const FORMAT = 1;
|
|
1351
|
+
const MESSAGES = global.VehicleSilTimelineMessages;
|
|
1352
|
+
const LANGUAGES = ['en', 'ja'];
|
|
1353
|
+
let language = 'en';
|
|
1354
|
+
/** The texts that the element being drawn adds or changes ({ <language>: { <key>: text } }), or null. */
|
|
1355
|
+
let extra = null;
|
|
1356
|
+
|
|
1357
|
+
/**
|
|
1358
|
+
* The language of the page: ?lang= in `search` when the page has it, else the first of the browser's languages
|
|
1359
|
+
* (`preferred`, as navigator.languages) that it has, else English. `known`: the languages there are texts for
|
|
1360
|
+
* (default: English and Japanese).
|
|
1361
|
+
*/
|
|
1362
|
+
function pickLanguage(search, preferred, known) {
|
|
1363
|
+
const asked = new URLSearchParams(search || '').get('lang');
|
|
1364
|
+
return chooseLanguage([asked, ...(preferred || [])], known);
|
|
1365
|
+
}
|
|
1366
|
+
|
|
1367
|
+
/** The first of the language tags (as "ja-JP") that `known` has, by the whole tag or its first part; else 'en'. */
|
|
1368
|
+
function chooseLanguage(tags, known) {
|
|
1369
|
+
const have = known || LANGUAGES;
|
|
1370
|
+
for (const tag of tags) {
|
|
1371
|
+
if (typeof tag !== 'string' || tag === '') continue;
|
|
1372
|
+
const lower = tag.toLowerCase();
|
|
1373
|
+
const found =
|
|
1374
|
+
have.find((k) => k.toLowerCase() === lower) ??
|
|
1375
|
+
have.find((k) => k.toLowerCase() === lower.split('-')[0]);
|
|
1376
|
+
if (found) return found;
|
|
1377
|
+
}
|
|
1378
|
+
return 'en';
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
function setLanguage(lang) {
|
|
1382
|
+
language = LANGUAGES.includes(lang) ? lang : 'en';
|
|
1383
|
+
}
|
|
1384
|
+
|
|
1385
|
+
/**
|
|
1386
|
+
* A text in a language: the page's own texts (`more`, as the element's messages property) first, then
|
|
1387
|
+
* messages.js; English when the language does not have it; a function value is called with args. Unknown: the key.
|
|
1388
|
+
*/
|
|
1389
|
+
function text(lang, key, args, more) {
|
|
1390
|
+
for (const where of [more?.[lang], MESSAGES?.[lang], more?.en, MESSAGES?.en]) {
|
|
1391
|
+
const value = where ? where[key] : undefined;
|
|
1392
|
+
if (value === undefined) continue;
|
|
1393
|
+
return typeof value === 'function' ? value(args || {}) : value;
|
|
1394
|
+
}
|
|
1395
|
+
return key;
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
/** A text of messages.js in the language of what is being drawn. */
|
|
1399
|
+
function t(key, args) {
|
|
1400
|
+
return text(language, key, args, extra);
|
|
1401
|
+
}
|
|
1402
|
+
|
|
1403
|
+
/** A step's or the scenario's status in the page's language (an unknown one as the file writes it). */
|
|
1404
|
+
function statusWord(status) {
|
|
1405
|
+
const key = `status.${status}`;
|
|
1406
|
+
return MESSAGES && Object.prototype.hasOwnProperty.call(MESSAGES.en, key)
|
|
1407
|
+
? t(key)
|
|
1408
|
+
: String(status);
|
|
1409
|
+
}
|
|
1410
|
+
|
|
1411
|
+
/** The values this page knows. Anything else is shown by name and text, and not drawn (the format only adds). */
|
|
1412
|
+
const KNOWN = {
|
|
1413
|
+
stepKind: ['set', 'ramp', 'wave', 'dither', 'expect', 'wait_until'],
|
|
1414
|
+
stepStatus: ['passed', 'failed', 'unfinished', 'not_run', 'skipped'],
|
|
1415
|
+
mode: ['at', 'always', 'once', 'during'],
|
|
1416
|
+
op: ['eq', 'ne', 'ge', 'le', 'gt', 'lt', 'near'],
|
|
1417
|
+
lineKind: ['set', 'ramp', 'wave', 'dither'],
|
|
1418
|
+
type: ['real', 'integer', 'bool', 'enum'],
|
|
1419
|
+
/** The encoding that goes with each source of a series. */
|
|
1420
|
+
encoding: { written: 'all', sampled: 'changes' },
|
|
1421
|
+
};
|
|
1422
|
+
|
|
1423
|
+
const isObject = (v) => v !== null && typeof v === 'object' && !Array.isArray(v);
|
|
1424
|
+
const isNum = (v) => typeof v === 'number' && Number.isFinite(v);
|
|
1425
|
+
const knows = (list, v) => list.includes(v);
|
|
1426
|
+
|
|
1427
|
+
// ---------------------------------------------------------------------------------------------------------------
|
|
1428
|
+
// Reading a file
|
|
1429
|
+
|
|
1430
|
+
/**
|
|
1431
|
+
* Reads the text (or the parsed JSON) of a timeline file.
|
|
1432
|
+
* Returns { timeline } or { error } (a sentence that says what is wrong and what to do).
|
|
1433
|
+
*/
|
|
1434
|
+
function readTimeline(input, name) {
|
|
1435
|
+
const label = name ? t('file.named', { name }) : t('file.this');
|
|
1436
|
+
const how = t('file.howToWrite');
|
|
1437
|
+
let data = input;
|
|
1438
|
+
if (typeof input === 'string') {
|
|
1439
|
+
try {
|
|
1440
|
+
data = JSON.parse(input);
|
|
1441
|
+
} catch (e) {
|
|
1442
|
+
return { error: t('read.notJson', { label, error: e.message, how }) };
|
|
1443
|
+
}
|
|
1444
|
+
}
|
|
1445
|
+
if (!isObject(data) || !('vehicle_sil_timeline' in data)) {
|
|
1446
|
+
return { error: t('read.notTimeline', { label, how }) };
|
|
1447
|
+
}
|
|
1448
|
+
if (data.vehicle_sil_timeline !== FORMAT) {
|
|
1449
|
+
const by =
|
|
1450
|
+
typeof data.vehicle_sil === 'string'
|
|
1451
|
+
? t('read.writtenBy', { version: data.vehicle_sil })
|
|
1452
|
+
: '';
|
|
1453
|
+
const format = JSON.stringify(data.vehicle_sil_timeline);
|
|
1454
|
+
return { error: t('read.otherFormat', { label, format, by, known: FORMAT }) };
|
|
1455
|
+
}
|
|
1456
|
+
if (data.stage !== 'run') {
|
|
1457
|
+
return { error: t('read.otherStage', { label, stage: JSON.stringify(data.stage) }) };
|
|
1458
|
+
}
|
|
1459
|
+
if (!isObject(data.scenario)) {
|
|
1460
|
+
return { error: t('read.noScenario', { label, how }) };
|
|
1461
|
+
}
|
|
1462
|
+
for (const key of ['variables', 'steps', 'series']) {
|
|
1463
|
+
if (!Array.isArray(data[key])) {
|
|
1464
|
+
return { error: t('read.noArray', { label, key, how }) };
|
|
1465
|
+
}
|
|
1466
|
+
const bad = data[key].findIndex((item) => !isObject(item));
|
|
1467
|
+
if (bad >= 0) {
|
|
1468
|
+
return { error: t('read.notObject', { label, key, index: bad, how }) };
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
if (data.variables.some((v) => typeof v.name !== 'string')) {
|
|
1472
|
+
return { error: t('read.noName', { label, how }) };
|
|
1473
|
+
}
|
|
1474
|
+
return { timeline: data };
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1477
|
+
// ---------------------------------------------------------------------------------------------------------------
|
|
1478
|
+
// Formatting
|
|
1479
|
+
|
|
1480
|
+
function fmtNum(v, exact) {
|
|
1481
|
+
if (!isNum(v)) return String(v);
|
|
1482
|
+
if (exact || Number.isInteger(v)) return String(v);
|
|
1483
|
+
const s = String(v);
|
|
1484
|
+
return s.length <= 9 ? s : String(Number(v.toPrecision(6)));
|
|
1485
|
+
}
|
|
1486
|
+
|
|
1487
|
+
function fmtMs(t) {
|
|
1488
|
+
return t === null || t === undefined ? '-' : `${fmtNum(t)} ms`;
|
|
1489
|
+
}
|
|
1490
|
+
|
|
1491
|
+
/** A value as the launcher writes it: an enum with its item's name, a bool as true or false. */
|
|
1492
|
+
function fmtValue(v, info, exact) {
|
|
1493
|
+
if (v === null || v === undefined) return 'null';
|
|
1494
|
+
if (typeof v === 'boolean') return String(v);
|
|
1495
|
+
if (info && info.type === 'enum' && Array.isArray(info.items)) {
|
|
1496
|
+
const item = info.items.find((i) => i && i.value === v);
|
|
1497
|
+
if (item) return `${item.name} (${v})`;
|
|
1498
|
+
}
|
|
1499
|
+
return fmtNum(v, exact);
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
/** One condition's comparisons, the way the scenario writes them ("le 200", "near 200 ± 0.5"). */
|
|
1503
|
+
function compareText(compare, info) {
|
|
1504
|
+
if (!Array.isArray(compare)) return '';
|
|
1505
|
+
return compare
|
|
1506
|
+
.map((c) => {
|
|
1507
|
+
if (!isObject(c)) return '?';
|
|
1508
|
+
const tol =
|
|
1509
|
+
c.op === 'near' && c.tolerance !== undefined ? ` ± ${fmtNum(c.tolerance, true)}` : '';
|
|
1510
|
+
return `${c.op} ${fmtValue(c.value, info, true)}${tol}`;
|
|
1511
|
+
})
|
|
1512
|
+
.join(t('compare.and'));
|
|
1513
|
+
}
|
|
1514
|
+
|
|
1515
|
+
// ---------------------------------------------------------------------------------------------------------------
|
|
1516
|
+
// The model: what the page draws, worked out once per file
|
|
1517
|
+
|
|
1518
|
+
/** Whether a value fits its variable's type. null fits all (a real that is no number); a type not known takes all. */
|
|
1519
|
+
function fitsType(value, type) {
|
|
1520
|
+
if (value === null || !knows(KNOWN.type, type)) return true;
|
|
1521
|
+
if (type === 'bool') return typeof value === 'boolean';
|
|
1522
|
+
if (type === 'real') return isNum(value);
|
|
1523
|
+
return Number.isInteger(value);
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
/**
|
|
1527
|
+
* Reads one series of a variable of type `type` into columns. Returns { series, notes } or { note } when the
|
|
1528
|
+
* page cannot draw it. A value that is not of the type becomes undefined (not drawn) and is named in the notes.
|
|
1529
|
+
*/
|
|
1530
|
+
function readSeries(s, type) {
|
|
1531
|
+
const what = t('series.what', { source: s.source });
|
|
1532
|
+
if (!Object.prototype.hasOwnProperty.call(KNOWN.encoding, s.source)) {
|
|
1533
|
+
return { note: t('series.unknownSource', { what, source: s.source }) };
|
|
1534
|
+
}
|
|
1535
|
+
if (s.encoding !== KNOWN.encoding[s.source]) {
|
|
1536
|
+
return { note: t('series.unknownEncoding', { what, encoding: s.encoding }) };
|
|
1537
|
+
}
|
|
1538
|
+
if (!Array.isArray(s.points)) return { note: t('series.noPoints', { what }) };
|
|
1539
|
+
let ti = 0;
|
|
1540
|
+
let vi = 1;
|
|
1541
|
+
let bi = -1;
|
|
1542
|
+
if (Array.isArray(s.columns)) {
|
|
1543
|
+
ti = s.columns.indexOf('at_ms');
|
|
1544
|
+
vi = s.columns.indexOf('value');
|
|
1545
|
+
bi = s.columns.indexOf('base');
|
|
1546
|
+
if (ti < 0 || vi < 0) {
|
|
1547
|
+
return { note: t('series.noColumns', { what }) };
|
|
1548
|
+
}
|
|
1549
|
+
}
|
|
1550
|
+
const times = [];
|
|
1551
|
+
const v = [];
|
|
1552
|
+
const base = bi >= 0 ? [] : null;
|
|
1553
|
+
const wrong = [];
|
|
1554
|
+
let rounded = 0;
|
|
1555
|
+
for (const p of s.points) {
|
|
1556
|
+
if (!Array.isArray(p) || !isNum(p[ti])) {
|
|
1557
|
+
return { note: t('series.badPoint', { what }) };
|
|
1558
|
+
}
|
|
1559
|
+
times.push(p[ti]);
|
|
1560
|
+
const value = p[vi] === undefined ? null : p[vi];
|
|
1561
|
+
if (!fitsType(value, type)) {
|
|
1562
|
+
wrong.push([p[ti], value]);
|
|
1563
|
+
v.push(undefined);
|
|
1564
|
+
} else {
|
|
1565
|
+
if (type === 'integer' && value !== null && !Number.isSafeInteger(value)) rounded++;
|
|
1566
|
+
v.push(value);
|
|
1567
|
+
}
|
|
1568
|
+
if (base) base.push(p[bi] === undefined ? null : p[bi]);
|
|
1569
|
+
}
|
|
1570
|
+
const notes = [];
|
|
1571
|
+
if (wrong.length) {
|
|
1572
|
+
const [at, value] = wrong[0];
|
|
1573
|
+
notes.push(
|
|
1574
|
+
t('series.wrongType', {
|
|
1575
|
+
count: wrong.length,
|
|
1576
|
+
what,
|
|
1577
|
+
words: t(`type.${type}`),
|
|
1578
|
+
type,
|
|
1579
|
+
value: JSON.stringify(value),
|
|
1580
|
+
at: fmtMs(at),
|
|
1581
|
+
}),
|
|
1582
|
+
);
|
|
1583
|
+
}
|
|
1584
|
+
if (rounded) {
|
|
1585
|
+
notes.push(t('series.rounded', { count: rounded, what, max: Number.MAX_SAFE_INTEGER }));
|
|
1586
|
+
}
|
|
1587
|
+
return {
|
|
1588
|
+
notes,
|
|
1589
|
+
series: {
|
|
1590
|
+
source: s.source,
|
|
1591
|
+
t: times,
|
|
1592
|
+
v,
|
|
1593
|
+
base,
|
|
1594
|
+
/** For points of the failed step's writes: point index -> applied (true, false, or null: not known). */
|
|
1595
|
+
applied: null,
|
|
1596
|
+
notAppliedFrom: Number.isInteger(s.not_applied_from) ? s.not_applied_from : null,
|
|
1597
|
+
/** written: a dither writes it too (its points have the column base). */
|
|
1598
|
+
dithered: bi >= 0,
|
|
1599
|
+
/** written: whether the file says the point before not_applied_from is in the ECU (see appliedBefore). */
|
|
1600
|
+
beforeApplied: false,
|
|
1601
|
+
firstMs: isNum(s.first_ms) ? s.first_ms : null,
|
|
1602
|
+
lastMs: isNum(s.last_ms) ? s.last_ms : null,
|
|
1603
|
+
samples: Number.isInteger(s.samples) ? s.samples : null,
|
|
1604
|
+
},
|
|
1605
|
+
};
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
function participantOf(name) {
|
|
1609
|
+
const dot = name.indexOf('.');
|
|
1610
|
+
return dot > 0 ? name.slice(0, dot) : name;
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1613
|
+
/** The intervals in which a series lost points at the limits: { from, before, dropped } or null. */
|
|
1614
|
+
function gapOf(limits, variable, source) {
|
|
1615
|
+
if (!isObject(limits) || !Array.isArray(limits.dropped)) return null;
|
|
1616
|
+
const d = limits.dropped.find(
|
|
1617
|
+
(x) => isObject(x) && x.variable === variable && x.source === source,
|
|
1618
|
+
);
|
|
1619
|
+
if (!d || !isNum(d.dropped_from_ms) || !isNum(d.dropped_before_ms)) return null;
|
|
1620
|
+
return { from: d.dropped_from_ms, before: d.dropped_before_ms, dropped: d.dropped };
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
/**
|
|
1624
|
+
* The bands that conditions put on a variable's lane. A band covers the samples the condition looks at:
|
|
1625
|
+
* at: the instant from_ms; always and during: from_ms to to_ms, but not past the failure of the step or the
|
|
1626
|
+
* end of the record (`recordedTo`), since no sample was looked at after them; once: from_ms to the time it held
|
|
1627
|
+
* (passed) or to the limit, with a thin line on to the limit. `until` is the end the scenario gave.
|
|
1628
|
+
*/
|
|
1629
|
+
function watchBands(step, variable, recordedTo) {
|
|
1630
|
+
const w = step.watch;
|
|
1631
|
+
if (!isObject(w) || !Array.isArray(w.conditions) || !isNum(w.from_ms))
|
|
1632
|
+
return { bands: [], notes: [] };
|
|
1633
|
+
const bands = [];
|
|
1634
|
+
const notes = [];
|
|
1635
|
+
const failedConditions =
|
|
1636
|
+
isObject(step.failed) && Array.isArray(step.failed.conditions)
|
|
1637
|
+
? step.failed.conditions.map((c) => c && c.condition)
|
|
1638
|
+
: [];
|
|
1639
|
+
w.conditions.forEach((c, index) => {
|
|
1640
|
+
if (!isObject(c) || c.variable !== variable) return;
|
|
1641
|
+
if (!knows(KNOWN.mode, w.mode)) {
|
|
1642
|
+
notes.push(t('band.unknownMode', { step: step.index, mode: w.mode }));
|
|
1643
|
+
return;
|
|
1644
|
+
}
|
|
1645
|
+
const compare = Array.isArray(c.compare) ? c.compare.filter(isObject) : [];
|
|
1646
|
+
const unknownOp = compare.find((x) => !knows(KNOWN.op, x.op));
|
|
1647
|
+
if (unknownOp) {
|
|
1648
|
+
notes.push(t('band.unknownOp', { step: step.index, op: unknownOp.op }));
|
|
1649
|
+
return;
|
|
1650
|
+
}
|
|
1651
|
+
const from = w.from_ms;
|
|
1652
|
+
let to = isNum(w.to_ms) ? w.to_ms : from;
|
|
1653
|
+
let limit = null;
|
|
1654
|
+
const until = to;
|
|
1655
|
+
if (w.mode === 'once') {
|
|
1656
|
+
limit = isNum(w.to_ms) ? w.to_ms : null;
|
|
1657
|
+
if (step.status === 'passed' && isNum(step.at_ms)) to = step.at_ms;
|
|
1658
|
+
else if (step.status === 'failed' && isObject(step.failed) && isNum(step.failed.at_ms))
|
|
1659
|
+
to = step.failed.at_ms;
|
|
1660
|
+
} else if (w.mode === 'during' || w.mode === 'always') {
|
|
1661
|
+
if (step.status === 'failed' && isObject(step.failed) && isNum(step.failed.at_ms))
|
|
1662
|
+
to = Math.min(to, step.failed.at_ms);
|
|
1663
|
+
if (isNum(recordedTo)) to = Math.min(to, recordedTo);
|
|
1664
|
+
}
|
|
1665
|
+
bands.push({
|
|
1666
|
+
step: step.index,
|
|
1667
|
+
condition: index,
|
|
1668
|
+
mode: w.mode,
|
|
1669
|
+
from,
|
|
1670
|
+
to: Math.max(to, from),
|
|
1671
|
+
until: Math.max(until, from),
|
|
1672
|
+
limit,
|
|
1673
|
+
compare,
|
|
1674
|
+
status: knows(KNOWN.stepStatus, step.status) ? step.status : 'unknown',
|
|
1675
|
+
failed: failedConditions.includes(index),
|
|
1676
|
+
});
|
|
1677
|
+
});
|
|
1678
|
+
return { bands, notes };
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
/** The failure to lead the eye to: the failed step and what failed, in numbers and names. */
|
|
1682
|
+
function failureOf(tl, byName) {
|
|
1683
|
+
const step = tl.steps.find((s) => s.status === 'failed');
|
|
1684
|
+
if (!step) return null;
|
|
1685
|
+
const f = isObject(step.failed) ? step.failed : null;
|
|
1686
|
+
const conditions = (f && Array.isArray(f.conditions) ? f.conditions : [])
|
|
1687
|
+
.filter(isObject)
|
|
1688
|
+
.map((c) => {
|
|
1689
|
+
const wc =
|
|
1690
|
+
isObject(step.watch) && Array.isArray(step.watch.conditions)
|
|
1691
|
+
? step.watch.conditions[c.condition]
|
|
1692
|
+
: null;
|
|
1693
|
+
const variable = isObject(wc) ? wc.variable : null;
|
|
1694
|
+
const info = byName.get(variable);
|
|
1695
|
+
return {
|
|
1696
|
+
variable,
|
|
1697
|
+
compare: isObject(wc) ? compareText(wc.compare, info && info.info) : null,
|
|
1698
|
+
value: c.value,
|
|
1699
|
+
valueText:
|
|
1700
|
+
c.value === null || c.value === undefined
|
|
1701
|
+
? null
|
|
1702
|
+
: fmtValue(c.value, info && info.info, true),
|
|
1703
|
+
sampleMs: isNum(c.sample_ms) ? c.sample_ms : null,
|
|
1704
|
+
mode: isObject(step.watch) ? step.watch.mode : null,
|
|
1705
|
+
};
|
|
1706
|
+
});
|
|
1707
|
+
const writes = (f && Array.isArray(f.writes) ? f.writes : []).map((w, i) => {
|
|
1708
|
+
if (!isObject(w)) return null;
|
|
1709
|
+
const info = byName.get(w.variable);
|
|
1710
|
+
const point = Number.isInteger(w.point) ? w.point : null;
|
|
1711
|
+
return {
|
|
1712
|
+
variable: w.variable,
|
|
1713
|
+
at: isNum(w.at_ms) ? w.at_ms : null,
|
|
1714
|
+
value: w.value,
|
|
1715
|
+
valueText:
|
|
1716
|
+
w.value === null || w.value === undefined
|
|
1717
|
+
? t('write.notComputed')
|
|
1718
|
+
: fmtValue(w.value, info && info.info, true),
|
|
1719
|
+
point,
|
|
1720
|
+
applied: w.applied === true ? true : w.applied === false ? false : null,
|
|
1721
|
+
// point null: nothing was sent, or the point went at the file's limits (then limits.dropped names the
|
|
1722
|
+
// variable's written series).
|
|
1723
|
+
pointDropped:
|
|
1724
|
+
point === null &&
|
|
1725
|
+
isObject(tl.limits) &&
|
|
1726
|
+
Array.isArray(tl.limits.dropped) &&
|
|
1727
|
+
tl.limits.dropped.some(
|
|
1728
|
+
(d) => isObject(d) && d.variable === w.variable && d.source === 'written',
|
|
1729
|
+
),
|
|
1730
|
+
cause: f.write === i,
|
|
1731
|
+
};
|
|
1732
|
+
});
|
|
1733
|
+
const known = writes.filter(Boolean);
|
|
1734
|
+
const at = f && isNum(f.at_ms) ? f.at_ms : isNum(step.at_ms) ? step.at_ms : null;
|
|
1735
|
+
return {
|
|
1736
|
+
step,
|
|
1737
|
+
at,
|
|
1738
|
+
code: (f && f.code) || step.code || null,
|
|
1739
|
+
message: typeof step.message === 'string' ? step.message : null,
|
|
1740
|
+
conditions,
|
|
1741
|
+
writes: known,
|
|
1742
|
+
};
|
|
1743
|
+
}
|
|
1744
|
+
|
|
1745
|
+
/**
|
|
1746
|
+
* Whether the file says that the point before not_applied_from of v's written series is in the ECU, so that the
|
|
1747
|
+
* ECU kept that value after the writes it did not apply. In a run that did not pass, a point before
|
|
1748
|
+
* not_applied_from may not have been applied (the run ended before its result was looked at), so only these say
|
|
1749
|
+
* so: the point is a write of the failed step with applied true; the run passed; or every line of the variable
|
|
1750
|
+
* that the point can be of is of a step that passed (a step passes only when its writes were applied), and no
|
|
1751
|
+
* dither writes the variable (a dither's write is no step's).
|
|
1752
|
+
*/
|
|
1753
|
+
function appliedBefore(v, tl) {
|
|
1754
|
+
const series = v.written;
|
|
1755
|
+
const naf = series.notAppliedFrom;
|
|
1756
|
+
if (naf === null || naf < 1 || naf > series.t.length) return false;
|
|
1757
|
+
const i = naf - 1;
|
|
1758
|
+
if (series.applied && series.applied.get(i) === true) return true;
|
|
1759
|
+
if (tl.scenario.status === 'passed') return true;
|
|
1760
|
+
if (series.dithered || v.lines.some((l) => l.kind === 'dither')) return false;
|
|
1761
|
+
const t = series.t[i];
|
|
1762
|
+
const of = v.lines.filter(
|
|
1763
|
+
(l) =>
|
|
1764
|
+
isNum(l.from_ms) &&
|
|
1765
|
+
l.from_ms <= t &&
|
|
1766
|
+
(l.to_ms === null || (isNum(l.to_ms) && t <= l.to_ms)),
|
|
1767
|
+
);
|
|
1768
|
+
return (
|
|
1769
|
+
of.length > 0 &&
|
|
1770
|
+
of.every((l) => {
|
|
1771
|
+
const step = tl.steps.find((s) => isObject(s) && s.index === l.step);
|
|
1772
|
+
return step !== undefined && step.status === 'passed';
|
|
1773
|
+
})
|
|
1774
|
+
);
|
|
1775
|
+
}
|
|
1776
|
+
|
|
1777
|
+
/** Builds everything the page draws from a file that readTimeline() accepted. */
|
|
1778
|
+
function buildModel(tl) {
|
|
1779
|
+
const sc = tl.scenario;
|
|
1780
|
+
const recordedTo = isNum(sc.recorded_to_ms) ? sc.recorded_to_ms : null;
|
|
1781
|
+
const timeStep = isNum(tl.time_step_ms) && tl.time_step_ms > 0 ? tl.time_step_ms : null;
|
|
1782
|
+
const vars = [];
|
|
1783
|
+
const byName = new Map();
|
|
1784
|
+
const addVar = (info) => {
|
|
1785
|
+
const v = {
|
|
1786
|
+
name: info.name,
|
|
1787
|
+
participant:
|
|
1788
|
+
typeof info.participant === 'string' ? info.participant : participantOf(info.name),
|
|
1789
|
+
info,
|
|
1790
|
+
written: null,
|
|
1791
|
+
sampled: null,
|
|
1792
|
+
notes: [],
|
|
1793
|
+
bands: [],
|
|
1794
|
+
lines: [],
|
|
1795
|
+
marks: [],
|
|
1796
|
+
gaps: {},
|
|
1797
|
+
failing: false,
|
|
1798
|
+
};
|
|
1799
|
+
vars.push(v);
|
|
1800
|
+
byName.set(v.name, v);
|
|
1801
|
+
return v;
|
|
1802
|
+
};
|
|
1803
|
+
tl.variables.forEach(addVar);
|
|
1804
|
+
const varOf = (name) =>
|
|
1805
|
+
byName.get(name) || addVar({ name, type: 'unknown', written: false, watched: false });
|
|
1806
|
+
|
|
1807
|
+
for (const s of tl.series) {
|
|
1808
|
+
if (typeof s.variable !== 'string') continue;
|
|
1809
|
+
const v = varOf(s.variable);
|
|
1810
|
+
const read = readSeries(s, v.info.type);
|
|
1811
|
+
if (read.note) {
|
|
1812
|
+
v.notes.push(read.note);
|
|
1813
|
+
continue;
|
|
1814
|
+
}
|
|
1815
|
+
if (read.series.source === 'written' && !v.written) v.written = read.series;
|
|
1816
|
+
else if (read.series.source === 'sampled' && !v.sampled) v.sampled = read.series;
|
|
1817
|
+
else continue;
|
|
1818
|
+
v.notes.push(...read.notes);
|
|
1819
|
+
const gap = gapOf(tl.limits, s.variable, s.source);
|
|
1820
|
+
if (gap) v.gaps[s.source] = gap;
|
|
1821
|
+
}
|
|
1822
|
+
for (const v of vars) {
|
|
1823
|
+
if (!knows(KNOWN.type, v.info.type) && (v.written || v.sampled)) {
|
|
1824
|
+
v.notes.push(t('variable.unknownType', { type: v.info.type }));
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
const lines = (Array.isArray(tl.lines) ? tl.lines : [])
|
|
1829
|
+
.map((line, index) => (isObject(line) ? { ...line, index } : null))
|
|
1830
|
+
.filter(Boolean);
|
|
1831
|
+
for (const line of lines)
|
|
1832
|
+
if (typeof line.variable === 'string') varOf(line.variable).lines.push(line);
|
|
1833
|
+
// A dither lasts until the next dither line of the same variable.
|
|
1834
|
+
for (const v of vars) {
|
|
1835
|
+
const dithers = v.lines.filter((l) => l.kind === 'dither');
|
|
1836
|
+
dithers.forEach((l, i) => {
|
|
1837
|
+
l.until = i + 1 < dithers.length ? dithers[i + 1].from_ms : null;
|
|
1838
|
+
});
|
|
1839
|
+
}
|
|
1840
|
+
|
|
1841
|
+
for (const step of tl.steps) {
|
|
1842
|
+
if (!isObject(step.watch) || !Array.isArray(step.watch.conditions)) continue;
|
|
1843
|
+
const names = new Set(step.watch.conditions.filter(isObject).map((c) => c.variable));
|
|
1844
|
+
for (const name of names) {
|
|
1845
|
+
if (typeof name !== 'string') continue;
|
|
1846
|
+
const v = varOf(name);
|
|
1847
|
+
const { bands, notes } = watchBands(step, name, recordedTo);
|
|
1848
|
+
v.bands.push(...bands);
|
|
1849
|
+
v.notes.push(...notes);
|
|
1850
|
+
}
|
|
1851
|
+
}
|
|
1852
|
+
|
|
1853
|
+
const failure = failureOf(tl, byName);
|
|
1854
|
+
if (failure) {
|
|
1855
|
+
for (const c of failure.conditions) {
|
|
1856
|
+
if (typeof c.variable !== 'string') continue;
|
|
1857
|
+
const v = varOf(c.variable);
|
|
1858
|
+
v.failing = true;
|
|
1859
|
+
v.marks.push({
|
|
1860
|
+
kind: 'condition',
|
|
1861
|
+
at: c.sampleMs ?? failure.at,
|
|
1862
|
+
value: c.value,
|
|
1863
|
+
text: c.valueText,
|
|
1864
|
+
});
|
|
1865
|
+
}
|
|
1866
|
+
for (const w of failure.writes) {
|
|
1867
|
+
if (typeof w.variable !== 'string') continue;
|
|
1868
|
+
const v = varOf(w.variable);
|
|
1869
|
+
if (w.cause || w.applied !== true) v.failing = true;
|
|
1870
|
+
if (v.written && w.point !== null) {
|
|
1871
|
+
if (!v.written.applied) v.written.applied = new Map();
|
|
1872
|
+
v.written.applied.set(w.point, w.applied);
|
|
1873
|
+
}
|
|
1874
|
+
v.marks.push({
|
|
1875
|
+
kind: 'write',
|
|
1876
|
+
at: w.at ?? failure.at,
|
|
1877
|
+
value: w.value,
|
|
1878
|
+
applied: w.applied,
|
|
1879
|
+
sent: w.point !== null || w.pointDropped,
|
|
1880
|
+
cause: w.cause,
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
for (const v of vars) if (v.written) v.written.beforeApplied = appliedBefore(v, tl);
|
|
1886
|
+
|
|
1887
|
+
// The time range of the whole run: the record, and the steps and lines that the run decided.
|
|
1888
|
+
let end = recordedTo ?? 0;
|
|
1889
|
+
for (const step of tl.steps) {
|
|
1890
|
+
if (step.status === 'not_run') continue;
|
|
1891
|
+
for (const t of [step.start_ms, step.at_ms, step.end_ms])
|
|
1892
|
+
if (isNum(t)) end = Math.max(end, t);
|
|
1893
|
+
}
|
|
1894
|
+
for (const l of lines)
|
|
1895
|
+
for (const t of [l.from_ms, l.to_ms]) if (isNum(t)) end = Math.max(end, t);
|
|
1896
|
+
for (const v of vars) {
|
|
1897
|
+
for (const s of [v.written, v.sampled])
|
|
1898
|
+
if (s && s.t.length) end = Math.max(end, s.t[s.t.length - 1]);
|
|
1899
|
+
}
|
|
1900
|
+
const margin = Math.max(timeStep ?? 0, end * 0.04, end > 0 ? 0 : 10);
|
|
1901
|
+
const domain = [0, end + margin];
|
|
1902
|
+
|
|
1903
|
+
const inputs = vars.filter((v) => v.info.written === true || (v.written && !v.info.watched));
|
|
1904
|
+
const others = vars.filter((v) => !inputs.includes(v));
|
|
1905
|
+
const findings = Array.isArray(tl.findings) ? tl.findings.filter(isObject) : [];
|
|
1906
|
+
const dropped =
|
|
1907
|
+
isObject(tl.limits) && Array.isArray(tl.limits.dropped)
|
|
1908
|
+
? tl.limits.dropped.filter(isObject)
|
|
1909
|
+
: [];
|
|
1910
|
+
return {
|
|
1911
|
+
tl,
|
|
1912
|
+
name: typeof sc.name === 'string' && sc.name !== '' ? sc.name : null,
|
|
1913
|
+
status: sc.status,
|
|
1914
|
+
recordedTo,
|
|
1915
|
+
overAt: isNum(sc.over_at_ms) ? sc.over_at_ms : null,
|
|
1916
|
+
timeStep,
|
|
1917
|
+
steps: tl.steps,
|
|
1918
|
+
lines,
|
|
1919
|
+
vars,
|
|
1920
|
+
byName,
|
|
1921
|
+
inputs,
|
|
1922
|
+
others,
|
|
1923
|
+
failure,
|
|
1924
|
+
findings,
|
|
1925
|
+
dropped,
|
|
1926
|
+
late: findings.some((f) => f.code === 'control-link-late-values'),
|
|
1927
|
+
domain,
|
|
1928
|
+
};
|
|
1929
|
+
}
|
|
1930
|
+
|
|
1931
|
+
// ---------------------------------------------------------------------------------------------------------------
|
|
1932
|
+
// Layout: time to position, rows of the step lane, the segments of a held series, thinning out
|
|
1933
|
+
|
|
1934
|
+
/** Maps virtual time [t0, t1] to x in [0, width]. */
|
|
1935
|
+
function makeScale(t0, t1, width) {
|
|
1936
|
+
const k = width / (t1 - t0 || 1);
|
|
1937
|
+
return { t0, t1, width, x: (t) => (t - t0) * k, t: (x) => t0 + x / k };
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
/** The view when the page opens: the failure (a little before the failed step to the end of the record), or all. */
|
|
1941
|
+
function initialView(model) {
|
|
1942
|
+
const [d0, d1] = model.domain;
|
|
1943
|
+
const f = model.failure;
|
|
1944
|
+
if (!f || !isNum(f.at)) return [d0, d1];
|
|
1945
|
+
const start = isNum(f.step.start_ms) ? Math.min(f.step.start_ms, f.at) : f.at;
|
|
1946
|
+
const right = Math.max(f.at, model.recordedTo ?? f.at);
|
|
1947
|
+
const span = Math.max(right - start, (d1 - d0) * 0.2, (model.timeStep ?? 1) * 4);
|
|
1948
|
+
const t0 = Math.max(d0, start - span * 0.3);
|
|
1949
|
+
const t1 = Math.min(d1, right + span * 0.15);
|
|
1950
|
+
return [t0, Math.max(t1, t0 + 1e-9)];
|
|
1951
|
+
}
|
|
1952
|
+
|
|
1953
|
+
/** Round tick values for an axis, about `count` of them. */
|
|
1954
|
+
function niceTicks(t0, t1, count) {
|
|
1955
|
+
const span = t1 - t0;
|
|
1956
|
+
if (!(span > 0)) return [t0];
|
|
1957
|
+
const raw = span / Math.max(1, count);
|
|
1958
|
+
const mag = Math.pow(10, Math.floor(Math.log10(raw)));
|
|
1959
|
+
const step = [1, 2, 5, 10].map((m) => m * mag).find((s) => s >= raw) ?? 10 * mag;
|
|
1960
|
+
const out = [];
|
|
1961
|
+
for (let t = Math.ceil(t0 / step) * step; t <= t1 + step * 1e-9; t += step)
|
|
1962
|
+
out.push(Number(t.toPrecision(12)));
|
|
1963
|
+
return out;
|
|
1964
|
+
}
|
|
1965
|
+
|
|
1966
|
+
/**
|
|
1967
|
+
* Puts intervals (in pixels: { x0, x1 }) on rows so that none overlap: the first row with room, in order.
|
|
1968
|
+
* Returns { rows: [row index per item], count }.
|
|
1969
|
+
*/
|
|
1970
|
+
function packRows(items, gap) {
|
|
1971
|
+
const ends = [];
|
|
1972
|
+
const rows = items.map((it) => {
|
|
1973
|
+
let r = ends.findIndex((e) => e + gap <= it.x0);
|
|
1974
|
+
if (r < 0) {
|
|
1975
|
+
r = ends.length;
|
|
1976
|
+
ends.push(-Infinity);
|
|
1977
|
+
}
|
|
1978
|
+
ends[r] = it.x1;
|
|
1979
|
+
return r;
|
|
1980
|
+
});
|
|
1981
|
+
return { rows, count: Math.max(1, ends.length) };
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
/** Whether a state is of a point that was sent and is not known to be in the ECU. */
|
|
1985
|
+
const unapplied = (state) => state === 'not-applied' || state === 'not-known';
|
|
1986
|
+
|
|
1987
|
+
/**
|
|
1988
|
+
* What is known of point i of a series. sampled: 'seen'. written: 'sent' before not_applied_from; from it on
|
|
1989
|
+
* 'not-applied' where the failed step's writes say the ECU did not apply it (applied false), and 'not-known'
|
|
1990
|
+
* otherwise (applied null, or a point sent after them: the schema says these are not known to have been applied).
|
|
1991
|
+
*/
|
|
1992
|
+
function pointState(series, i) {
|
|
1993
|
+
if (series.source === 'sampled') return 'seen';
|
|
1994
|
+
const naf = series.notAppliedFrom;
|
|
1995
|
+
if (naf === null || i < naf) return 'sent';
|
|
1996
|
+
const applied = series.applied ? series.applied.get(i) : undefined;
|
|
1997
|
+
return applied === false ? 'not-applied' : applied === true ? 'sent' : 'not-known';
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
/**
|
|
2001
|
+
* The value the ECU kept from the first point of not_applied_from on, while it is known: up to the first point
|
|
2002
|
+
* that is not 'not-applied'. Returns { from, to, v } or null (no such point, not known from the start, or the
|
|
2003
|
+
* file does not say that the value before was applied: beforeApplied).
|
|
2004
|
+
*/
|
|
2005
|
+
function keptValue(series, end) {
|
|
2006
|
+
const naf = series.notAppliedFrom;
|
|
2007
|
+
const n = series.t.length;
|
|
2008
|
+
if (
|
|
2009
|
+
naf === null ||
|
|
2010
|
+
naf < 1 ||
|
|
2011
|
+
naf >= n ||
|
|
2012
|
+
series.beforeApplied !== true ||
|
|
2013
|
+
pointState(series, naf) !== 'not-applied'
|
|
2014
|
+
)
|
|
2015
|
+
return null;
|
|
2016
|
+
let to = Math.max(end ?? series.t[n - 1], series.t[n - 1]);
|
|
2017
|
+
for (let i = naf + 1; i < n; i++) {
|
|
2018
|
+
if (pointState(series, i) !== 'not-applied') {
|
|
2019
|
+
to = series.t[i];
|
|
2020
|
+
break;
|
|
2021
|
+
}
|
|
2022
|
+
}
|
|
2023
|
+
return { from: series.t[naf], to, v: series.v[naf - 1] };
|
|
2024
|
+
}
|
|
2025
|
+
|
|
2026
|
+
/**
|
|
2027
|
+
* The segments of a series held from each point to the next: { from, to, v, base, state }.
|
|
2028
|
+
* state: 'sent' (or 'seen'); 'not-applied' and 'not-known' (from not_applied_from on, see pointState); 'held'
|
|
2029
|
+
* (the value that stayed in the ECU after a write it did not apply, while that is known and where the file says
|
|
2030
|
+
* it was applied: keptValue); 'alone' (a point
|
|
2031
|
+
* inside an interval whose points were dropped: not held). `end` is where the last point stops (the end of the
|
|
2032
|
+
* record, or last_ms of a sampled series). v is undefined for a value that is not of the variable's type.
|
|
2033
|
+
*/
|
|
2034
|
+
function holdSegments(series, end, gap) {
|
|
2035
|
+
const segs = [];
|
|
2036
|
+
const n = series.t.length;
|
|
2037
|
+
const naf = series.notAppliedFrom;
|
|
2038
|
+
for (let i = 0; i < n; i++) {
|
|
2039
|
+
const from = series.t[i];
|
|
2040
|
+
let to = i + 1 < n ? series.t[i + 1] : Math.max(end ?? from, from);
|
|
2041
|
+
let state = pointState(series, i);
|
|
2042
|
+
if (gap) {
|
|
2043
|
+
if (from >= gap.from && from < gap.before) {
|
|
2044
|
+
to = from;
|
|
2045
|
+
if (!unapplied(state)) state = 'alone';
|
|
2046
|
+
} else if (from < gap.from && to > gap.from) {
|
|
2047
|
+
to = gap.from;
|
|
2048
|
+
}
|
|
2049
|
+
}
|
|
2050
|
+
if (naf !== null && i === naf - 1) to = Math.min(to, series.t[naf]);
|
|
2051
|
+
segs.push({
|
|
2052
|
+
from,
|
|
2053
|
+
to,
|
|
2054
|
+
v: series.v[i],
|
|
2055
|
+
base: series.base ? series.base[i] : undefined,
|
|
2056
|
+
state,
|
|
2057
|
+
});
|
|
2058
|
+
}
|
|
2059
|
+
const kept = series.source === 'sampled' ? null : keptValue(series, end);
|
|
2060
|
+
if (kept) segs.push({ ...kept, base: undefined, state: 'held' });
|
|
2061
|
+
return segs;
|
|
2062
|
+
}
|
|
2063
|
+
|
|
2064
|
+
/**
|
|
2065
|
+
* Where each segment of a bool or enum band goes, in the order drawn: { seg, y, height }. The value kept in the
|
|
2066
|
+
* ECU ('held') is a strip under the row, drawn first, so that it never covers a write that was not applied or
|
|
2067
|
+
* whose result is not known (the row above it is shorter by the strip).
|
|
2068
|
+
*/
|
|
2069
|
+
function stateBandLayout(segs, y0, height) {
|
|
2070
|
+
const strip = 5;
|
|
2071
|
+
const held = segs.filter((seg) => seg.state === 'held');
|
|
2072
|
+
const rowHeight = held.length ? height - strip - 1 : height;
|
|
2073
|
+
return [
|
|
2074
|
+
...held.map((seg) => ({ seg, y: y0 + height - strip, height: strip })),
|
|
2075
|
+
...segs
|
|
2076
|
+
.filter((seg) => seg.state !== 'held')
|
|
2077
|
+
.map((seg) => ({ seg, y: y0, height: rowHeight })),
|
|
2078
|
+
];
|
|
2079
|
+
}
|
|
2080
|
+
|
|
2081
|
+
/**
|
|
2082
|
+
* Thins out the segments in view [t0, t1] to about 2 per pixel column: segments that start in the same column
|
|
2083
|
+
* become one with the column's min and max (drawn as a vertical stroke) and its last value. Segments of
|
|
2084
|
+
* another state or with a value that is not a number are kept as they are.
|
|
2085
|
+
*/
|
|
2086
|
+
function decimate(segs, scale) {
|
|
2087
|
+
const visible = segs.filter((s) => s.to >= scale.t0 && s.from <= scale.t1);
|
|
2088
|
+
if (visible.length <= 2 * Math.max(1, scale.width)) {
|
|
2089
|
+
return visible.map((s) => ({ ...s, min: s.v, max: s.v }));
|
|
2090
|
+
}
|
|
2091
|
+
const out = [];
|
|
2092
|
+
let cur = null;
|
|
2093
|
+
let col = null;
|
|
2094
|
+
for (const s of visible) {
|
|
2095
|
+
const c = Math.floor(scale.x(s.from));
|
|
2096
|
+
const numeric = isNum(s.v);
|
|
2097
|
+
if (cur && numeric && c === col && s.state === cur.state && isNum(cur.v)) {
|
|
2098
|
+
cur.to = s.to;
|
|
2099
|
+
cur.min = Math.min(cur.min, s.v);
|
|
2100
|
+
cur.max = Math.max(cur.max, s.v);
|
|
2101
|
+
cur.v = s.v;
|
|
2102
|
+
cur.base = s.base;
|
|
2103
|
+
continue;
|
|
2104
|
+
}
|
|
2105
|
+
cur = { ...s, min: s.v, max: s.v };
|
|
2106
|
+
col = c;
|
|
2107
|
+
out.push(cur);
|
|
2108
|
+
}
|
|
2109
|
+
return out;
|
|
2110
|
+
}
|
|
2111
|
+
|
|
2112
|
+
/**
|
|
2113
|
+
* The value of a series at time t, or null where it has none:
|
|
2114
|
+
* { value } a value sent or seen (undefined: not of the variable's type);
|
|
2115
|
+
* { missing: true } inside the interval `gap` whose points were dropped at the limits;
|
|
2116
|
+
* { value, state: 'not-applied', kept } sent, and the ECU did not apply it. kept: { value } that the ECU
|
|
2117
|
+
* has (value undefined: from before the record); { lastSent }: the
|
|
2118
|
+
* value sent before, which the file does not say was applied; or
|
|
2119
|
+
* null: not known;
|
|
2120
|
+
* { value, state: 'not-known' } sent, and whether the ECU applied it is not known.
|
|
2121
|
+
*/
|
|
2122
|
+
function valueAt(series, t, end, gap) {
|
|
2123
|
+
if (!series || !series.t.length || t < series.t[0]) return null;
|
|
2124
|
+
let lo = 0;
|
|
2125
|
+
let hi = series.t.length - 1;
|
|
2126
|
+
while (lo < hi) {
|
|
2127
|
+
const mid = (lo + hi + 1) >> 1;
|
|
2128
|
+
if (series.t[mid] <= t) lo = mid;
|
|
2129
|
+
else hi = mid - 1;
|
|
2130
|
+
}
|
|
2131
|
+
// Where the drawing stops: a sampled value at last_ms; a sent one at the end, or at its last point after it.
|
|
2132
|
+
const last = series.t[series.t.length - 1];
|
|
2133
|
+
const limit =
|
|
2134
|
+
series.source === 'sampled' ? (series.lastMs ?? end) : isNum(end) ? Math.max(end, last) : end;
|
|
2135
|
+
if (isNum(limit) && t > limit) return null;
|
|
2136
|
+
if (gap && t >= gap.from && t < gap.before && series.t[lo] !== t) return { missing: true };
|
|
2137
|
+
const state = pointState(series, lo);
|
|
2138
|
+
if (state === 'not-known') return { value: series.v[lo], state };
|
|
2139
|
+
if (state === 'not-applied') {
|
|
2140
|
+
// The ECU has the value before not_applied_from only while every point since was not applied.
|
|
2141
|
+
const naf = series.notAppliedFrom;
|
|
2142
|
+
let known = true;
|
|
2143
|
+
for (let i = naf; i <= lo && known; i++) known = pointState(series, i) === 'not-applied';
|
|
2144
|
+
let kept = null;
|
|
2145
|
+
if (known && naf === 0) kept = { value: undefined };
|
|
2146
|
+
else if (known && series.beforeApplied === true) kept = { value: series.v[naf - 1] };
|
|
2147
|
+
else if (known) kept = { lastSent: series.v[naf - 1] };
|
|
2148
|
+
return { value: series.v[lo], state, kept };
|
|
2149
|
+
}
|
|
2150
|
+
return { value: series.v[lo] };
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2153
|
+
/** The words of the cursor's read-out for one series ('sent' or 'seen') at a time: see valueAt(). */
|
|
2154
|
+
function readoutText(source, at, info) {
|
|
2155
|
+
const word = t(`word.${source}`);
|
|
2156
|
+
if (at.missing) return t('readout.missing', { word });
|
|
2157
|
+
if (at.value === undefined) return t('readout.wrongType', { word });
|
|
2158
|
+
const value = t('readout.value', { word, value: fmtValue(at.value, info) });
|
|
2159
|
+
if (at.state === 'not-known') return t('readout.notKnown', { value });
|
|
2160
|
+
if (at.state !== 'not-applied') return value;
|
|
2161
|
+
if (at.kept !== null && 'lastSent' in at.kept)
|
|
2162
|
+
return t('readout.notAppliedLastSent', { value, last: fmtValue(at.kept.lastSent, info) });
|
|
2163
|
+
const has =
|
|
2164
|
+
at.kept === null
|
|
2165
|
+
? t('readout.hasUnknown')
|
|
2166
|
+
: at.kept.value === undefined
|
|
2167
|
+
? t('readout.hasEarlier')
|
|
2168
|
+
: fmtValue(at.kept.value, info);
|
|
2169
|
+
return t('readout.notApplied', { value, has });
|
|
2170
|
+
}
|
|
2171
|
+
|
|
2172
|
+
/**
|
|
2173
|
+
* The words of the table of a failed step's writes, from what the file says of each write: applied, point (null:
|
|
2174
|
+
* not sent, or its point was dropped at the limits) and whether it is the cause. Returns { heading, explain,
|
|
2175
|
+
* cause(write) }.
|
|
2176
|
+
*/
|
|
2177
|
+
function writeWords(f) {
|
|
2178
|
+
const at = f.writes.length && f.writes[0].at !== null ? f.writes[0].at : f.at;
|
|
2179
|
+
const has = (applied) => f.writes.some((w) => w.applied === applied);
|
|
2180
|
+
const explain = [
|
|
2181
|
+
has(true) ? t('writes.explainApplied') : null,
|
|
2182
|
+
has(false) ? t('writes.explainNotApplied') : null,
|
|
2183
|
+
has(null) ? t('writes.explainNotKnown') : null,
|
|
2184
|
+
]
|
|
2185
|
+
.filter(Boolean)
|
|
2186
|
+
.join(' ');
|
|
2187
|
+
const cause = (w) => {
|
|
2188
|
+
if (w.point === null && w.pointDropped) {
|
|
2189
|
+
const dropped = t('writes.pointDropped');
|
|
2190
|
+
return w.cause ? t('writes.causeAnd', { what: dropped }) : dropped;
|
|
2191
|
+
}
|
|
2192
|
+
if (w.point === null && w.applied === false)
|
|
2193
|
+
return w.cause ? t('writes.notSentCause') : t('writes.notSent');
|
|
2194
|
+
return w.cause ? t('writes.cause') : '';
|
|
2195
|
+
};
|
|
2196
|
+
return { heading: t('writes.heading', { at: fmtMs(at) }), explain, cause };
|
|
2197
|
+
}
|
|
2198
|
+
|
|
2199
|
+
/** The value range of a numeric lane: the declared min and max, or (fit) the values with some room. */
|
|
2200
|
+
function laneRange(v, fit) {
|
|
2201
|
+
const info = v.info;
|
|
2202
|
+
if (!fit && isNum(info.min) && isNum(info.max) && info.max > info.min)
|
|
2203
|
+
return [info.min, info.max];
|
|
2204
|
+
let lo = Infinity;
|
|
2205
|
+
let hi = -Infinity;
|
|
2206
|
+
const take = (x) => {
|
|
2207
|
+
if (isNum(x)) {
|
|
2208
|
+
lo = Math.min(lo, x);
|
|
2209
|
+
hi = Math.max(hi, x);
|
|
2210
|
+
}
|
|
2211
|
+
};
|
|
2212
|
+
for (const s of [v.written, v.sampled]) {
|
|
2213
|
+
if (!s) continue;
|
|
2214
|
+
s.v.forEach(take);
|
|
2215
|
+
if (s.base) s.base.forEach(take);
|
|
2216
|
+
}
|
|
2217
|
+
for (const b of v.bands) {
|
|
2218
|
+
for (const c of b.compare) {
|
|
2219
|
+
take(c.value);
|
|
2220
|
+
if (c.op === 'near' && isNum(c.tolerance)) {
|
|
2221
|
+
take(c.value - c.tolerance);
|
|
2222
|
+
take(c.value + c.tolerance);
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
}
|
|
2226
|
+
for (const m of v.marks) take(m.value);
|
|
2227
|
+
if (lo === Infinity) return [0, 1];
|
|
2228
|
+
if (lo === hi) {
|
|
2229
|
+
const d = Math.abs(lo) * 0.1 || 1;
|
|
2230
|
+
return [lo - d, hi + d];
|
|
2231
|
+
}
|
|
2232
|
+
const pad = (hi - lo) * 0.08;
|
|
2233
|
+
return [lo - pad, hi + pad];
|
|
2234
|
+
}
|
|
2235
|
+
|
|
2236
|
+
/**
|
|
2237
|
+
* Whether a numeric lane starts scaled to its values: when the values use less than a fifth of the declared
|
|
2238
|
+
* range (min to max), a lane in the declared range would show a flat line. The lane's button switches.
|
|
2239
|
+
*/
|
|
2240
|
+
function defaultFit(v) {
|
|
2241
|
+
const info = v.info;
|
|
2242
|
+
if (!(isNum(info.min) && isNum(info.max) && info.max > info.min)) return true;
|
|
2243
|
+
const [lo, hi] = laneRange(v, true);
|
|
2244
|
+
return hi - lo < (info.max - info.min) / 5;
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2247
|
+
/** Joins neighbouring segments with the same value and state (a band shows each state once). */
|
|
2248
|
+
function mergeEqual(segs) {
|
|
2249
|
+
const out = [];
|
|
2250
|
+
for (const seg of segs) {
|
|
2251
|
+
const prev = out[out.length - 1];
|
|
2252
|
+
if (
|
|
2253
|
+
prev &&
|
|
2254
|
+
prev.state === seg.state &&
|
|
2255
|
+
prev.v === seg.v &&
|
|
2256
|
+
prev.to === seg.from &&
|
|
2257
|
+
seg.state !== 'alone'
|
|
2258
|
+
) {
|
|
2259
|
+
prev.to = seg.to;
|
|
2260
|
+
} else {
|
|
2261
|
+
out.push({ ...seg });
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2264
|
+
return out;
|
|
2265
|
+
}
|
|
2266
|
+
|
|
2267
|
+
/** How a lane draws its variable. */
|
|
2268
|
+
function laneKind(v) {
|
|
2269
|
+
if (v.info.type === 'bool') return 'bool';
|
|
2270
|
+
if (v.info.type === 'enum') return 'enum';
|
|
2271
|
+
return 'number';
|
|
2272
|
+
}
|
|
2273
|
+
|
|
2274
|
+
const api = {
|
|
2275
|
+
FORMAT,
|
|
2276
|
+
KNOWN,
|
|
2277
|
+
MESSAGES,
|
|
2278
|
+
LANGUAGES,
|
|
2279
|
+
pickLanguage,
|
|
2280
|
+
chooseLanguage,
|
|
2281
|
+
setLanguage,
|
|
2282
|
+
t,
|
|
2283
|
+
text,
|
|
2284
|
+
statusWord,
|
|
2285
|
+
readTimeline,
|
|
2286
|
+
buildModel,
|
|
2287
|
+
makeScale,
|
|
2288
|
+
initialView,
|
|
2289
|
+
niceTicks,
|
|
2290
|
+
packRows,
|
|
2291
|
+
pointState,
|
|
2292
|
+
holdSegments,
|
|
2293
|
+
stateBandLayout,
|
|
2294
|
+
decimate,
|
|
2295
|
+
valueAt,
|
|
2296
|
+
readoutText,
|
|
2297
|
+
writeWords,
|
|
2298
|
+
laneRange,
|
|
2299
|
+
defaultFit,
|
|
2300
|
+
mergeEqual,
|
|
2301
|
+
laneKind,
|
|
2302
|
+
fmtValue,
|
|
2303
|
+
fmtMs,
|
|
2304
|
+
compareText,
|
|
2305
|
+
};
|
|
2306
|
+
|
|
2307
|
+
global.VehicleSilTimeline = api;
|
|
2308
|
+
if (typeof document === 'undefined' || typeof customElements === 'undefined') return;
|
|
2309
|
+
|
|
2310
|
+
// ---------------------------------------------------------------------------------------------------------------
|
|
2311
|
+
// The element
|
|
2312
|
+
//
|
|
2313
|
+
// The drawing functions below work on the element being drawn: `current`, its `state` and its shadow `root`.
|
|
2314
|
+
// Every way into them (a property, an attribute, a listener, the answer of a fetch, the observer of the size)
|
|
2315
|
+
// first makes its element the current one with enter(), or is made with bound(), which does that.
|
|
2316
|
+
|
|
2317
|
+
const SVG = 'http://www.w3.org/2000/svg';
|
|
2318
|
+
const LANE_NUMBER_HEIGHT = 76;
|
|
2319
|
+
const COMPACT_NUMBER_HEIGHT = 44;
|
|
2320
|
+
const BAND_HEIGHT = 24;
|
|
2321
|
+
const STRIP_HEIGHT = 16;
|
|
2322
|
+
const STEP_ROW = 22;
|
|
2323
|
+
|
|
2324
|
+
/** An HTML element; children are elements or strings (set as text, never parsed). */
|
|
2325
|
+
function h(tag, attrs, ...children) {
|
|
2326
|
+
const e = document.createElement(tag);
|
|
2327
|
+
for (const [k, val] of Object.entries(attrs || {})) {
|
|
2328
|
+
if (val === null || val === undefined || val === false) continue;
|
|
2329
|
+
if (k === 'class') e.className = val;
|
|
2330
|
+
else if (k === 'text') e.textContent = val;
|
|
2331
|
+
else if (k.startsWith('on')) e.addEventListener(k.slice(2), bound(val));
|
|
2332
|
+
else e.setAttribute(k, val === true ? '' : String(val));
|
|
2333
|
+
}
|
|
2334
|
+
for (const c of children.flat()) {
|
|
2335
|
+
if (c === null || c === undefined || c === false) continue;
|
|
2336
|
+
e.append(typeof c === 'string' ? document.createTextNode(c) : c);
|
|
2337
|
+
}
|
|
2338
|
+
return e;
|
|
2339
|
+
}
|
|
2340
|
+
|
|
2341
|
+
/** An SVG element. */
|
|
2342
|
+
function s(tag, attrs, parent) {
|
|
2343
|
+
const e = document.createElementNS(SVG, tag);
|
|
2344
|
+
for (const [k, val] of Object.entries(attrs || {})) {
|
|
2345
|
+
if (val === null || val === undefined) continue;
|
|
2346
|
+
if (k === 'text') e.textContent = val;
|
|
2347
|
+
else e.setAttribute(k, String(val));
|
|
2348
|
+
}
|
|
2349
|
+
if (parent) parent.append(e);
|
|
2350
|
+
return e;
|
|
2351
|
+
}
|
|
2352
|
+
|
|
2353
|
+
function tooltip(el, text) {
|
|
2354
|
+
s('title', { text }, el);
|
|
2355
|
+
return el;
|
|
2356
|
+
}
|
|
2357
|
+
|
|
2358
|
+
/** What one element shows; the view, the cursor and the step are what its properties of the same names say. */
|
|
2359
|
+
function newState() {
|
|
2360
|
+
return {
|
|
2361
|
+
model: null,
|
|
2362
|
+
view: null,
|
|
2363
|
+
fit: new Set(),
|
|
2364
|
+
hidden: new Set(),
|
|
2365
|
+
cursor: null,
|
|
2366
|
+
/** The index of the chosen step, or null. */
|
|
2367
|
+
step: null,
|
|
2368
|
+
lanes: [],
|
|
2369
|
+
width: 0,
|
|
2370
|
+
/** The name of the file shown (null for data without a name, or none). */
|
|
2371
|
+
file: null,
|
|
2372
|
+
};
|
|
2373
|
+
}
|
|
2374
|
+
|
|
2375
|
+
/** The element being drawn ({ host, root, state, options }), its state and its shadow root. */
|
|
2376
|
+
let current = null;
|
|
2377
|
+
let state = null;
|
|
2378
|
+
let root = null;
|
|
2379
|
+
|
|
2380
|
+
/** Makes an element the one being drawn: its state, its root, its language and its texts. */
|
|
2381
|
+
function enter(element) {
|
|
2382
|
+
current = element;
|
|
2383
|
+
state = element.state;
|
|
2384
|
+
root = element.root;
|
|
2385
|
+
language = element.language;
|
|
2386
|
+
extra = element.options.messages;
|
|
2387
|
+
}
|
|
2388
|
+
|
|
2389
|
+
/** fn, made to draw on the element that is current now, whenever it is called. */
|
|
2390
|
+
function bound(fn) {
|
|
2391
|
+
const element = current;
|
|
2392
|
+
return function (...args) {
|
|
2393
|
+
enter(element);
|
|
2394
|
+
return fn.apply(this, args);
|
|
2395
|
+
};
|
|
2396
|
+
}
|
|
2397
|
+
|
|
2398
|
+
const $ = (id) => root.getElementById(id);
|
|
2399
|
+
|
|
2400
|
+
/** Tells the page around: an event on the element, unless a property set from outside caused the change. */
|
|
2401
|
+
function emit(type, detail, always) {
|
|
2402
|
+
if (current.quiet && !always) return;
|
|
2403
|
+
current.host.dispatchEvent(
|
|
2404
|
+
new CustomEvent(type, { detail, bubbles: type !== 'load' && type !== 'error' }),
|
|
2405
|
+
);
|
|
2406
|
+
}
|
|
2407
|
+
|
|
2408
|
+
/**
|
|
2409
|
+
* Says why a file cannot be shown. The element then shows no file, so that nothing in it is taken for this one.
|
|
2410
|
+
* keep: the input is what could not be read (it is read again, and refused again, in another language); otherwise
|
|
2411
|
+
* nothing is kept to show, and the message (a function: say(), in the language of the moment) is said again when
|
|
2412
|
+
* the language changes. again: the same refusal in another language, which is not told again.
|
|
2413
|
+
*/
|
|
2414
|
+
function showError(say, status, keep, again) {
|
|
2415
|
+
const message = typeof say === 'function' ? say() : say;
|
|
2416
|
+
current.error = keep ? null : { say, status };
|
|
2417
|
+
if (!keep) {
|
|
2418
|
+
current.input = null;
|
|
2419
|
+
current.inputName = null;
|
|
2420
|
+
}
|
|
2421
|
+
const box = $('error');
|
|
2422
|
+
box.replaceChildren(h('strong', { text: t('page.cannotShow') }), message);
|
|
2423
|
+
box.hidden = false;
|
|
2424
|
+
state.model = null;
|
|
2425
|
+
state.file = null;
|
|
2426
|
+
state.lanes = [];
|
|
2427
|
+
$('view').hidden = true;
|
|
2428
|
+
$('title').textContent = t('page.title');
|
|
2429
|
+
$('facts').replaceChildren();
|
|
2430
|
+
if (!again) emit('error', { message, status: status ?? null }, true);
|
|
2431
|
+
}
|
|
2432
|
+
|
|
2433
|
+
function clearError() {
|
|
2434
|
+
current.error = null;
|
|
2435
|
+
$('error').hidden = true;
|
|
2436
|
+
}
|
|
2437
|
+
|
|
2438
|
+
/**
|
|
2439
|
+
* Shows a file (its text or its parsed JSON). again: the same file in another language or with other texts, which
|
|
2440
|
+
* keeps what the user chose (the view, the cursor, the step, the lanes); a new file starts from the properties.
|
|
2441
|
+
*/
|
|
2442
|
+
function load(input, name, again) {
|
|
2443
|
+
const read = readTimeline(input, name);
|
|
2444
|
+
if (read.error) {
|
|
2445
|
+
showError(read.error, null, true, again);
|
|
2446
|
+
return;
|
|
2447
|
+
}
|
|
2448
|
+
clearError();
|
|
2449
|
+
const model = buildModel(read.timeline);
|
|
2450
|
+
const before = again && state.model ? state : null;
|
|
2451
|
+
state.model = model;
|
|
2452
|
+
state.file = name || null;
|
|
2453
|
+
if (before) {
|
|
2454
|
+
setView(state.view, true);
|
|
2455
|
+
state.step = model.steps.some((st) => st.index === state.step) ? state.step : null;
|
|
2456
|
+
} else {
|
|
2457
|
+
state.fit.clear();
|
|
2458
|
+
state.hidden.clear();
|
|
2459
|
+
const o = current.options;
|
|
2460
|
+
state.view = initialView(model);
|
|
2461
|
+
state.cursor = isNum(o.cursor) ? o.cursor : null;
|
|
2462
|
+
state.step = model.steps.some((st) => st.index === o.step) ? o.step : null;
|
|
2463
|
+
if (state.step !== null && isNum(stepOf(state.step)?.start_ms))
|
|
2464
|
+
state.view = stepView(stepOf(state.step));
|
|
2465
|
+
if (isNum(o.from) || isNum(o.to))
|
|
2466
|
+
setView([o.from ?? model.domain[0], o.to ?? model.domain[1]], true);
|
|
2467
|
+
}
|
|
2468
|
+
$('view').hidden = false;
|
|
2469
|
+
renderAll();
|
|
2470
|
+
if (!before) {
|
|
2471
|
+
emit(
|
|
2472
|
+
'load',
|
|
2473
|
+
{
|
|
2474
|
+
file: state.file,
|
|
2475
|
+
scenario: model.name ?? null,
|
|
2476
|
+
status: model.status,
|
|
2477
|
+
start: model.domain[0],
|
|
2478
|
+
end: model.domain[1],
|
|
2479
|
+
},
|
|
2480
|
+
true,
|
|
2481
|
+
);
|
|
2482
|
+
}
|
|
2483
|
+
}
|
|
2484
|
+
|
|
2485
|
+
// --- the parts that do not change with the view
|
|
2486
|
+
|
|
2487
|
+
function renderHeader(m) {
|
|
2488
|
+
const tl = m.tl;
|
|
2489
|
+
$('title').textContent = m.name ?? t('page.noName');
|
|
2490
|
+
const status = h('span', {
|
|
2491
|
+
class: `badge st-${statusClass(m.status)}`,
|
|
2492
|
+
title: String(m.status),
|
|
2493
|
+
text: statusWord(m.status),
|
|
2494
|
+
});
|
|
2495
|
+
const facts = [
|
|
2496
|
+
['fact.file', state.file],
|
|
2497
|
+
['fact.scenario', tl.scenario.file],
|
|
2498
|
+
['fact.configuration', tl.file],
|
|
2499
|
+
['fact.variant', tl.variant],
|
|
2500
|
+
['fact.timeStep', m.timeStep !== null ? fmtMs(m.timeStep) : null],
|
|
2501
|
+
['fact.recordedTo', m.recordedTo !== null ? fmtMs(m.recordedTo) : t('fact.nothingRecorded')],
|
|
2502
|
+
['fact.version', tl.vehicle_sil],
|
|
2503
|
+
].filter(([, v]) => v !== null && v !== undefined);
|
|
2504
|
+
const params = Array.isArray(tl.params) ? tl.params.filter(isObject) : [];
|
|
2505
|
+
$('facts').replaceChildren(
|
|
2506
|
+
status,
|
|
2507
|
+
...facts.map(([k, v]) =>
|
|
2508
|
+
h('span', { class: 'fact' }, h('span', { class: 'muted', text: `${t(k)} ` }), String(v)),
|
|
2509
|
+
),
|
|
2510
|
+
...params.map((p) =>
|
|
2511
|
+
h(
|
|
2512
|
+
'span',
|
|
2513
|
+
{ class: 'fact' },
|
|
2514
|
+
h('span', { class: 'muted', text: `${t('fact.param')} ` }),
|
|
2515
|
+
`${p.name} = ${fmtValue(p.value)}`,
|
|
2516
|
+
h('span', { class: 'muted', text: ` (${p.from})` }),
|
|
2517
|
+
),
|
|
2518
|
+
),
|
|
2519
|
+
);
|
|
2520
|
+
}
|
|
2521
|
+
|
|
2522
|
+
function statusClass(st) {
|
|
2523
|
+
return knows(KNOWN.stepStatus, st) || st === 'incomplete' ? st : 'unknown';
|
|
2524
|
+
}
|
|
2525
|
+
|
|
2526
|
+
function renderSummary(m) {
|
|
2527
|
+
const box = $('summary');
|
|
2528
|
+
const parts = [];
|
|
2529
|
+
const f = m.failure;
|
|
2530
|
+
if (f) {
|
|
2531
|
+
const step = f.step;
|
|
2532
|
+
const where = [
|
|
2533
|
+
step.kind,
|
|
2534
|
+
t('failure.where', { line: step.line, file: m.tl.scenario.file }),
|
|
2535
|
+
f.code,
|
|
2536
|
+
]
|
|
2537
|
+
.filter(Boolean)
|
|
2538
|
+
.join(' · ');
|
|
2539
|
+
parts.push(
|
|
2540
|
+
h(
|
|
2541
|
+
'div',
|
|
2542
|
+
{ class: 'banner bad', 'data-testid': 'failure' },
|
|
2543
|
+
h('h3', { text: t('failure.heading', { step: step.index, at: fmtMs(f.at) }) }),
|
|
2544
|
+
h('p', { class: 'muted small', text: `${where} · ${step.text}` }),
|
|
2545
|
+
f.message
|
|
2546
|
+
? h('p', { class: 'message', 'data-testid': 'failure-message', text: f.message })
|
|
2547
|
+
: null,
|
|
2548
|
+
f.conditions.length ? renderConditions(f) : null,
|
|
2549
|
+
f.writes.length ? renderWrites(f) : null,
|
|
2550
|
+
),
|
|
2551
|
+
);
|
|
2552
|
+
} else if (m.status === 'passed') {
|
|
2553
|
+
const n = m.steps.length;
|
|
2554
|
+
const skipped = m.steps.filter((x) => x.status === 'skipped').length;
|
|
2555
|
+
parts.push(
|
|
2556
|
+
h(
|
|
2557
|
+
'div',
|
|
2558
|
+
{ class: 'banner ok', 'data-testid': 'passed' },
|
|
2559
|
+
h('h3', { text: t('passed.heading', { count: n }) }),
|
|
2560
|
+
skipped ? h('p', { text: t('passed.skipped', { count: skipped }) }) : null,
|
|
2561
|
+
),
|
|
2562
|
+
);
|
|
2563
|
+
} else {
|
|
2564
|
+
const text =
|
|
2565
|
+
m.status === 'not_run'
|
|
2566
|
+
? t('notDecided.notRun')
|
|
2567
|
+
: m.status === 'incomplete'
|
|
2568
|
+
? t('notDecided.incomplete')
|
|
2569
|
+
: t('notDecided.unknown', { status: m.status });
|
|
2570
|
+
parts.push(
|
|
2571
|
+
h(
|
|
2572
|
+
'div',
|
|
2573
|
+
{ class: 'banner warn', 'data-testid': 'not-decided' },
|
|
2574
|
+
h('h3', { text: t('notDecided.heading', { status: statusWord(m.status) }) }),
|
|
2575
|
+
h('p', { text }),
|
|
2576
|
+
...m.findings
|
|
2577
|
+
.filter((x) => x.severity === 'error' && typeof x.message === 'string')
|
|
2578
|
+
.map((x) => h('p', { class: 'message', text: `${x.code}: ${x.message}` })),
|
|
2579
|
+
),
|
|
2580
|
+
);
|
|
2581
|
+
}
|
|
2582
|
+
if (m.dropped.length) {
|
|
2583
|
+
parts.push(
|
|
2584
|
+
h(
|
|
2585
|
+
'div',
|
|
2586
|
+
{ class: 'banner warn small' },
|
|
2587
|
+
h('strong', { text: t('dropped.heading') }),
|
|
2588
|
+
t('dropped.text'),
|
|
2589
|
+
m.dropped
|
|
2590
|
+
.map((d) =>
|
|
2591
|
+
t('dropped.item', {
|
|
2592
|
+
variable: d.variable,
|
|
2593
|
+
source: d.source,
|
|
2594
|
+
count: d.dropped,
|
|
2595
|
+
from: fmtMs(d.dropped_from_ms),
|
|
2596
|
+
to: fmtMs(d.dropped_before_ms),
|
|
2597
|
+
}),
|
|
2598
|
+
)
|
|
2599
|
+
.join('; '),
|
|
2600
|
+
'.',
|
|
2601
|
+
),
|
|
2602
|
+
);
|
|
2603
|
+
}
|
|
2604
|
+
if (m.late) {
|
|
2605
|
+
parts.push(
|
|
2606
|
+
h(
|
|
2607
|
+
'div',
|
|
2608
|
+
{ class: 'banner warn small' },
|
|
2609
|
+
h('strong', { text: t('late.heading') }),
|
|
2610
|
+
t('late.text'),
|
|
2611
|
+
),
|
|
2612
|
+
);
|
|
2613
|
+
}
|
|
2614
|
+
box.replaceChildren(...parts);
|
|
2615
|
+
}
|
|
2616
|
+
|
|
2617
|
+
function renderConditions(f) {
|
|
2618
|
+
return h(
|
|
2619
|
+
'div',
|
|
2620
|
+
{},
|
|
2621
|
+
h('h4', { text: t('conditions.heading') }),
|
|
2622
|
+
h(
|
|
2623
|
+
'ul',
|
|
2624
|
+
{ 'data-testid': 'failed-conditions' },
|
|
2625
|
+
...f.conditions.map((c) => {
|
|
2626
|
+
const what = `${c.variable ?? '?'} ${c.compare ?? ''}`.trim();
|
|
2627
|
+
let got;
|
|
2628
|
+
if (c.valueText !== null)
|
|
2629
|
+
got =
|
|
2630
|
+
t('conditions.was', { value: c.valueText }) +
|
|
2631
|
+
(c.sampleMs !== null ? t('conditions.sampleOf', { at: fmtMs(c.sampleMs) }) : '');
|
|
2632
|
+
else if (c.mode === 'during') got = t('conditions.noSample');
|
|
2633
|
+
else got = t('conditions.noValue');
|
|
2634
|
+
return h('li', {}, h('code', { text: what }), `: ${got}`);
|
|
2635
|
+
}),
|
|
2636
|
+
),
|
|
2637
|
+
);
|
|
2638
|
+
}
|
|
2639
|
+
|
|
2640
|
+
function renderWrites(f) {
|
|
2641
|
+
const words = writeWords(f);
|
|
2642
|
+
const label = (w) =>
|
|
2643
|
+
w.applied === true
|
|
2644
|
+
? t('writes.applied')
|
|
2645
|
+
: w.applied === false
|
|
2646
|
+
? t('writes.notApplied')
|
|
2647
|
+
: t('writes.notKnown');
|
|
2648
|
+
return h(
|
|
2649
|
+
'div',
|
|
2650
|
+
{},
|
|
2651
|
+
h('h4', { text: words.heading }),
|
|
2652
|
+
h('p', { class: 'muted small', 'data-testid': 'failed-writes-explained' }, words.explain),
|
|
2653
|
+
h(
|
|
2654
|
+
'table',
|
|
2655
|
+
{ class: 'writes', 'data-testid': 'failed-writes' },
|
|
2656
|
+
h(
|
|
2657
|
+
'thead',
|
|
2658
|
+
{},
|
|
2659
|
+
h(
|
|
2660
|
+
'tr',
|
|
2661
|
+
{},
|
|
2662
|
+
...['writes.colVariable', 'writes.colValue', 'writes.colInEcu', 'writes.colCause'].map(
|
|
2663
|
+
(x) => h('th', { scope: 'col', text: t(x) }),
|
|
2664
|
+
),
|
|
2665
|
+
),
|
|
2666
|
+
),
|
|
2667
|
+
h(
|
|
2668
|
+
'tbody',
|
|
2669
|
+
{},
|
|
2670
|
+
...f.writes.map((w) =>
|
|
2671
|
+
h(
|
|
2672
|
+
'tr',
|
|
2673
|
+
{ class: w.cause ? 'cause' : null },
|
|
2674
|
+
h('td', {}, h('code', { text: w.variable })),
|
|
2675
|
+
h('td', { text: w.valueText }),
|
|
2676
|
+
h(
|
|
2677
|
+
'td',
|
|
2678
|
+
{ class: `applied-${String(w.applied)}` },
|
|
2679
|
+
appliedIcon(w.applied),
|
|
2680
|
+
` ${label(w)}`,
|
|
2681
|
+
),
|
|
2682
|
+
h('td', { text: words.cause(w) }),
|
|
2683
|
+
),
|
|
2684
|
+
),
|
|
2685
|
+
),
|
|
2686
|
+
),
|
|
2687
|
+
);
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2690
|
+
function appliedIcon(applied) {
|
|
2691
|
+
return h('span', {
|
|
2692
|
+
class: 'icon',
|
|
2693
|
+
'aria-hidden': 'true',
|
|
2694
|
+
text: applied === true ? '✓' : applied === false ? '✗' : '?',
|
|
2695
|
+
});
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
function renderParticipants(m) {
|
|
2699
|
+
const names = [...new Set(m.vars.map((v) => v.participant))];
|
|
2700
|
+
const box = $('participants');
|
|
2701
|
+
if (names.length < 2) {
|
|
2702
|
+
box.replaceChildren();
|
|
2703
|
+
return;
|
|
2704
|
+
}
|
|
2705
|
+
box.replaceChildren(
|
|
2706
|
+
h('span', { class: 'muted', text: `${t('participants.label')} ` }),
|
|
2707
|
+
...names.map((p) =>
|
|
2708
|
+
h(
|
|
2709
|
+
'label',
|
|
2710
|
+
{ class: 'chip' },
|
|
2711
|
+
h('input', {
|
|
2712
|
+
type: 'checkbox',
|
|
2713
|
+
checked: !state.hidden.has(p),
|
|
2714
|
+
onchange: (e) => {
|
|
2715
|
+
if (e.target.checked) state.hidden.delete(p);
|
|
2716
|
+
else state.hidden.add(p);
|
|
2717
|
+
renderChart();
|
|
2718
|
+
},
|
|
2719
|
+
}),
|
|
2720
|
+
` ${p}`,
|
|
2721
|
+
),
|
|
2722
|
+
),
|
|
2723
|
+
);
|
|
2724
|
+
}
|
|
2725
|
+
|
|
2726
|
+
// --- the tables (the same contents as the chart)
|
|
2727
|
+
|
|
2728
|
+
function renderTables(m) {
|
|
2729
|
+
const stepRows = m.steps.map((st) => {
|
|
2730
|
+
const result =
|
|
2731
|
+
st.message ??
|
|
2732
|
+
(typeof st.expect_skipped === 'string'
|
|
2733
|
+
? t('step.expectSkipped', { why: st.expect_skipped })
|
|
2734
|
+
: '');
|
|
2735
|
+
const canShow = isNum(st.start_ms);
|
|
2736
|
+
return h(
|
|
2737
|
+
'tr',
|
|
2738
|
+
{
|
|
2739
|
+
class:
|
|
2740
|
+
[st.status === 'failed' ? 'failed-row' : '', st.index === state.step ? 'selected' : '']
|
|
2741
|
+
.filter(Boolean)
|
|
2742
|
+
.join(' ') || null,
|
|
2743
|
+
'data-step': st.index,
|
|
2744
|
+
},
|
|
2745
|
+
h(
|
|
2746
|
+
'td',
|
|
2747
|
+
{},
|
|
2748
|
+
canShow
|
|
2749
|
+
? h('button', {
|
|
2750
|
+
type: 'button',
|
|
2751
|
+
class: 'link',
|
|
2752
|
+
title: t('step.showOnChart'),
|
|
2753
|
+
onclick: () => showStep(st, true),
|
|
2754
|
+
text: `#${st.index}`,
|
|
2755
|
+
})
|
|
2756
|
+
: `#${st.index}`,
|
|
2757
|
+
),
|
|
2758
|
+
h('td', { text: String(st.line ?? '') }),
|
|
2759
|
+
h('td', { text: String(st.kind) }),
|
|
2760
|
+
h(
|
|
2761
|
+
'td',
|
|
2762
|
+
{},
|
|
2763
|
+
h('span', {
|
|
2764
|
+
class: `badge st-${statusClass(st.status)}`,
|
|
2765
|
+
title: String(st.status),
|
|
2766
|
+
text: statusWord(st.status),
|
|
2767
|
+
}),
|
|
2768
|
+
),
|
|
2769
|
+
h('td', { class: 'num', text: fmtMs(st.start_ms) }),
|
|
2770
|
+
h('td', { class: 'num', text: fmtMs(st.at_ms) }),
|
|
2771
|
+
h('td', { class: 'num', text: fmtMs(st.end_ms) }),
|
|
2772
|
+
h('td', { text: String(st.text ?? '') }),
|
|
2773
|
+
h('td', { text: result }),
|
|
2774
|
+
);
|
|
2775
|
+
});
|
|
2776
|
+
const lineRows = m.lines.map((l) =>
|
|
2777
|
+
h(
|
|
2778
|
+
'tr',
|
|
2779
|
+
{},
|
|
2780
|
+
h('td', { text: String(l.index) }),
|
|
2781
|
+
h('td', {}, h('code', { text: String(l.variable) })),
|
|
2782
|
+
h('td', { text: String(l.kind) }),
|
|
2783
|
+
h('td', {
|
|
2784
|
+
text: l.step === null || l.step === undefined ? t('line.inputs') : `#${l.step}`,
|
|
2785
|
+
}),
|
|
2786
|
+
h('td', { class: 'num', text: fmtMs(l.from_ms) }),
|
|
2787
|
+
h('td', { class: 'num', text: fmtMs(l.to_ms) }),
|
|
2788
|
+
h('td', {
|
|
2789
|
+
text:
|
|
2790
|
+
l.base === null || l.base === undefined
|
|
2791
|
+
? ''
|
|
2792
|
+
: `${fmtValue(l.base, m.byName.get(l.variable)?.info, true)} (${l.base_source})`,
|
|
2793
|
+
}),
|
|
2794
|
+
h('td', { text: String(l.text ?? '') }),
|
|
2795
|
+
),
|
|
2796
|
+
);
|
|
2797
|
+
const findingRows = m.findings.map((x) =>
|
|
2798
|
+
h(
|
|
2799
|
+
'tr',
|
|
2800
|
+
{},
|
|
2801
|
+
h('td', { text: String(x.severity ?? '') }),
|
|
2802
|
+
h('td', {}, h('code', { text: String(x.code) })),
|
|
2803
|
+
h('td', { text: x.line === null || x.line === undefined ? '' : String(x.line) }),
|
|
2804
|
+
h('td', { text: String(x.message ?? t('finding.codeOnly')) }),
|
|
2805
|
+
),
|
|
2806
|
+
);
|
|
2807
|
+
const table = (caption, heads, rows, testid) =>
|
|
2808
|
+
h(
|
|
2809
|
+
'details',
|
|
2810
|
+
{ open: true },
|
|
2811
|
+
h('summary', { text: t('tables.count', { caption, count: rows.length }) }),
|
|
2812
|
+
rows.length
|
|
2813
|
+
? h(
|
|
2814
|
+
'div',
|
|
2815
|
+
{ class: 'table-wrap' },
|
|
2816
|
+
h(
|
|
2817
|
+
'table',
|
|
2818
|
+
{ 'data-testid': testid },
|
|
2819
|
+
h(
|
|
2820
|
+
'thead',
|
|
2821
|
+
{},
|
|
2822
|
+
h('tr', {}, ...heads.map((x) => h('th', { scope: 'col', text: x }))),
|
|
2823
|
+
),
|
|
2824
|
+
h('tbody', {}, ...rows),
|
|
2825
|
+
),
|
|
2826
|
+
)
|
|
2827
|
+
: h('p', { class: 'muted', text: t('tables.none') }),
|
|
2828
|
+
);
|
|
2829
|
+
$('tables').replaceChildren(
|
|
2830
|
+
table(
|
|
2831
|
+
t('tables.steps'),
|
|
2832
|
+
cols('index', 'line', 'kind', 'status', 'start', 'decided', 'end', 'step', 'result'),
|
|
2833
|
+
stepRows,
|
|
2834
|
+
'steps-table',
|
|
2835
|
+
),
|
|
2836
|
+
table(
|
|
2837
|
+
t('tables.lines'),
|
|
2838
|
+
cols('index', 'variable', 'kind', 'step', 'from', 'to', 'base', 'text'),
|
|
2839
|
+
lineRows,
|
|
2840
|
+
'lines-table',
|
|
2841
|
+
),
|
|
2842
|
+
table(
|
|
2843
|
+
t('tables.findings'),
|
|
2844
|
+
cols('severity', 'code', 'line', 'message'),
|
|
2845
|
+
findingRows,
|
|
2846
|
+
'findings-table',
|
|
2847
|
+
),
|
|
2848
|
+
);
|
|
2849
|
+
}
|
|
2850
|
+
|
|
2851
|
+
/** The headings of a table's columns. */
|
|
2852
|
+
function cols(...names) {
|
|
2853
|
+
return names.map((name) => t(`col.${name}`));
|
|
2854
|
+
}
|
|
2855
|
+
|
|
2856
|
+
/** The view around a step (from its start to its end and the end of what it watches). */
|
|
2857
|
+
function stepView(st) {
|
|
2858
|
+
const from = st.start_ms;
|
|
2859
|
+
const ends = [st.end_ms, st.at_ms, isObject(st.watch) ? st.watch.to_ms : null].filter(isNum);
|
|
2860
|
+
const to = Math.max(from, ...ends);
|
|
2861
|
+
const pad = Math.max((to - from) * 0.25, (state.model.timeStep ?? 1) * 3);
|
|
2862
|
+
return [Math.max(state.model.domain[0], from - pad), Math.min(state.model.domain[1], to + pad)];
|
|
2863
|
+
}
|
|
2864
|
+
|
|
2865
|
+
/** The step of an index, or undefined. */
|
|
2866
|
+
function stepOf(index) {
|
|
2867
|
+
return state.model ? state.model.steps.find((st) => st.index === index) : undefined;
|
|
2868
|
+
}
|
|
2869
|
+
|
|
2870
|
+
/** Chooses a step (null: none): marks it on the chart and in the table, and shows it when it has a time. */
|
|
2871
|
+
function showStep(st, scroll) {
|
|
2872
|
+
const changed = (st ? st.index : null) !== state.step;
|
|
2873
|
+
state.step = st ? st.index : null;
|
|
2874
|
+
for (const row of root.querySelectorAll('tr[data-step]'))
|
|
2875
|
+
row.classList.toggle('selected', Number(row.dataset.step) === state.step);
|
|
2876
|
+
if (st && isNum(st.start_ms)) setView(stepView(st));
|
|
2877
|
+
else renderChart();
|
|
2878
|
+
if (changed) emit('stepselect', { step: state.step });
|
|
2879
|
+
if (scroll) $('chart').scrollIntoView({ block: 'nearest' });
|
|
2880
|
+
}
|
|
2881
|
+
|
|
2882
|
+
// --- the chart
|
|
2883
|
+
|
|
2884
|
+
/** Shows a part of the run (clamped to it). noDraw: only set it (the caller draws). */
|
|
2885
|
+
function setView(view, noDraw) {
|
|
2886
|
+
const [d0, d1] = state.model.domain;
|
|
2887
|
+
let [t0, t1] = view;
|
|
2888
|
+
t0 = Math.max(d0, t0);
|
|
2889
|
+
t1 = Math.min(d1, t1);
|
|
2890
|
+
if (!(t1 > t0)) return;
|
|
2891
|
+
const changed = !state.view || state.view[0] !== t0 || state.view[1] !== t1;
|
|
2892
|
+
state.view = [t0, t1];
|
|
2893
|
+
if (noDraw) return;
|
|
2894
|
+
renderChart();
|
|
2895
|
+
if (changed) emit('viewchange', { from: t0, to: t1 });
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2898
|
+
function renderAll() {
|
|
2899
|
+
const m = state.model;
|
|
2900
|
+
renderHeader(m);
|
|
2901
|
+
renderSummary(m);
|
|
2902
|
+
renderParticipants(m);
|
|
2903
|
+
renderTables(m);
|
|
2904
|
+
renderChart();
|
|
2905
|
+
}
|
|
2906
|
+
|
|
2907
|
+
/** The width of a lane's plot: the chart less the column of the lane heads (as timeline.css lays them out). */
|
|
2908
|
+
function plotWidth() {
|
|
2909
|
+
const chart = $('chart');
|
|
2910
|
+
const compact = current.options.compact;
|
|
2911
|
+
const head = compact
|
|
2912
|
+
? chart.clientWidth >= 480
|
|
2913
|
+
? 120
|
|
2914
|
+
: 0
|
|
2915
|
+
: chart.clientWidth >= 720
|
|
2916
|
+
? 200
|
|
2917
|
+
: 0;
|
|
2918
|
+
return Math.max(compact ? 100 : 160, chart.clientWidth - head - 2);
|
|
2919
|
+
}
|
|
2920
|
+
|
|
2921
|
+
/**
|
|
2922
|
+
* The lanes of the variables to draw, in order: with the variables property, those it names (a name, or a
|
|
2923
|
+
* prefix ending in '*') in its order, else the inputs of the scenario first. groups: whether to head the two
|
|
2924
|
+
* groups (only without the property). missing: the entries of the property that match no variable of the file.
|
|
2925
|
+
*/
|
|
2926
|
+
function lanesToDraw(m) {
|
|
2927
|
+
const visible = (v) => !state.hidden.has(v.participant);
|
|
2928
|
+
const wanted = current.options.variables;
|
|
2929
|
+
if (!wanted) {
|
|
2930
|
+
const inputs = m.inputs.filter(visible);
|
|
2931
|
+
return { inputs, others: m.others.filter(visible), groups: true, missing: [] };
|
|
2932
|
+
}
|
|
2933
|
+
const every = [...m.inputs, ...m.others];
|
|
2934
|
+
const all = every.filter(visible);
|
|
2935
|
+
const chosen = [];
|
|
2936
|
+
const missing = [];
|
|
2937
|
+
for (const pattern of wanted) {
|
|
2938
|
+
const prefix = pattern.endsWith('*') ? pattern.slice(0, -1) : null;
|
|
2939
|
+
const matches = (v) => (prefix !== null ? v.name.startsWith(prefix) : v.name === pattern);
|
|
2940
|
+
if (!every.some(matches)) missing.push(pattern);
|
|
2941
|
+
for (const v of all) {
|
|
2942
|
+
if (!chosen.includes(v) && matches(v)) chosen.push(v);
|
|
2943
|
+
}
|
|
2944
|
+
}
|
|
2945
|
+
return { inputs: chosen, others: [], groups: false, missing };
|
|
2946
|
+
}
|
|
2947
|
+
|
|
2948
|
+
function renderChart() {
|
|
2949
|
+
const m = state.model;
|
|
2950
|
+
if (!m) return;
|
|
2951
|
+
const width = plotWidth();
|
|
2952
|
+
state.width = width;
|
|
2953
|
+
const scale = makeScale(state.view[0], state.view[1], width);
|
|
2954
|
+
state.lanes = [];
|
|
2955
|
+
const chart = $('chart');
|
|
2956
|
+
const children = [axisLane(scale), stepLane(m, scale)];
|
|
2957
|
+
const { inputs, others, groups, missing } = lanesToDraw(m);
|
|
2958
|
+
// A name of the variables property that matches nothing is said, not dropped in silence.
|
|
2959
|
+
const note = $('chart-note');
|
|
2960
|
+
const names = [...m.inputs, ...m.others].map((v) => v.name);
|
|
2961
|
+
note.hidden = missing.length === 0;
|
|
2962
|
+
note.textContent = missing.length
|
|
2963
|
+
? t('chart.noMatch', {
|
|
2964
|
+
names: missing.join(', '),
|
|
2965
|
+
have: names.slice(0, 5).join(', ') + (names.length > 5 ? ', …' : ''),
|
|
2966
|
+
})
|
|
2967
|
+
: '';
|
|
2968
|
+
if (inputs.length) {
|
|
2969
|
+
if (groups) children.push(h('div', { class: 'group', text: t('chart.inputs') }));
|
|
2970
|
+
children.push(...inputs.map((v) => variableLane(m, v, scale)));
|
|
2971
|
+
}
|
|
2972
|
+
if (others.length) {
|
|
2973
|
+
if (groups) children.push(h('div', { class: 'group', text: t('chart.others') }));
|
|
2974
|
+
children.push(...others.map((v) => variableLane(m, v, scale)));
|
|
2975
|
+
}
|
|
2976
|
+
chart.replaceChildren(...children);
|
|
2977
|
+
$('range').textContent = t('chart.showing', {
|
|
2978
|
+
from: fmtMs(scale.t0),
|
|
2979
|
+
to: fmtMs(scale.t1),
|
|
2980
|
+
start: fmtMs(m.domain[0]),
|
|
2981
|
+
end: fmtMs(m.domain[1]),
|
|
2982
|
+
});
|
|
2983
|
+
$('show-failure').hidden = !m.failure;
|
|
2984
|
+
updateCursor();
|
|
2985
|
+
}
|
|
2986
|
+
|
|
2987
|
+
function laneShell(head, height, scale, cls) {
|
|
2988
|
+
const svg = s('svg', {
|
|
2989
|
+
class: 'plot',
|
|
2990
|
+
width: scale.width,
|
|
2991
|
+
height,
|
|
2992
|
+
viewBox: `0 0 ${scale.width} ${height}`,
|
|
2993
|
+
role: 'img',
|
|
2994
|
+
});
|
|
2995
|
+
const lane = h(
|
|
2996
|
+
'div',
|
|
2997
|
+
{ class: `lane ${cls || ''}` },
|
|
2998
|
+
h('div', { class: 'lane-head' }, head),
|
|
2999
|
+
h('div', { class: 'lane-plot' }, svg),
|
|
3000
|
+
);
|
|
3001
|
+
const cursor = s('line', { class: 'cursor', x1: -10, x2: -10, y1: 0, y2: height }, null);
|
|
3002
|
+
state.lanes.push({ svg, cursor, height, readout: null });
|
|
3003
|
+
attachPointer(svg, scale, height);
|
|
3004
|
+
return { lane, svg, cursor };
|
|
3005
|
+
}
|
|
3006
|
+
|
|
3007
|
+
/** The marks every lane has: the part after the record, the failure time. Drawn before the data. */
|
|
3008
|
+
function commonBack(svg, m, scale, height) {
|
|
3009
|
+
if (m.recordedTo !== null && m.recordedTo < scale.t1) {
|
|
3010
|
+
const x = Math.max(0, scale.x(m.recordedTo));
|
|
3011
|
+
s('rect', { class: 'unrecorded', x, y: 0, width: scale.width - x, height }, svg);
|
|
3012
|
+
}
|
|
3013
|
+
if (m.recordedTo === null)
|
|
3014
|
+
s('rect', { class: 'unrecorded', x: 0, y: 0, width: scale.width, height }, svg);
|
|
3015
|
+
}
|
|
3016
|
+
|
|
3017
|
+
function commonFront(svg, m, scale, height, cursor) {
|
|
3018
|
+
if (m.failure && isNum(m.failure.at) && m.failure.at >= scale.t0 && m.failure.at <= scale.t1) {
|
|
3019
|
+
const x = scale.x(m.failure.at);
|
|
3020
|
+
s('line', { class: 'fail-line', x1: x, x2: x, y1: 0, y2: height }, svg);
|
|
3021
|
+
}
|
|
3022
|
+
svg.append(cursor);
|
|
3023
|
+
}
|
|
3024
|
+
|
|
3025
|
+
function axisLane(scale) {
|
|
3026
|
+
const height = 22;
|
|
3027
|
+
const { lane, svg, cursor } = laneShell(
|
|
3028
|
+
h('span', {
|
|
3029
|
+
class: 'muted small',
|
|
3030
|
+
id: 'cursor-time',
|
|
3031
|
+
'aria-live': 'polite',
|
|
3032
|
+
text: t('chart.virtualTime'),
|
|
3033
|
+
}),
|
|
3034
|
+
height,
|
|
3035
|
+
scale,
|
|
3036
|
+
'axis',
|
|
3037
|
+
);
|
|
3038
|
+
commonBack(svg, state.model, scale, height);
|
|
3039
|
+
const ticks = niceTicks(scale.t0, scale.t1, Math.max(2, Math.floor(scale.width / 90)));
|
|
3040
|
+
for (const t of ticks) {
|
|
3041
|
+
const x = scale.x(t);
|
|
3042
|
+
s('line', { class: 'tick', x1: x, x2: x, y1: height - 6, y2: height }, svg);
|
|
3043
|
+
s('text', { class: 'tick-label', x: x + 3, y: height - 8, text: fmtMs(t) }, svg);
|
|
3044
|
+
}
|
|
3045
|
+
svg.append(cursor);
|
|
3046
|
+
return lane;
|
|
3047
|
+
}
|
|
3048
|
+
|
|
3049
|
+
function stepLane(m, scale) {
|
|
3050
|
+
const items = [];
|
|
3051
|
+
for (const st of m.steps) {
|
|
3052
|
+
if (!isNum(st.start_ms)) continue;
|
|
3053
|
+
const start = st.start_ms;
|
|
3054
|
+
let end = [st.end_ms, st.at_ms].filter(isNum).reduce((a, b) => Math.max(a, b), start);
|
|
3055
|
+
const open = st.status === 'unfinished';
|
|
3056
|
+
if (open) end = m.domain[1];
|
|
3057
|
+
const limit =
|
|
3058
|
+
isObject(st.watch) &&
|
|
3059
|
+
st.watch.mode === 'once' &&
|
|
3060
|
+
isNum(st.watch.to_ms) &&
|
|
3061
|
+
st.watch.to_ms > end
|
|
3062
|
+
? st.watch.to_ms
|
|
3063
|
+
: null;
|
|
3064
|
+
if ((limit ?? end) < scale.t0 || start > scale.t1) continue;
|
|
3065
|
+
const label = `#${st.index} ${st.kind}`;
|
|
3066
|
+
const labelWidth = label.length * 6.6 + 12;
|
|
3067
|
+
const xs = Math.max(0, scale.x(start));
|
|
3068
|
+
const xe = Math.min(scale.width, scale.x(limit ?? end));
|
|
3069
|
+
// A label that would run off the right edge goes to the left of its step.
|
|
3070
|
+
const left = xe - xs < labelWidth && xs + labelWidth > scale.width;
|
|
3071
|
+
const x0 = left ? xs - labelWidth : xs;
|
|
3072
|
+
const x1 = left ? Math.max(xe, xs + 7) : Math.max(xe, xs + labelWidth);
|
|
3073
|
+
items.push({ st, start, end, limit, open, label, left, x0, x1 });
|
|
3074
|
+
}
|
|
3075
|
+
const { rows, count } = packRows(items, 6);
|
|
3076
|
+
const height = count * STEP_ROW + 6;
|
|
3077
|
+
const head = h(
|
|
3078
|
+
'div',
|
|
3079
|
+
{},
|
|
3080
|
+
h('strong', { text: t('chart.steps') }),
|
|
3081
|
+
h('div', { class: 'readout small', id: 'cursor-steps' }),
|
|
3082
|
+
);
|
|
3083
|
+
const { lane, svg, cursor } = laneShell(head, height, scale, 'steps');
|
|
3084
|
+
commonBack(svg, m, scale, height);
|
|
3085
|
+
items.forEach((it, i) => {
|
|
3086
|
+
const y = rows[i] * STEP_ROW + 4;
|
|
3087
|
+
const bh = STEP_ROW - 6;
|
|
3088
|
+
const chosen = it.st.index === state.step ? ' selected' : '';
|
|
3089
|
+
const g = s(
|
|
3090
|
+
'g',
|
|
3091
|
+
{ class: `step st-${statusClass(it.st.status)}${chosen}`, 'data-step': it.st.index },
|
|
3092
|
+
svg,
|
|
3093
|
+
);
|
|
3094
|
+
const x0 = scale.x(it.start);
|
|
3095
|
+
const x1 = scale.x(it.end);
|
|
3096
|
+
const point = x1 - x0 < 2;
|
|
3097
|
+
if (it.st.status === 'skipped') {
|
|
3098
|
+
s('rect', { class: 'skipped', x: x0 - 5, y, width: 10, height: bh }, g);
|
|
3099
|
+
} else if (point) {
|
|
3100
|
+
s(
|
|
3101
|
+
'path',
|
|
3102
|
+
{ class: 'marker', d: `M${x0} ${y} l6 ${bh / 2} l-6 ${bh / 2} l-6 ${-bh / 2} z` },
|
|
3103
|
+
g,
|
|
3104
|
+
);
|
|
3105
|
+
} else {
|
|
3106
|
+
s('rect', { class: 'bar', x: x0, y, width: x1 - x0, height: bh, rx: 3 }, g);
|
|
3107
|
+
if (it.open)
|
|
3108
|
+
s(
|
|
3109
|
+
'path',
|
|
3110
|
+
{ class: 'open', d: `M${x1 - 7} ${y - 1} l7 ${bh / 2 + 1} l-7 ${bh / 2 + 1}` },
|
|
3111
|
+
g,
|
|
3112
|
+
);
|
|
3113
|
+
}
|
|
3114
|
+
if (isNum(it.st.at_ms) && it.st.at_ms !== it.start && it.st.status !== 'unfinished') {
|
|
3115
|
+
const xa = scale.x(it.st.at_ms);
|
|
3116
|
+
s('line', { class: 'decided', x1: xa, x2: xa, y1: y - 2, y2: y + bh + 2 }, g);
|
|
3117
|
+
}
|
|
3118
|
+
if (it.limit !== null) {
|
|
3119
|
+
const xl = scale.x(it.limit);
|
|
3120
|
+
s('line', { class: 'limit', x1, x2: xl, y1: y + bh / 2, y2: y + bh / 2 }, g);
|
|
3121
|
+
s('line', { class: 'limit', x1: xl, x2: xl, y1: y + 2, y2: y + bh - 2 }, g);
|
|
3122
|
+
}
|
|
3123
|
+
if (it.left) {
|
|
3124
|
+
s(
|
|
3125
|
+
'text',
|
|
3126
|
+
{ class: 'step-label', x: x0 - 8, y: y + bh - 4, 'text-anchor': 'end', text: it.label },
|
|
3127
|
+
g,
|
|
3128
|
+
);
|
|
3129
|
+
} else {
|
|
3130
|
+
s(
|
|
3131
|
+
'text',
|
|
3132
|
+
{
|
|
3133
|
+
class: 'step-label',
|
|
3134
|
+
x: Math.max(x0, 0) + (point ? 8 : 5),
|
|
3135
|
+
y: y + bh - 4,
|
|
3136
|
+
text: it.label,
|
|
3137
|
+
},
|
|
3138
|
+
g,
|
|
3139
|
+
);
|
|
3140
|
+
}
|
|
3141
|
+
const lines = [
|
|
3142
|
+
t('step.title', {
|
|
3143
|
+
index: it.st.index,
|
|
3144
|
+
kind: it.st.kind,
|
|
3145
|
+
line: it.st.line,
|
|
3146
|
+
status: statusWord(it.st.status),
|
|
3147
|
+
}),
|
|
3148
|
+
String(it.st.text ?? ''),
|
|
3149
|
+
t('step.times', {
|
|
3150
|
+
start: fmtMs(it.st.start_ms),
|
|
3151
|
+
decided: fmtMs(it.st.at_ms),
|
|
3152
|
+
end: fmtMs(it.st.end_ms),
|
|
3153
|
+
}),
|
|
3154
|
+
];
|
|
3155
|
+
if (it.st.message) lines.push(it.st.message);
|
|
3156
|
+
if (typeof it.st.expect_skipped === 'string')
|
|
3157
|
+
lines.push(t('step.expectSkipped', { why: it.st.expect_skipped }));
|
|
3158
|
+
tooltip(g, lines.join('\n'));
|
|
3159
|
+
});
|
|
3160
|
+
commonFront(svg, m, scale, height, cursor);
|
|
3161
|
+
return lane;
|
|
3162
|
+
}
|
|
3163
|
+
|
|
3164
|
+
function variableLane(m, v, scale) {
|
|
3165
|
+
const kind = laneKind(v);
|
|
3166
|
+
const both = v.written && v.sampled;
|
|
3167
|
+
const strip = v.lines.length ? STRIP_HEIGHT : 0;
|
|
3168
|
+
const bandCount = both ? 2 : 1;
|
|
3169
|
+
const numberHeight = current.options.compact ? COMPACT_NUMBER_HEIGHT : LANE_NUMBER_HEIGHT;
|
|
3170
|
+
const plotH = kind === 'number' ? numberHeight : BAND_HEIGHT * bandCount + 8;
|
|
3171
|
+
const height = strip + plotH;
|
|
3172
|
+
const info = v.info;
|
|
3173
|
+
const range =
|
|
3174
|
+
isNum(info.min) && isNum(info.max)
|
|
3175
|
+
? t('lane.range', { min: fmtNum(info.min), max: fmtNum(info.max) })
|
|
3176
|
+
: null;
|
|
3177
|
+
const meta = [
|
|
3178
|
+
info.causality ?? null,
|
|
3179
|
+
info.type,
|
|
3180
|
+
info.unit || null,
|
|
3181
|
+
range,
|
|
3182
|
+
isNum(info.ecu_step_ms) ? t('lane.ecuStep', { ms: fmtMs(info.ecu_step_ms) }) : null,
|
|
3183
|
+
]
|
|
3184
|
+
.filter(Boolean)
|
|
3185
|
+
.join(' · ');
|
|
3186
|
+
const fit = defaultFit(v) !== state.fit.has(v.name);
|
|
3187
|
+
const labels = current.options.labels;
|
|
3188
|
+
const label =
|
|
3189
|
+
labels &&
|
|
3190
|
+
Object.prototype.hasOwnProperty.call(labels, v.name) &&
|
|
3191
|
+
typeof labels[v.name] === 'string'
|
|
3192
|
+
? labels[v.name]
|
|
3193
|
+
: null;
|
|
3194
|
+
const readout = h('div', { class: 'readout small' });
|
|
3195
|
+
const writtenEnd =
|
|
3196
|
+
m.recordedTo ??
|
|
3197
|
+
(v.written && v.written.t.length ? v.written.t[v.written.t.length - 1] : null);
|
|
3198
|
+
// The legend names the states of the sent values that the lane has.
|
|
3199
|
+
const writtenStates = new Set();
|
|
3200
|
+
if (v.written && v.written.notAppliedFrom !== null) {
|
|
3201
|
+
for (let i = v.written.notAppliedFrom; i < v.written.t.length; i++)
|
|
3202
|
+
writtenStates.add(pointState(v.written, i));
|
|
3203
|
+
if (keptValue(v.written, writtenEnd)) writtenStates.add('held');
|
|
3204
|
+
}
|
|
3205
|
+
const head = h(
|
|
3206
|
+
'div',
|
|
3207
|
+
{},
|
|
3208
|
+
label ? h('span', { class: 'var-label', text: label }) : null,
|
|
3209
|
+
h('code', { class: `var-name${v.failing ? ' failing' : ''}`, text: v.name }),
|
|
3210
|
+
h('div', { class: 'muted small', text: meta }),
|
|
3211
|
+
h(
|
|
3212
|
+
'div',
|
|
3213
|
+
{ class: 'legend small' },
|
|
3214
|
+
v.written
|
|
3215
|
+
? h(
|
|
3216
|
+
'span',
|
|
3217
|
+
{ class: 'key sent' },
|
|
3218
|
+
t(both && kind !== 'number' ? 'legend.sentUpper' : 'legend.sent'),
|
|
3219
|
+
)
|
|
3220
|
+
: null,
|
|
3221
|
+
v.sampled
|
|
3222
|
+
? h(
|
|
3223
|
+
'span',
|
|
3224
|
+
{ class: 'key seen' },
|
|
3225
|
+
t(both && kind !== 'number' ? 'legend.seenLower' : 'legend.seen'),
|
|
3226
|
+
)
|
|
3227
|
+
: null,
|
|
3228
|
+
writtenStates.has('not-applied')
|
|
3229
|
+
? h('span', { class: 'key not-applied' }, t('legend.notApplied'))
|
|
3230
|
+
: null,
|
|
3231
|
+
writtenStates.has('not-known')
|
|
3232
|
+
? h('span', { class: 'key not-known' }, t('legend.notKnown'))
|
|
3233
|
+
: null,
|
|
3234
|
+
writtenStates.has('held') ? h('span', { class: 'key held' }, t('legend.held')) : null,
|
|
3235
|
+
v.written && v.written.base ? h('span', { class: 'key base' }, t('legend.base')) : null,
|
|
3236
|
+
kind === 'number' && isNum(info.min) && isNum(info.max)
|
|
3237
|
+
? h('button', {
|
|
3238
|
+
type: 'button',
|
|
3239
|
+
class: 'link',
|
|
3240
|
+
'aria-pressed': fit ? 'true' : 'false',
|
|
3241
|
+
title: fit ? t('fit.toDeclared') : t('fit.toValues'),
|
|
3242
|
+
onclick: () => {
|
|
3243
|
+
if (state.fit.has(v.name)) state.fit.delete(v.name);
|
|
3244
|
+
else state.fit.add(v.name);
|
|
3245
|
+
renderChart();
|
|
3246
|
+
},
|
|
3247
|
+
text: fit ? t('fit.declared') : t('fit.values'),
|
|
3248
|
+
})
|
|
3249
|
+
: null,
|
|
3250
|
+
),
|
|
3251
|
+
readout,
|
|
3252
|
+
...v.notes.map((n) => h('div', { class: 'note small', text: t('lane.note', { text: n }) })),
|
|
3253
|
+
);
|
|
3254
|
+
const { lane, svg, cursor } = laneShell(head, height, scale, v.failing ? 'failing' : '');
|
|
3255
|
+
state.lanes[state.lanes.length - 1].readout = { el: readout, v };
|
|
3256
|
+
svg.setAttribute('aria-label', t('lane.label', { name: label ?? v.name }));
|
|
3257
|
+
commonBack(svg, m, scale, height);
|
|
3258
|
+
if (strip) drawLines(svg, m, v, scale);
|
|
3259
|
+
const area = { y0: strip + 4, y1: height - 4 };
|
|
3260
|
+
for (const [source, gap] of Object.entries(v.gaps)) {
|
|
3261
|
+
if (gap.before < scale.t0 || gap.from > scale.t1) continue;
|
|
3262
|
+
const x0 = Math.max(0, scale.x(gap.from));
|
|
3263
|
+
const x1 = Math.min(scale.width, scale.x(gap.before));
|
|
3264
|
+
tooltip(
|
|
3265
|
+
s(
|
|
3266
|
+
'rect',
|
|
3267
|
+
{
|
|
3268
|
+
class: 'dropped',
|
|
3269
|
+
x: x0,
|
|
3270
|
+
y: area.y0,
|
|
3271
|
+
width: Math.max(1, x1 - x0),
|
|
3272
|
+
height: area.y1 - area.y0,
|
|
3273
|
+
},
|
|
3274
|
+
svg,
|
|
3275
|
+
),
|
|
3276
|
+
t('lane.dropped', {
|
|
3277
|
+
count: gap.dropped,
|
|
3278
|
+
source,
|
|
3279
|
+
from: fmtMs(gap.from),
|
|
3280
|
+
to: fmtMs(gap.before),
|
|
3281
|
+
}),
|
|
3282
|
+
);
|
|
3283
|
+
}
|
|
3284
|
+
const sampledEnd = v.sampled ? (v.sampled.lastMs ?? m.recordedTo) : null;
|
|
3285
|
+
if (kind === 'number') {
|
|
3286
|
+
const [lo, hi] = laneRange(v, fit);
|
|
3287
|
+
const y = (val) => area.y1 - ((val - lo) / (hi - lo || 1)) * (area.y1 - area.y0);
|
|
3288
|
+
s('text', { class: 'range-label', x: 2, y: area.y0 + 9, text: fmtNum(hi) }, svg);
|
|
3289
|
+
s('text', { class: 'range-label', x: 2, y: area.y1 - 2, text: fmtNum(lo) }, svg);
|
|
3290
|
+
drawBandsNumber(svg, v, scale, y, area, lo, hi);
|
|
3291
|
+
if (v.sampled)
|
|
3292
|
+
drawNumberSeries(
|
|
3293
|
+
svg,
|
|
3294
|
+
holdSegments(v.sampled, sampledEnd, v.gaps.sampled),
|
|
3295
|
+
scale,
|
|
3296
|
+
y,
|
|
3297
|
+
'seen',
|
|
3298
|
+
);
|
|
3299
|
+
if (v.written) {
|
|
3300
|
+
const segs = holdSegments(v.written, writtenEnd, v.gaps.written);
|
|
3301
|
+
if (v.written.base) drawBase(svg, segs, scale, y);
|
|
3302
|
+
drawNumberSeries(svg, segs, scale, y, 'sent');
|
|
3303
|
+
}
|
|
3304
|
+
drawMarks(
|
|
3305
|
+
svg,
|
|
3306
|
+
v,
|
|
3307
|
+
scale,
|
|
3308
|
+
(val) => (isNum(val) ? y(Math.min(hi, Math.max(lo, val))) : (area.y0 + area.y1) / 2),
|
|
3309
|
+
area,
|
|
3310
|
+
);
|
|
3311
|
+
} else {
|
|
3312
|
+
const bands = [];
|
|
3313
|
+
if (v.written) bands.push(['sent', v.written, writtenEnd, v.gaps.written]);
|
|
3314
|
+
if (v.sampled) bands.push(['seen', v.sampled, sampledEnd, v.gaps.sampled]);
|
|
3315
|
+
// A write of the failed step has its mark with its words; its band does not say them again.
|
|
3316
|
+
const marked = new Set(v.marks.filter((mk) => mk.kind === 'write').map((mk) => mk.at));
|
|
3317
|
+
bands.forEach(([cls, series, end, gap], i) => {
|
|
3318
|
+
const y0 = area.y0 + i * BAND_HEIGHT;
|
|
3319
|
+
drawStateBand(
|
|
3320
|
+
svg,
|
|
3321
|
+
mergeEqual(holdSegments(series, end, gap)),
|
|
3322
|
+
scale,
|
|
3323
|
+
y0,
|
|
3324
|
+
BAND_HEIGHT - 4,
|
|
3325
|
+
cls,
|
|
3326
|
+
kind,
|
|
3327
|
+
info,
|
|
3328
|
+
cls === 'sent' ? marked : new Set(),
|
|
3329
|
+
);
|
|
3330
|
+
});
|
|
3331
|
+
drawBandsState(svg, v, scale, area, info);
|
|
3332
|
+
drawMarks(svg, v, scale, () => area.y0 + (BAND_HEIGHT - 4) / 2, area);
|
|
3333
|
+
}
|
|
3334
|
+
if (!v.written && !v.sampled && !v.notes.length) {
|
|
3335
|
+
s('text', { class: 'empty-label', x: 6, y: height / 2 + 4, text: t('lane.noValues') }, svg);
|
|
3336
|
+
}
|
|
3337
|
+
commonFront(svg, m, scale, height, cursor);
|
|
3338
|
+
return lane;
|
|
3339
|
+
}
|
|
3340
|
+
|
|
3341
|
+
function drawLines(svg, m, v, scale) {
|
|
3342
|
+
for (const l of v.lines) {
|
|
3343
|
+
if (!isNum(l.from_ms)) continue;
|
|
3344
|
+
const known = knows(KNOWN.lineKind, l.kind);
|
|
3345
|
+
const x0 = scale.x(l.from_ms);
|
|
3346
|
+
const text = t('line.title', {
|
|
3347
|
+
text: l.text ?? l.kind,
|
|
3348
|
+
where:
|
|
3349
|
+
l.step === null || l.step === undefined
|
|
3350
|
+
? t('line.inputs')
|
|
3351
|
+
: t('line.step', { step: l.step }),
|
|
3352
|
+
line: l.line,
|
|
3353
|
+
});
|
|
3354
|
+
const g = tooltip(
|
|
3355
|
+
s('g', { class: `line-mark line-${known ? l.kind : 'unknown'}` }, svg),
|
|
3356
|
+
text,
|
|
3357
|
+
);
|
|
3358
|
+
if (!known) {
|
|
3359
|
+
s('line', { x1: x0, x2: x0, y1: 1, y2: STRIP_HEIGHT - 2 }, g);
|
|
3360
|
+
if (isNum(l.to_ms))
|
|
3361
|
+
s('line', { x1: scale.x(l.to_ms), x2: scale.x(l.to_ms), y1: 1, y2: STRIP_HEIGHT - 2 }, g);
|
|
3362
|
+
continue;
|
|
3363
|
+
}
|
|
3364
|
+
if (l.kind === 'set') {
|
|
3365
|
+
s('path', { d: `M${x0} 2 l4 4 l-4 4 l-4 -4 z` }, g);
|
|
3366
|
+
continue;
|
|
3367
|
+
}
|
|
3368
|
+
let end =
|
|
3369
|
+
l.kind === 'dither' ? (l.until ?? m.domain[1]) : isNum(l.to_ms) ? l.to_ms : l.from_ms;
|
|
3370
|
+
if (isNum(l.stopped_at_ms)) end = Math.min(end, l.stopped_at_ms);
|
|
3371
|
+
if (l.kind === 'dither' && !l.shape) {
|
|
3372
|
+
s('path', { d: `M${x0 - 3} 3 l6 6 m0 -6 l-6 6` }, g);
|
|
3373
|
+
continue;
|
|
3374
|
+
}
|
|
3375
|
+
const x1 = scale.x(end);
|
|
3376
|
+
s('rect', { x: x0, y: 2, width: Math.max(2, x1 - x0), height: STRIP_HEIGHT - 5, rx: 2 }, g);
|
|
3377
|
+
const label =
|
|
3378
|
+
l.shape && typeof l.shape.type === 'string'
|
|
3379
|
+
? `${l.kind === 'dither' ? 'dither ' : ''}${l.shape.type}`
|
|
3380
|
+
: l.kind;
|
|
3381
|
+
if (x1 - x0 > label.length * 6 + 6)
|
|
3382
|
+
s('text', { x: Math.max(x0, 0) + 3, y: STRIP_HEIGHT - 4, text: label }, g);
|
|
3383
|
+
}
|
|
3384
|
+
}
|
|
3385
|
+
|
|
3386
|
+
/** The title of a segment of a series, by its state (the same words as the read-out and the writes table). */
|
|
3387
|
+
const STATE_TITLES = {
|
|
3388
|
+
'not-applied': 'state.notApplied',
|
|
3389
|
+
'not-known': 'state.notKnown',
|
|
3390
|
+
held: 'state.held',
|
|
3391
|
+
};
|
|
3392
|
+
const stateTitle = (st) => t(STATE_TITLES[st]);
|
|
3393
|
+
|
|
3394
|
+
function drawNumberSeries(svg, segs, scale, y, cls) {
|
|
3395
|
+
const shown = decimate(segs, scale);
|
|
3396
|
+
const groups = { main: [], 'not-applied': [], 'not-known': [], held: [] };
|
|
3397
|
+
let prev = null;
|
|
3398
|
+
for (const seg of shown) {
|
|
3399
|
+
const key = Object.prototype.hasOwnProperty.call(groups, seg.state) ? seg.state : 'main';
|
|
3400
|
+
if (!isNum(seg.v)) {
|
|
3401
|
+
prev = null;
|
|
3402
|
+
continue;
|
|
3403
|
+
}
|
|
3404
|
+
const x0 = scale.x(seg.from);
|
|
3405
|
+
const x1 = scale.x(seg.to);
|
|
3406
|
+
let d = '';
|
|
3407
|
+
if (prev && prev.key === key && Math.abs(prev.x - x0) < 0.5)
|
|
3408
|
+
d += `M${x0} ${prev.y}L${x0} ${y(seg.v)}`;
|
|
3409
|
+
if (seg.min !== seg.max) d += `M${x0} ${y(seg.min)}L${x0} ${y(seg.max)}`;
|
|
3410
|
+
d += `M${x0} ${y(seg.v)}L${Math.max(x1, x0 + 0.5)} ${y(seg.v)}`;
|
|
3411
|
+
groups[key].push(d);
|
|
3412
|
+
prev = seg.state === 'alone' ? null : { key, x: x1, y: y(seg.v) };
|
|
3413
|
+
if (seg.state === 'alone' || unapplied(seg.state)) {
|
|
3414
|
+
const pt = s(
|
|
3415
|
+
'circle',
|
|
3416
|
+
{ class: `pt ${cls} ${seg.state}`, cx: x0, cy: y(seg.v), r: 2.5 },
|
|
3417
|
+
svg,
|
|
3418
|
+
);
|
|
3419
|
+
if (unapplied(seg.state))
|
|
3420
|
+
tooltip(
|
|
3421
|
+
pt,
|
|
3422
|
+
t('state.at', {
|
|
3423
|
+
title: stateTitle(seg.state),
|
|
3424
|
+
value: fmtValue(seg.v),
|
|
3425
|
+
at: fmtMs(seg.from),
|
|
3426
|
+
}),
|
|
3427
|
+
);
|
|
3428
|
+
}
|
|
3429
|
+
}
|
|
3430
|
+
if (groups.main.length) s('path', { class: `series ${cls}`, d: groups.main.join('') }, svg);
|
|
3431
|
+
for (const key of ['held', 'not-applied', 'not-known']) {
|
|
3432
|
+
if (groups[key].length)
|
|
3433
|
+
tooltip(
|
|
3434
|
+
s('path', { class: `series ${cls} ${key}`, d: groups[key].join('') }, svg),
|
|
3435
|
+
stateTitle(key),
|
|
3436
|
+
);
|
|
3437
|
+
}
|
|
3438
|
+
}
|
|
3439
|
+
|
|
3440
|
+
function drawBase(svg, segs, scale, y) {
|
|
3441
|
+
const d = decimate(segs, scale)
|
|
3442
|
+
.filter((seg) => isNum(seg.base) && seg.state !== 'held')
|
|
3443
|
+
.map(
|
|
3444
|
+
(seg) =>
|
|
3445
|
+
`M${scale.x(seg.from)} ${y(seg.base)}L${Math.max(scale.x(seg.to), scale.x(seg.from) + 0.5)} ${y(seg.base)}`,
|
|
3446
|
+
)
|
|
3447
|
+
.join('');
|
|
3448
|
+
if (d) s('path', { class: 'series base', d }, svg);
|
|
3449
|
+
}
|
|
3450
|
+
|
|
3451
|
+
function drawStateBand(svg, segs, scale, y0, height, cls, kind, info, marked) {
|
|
3452
|
+
let before = null; // the last rect of the row: { from, y, x1 }
|
|
3453
|
+
for (const { seg, y, height: rh } of stateBandLayout(decimate(segs, scale), y0, height)) {
|
|
3454
|
+
// A value that is not of the variable's type is not drawn (the lane's note names it).
|
|
3455
|
+
if (seg.v === undefined) continue;
|
|
3456
|
+
let x0 = Math.max(-1, scale.x(seg.from));
|
|
3457
|
+
// Points of one time (a write sent after one that was refused) go side by side in the order sent, so that
|
|
3458
|
+
// a later one does not cover the one before, and past the mark of a failed write at that time (10 px wide).
|
|
3459
|
+
if (before && before.y === y && before.from === seg.from)
|
|
3460
|
+
x0 = Math.max(x0, before.x1, marked.has(seg.from) ? scale.x(seg.from) + 6 : -Infinity);
|
|
3461
|
+
const x1 = Math.min(scale.width + 1, scale.x(seg.to));
|
|
3462
|
+
// A point at the end of the record (or alone in a gap) still gets a visible width.
|
|
3463
|
+
const w = Math.max(seg.to === seg.from || unapplied(seg.state) ? 3 : 0.5, x1 - x0);
|
|
3464
|
+
before = { from: seg.from, y, x1: x0 + w };
|
|
3465
|
+
let fill;
|
|
3466
|
+
if (seg.v === null) fill = 'null';
|
|
3467
|
+
else if (seg.min !== seg.max) fill = 'mixed';
|
|
3468
|
+
else if (kind === 'bool') fill = seg.v ? 'true' : 'false';
|
|
3469
|
+
else fill = `e${Math.abs(Number(seg.v)) % 3}`;
|
|
3470
|
+
const r = s(
|
|
3471
|
+
'rect',
|
|
3472
|
+
{ class: `state ${cls} ${seg.state} v-${fill}`, x: x0, y, width: w, height: rh },
|
|
3473
|
+
svg,
|
|
3474
|
+
);
|
|
3475
|
+
const value = fmtValue(seg.v, info);
|
|
3476
|
+
tooltip(
|
|
3477
|
+
r,
|
|
3478
|
+
seg.state === 'held'
|
|
3479
|
+
? t('state.fromTo', {
|
|
3480
|
+
title: stateTitle('held'),
|
|
3481
|
+
value,
|
|
3482
|
+
from: fmtMs(seg.from),
|
|
3483
|
+
to: fmtMs(seg.to),
|
|
3484
|
+
})
|
|
3485
|
+
: unapplied(seg.state)
|
|
3486
|
+
? t('state.at', { title: stateTitle(seg.state), value, at: fmtMs(seg.from) })
|
|
3487
|
+
: t('state.from', { value, from: fmtMs(seg.from) }),
|
|
3488
|
+
);
|
|
3489
|
+
if (seg.state === 'held' || (unapplied(seg.state) && marked.has(seg.from))) continue;
|
|
3490
|
+
const text = fill === 'mixed' ? '…' : value;
|
|
3491
|
+
const name =
|
|
3492
|
+
kind === 'enum' && info && Array.isArray(info.items)
|
|
3493
|
+
? ((info.items.find((i) => i && i.value === seg.v) || {}).name ?? text)
|
|
3494
|
+
: text;
|
|
3495
|
+
const said = {
|
|
3496
|
+
'not-applied': t('state.notAppliedSuffix'),
|
|
3497
|
+
'not-known': t('state.notKnownSuffix'),
|
|
3498
|
+
}[seg.state];
|
|
3499
|
+
const label = said && w > (name + said).length * 6.5 + 6 ? name + said : name;
|
|
3500
|
+
if (w > label.length * 6.5 + 6) {
|
|
3501
|
+
s(
|
|
3502
|
+
'text',
|
|
3503
|
+
{
|
|
3504
|
+
class: `state-label ${seg.state}`,
|
|
3505
|
+
x: Math.max(x0, 0) + 3,
|
|
3506
|
+
y: y + rh - 6,
|
|
3507
|
+
text: label,
|
|
3508
|
+
},
|
|
3509
|
+
svg,
|
|
3510
|
+
);
|
|
3511
|
+
}
|
|
3512
|
+
}
|
|
3513
|
+
}
|
|
3514
|
+
|
|
3515
|
+
/** Green for a condition that held, red for the one that failed; grey when its step was not decided by it. */
|
|
3516
|
+
function bandClass(b) {
|
|
3517
|
+
return b.failed ? 'bad' : b.status === 'passed' ? 'ok' : 'neutral';
|
|
3518
|
+
}
|
|
3519
|
+
|
|
3520
|
+
function bandTitle(b, info) {
|
|
3521
|
+
const range =
|
|
3522
|
+
b.mode === 'at'
|
|
3523
|
+
? t('band.at', { at: fmtMs(b.from) })
|
|
3524
|
+
: t('band.range', { from: fmtMs(b.from), to: fmtMs(b.until) });
|
|
3525
|
+
const limit =
|
|
3526
|
+
b.limit !== null && b.limit !== b.to ? t('band.limit', { limit: fmtMs(b.limit) }) : '';
|
|
3527
|
+
const result = b.failed
|
|
3528
|
+
? t('band.didNotHold')
|
|
3529
|
+
: b.status === 'passed'
|
|
3530
|
+
? t('band.held')
|
|
3531
|
+
: t('band.stepStatus', { status: statusWord(b.status) });
|
|
3532
|
+
return t('band.title', {
|
|
3533
|
+
step: b.step,
|
|
3534
|
+
mode: b.mode,
|
|
3535
|
+
compare: compareText(b.compare, info),
|
|
3536
|
+
range,
|
|
3537
|
+
limit,
|
|
3538
|
+
result,
|
|
3539
|
+
});
|
|
3540
|
+
}
|
|
3541
|
+
|
|
3542
|
+
function drawBandsNumber(svg, v, scale, y, area, lo, hi) {
|
|
3543
|
+
const clampY = (val) => y(Math.min(hi, Math.max(lo, val)));
|
|
3544
|
+
for (const b of v.bands) {
|
|
3545
|
+
if (b.to < scale.t0 || b.from > scale.t1) continue;
|
|
3546
|
+
const x0 = scale.x(b.from);
|
|
3547
|
+
const x1 = Math.max(scale.x(b.to), x0 + 3);
|
|
3548
|
+
const g = tooltip(s('g', { class: `band ${bandClass(b)}` }, svg), bandTitle(b, v.info));
|
|
3549
|
+
for (const c of b.compare) {
|
|
3550
|
+
if (!isNum(c.value)) continue;
|
|
3551
|
+
let top;
|
|
3552
|
+
let bottom;
|
|
3553
|
+
if (c.op === 'ge' || c.op === 'gt') [top, bottom] = [area.y0, clampY(c.value)];
|
|
3554
|
+
else if (c.op === 'le' || c.op === 'lt') [top, bottom] = [clampY(c.value), area.y1];
|
|
3555
|
+
else if (c.op === 'near' && isNum(c.tolerance))
|
|
3556
|
+
[top, bottom] = [clampY(c.value + c.tolerance), clampY(c.value - c.tolerance)];
|
|
3557
|
+
else if (c.op === 'eq') [top, bottom] = [clampY(c.value) - 2, clampY(c.value) + 2];
|
|
3558
|
+
if (top !== undefined)
|
|
3559
|
+
s(
|
|
3560
|
+
'rect',
|
|
3561
|
+
{ class: 'allowed', x: x0, y: top, width: x1 - x0, height: Math.max(2, bottom - top) },
|
|
3562
|
+
g,
|
|
3563
|
+
);
|
|
3564
|
+
const ty = clampY(c.value);
|
|
3565
|
+
s(
|
|
3566
|
+
'line',
|
|
3567
|
+
{ class: `threshold${c.op === 'ne' ? ' ne' : ''}`, x1: x0, x2: x1, y1: ty, y2: ty },
|
|
3568
|
+
g,
|
|
3569
|
+
);
|
|
3570
|
+
}
|
|
3571
|
+
if (b.limit !== null && b.limit > b.to) {
|
|
3572
|
+
const xl = scale.x(b.limit);
|
|
3573
|
+
const ty = isNum(b.compare[0] && b.compare[0].value) ? clampY(b.compare[0].value) : area.y0;
|
|
3574
|
+
s('line', { class: 'threshold limit', x1: x1, x2: xl, y1: ty, y2: ty }, g);
|
|
3575
|
+
}
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
|
|
3579
|
+
function drawBandsState(svg, v, scale, area, info) {
|
|
3580
|
+
for (const b of v.bands) {
|
|
3581
|
+
if (b.to < scale.t0 || b.from > scale.t1) continue;
|
|
3582
|
+
const x0 = scale.x(b.from);
|
|
3583
|
+
const x1 = Math.max(scale.x(b.to), x0 + 3);
|
|
3584
|
+
const g = tooltip(s('g', { class: `band ${bandClass(b)}` }, svg), bandTitle(b, info));
|
|
3585
|
+
s(
|
|
3586
|
+
'rect',
|
|
3587
|
+
{
|
|
3588
|
+
class: 'expect-box',
|
|
3589
|
+
x: x0,
|
|
3590
|
+
y: area.y0 - 2,
|
|
3591
|
+
width: x1 - x0,
|
|
3592
|
+
height: area.y1 - area.y0 + 4,
|
|
3593
|
+
},
|
|
3594
|
+
g,
|
|
3595
|
+
);
|
|
3596
|
+
const text = t('band.expect', { compare: compareText(b.compare, info) });
|
|
3597
|
+
if (x1 - x0 > text.length * 6 + 4)
|
|
3598
|
+
s('text', { class: 'expect-label', x: x0 + 3, y: area.y1 - 1, text }, g);
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
|
|
3602
|
+
function drawMarks(svg, v, scale, yOf, area) {
|
|
3603
|
+
for (const mk of v.marks) {
|
|
3604
|
+
if (!isNum(mk.at) || mk.at < scale.t0 || mk.at > scale.t1) continue;
|
|
3605
|
+
const x = scale.x(mk.at);
|
|
3606
|
+
const cy = yOf(mk.value);
|
|
3607
|
+
if (mk.kind === 'condition') {
|
|
3608
|
+
const g = tooltip(
|
|
3609
|
+
s('g', { class: 'mark bad' }, svg),
|
|
3610
|
+
mk.text === null
|
|
3611
|
+
? t('mark.noValueAt', { at: fmtMs(mk.at) })
|
|
3612
|
+
: t('mark.was', { value: mk.text, at: fmtMs(mk.at) }),
|
|
3613
|
+
);
|
|
3614
|
+
s('circle', { cx: x, cy, r: 5 }, g);
|
|
3615
|
+
const label = mk.text === null ? t('mark.noValue') : mk.text;
|
|
3616
|
+
const left = x + label.length * 6.5 + 10 > scale.width;
|
|
3617
|
+
s(
|
|
3618
|
+
'text',
|
|
3619
|
+
{
|
|
3620
|
+
x: left ? x - 8 : x + 8,
|
|
3621
|
+
y: Math.max(area.y0 + 10, cy - 4),
|
|
3622
|
+
'text-anchor': left ? 'end' : 'start',
|
|
3623
|
+
text: label,
|
|
3624
|
+
},
|
|
3625
|
+
g,
|
|
3626
|
+
);
|
|
3627
|
+
} else {
|
|
3628
|
+
const cls = mk.applied === true ? 'ok' : mk.applied === false ? 'bad' : 'warn';
|
|
3629
|
+
const word =
|
|
3630
|
+
mk.applied === true
|
|
3631
|
+
? t('mark.applied')
|
|
3632
|
+
: mk.applied === false
|
|
3633
|
+
? mk.sent === false
|
|
3634
|
+
? t('mark.notSent')
|
|
3635
|
+
: t('mark.notApplied')
|
|
3636
|
+
: t('mark.notKnownWhether');
|
|
3637
|
+
const g = tooltip(
|
|
3638
|
+
s('g', { class: `mark write ${cls}${mk.cause ? ' cause' : ''}` }, svg),
|
|
3639
|
+
t('mark.write', {
|
|
3640
|
+
value: fmtValue(mk.value, v.info, true),
|
|
3641
|
+
at: fmtMs(mk.at),
|
|
3642
|
+
word,
|
|
3643
|
+
cause: mk.cause ? t('mark.cause') : '',
|
|
3644
|
+
}),
|
|
3645
|
+
);
|
|
3646
|
+
s('rect', { x: x - 5, y: cy - 5, width: 10, height: 10, rx: 2 }, g);
|
|
3647
|
+
s(
|
|
3648
|
+
'text',
|
|
3649
|
+
{
|
|
3650
|
+
class: 'glyph',
|
|
3651
|
+
x,
|
|
3652
|
+
y: cy + 4,
|
|
3653
|
+
'text-anchor': 'middle',
|
|
3654
|
+
text: mk.applied === true ? '✓' : mk.applied === false ? '✗' : '?',
|
|
3655
|
+
},
|
|
3656
|
+
g,
|
|
3657
|
+
);
|
|
3658
|
+
const label = t('mark.label', {
|
|
3659
|
+
value: fmtValue(mk.value, v.info),
|
|
3660
|
+
word: mk.applied === null ? t('mark.notKnown') : word,
|
|
3661
|
+
});
|
|
3662
|
+
const left = x + label.length * 6.5 + 10 > scale.width;
|
|
3663
|
+
s(
|
|
3664
|
+
'text',
|
|
3665
|
+
{
|
|
3666
|
+
x: left ? x - 9 : x + 9,
|
|
3667
|
+
y: Math.max(area.y0 + 10, cy - 6),
|
|
3668
|
+
'text-anchor': left ? 'end' : 'start',
|
|
3669
|
+
text: label,
|
|
3670
|
+
},
|
|
3671
|
+
g,
|
|
3672
|
+
);
|
|
3673
|
+
}
|
|
3674
|
+
}
|
|
3675
|
+
}
|
|
3676
|
+
|
|
3677
|
+
// --- the cursor and zooming
|
|
3678
|
+
|
|
3679
|
+
/** el.addEventListener, drawing on the element that is current now. */
|
|
3680
|
+
function listen(el, type, fn) {
|
|
3681
|
+
el.addEventListener(type, bound(fn));
|
|
3682
|
+
}
|
|
3683
|
+
|
|
3684
|
+
/** Moves the cursor as the user does, and says so. */
|
|
3685
|
+
function moveCursor(at) {
|
|
3686
|
+
if (at === state.cursor) return;
|
|
3687
|
+
state.cursor = at;
|
|
3688
|
+
updateCursor();
|
|
3689
|
+
emit('cursorchange', { cursor: at });
|
|
3690
|
+
}
|
|
3691
|
+
|
|
3692
|
+
function attachPointer(svg, scale, height) {
|
|
3693
|
+
let down = null;
|
|
3694
|
+
let downStep = null;
|
|
3695
|
+
let sel = null;
|
|
3696
|
+
const xOf = (e) => {
|
|
3697
|
+
const r = svg.getBoundingClientRect();
|
|
3698
|
+
return Math.min(scale.width, Math.max(0, e.clientX - r.left));
|
|
3699
|
+
};
|
|
3700
|
+
listen(svg, 'pointerdown', (e) => {
|
|
3701
|
+
if (e.button !== 0) return;
|
|
3702
|
+
down = xOf(e);
|
|
3703
|
+
// A click on a step chooses it (the pointer is captured, so the click itself goes to the lane).
|
|
3704
|
+
const step = e.target.closest ? e.target.closest('[data-step]') : null;
|
|
3705
|
+
downStep = step ? stepOf(Number(step.dataset.step)) : null;
|
|
3706
|
+
svg.setPointerCapture(e.pointerId);
|
|
3707
|
+
});
|
|
3708
|
+
listen(svg, 'pointermove', (e) => {
|
|
3709
|
+
const x = xOf(e);
|
|
3710
|
+
moveCursor(scale.t(x));
|
|
3711
|
+
if (down !== null && Math.abs(x - down) > 4) {
|
|
3712
|
+
if (!sel) sel = s('rect', { class: 'selection', y: 0, height }, svg);
|
|
3713
|
+
sel.setAttribute('x', Math.min(x, down));
|
|
3714
|
+
sel.setAttribute('width', Math.abs(x - down));
|
|
3715
|
+
}
|
|
3716
|
+
});
|
|
3717
|
+
listen(svg, 'pointerup', (e) => {
|
|
3718
|
+
const x = xOf(e);
|
|
3719
|
+
const dragged = down !== null && Math.abs(x - down) > 4;
|
|
3720
|
+
if (dragged) setView([scale.t(Math.min(x, down)), scale.t(Math.max(x, down))]);
|
|
3721
|
+
else if (down !== null && downStep) showStep(downStep);
|
|
3722
|
+
down = null;
|
|
3723
|
+
downStep = null;
|
|
3724
|
+
if (sel) sel.remove();
|
|
3725
|
+
sel = null;
|
|
3726
|
+
});
|
|
3727
|
+
listen(svg, 'dblclick', () => setView(state.model.domain));
|
|
3728
|
+
}
|
|
3729
|
+
|
|
3730
|
+
function updateCursor() {
|
|
3731
|
+
const m = state.model;
|
|
3732
|
+
const at = state.cursor;
|
|
3733
|
+
if (!m || at === null || at < state.view[0] || at > state.view[1]) {
|
|
3734
|
+
for (const lane of state.lanes) {
|
|
3735
|
+
lane.cursor.setAttribute('x1', -10);
|
|
3736
|
+
lane.cursor.setAttribute('x2', -10);
|
|
3737
|
+
if (lane.readout) lane.readout.el.textContent = '';
|
|
3738
|
+
}
|
|
3739
|
+
const time = $('cursor-time');
|
|
3740
|
+
if (time) time.textContent = t('chart.virtualTime');
|
|
3741
|
+
const steps = $('cursor-steps');
|
|
3742
|
+
if (steps) steps.textContent = '';
|
|
3743
|
+
return;
|
|
3744
|
+
}
|
|
3745
|
+
const scale = makeScale(state.view[0], state.view[1], state.width);
|
|
3746
|
+
const x = scale.x(at);
|
|
3747
|
+
for (const lane of state.lanes) {
|
|
3748
|
+
lane.cursor.setAttribute('x1', x);
|
|
3749
|
+
lane.cursor.setAttribute('x2', x);
|
|
3750
|
+
if (!lane.readout) continue;
|
|
3751
|
+
const v = lane.readout.v;
|
|
3752
|
+
const parts = [];
|
|
3753
|
+
const end = m.recordedTo;
|
|
3754
|
+
const w = valueAt(v.written, at, end, v.gaps.written);
|
|
3755
|
+
const sv = valueAt(v.sampled, at, end, v.gaps.sampled);
|
|
3756
|
+
if (w) parts.push(readoutText('sent', w, v.info));
|
|
3757
|
+
if (sv) parts.push(readoutText('seen', sv, v.info));
|
|
3758
|
+
// The time is in the head of the axis lane; each lane says only its values (all of them on hover).
|
|
3759
|
+
lane.readout.el.textContent = parts.join(' · ');
|
|
3760
|
+
lane.readout.el.title = lane.readout.el.textContent;
|
|
3761
|
+
}
|
|
3762
|
+
$('cursor-time').textContent = t('chart.cursor', { at: fmtMs(Number(at.toPrecision(6))) });
|
|
3763
|
+
const active = m.steps.filter((st) => {
|
|
3764
|
+
if (!isNum(st.start_ms)) return false;
|
|
3765
|
+
const e = [st.end_ms, st.at_ms].filter(isNum).reduce((a, b) => Math.max(a, b), st.start_ms);
|
|
3766
|
+
return at >= st.start_ms && (at <= e || st.status === 'unfinished');
|
|
3767
|
+
});
|
|
3768
|
+
$('cursor-steps').textContent = active.length
|
|
3769
|
+
? active.map((st) => `#${st.index} ${st.kind} (${statusWord(st.status)})`).join(', ')
|
|
3770
|
+
: '';
|
|
3771
|
+
}
|
|
3772
|
+
|
|
3773
|
+
// --- loading
|
|
3774
|
+
|
|
3775
|
+
/** The key under which the GUI's screens keep the server's token in sessionStorage (takeToken of the client). */
|
|
3776
|
+
const TOKEN_KEY = 'vehicle-sil-gui-token';
|
|
3777
|
+
|
|
3778
|
+
/** The token that the GUI's screens keep in this tab, or null. */
|
|
3779
|
+
function storedToken() {
|
|
3780
|
+
try {
|
|
3781
|
+
return window.sessionStorage.getItem(TOKEN_KEY);
|
|
3782
|
+
} catch {
|
|
3783
|
+
return null; // the browser blocks site data
|
|
3784
|
+
}
|
|
3785
|
+
}
|
|
3786
|
+
|
|
3787
|
+
/** Loads the file at src (an address on the page's own server) and shows it; an older load still under way is dropped. */
|
|
3788
|
+
function fromSrc(src) {
|
|
3789
|
+
const element = current;
|
|
3790
|
+
const seq = ++element.loads;
|
|
3791
|
+
if (element.abort) element.abort.abort();
|
|
3792
|
+
element.abort = null;
|
|
3793
|
+
if (location.protocol === 'file:') {
|
|
3794
|
+
showError(() => t('load.fileProtocol'));
|
|
3795
|
+
return;
|
|
3796
|
+
}
|
|
3797
|
+
let url;
|
|
3798
|
+
try {
|
|
3799
|
+
url = new URL(src, document.baseURI);
|
|
3800
|
+
} catch {
|
|
3801
|
+
showError(() => t('load.notAddress', { src }));
|
|
3802
|
+
return;
|
|
3803
|
+
}
|
|
3804
|
+
if (url.origin !== location.origin) {
|
|
3805
|
+
showError(() => t('load.otherOrigin', { origin: location.origin, other: url.origin }));
|
|
3806
|
+
return;
|
|
3807
|
+
}
|
|
3808
|
+
const o = element.options;
|
|
3809
|
+
const token = o.token ?? storedToken();
|
|
3810
|
+
const headers = {};
|
|
3811
|
+
for (const [k, v] of Object.entries(isObject(o.headers) ? o.headers : {}))
|
|
3812
|
+
if (typeof v === 'string') headers[k] = v;
|
|
3813
|
+
if (token) headers.Authorization = `Bearer ${token}`;
|
|
3814
|
+
let name = url.pathname.split('/').pop() || url.pathname;
|
|
3815
|
+
const abort = typeof AbortController === 'function' ? new AbortController() : null;
|
|
3816
|
+
element.abort = abort;
|
|
3817
|
+
element.host.setAttribute('aria-busy', 'true');
|
|
3818
|
+
const fresh = () => {
|
|
3819
|
+
if (element.abort === abort) element.abort = null; // this load is over
|
|
3820
|
+
if (seq !== element.loads) return false;
|
|
3821
|
+
element.host.removeAttribute('aria-busy');
|
|
3822
|
+
return true;
|
|
3823
|
+
};
|
|
3824
|
+
// A redirect could lead to another origin with the token and the headers: the file must come from this address
|
|
3825
|
+
// itself. 'manual' does not follow it, and says that it was one (an opaque answer).
|
|
3826
|
+
fetch(url, {
|
|
3827
|
+
credentials: 'same-origin',
|
|
3828
|
+
redirect: 'manual',
|
|
3829
|
+
headers,
|
|
3830
|
+
signal: abort ? abort.signal : undefined,
|
|
3831
|
+
})
|
|
3832
|
+
.then(
|
|
3833
|
+
bound((r) => {
|
|
3834
|
+
if (r.type === 'opaqueredirect') {
|
|
3835
|
+
throw Object.assign(new Error(), {
|
|
3836
|
+
say: () => t('load.redirected', { url: url.href }),
|
|
3837
|
+
});
|
|
3838
|
+
}
|
|
3839
|
+
if (r.status === 401) {
|
|
3840
|
+
// Said alone: the address is right, and the token is what to change.
|
|
3841
|
+
throw Object.assign(new Error(), { say: () => t('load.unauthorized'), status: 401 });
|
|
3842
|
+
}
|
|
3843
|
+
if (!r.ok) {
|
|
3844
|
+
return r.text().then(
|
|
3845
|
+
bound((body) => {
|
|
3846
|
+
const said = serverMessage(body);
|
|
3847
|
+
const say = () => t('load.http', { status: r.status, message: said });
|
|
3848
|
+
throw Object.assign(new Error(), { say, status: r.status });
|
|
3849
|
+
}),
|
|
3850
|
+
);
|
|
3851
|
+
}
|
|
3852
|
+
name = fileName(r.headers.get('Content-Disposition')) || name;
|
|
3853
|
+
return r.text();
|
|
3854
|
+
}),
|
|
3855
|
+
)
|
|
3856
|
+
.then(
|
|
3857
|
+
bound((text) => {
|
|
3858
|
+
if (!fresh()) return;
|
|
3859
|
+
element.input = text;
|
|
3860
|
+
element.srcName = name;
|
|
3861
|
+
element.inputName = o.fileName || name;
|
|
3862
|
+
load(text, element.inputName);
|
|
3863
|
+
}),
|
|
3864
|
+
bound((e) => {
|
|
3865
|
+
if (!fresh() || (e && e.name === 'AbortError')) return;
|
|
3866
|
+
// 401 and a redirect are said alone (the address is right); other HTTP errors and a failed request
|
|
3867
|
+
// within load.failed (the address may be wrong).
|
|
3868
|
+
const alone = e.say && (e.status === 401 || !e.status);
|
|
3869
|
+
const say = alone
|
|
3870
|
+
? e.say
|
|
3871
|
+
: () => t('load.failed', { url: url.href, error: e.say ? e.say() : e.message });
|
|
3872
|
+
showError(say, e.status);
|
|
3873
|
+
}),
|
|
3874
|
+
);
|
|
3875
|
+
}
|
|
3876
|
+
|
|
3877
|
+
/** The message of a GUI server's error ({"error": {"message"}}; in English, as the server writes it), or ''. */
|
|
3878
|
+
function serverMessage(body) {
|
|
3879
|
+
try {
|
|
3880
|
+
const message = JSON.parse(body)?.error?.message;
|
|
3881
|
+
return typeof message === 'string' ? message : '';
|
|
3882
|
+
} catch {
|
|
3883
|
+
return '';
|
|
3884
|
+
}
|
|
3885
|
+
}
|
|
3886
|
+
|
|
3887
|
+
/** The file name of a Content-Disposition header (filename="..."), or null. */
|
|
3888
|
+
function fileName(header) {
|
|
3889
|
+
const match = /filename="([^"\\]+)"/.exec(header ?? '');
|
|
3890
|
+
return match ? match[1] : null;
|
|
3891
|
+
}
|
|
3892
|
+
|
|
3893
|
+
/** A text of messages.js into an element: a string, or an array of strings and [tag, text] (never parsed). */
|
|
3894
|
+
function fill(el, value) {
|
|
3895
|
+
const parts = Array.isArray(value) ? value : [value];
|
|
3896
|
+
el.replaceChildren(
|
|
3897
|
+
...parts.map((part) => (Array.isArray(part) ? h(part[0], { text: part[1] }) : part)),
|
|
3898
|
+
);
|
|
3899
|
+
}
|
|
3900
|
+
|
|
3901
|
+
/** Stops a load under way: its answer is dropped. */
|
|
3902
|
+
function stopLoad(element) {
|
|
3903
|
+
element.loads++;
|
|
3904
|
+
if (element.abort) element.abort.abort();
|
|
3905
|
+
element.abort = null;
|
|
3906
|
+
element.host.removeAttribute('aria-busy');
|
|
3907
|
+
}
|
|
3908
|
+
|
|
3909
|
+
/** Shows nothing: no file is given. */
|
|
3910
|
+
function clear() {
|
|
3911
|
+
stopLoad(current);
|
|
3912
|
+
current.input = null;
|
|
3913
|
+
current.inputName = null;
|
|
3914
|
+
state.model = null;
|
|
3915
|
+
state.file = null;
|
|
3916
|
+
state.lanes = [];
|
|
3917
|
+
clearError();
|
|
3918
|
+
$('view').hidden = true;
|
|
3919
|
+
$('title').textContent = t('page.title');
|
|
3920
|
+
$('facts').replaceChildren();
|
|
3921
|
+
}
|
|
3922
|
+
|
|
3923
|
+
// --- the element's parts, look and keys
|
|
3924
|
+
|
|
3925
|
+
/** The shadow root's contents. Texts come from messages.js (data-text, data-label) whenever the language changes. */
|
|
3926
|
+
function skeleton() {
|
|
3927
|
+
return [
|
|
3928
|
+
h(
|
|
3929
|
+
'header',
|
|
3930
|
+
{ id: 'head' },
|
|
3931
|
+
h(
|
|
3932
|
+
'div',
|
|
3933
|
+
{},
|
|
3934
|
+
h('h2', { id: 'title', 'data-text': 'page.title' }),
|
|
3935
|
+
h('div', { id: 'facts', class: 'small' }),
|
|
3936
|
+
),
|
|
3937
|
+
h('slot', { name: 'actions' }),
|
|
3938
|
+
),
|
|
3939
|
+
h('div', { id: 'error', role: 'alert', hidden: true }),
|
|
3940
|
+
h(
|
|
3941
|
+
'section',
|
|
3942
|
+
{ id: 'view', hidden: true },
|
|
3943
|
+
h('div', { id: 'summary' }),
|
|
3944
|
+
h(
|
|
3945
|
+
'div',
|
|
3946
|
+
{ id: 'toolbar', class: 'toolbar small' },
|
|
3947
|
+
h('span', { id: 'range', class: 'muted' }),
|
|
3948
|
+
h('button', { id: 'show-failure', type: 'button', 'data-text': 'page.showFailure' }),
|
|
3949
|
+
h('button', { id: 'show-all', type: 'button', 'data-text': 'page.whole' }),
|
|
3950
|
+
h('button', { id: 'zoom-out', type: 'button', 'data-text': 'page.zoomOut' }),
|
|
3951
|
+
h('span', { id: 'participants', class: 'toolbar' }),
|
|
3952
|
+
),
|
|
3953
|
+
h('p', { id: 'help', class: 'muted small', 'data-text': 'page.help' }),
|
|
3954
|
+
h('p', { id: 'chart-note', class: 'note small', role: 'status', hidden: true }),
|
|
3955
|
+
h('div', { id: 'chart', tabindex: '0', 'data-label': 'page.chartLabel' }),
|
|
3956
|
+
h('div', { id: 'tables' }),
|
|
3957
|
+
),
|
|
3958
|
+
];
|
|
3959
|
+
}
|
|
3960
|
+
|
|
3961
|
+
function translate() {
|
|
3962
|
+
for (const el of root.querySelectorAll('[data-text]')) fill(el, t(el.dataset.text));
|
|
3963
|
+
for (const el of root.querySelectorAll('[data-label]'))
|
|
3964
|
+
el.setAttribute('aria-label', t(el.dataset.label));
|
|
3965
|
+
if (!state.model) $('title').textContent = t('page.title');
|
|
3966
|
+
}
|
|
3967
|
+
|
|
3968
|
+
/** The buttons and keys of the chart. */
|
|
3969
|
+
function attachControls() {
|
|
3970
|
+
listen($('show-failure'), 'click', () => setView(initialView(state.model)));
|
|
3971
|
+
listen($('show-all'), 'click', () => setView(state.model.domain));
|
|
3972
|
+
listen($('zoom-out'), 'click', () => {
|
|
3973
|
+
const [t0, t1] = state.view;
|
|
3974
|
+
const half = t1 - t0;
|
|
3975
|
+
setView([t0 - half / 2, t1 + half / 2]);
|
|
3976
|
+
});
|
|
3977
|
+
const chart = $('chart');
|
|
3978
|
+
listen(chart, 'keydown', (e) => {
|
|
3979
|
+
if (!state.model) return;
|
|
3980
|
+
if (e.key === '+' || e.key === '=' || e.key === '-') {
|
|
3981
|
+
// Zoom in or out around the cursor (or the middle of the view).
|
|
3982
|
+
e.preventDefault();
|
|
3983
|
+
const [t0, t1] = state.view;
|
|
3984
|
+
const c = state.cursor ?? (t0 + t1) / 2;
|
|
3985
|
+
const k = e.key === '-' ? 2 : 0.5;
|
|
3986
|
+
setView([c - (c - t0) * k, c + (t1 - c) * k]);
|
|
3987
|
+
return;
|
|
3988
|
+
}
|
|
3989
|
+
if (e.key !== 'ArrowLeft' && e.key !== 'ArrowRight') return;
|
|
3990
|
+
e.preventDefault();
|
|
3991
|
+
const stepT =
|
|
3992
|
+
(state.model.timeStep ?? (state.view[1] - state.view[0]) / 100) * (e.shiftKey ? 10 : 1);
|
|
3993
|
+
const t = state.cursor ?? state.view[0];
|
|
3994
|
+
moveCursor(
|
|
3995
|
+
Math.min(
|
|
3996
|
+
state.view[1],
|
|
3997
|
+
Math.max(state.view[0], t + (e.key === 'ArrowLeft' ? -stepT : stepT)),
|
|
3998
|
+
),
|
|
3999
|
+
);
|
|
4000
|
+
});
|
|
4001
|
+
let lastWidth = 0;
|
|
4002
|
+
new ResizeObserver(
|
|
4003
|
+
bound(() => {
|
|
4004
|
+
const w = chart.clientWidth;
|
|
4005
|
+
if (state.model && w !== lastWidth) {
|
|
4006
|
+
lastWidth = w;
|
|
4007
|
+
renderChart();
|
|
4008
|
+
}
|
|
4009
|
+
}),
|
|
4010
|
+
).observe(chart);
|
|
4011
|
+
}
|
|
4012
|
+
|
|
4013
|
+
/** The style sheet of every element (timeline.css, which bundle.js puts into the one file), made once. */
|
|
4014
|
+
let sheet = null;
|
|
4015
|
+
function adoptStyles(shadow) {
|
|
4016
|
+
const css = global.VehicleSilTimelineStyles;
|
|
4017
|
+
if (typeof css !== 'string') return;
|
|
4018
|
+
if ('adoptedStyleSheets' in shadow && typeof CSSStyleSheet === 'function') {
|
|
4019
|
+
if (!sheet) {
|
|
4020
|
+
sheet = new CSSStyleSheet();
|
|
4021
|
+
sheet.replaceSync(css);
|
|
4022
|
+
}
|
|
4023
|
+
shadow.adoptedStyleSheets = [sheet];
|
|
4024
|
+
} else {
|
|
4025
|
+
shadow.append(h('style', { text: css }));
|
|
4026
|
+
}
|
|
4027
|
+
}
|
|
4028
|
+
|
|
4029
|
+
const number = (v) => {
|
|
4030
|
+
if (v === null || v === undefined || v === '') return null;
|
|
4031
|
+
const n = typeof v === 'number' ? v : Number(v);
|
|
4032
|
+
return Number.isFinite(n) ? n : null;
|
|
4033
|
+
};
|
|
4034
|
+
const list = (v) => {
|
|
4035
|
+
if (v === null || v === undefined) return null;
|
|
4036
|
+
const items = (Array.isArray(v) ? v.map(String) : String(v).split(/[\s,]+/)).filter(Boolean);
|
|
4037
|
+
return items.length ? items : null;
|
|
4038
|
+
};
|
|
4039
|
+
|
|
4040
|
+
/**
|
|
4041
|
+
* The simple options: attribute -> [property, kind, what a change redraws]. A string or boolean option is kept
|
|
4042
|
+
* in its attribute (the property sets it); a number or a list is kept as the property (the attribute sets it).
|
|
4043
|
+
*/
|
|
4044
|
+
const OPTIONS = {
|
|
4045
|
+
src: ['src', 'string', 'source'],
|
|
4046
|
+
'file-name': ['fileName', 'string', 'name'],
|
|
4047
|
+
cursor: ['cursor', 'number', 'cursor'],
|
|
4048
|
+
step: ['step', 'number', 'step'],
|
|
4049
|
+
from: ['from', 'number', 'from'],
|
|
4050
|
+
to: ['to', 'number', 'to'],
|
|
4051
|
+
variables: ['variables', 'list', 'chart'],
|
|
4052
|
+
hide: ['hide', 'string', 'none'],
|
|
4053
|
+
compact: ['compact', 'boolean', 'chart'],
|
|
4054
|
+
theme: ['theme', 'string', 'none'],
|
|
4055
|
+
};
|
|
4056
|
+
/** The words of hide and the values of theme that timeline.css reads. */
|
|
4057
|
+
const PARTS = ['header', 'summary', 'toolbar', 'help', 'steps', 'readout', 'legend', 'tables'];
|
|
4058
|
+
const THEMES = ['light', 'dark', 'auto'];
|
|
4059
|
+
|
|
4060
|
+
/**
|
|
4061
|
+
* Says once in the browser's console, for each element and value, that a value of an option cannot be used: it
|
|
4062
|
+
* is not an error of the file (the event error), but a mistake that the screen's author should see.
|
|
4063
|
+
*/
|
|
4064
|
+
function warn(c, key, args) {
|
|
4065
|
+
const said = `${key} ${JSON.stringify(args)}`;
|
|
4066
|
+
if (c.warned.has(said)) return;
|
|
4067
|
+
c.warned.add(said);
|
|
4068
|
+
console.warn(text(c.language, key, args, c.options.messages));
|
|
4069
|
+
}
|
|
4070
|
+
|
|
4071
|
+
/** Checks a value given to an option (an attribute or a property), and warns about one it cannot use. */
|
|
4072
|
+
function check(c, property, value) {
|
|
4073
|
+
if (['cursor', 'step', 'from', 'to'].includes(property)) {
|
|
4074
|
+
if (value !== null && value !== undefined && value !== '' && number(value) === null)
|
|
4075
|
+
warn(c, 'warn.number', { name: property, value: String(value) });
|
|
4076
|
+
const { from, to } = c.options;
|
|
4077
|
+
if ((property === 'from' || property === 'to') && isNum(from) && isNum(to) && from >= to)
|
|
4078
|
+
warn(c, 'warn.range', { from, to });
|
|
4079
|
+
} else if (property === 'hide') {
|
|
4080
|
+
for (const word of list(value) ?? [])
|
|
4081
|
+
if (!PARTS.includes(word)) warn(c, 'warn.hide', { value: word, known: PARTS.join(', ') });
|
|
4082
|
+
} else if (property === 'theme') {
|
|
4083
|
+
if (value !== null && value !== undefined && !THEMES.includes(String(value)))
|
|
4084
|
+
warn(c, 'warn.theme', { value: String(value) });
|
|
4085
|
+
}
|
|
4086
|
+
}
|
|
4087
|
+
|
|
4088
|
+
/** The options that are properties only (objects, and the token, which has no place in the page's markup). */
|
|
4089
|
+
const PROPERTIES = {
|
|
4090
|
+
data: 'source',
|
|
4091
|
+
token: 'source',
|
|
4092
|
+
headers: 'source',
|
|
4093
|
+
labels: 'chart',
|
|
4094
|
+
messages: 'language',
|
|
4095
|
+
};
|
|
4096
|
+
|
|
4097
|
+
class VehicleSilTimelineElement extends HTMLElement {
|
|
4098
|
+
static get observedAttributes() {
|
|
4099
|
+
return [...Object.keys(OPTIONS), 'lang'];
|
|
4100
|
+
}
|
|
4101
|
+
|
|
4102
|
+
/** What the drawing functions work on (current, when this element is drawn); not part of the element's API. */
|
|
4103
|
+
#c;
|
|
4104
|
+
|
|
4105
|
+
constructor() {
|
|
4106
|
+
super();
|
|
4107
|
+
const c = {
|
|
4108
|
+
host: this,
|
|
4109
|
+
root: this.attachShadow({ mode: 'open' }),
|
|
4110
|
+
state: newState(),
|
|
4111
|
+
options: {
|
|
4112
|
+
cursor: null,
|
|
4113
|
+
step: null,
|
|
4114
|
+
from: null,
|
|
4115
|
+
to: null,
|
|
4116
|
+
variables: null,
|
|
4117
|
+
compact: false,
|
|
4118
|
+
data: null,
|
|
4119
|
+
token: null,
|
|
4120
|
+
headers: null,
|
|
4121
|
+
labels: null,
|
|
4122
|
+
messages: null,
|
|
4123
|
+
},
|
|
4124
|
+
language: 'en',
|
|
4125
|
+
/** Whether a change comes from outside (a property or an attribute): it is not told back with an event. */
|
|
4126
|
+
quiet: false,
|
|
4127
|
+
/** The number of the latest load, and how to stop it: an older answer is dropped. */
|
|
4128
|
+
loads: 0,
|
|
4129
|
+
abort: null,
|
|
4130
|
+
/** What is shown (the text or the object, and its name), to draw it again in another language. */
|
|
4131
|
+
input: null,
|
|
4132
|
+
inputName: null,
|
|
4133
|
+
/** The name the server gave the file of src. */
|
|
4134
|
+
srcName: null,
|
|
4135
|
+
/** The refusal shown ({ say, status }), said again in another language. */
|
|
4136
|
+
error: null,
|
|
4137
|
+
/** The values already warned about (see warn). */
|
|
4138
|
+
warned: new Set(),
|
|
4139
|
+
changes: new Set(['source', 'language']),
|
|
4140
|
+
scheduled: false,
|
|
4141
|
+
};
|
|
4142
|
+
this.#c = c;
|
|
4143
|
+
adoptStyles(c.root);
|
|
4144
|
+
c.root.append(...skeleton());
|
|
4145
|
+
enter(c);
|
|
4146
|
+
attachControls();
|
|
4147
|
+
}
|
|
4148
|
+
|
|
4149
|
+
connectedCallback() {
|
|
4150
|
+
// A property set before this script defined the element hides the class's accessor: set it again.
|
|
4151
|
+
for (const name of [...Object.values(OPTIONS).map(([p]) => p), ...Object.keys(PROPERTIES)]) {
|
|
4152
|
+
if (Object.prototype.hasOwnProperty.call(this, name)) {
|
|
4153
|
+
const value = this[name];
|
|
4154
|
+
delete this[name];
|
|
4155
|
+
this[name] = value;
|
|
4156
|
+
}
|
|
4157
|
+
}
|
|
4158
|
+
this.#schedule();
|
|
4159
|
+
}
|
|
4160
|
+
|
|
4161
|
+
disconnectedCallback() {
|
|
4162
|
+
// A load under way stops, and starts again when the element is put back (a framework may move it).
|
|
4163
|
+
const c = this.#c;
|
|
4164
|
+
if (c.abort) {
|
|
4165
|
+
stopLoad(c);
|
|
4166
|
+
c.changes.add('source');
|
|
4167
|
+
}
|
|
4168
|
+
}
|
|
4169
|
+
|
|
4170
|
+
attributeChangedCallback(name, before, after) {
|
|
4171
|
+
if (name === 'lang') return this.#change('language');
|
|
4172
|
+
const [property, kind, what] = OPTIONS[name];
|
|
4173
|
+
const c = this.#c;
|
|
4174
|
+
const o = c.options;
|
|
4175
|
+
if (name === 'hide' && after !== null && after.includes(',')) {
|
|
4176
|
+
// timeline.css reads words separated by spaces; commas are taken as for variables
|
|
4177
|
+
this.setAttribute('hide', (list(after) ?? []).join(' '));
|
|
4178
|
+
return;
|
|
4179
|
+
}
|
|
4180
|
+
if (kind === 'number') o[property] = number(after);
|
|
4181
|
+
else if (kind === 'list') o[property] = list(after);
|
|
4182
|
+
else if (kind === 'boolean') o[property] = after !== null;
|
|
4183
|
+
check(c, property, after);
|
|
4184
|
+
// A number set again applies again: the user may have moved the cursor or the view since.
|
|
4185
|
+
this.#change(what, before !== after || what === 'source' || kind === 'number');
|
|
4186
|
+
}
|
|
4187
|
+
|
|
4188
|
+
/** Redraws what a change needs, once for all the changes made at the same time. */
|
|
4189
|
+
#change(what, really = true) {
|
|
4190
|
+
if (!really || what === 'none') return;
|
|
4191
|
+
this.#c.changes.add(what);
|
|
4192
|
+
this.#schedule();
|
|
4193
|
+
}
|
|
4194
|
+
|
|
4195
|
+
/** Draws the changes made so far, once, after the code that made them. */
|
|
4196
|
+
#schedule() {
|
|
4197
|
+
const c = this.#c;
|
|
4198
|
+
if (c.scheduled || !this.isConnected) return;
|
|
4199
|
+
c.scheduled = true;
|
|
4200
|
+
queueMicrotask(() => this.#flush());
|
|
4201
|
+
}
|
|
4202
|
+
|
|
4203
|
+
#flush() {
|
|
4204
|
+
const c = this.#c;
|
|
4205
|
+
c.scheduled = false;
|
|
4206
|
+
if (!this.isConnected) return;
|
|
4207
|
+
const what = c.changes;
|
|
4208
|
+
c.changes = new Set();
|
|
4209
|
+
const o = c.options;
|
|
4210
|
+
const known = [...LANGUAGES, ...Object.keys(isObject(o.messages) ? o.messages : {})];
|
|
4211
|
+
const navigatorLanguages = navigator.languages ?? [navigator.language];
|
|
4212
|
+
c.language = chooseLanguage([this.getAttribute('lang'), ...navigatorLanguages], known);
|
|
4213
|
+
c.quiet = true;
|
|
4214
|
+
try {
|
|
4215
|
+
enter(c);
|
|
4216
|
+
if (what.has('language')) translate();
|
|
4217
|
+
if (what.has('source')) {
|
|
4218
|
+
if (o.data !== null && o.data !== undefined) {
|
|
4219
|
+
stopLoad(c);
|
|
4220
|
+
c.input = o.data;
|
|
4221
|
+
c.inputName = this.fileName || null;
|
|
4222
|
+
load(o.data, c.inputName);
|
|
4223
|
+
} else if (this.src) {
|
|
4224
|
+
fromSrc(this.src);
|
|
4225
|
+
} else {
|
|
4226
|
+
clear();
|
|
4227
|
+
}
|
|
4228
|
+
} else if (what.has('language') && c.input !== null) {
|
|
4229
|
+
load(c.input, c.inputName, true);
|
|
4230
|
+
} else if (what.has('language') && c.error) {
|
|
4231
|
+
showError(c.error.say, c.error.status, false, true);
|
|
4232
|
+
} else if (what.has('chart') && state.model) {
|
|
4233
|
+
renderChart();
|
|
4234
|
+
}
|
|
4235
|
+
if (what.has('name') && !what.has('source') && state.model) {
|
|
4236
|
+
// Only the name shown changes: the file is not loaded again.
|
|
4237
|
+
c.inputName = this.fileName || (o.data === null ? c.srcName : null);
|
|
4238
|
+
state.file = c.inputName;
|
|
4239
|
+
renderHeader(state.model);
|
|
4240
|
+
}
|
|
4241
|
+
if (!state.model) return;
|
|
4242
|
+
if (what.has('step')) showStep(stepOf(o.step) ?? null);
|
|
4243
|
+
if (what.has('from') || what.has('to')) {
|
|
4244
|
+
// A side not given now stays where the view is (the user may have moved it).
|
|
4245
|
+
const from = what.has('from') && o.from !== null ? o.from : state.view[0];
|
|
4246
|
+
const to = what.has('to') && o.to !== null ? o.to : state.view[1];
|
|
4247
|
+
setView([from, to]);
|
|
4248
|
+
}
|
|
4249
|
+
if (what.has('cursor')) {
|
|
4250
|
+
state.cursor = o.cursor;
|
|
4251
|
+
updateCursor();
|
|
4252
|
+
}
|
|
4253
|
+
} finally {
|
|
4254
|
+
c.quiet = false;
|
|
4255
|
+
}
|
|
4256
|
+
}
|
|
4257
|
+
|
|
4258
|
+
/** Loads src again (the file may have changed, or the token). */
|
|
4259
|
+
reload() {
|
|
4260
|
+
this.#change('source');
|
|
4261
|
+
}
|
|
4262
|
+
|
|
4263
|
+
// --- the simple options
|
|
4264
|
+
|
|
4265
|
+
get src() {
|
|
4266
|
+
return this.getAttribute('src') ?? '';
|
|
4267
|
+
}
|
|
4268
|
+
set src(v) {
|
|
4269
|
+
this.#setOrRemove('src', v === null || v === undefined || v === '' ? null : String(v));
|
|
4270
|
+
}
|
|
4271
|
+
get fileName() {
|
|
4272
|
+
return this.getAttribute('file-name') ?? '';
|
|
4273
|
+
}
|
|
4274
|
+
set fileName(v) {
|
|
4275
|
+
this.#setOrRemove('file-name', v === null || v === undefined || v === '' ? null : String(v));
|
|
4276
|
+
}
|
|
4277
|
+
get hide() {
|
|
4278
|
+
return this.getAttribute('hide') ?? '';
|
|
4279
|
+
}
|
|
4280
|
+
set hide(v) {
|
|
4281
|
+
const words = list(v);
|
|
4282
|
+
this.#setOrRemove('hide', words ? words.join(' ') : null);
|
|
4283
|
+
}
|
|
4284
|
+
get theme() {
|
|
4285
|
+
return this.getAttribute('theme') ?? 'auto';
|
|
4286
|
+
}
|
|
4287
|
+
set theme(v) {
|
|
4288
|
+
this.#setOrRemove('theme', v === null || v === undefined || v === '' ? null : String(v));
|
|
4289
|
+
}
|
|
4290
|
+
get compact() {
|
|
4291
|
+
return this.hasAttribute('compact');
|
|
4292
|
+
}
|
|
4293
|
+
set compact(v) {
|
|
4294
|
+
this.toggleAttribute('compact', Boolean(v));
|
|
4295
|
+
}
|
|
4296
|
+
get variables() {
|
|
4297
|
+
return this.#c.options.variables ? [...this.#c.options.variables] : null;
|
|
4298
|
+
}
|
|
4299
|
+
set variables(v) {
|
|
4300
|
+
this.#c.options.variables = list(v);
|
|
4301
|
+
this.#change('chart');
|
|
4302
|
+
}
|
|
4303
|
+
get cursor() {
|
|
4304
|
+
return this.#c.changes.has('cursor') || !this.#c.state.model
|
|
4305
|
+
? this.#c.options.cursor
|
|
4306
|
+
: this.#c.state.cursor;
|
|
4307
|
+
}
|
|
4308
|
+
set cursor(v) {
|
|
4309
|
+
check(this.#c, 'cursor', v);
|
|
4310
|
+
this.#c.options.cursor = number(v);
|
|
4311
|
+
this.#change('cursor');
|
|
4312
|
+
}
|
|
4313
|
+
get step() {
|
|
4314
|
+
return this.#c.changes.has('step') || !this.#c.state.model
|
|
4315
|
+
? this.#c.options.step
|
|
4316
|
+
: this.#c.state.step;
|
|
4317
|
+
}
|
|
4318
|
+
set step(v) {
|
|
4319
|
+
check(this.#c, 'step', v);
|
|
4320
|
+
this.#c.options.step = number(v);
|
|
4321
|
+
this.#change('step');
|
|
4322
|
+
}
|
|
4323
|
+
get from() {
|
|
4324
|
+
return this.#c.changes.has('from') || !this.#c.state.view
|
|
4325
|
+
? this.#c.options.from
|
|
4326
|
+
: this.#c.state.view[0];
|
|
4327
|
+
}
|
|
4328
|
+
set from(v) {
|
|
4329
|
+
this.#c.options.from = number(v);
|
|
4330
|
+
check(this.#c, 'from', v);
|
|
4331
|
+
this.#change('from');
|
|
4332
|
+
}
|
|
4333
|
+
get to() {
|
|
4334
|
+
return this.#c.changes.has('to') || !this.#c.state.view
|
|
4335
|
+
? this.#c.options.to
|
|
4336
|
+
: this.#c.state.view[1];
|
|
4337
|
+
}
|
|
4338
|
+
set to(v) {
|
|
4339
|
+
this.#c.options.to = number(v);
|
|
4340
|
+
check(this.#c, 'to', v);
|
|
4341
|
+
this.#change('to');
|
|
4342
|
+
}
|
|
4343
|
+
|
|
4344
|
+
// --- the options that are properties only
|
|
4345
|
+
|
|
4346
|
+
get data() {
|
|
4347
|
+
return this.#c.options.data;
|
|
4348
|
+
}
|
|
4349
|
+
set data(v) {
|
|
4350
|
+
this.#c.options.data = v === undefined ? null : v;
|
|
4351
|
+
this.#change('source');
|
|
4352
|
+
}
|
|
4353
|
+
get token() {
|
|
4354
|
+
return this.#c.options.token;
|
|
4355
|
+
}
|
|
4356
|
+
set token(v) {
|
|
4357
|
+
this.#c.options.token = typeof v === 'string' && v !== '' ? v : null;
|
|
4358
|
+
this.#change('source', !this.#c.options.data);
|
|
4359
|
+
}
|
|
4360
|
+
get headers() {
|
|
4361
|
+
return this.#c.options.headers;
|
|
4362
|
+
}
|
|
4363
|
+
set headers(v) {
|
|
4364
|
+
this.#c.options.headers = isObject(v) ? v : null;
|
|
4365
|
+
this.#change('source', !this.#c.options.data);
|
|
4366
|
+
}
|
|
4367
|
+
get labels() {
|
|
4368
|
+
return this.#c.options.labels;
|
|
4369
|
+
}
|
|
4370
|
+
set labels(v) {
|
|
4371
|
+
this.#c.options.labels = isObject(v) ? v : null;
|
|
4372
|
+
this.#change('chart');
|
|
4373
|
+
}
|
|
4374
|
+
get messages() {
|
|
4375
|
+
return this.#c.options.messages;
|
|
4376
|
+
}
|
|
4377
|
+
set messages(v) {
|
|
4378
|
+
this.#c.options.messages = isObject(v) ? v : null;
|
|
4379
|
+
this.#change('language');
|
|
4380
|
+
}
|
|
4381
|
+
|
|
4382
|
+
#setOrRemove(name, value) {
|
|
4383
|
+
if (value === null) this.removeAttribute(name);
|
|
4384
|
+
else this.setAttribute(name, value);
|
|
4385
|
+
}
|
|
4386
|
+
}
|
|
4387
|
+
|
|
4388
|
+
api.Element = VehicleSilTimelineElement;
|
|
4389
|
+
if (!customElements.get('vehicle-sil-timeline'))
|
|
4390
|
+
customElements.define('vehicle-sil-timeline', VehicleSilTimelineElement);
|
|
4391
|
+
})(globalThis);
|
|
4392
|
+
|
|
4393
|
+
export {};
|