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