@7365admin1/core 3.122.3 → 3.122.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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +28 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/padbot.test.mjs +36 -5
package/package.json
CHANGED
package/test/padbot.test.mjs
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
padbotCheckpointVisit,
|
|
25
25
|
padbotPlanShare,
|
|
26
26
|
padbotCurrentMap,
|
|
27
|
+
padbotChargingPoint,
|
|
27
28
|
padbotAccountKey,
|
|
28
29
|
recordPadbotLive,
|
|
29
30
|
statesByType,
|
|
@@ -587,26 +588,33 @@ test("adapter listRobots: the account's patrol robots with one batched state rea
|
|
|
587
588
|
const S2_LVL3 = "40f18c40a12ee2f3c0b20b38dc7a5b0f";
|
|
588
589
|
const S2_MAPS = [
|
|
589
590
|
{ mapId: "24fe9c97e9160548d100dab541f1662a", mapName: "20260528172106098_5ecd8fa9", mapDisplayName: "B1", building: "", floor: 1, isDefault: false, width: 1092, height: 1865, resolution: 0.05, originX: -27.55, originY: -80, mapGroup: "" },
|
|
590
|
-
{ mapId: S2_LVL3, mapName: "772df9dc808b45a5_20260924185244234", mapDisplayName: "Lvl3 Office", building: "", floor: 3, isDefault: true, width: 255, height: 244, resolution: 0.05, originX: -24.7, originY: -2.3, mapGroup: ""
|
|
591
|
+
{ mapId: S2_LVL3, mapName: "772df9dc808b45a5_20260924185244234", mapDisplayName: "Lvl3 Office", building: "", floor: 3, isDefault: true, width: 255, height: 244, resolution: 0.05, originX: -24.7, originY: -2.3, mapGroup: "",
|
|
592
|
+
targetPoints: [
|
|
593
|
+
{ name: "P4", targetPointType: 0, worldX: -22.3, worldY: 4.1, yaw: 188 },
|
|
594
|
+
{ name: "P3", targetPointType: 0, worldX: -18.75, worldY: 6.4, yaw: 170 },
|
|
595
|
+
{ name: "Charging Area", targetPointType: 10, worldX: -13.9, worldY: 8.75, yaw: 266 },
|
|
596
|
+
{ name: "P1", targetPointType: 0, worldX: -13.7, worldY: 5.15, yaw: 258 },
|
|
597
|
+
{ name: "P2", targetPointType: 0, worldX: -15.55, worldY: 7.1, yaw: 29 },
|
|
598
|
+
] },
|
|
591
599
|
];
|
|
592
|
-
const s2States = (mapId = S2_LVL3) => [
|
|
600
|
+
const s2States = (mapId = S2_LVL3, chargingState = 2) => [
|
|
593
601
|
{
|
|
594
602
|
serialNumber: "PS8517",
|
|
595
603
|
states: [
|
|
596
604
|
{ stateType: "1000", data: { updatedAt: fresh } },
|
|
597
605
|
{ stateType: "1001", data: { updatedAt: fresh, batteryPercent: 100 } },
|
|
598
|
-
{ stateType: "1002", data: { updatedAt: fresh, chargingState
|
|
606
|
+
{ stateType: "1002", data: { updatedAt: fresh, chargingState } },
|
|
599
607
|
{ stateType: "1003", data: { updatedAt: fresh, mapName: null, nextTargetPointName: null, finalTargetPointName: null, actionType: 0, actionState: 0, message: null } },
|
|
600
608
|
{ stateType: "1007", data: { updatedAt: "2026-09-24T10:52:45.143Z", mapId, floor: 3, mapDisplayName: "Lvl3 Office", width: 255, height: 244 } },
|
|
601
609
|
{ stateType: "1010", data: { updatedAt: fresh, workState: 0, taskType: 0, taskInfo: null } },
|
|
602
610
|
],
|
|
603
611
|
},
|
|
604
612
|
];
|
|
605
|
-
const s2Robot = (location, mapId, heardPose) => {
|
|
613
|
+
const s2Robot = (location, mapId, heardPose, chargingState = 0) => {
|
|
606
614
|
clearPadbotCache();
|
|
607
615
|
if (heardPose) recordPadbotLive(padbotAccountKey(CREDS), "PS8517", { pose: heardPose });
|
|
608
616
|
const f = fakePadbot({
|
|
609
|
-
[PADBOT_PATHS.states]: () => s2States(mapId),
|
|
617
|
+
[PADBOT_PATHS.states]: () => s2States(mapId, chargingState),
|
|
610
618
|
[PADBOT_PATHS.robots]: () => [{ serialNumber: "PS8517", robotName: "HERO-OTH-SECURITY", robotType: "PATROL", robotModel: "S2" }],
|
|
611
619
|
[PADBOT_PATHS.location]: () => location,
|
|
612
620
|
[PADBOT_PATHS.maps]: () => S2_MAPS,
|
|
@@ -654,3 +662,26 @@ test("real S2: PadBot's REST gives null coordinates while standing still -> its
|
|
|
654
662
|
assert.match(other.statusName, /Position not reported$/);
|
|
655
663
|
clearPadbotCache();
|
|
656
664
|
});
|
|
665
|
+
|
|
666
|
+
test("real S2 docked (1002 chargingState 2, REST null, no MQTT pose) -> pin at Lvl3's Charging Area, 'At charger'", async () => {
|
|
667
|
+
const r = await s2Robot({ mapId: S2_LVL3, worldX: null, worldY: null, yaw: -94 }, undefined, undefined, 2);
|
|
668
|
+
assert.deepEqual(r.planPosition, padbotPlanShare(S2_MAPS[1], -13.9, 8.75));
|
|
669
|
+
assert.match(r.statusName, /At charger$/);
|
|
670
|
+
const off = await s2Robot({ mapId: S2_LVL3, worldX: null, worldY: null, yaw: -94 }, undefined, undefined, 0);
|
|
671
|
+
assert.equal(off.position, null, "not on the charger: no pin");
|
|
672
|
+
assert.equal(padbotChargingPoint({ targetPoints: [{ targetPointType: 10, worldX: 1, worldY: 1 }, { targetPointType: 10, worldX: 2, worldY: 2 }] }), null, "two piles: no guess");
|
|
673
|
+
});
|
|
674
|
+
|
|
675
|
+
test("real S2 routes with mapId null -> each on the map holding all its stops (names repeat across maps)", () => {
|
|
676
|
+
const b1 = { ...S2_MAPS[0], targetPoints: ["P1", "P2", "P3", "P4", "P5"].map((name, i) => ({ name, targetPointType: 0, worldX: -20 + i, worldY: -70 + i })) };
|
|
677
|
+
const maps = [b1, S2_MAPS[1]];
|
|
678
|
+
const paths = [
|
|
679
|
+
{ pathId: "a", pathName: "B1", mapId: null, isDefault: true, pointNames: ["P1", "P2", "P3", "P4", "P5"] },
|
|
680
|
+
{ pathId: "b", pathName: "Patrolling Lvl3", mapId: null, isDefault: false, pointNames: ["P1", "P2", "P3", "P4"] },
|
|
681
|
+
];
|
|
682
|
+
const plan = padbotPatrolPlan(paths, maps, { "1007": { mapId: S2_LVL3, floor: 3 } });
|
|
683
|
+
const byId = Object.fromEntries(plan.routes.map((r) => [r.id, r]));
|
|
684
|
+
assert.equal(byId.a.mapId, b1.mapId);
|
|
685
|
+
assert.equal(byId.b.mapId, S2_LVL3, "on both maps -> the robot's current map");
|
|
686
|
+
assert.deepEqual(byId.b.checkpoints[0], { name: "P1", ...padbotPlanShare(S2_MAPS[1], -13.7, 5.15) }, "placed with Lvl3's P1, not B1's");
|
|
687
|
+
});
|