@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/dist/index.mjs CHANGED
@@ -64708,6 +64708,12 @@ function padbotCurrentMap(maps, ids2, floor) {
64708
64708
  const onFloor = Number.isInteger(floor) ? list.filter((m) => m.floor === floor) : [];
64709
64709
  return onFloor.length === 1 ? onFloor[0] : null;
64710
64710
  }
64711
+ function padbotChargingPoint(map) {
64712
+ const piles = (Array.isArray(map?.targetPoints) ? map.targetPoints : []).filter(
64713
+ (t) => Number(t?.targetPointType) === 10 && num(t?.worldX) !== null && num(t?.worldY) !== null
64714
+ );
64715
+ return piles.length === 1 ? { worldX: num(piles[0].worldX), worldY: num(piles[0].worldY), yaw: piles[0].yaw } : null;
64716
+ }
64711
64717
  var PADBOT_OTHER_MAP_TEXT = "The robot must be on this map first.";
64712
64718
  function padbotAlarmFault(alarm) {
64713
64719
  if (!alarm?.alarmType)
@@ -64746,7 +64752,19 @@ function padbotPatrolPlan(paths, maps, states = {}) {
64746
64752
  }
64747
64753
  return null;
64748
64754
  };
64749
- const routes = (Array.isArray(paths) ? paths : []).map((p) => {
64755
+ const routeMapId = (p) => {
64756
+ if (typeof p?.mapId === "string" && p.mapId)
64757
+ return p.mapId;
64758
+ const names = Array.isArray(p?.points) && p.points.length ? p.points.map((pt) => pt?.targetPointName) : Array.isArray(p?.pointNames) ? p.pointNames : [];
64759
+ if (!names.length)
64760
+ return p?.mapId;
64761
+ const holders = allMaps.filter((m) => names.every((n) => (m?.targetPoints ?? []).some((t) => t?.name === n)));
64762
+ if (holders.length === 1)
64763
+ return holders[0].mapId;
64764
+ return holders.find((m) => m?.mapId === currentMap)?.mapId ?? p?.mapId;
64765
+ };
64766
+ const routes = (Array.isArray(paths) ? paths : []).map((path5) => {
64767
+ const p = { ...path5, mapId: routeMapId(path5) };
64750
64768
  const map = mapById.get(p?.mapId);
64751
64769
  const raw = Array.isArray(p?.points) && p.points.length ? [...p.points].sort((a, b) => (a?.pointIndex ?? 0) - (b?.pointIndex ?? 0)).map((pt) => ({ id: pt?.targetPointId, name: pt?.targetPointName, mapId: pt?.mapId ?? p?.mapId })) : (Array.isArray(p?.pointNames) ? p.pointNames : []).map((n) => ({ name: n, mapId: p?.mapId }));
64752
64770
  const placed = raw.map((pt) => {
@@ -65022,6 +65040,13 @@ function createPadbotAdapter(credentials, options = {}) {
65022
65040
  const mins = Math.floor((now() - last.at) / 6e4);
65023
65041
  robot.statusName = `${robot.statusName} \xB7 Last reported position${mins >= 1 ? ` (${mins} min ago)` : ""}`;
65024
65042
  }
65043
+ const onCharger = [1, 2].includes(st["1002"]?.chargingState);
65044
+ const pile = onCharger && !robot.position ? padbotChargingPoint(map) : null;
65045
+ if (pile) {
65046
+ robot.position = { x: pile.worldX, y: pile.worldY, theta: (num(pile.yaw) ?? 0) * Math.PI / 180 };
65047
+ robot.planPosition = padbotPlanShare(map, pile.worldX, pile.worldY);
65048
+ robot.statusName = `${robot.statusName} \xB7 At charger`;
65049
+ }
65025
65050
  if (!robot.position)
65026
65051
  robot.statusName = `${robot.statusName} \xB7 Position not reported`;
65027
65052
  if (alarm)
@@ -105059,6 +105084,7 @@ export {
105059
105084
  padbotAlarmPollEnabled,
105060
105085
  padbotBaseUrl,
105061
105086
  padbotCanReachMap,
105087
+ padbotChargingPoint,
105062
105088
  padbotCheckpointVisit,
105063
105089
  padbotCommandLog,
105064
105090
  padbotCurrentMap,