@7365admin1/core 3.124.0 → 3.124.2
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/CHANGELOG.md +12 -0
- package/dist/index.d.ts +112 -3
- package/dist/index.js +166 -28
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +159 -28
- package/dist/index.mjs.map +1 -1
- package/logs/.6b77785a74c362881f6fb7e95a7530280abbf9ed-audit.json +5 -5
- package/logs/.ca6dad43b7d35307d69543a741eb24d3ce997028-audit.json +5 -5
- package/logs/dahua/.6ec119960df5f4d6b0eca28515ba03f28bca7d1b-audit.json +5 -0
- package/logs/dahua/.ddefed381272b698d725b4376425900c8428d7a4-audit.json +5 -0
- package/package.json +2 -2
- package/test/camera-alert.util.test.mjs +20 -0
- package/test/padbot-movement.test.mjs +157 -0
- package/test/padbot.test.mjs +4 -4
- package/test/site-incident-counter.test.mjs +70 -0
- package/logs/combined-2026-09-10.log +0 -0
- package/logs/error-2026-09-10.log +0 -0
package/dist/index.js
CHANGED
|
@@ -261,20 +261,26 @@ __export(src_exports, {
|
|
|
261
261
|
PADBOT_ACTION_TEXT: () => PADBOT_ACTION_TEXT,
|
|
262
262
|
PADBOT_ALARMS: () => PADBOT_ALARMS,
|
|
263
263
|
PADBOT_ALARM_POLL_MS: () => PADBOT_ALARM_POLL_MS,
|
|
264
|
+
PADBOT_ALARM_READ_MS: () => PADBOT_ALARM_READ_MS,
|
|
264
265
|
PADBOT_ALARM_TEXT: () => PADBOT_ALARM_TEXT,
|
|
266
|
+
PADBOT_ARRIVED_M: () => PADBOT_ARRIVED_M,
|
|
265
267
|
PADBOT_BRAND: () => PADBOT_BRAND,
|
|
266
268
|
PADBOT_BRAND_DEFINITION: () => PADBOT_BRAND_DEFINITION,
|
|
267
269
|
PADBOT_CAPABILITIES: () => PADBOT_CAPABILITIES,
|
|
270
|
+
PADBOT_CHARGING: () => PADBOT_CHARGING,
|
|
268
271
|
PADBOT_DISPLAY_NAME: () => PADBOT_DISPLAY_NAME,
|
|
269
272
|
PADBOT_FAILURE_SHOW_MS: () => PADBOT_FAILURE_SHOW_MS,
|
|
270
273
|
PADBOT_LIVE_POSE_MS: () => PADBOT_LIVE_POSE_MS,
|
|
271
274
|
PADBOT_MAKER_APP_ONLY: () => PADBOT_MAKER_APP_ONLY,
|
|
272
275
|
PADBOT_MODELS: () => PADBOT_MODELS,
|
|
273
276
|
PADBOT_MOTION: () => PADBOT_MOTION,
|
|
277
|
+
PADBOT_MOTION_MS: () => PADBOT_MOTION_MS,
|
|
278
|
+
PADBOT_MOVED_M: () => PADBOT_MOVED_M,
|
|
274
279
|
PADBOT_MQTT_SYNC_MS: () => PADBOT_MQTT_SYNC_MS,
|
|
275
280
|
PADBOT_ONLINE_WINDOW_MS: () => PADBOT_ONLINE_WINDOW_MS,
|
|
276
281
|
PADBOT_OTHER_MAP_TEXT: () => PADBOT_OTHER_MAP_TEXT,
|
|
277
282
|
PADBOT_PATHS: () => PADBOT_PATHS,
|
|
283
|
+
PADBOT_ROBOT_READ_MS: () => PADBOT_ROBOT_READ_MS,
|
|
278
284
|
PATROL_CCTV_CAMERA_FILTER: () => PATROL_CCTV_CAMERA_FILTER,
|
|
279
285
|
PATROL_EMAIL_MAX_LOGS: () => PATROL_EMAIL_MAX_LOGS,
|
|
280
286
|
PATROL_EMAIL_MAX_PER_HOUR: () => PATROL_EMAIL_MAX_PER_HOUR,
|
|
@@ -625,6 +631,7 @@ __export(src_exports, {
|
|
|
625
631
|
padbotLive: () => padbotLive,
|
|
626
632
|
padbotManualDriveEnabled: () => padbotManualDriveEnabled,
|
|
627
633
|
padbotMode: () => padbotMode,
|
|
634
|
+
padbotMotion: () => padbotMotion,
|
|
628
635
|
padbotMqttEnabled: () => padbotMqttEnabled,
|
|
629
636
|
padbotPatrolPlan: () => padbotPatrolPlan,
|
|
630
637
|
padbotPatrolRecord: () => padbotPatrolRecord,
|
|
@@ -6787,7 +6794,21 @@ function MSite(value) {
|
|
|
6787
6794
|
name: value.name ?? "",
|
|
6788
6795
|
description: value.description ?? "",
|
|
6789
6796
|
orgId: value.orgId ?? "",
|
|
6790
|
-
|
|
6797
|
+
/*
|
|
6798
|
+
* `incidentCounter` is seeded at creation rather than left absent.
|
|
6799
|
+
*
|
|
6800
|
+
* `incident-report.service.ts` increments it for every report, and it used
|
|
6801
|
+
* to spring into existence on the first one — a dotted `$set` creates the
|
|
6802
|
+
* key. Seeding it means a site's shape does not depend on whether anybody
|
|
6803
|
+
* has filed a report yet, so a reader cannot meet the field as `undefined`
|
|
6804
|
+
* on a new site and only as a number on an old one.
|
|
6805
|
+
*
|
|
6806
|
+
* `siteSchema` does not permit `metadata` on creation at all, so the spread
|
|
6807
|
+
* below never fires today — it is there so that a caller supplying its own
|
|
6808
|
+
* metadata would still win if the schema ever allows it, rather than having
|
|
6809
|
+
* its counter silently reset to zero.
|
|
6810
|
+
*/
|
|
6811
|
+
metadata: { incidentCounter: 0, ...value.metadata ?? {} },
|
|
6791
6812
|
status: "active",
|
|
6792
6813
|
createdAt: /* @__PURE__ */ new Date(),
|
|
6793
6814
|
address: value.address,
|
|
@@ -22654,6 +22675,9 @@ function shouldAlertOnFailure(consecutiveFailures) {
|
|
|
22654
22675
|
return false;
|
|
22655
22676
|
return (consecutiveFailures - CAMERA_ALERT_EVERY_AFTER) % CAMERA_ALERT_EVERY_AFTER === 0;
|
|
22656
22677
|
}
|
|
22678
|
+
function shouldStoreCameraFault(alertedThisOutage) {
|
|
22679
|
+
return alertedThisOutage === 0;
|
|
22680
|
+
}
|
|
22657
22681
|
|
|
22658
22682
|
// src/utils/dahua-protocol.util.ts
|
|
22659
22683
|
var DAHUA_AUTH_ATTEMPTS_BEFORE_ALERT = 2;
|
|
@@ -23821,6 +23845,7 @@ function useDahuaService() {
|
|
|
23821
23845
|
`[${camera?.siteName}-${camera?.direction}] Connection lost or error: ${error.message || error}. Retrying in 10 seconds... (failure ${connectionFailureCount})`
|
|
23822
23846
|
);
|
|
23823
23847
|
if (onDetected && shouldAlertOnFailure(connectionFailureCount)) {
|
|
23848
|
+
const storeInInbox = shouldStoreCameraFault(alertedFailureCount);
|
|
23824
23849
|
alertedFailureCount = connectionFailureCount;
|
|
23825
23850
|
onDetected({
|
|
23826
23851
|
site: camera?.site,
|
|
@@ -23829,7 +23854,8 @@ function useDahuaService() {
|
|
|
23829
23854
|
camera: camera?._id?.toString(),
|
|
23830
23855
|
message: cameraUnreachableMessage(camera)
|
|
23831
23856
|
});
|
|
23832
|
-
|
|
23857
|
+
if (storeInInbox)
|
|
23858
|
+
notifyCameraFault(camera, cameraUnreachableMessage(camera));
|
|
23833
23859
|
}
|
|
23834
23860
|
}
|
|
23835
23861
|
} finally {
|
|
@@ -65352,9 +65378,9 @@ function padbotReadiness(states, now = Date.now()) {
|
|
|
65352
65378
|
const charging = st["1002"]?.chargingState;
|
|
65353
65379
|
const notes = [];
|
|
65354
65380
|
if (es.wheelLockState === 1)
|
|
65355
|
-
notes.push("
|
|
65381
|
+
notes.push("Wheel motor lock reads 1 (1006). The S2 reads 1 even while it drives, so this does not stop it.");
|
|
65356
65382
|
if (charging === 2)
|
|
65357
|
-
notes.push("Charging state 2
|
|
65383
|
+
notes.push("Charging state 2 = docked on the charger (inferred from the S2; PadBot's v4.0 document lists only 0 and 1).");
|
|
65358
65384
|
return {
|
|
65359
65385
|
online: padbotMode(st, now).online,
|
|
65360
65386
|
heartbeatAt: st["1000"]?.updatedAt ?? null,
|
|
@@ -65388,6 +65414,33 @@ function padbotFailureText(p) {
|
|
|
65388
65414
|
return null;
|
|
65389
65415
|
return `Could not reach ${p.target || "its destination"}${p.message ? ` (${p.message})` : ""}`;
|
|
65390
65416
|
}
|
|
65417
|
+
var PADBOT_CHARGING = { OFF: 0, UNDOCKING_OR_CHARGING: 1, DOCKED: 2, DOCKING: 3 };
|
|
65418
|
+
var PADBOT_MOVED_M = 0.3;
|
|
65419
|
+
var PADBOT_ARRIVED_M = 0.5;
|
|
65420
|
+
var PADBOT_MOTION_MS = 3 * 6e4;
|
|
65421
|
+
function padbotMotion(m, now) {
|
|
65422
|
+
const c = typeof now.charging === "number" ? now.charging : null;
|
|
65423
|
+
const walked = m.pose && now.pose ? Math.hypot(now.pose.x - m.pose.x, now.pose.y - m.pose.y) : null;
|
|
65424
|
+
const moved = c !== null && m.charging !== null && c !== m.charging || walked !== null && walked > PADBOT_MOVED_M;
|
|
65425
|
+
if (!moved)
|
|
65426
|
+
return null;
|
|
65427
|
+
if (m.kind === "return") {
|
|
65428
|
+
if (c === PADBOT_CHARGING.DOCKING)
|
|
65429
|
+
return { text: "Docking", mode: "WORKING", done: false };
|
|
65430
|
+
if (c === PADBOT_CHARGING.DOCKED || c === PADBOT_CHARGING.UNDOCKING_OR_CHARGING)
|
|
65431
|
+
return { text: "Back on charger", mode: null, done: true };
|
|
65432
|
+
return { text: "On the way to the charger", mode: "WORKING", done: false };
|
|
65433
|
+
}
|
|
65434
|
+
if (m.charging === PADBOT_CHARGING.DOCKED && c === PADBOT_CHARGING.UNDOCKING_OR_CHARGING)
|
|
65435
|
+
return { text: "Leaving the charger", mode: "WORKING", done: false };
|
|
65436
|
+
const t = m.target;
|
|
65437
|
+
if (t && t.x !== null && t.y !== null && now.pose && Math.hypot(now.pose.x - t.x, now.pose.y - t.y) <= PADBOT_ARRIVED_M) {
|
|
65438
|
+
return { text: `Arrived at ${t.name}`, mode: null, done: true };
|
|
65439
|
+
}
|
|
65440
|
+
if (t)
|
|
65441
|
+
return { text: `On the way to ${t.name}`, mode: "WORKING", done: false };
|
|
65442
|
+
return { text: m.kind === "full" || m.kind === "area" || m.kind === "patrol-resume" ? "Patrolling" : "On the way", mode: "WORKING", done: false };
|
|
65443
|
+
}
|
|
65391
65444
|
function networkText(net) {
|
|
65392
65445
|
const say = (label2, v) => v < 0 ? ` \xB7 ${label2} ${v} dBm` : ` \xB7 ${label2} signal ${v}`;
|
|
65393
65446
|
const wifi = num(net?.wifi?.signalStrength);
|
|
@@ -65656,6 +65709,9 @@ function clearPadbotCache() {
|
|
|
65656
65709
|
live.clear();
|
|
65657
65710
|
commandLog.clear();
|
|
65658
65711
|
lastFailure.clear();
|
|
65712
|
+
motions.clear();
|
|
65713
|
+
robotReads.clear();
|
|
65714
|
+
alarmReads.clear();
|
|
65659
65715
|
}
|
|
65660
65716
|
function forgetPadbotMaps(appid, robotSn) {
|
|
65661
65717
|
for (const key of cache2.keys())
|
|
@@ -65684,6 +65740,11 @@ function logCommand(accountKey, robotSn, entry) {
|
|
|
65684
65740
|
var padbotCommandLog = (accountKey, robotSn) => commandLog.get(`${accountKey}:${robotSn}`) ?? [];
|
|
65685
65741
|
var lastFailure = /* @__PURE__ */ new Map();
|
|
65686
65742
|
var PADBOT_FAILURE_SHOW_MS = 3 * 6e4;
|
|
65743
|
+
var motions = /* @__PURE__ */ new Map();
|
|
65744
|
+
var PADBOT_ROBOT_READ_MS = 900;
|
|
65745
|
+
var robotReads = /* @__PURE__ */ new Map();
|
|
65746
|
+
var PADBOT_ALARM_READ_MS = 1e4;
|
|
65747
|
+
var alarmReads = /* @__PURE__ */ new Map();
|
|
65687
65748
|
async function readPadbotStates(credentials, robotSn, stateTypes) {
|
|
65688
65749
|
const list = await createPadbotClient(credentials).call(PADBOT_PATHS.states, { serialNumbers: [robotSn], stateTypes });
|
|
65689
65750
|
const entry = (list ?? []).find((e) => e?.serialNumber === robotSn);
|
|
@@ -65709,7 +65770,7 @@ async function listPadbotAlarmsSince(credentials, serials, startTime) {
|
|
|
65709
65770
|
}
|
|
65710
65771
|
function createPadbotAdapter(credentials, options = {}) {
|
|
65711
65772
|
const { call, raw } = createPadbotClient(credentials, options);
|
|
65712
|
-
const watch = options.watch === void 0 ? { everyMs: 2e3, forMs:
|
|
65773
|
+
const watch = options.watch === void 0 ? { everyMs: 2e3, forMs: 6e4 } : options.watch;
|
|
65713
65774
|
const sleep3 = options.sleep ?? ((ms2) => new Promise((resolve) => {
|
|
65714
65775
|
const t = setTimeout(resolve, ms2);
|
|
65715
65776
|
t?.unref?.();
|
|
@@ -65725,14 +65786,43 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65725
65786
|
const entry = (list ?? []).find((e) => e?.serialNumber === sn);
|
|
65726
65787
|
return entry ? statesByType(entry) : null;
|
|
65727
65788
|
};
|
|
65728
|
-
|
|
65789
|
+
function openAlarm(robotSn) {
|
|
65790
|
+
const k = `${account}:${robotSn}`;
|
|
65791
|
+
const hit = alarmReads.get(k);
|
|
65792
|
+
if (hit && now() - hit.at < PADBOT_ALARM_READ_MS)
|
|
65793
|
+
return hit.value;
|
|
65794
|
+
if (alarmReads.size > 2e3)
|
|
65795
|
+
alarmReads.clear();
|
|
65796
|
+
const value = call(PADBOT_PATHS.alarms, { serialNumbers: [robotSn], resolved: false, pageNumber: 1, pageSize: 1 }).then((d) => d?.items?.[0] ?? null).catch(() => {
|
|
65797
|
+
alarmReads.delete(k);
|
|
65798
|
+
return null;
|
|
65799
|
+
});
|
|
65800
|
+
alarmReads.set(k, { at: now(), value });
|
|
65801
|
+
return value;
|
|
65802
|
+
}
|
|
65803
|
+
function getRobot(robotSn) {
|
|
65804
|
+
const k = `${account}:${robotSn}`;
|
|
65805
|
+
const hit = robotReads.get(k);
|
|
65806
|
+
if (hit && now() - hit.at < PADBOT_ROBOT_READ_MS)
|
|
65807
|
+
return hit.value;
|
|
65808
|
+
if (robotReads.size > 2e3)
|
|
65809
|
+
robotReads.clear();
|
|
65810
|
+
const value = readRobot(robotSn);
|
|
65811
|
+
robotReads.set(k, { at: now(), value });
|
|
65812
|
+
value.catch(() => robotReads.delete(k));
|
|
65813
|
+
return value;
|
|
65814
|
+
}
|
|
65815
|
+
async function readRobot(robotSn) {
|
|
65816
|
+
const heard = padbotLive(account, robotSn);
|
|
65817
|
+
const pose = heard?.pose && now() - heard.pose.at < PADBOT_LIVE_POSE_MS ? heard.pose : null;
|
|
65818
|
+
const locRead = pose ? Promise.resolve({ mapId: pose.mapId, worldX: pose.x, worldY: pose.y, yaw: pose.yawDeg }) : call(PADBOT_PATHS.location, { serialNumber: robotSn }).catch(() => null);
|
|
65819
|
+
const alarmRead = openAlarm(robotSn);
|
|
65729
65820
|
const [st, list] = await Promise.all([states(robotSn), roster().catch(() => [])]);
|
|
65730
65821
|
if (!st)
|
|
65731
65822
|
return null;
|
|
65732
65823
|
const info = (list ?? []).find((r) => r?.serialNumber === robotSn);
|
|
65733
65824
|
const { online, mode, statusName } = padbotMode(st, now());
|
|
65734
65825
|
const floor = st["1007"]?.floor;
|
|
65735
|
-
const heard = padbotLive(account, robotSn);
|
|
65736
65826
|
const restBatteryAt = ms(st["1001"]?.updatedAt);
|
|
65737
65827
|
const battery = heard?.batteryPercent !== void 0 && (!Number.isFinite(restBatteryAt) || (heard.batteryAt ?? 0) > restBatteryAt) ? heard.batteryPercent : num(st["1001"]?.batteryPercent);
|
|
65738
65828
|
const failed = lastFailure.get(`${account}:${robotSn}`);
|
|
@@ -65759,11 +65849,8 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65759
65849
|
}
|
|
65760
65850
|
if (!online)
|
|
65761
65851
|
return robot;
|
|
65762
|
-
const
|
|
65763
|
-
const
|
|
65764
|
-
pose ? Promise.resolve({ mapId: pose.mapId, worldX: pose.x, worldY: pose.y, yaw: pose.yawDeg }) : call(PADBOT_PATHS.location, { serialNumber: robotSn }).catch(() => null),
|
|
65765
|
-
robot.fault ? Promise.resolve(null) : call(PADBOT_PATHS.alarms, { serialNumbers: [robotSn], resolved: false, pageNumber: 1, pageSize: 1 }).then((d) => d?.items?.[0] ?? null).catch(() => null)
|
|
65766
|
-
]);
|
|
65852
|
+
const [loc, openA] = await Promise.all([locRead, alarmRead]);
|
|
65853
|
+
const alarm = robot.fault ? null : openA;
|
|
65767
65854
|
const lx = num(loc?.worldX ?? loc?.x);
|
|
65768
65855
|
const ly = num(loc?.worldY ?? loc?.y);
|
|
65769
65856
|
if (typeof loc?.mapId === "string" && loc.mapId)
|
|
@@ -65775,6 +65862,13 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65775
65862
|
robot.position = { x: lx, y: ly, theta: (num(loc.yaw ?? loc.r) ?? 0) * Math.PI / 180 };
|
|
65776
65863
|
robot.planPosition = padbotPlanShare(map, lx, ly);
|
|
65777
65864
|
}
|
|
65865
|
+
const mo = motions.get(`${account}:${robotSn}`);
|
|
65866
|
+
const going = mo && now() - mo.sentAt < PADBOT_MOTION_MS && /^(Standing by|Charging)/.test(robot.statusName ?? "") ? padbotMotion(mo, { charging: st["1002"]?.chargingState, pose: robot.position ? { x: robot.position.x, y: robot.position.y } : null }) : null;
|
|
65867
|
+
if (going) {
|
|
65868
|
+
robot.statusName = (robot.statusName ?? "").replace(/^(Standing by|Charging)/, going.text);
|
|
65869
|
+
if (going.mode)
|
|
65870
|
+
robot.mode = going.mode;
|
|
65871
|
+
}
|
|
65778
65872
|
const last = heard?.pose;
|
|
65779
65873
|
if (!robot.position && last && (last.mapId === null || last.mapId === robot.mapId) && (robot.mode === "IDLE" || robot.mode === "CHARGING_CYCLE" || robot.mode === "CHARGED")) {
|
|
65780
65874
|
robot.position = { x: last.x, y: last.y, theta: (last.yawDeg ?? 0) * Math.PI / 180 };
|
|
@@ -65787,7 +65881,8 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65787
65881
|
if (pile) {
|
|
65788
65882
|
robot.position = { x: pile.worldX, y: pile.worldY, theta: (num(pile.yaw) ?? 0) * Math.PI / 180 };
|
|
65789
65883
|
robot.planPosition = padbotPlanShare(map, pile.worldX, pile.worldY);
|
|
65790
|
-
|
|
65884
|
+
if (!going || going.done)
|
|
65885
|
+
robot.statusName = `${robot.statusName} \xB7 At charger`;
|
|
65791
65886
|
}
|
|
65792
65887
|
if (!robot.position)
|
|
65793
65888
|
robot.statusName = `${robot.statusName} \xB7 Position not reported`;
|
|
@@ -65808,7 +65903,7 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65808
65903
|
const ids2 = [loc?.mapId, st?.["1007"]?.mapId];
|
|
65809
65904
|
const map = padbotCurrentMap(all, ids2, st?.["1007"]?.floor);
|
|
65810
65905
|
const mapId = map?.mapId ?? ids2.find((id) => typeof id === "string" && id) ?? null;
|
|
65811
|
-
return { st: st ?? {}, all: all ?? [], mapId };
|
|
65906
|
+
return { st: st ?? {}, all: all ?? [], mapId, loc };
|
|
65812
65907
|
}
|
|
65813
65908
|
const mapName = (all, id) => {
|
|
65814
65909
|
const m = all.find((x) => x?.mapId === id);
|
|
@@ -65832,10 +65927,10 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65832
65927
|
}
|
|
65833
65928
|
return String(rawRoute.pathId);
|
|
65834
65929
|
}
|
|
65835
|
-
async function watchReaction(robotSn, entry, sentAt) {
|
|
65930
|
+
async function watchReaction(robotSn, entry, sentAt, motion) {
|
|
65836
65931
|
if (!watch)
|
|
65837
65932
|
return;
|
|
65838
|
-
const r = entry.reaction = { watching: true, points: [], failure: null, moved: false };
|
|
65933
|
+
const r = entry.reaction = { watching: true, points: [], failure: null, moved: false, firstChangeAfterSeconds: null, progress: null };
|
|
65839
65934
|
let last = "";
|
|
65840
65935
|
try {
|
|
65841
65936
|
for (let waited = 0; waited < watch.forMs; ) {
|
|
@@ -65845,19 +65940,28 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65845
65940
|
if (!st)
|
|
65846
65941
|
continue;
|
|
65847
65942
|
const p = padbotReactionPoint(st);
|
|
65943
|
+
const after = Math.round((now() - sentAt) / 1e3);
|
|
65848
65944
|
const key = JSON.stringify(p);
|
|
65849
|
-
if (key !== last && r.points.length <
|
|
65850
|
-
r.points.push({ ...p, afterSeconds:
|
|
65945
|
+
if (key !== last && r.points.length < 30)
|
|
65946
|
+
r.points.push({ ...p, afterSeconds: after });
|
|
65851
65947
|
last = key;
|
|
65852
|
-
|
|
65948
|
+
const heard = padbotLive(account, robotSn)?.pose;
|
|
65949
|
+
const pose = heard && now() - heard.at < PADBOT_LIVE_POSE_MS ? { x: heard.x, y: heard.y } : null;
|
|
65950
|
+
const going = padbotMotion(motion, { charging: p.charging, pose });
|
|
65951
|
+
if (going || p.state >= 1 && p.state <= 5) {
|
|
65952
|
+
if (!r.moved)
|
|
65953
|
+
r.firstChangeAfterSeconds = after;
|
|
65853
65954
|
r.moved = true;
|
|
65955
|
+
}
|
|
65956
|
+
if (going)
|
|
65957
|
+
r.progress = going.text;
|
|
65854
65958
|
const failure = padbotFailureText(p);
|
|
65855
65959
|
if (failure) {
|
|
65856
65960
|
r.failure = failure;
|
|
65857
65961
|
lastFailure.set(`${account}:${robotSn}`, { at: now(), text: failure });
|
|
65858
65962
|
break;
|
|
65859
65963
|
}
|
|
65860
|
-
if (p.state === 5)
|
|
65964
|
+
if (p.state === 5 || going?.done)
|
|
65861
65965
|
break;
|
|
65862
65966
|
}
|
|
65863
65967
|
} finally {
|
|
@@ -65866,22 +65970,48 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65866
65970
|
}
|
|
65867
65971
|
async function sendCommand2(robotSn, command) {
|
|
65868
65972
|
const sn = { serialNumber: robotSn };
|
|
65973
|
+
const where = command.kind === "go-to-point" ? await whereIs(robotSn) : null;
|
|
65974
|
+
let motion = null;
|
|
65869
65975
|
if (MOVING_COMMANDS.has(command.kind)) {
|
|
65870
|
-
const
|
|
65976
|
+
const before = where?.st ?? await states(robotSn);
|
|
65977
|
+
const block = padbotCommandBlock(before, command.kind, now());
|
|
65871
65978
|
if (block)
|
|
65872
65979
|
throw new import_node_server_utils162.BadRequestError(block);
|
|
65873
65980
|
lastFailure.delete(`${account}:${robotSn}`);
|
|
65874
|
-
|
|
65981
|
+
const heard = padbotLive(account, robotSn)?.pose;
|
|
65982
|
+
const lx = num(where?.loc?.worldX);
|
|
65983
|
+
const ly = num(where?.loc?.worldY);
|
|
65984
|
+
let target = null;
|
|
65985
|
+
if (command.kind === "go-to-point") {
|
|
65986
|
+
const pt = (where?.all ?? []).flatMap((m) => Array.isArray(m?.targetPoints) ? m.targetPoints : []).find((t) => t?.targetPointId === command.targetPointId);
|
|
65987
|
+
target = { name: String(pt?.name || "the chosen point"), x: num(pt?.worldX), y: num(pt?.worldY) };
|
|
65988
|
+
}
|
|
65989
|
+
motion = {
|
|
65990
|
+
kind: command.kind,
|
|
65991
|
+
sentAt: 0,
|
|
65992
|
+
charging: typeof before?.["1002"]?.chargingState === "number" ? before["1002"].chargingState : null,
|
|
65993
|
+
pose: lx !== null && ly !== null ? { x: lx, y: ly } : heard ? { x: heard.x, y: heard.y } : null,
|
|
65994
|
+
target
|
|
65995
|
+
};
|
|
65996
|
+
} else if (command.kind === "cancel")
|
|
65997
|
+
motions.delete(`${account}:${robotSn}`);
|
|
65875
65998
|
const call2 = async (path5, body) => {
|
|
65876
65999
|
const at2 = new Date(now()).toISOString();
|
|
65877
66000
|
const meta = {};
|
|
66001
|
+
const t0 = Date.now();
|
|
65878
66002
|
try {
|
|
65879
66003
|
await callRaw(path5, body, meta);
|
|
65880
|
-
const entry = { at: at2, command: command.kind, path: path5, body, ok: true, vendorCode: 0, vendorMessage: meta.message, requestId: meta.requestId };
|
|
66004
|
+
const entry = { at: at2, command: command.kind, path: path5, body, ok: true, vendorCode: 0, vendorMessage: meta.message, requestId: meta.requestId, vendorMs: Date.now() - t0 };
|
|
65881
66005
|
logCommand(account, robotSn, entry);
|
|
65882
|
-
if (
|
|
65883
|
-
|
|
66006
|
+
if (motion) {
|
|
66007
|
+
motion.sentAt = now();
|
|
66008
|
+
if (motions.size > 2e3)
|
|
66009
|
+
motions.clear();
|
|
66010
|
+
motions.set(`${account}:${robotSn}`, motion);
|
|
66011
|
+
robotReads.delete(`${account}:${robotSn}`);
|
|
66012
|
+
void watchReaction(robotSn, entry, motion.sentAt, motion).catch(() => {
|
|
65884
66013
|
});
|
|
66014
|
+
}
|
|
65885
66015
|
} catch (e) {
|
|
65886
66016
|
logCommand(account, robotSn, {
|
|
65887
66017
|
at: at2,
|
|
@@ -65926,7 +66056,6 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65926
66056
|
await call2(PADBOT_PATHS.relocate, { ...sn, worldX: command.x, worldY: command.y });
|
|
65927
66057
|
return;
|
|
65928
66058
|
case "go-to-point": {
|
|
65929
|
-
const where = await whereIs(robotSn);
|
|
65930
66059
|
if (!padbotCanReachMap(where.all, where.mapId, command.mapId))
|
|
65931
66060
|
throw new import_node_server_utils162.BadRequestError(PADBOT_OTHER_MAP_TEXT);
|
|
65932
66061
|
await call2(PADBOT_PATHS.navigateTarget, { ...sn, mapId: command.mapId, targetPointId: command.targetPointId });
|
|
@@ -66024,6 +66153,8 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
66024
66153
|
}
|
|
66025
66154
|
for (let i = 0; i < ids2.length; i += 100)
|
|
66026
66155
|
await call(PADBOT_PATHS.resolve, { alarmIds: ids2.slice(i, i + 100) });
|
|
66156
|
+
robotReads.delete(`${account}:${robotSn}`);
|
|
66157
|
+
alarmReads.delete(`${account}:${robotSn}`);
|
|
66027
66158
|
return ids2.length;
|
|
66028
66159
|
},
|
|
66029
66160
|
async getPatrolHistory(robotSn, pageNumber, pageSize) {
|
|
@@ -90320,7 +90451,7 @@ function useNewDashboardRepo() {
|
|
|
90320
90451
|
todayAttentions.push({
|
|
90321
90452
|
id: pendingIncidentDocs[0]._id.toString(),
|
|
90322
90453
|
type: "incident",
|
|
90323
|
-
title: `${pendingIncidentCount} incident${pendingIncidentCount === 1 ? "" : "s"}
|
|
90454
|
+
title: `${pendingIncidentCount} incident${pendingIncidentCount === 1 ? "" : "s"} waiting to be acknowledged`,
|
|
90324
90455
|
createdAt: pendingIncidentDocs[0].updatedAt || pendingIncidentDocs[0].createdAt || /* @__PURE__ */ new Date()
|
|
90325
90456
|
});
|
|
90326
90457
|
}
|
|
@@ -90328,7 +90459,7 @@ function useNewDashboardRepo() {
|
|
|
90328
90459
|
todayAttentions.push({
|
|
90329
90460
|
id: pendingFacilityBookingDocs[0]._id.toString(),
|
|
90330
90461
|
type: "facility-booking",
|
|
90331
|
-
title: `${pendingFacilityBookingCount} facility booking${pendingFacilityBookingCount === 1 ? "" : "s"}
|
|
90462
|
+
title: `${pendingFacilityBookingCount} facility booking${pendingFacilityBookingCount === 1 ? "" : "s"} waiting for approval`,
|
|
90332
90463
|
createdAt: pendingFacilityBookingDocs[0].createdAt || /* @__PURE__ */ new Date()
|
|
90333
90464
|
});
|
|
90334
90465
|
}
|
|
@@ -105090,20 +105221,26 @@ function usePersonalEmergencyChainController() {
|
|
|
105090
105221
|
PADBOT_ACTION_TEXT,
|
|
105091
105222
|
PADBOT_ALARMS,
|
|
105092
105223
|
PADBOT_ALARM_POLL_MS,
|
|
105224
|
+
PADBOT_ALARM_READ_MS,
|
|
105093
105225
|
PADBOT_ALARM_TEXT,
|
|
105226
|
+
PADBOT_ARRIVED_M,
|
|
105094
105227
|
PADBOT_BRAND,
|
|
105095
105228
|
PADBOT_BRAND_DEFINITION,
|
|
105096
105229
|
PADBOT_CAPABILITIES,
|
|
105230
|
+
PADBOT_CHARGING,
|
|
105097
105231
|
PADBOT_DISPLAY_NAME,
|
|
105098
105232
|
PADBOT_FAILURE_SHOW_MS,
|
|
105099
105233
|
PADBOT_LIVE_POSE_MS,
|
|
105100
105234
|
PADBOT_MAKER_APP_ONLY,
|
|
105101
105235
|
PADBOT_MODELS,
|
|
105102
105236
|
PADBOT_MOTION,
|
|
105237
|
+
PADBOT_MOTION_MS,
|
|
105238
|
+
PADBOT_MOVED_M,
|
|
105103
105239
|
PADBOT_MQTT_SYNC_MS,
|
|
105104
105240
|
PADBOT_ONLINE_WINDOW_MS,
|
|
105105
105241
|
PADBOT_OTHER_MAP_TEXT,
|
|
105106
105242
|
PADBOT_PATHS,
|
|
105243
|
+
PADBOT_ROBOT_READ_MS,
|
|
105107
105244
|
PATROL_CCTV_CAMERA_FILTER,
|
|
105108
105245
|
PATROL_EMAIL_MAX_LOGS,
|
|
105109
105246
|
PATROL_EMAIL_MAX_PER_HOUR,
|
|
@@ -105454,6 +105591,7 @@ function usePersonalEmergencyChainController() {
|
|
|
105454
105591
|
padbotLive,
|
|
105455
105592
|
padbotManualDriveEnabled,
|
|
105456
105593
|
padbotMode,
|
|
105594
|
+
padbotMotion,
|
|
105457
105595
|
padbotMqttEnabled,
|
|
105458
105596
|
padbotPatrolPlan,
|
|
105459
105597
|
padbotPatrolRecord,
|