@7365admin1/core 3.123.0 → 3.124.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.d.ts +82 -4
- package/dist/index.js +148 -25
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +141 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/console-audit.test.mjs +8 -0
- package/test/padbot-movement.test.mjs +157 -0
- package/test/padbot.test.mjs +4 -4
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,
|
|
@@ -11336,6 +11343,7 @@ var ConsoleAuditAction = /* @__PURE__ */ ((ConsoleAuditAction3) => {
|
|
|
11336
11343
|
ConsoleAuditAction3["ROBOT_MAP_REMOVED"] = "robot.map-removed";
|
|
11337
11344
|
ConsoleAuditAction3["ROBOT_LIFT_REQUESTED"] = "robot.lift-requested";
|
|
11338
11345
|
ConsoleAuditAction3["ROBOT_LIFT_RELEASED"] = "robot.lift-released";
|
|
11346
|
+
ConsoleAuditAction3["INVENTORY_STORE_TYPE_REPAIRED"] = "inventory.store-type-repaired";
|
|
11339
11347
|
return ConsoleAuditAction3;
|
|
11340
11348
|
})(ConsoleAuditAction || {});
|
|
11341
11349
|
var CLIENT_ACTIONS = [
|
|
@@ -11373,7 +11381,8 @@ var CONSOLE_AUDIT_LABELS = {
|
|
|
11373
11381
|
["robot.map-updated" /* ROBOT_MAP_UPDATED */]: "Building map edited",
|
|
11374
11382
|
["robot.map-removed" /* ROBOT_MAP_REMOVED */]: "Building map removed",
|
|
11375
11383
|
["robot.lift-requested" /* ROBOT_LIFT_REQUESTED */]: "Robot asked for a lift",
|
|
11376
|
-
["robot.lift-released" /* ROBOT_LIFT_RELEASED */]: "Robot lift request released"
|
|
11384
|
+
["robot.lift-released" /* ROBOT_LIFT_RELEASED */]: "Robot lift request released",
|
|
11385
|
+
["inventory.store-type-repaired" /* INVENTORY_STORE_TYPE_REPAIRED */]: "Inventory store type corrected"
|
|
11377
11386
|
};
|
|
11378
11387
|
var ConsoleAuditTarget = /* @__PURE__ */ ((ConsoleAuditTarget2) => {
|
|
11379
11388
|
ConsoleAuditTarget2["ORGANIZATION"] = "organization";
|
|
@@ -11385,6 +11394,7 @@ var ConsoleAuditTarget = /* @__PURE__ */ ((ConsoleAuditTarget2) => {
|
|
|
11385
11394
|
ConsoleAuditTarget2["SITE"] = "site";
|
|
11386
11395
|
ConsoleAuditTarget2["ROBOT"] = "robot";
|
|
11387
11396
|
ConsoleAuditTarget2["ROBOT_MAP"] = "robot-map";
|
|
11397
|
+
ConsoleAuditTarget2["INVENTORY_STORE"] = "inventory-store";
|
|
11388
11398
|
return ConsoleAuditTarget2;
|
|
11389
11399
|
})(ConsoleAuditTarget || {});
|
|
11390
11400
|
var CAMERA_AUDIT_FIELDS = [
|
|
@@ -11432,6 +11442,7 @@ var ROBOT_MAP_AUDIT_FIELDS = [
|
|
|
11432
11442
|
];
|
|
11433
11443
|
var ROBOT_LIFT_AUDIT_FIELDS = ["name", "liftName", "fromFloor", "toFloor"];
|
|
11434
11444
|
var AUDIT_FIELDS = {
|
|
11445
|
+
["inventory.store-type-repaired" /* INVENTORY_STORE_TYPE_REPAIRED */]: ["ownerType", "name"],
|
|
11435
11446
|
["robot.map-saved" /* ROBOT_MAP_SAVED */]: ROBOT_MAP_AUDIT_FIELDS,
|
|
11436
11447
|
["robot.map-updated" /* ROBOT_MAP_UPDATED */]: ROBOT_MAP_AUDIT_FIELDS,
|
|
11437
11448
|
["robot.map-removed" /* ROBOT_MAP_REMOVED */]: ROBOT_MAP_AUDIT_FIELDS,
|
|
@@ -65348,9 +65359,9 @@ function padbotReadiness(states, now = Date.now()) {
|
|
|
65348
65359
|
const charging = st["1002"]?.chargingState;
|
|
65349
65360
|
const notes = [];
|
|
65350
65361
|
if (es.wheelLockState === 1)
|
|
65351
|
-
notes.push("
|
|
65362
|
+
notes.push("Wheel motor lock reads 1 (1006). The S2 reads 1 even while it drives, so this does not stop it.");
|
|
65352
65363
|
if (charging === 2)
|
|
65353
|
-
notes.push("Charging state 2
|
|
65364
|
+
notes.push("Charging state 2 = docked on the charger (inferred from the S2; PadBot's v4.0 document lists only 0 and 1).");
|
|
65354
65365
|
return {
|
|
65355
65366
|
online: padbotMode(st, now).online,
|
|
65356
65367
|
heartbeatAt: st["1000"]?.updatedAt ?? null,
|
|
@@ -65384,6 +65395,33 @@ function padbotFailureText(p) {
|
|
|
65384
65395
|
return null;
|
|
65385
65396
|
return `Could not reach ${p.target || "its destination"}${p.message ? ` (${p.message})` : ""}`;
|
|
65386
65397
|
}
|
|
65398
|
+
var PADBOT_CHARGING = { OFF: 0, UNDOCKING_OR_CHARGING: 1, DOCKED: 2, DOCKING: 3 };
|
|
65399
|
+
var PADBOT_MOVED_M = 0.3;
|
|
65400
|
+
var PADBOT_ARRIVED_M = 0.5;
|
|
65401
|
+
var PADBOT_MOTION_MS = 3 * 6e4;
|
|
65402
|
+
function padbotMotion(m, now) {
|
|
65403
|
+
const c = typeof now.charging === "number" ? now.charging : null;
|
|
65404
|
+
const walked = m.pose && now.pose ? Math.hypot(now.pose.x - m.pose.x, now.pose.y - m.pose.y) : null;
|
|
65405
|
+
const moved = c !== null && m.charging !== null && c !== m.charging || walked !== null && walked > PADBOT_MOVED_M;
|
|
65406
|
+
if (!moved)
|
|
65407
|
+
return null;
|
|
65408
|
+
if (m.kind === "return") {
|
|
65409
|
+
if (c === PADBOT_CHARGING.DOCKING)
|
|
65410
|
+
return { text: "Docking", mode: "WORKING", done: false };
|
|
65411
|
+
if (c === PADBOT_CHARGING.DOCKED || c === PADBOT_CHARGING.UNDOCKING_OR_CHARGING)
|
|
65412
|
+
return { text: "Back on charger", mode: null, done: true };
|
|
65413
|
+
return { text: "On the way to the charger", mode: "WORKING", done: false };
|
|
65414
|
+
}
|
|
65415
|
+
if (m.charging === PADBOT_CHARGING.DOCKED && c === PADBOT_CHARGING.UNDOCKING_OR_CHARGING)
|
|
65416
|
+
return { text: "Leaving the charger", mode: "WORKING", done: false };
|
|
65417
|
+
const t = m.target;
|
|
65418
|
+
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) {
|
|
65419
|
+
return { text: `Arrived at ${t.name}`, mode: null, done: true };
|
|
65420
|
+
}
|
|
65421
|
+
if (t)
|
|
65422
|
+
return { text: `On the way to ${t.name}`, mode: "WORKING", done: false };
|
|
65423
|
+
return { text: m.kind === "full" || m.kind === "area" || m.kind === "patrol-resume" ? "Patrolling" : "On the way", mode: "WORKING", done: false };
|
|
65424
|
+
}
|
|
65387
65425
|
function networkText(net) {
|
|
65388
65426
|
const say = (label2, v) => v < 0 ? ` \xB7 ${label2} ${v} dBm` : ` \xB7 ${label2} signal ${v}`;
|
|
65389
65427
|
const wifi = num(net?.wifi?.signalStrength);
|
|
@@ -65652,6 +65690,9 @@ function clearPadbotCache() {
|
|
|
65652
65690
|
live.clear();
|
|
65653
65691
|
commandLog.clear();
|
|
65654
65692
|
lastFailure.clear();
|
|
65693
|
+
motions.clear();
|
|
65694
|
+
robotReads.clear();
|
|
65695
|
+
alarmReads.clear();
|
|
65655
65696
|
}
|
|
65656
65697
|
function forgetPadbotMaps(appid, robotSn) {
|
|
65657
65698
|
for (const key of cache2.keys())
|
|
@@ -65680,6 +65721,11 @@ function logCommand(accountKey, robotSn, entry) {
|
|
|
65680
65721
|
var padbotCommandLog = (accountKey, robotSn) => commandLog.get(`${accountKey}:${robotSn}`) ?? [];
|
|
65681
65722
|
var lastFailure = /* @__PURE__ */ new Map();
|
|
65682
65723
|
var PADBOT_FAILURE_SHOW_MS = 3 * 6e4;
|
|
65724
|
+
var motions = /* @__PURE__ */ new Map();
|
|
65725
|
+
var PADBOT_ROBOT_READ_MS = 900;
|
|
65726
|
+
var robotReads = /* @__PURE__ */ new Map();
|
|
65727
|
+
var PADBOT_ALARM_READ_MS = 1e4;
|
|
65728
|
+
var alarmReads = /* @__PURE__ */ new Map();
|
|
65683
65729
|
async function readPadbotStates(credentials, robotSn, stateTypes) {
|
|
65684
65730
|
const list = await createPadbotClient(credentials).call(PADBOT_PATHS.states, { serialNumbers: [robotSn], stateTypes });
|
|
65685
65731
|
const entry = (list ?? []).find((e) => e?.serialNumber === robotSn);
|
|
@@ -65705,7 +65751,7 @@ async function listPadbotAlarmsSince(credentials, serials, startTime) {
|
|
|
65705
65751
|
}
|
|
65706
65752
|
function createPadbotAdapter(credentials, options = {}) {
|
|
65707
65753
|
const { call, raw } = createPadbotClient(credentials, options);
|
|
65708
|
-
const watch = options.watch === void 0 ? { everyMs: 2e3, forMs:
|
|
65754
|
+
const watch = options.watch === void 0 ? { everyMs: 2e3, forMs: 6e4 } : options.watch;
|
|
65709
65755
|
const sleep3 = options.sleep ?? ((ms2) => new Promise((resolve) => {
|
|
65710
65756
|
const t = setTimeout(resolve, ms2);
|
|
65711
65757
|
t?.unref?.();
|
|
@@ -65721,14 +65767,43 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65721
65767
|
const entry = (list ?? []).find((e) => e?.serialNumber === sn);
|
|
65722
65768
|
return entry ? statesByType(entry) : null;
|
|
65723
65769
|
};
|
|
65724
|
-
|
|
65770
|
+
function openAlarm(robotSn) {
|
|
65771
|
+
const k = `${account}:${robotSn}`;
|
|
65772
|
+
const hit = alarmReads.get(k);
|
|
65773
|
+
if (hit && now() - hit.at < PADBOT_ALARM_READ_MS)
|
|
65774
|
+
return hit.value;
|
|
65775
|
+
if (alarmReads.size > 2e3)
|
|
65776
|
+
alarmReads.clear();
|
|
65777
|
+
const value = call(PADBOT_PATHS.alarms, { serialNumbers: [robotSn], resolved: false, pageNumber: 1, pageSize: 1 }).then((d) => d?.items?.[0] ?? null).catch(() => {
|
|
65778
|
+
alarmReads.delete(k);
|
|
65779
|
+
return null;
|
|
65780
|
+
});
|
|
65781
|
+
alarmReads.set(k, { at: now(), value });
|
|
65782
|
+
return value;
|
|
65783
|
+
}
|
|
65784
|
+
function getRobot(robotSn) {
|
|
65785
|
+
const k = `${account}:${robotSn}`;
|
|
65786
|
+
const hit = robotReads.get(k);
|
|
65787
|
+
if (hit && now() - hit.at < PADBOT_ROBOT_READ_MS)
|
|
65788
|
+
return hit.value;
|
|
65789
|
+
if (robotReads.size > 2e3)
|
|
65790
|
+
robotReads.clear();
|
|
65791
|
+
const value = readRobot(robotSn);
|
|
65792
|
+
robotReads.set(k, { at: now(), value });
|
|
65793
|
+
value.catch(() => robotReads.delete(k));
|
|
65794
|
+
return value;
|
|
65795
|
+
}
|
|
65796
|
+
async function readRobot(robotSn) {
|
|
65797
|
+
const heard = padbotLive(account, robotSn);
|
|
65798
|
+
const pose = heard?.pose && now() - heard.pose.at < PADBOT_LIVE_POSE_MS ? heard.pose : null;
|
|
65799
|
+
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);
|
|
65800
|
+
const alarmRead = openAlarm(robotSn);
|
|
65725
65801
|
const [st, list] = await Promise.all([states(robotSn), roster().catch(() => [])]);
|
|
65726
65802
|
if (!st)
|
|
65727
65803
|
return null;
|
|
65728
65804
|
const info = (list ?? []).find((r) => r?.serialNumber === robotSn);
|
|
65729
65805
|
const { online, mode, statusName } = padbotMode(st, now());
|
|
65730
65806
|
const floor = st["1007"]?.floor;
|
|
65731
|
-
const heard = padbotLive(account, robotSn);
|
|
65732
65807
|
const restBatteryAt = ms(st["1001"]?.updatedAt);
|
|
65733
65808
|
const battery = heard?.batteryPercent !== void 0 && (!Number.isFinite(restBatteryAt) || (heard.batteryAt ?? 0) > restBatteryAt) ? heard.batteryPercent : num(st["1001"]?.batteryPercent);
|
|
65734
65809
|
const failed = lastFailure.get(`${account}:${robotSn}`);
|
|
@@ -65755,11 +65830,8 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65755
65830
|
}
|
|
65756
65831
|
if (!online)
|
|
65757
65832
|
return robot;
|
|
65758
|
-
const
|
|
65759
|
-
const
|
|
65760
|
-
pose ? Promise.resolve({ mapId: pose.mapId, worldX: pose.x, worldY: pose.y, yaw: pose.yawDeg }) : call(PADBOT_PATHS.location, { serialNumber: robotSn }).catch(() => null),
|
|
65761
|
-
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)
|
|
65762
|
-
]);
|
|
65833
|
+
const [loc, openA] = await Promise.all([locRead, alarmRead]);
|
|
65834
|
+
const alarm = robot.fault ? null : openA;
|
|
65763
65835
|
const lx = num(loc?.worldX ?? loc?.x);
|
|
65764
65836
|
const ly = num(loc?.worldY ?? loc?.y);
|
|
65765
65837
|
if (typeof loc?.mapId === "string" && loc.mapId)
|
|
@@ -65771,6 +65843,13 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65771
65843
|
robot.position = { x: lx, y: ly, theta: (num(loc.yaw ?? loc.r) ?? 0) * Math.PI / 180 };
|
|
65772
65844
|
robot.planPosition = padbotPlanShare(map, lx, ly);
|
|
65773
65845
|
}
|
|
65846
|
+
const mo = motions.get(`${account}:${robotSn}`);
|
|
65847
|
+
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;
|
|
65848
|
+
if (going) {
|
|
65849
|
+
robot.statusName = (robot.statusName ?? "").replace(/^(Standing by|Charging)/, going.text);
|
|
65850
|
+
if (going.mode)
|
|
65851
|
+
robot.mode = going.mode;
|
|
65852
|
+
}
|
|
65774
65853
|
const last = heard?.pose;
|
|
65775
65854
|
if (!robot.position && last && (last.mapId === null || last.mapId === robot.mapId) && (robot.mode === "IDLE" || robot.mode === "CHARGING_CYCLE" || robot.mode === "CHARGED")) {
|
|
65776
65855
|
robot.position = { x: last.x, y: last.y, theta: (last.yawDeg ?? 0) * Math.PI / 180 };
|
|
@@ -65783,7 +65862,8 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65783
65862
|
if (pile) {
|
|
65784
65863
|
robot.position = { x: pile.worldX, y: pile.worldY, theta: (num(pile.yaw) ?? 0) * Math.PI / 180 };
|
|
65785
65864
|
robot.planPosition = padbotPlanShare(map, pile.worldX, pile.worldY);
|
|
65786
|
-
|
|
65865
|
+
if (!going || going.done)
|
|
65866
|
+
robot.statusName = `${robot.statusName} \xB7 At charger`;
|
|
65787
65867
|
}
|
|
65788
65868
|
if (!robot.position)
|
|
65789
65869
|
robot.statusName = `${robot.statusName} \xB7 Position not reported`;
|
|
@@ -65804,7 +65884,7 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65804
65884
|
const ids2 = [loc?.mapId, st?.["1007"]?.mapId];
|
|
65805
65885
|
const map = padbotCurrentMap(all, ids2, st?.["1007"]?.floor);
|
|
65806
65886
|
const mapId = map?.mapId ?? ids2.find((id) => typeof id === "string" && id) ?? null;
|
|
65807
|
-
return { st: st ?? {}, all: all ?? [], mapId };
|
|
65887
|
+
return { st: st ?? {}, all: all ?? [], mapId, loc };
|
|
65808
65888
|
}
|
|
65809
65889
|
const mapName = (all, id) => {
|
|
65810
65890
|
const m = all.find((x) => x?.mapId === id);
|
|
@@ -65828,10 +65908,10 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65828
65908
|
}
|
|
65829
65909
|
return String(rawRoute.pathId);
|
|
65830
65910
|
}
|
|
65831
|
-
async function watchReaction(robotSn, entry, sentAt) {
|
|
65911
|
+
async function watchReaction(robotSn, entry, sentAt, motion) {
|
|
65832
65912
|
if (!watch)
|
|
65833
65913
|
return;
|
|
65834
|
-
const r = entry.reaction = { watching: true, points: [], failure: null, moved: false };
|
|
65914
|
+
const r = entry.reaction = { watching: true, points: [], failure: null, moved: false, firstChangeAfterSeconds: null, progress: null };
|
|
65835
65915
|
let last = "";
|
|
65836
65916
|
try {
|
|
65837
65917
|
for (let waited = 0; waited < watch.forMs; ) {
|
|
@@ -65841,19 +65921,28 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65841
65921
|
if (!st)
|
|
65842
65922
|
continue;
|
|
65843
65923
|
const p = padbotReactionPoint(st);
|
|
65924
|
+
const after = Math.round((now() - sentAt) / 1e3);
|
|
65844
65925
|
const key = JSON.stringify(p);
|
|
65845
|
-
if (key !== last && r.points.length <
|
|
65846
|
-
r.points.push({ ...p, afterSeconds:
|
|
65926
|
+
if (key !== last && r.points.length < 30)
|
|
65927
|
+
r.points.push({ ...p, afterSeconds: after });
|
|
65847
65928
|
last = key;
|
|
65848
|
-
|
|
65929
|
+
const heard = padbotLive(account, robotSn)?.pose;
|
|
65930
|
+
const pose = heard && now() - heard.at < PADBOT_LIVE_POSE_MS ? { x: heard.x, y: heard.y } : null;
|
|
65931
|
+
const going = padbotMotion(motion, { charging: p.charging, pose });
|
|
65932
|
+
if (going || p.state >= 1 && p.state <= 5) {
|
|
65933
|
+
if (!r.moved)
|
|
65934
|
+
r.firstChangeAfterSeconds = after;
|
|
65849
65935
|
r.moved = true;
|
|
65936
|
+
}
|
|
65937
|
+
if (going)
|
|
65938
|
+
r.progress = going.text;
|
|
65850
65939
|
const failure = padbotFailureText(p);
|
|
65851
65940
|
if (failure) {
|
|
65852
65941
|
r.failure = failure;
|
|
65853
65942
|
lastFailure.set(`${account}:${robotSn}`, { at: now(), text: failure });
|
|
65854
65943
|
break;
|
|
65855
65944
|
}
|
|
65856
|
-
if (p.state === 5)
|
|
65945
|
+
if (p.state === 5 || going?.done)
|
|
65857
65946
|
break;
|
|
65858
65947
|
}
|
|
65859
65948
|
} finally {
|
|
@@ -65862,22 +65951,48 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65862
65951
|
}
|
|
65863
65952
|
async function sendCommand2(robotSn, command) {
|
|
65864
65953
|
const sn = { serialNumber: robotSn };
|
|
65954
|
+
const where = command.kind === "go-to-point" ? await whereIs(robotSn) : null;
|
|
65955
|
+
let motion = null;
|
|
65865
65956
|
if (MOVING_COMMANDS.has(command.kind)) {
|
|
65866
|
-
const
|
|
65957
|
+
const before = where?.st ?? await states(robotSn);
|
|
65958
|
+
const block = padbotCommandBlock(before, command.kind, now());
|
|
65867
65959
|
if (block)
|
|
65868
65960
|
throw new import_node_server_utils162.BadRequestError(block);
|
|
65869
65961
|
lastFailure.delete(`${account}:${robotSn}`);
|
|
65870
|
-
|
|
65962
|
+
const heard = padbotLive(account, robotSn)?.pose;
|
|
65963
|
+
const lx = num(where?.loc?.worldX);
|
|
65964
|
+
const ly = num(where?.loc?.worldY);
|
|
65965
|
+
let target = null;
|
|
65966
|
+
if (command.kind === "go-to-point") {
|
|
65967
|
+
const pt = (where?.all ?? []).flatMap((m) => Array.isArray(m?.targetPoints) ? m.targetPoints : []).find((t) => t?.targetPointId === command.targetPointId);
|
|
65968
|
+
target = { name: String(pt?.name || "the chosen point"), x: num(pt?.worldX), y: num(pt?.worldY) };
|
|
65969
|
+
}
|
|
65970
|
+
motion = {
|
|
65971
|
+
kind: command.kind,
|
|
65972
|
+
sentAt: 0,
|
|
65973
|
+
charging: typeof before?.["1002"]?.chargingState === "number" ? before["1002"].chargingState : null,
|
|
65974
|
+
pose: lx !== null && ly !== null ? { x: lx, y: ly } : heard ? { x: heard.x, y: heard.y } : null,
|
|
65975
|
+
target
|
|
65976
|
+
};
|
|
65977
|
+
} else if (command.kind === "cancel")
|
|
65978
|
+
motions.delete(`${account}:${robotSn}`);
|
|
65871
65979
|
const call2 = async (path5, body) => {
|
|
65872
65980
|
const at2 = new Date(now()).toISOString();
|
|
65873
65981
|
const meta = {};
|
|
65982
|
+
const t0 = Date.now();
|
|
65874
65983
|
try {
|
|
65875
65984
|
await callRaw(path5, body, meta);
|
|
65876
|
-
const entry = { at: at2, command: command.kind, path: path5, body, ok: true, vendorCode: 0, vendorMessage: meta.message, requestId: meta.requestId };
|
|
65985
|
+
const entry = { at: at2, command: command.kind, path: path5, body, ok: true, vendorCode: 0, vendorMessage: meta.message, requestId: meta.requestId, vendorMs: Date.now() - t0 };
|
|
65877
65986
|
logCommand(account, robotSn, entry);
|
|
65878
|
-
if (
|
|
65879
|
-
|
|
65987
|
+
if (motion) {
|
|
65988
|
+
motion.sentAt = now();
|
|
65989
|
+
if (motions.size > 2e3)
|
|
65990
|
+
motions.clear();
|
|
65991
|
+
motions.set(`${account}:${robotSn}`, motion);
|
|
65992
|
+
robotReads.delete(`${account}:${robotSn}`);
|
|
65993
|
+
void watchReaction(robotSn, entry, motion.sentAt, motion).catch(() => {
|
|
65880
65994
|
});
|
|
65995
|
+
}
|
|
65881
65996
|
} catch (e) {
|
|
65882
65997
|
logCommand(account, robotSn, {
|
|
65883
65998
|
at: at2,
|
|
@@ -65922,7 +66037,6 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
65922
66037
|
await call2(PADBOT_PATHS.relocate, { ...sn, worldX: command.x, worldY: command.y });
|
|
65923
66038
|
return;
|
|
65924
66039
|
case "go-to-point": {
|
|
65925
|
-
const where = await whereIs(robotSn);
|
|
65926
66040
|
if (!padbotCanReachMap(where.all, where.mapId, command.mapId))
|
|
65927
66041
|
throw new import_node_server_utils162.BadRequestError(PADBOT_OTHER_MAP_TEXT);
|
|
65928
66042
|
await call2(PADBOT_PATHS.navigateTarget, { ...sn, mapId: command.mapId, targetPointId: command.targetPointId });
|
|
@@ -66020,6 +66134,8 @@ function createPadbotAdapter(credentials, options = {}) {
|
|
|
66020
66134
|
}
|
|
66021
66135
|
for (let i = 0; i < ids2.length; i += 100)
|
|
66022
66136
|
await call(PADBOT_PATHS.resolve, { alarmIds: ids2.slice(i, i + 100) });
|
|
66137
|
+
robotReads.delete(`${account}:${robotSn}`);
|
|
66138
|
+
alarmReads.delete(`${account}:${robotSn}`);
|
|
66023
66139
|
return ids2.length;
|
|
66024
66140
|
},
|
|
66025
66141
|
async getPatrolHistory(robotSn, pageNumber, pageSize) {
|
|
@@ -105086,20 +105202,26 @@ function usePersonalEmergencyChainController() {
|
|
|
105086
105202
|
PADBOT_ACTION_TEXT,
|
|
105087
105203
|
PADBOT_ALARMS,
|
|
105088
105204
|
PADBOT_ALARM_POLL_MS,
|
|
105205
|
+
PADBOT_ALARM_READ_MS,
|
|
105089
105206
|
PADBOT_ALARM_TEXT,
|
|
105207
|
+
PADBOT_ARRIVED_M,
|
|
105090
105208
|
PADBOT_BRAND,
|
|
105091
105209
|
PADBOT_BRAND_DEFINITION,
|
|
105092
105210
|
PADBOT_CAPABILITIES,
|
|
105211
|
+
PADBOT_CHARGING,
|
|
105093
105212
|
PADBOT_DISPLAY_NAME,
|
|
105094
105213
|
PADBOT_FAILURE_SHOW_MS,
|
|
105095
105214
|
PADBOT_LIVE_POSE_MS,
|
|
105096
105215
|
PADBOT_MAKER_APP_ONLY,
|
|
105097
105216
|
PADBOT_MODELS,
|
|
105098
105217
|
PADBOT_MOTION,
|
|
105218
|
+
PADBOT_MOTION_MS,
|
|
105219
|
+
PADBOT_MOVED_M,
|
|
105099
105220
|
PADBOT_MQTT_SYNC_MS,
|
|
105100
105221
|
PADBOT_ONLINE_WINDOW_MS,
|
|
105101
105222
|
PADBOT_OTHER_MAP_TEXT,
|
|
105102
105223
|
PADBOT_PATHS,
|
|
105224
|
+
PADBOT_ROBOT_READ_MS,
|
|
105103
105225
|
PATROL_CCTV_CAMERA_FILTER,
|
|
105104
105226
|
PATROL_EMAIL_MAX_LOGS,
|
|
105105
105227
|
PATROL_EMAIL_MAX_PER_HOUR,
|
|
@@ -105450,6 +105572,7 @@ function usePersonalEmergencyChainController() {
|
|
|
105450
105572
|
padbotLive,
|
|
105451
105573
|
padbotManualDriveEnabled,
|
|
105452
105574
|
padbotMode,
|
|
105575
|
+
padbotMotion,
|
|
105453
105576
|
padbotMqttEnabled,
|
|
105454
105577
|
padbotPatrolPlan,
|
|
105455
105578
|
padbotPatrolRecord,
|