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