@m4l/gclick-realtime 1.0.4 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/contracts/constants.d.ts +2 -1
- package/contracts/constants.d.ts.map +1 -1
- package/contracts/constants.js +1 -1
- package/contracts/deviceData.d.ts +30 -20
- package/contracts/deviceData.d.ts.map +1 -1
- package/contracts/deviceDetail.d.ts +71 -0
- package/contracts/deviceDetail.d.ts.map +1 -0
- package/contracts/index.d.ts +3 -2
- package/contracts/index.d.ts.map +1 -1
- package/contracts/vpts.d.ts +84 -27
- package/contracts/vpts.d.ts.map +1 -1
- package/dummy/catalogs/baseDeviceTemplate.d.ts +1 -1
- package/dummy/catalogs/baseDeviceTemplate.d.ts.map +1 -1
- package/dummy/catalogs/baseDeviceTemplate.js +14 -10
- package/dummy/catalogs/blueprints.d.ts +8 -8
- package/dummy/catalogs/blueprints.js +40 -40
- package/dummy/catalogs/plans.d.ts +14 -0
- package/dummy/catalogs/plans.d.ts.map +1 -1
- package/dummy/catalogs/plans.js +34 -6
- package/dummy/catalogs/scenarios.d.ts +73 -0
- package/dummy/catalogs/scenarios.d.ts.map +1 -1
- package/dummy/catalogs/scenarios.js +80 -0
- package/dummy/runtime/dummy.d.ts.map +1 -1
- package/dummy/runtime/dummy.js +27 -24
- package/dummy/runtime/simulation.d.ts.map +1 -1
- package/dummy/runtime/simulation.js +349 -325
- package/dummy/shared/types.d.ts +6 -1
- package/dummy/shared/types.d.ts.map +1 -1
- package/fixtures/constants.d.ts +11 -2
- package/fixtures/constants.d.ts.map +1 -1
- package/fixtures/constants.js +15 -2
- package/fixtures/scenarios.d.ts +36 -0
- package/fixtures/scenarios.d.ts.map +1 -1
- package/fixtures/scenarios.js +36 -0
- package/fixtures/types.d.ts +2 -1
- package/fixtures/types.d.ts.map +1 -1
- package/fixtures/types.js +1 -1
- package/package.json +1 -1
- package/payload/getVptValueWithGuard.js +1 -1
- package/web/host/hostRuntime.d.ts.map +1 -1
- package/web/host/hostRuntime.js +13 -13
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import { getVptValueWithGuard as
|
|
2
|
-
import { GNSSEnumSignal as S, GNSSEnumMotionStatus as
|
|
3
|
-
import { calculateDistanceMeters as
|
|
4
|
-
import { createRealTimeDummySimulationConfigFromPreset as te, REAL_TIME_DUMMY_SIMULATION_PRESETS as
|
|
5
|
-
import { REAL_TIME_DUMMY_DEFAULT_SCENARIO_ID as
|
|
1
|
+
import { getVptValueWithGuard as b } from "../../payload/getVptValueWithGuard.js";
|
|
2
|
+
import { GNSSEnumSignal as S, GNSSEnumMotionStatus as l, ADCPowerEnum as I } from "../../contracts/constants.js";
|
|
3
|
+
import { calculateDistanceMeters as B, calculatePolylineDistanceMeters as z, resolveFrameSpeedKph as J, interpolateCoordinate as Q, calculateCourseDegrees as ee } from "../shared/helpers.js";
|
|
4
|
+
import { createRealTimeDummySimulationConfigFromPreset as te, REAL_TIME_DUMMY_SIMULATION_PRESETS as se } from "../catalogs/presets.js";
|
|
5
|
+
import { REAL_TIME_DUMMY_DEFAULT_SCENARIO_ID as ne, REAL_TIME_DUMMY_SCENARIOS as G, REAL_TIME_DUMMY_DEFAULT_PLAYBACK as T } from "../catalogs/scenarios.js";
|
|
6
6
|
import M from "../../node_modules/lodash-es/cloneDeep.js";
|
|
7
7
|
import { REAL_TIME_DUMMY_ROUTE_TEMPLATES as U } from "../catalogs/routes.js";
|
|
8
8
|
import { REAL_TIME_DUMMY_EXECUTION_PLANS as x } from "../catalogs/plans.js";
|
|
9
9
|
import { REAL_TIME_DUMMY_DEVICE_BLUEPRINTS as F } from "../catalogs/blueprints.js";
|
|
10
|
-
import
|
|
10
|
+
import w from "../../node_modules/lodash-es/merge.js";
|
|
11
11
|
import { REAL_TIME_DUMMY_DEFAULT_ICON_ID as oe, REAL_TIME_DUMMY_BASE_DEVICE_TEMPLATE as ie } from "../catalogs/baseDeviceTemplate.js";
|
|
12
|
-
import
|
|
13
|
-
const
|
|
12
|
+
import E from "../../node_modules/lodash-es/unset.js";
|
|
13
|
+
const X = Date.parse("2026-04-21T12:00:00.000Z"), $ = [
|
|
14
14
|
"gnssCourse",
|
|
15
15
|
"gnssLatitude",
|
|
16
16
|
"gnssLongitude",
|
|
17
17
|
"gnssSpeed"
|
|
18
18
|
];
|
|
19
|
-
function C(e,
|
|
20
|
-
return Object.hasOwn(e,
|
|
19
|
+
function C(e, s) {
|
|
20
|
+
return Object.hasOwn(e, s);
|
|
21
21
|
}
|
|
22
22
|
function ae(e) {
|
|
23
23
|
if (e)
|
|
@@ -35,40 +35,40 @@ function re(e) {
|
|
|
35
35
|
name: e.name
|
|
36
36
|
};
|
|
37
37
|
}
|
|
38
|
-
function y(e,
|
|
38
|
+
function y(e, s) {
|
|
39
39
|
if (!e)
|
|
40
40
|
return e;
|
|
41
41
|
const t = Date.parse(e);
|
|
42
42
|
return Number.isFinite(t) ? new Date(
|
|
43
|
-
|
|
43
|
+
s + (t - X)
|
|
44
44
|
).toISOString() : e;
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function O(e) {
|
|
47
47
|
return typeof e == "object" && e !== null && "value" in e;
|
|
48
48
|
}
|
|
49
|
-
function ce(e,
|
|
50
|
-
const o = e.vpts?.vptGnss?.[
|
|
51
|
-
|
|
49
|
+
function ce(e, s, t) {
|
|
50
|
+
const o = e.vpts?.vptGnss?.[s];
|
|
51
|
+
O(o) && (o.updatedAt = y(
|
|
52
52
|
o.updatedAt,
|
|
53
53
|
t
|
|
54
54
|
));
|
|
55
55
|
}
|
|
56
|
-
function le(e,
|
|
57
|
-
const o = e.vpts?.vptGnss?.[
|
|
58
|
-
|
|
56
|
+
function le(e, s, t) {
|
|
57
|
+
const o = e.vpts?.vptGnss?.[s];
|
|
58
|
+
O(o) && (o.updatedAt = t);
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
return
|
|
60
|
+
function k(e, s, t) {
|
|
61
|
+
return O(e) ? {
|
|
62
62
|
...e,
|
|
63
63
|
updatedAt: t,
|
|
64
|
-
value:
|
|
65
|
-
} :
|
|
64
|
+
value: s
|
|
65
|
+
} : s;
|
|
66
66
|
}
|
|
67
|
-
function
|
|
67
|
+
function P(e, s) {
|
|
68
68
|
if (e.reportProfiles?.trackerEvents) {
|
|
69
69
|
const t = y(
|
|
70
70
|
e.reportProfiles.trackerEvents.modemLastEvent?.date,
|
|
71
|
-
|
|
71
|
+
s
|
|
72
72
|
);
|
|
73
73
|
e.reportProfiles.trackerEvents.modemLastEvent && t && (e.reportProfiles.trackerEvents.modemLastEvent = {
|
|
74
74
|
...e.reportProfiles.trackerEvents.modemLastEvent,
|
|
@@ -78,89 +78,95 @@ function X(e, n) {
|
|
|
78
78
|
if (Object.values(e.vpts?.vptDiX ?? {}).forEach((t) => {
|
|
79
79
|
t.diXStatus && (t.diXStatus.updatedAt = y(
|
|
80
80
|
t.diXStatus.updatedAt,
|
|
81
|
-
|
|
81
|
+
s
|
|
82
82
|
)), t.diXValue && (t.diXValue.updatedAt = y(
|
|
83
83
|
t.diXValue.updatedAt,
|
|
84
|
-
|
|
84
|
+
s
|
|
85
85
|
));
|
|
86
86
|
}), Object.values(e.vpts?.vptDoX ?? {}).forEach((t) => {
|
|
87
87
|
t.diXValue && (t.diXValue.updatedAt = y(
|
|
88
88
|
t.diXValue.updatedAt,
|
|
89
|
-
|
|
89
|
+
s
|
|
90
90
|
));
|
|
91
91
|
}), e.vpts?.vptGnss?.gnssMotionStatus && (e.vpts.vptGnss.gnssMotionStatus.updatedAt = y(
|
|
92
92
|
e.vpts.vptGnss.gnssMotionStatus.updatedAt,
|
|
93
|
-
|
|
93
|
+
s
|
|
94
94
|
)), e.vpts?.vptGnss?.gnssSignal && (e.vpts.vptGnss.gnssSignal.updatedAt = y(
|
|
95
95
|
e.vpts.vptGnss.gnssSignal.updatedAt,
|
|
96
|
-
|
|
96
|
+
s
|
|
97
97
|
)), e.vpts?.vptIgnition?.ignitionValue && (e.vpts.vptIgnition.ignitionValue.updatedAt = y(
|
|
98
98
|
e.vpts.vptIgnition.ignitionValue.updatedAt,
|
|
99
|
-
|
|
99
|
+
s
|
|
100
100
|
)), $.forEach((t) => {
|
|
101
|
-
ce(e, t,
|
|
102
|
-
}), e.vpts?.
|
|
101
|
+
ce(e, t, s);
|
|
102
|
+
}), e.vpts?.vptNetwork) {
|
|
103
103
|
const t = y(
|
|
104
|
-
e.vpts.
|
|
105
|
-
|
|
104
|
+
e.vpts.vptNetwork.lastConnection,
|
|
105
|
+
s
|
|
106
106
|
), o = y(
|
|
107
|
-
e.vpts.
|
|
108
|
-
|
|
107
|
+
e.vpts.vptNetwork.lastEvent?.date,
|
|
108
|
+
s
|
|
109
109
|
);
|
|
110
|
-
t && (e.vpts.
|
|
110
|
+
t && (e.vpts.vptNetwork.lastConnection = t), e.vpts.vptNetwork.lastEvent && o && (e.vpts.vptNetwork.lastEvent = {
|
|
111
|
+
...e.vpts.vptNetwork.lastEvent,
|
|
112
|
+
date: o
|
|
113
|
+
});
|
|
111
114
|
}
|
|
112
115
|
return e;
|
|
113
116
|
}
|
|
114
|
-
function ue(e,
|
|
117
|
+
function ue(e, s) {
|
|
115
118
|
const t = M(e);
|
|
116
|
-
return
|
|
119
|
+
return P(t.current, s), t;
|
|
117
120
|
}
|
|
118
|
-
function de(e,
|
|
119
|
-
const t = M(e), o = new Date(
|
|
121
|
+
function de(e, s) {
|
|
122
|
+
const t = M(e), o = new Date(s).toISOString();
|
|
120
123
|
return t.current.reportProfiles?.trackerEvents?.modemLastEvent && (t.current.reportProfiles.trackerEvents.modemLastEvent = {
|
|
121
124
|
...t.current.reportProfiles.trackerEvents.modemLastEvent,
|
|
122
125
|
date: o
|
|
123
|
-
}), Object.values(t.current.vpts?.vptDiX ?? {}).forEach((
|
|
124
|
-
|
|
125
|
-
}), Object.values(t.current.vpts?.vptDoX ?? {}).forEach((
|
|
126
|
-
|
|
127
|
-
}), t.current.vpts?.vptGnss?.gnssMotionStatus && (t.current.vpts.vptGnss.gnssMotionStatus.updatedAt = o), t.current.vpts?.vptGnss?.gnssSignal && (t.current.vpts.vptGnss.gnssSignal.updatedAt = o), t.current.vpts?.vptIgnition?.ignitionValue && (t.current.vpts.vptIgnition.ignitionValue.updatedAt = o), $.forEach((
|
|
126
|
+
}), Object.values(t.current.vpts?.vptDiX ?? {}).forEach((n) => {
|
|
127
|
+
n.diXStatus && (n.diXStatus.updatedAt = o), n.diXValue && (n.diXValue.updatedAt = o);
|
|
128
|
+
}), Object.values(t.current.vpts?.vptDoX ?? {}).forEach((n) => {
|
|
129
|
+
n.diXValue && (n.diXValue.updatedAt = o);
|
|
130
|
+
}), t.current.vpts?.vptGnss?.gnssMotionStatus && (t.current.vpts.vptGnss.gnssMotionStatus.updatedAt = o), t.current.vpts?.vptGnss?.gnssSignal && (t.current.vpts.vptGnss.gnssSignal.updatedAt = o), t.current.vpts?.vptIgnition?.ignitionValue && (t.current.vpts.vptIgnition.ignitionValue.updatedAt = o), $.forEach((n) => {
|
|
128
131
|
le(
|
|
129
132
|
t.current,
|
|
130
|
-
|
|
133
|
+
n,
|
|
131
134
|
o
|
|
132
135
|
);
|
|
133
|
-
}), t.current.vpts?.
|
|
136
|
+
}), t.current.vpts?.vptNetwork && (t.current.vpts.vptNetwork.lastConnection && (t.current.vpts.vptNetwork.lastConnection = o), t.current.vpts.vptNetwork.lastEvent && (t.current.vpts.vptNetwork.lastEvent = {
|
|
137
|
+
...t.current.vpts.vptNetwork.lastEvent,
|
|
138
|
+
date: o
|
|
139
|
+
})), t;
|
|
134
140
|
}
|
|
135
|
-
function pe(e,
|
|
141
|
+
function pe(e, s) {
|
|
136
142
|
const t = M(e);
|
|
137
143
|
if (t.type === "delete")
|
|
138
144
|
return t;
|
|
139
145
|
if (t.type === "new") {
|
|
140
146
|
const o = t.payload;
|
|
141
|
-
return
|
|
147
|
+
return P(o.current, s), t;
|
|
142
148
|
}
|
|
143
|
-
return
|
|
149
|
+
return P(
|
|
144
150
|
t.payload.current,
|
|
145
|
-
|
|
151
|
+
s
|
|
146
152
|
), t;
|
|
147
153
|
}
|
|
148
|
-
function K(e,
|
|
154
|
+
function K(e, s) {
|
|
149
155
|
return {
|
|
150
|
-
...
|
|
156
|
+
...T,
|
|
151
157
|
...e,
|
|
152
|
-
...
|
|
158
|
+
...s,
|
|
153
159
|
framesPerTick: Math.max(
|
|
154
160
|
1,
|
|
155
|
-
|
|
161
|
+
s?.framesPerTick ?? e?.framesPerTick ?? T.framesPerTick
|
|
156
162
|
),
|
|
157
163
|
intervalMs: Math.max(
|
|
158
164
|
1,
|
|
159
|
-
|
|
165
|
+
s?.intervalMs ?? e?.intervalMs ?? T.intervalMs
|
|
160
166
|
),
|
|
161
167
|
logicalSampleSeconds: Math.max(
|
|
162
168
|
1,
|
|
163
|
-
|
|
169
|
+
s?.logicalSampleSeconds ?? e?.logicalSampleSeconds ?? T.logicalSampleSeconds
|
|
164
170
|
)
|
|
165
171
|
};
|
|
166
172
|
}
|
|
@@ -180,29 +186,29 @@ function ge(e) {
|
|
|
180
186
|
return x[e];
|
|
181
187
|
}
|
|
182
188
|
function fe(e) {
|
|
183
|
-
const
|
|
184
|
-
if (!
|
|
189
|
+
const s = se[e];
|
|
190
|
+
if (!s)
|
|
185
191
|
throw new Error(`Unknown dummy simulation preset "${e}"`);
|
|
186
|
-
return
|
|
192
|
+
return s;
|
|
187
193
|
}
|
|
188
194
|
function Me(e) {
|
|
189
|
-
const
|
|
190
|
-
(t, o,
|
|
195
|
+
const s = e.reduce(
|
|
196
|
+
(t, o, n, i) => {
|
|
191
197
|
const a = o.assignment.resourceSerialId;
|
|
192
|
-
return i.findIndex((c) => c.assignment.resourceSerialId === a) !==
|
|
198
|
+
return i.findIndex((c) => c.assignment.resourceSerialId === a) !== n && !t.includes(a) && t.push(a), t;
|
|
193
199
|
},
|
|
194
200
|
[]
|
|
195
201
|
);
|
|
196
|
-
if (
|
|
202
|
+
if (s.length)
|
|
197
203
|
throw new Error(
|
|
198
|
-
`Dummy simulation resolved duplicate device ids: ${
|
|
204
|
+
`Dummy simulation resolved duplicate device ids: ${s.join(", ")}. Each preset must contribute its own unique resourceSerialId values.`
|
|
199
205
|
);
|
|
200
206
|
}
|
|
201
207
|
function ye(e) {
|
|
202
|
-
const
|
|
208
|
+
const s = e?.presetId, t = s ? fe(s).simulation : void 0, o = e?.scenarioId ?? t?.scenarioId ?? ne;
|
|
203
209
|
if (!C(G, o))
|
|
204
210
|
throw new Error(`Unknown dummy scenario "${o}"`);
|
|
205
|
-
const
|
|
211
|
+
const n = G[o], i = (e?.devices ?? t?.devices ?? n.devices).map(
|
|
206
212
|
(a) => ({
|
|
207
213
|
assignment: a,
|
|
208
214
|
blueprint: me(a.blueprintId),
|
|
@@ -213,7 +219,7 @@ function ye(e) {
|
|
|
213
219
|
return Me(i), {
|
|
214
220
|
devices: i,
|
|
215
221
|
playback: K(
|
|
216
|
-
K(
|
|
222
|
+
K(n.playback, t?.playback),
|
|
217
223
|
e?.playback
|
|
218
224
|
)
|
|
219
225
|
};
|
|
@@ -249,177 +255,189 @@ function Se(e) {
|
|
|
249
255
|
};
|
|
250
256
|
}
|
|
251
257
|
}
|
|
252
|
-
function
|
|
253
|
-
return Math.min(t, Math.max(
|
|
258
|
+
function _(e, s, t) {
|
|
259
|
+
return Math.min(t, Math.max(s, e));
|
|
254
260
|
}
|
|
255
261
|
function q(e) {
|
|
256
262
|
return Math.round(e * 10) / 10;
|
|
257
263
|
}
|
|
258
|
-
function
|
|
259
|
-
return e <= 0 ?
|
|
264
|
+
function R(e, s) {
|
|
265
|
+
return e <= 0 ? I.lost : s === "12" ? e >= 12.4 ? I.ok : I.low : e >= 24.8 ? I.ok : I.low;
|
|
260
266
|
}
|
|
261
|
-
function
|
|
262
|
-
const
|
|
263
|
-
return Math.round(
|
|
267
|
+
function Y(e) {
|
|
268
|
+
const s = (e - 24.3) / 3.599999999999998;
|
|
269
|
+
return Math.round(_(s, 0, 1) * 100);
|
|
264
270
|
}
|
|
265
|
-
function
|
|
266
|
-
const t = [0, 0.04, -0.03, 0.06, -0.02], o = t[
|
|
267
|
-
let
|
|
271
|
+
function A(e, s) {
|
|
272
|
+
const t = [0, 0.04, -0.03, 0.06, -0.02], o = t[s % t.length] ?? 0;
|
|
273
|
+
let n = e.ignition ? 13.6 : 12.3;
|
|
268
274
|
switch (e.motionStatus) {
|
|
269
|
-
case
|
|
270
|
-
|
|
275
|
+
case l.notDetectable:
|
|
276
|
+
n = e.ignition ? 12.4 : 12.1;
|
|
271
277
|
break;
|
|
272
|
-
case
|
|
273
|
-
|
|
278
|
+
case l.off:
|
|
279
|
+
n = 12.2;
|
|
274
280
|
break;
|
|
275
|
-
case
|
|
276
|
-
|
|
281
|
+
case l.towing:
|
|
282
|
+
n = 12.1;
|
|
277
283
|
break;
|
|
278
|
-
case
|
|
279
|
-
|
|
284
|
+
case l.stopped:
|
|
285
|
+
n = e.ignition ? 12.5 : 12.2;
|
|
280
286
|
break;
|
|
281
|
-
case
|
|
282
|
-
|
|
287
|
+
case l.stoppedRalenti:
|
|
288
|
+
n = 13.4;
|
|
283
289
|
break;
|
|
284
|
-
case
|
|
285
|
-
|
|
290
|
+
case l.stoppedExcesiveRalenti:
|
|
291
|
+
n = 13.3;
|
|
286
292
|
break;
|
|
287
|
-
case
|
|
293
|
+
case l.maxSpeed:
|
|
294
|
+
n = 13.8;
|
|
295
|
+
break;
|
|
296
|
+
case l.moving:
|
|
288
297
|
default:
|
|
289
|
-
|
|
298
|
+
n = e.ignition ? 13.6 : 12.3;
|
|
290
299
|
break;
|
|
291
300
|
}
|
|
292
|
-
e.signal === S.noSignal && (
|
|
301
|
+
e.signal === S.noSignal && (n -= 0.2);
|
|
293
302
|
let i = e.ignition ? 26.3 : 25.2;
|
|
294
303
|
switch (e.motionStatus) {
|
|
295
|
-
case
|
|
304
|
+
case l.notDetectable:
|
|
305
|
+
i = e.ignition ? 25.2 : 24.9;
|
|
306
|
+
break;
|
|
307
|
+
case l.off:
|
|
296
308
|
i = 25;
|
|
297
309
|
break;
|
|
298
|
-
case
|
|
310
|
+
case l.towing:
|
|
299
311
|
i = 24.9;
|
|
300
312
|
break;
|
|
301
|
-
case
|
|
313
|
+
case l.stopped:
|
|
302
314
|
i = e.ignition ? 25.4 : 25;
|
|
303
315
|
break;
|
|
304
|
-
case
|
|
316
|
+
case l.stoppedRalenti:
|
|
305
317
|
i = 26.1;
|
|
306
318
|
break;
|
|
307
|
-
case
|
|
319
|
+
case l.stoppedExcesiveRalenti:
|
|
308
320
|
i = 25.9;
|
|
309
321
|
break;
|
|
310
|
-
case
|
|
322
|
+
case l.maxSpeed:
|
|
311
323
|
i = 26.6;
|
|
312
324
|
break;
|
|
313
|
-
case
|
|
325
|
+
case l.moving:
|
|
314
326
|
default:
|
|
315
327
|
i = e.ignition ? 26.4 : 25.2;
|
|
316
328
|
break;
|
|
317
329
|
}
|
|
318
330
|
e.signal === S.acceptable && (i -= 0.2), e.signal === S.noSignal && (i -= 0.5);
|
|
319
|
-
const a = q(
|
|
331
|
+
const a = q(_(n + o, 11.8, 13.9)), r = q(_(i + o * 2, 24, 27.9));
|
|
320
332
|
return {
|
|
321
|
-
backupChargeLevel:
|
|
322
|
-
backupStatus:
|
|
333
|
+
backupChargeLevel: Y(r),
|
|
334
|
+
backupStatus: R(r, "24"),
|
|
323
335
|
backupVolt: r,
|
|
324
|
-
mainStatus:
|
|
336
|
+
mainStatus: R(a, "12"),
|
|
325
337
|
mainVolt: a
|
|
326
338
|
};
|
|
327
339
|
}
|
|
328
340
|
function De(e) {
|
|
329
341
|
return Object.fromEntries(
|
|
330
|
-
Object.entries(e.vpts?.vptDiX ?? {}).map(([
|
|
342
|
+
Object.entries(e.vpts?.vptDiX ?? {}).map(([s, t]) => [s, !!b(t.diXValue, !1)])
|
|
331
343
|
);
|
|
332
344
|
}
|
|
333
345
|
function he(e) {
|
|
334
346
|
return Object.fromEntries(
|
|
335
|
-
Object.entries(e.vpts?.vptDoX ?? {}).map(([
|
|
347
|
+
Object.entries(e.vpts?.vptDoX ?? {}).map(([s, t]) => [s, !!b(t.diXValue, !1)])
|
|
336
348
|
);
|
|
337
349
|
}
|
|
338
|
-
function
|
|
339
|
-
return e.motionStatus !== void 0 ? e.motionStatus :
|
|
350
|
+
function N(e, s) {
|
|
351
|
+
return e.motionStatus !== void 0 ? e.motionStatus : s.ignition ? e.speedKph >= 55 ? l.maxSpeed : l.moving : l.towing;
|
|
340
352
|
}
|
|
341
|
-
function
|
|
342
|
-
return e.motionStatus !== void 0 ? e.motionStatus :
|
|
353
|
+
function W(e, s) {
|
|
354
|
+
return e.motionStatus !== void 0 ? e.motionStatus : s.ignition ? l.stopped : l.off;
|
|
343
355
|
}
|
|
344
|
-
function
|
|
345
|
-
const t =
|
|
356
|
+
function H(e, s) {
|
|
357
|
+
const t = s.signal ?? e.signal;
|
|
346
358
|
return {
|
|
347
|
-
diX:
|
|
348
|
-
doX:
|
|
349
|
-
ignition:
|
|
350
|
-
modemCsq:
|
|
359
|
+
diX: s.diX ? { ...e.diX, ...s.diX } : { ...e.diX },
|
|
360
|
+
doX: s.doX ? { ...e.doX, ...s.doX } : { ...e.doX },
|
|
361
|
+
ignition: s.ignition ?? e.ignition,
|
|
362
|
+
modemCsq: s.modemCsq ?? (s.signal !== void 0 ? j(t) : e.modemCsq),
|
|
351
363
|
signal: t
|
|
352
364
|
};
|
|
353
365
|
}
|
|
354
|
-
function Ee(e,
|
|
355
|
-
return e.omitDeviceIcon ??
|
|
366
|
+
function Ee(e, s) {
|
|
367
|
+
return e.omitDeviceIcon ?? s.omitDeviceIcon ?? !1;
|
|
356
368
|
}
|
|
357
|
-
function Ie(e,
|
|
369
|
+
function Ie(e, s) {
|
|
358
370
|
const t = M(ie);
|
|
359
|
-
|
|
360
|
-
const o = e.group ??
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
371
|
+
w(t.current, s.currentPatch ?? {}), w(t.current, e.currentPatch ?? {}), w(t.settings, s.settingsPatch ?? {}), t.settings.active = e.active ?? s.active ?? t.settings.active, t.alias = e.alias ?? s.alias ?? t.alias;
|
|
372
|
+
const o = e.group ?? s.group ?? t.settings.group, n = e.department ?? s.department ?? t.department ?? re(o);
|
|
373
|
+
if (t.department = n, t.settings.group = o ?? ae(n), t.settings.iconBgColor = e.iconBgColor ?? s.iconBgColor ?? t.settings.iconBgColor, Ee(e, s))
|
|
374
|
+
t.deviceIcon = void 0;
|
|
375
|
+
else {
|
|
376
|
+
t.deviceIcon ??= {
|
|
377
|
+
iconId: oe
|
|
378
|
+
};
|
|
379
|
+
const i = e.iconId ?? s.iconId ?? t.deviceIcon.iconId;
|
|
380
|
+
t.deviceIcon.iconId = i;
|
|
381
|
+
}
|
|
382
|
+
return t.name = e.name ?? s.name, t.settings.properties?.internal_name && (t.settings.properties.internal_name.value = `${t.name}-${e.resourceSerialId}`), {
|
|
365
383
|
...t,
|
|
366
384
|
resourceSerialId: Number(e.resourceSerialId)
|
|
367
385
|
};
|
|
368
386
|
}
|
|
369
|
-
function
|
|
370
|
-
const
|
|
387
|
+
function we(e) {
|
|
388
|
+
const s = e.current.vpts?.vptGnss?.gnssSignal?.value ?? S.reliable;
|
|
371
389
|
return {
|
|
372
390
|
diX: De(e.current),
|
|
373
391
|
doX: he(e.current),
|
|
374
|
-
ignition: e.current.vpts?.vptIgnition?.ignitionValue
|
|
375
|
-
modemCsq:
|
|
392
|
+
ignition: !!b(e.current.vpts?.vptIgnition?.ignitionValue, !0),
|
|
393
|
+
modemCsq: b(
|
|
376
394
|
e.current.vpts?.vptModem?.modemCsq,
|
|
377
|
-
j(
|
|
395
|
+
j(s)
|
|
378
396
|
),
|
|
379
|
-
signal:
|
|
397
|
+
signal: s
|
|
380
398
|
};
|
|
381
399
|
}
|
|
382
|
-
function
|
|
400
|
+
function Te(e, s) {
|
|
383
401
|
if (e.playbackOffsetSeconds !== void 0)
|
|
384
402
|
return Math.max(0, e.playbackOffsetSeconds);
|
|
385
403
|
const t = Number(e.resourceSerialId);
|
|
386
|
-
return Number.isFinite(t) ? Math.abs(t) % 12 *
|
|
404
|
+
return Number.isFinite(t) ? Math.abs(t) % 12 * s.logicalSampleSeconds * 4 : 0;
|
|
387
405
|
}
|
|
388
|
-
function
|
|
406
|
+
function ke(e, s) {
|
|
389
407
|
if (e.emissionOffsetMs !== void 0)
|
|
390
|
-
return Math.max(0, e.emissionOffsetMs %
|
|
408
|
+
return Math.max(0, e.emissionOffsetMs % s.intervalMs);
|
|
391
409
|
const t = Number(e.resourceSerialId);
|
|
392
|
-
return Number.isFinite(t) ? Math.abs(t * 137 %
|
|
410
|
+
return Number.isFinite(t) ? Math.abs(t * 137 % s.intervalMs) : 0;
|
|
393
411
|
}
|
|
394
|
-
function
|
|
412
|
+
function be(e) {
|
|
395
413
|
return {
|
|
396
|
-
cumulativeDistancesMeters: e.waypoints.reduce((t, o,
|
|
397
|
-
if (
|
|
414
|
+
cumulativeDistancesMeters: e.waypoints.reduce((t, o, n, i) => {
|
|
415
|
+
if (n === 0)
|
|
398
416
|
return t.push(0), t;
|
|
399
|
-
const a = i[
|
|
400
|
-
return t.push(r +
|
|
417
|
+
const a = i[n - 1], r = t[n - 1] ?? 0;
|
|
418
|
+
return t.push(r + B(a, o)), t;
|
|
401
419
|
}, []),
|
|
402
420
|
totalDistanceMeters: z(e.waypoints),
|
|
403
421
|
waypoints: e.waypoints
|
|
404
422
|
};
|
|
405
423
|
}
|
|
406
|
-
function
|
|
407
|
-
const
|
|
408
|
-
return !
|
|
424
|
+
function Re(e) {
|
|
425
|
+
const s = e.waypoints[0], t = e.waypoints[e.waypoints.length - 1];
|
|
426
|
+
return !s || !t ? !1 : B(s, t) <= 1;
|
|
409
427
|
}
|
|
410
|
-
function
|
|
411
|
-
return e.phases.reduce((
|
|
428
|
+
function Ce(e) {
|
|
429
|
+
return e.phases.reduce((s, t) => t.type !== "drive" ? s : s + t.speedKph * 1e3 / 3600 * t.durationSeconds, 0);
|
|
412
430
|
}
|
|
413
|
-
function
|
|
414
|
-
const o =
|
|
415
|
-
if (o >
|
|
431
|
+
function Ae(e, s, t) {
|
|
432
|
+
const o = Ce(t), n = Math.max(150, s.totalDistanceMeters * 0.03);
|
|
433
|
+
if (o > s.totalDistanceMeters + n)
|
|
416
434
|
throw new Error(
|
|
417
435
|
`Dummy plan "${t.planId}" exceeds route "${e.routeId}" by ${Math.round(
|
|
418
|
-
o -
|
|
436
|
+
o - s.totalDistanceMeters
|
|
419
437
|
)} meters`
|
|
420
438
|
);
|
|
421
439
|
}
|
|
422
|
-
function
|
|
440
|
+
function V(e, s, t) {
|
|
423
441
|
const o = e.waypoints[0];
|
|
424
442
|
if (!o)
|
|
425
443
|
throw new Error("Dummy route must contain at least one waypoint");
|
|
@@ -430,17 +448,17 @@ function L(e, n, t) {
|
|
|
430
448
|
lat: o.lat,
|
|
431
449
|
lng: o.lng
|
|
432
450
|
};
|
|
433
|
-
const
|
|
434
|
-
Math.max(0,
|
|
451
|
+
const n = Math.min(
|
|
452
|
+
Math.max(0, s),
|
|
435
453
|
e.totalDistanceMeters
|
|
436
454
|
);
|
|
437
455
|
for (let a = 0; a < e.waypoints.length - 1; a += 1) {
|
|
438
|
-
const r = e.waypoints[a], c = e.waypoints[a + 1],
|
|
439
|
-
if (
|
|
456
|
+
const r = e.waypoints[a], c = e.waypoints[a + 1], u = e.cumulativeDistancesMeters[a] ?? 0, v = e.cumulativeDistancesMeters[a + 1] ?? u;
|
|
457
|
+
if (n > v && a < e.waypoints.length - 2)
|
|
440
458
|
continue;
|
|
441
|
-
const p = Math.max(0, v -
|
|
459
|
+
const p = Math.max(0, v - u), d = p === 0 ? 0 : (n - u) / p, m = Q(r, c, d), g = p === 0 ? t : ee(r, c);
|
|
442
460
|
return {
|
|
443
|
-
address:
|
|
461
|
+
address: d < 0.5 ? r.address : c.address,
|
|
444
462
|
course: g,
|
|
445
463
|
lat: m.lat,
|
|
446
464
|
lng: m.lng
|
|
@@ -454,21 +472,21 @@ function L(e, n, t) {
|
|
|
454
472
|
lng: i.lng
|
|
455
473
|
};
|
|
456
474
|
}
|
|
457
|
-
function
|
|
458
|
-
const o =
|
|
475
|
+
function Ve(e, s, t) {
|
|
476
|
+
const o = s.phases.find((c) => c.type !== "delete");
|
|
459
477
|
if (!o)
|
|
460
|
-
throw new Error(`Dummy plan "${
|
|
461
|
-
const
|
|
478
|
+
throw new Error(`Dummy plan "${s.planId}" must contain at least one executable phase`);
|
|
479
|
+
const n = H(t, o), i = V(e, 0, 0), a = o.type === "drive" ? N(o, n) : W(o, n), r = A(
|
|
462
480
|
{
|
|
463
|
-
ignition:
|
|
481
|
+
ignition: n.ignition,
|
|
464
482
|
motionStatus: a,
|
|
465
|
-
signal:
|
|
483
|
+
signal: n.signal
|
|
466
484
|
},
|
|
467
485
|
0
|
|
468
486
|
);
|
|
469
487
|
return {
|
|
470
488
|
cursor: {
|
|
471
|
-
currentTimestampMs:
|
|
489
|
+
currentTimestampMs: X,
|
|
472
490
|
frameIndex: 0,
|
|
473
491
|
lastCourse: i.course,
|
|
474
492
|
odometerMeters: 0,
|
|
@@ -478,34 +496,34 @@ function Ae(e, n, t) {
|
|
|
478
496
|
address: i.address,
|
|
479
497
|
backupVolt: r.backupVolt,
|
|
480
498
|
course: i.course,
|
|
481
|
-
diX: { ...
|
|
482
|
-
doX: { ...
|
|
483
|
-
ignition:
|
|
499
|
+
diX: { ...n.diX },
|
|
500
|
+
doX: { ...n.doX },
|
|
501
|
+
ignition: n.ignition,
|
|
484
502
|
lat: i.lat,
|
|
485
503
|
lng: i.lng,
|
|
486
504
|
mainVolt: r.mainVolt,
|
|
487
|
-
modemCsq:
|
|
505
|
+
modemCsq: n.modemCsq,
|
|
488
506
|
motionStatus: a,
|
|
489
507
|
odometerMeters: 0,
|
|
490
|
-
signal:
|
|
508
|
+
signal: n.signal,
|
|
491
509
|
speedKph: o.type === "drive" ? o.speedKph : 0,
|
|
492
|
-
timestampMs:
|
|
510
|
+
timestampMs: X
|
|
493
511
|
},
|
|
494
|
-
persistentState:
|
|
512
|
+
persistentState: n
|
|
495
513
|
};
|
|
496
514
|
}
|
|
497
|
-
function
|
|
498
|
-
const
|
|
499
|
-
if (!
|
|
515
|
+
function Le(e, s, t, o) {
|
|
516
|
+
const n = s.reduce((g, f, D) => ((f.type === "new" || f.type === "update") && g.push(D), g), []);
|
|
517
|
+
if (!n.length)
|
|
500
518
|
return {
|
|
501
519
|
initialMessageIndex: 1,
|
|
502
520
|
initialResource: e,
|
|
503
|
-
playbackMessages:
|
|
521
|
+
playbackMessages: s
|
|
504
522
|
};
|
|
505
|
-
const i =
|
|
523
|
+
const i = Te(o, t), a = Math.floor(i / t.logicalSampleSeconds), r = Math.min(a, n.length - 1), c = n[r], u = s[c], v = (u.type === "new", u.payload.current), p = {
|
|
506
524
|
...e,
|
|
507
525
|
current: M(v)
|
|
508
|
-
},
|
|
526
|
+
}, d = s.slice(c + 1), m = t.loop ? s.slice(1, c + 1) : [];
|
|
509
527
|
return {
|
|
510
528
|
initialMessageIndex: 1,
|
|
511
529
|
initialResource: p,
|
|
@@ -515,53 +533,53 @@ function Ve(e, n, t, o) {
|
|
|
515
533
|
resourceSerialId: o.resourceSerialId,
|
|
516
534
|
type: "new"
|
|
517
535
|
},
|
|
518
|
-
...
|
|
536
|
+
...d,
|
|
519
537
|
...m
|
|
520
538
|
]
|
|
521
539
|
};
|
|
522
540
|
}
|
|
523
|
-
function Xe(e,
|
|
524
|
-
const t =
|
|
541
|
+
function Xe(e, s) {
|
|
542
|
+
const t = s.messagePayloadPatches ?? [];
|
|
525
543
|
if (!t.length)
|
|
526
544
|
return e;
|
|
527
545
|
const o = {
|
|
528
546
|
...e,
|
|
529
547
|
initialResource: M(e.initialResource),
|
|
530
|
-
messages: e.messages.map((
|
|
548
|
+
messages: e.messages.map((n) => M(n))
|
|
531
549
|
};
|
|
532
|
-
return t.forEach((
|
|
533
|
-
const i = o.messages[
|
|
550
|
+
return t.forEach((n) => {
|
|
551
|
+
const i = o.messages[n.messageIndex];
|
|
534
552
|
if (!i)
|
|
535
553
|
throw new Error(
|
|
536
|
-
`Dummy hostile payload patch targeted missing message index ${
|
|
554
|
+
`Dummy hostile payload patch targeted missing message index ${n.messageIndex} for device ${s.resourceSerialId}.`
|
|
537
555
|
);
|
|
538
556
|
if (i.type === "delete")
|
|
539
557
|
throw new Error(
|
|
540
|
-
`Dummy hostile payload patch cannot target delete message index ${
|
|
558
|
+
`Dummy hostile payload patch cannot target delete message index ${n.messageIndex} for device ${s.resourceSerialId}.`
|
|
541
559
|
);
|
|
542
|
-
|
|
560
|
+
w(
|
|
543
561
|
i.payload,
|
|
544
|
-
M(
|
|
545
|
-
),
|
|
562
|
+
M(n.payloadPatch)
|
|
563
|
+
), n.messageIndex === 0 && i.type === "new" && w(
|
|
546
564
|
o.initialResource,
|
|
547
|
-
M(
|
|
565
|
+
M(n.payloadPatch)
|
|
548
566
|
);
|
|
549
567
|
}), o;
|
|
550
568
|
}
|
|
551
|
-
function Pe(e,
|
|
552
|
-
const t =
|
|
553
|
-
if (!t?.gnssMotionStatus && !t?.gnssSignal && !o)
|
|
569
|
+
function Pe(e, s) {
|
|
570
|
+
const t = s.omittedGnssFields, o = s.omitSyntheticModemTimestamps === !0;
|
|
571
|
+
if (!t?.gnssLatitude && !t?.gnssLongitude && !t?.gnssMotionStatus && !t?.gnssSignal && !o)
|
|
554
572
|
return e;
|
|
555
|
-
const
|
|
573
|
+
const n = {
|
|
556
574
|
...e,
|
|
557
575
|
initialResource: M(e.initialResource),
|
|
558
576
|
messages: e.messages.map((a) => M(a))
|
|
559
577
|
}, i = (a) => {
|
|
560
|
-
t?.gnssMotionStatus &&
|
|
578
|
+
t?.gnssLatitude && E(a, "vpts.vptGnss.gnssLatitude"), t?.gnssLongitude && E(a, "vpts.vptGnss.gnssLongitude"), t?.gnssMotionStatus && E(a, "vpts.vptGnss.gnssMotionStatus"), t?.gnssSignal && E(a, "vpts.vptGnss.gnssSignal"), o && (E(a, "reportProfiles.trackerEvents.modemLastEvent"), E(a, "vpts.vptNetwork.lastConnection"), E(a, "vpts.vptNetwork.lastEvent"));
|
|
561
579
|
};
|
|
562
580
|
return i(
|
|
563
|
-
|
|
564
|
-
),
|
|
581
|
+
n.initialResource.current
|
|
582
|
+
), n.messages.forEach((a) => {
|
|
565
583
|
if (a.type !== "delete") {
|
|
566
584
|
if (a.type === "new") {
|
|
567
585
|
i(a.payload.current);
|
|
@@ -571,91 +589,97 @@ function Pe(e, n) {
|
|
|
571
589
|
a.payload.current
|
|
572
590
|
);
|
|
573
591
|
}
|
|
574
|
-
}),
|
|
592
|
+
}), n;
|
|
575
593
|
}
|
|
576
|
-
function
|
|
577
|
-
const t = new Date(
|
|
578
|
-
return
|
|
579
|
-
...
|
|
594
|
+
function L(e, s) {
|
|
595
|
+
const t = new Date(s.timestampMs).toISOString(), o = Se(s.signal), n = M(e);
|
|
596
|
+
return n.reportProfiles = {
|
|
597
|
+
...n.reportProfiles,
|
|
580
598
|
trackerEvents: {
|
|
581
|
-
...
|
|
599
|
+
...n.reportProfiles?.trackerEvents,
|
|
582
600
|
modemLastEvent: {
|
|
583
601
|
date: t
|
|
584
602
|
}
|
|
585
603
|
}
|
|
586
|
-
},
|
|
587
|
-
Object.entries(
|
|
604
|
+
}, n.vpts = n.vpts ?? {}, n.vpts.vptDiX = Object.fromEntries(
|
|
605
|
+
Object.entries(s.diX).map(([i, a]) => [
|
|
588
606
|
i,
|
|
589
607
|
{
|
|
590
608
|
diXStatus: { value: !0, updatedAt: t },
|
|
591
609
|
diXValue: { value: a, updatedAt: t }
|
|
592
610
|
}
|
|
593
611
|
])
|
|
594
|
-
),
|
|
595
|
-
Object.entries(
|
|
612
|
+
), n.vpts.vptDoX = Object.fromEntries(
|
|
613
|
+
Object.entries(s.doX).map(([i, a]) => [
|
|
596
614
|
i,
|
|
597
615
|
{
|
|
598
616
|
diXValue: { value: a, updatedAt: t }
|
|
599
617
|
}
|
|
600
618
|
])
|
|
601
|
-
),
|
|
602
|
-
...
|
|
603
|
-
gnssAddress:
|
|
619
|
+
), n.vpts.vptGnss = {
|
|
620
|
+
...n.vpts.vptGnss,
|
|
621
|
+
gnssAddress: s.address,
|
|
604
622
|
gnssAltitude: 1520,
|
|
605
|
-
gnssCourse:
|
|
606
|
-
|
|
607
|
-
Math.round(
|
|
623
|
+
gnssCourse: k(
|
|
624
|
+
n.vpts.vptGnss?.gnssCourse,
|
|
625
|
+
Math.round(s.course),
|
|
608
626
|
t
|
|
609
627
|
),
|
|
610
628
|
gnssHdop: o.gnssHdop,
|
|
611
|
-
gnssLatitude:
|
|
612
|
-
|
|
613
|
-
|
|
629
|
+
gnssLatitude: k(
|
|
630
|
+
n.vpts.vptGnss?.gnssLatitude,
|
|
631
|
+
s.lat,
|
|
614
632
|
t
|
|
615
633
|
),
|
|
616
|
-
gnssLongitude:
|
|
617
|
-
|
|
618
|
-
|
|
634
|
+
gnssLongitude: k(
|
|
635
|
+
n.vpts.vptGnss?.gnssLongitude,
|
|
636
|
+
s.lng,
|
|
619
637
|
t
|
|
620
638
|
),
|
|
621
|
-
gnssMotionStatus: { value:
|
|
622
|
-
gnssOdometer: Math.round(
|
|
639
|
+
gnssMotionStatus: { value: s.motionStatus, updatedAt: t },
|
|
640
|
+
gnssOdometer: Math.round(s.odometerMeters),
|
|
623
641
|
gnssSatellitesInUse: o.gnssSatellitesInUse,
|
|
624
|
-
gnssSignal: { value:
|
|
625
|
-
gnssSpeed:
|
|
626
|
-
|
|
627
|
-
|
|
642
|
+
gnssSignal: { value: s.signal, updatedAt: t },
|
|
643
|
+
gnssSpeed: k(
|
|
644
|
+
n.vpts.vptGnss?.gnssSpeed,
|
|
645
|
+
s.speedKph,
|
|
628
646
|
t
|
|
629
647
|
)
|
|
630
|
-
},
|
|
648
|
+
}, n.vpts.vptIgnition = {
|
|
631
649
|
ignitionValue: {
|
|
632
650
|
updatedAt: t,
|
|
633
|
-
value:
|
|
651
|
+
value: s.ignition
|
|
634
652
|
}
|
|
635
|
-
},
|
|
653
|
+
}, n.vpts.vptModem = {
|
|
636
654
|
callActive: !1,
|
|
637
|
-
modemCsq:
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
},
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
+
modemCsq: s.modemCsq
|
|
656
|
+
}, n.vpts.vptNetwork = {
|
|
657
|
+
...n.vpts.vptNetwork,
|
|
658
|
+
lastConnection: t,
|
|
659
|
+
lastEvent: {
|
|
660
|
+
...n.vpts.vptNetwork?.lastEvent,
|
|
661
|
+
date: t,
|
|
662
|
+
id: n.vpts.vptNetwork?.lastEvent?.id ?? 99
|
|
663
|
+
}
|
|
664
|
+
}, n.vpts.vptADCPower = {
|
|
665
|
+
backupChargeLevel: Y(s.backupVolt),
|
|
666
|
+
backupStatus: R(s.backupVolt, "24"),
|
|
667
|
+
backupVolt: s.backupVolt,
|
|
668
|
+
mainStatus: R(s.mainVolt, "12"),
|
|
669
|
+
mainVolt: s.mainVolt
|
|
670
|
+
}, n;
|
|
671
|
+
}
|
|
672
|
+
function Z(e, s) {
|
|
673
|
+
return Math.max(1, Math.ceil(e.durationSeconds / s.logicalSampleSeconds));
|
|
674
|
+
}
|
|
675
|
+
function _e(e, s, t, o, n, i, a, r) {
|
|
676
|
+
const c = Z(n, a);
|
|
677
|
+
for (let u = 0; u < c; u += 1) {
|
|
678
|
+
const v = J(n.speedKph, r.frameIndex + 1), p = v * 1e3 / 3600 * a.logicalSampleSeconds, d = Math.min(
|
|
655
679
|
o.totalDistanceMeters,
|
|
656
680
|
r.routeDistanceMeters + p
|
|
657
|
-
), m =
|
|
658
|
-
r.currentTimestampMs += a.logicalSampleSeconds * 1e3, r.frameIndex += 1, r.lastCourse = g.course, r.odometerMeters += m, r.routeDistanceMeters =
|
|
681
|
+
), m = d - r.routeDistanceMeters, g = V(o, d, r.lastCourse);
|
|
682
|
+
r.currentTimestampMs += a.logicalSampleSeconds * 1e3, r.frameIndex += 1, r.lastCourse = g.course, r.odometerMeters += m, r.routeDistanceMeters = d;
|
|
659
683
|
const f = {
|
|
660
684
|
address: g.address,
|
|
661
685
|
backupVolt: 0,
|
|
@@ -667,30 +691,30 @@ function _e(e, n, t, o, s, i, a, r) {
|
|
|
667
691
|
lng: g.lng,
|
|
668
692
|
mainVolt: 0,
|
|
669
693
|
modemCsq: i.modemCsq,
|
|
670
|
-
motionStatus:
|
|
694
|
+
motionStatus: N(n, i),
|
|
671
695
|
odometerMeters: r.odometerMeters,
|
|
672
696
|
signal: i.signal,
|
|
673
697
|
speedKph: m > 0 ? v : 0,
|
|
674
698
|
timestampMs: r.currentTimestampMs
|
|
675
|
-
}, D =
|
|
699
|
+
}, D = A(f, r.frameIndex);
|
|
676
700
|
f.mainVolt = D.mainVolt, f.backupVolt = D.backupVolt, e.push({
|
|
677
701
|
payload: {
|
|
678
|
-
current:
|
|
702
|
+
current: L(t, f)
|
|
679
703
|
},
|
|
680
|
-
resourceSerialId:
|
|
704
|
+
resourceSerialId: s,
|
|
681
705
|
type: "update"
|
|
682
706
|
});
|
|
683
707
|
}
|
|
684
708
|
}
|
|
685
|
-
function Oe(e,
|
|
686
|
-
const c =
|
|
687
|
-
for (let
|
|
688
|
-
const v =
|
|
709
|
+
function Oe(e, s, t, o, n, i, a, r) {
|
|
710
|
+
const c = Z(n, a);
|
|
711
|
+
for (let u = 0; u < c; u += 1) {
|
|
712
|
+
const v = V(o, r.routeDistanceMeters, r.lastCourse);
|
|
689
713
|
r.currentTimestampMs += a.logicalSampleSeconds * 1e3, r.frameIndex += 1;
|
|
690
714
|
const p = {
|
|
691
715
|
address: v.address,
|
|
692
716
|
backupVolt: 0,
|
|
693
|
-
course:
|
|
717
|
+
course: n.courseOverrideDegrees ?? r.lastCourse,
|
|
694
718
|
diX: { ...i.diX },
|
|
695
719
|
doX: { ...i.doX },
|
|
696
720
|
ignition: i.ignition,
|
|
@@ -698,92 +722,92 @@ function Oe(e, n, t, o, s, i, a, r) {
|
|
|
698
722
|
lng: v.lng,
|
|
699
723
|
mainVolt: 0,
|
|
700
724
|
modemCsq: i.modemCsq,
|
|
701
|
-
motionStatus:
|
|
725
|
+
motionStatus: W(n, i),
|
|
702
726
|
odometerMeters: r.odometerMeters,
|
|
703
727
|
signal: i.signal,
|
|
704
728
|
speedKph: 0,
|
|
705
729
|
timestampMs: r.currentTimestampMs
|
|
706
|
-
},
|
|
707
|
-
p.mainVolt =
|
|
730
|
+
}, d = A(p, r.frameIndex);
|
|
731
|
+
p.mainVolt = d.mainVolt, p.backupVolt = d.backupVolt, e.push({
|
|
708
732
|
payload: {
|
|
709
|
-
current:
|
|
733
|
+
current: L(t, p)
|
|
710
734
|
},
|
|
711
|
-
resourceSerialId:
|
|
735
|
+
resourceSerialId: s,
|
|
712
736
|
type: "update"
|
|
713
737
|
});
|
|
714
738
|
}
|
|
715
739
|
}
|
|
716
|
-
function
|
|
740
|
+
function Ne({
|
|
717
741
|
baseCurrent: e,
|
|
718
|
-
cursor:
|
|
742
|
+
cursor: s,
|
|
719
743
|
messages: t,
|
|
720
744
|
persistentState: o,
|
|
721
|
-
playback:
|
|
745
|
+
playback: n,
|
|
722
746
|
resourceSerialId: i,
|
|
723
747
|
routeIndex: a,
|
|
724
748
|
speedKph: r
|
|
725
749
|
}) {
|
|
726
|
-
if (!
|
|
750
|
+
if (r === void 0 || !Re(a) || s.routeDistanceMeters >= a.totalDistanceMeters)
|
|
727
751
|
return;
|
|
728
752
|
const c = Math.max(r, 8);
|
|
729
|
-
for (;
|
|
730
|
-
const
|
|
753
|
+
for (; s.routeDistanceMeters < a.totalDistanceMeters; ) {
|
|
754
|
+
const u = c * 1e3 / 3600 * n.logicalSampleSeconds, v = Math.min(
|
|
731
755
|
a.totalDistanceMeters,
|
|
732
|
-
|
|
733
|
-
), p = v -
|
|
734
|
-
|
|
756
|
+
s.routeDistanceMeters + u
|
|
757
|
+
), p = v - s.routeDistanceMeters, d = V(a, v, s.lastCourse);
|
|
758
|
+
s.currentTimestampMs += n.logicalSampleSeconds * 1e3, s.frameIndex += 1, s.lastCourse = d.course, s.odometerMeters += p, s.routeDistanceMeters = v;
|
|
735
759
|
const m = {
|
|
736
|
-
address:
|
|
760
|
+
address: d.address,
|
|
737
761
|
backupVolt: 0,
|
|
738
|
-
course:
|
|
762
|
+
course: d.course,
|
|
739
763
|
diX: { ...o.diX },
|
|
740
764
|
doX: { ...o.doX },
|
|
741
765
|
ignition: o.ignition,
|
|
742
|
-
lat:
|
|
743
|
-
lng:
|
|
766
|
+
lat: d.lat,
|
|
767
|
+
lng: d.lng,
|
|
744
768
|
mainVolt: 0,
|
|
745
769
|
modemCsq: o.modemCsq,
|
|
746
|
-
motionStatus:
|
|
770
|
+
motionStatus: N(
|
|
747
771
|
{
|
|
748
|
-
durationSeconds:
|
|
772
|
+
durationSeconds: n.logicalSampleSeconds,
|
|
749
773
|
speedKph: c
|
|
750
774
|
},
|
|
751
775
|
o
|
|
752
776
|
),
|
|
753
|
-
odometerMeters:
|
|
777
|
+
odometerMeters: s.odometerMeters,
|
|
754
778
|
signal: o.signal,
|
|
755
779
|
speedKph: p > 0 ? c : 0,
|
|
756
|
-
timestampMs:
|
|
757
|
-
}, g =
|
|
780
|
+
timestampMs: s.currentTimestampMs
|
|
781
|
+
}, g = A(m, s.frameIndex);
|
|
758
782
|
m.mainVolt = g.mainVolt, m.backupVolt = g.backupVolt, t.push({
|
|
759
783
|
payload: {
|
|
760
|
-
current:
|
|
784
|
+
current: L(e, m)
|
|
761
785
|
},
|
|
762
786
|
resourceSerialId: i,
|
|
763
787
|
type: "update"
|
|
764
788
|
});
|
|
765
789
|
}
|
|
766
790
|
}
|
|
767
|
-
function
|
|
768
|
-
const { assignment: t, blueprint: o, plan:
|
|
769
|
-
|
|
770
|
-
const r = Ie(t, o), c =
|
|
791
|
+
function Ge(e, s) {
|
|
792
|
+
const { assignment: t, blueprint: o, plan: n, route: i } = e, a = be(i);
|
|
793
|
+
Ae(i, a, n);
|
|
794
|
+
const r = Ie(t, o), c = we(r), { cursor: u, frameState: v, persistentState: p } = Ve(
|
|
771
795
|
a,
|
|
772
|
-
|
|
796
|
+
n,
|
|
773
797
|
c
|
|
774
|
-
),
|
|
798
|
+
), d = {
|
|
775
799
|
...r,
|
|
776
|
-
current:
|
|
800
|
+
current: L(r.current, v)
|
|
777
801
|
};
|
|
778
|
-
let m = p, g =
|
|
802
|
+
let m = p, g = n.phases.find((h) => h.type === "drive")?.speedKph;
|
|
779
803
|
const f = [
|
|
780
804
|
{
|
|
781
|
-
payload:
|
|
805
|
+
payload: d,
|
|
782
806
|
resourceSerialId: t.resourceSerialId,
|
|
783
807
|
type: "new"
|
|
784
808
|
}
|
|
785
809
|
];
|
|
786
|
-
for (const h of
|
|
810
|
+
for (const h of n.phases) {
|
|
787
811
|
if (h.type === "delete") {
|
|
788
812
|
f.push({
|
|
789
813
|
payload: {},
|
|
@@ -792,7 +816,7 @@ function Ue(e, n) {
|
|
|
792
816
|
});
|
|
793
817
|
break;
|
|
794
818
|
}
|
|
795
|
-
if (m =
|
|
819
|
+
if (m = H(m, h), h.type === "drive") {
|
|
796
820
|
g = h.speedKph, _e(
|
|
797
821
|
f,
|
|
798
822
|
t.resourceSerialId,
|
|
@@ -800,8 +824,8 @@ function Ue(e, n) {
|
|
|
800
824
|
a,
|
|
801
825
|
h,
|
|
802
826
|
m,
|
|
803
|
-
|
|
804
|
-
|
|
827
|
+
s,
|
|
828
|
+
u
|
|
805
829
|
);
|
|
806
830
|
continue;
|
|
807
831
|
}
|
|
@@ -812,24 +836,24 @@ function Ue(e, n) {
|
|
|
812
836
|
a,
|
|
813
837
|
h,
|
|
814
838
|
m,
|
|
815
|
-
|
|
816
|
-
|
|
839
|
+
s,
|
|
840
|
+
u
|
|
817
841
|
);
|
|
818
842
|
}
|
|
819
|
-
|
|
843
|
+
Ne({
|
|
820
844
|
baseCurrent: r.current,
|
|
821
|
-
cursor:
|
|
845
|
+
cursor: u,
|
|
822
846
|
messages: f,
|
|
823
847
|
persistentState: m,
|
|
824
|
-
playback:
|
|
848
|
+
playback: s,
|
|
825
849
|
resourceSerialId: t.resourceSerialId,
|
|
826
850
|
routeIndex: a,
|
|
827
851
|
speedKph: g
|
|
828
852
|
});
|
|
829
|
-
const D =
|
|
853
|
+
const D = Le(r, f, s, t);
|
|
830
854
|
return Pe(
|
|
831
855
|
Xe({
|
|
832
|
-
emissionOffsetMs:
|
|
856
|
+
emissionOffsetMs: ke(t, s),
|
|
833
857
|
initialMessageIndex: D.initialMessageIndex,
|
|
834
858
|
initialResource: D.initialResource,
|
|
835
859
|
messages: D.playbackMessages,
|
|
@@ -838,54 +862,54 @@ function Ue(e, n) {
|
|
|
838
862
|
t
|
|
839
863
|
);
|
|
840
864
|
}
|
|
841
|
-
function
|
|
865
|
+
function Ue(e, s) {
|
|
842
866
|
const t = ye(e), o = {
|
|
843
|
-
devices: t.devices.map((
|
|
867
|
+
devices: t.devices.map((n) => Ge(n, t.playback)),
|
|
844
868
|
playback: t.playback
|
|
845
869
|
};
|
|
846
|
-
return
|
|
870
|
+
return s?.wallClockStartAtMs === void 0 ? o : {
|
|
847
871
|
...o,
|
|
848
|
-
devices: o.devices.map((
|
|
849
|
-
...
|
|
872
|
+
devices: o.devices.map((n) => ({
|
|
873
|
+
...n,
|
|
850
874
|
initialResource: ue(
|
|
851
|
-
|
|
852
|
-
|
|
875
|
+
n.initialResource,
|
|
876
|
+
s.wallClockStartAtMs
|
|
853
877
|
),
|
|
854
|
-
messages:
|
|
878
|
+
messages: n.messages.map((i) => pe(
|
|
855
879
|
i,
|
|
856
|
-
|
|
880
|
+
s.wallClockStartAtMs
|
|
857
881
|
))
|
|
858
882
|
}))
|
|
859
883
|
};
|
|
860
884
|
}
|
|
861
|
-
function
|
|
862
|
-
return
|
|
863
|
-
|
|
864
|
-
|
|
885
|
+
function xe(e, s) {
|
|
886
|
+
return Ue(e).devices.reduce((o, n) => (o[n.resourceSerialId] = s?.wallClockStartAtMs === void 0 ? n.initialResource : de(
|
|
887
|
+
n.initialResource,
|
|
888
|
+
s.wallClockStartAtMs
|
|
865
889
|
), o), {});
|
|
866
890
|
}
|
|
867
|
-
function
|
|
891
|
+
function Fe({
|
|
868
892
|
resourceTypeId: e,
|
|
869
|
-
simulation:
|
|
893
|
+
simulation: s
|
|
870
894
|
}) {
|
|
871
895
|
const t = Date.now();
|
|
872
896
|
return {
|
|
873
|
-
initialHashResources:
|
|
897
|
+
initialHashResources: xe(s, {
|
|
874
898
|
wallClockStartAtMs: t
|
|
875
899
|
}),
|
|
876
900
|
resourceTypeId: e,
|
|
877
|
-
simulation:
|
|
901
|
+
simulation: s,
|
|
878
902
|
sourceDataMechanism: "dummy",
|
|
879
903
|
wallClockStartAtMs: t
|
|
880
904
|
};
|
|
881
905
|
}
|
|
882
906
|
function et({
|
|
883
907
|
presetId: e,
|
|
884
|
-
resourceTypeId:
|
|
908
|
+
resourceTypeId: s,
|
|
885
909
|
simulationOverrides: t
|
|
886
910
|
}) {
|
|
887
|
-
return
|
|
888
|
-
resourceTypeId:
|
|
911
|
+
return Fe({
|
|
912
|
+
resourceTypeId: s,
|
|
889
913
|
simulation: te({
|
|
890
914
|
overrides: t,
|
|
891
915
|
presetId: e
|
|
@@ -893,8 +917,8 @@ function et({
|
|
|
893
917
|
});
|
|
894
918
|
}
|
|
895
919
|
export {
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
920
|
+
Ue as buildRealTimeDummyRuntimeModel,
|
|
921
|
+
xe as createRealTimeDummyInitialResources,
|
|
922
|
+
Fe as createRealTimeDummyResourceTypeConfig,
|
|
899
923
|
et as createRealTimeDummyResourceTypeConfigFromPreset
|
|
900
924
|
};
|