@7365admin1/core 3.120.0 → 3.121.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.ts +19 -1
- package/dist/index.js +33 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/test/padbot-mqtt.test.mjs +3 -1
- package/test/padbot-real-data.test.mjs +50 -0
package/package.json
CHANGED
|
@@ -346,7 +346,9 @@ test("go-to-point: parsed strictly; needs navigateToPoint; PadBot sends §5.7 wi
|
|
|
346
346
|
const path = new URL(url).pathname;
|
|
347
347
|
calls.push({ path, body: JSON.parse(init.body) });
|
|
348
348
|
const code = path === PADBOT_PATHS.stop ? 1009 : 0;
|
|
349
|
-
|
|
349
|
+
// The robot reports map m1 (§4.2 1007), so a point on m1 is reachable.
|
|
350
|
+
const data = path === PADBOT_PATHS.states ? [{ serialNumber: "PS1", states: [{ stateType: "1007", data: { mapId: "m1" } }] }] : null;
|
|
351
|
+
return { status: 200, text: async () => JSON.stringify({ code, message: code ? "robot busy" : "success", data }) };
|
|
350
352
|
};
|
|
351
353
|
const a = createPadbotAdapter(creds, { baseUrl: "https://pb.test", fetch });
|
|
352
354
|
await a.sendCommand("PS1", { kind: "go-to-point", mapId: "m1", targetPointId: "t2" });
|
|
@@ -13,6 +13,8 @@ import {
|
|
|
13
13
|
clearPadbotCache,
|
|
14
14
|
createPadbotAdapter,
|
|
15
15
|
networkText,
|
|
16
|
+
PADBOT_OTHER_MAP_TEXT,
|
|
17
|
+
padbotCanReachMap,
|
|
16
18
|
padbotPatrolPlan,
|
|
17
19
|
} from "./.build/services/padbot.adapter.mjs";
|
|
18
20
|
import { normalisePatrolPlan } from "./.build/utils/robot-adapter.util.mjs";
|
|
@@ -163,3 +165,51 @@ test("live video: HD asks PadBot for quality 1, default smooth for quality 2", a
|
|
|
163
165
|
await a.getLiveVideo("PS8517");
|
|
164
166
|
assert.deepEqual(f.calls.map((c) => c.body.quality), [1, 2]);
|
|
165
167
|
});
|
|
168
|
+
|
|
169
|
+
/* ---------------------------- multi-map robots (owner report 2026-09-26: 2 maps, no choice) */
|
|
170
|
+
|
|
171
|
+
test("maps: the robot's current map comes from §4.2 1007 (and §4.3 when it names one)", async () => {
|
|
172
|
+
clearPadbotCache();
|
|
173
|
+
const f = fake({
|
|
174
|
+
[PADBOT_PATHS.states]: () => [{ serialNumber: "PS8517", states: [
|
|
175
|
+
{ stateType: "1000", data: { updatedAt: fresh } },
|
|
176
|
+
{ stateType: "1007", data: { mapId: "20260528172106098_5ecd8fa9", floor: -1, updatedAt: fresh } },
|
|
177
|
+
] }],
|
|
178
|
+
[PADBOT_PATHS.location]: () => ({ mapId: "772df9dc808b45a5_20260924185244234", worldX: 1, worldY: 1, yaw: 0 }),
|
|
179
|
+
[PADBOT_PATHS.maps]: () => [],
|
|
180
|
+
[PADBOT_PATHS.alarms]: () => ({ items: [] }),
|
|
181
|
+
});
|
|
182
|
+
const a = createPadbotAdapter(CREDS, { baseUrl: "https://pb.test", fetch: f.fetch, now: () => NOW });
|
|
183
|
+
const r = await a.getRobot("PS8517");
|
|
184
|
+
assert.equal(r.mapId, "772df9dc808b45a5_20260924185244234", "the location read's map wins (it is the newest)");
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
test("routes: each route keeps the id of the map it belongs to", () => {
|
|
188
|
+
const maps = [{ mapId: "mB1", floor: -1 }, { mapId: "mL3", floor: 3 }];
|
|
189
|
+
const paths = [
|
|
190
|
+
{ pathId: "p1", pathName: "B1", mapId: "mB1", isDefault: true, pointNames: ["Gate", "Lobby"] },
|
|
191
|
+
{ pathId: "p2", pathName: "Patrolling Lvl3", mapId: "mL3", pointNames: ["Lift", "Store"] },
|
|
192
|
+
];
|
|
193
|
+
const plan = normalisePatrolPlan(padbotPatrolPlan(paths, maps, {}));
|
|
194
|
+
assert.deepEqual(plan.routes.map((r) => [r.name, r.mapId, r.floorNo]), [["B1 (default)", "mB1", -1], ["Patrolling Lvl3", "mL3", 3]]);
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
test("go to point on another map: only inside one map group, else 'The robot must be on this map first.'", async () => {
|
|
198
|
+
assert.equal(padbotCanReachMap([], "m1", "m1"), true);
|
|
199
|
+
assert.equal(padbotCanReachMap([{ mapId: "m1", mapGroup: "" }, { mapId: "m2", mapGroup: "" }], "m1", "m2"), false);
|
|
200
|
+
assert.equal(padbotCanReachMap([{ mapId: "m1", mapGroup: "tower" }, { mapId: "m2", mapGroup: "tower" }], "m1", "m2"), true);
|
|
201
|
+
assert.equal(padbotCanReachMap([{ mapId: "m1", mapGroup: "a" }, { mapId: "m2", mapGroup: "b" }], "m1", "m2"), false);
|
|
202
|
+
assert.equal(padbotCanReachMap([], null, "m1"), false, "unknown current map: refused, never guessed");
|
|
203
|
+
|
|
204
|
+
clearPadbotCache();
|
|
205
|
+
const f = fake({
|
|
206
|
+
[PADBOT_PATHS.states]: () => [{ serialNumber: "PS8517", states: [{ stateType: "1007", data: { mapId: "m1" } }] }],
|
|
207
|
+
[PADBOT_PATHS.maps]: () => [{ mapId: "m1", mapGroup: "" }, { mapId: "m2", mapGroup: "" }],
|
|
208
|
+
[PADBOT_PATHS.navigateTarget]: () => null,
|
|
209
|
+
});
|
|
210
|
+
const a = createPadbotAdapter(CREDS, { baseUrl: "https://pb.test", fetch: f.fetch, now: () => NOW });
|
|
211
|
+
await assert.rejects(a.sendCommand("PS8517", { kind: "go-to-point", mapId: "m2", targetPointId: "t9" }), (e) => e.message === PADBOT_OTHER_MAP_TEXT);
|
|
212
|
+
assert.ok(!f.calls.some((c) => c.path === PADBOT_PATHS.navigateTarget), "nothing sent to the robot");
|
|
213
|
+
await a.sendCommand("PS8517", { kind: "go-to-point", mapId: "m1", targetPointId: "t1" });
|
|
214
|
+
assert.equal(f.calls.at(-1).path, PADBOT_PATHS.navigateTarget);
|
|
215
|
+
});
|