@7365admin1/core 3.93.0 → 3.95.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 +16 -0
- package/dist/index.d.ts +391 -117
- package/dist/index.js +866 -224
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +957 -336
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/test/e2e/harness.mjs +1 -0
- package/test/e2e/open-rmf.e2e.test.mjs +185 -0
- package/test/fixtures/open-rmf/building_map.json +1168 -0
- package/test/fixtures/open-rmf/door_state.json +10 -0
- package/test/fixtures/open-rmf/fleets.json +109 -0
- package/test/fixtures/open-rmf/lift_state.json +19 -0
- package/test/fixtures/open-rmf/robot_task_response.json +42 -0
- package/test/fixtures/open-rmf/schemas/LICENSE.md +201 -0
- package/test/fixtures/open-rmf/schemas/NOTICE.md +7 -0
- package/test/fixtures/open-rmf/schemas/cancel_task_request.json +24 -0
- package/test/fixtures/open-rmf/schemas/fleet_state.json +15 -0
- package/test/fixtures/open-rmf/schemas/interrupt_task_request.json +24 -0
- package/test/fixtures/open-rmf/schemas/location_2D.json +14 -0
- package/test/fixtures/open-rmf/schemas/resume_task_request.json +30 -0
- package/test/fixtures/open-rmf/schemas/robot_state.json +69 -0
- package/test/fixtures/open-rmf/schemas/robot_task_request.json +24 -0
- package/test/fixtures/open-rmf/schemas/task_request.json +42 -0
- package/test/fixtures/open-rmf/schemas/task_state.json +278 -0
- package/test/fixtures/open-rmf/task_state_clean_completed.json +119 -0
- package/test/fixtures/open-rmf/task_state_patrol.json +1 -0
- package/test/open-rmf.test.mjs +297 -0
package/dist/index.js
CHANGED
|
@@ -86,6 +86,7 @@ __export(src_exports, {
|
|
|
86
86
|
DEMO_ROUTES: () => DEMO_ROUTES,
|
|
87
87
|
DEVICE_STATUS: () => DEVICE_STATUS,
|
|
88
88
|
DOBStatus: () => DOBStatus,
|
|
89
|
+
DOOR_MODE: () => DOOR_MODE,
|
|
89
90
|
DUPLICATE_TERMS_VERSION_MESSAGE: () => DUPLICATE_TERMS_VERSION_MESSAGE,
|
|
90
91
|
DayOfWeek: () => DayOfWeek,
|
|
91
92
|
E164: () => E164,
|
|
@@ -225,6 +226,9 @@ __export(src_exports, {
|
|
|
225
226
|
NotificationModule: () => NotificationModule,
|
|
226
227
|
NotificationService: () => NotificationService,
|
|
227
228
|
OFFLINE_FAULT_CODE: () => OFFLINE_FAULT_CODE,
|
|
229
|
+
OPEN_RMF_BRAND: () => OPEN_RMF_BRAND,
|
|
230
|
+
OPEN_RMF_CAPABILITIES: () => OPEN_RMF_CAPABILITIES,
|
|
231
|
+
OPEN_RMF_DISPLAY_NAME: () => OPEN_RMF_DISPLAY_NAME,
|
|
228
232
|
ORG_MARKETPLACE_VENDOR_FIELD: () => ORG_MARKETPLACE_VENDOR_FIELD,
|
|
229
233
|
ORG_OWNER_REPAIR_CLAIM_STALE_MS: () => ORG_OWNER_REPAIR_CLAIM_STALE_MS,
|
|
230
234
|
ORG_OWNER_REPAIR_CLAIM_TAKEN_REASON: () => ORG_OWNER_REPAIR_CLAIM_TAKEN_REASON,
|
|
@@ -233,6 +237,7 @@ __export(src_exports, {
|
|
|
233
237
|
OUNITECH_BRAND: () => OUNITECH_BRAND,
|
|
234
238
|
OUNITECH_CAPABILITIES: () => OUNITECH_CAPABILITIES,
|
|
235
239
|
OUNITECH_PENDING_COMMANDS: () => OUNITECH_PENDING_COMMANDS,
|
|
240
|
+
OpenRmfError: () => OpenRmfError,
|
|
236
241
|
OrgNature: () => OrgNature,
|
|
237
242
|
OvernightParkingRequestSort: () => OvernightParkingRequestSort,
|
|
238
243
|
OvernightParkingRequestStatus: () => OvernightParkingRequestStatus,
|
|
@@ -329,6 +334,7 @@ __export(src_exports, {
|
|
|
329
334
|
attendanceSchema: () => attendanceSchema,
|
|
330
335
|
attendanceSettingsSchema: () => attendanceSettingsSchema,
|
|
331
336
|
buildSelfServiceEmailContext: () => buildSelfServiceEmailContext,
|
|
337
|
+
buildingFromRmf: () => buildingFromRmf,
|
|
332
338
|
buildingMapBodySchema: () => buildingMapBodySchema,
|
|
333
339
|
buildingMapCreateSchema: () => buildingMapCreateSchema,
|
|
334
340
|
buildingMapFromRobotMaps: () => buildingMapFromRobotMaps,
|
|
@@ -370,6 +376,8 @@ __export(src_exports, {
|
|
|
370
376
|
createDemoAdapter: () => createDemoAdapter,
|
|
371
377
|
createLiftSimulator: () => createLiftSimulator,
|
|
372
378
|
createManpowerRemarksDaily: () => createManpowerRemarksDaily,
|
|
379
|
+
createOpenRmfAdapter: () => createOpenRmfAdapter,
|
|
380
|
+
createOpenRmfClient: () => createOpenRmfClient,
|
|
373
381
|
createOunitechAdapter: () => createOunitechAdapter,
|
|
374
382
|
createSseParser: () => createSseParser,
|
|
375
383
|
customerSchema: () => customerSchema,
|
|
@@ -392,6 +400,7 @@ __export(src_exports, {
|
|
|
392
400
|
deviceHttpTimeoutMs: () => deviceHttpTimeoutMs,
|
|
393
401
|
deviceProbeTtlSeconds: () => deviceProbeTtlSeconds,
|
|
394
402
|
disconnectedState: () => disconnectedState,
|
|
403
|
+
doorModeOf: () => doorModeOf,
|
|
395
404
|
emitNotificationCreated: () => emitNotificationCreated,
|
|
396
405
|
emptyPersonalEmergencyChain: () => emptyPersonalEmergencyChain,
|
|
397
406
|
encodeGreyscalePng: () => encodeGreyscalePng,
|
|
@@ -408,6 +417,7 @@ __export(src_exports, {
|
|
|
408
417
|
ffmpegFrameArgs: () => ffmpegFrameArgs,
|
|
409
418
|
ffmpegPath: () => ffmpegPath,
|
|
410
419
|
filterByAccess: () => filterByAccess,
|
|
420
|
+
floorNoOf: () => floorNoOf,
|
|
411
421
|
formatCapabilityTrace: () => formatCapabilityTrace,
|
|
412
422
|
formatDahuaDate: () => formatDahuaDate,
|
|
413
423
|
getIO: () => getIO,
|
|
@@ -430,6 +440,7 @@ __export(src_exports, {
|
|
|
430
440
|
isAvailableForWork: () => isAvailableForWork,
|
|
431
441
|
isCameraEntitled: () => isCameraEntitled,
|
|
432
442
|
isDispatchable: () => isDispatchable,
|
|
443
|
+
isDoorPassable: () => isDoorPassable,
|
|
433
444
|
isDuplicateMemberError: () => isDuplicateMemberError,
|
|
434
445
|
isDuplicateVersionError: () => isDuplicateVersionError,
|
|
435
446
|
isLiftAvailable: () => isLiftAvailable,
|
|
@@ -484,6 +495,9 @@ __export(src_exports, {
|
|
|
484
495
|
occurrence_book_namespace_collection: () => occurrence_book_namespace_collection,
|
|
485
496
|
onBookTimezonesChanged: () => onBookTimezonesChanged,
|
|
486
497
|
online_forms_namespace_collection: () => online_forms_namespace_collection,
|
|
498
|
+
openRmfConfig: () => openRmfConfig,
|
|
499
|
+
openRmfDoorDriver: () => openRmfDoorDriver,
|
|
500
|
+
openRmfLiftDriver: () => openRmfLiftDriver,
|
|
487
501
|
orgLevelRoles: () => orgLevelRoles,
|
|
488
502
|
orgModulesHandlers: () => orgModulesHandlers,
|
|
489
503
|
orgOwnerRepairHandlers: () => orgOwnerRepairHandlers,
|
|
@@ -506,6 +520,7 @@ __export(src_exports, {
|
|
|
506
520
|
planDayFromJsDay: () => planDayFromJsDay,
|
|
507
521
|
planDemoRobots: () => planDemoRobots,
|
|
508
522
|
planOrgOwnerRepair: () => planOrgOwnerRepair,
|
|
523
|
+
planShareOf: () => planShareOf,
|
|
509
524
|
platform_terms_namespace_collection: () => platform_terms_namespace_collection,
|
|
510
525
|
playbackRelays: () => playbackRelays,
|
|
511
526
|
playbackWindowRefusal: () => playbackWindowRefusal,
|
|
@@ -522,6 +537,7 @@ __export(src_exports, {
|
|
|
522
537
|
refuseServiceProviderInviteAction: () => refuseServiceProviderInviteAction,
|
|
523
538
|
registerCameraTransport: () => registerCameraTransport,
|
|
524
539
|
registerDemoBrand: () => registerDemoBrand,
|
|
540
|
+
registerOpenRmfBrand: () => registerOpenRmfBrand,
|
|
525
541
|
registerOunitechBrand: () => registerOunitechBrand,
|
|
526
542
|
registerRobotBrand: () => registerRobotBrand,
|
|
527
543
|
registeredRobotBrands: () => registeredRobotBrands,
|
|
@@ -722,6 +738,7 @@ __export(src_exports, {
|
|
|
722
738
|
site_people_namespace_collection: () => site_people_namespace_collection,
|
|
723
739
|
snapshotEndpoint: () => snapshotEndpoint,
|
|
724
740
|
snapshotRefusalReason: () => snapshotRefusalReason,
|
|
741
|
+
splitRobotSn: () => splitRobotSn,
|
|
725
742
|
staffMayBypass: () => staffMayBypass,
|
|
726
743
|
startDemoTracking: () => startDemoTracking,
|
|
727
744
|
startRobotTracking: () => startRobotTracking,
|
|
@@ -731,6 +748,8 @@ __export(src_exports, {
|
|
|
731
748
|
subscriptionPlanSchema: () => subscriptionPlanSchema,
|
|
732
749
|
summariseBulkCameraPlan: () => summariseBulkCameraPlan,
|
|
733
750
|
supports: () => supports,
|
|
751
|
+
taskRequestFor: () => taskRequestFor,
|
|
752
|
+
toAdapterRobot: () => toAdapterRobot,
|
|
734
753
|
trackingBackoffMs: () => trackingBackoffMs,
|
|
735
754
|
uncontrollableFleetWarning: () => uncontrollableFleetWarning,
|
|
736
755
|
updateRemarksStatusEod: () => updateRemarksStatusEod,
|
|
@@ -979,6 +998,7 @@ __export(src_exports, {
|
|
|
979
998
|
userSchema: () => userSchema,
|
|
980
999
|
vehicleCategoryFor: () => vehicleCategoryFor,
|
|
981
1000
|
vehicleHistoryEntry: () => vehicleHistoryEntry,
|
|
1001
|
+
vehicleHistoryValue: () => vehicleHistoryValue,
|
|
982
1002
|
vehicleListViewQuery: () => vehicleListViewQuery,
|
|
983
1003
|
vehicleSchema: () => vehicleSchema,
|
|
984
1004
|
vehicleViewOf: () => vehicleViewOf,
|
|
@@ -987,6 +1007,7 @@ __export(src_exports, {
|
|
|
987
1007
|
visitors_namespace_collection: () => visitors_namespace_collection,
|
|
988
1008
|
wallConfig: () => wallConfig,
|
|
989
1009
|
wallsFromOccupancyGrid: () => wallsFromOccupancyGrid,
|
|
1010
|
+
waypointsFor: () => waypointsFor,
|
|
990
1011
|
withLiveLink: () => withLiveLink,
|
|
991
1012
|
workOrderSchema: () => workOrderSchema,
|
|
992
1013
|
work_orders2_namespace_collection: () => work_orders2_namespace_collection,
|
|
@@ -11018,11 +11039,11 @@ function moduleGateData() {
|
|
|
11018
11039
|
};
|
|
11019
11040
|
}
|
|
11020
11041
|
function memoisedGateData(data) {
|
|
11021
|
-
const
|
|
11042
|
+
const cache2 = /* @__PURE__ */ new Map();
|
|
11022
11043
|
const once = (key, load) => {
|
|
11023
|
-
if (!
|
|
11024
|
-
|
|
11025
|
-
return
|
|
11044
|
+
if (!cache2.has(key))
|
|
11045
|
+
cache2.set(key, load());
|
|
11046
|
+
return cache2.get(key);
|
|
11026
11047
|
};
|
|
11027
11048
|
return {
|
|
11028
11049
|
...data,
|
|
@@ -18273,13 +18294,44 @@ function vehicleViewOf(value) {
|
|
|
18273
18294
|
return "residents" /* RESIDENTS */;
|
|
18274
18295
|
}
|
|
18275
18296
|
var VEHICLE_HISTORY_LIMIT = 20;
|
|
18297
|
+
function vehicleHistoryValue(field, value) {
|
|
18298
|
+
if (value === void 0 || value === null)
|
|
18299
|
+
return null;
|
|
18300
|
+
if (value instanceof Date) {
|
|
18301
|
+
return Number.isNaN(value.getTime()) ? null : value.toISOString();
|
|
18302
|
+
}
|
|
18303
|
+
if (value instanceof import_mongodb46.ObjectId)
|
|
18304
|
+
return value.toHexString();
|
|
18305
|
+
if (typeof value === "number" || typeof value === "boolean")
|
|
18306
|
+
return value;
|
|
18307
|
+
const text2 = String(value).trim();
|
|
18308
|
+
if (!text2)
|
|
18309
|
+
return null;
|
|
18310
|
+
if (field === "nric")
|
|
18311
|
+
return text2.length > 4 ? `*****${text2.slice(-4)}` : "****";
|
|
18312
|
+
return text2.length > 300 ? `${text2.slice(0, 300)}...` : text2;
|
|
18313
|
+
}
|
|
18276
18314
|
function vehicleHistoryEntry(action, user, fields) {
|
|
18277
18315
|
const id = String(user ?? "");
|
|
18316
|
+
const changes = [];
|
|
18317
|
+
const seen2 = /* @__PURE__ */ new Set();
|
|
18318
|
+
for (const item of fields) {
|
|
18319
|
+
if (!item || typeof item === "string" || !item.field || seen2.has(item.field))
|
|
18320
|
+
continue;
|
|
18321
|
+
seen2.add(item.field);
|
|
18322
|
+
changes.push({
|
|
18323
|
+
field: item.field,
|
|
18324
|
+
from: vehicleHistoryValue(item.field, item.from),
|
|
18325
|
+
to: vehicleHistoryValue(item.field, item.to)
|
|
18326
|
+
});
|
|
18327
|
+
}
|
|
18328
|
+
const names = fields.map((item) => typeof item === "string" ? item : item?.field).filter((name) => !!name);
|
|
18278
18329
|
return {
|
|
18279
18330
|
action,
|
|
18280
18331
|
updatedBy: import_mongodb46.ObjectId.isValid(id) ? new import_mongodb46.ObjectId(id) : null,
|
|
18281
18332
|
updatedAt: /* @__PURE__ */ new Date(),
|
|
18282
|
-
fields: Array.from(new Set(
|
|
18333
|
+
fields: Array.from(new Set(names)),
|
|
18334
|
+
...changes.length ? { changes } : {}
|
|
18283
18335
|
};
|
|
18284
18336
|
}
|
|
18285
18337
|
var VehicleOrder = /* @__PURE__ */ ((VehicleOrder2) => {
|
|
@@ -19055,11 +19107,51 @@ function useVehicleRepo() {
|
|
|
19055
19107
|
for (const user of users)
|
|
19056
19108
|
names.set(String(user._id), String(user.name ?? ""));
|
|
19057
19109
|
}
|
|
19110
|
+
const PLACE_COLLECTIONS = {
|
|
19111
|
+
block: "buildings",
|
|
19112
|
+
level: "building-levels",
|
|
19113
|
+
unit: "building-units"
|
|
19114
|
+
};
|
|
19115
|
+
const placeIds = { block: /* @__PURE__ */ new Set(), level: /* @__PURE__ */ new Set(), unit: /* @__PURE__ */ new Set() };
|
|
19116
|
+
for (const entry of history) {
|
|
19117
|
+
for (const change of entry?.changes ?? []) {
|
|
19118
|
+
const bucket = placeIds[change?.field];
|
|
19119
|
+
if (!bucket)
|
|
19120
|
+
continue;
|
|
19121
|
+
for (const v of [change.from, change.to]) {
|
|
19122
|
+
if (typeof v === "string" && import_mongodb47.ObjectId.isValid(v))
|
|
19123
|
+
bucket.add(v);
|
|
19124
|
+
}
|
|
19125
|
+
}
|
|
19126
|
+
}
|
|
19127
|
+
const placeNames = /* @__PURE__ */ new Map();
|
|
19128
|
+
if (db2) {
|
|
19129
|
+
for (const [field, set] of Object.entries(placeIds)) {
|
|
19130
|
+
if (!set.size)
|
|
19131
|
+
continue;
|
|
19132
|
+
const docs = await db2.collection(PLACE_COLLECTIONS[field]).find(
|
|
19133
|
+
{ _id: { $in: Array.from(set).map((id) => new import_mongodb47.ObjectId(id)) } },
|
|
19134
|
+
{ projection: { name: 1 } }
|
|
19135
|
+
).toArray();
|
|
19136
|
+
for (const doc of docs)
|
|
19137
|
+
placeNames.set(`${field}:${String(doc._id)}`, String(doc.name ?? ""));
|
|
19138
|
+
}
|
|
19139
|
+
}
|
|
19140
|
+
const placeName = (field, v) => typeof v === "string" ? placeNames.get(`${field}:${v}`) : void 0;
|
|
19058
19141
|
return {
|
|
19059
19142
|
...result,
|
|
19060
19143
|
history: history.map((entry) => ({
|
|
19061
19144
|
...entry,
|
|
19062
|
-
updatedByName: entry?.updatedBy ? names.get(String(entry.updatedBy)) ?? "" : ""
|
|
19145
|
+
updatedByName: entry?.updatedBy ? names.get(String(entry.updatedBy)) ?? "" : "",
|
|
19146
|
+
...Array.isArray(entry?.changes) && {
|
|
19147
|
+
changes: entry.changes.map(
|
|
19148
|
+
(change) => PLACE_COLLECTIONS[change.field] ? {
|
|
19149
|
+
...change,
|
|
19150
|
+
fromName: placeName(change.field, change.from),
|
|
19151
|
+
toName: placeName(change.field, change.to)
|
|
19152
|
+
} : change
|
|
19153
|
+
)
|
|
19154
|
+
}
|
|
19063
19155
|
}))
|
|
19064
19156
|
};
|
|
19065
19157
|
} catch (error) {
|
|
@@ -34782,7 +34874,11 @@ function useVehicleService() {
|
|
|
34782
34874
|
} = useVehicleRepo();
|
|
34783
34875
|
function changedFields(record, next) {
|
|
34784
34876
|
const asText = (v) => v instanceof Date ? String(v.getTime()) : String(v ?? "");
|
|
34785
|
-
return Object.entries(next).filter(([key, value]) => asText(value) !== asText(record?.[key])).map(([key]) =>
|
|
34877
|
+
return Object.entries(next).filter(([key, value]) => asText(value) !== asText(record?.[key])).map(([key, value]) => ({
|
|
34878
|
+
field: key,
|
|
34879
|
+
from: record?.[key] ?? null,
|
|
34880
|
+
to: value ?? null
|
|
34881
|
+
}));
|
|
34786
34882
|
}
|
|
34787
34883
|
function anprCameraSummary(cameras, list) {
|
|
34788
34884
|
return cameras.map((camera) => ({
|
|
@@ -35531,6 +35627,7 @@ function useVehicleService() {
|
|
|
35531
35627
|
vehicleHistoryEntry(
|
|
35532
35628
|
"created",
|
|
35533
35629
|
user,
|
|
35630
|
+
// Created: each value it was saved with, from nothing.
|
|
35534
35631
|
Object.entries({
|
|
35535
35632
|
plateNumber: vehicleValue.plateNumber,
|
|
35536
35633
|
name: vehicleValue.name,
|
|
@@ -35546,7 +35643,7 @@ function useVehicleService() {
|
|
|
35546
35643
|
start: vehicleValue.start,
|
|
35547
35644
|
end: vehicleValue.end,
|
|
35548
35645
|
remarks: vehicleValue.remarks
|
|
35549
|
-
}).filter(([, v]) => v !== void 0 && v !== null && String(v) !== "").map(([k]) => k)
|
|
35646
|
+
}).filter(([, v]) => v !== void 0 && v !== null && String(v) !== "").map(([k, v]) => ({ field: k, from: null, to: v }))
|
|
35550
35647
|
)
|
|
35551
35648
|
];
|
|
35552
35649
|
await _add(vehicleValue, session);
|
|
@@ -35630,7 +35727,9 @@ function useVehicleService() {
|
|
|
35630
35727
|
session
|
|
35631
35728
|
);
|
|
35632
35729
|
await session.commitTransaction();
|
|
35633
|
-
await recordHistory(_id, "deleted", user, [
|
|
35730
|
+
await recordHistory(_id, "deleted", user, [
|
|
35731
|
+
{ field: "status", from: vehicle?.status ?? null, to: "deleted" /* DELETED */ }
|
|
35732
|
+
]);
|
|
35634
35733
|
return `Vehicle plate number deleted from ${type} record successfully.`;
|
|
35635
35734
|
} catch (error) {
|
|
35636
35735
|
import_node_server_utils109.logger.error("Error in vehicle service delete:", error);
|
|
@@ -35732,7 +35831,7 @@ function useVehicleService() {
|
|
|
35732
35831
|
};
|
|
35733
35832
|
await _updateVehicleById(id, formattedValue, session);
|
|
35734
35833
|
await session.commitTransaction();
|
|
35735
|
-
await recordHistory(id, "approved", user,
|
|
35834
|
+
await recordHistory(id, "approved", user, changedFields(vehicle, formattedValue));
|
|
35736
35835
|
return "Vehicle plate number approved and added successfully.";
|
|
35737
35836
|
} catch (error) {
|
|
35738
35837
|
import_node_server_utils109.logger.error("Error in vehicle service approving and adding:", error);
|
|
@@ -35888,7 +35987,7 @@ function useVehicleService() {
|
|
|
35888
35987
|
};
|
|
35889
35988
|
await _updateVehicleById(id, formattedValue, session);
|
|
35890
35989
|
await session.commitTransaction();
|
|
35891
|
-
await recordHistory(id, "restored", user,
|
|
35990
|
+
await recordHistory(id, "restored", user, changedFields(vehicle, formattedValue));
|
|
35892
35991
|
return "Vehicle reactivated successfully.";
|
|
35893
35992
|
} catch (error) {
|
|
35894
35993
|
import_node_server_utils109.logger.error("Error in vehicle service reactivation:", error);
|
|
@@ -60842,7 +60941,7 @@ var OUNITECH_PENDING_COMMANDS = ["pause", "resume", "cancel"].map(
|
|
|
60842
60941
|
);
|
|
60843
60942
|
function createOunitechAdapter(credentials, options) {
|
|
60844
60943
|
const cloud = useRobotCloudService(credentials, options);
|
|
60845
|
-
function
|
|
60944
|
+
function toAdapterRobot2(raw) {
|
|
60846
60945
|
return {
|
|
60847
60946
|
robotSn: raw.robotSn,
|
|
60848
60947
|
name: raw.robotName,
|
|
@@ -60864,7 +60963,7 @@ function createOunitechAdapter(credentials, options) {
|
|
|
60864
60963
|
capabilities: OUNITECH_CAPABILITIES,
|
|
60865
60964
|
async listRobots() {
|
|
60866
60965
|
const fleet2 = await cloud.getRobots();
|
|
60867
|
-
return fleet2.map(
|
|
60966
|
+
return fleet2.map(toAdapterRobot2);
|
|
60868
60967
|
},
|
|
60869
60968
|
async getRobot(robotSn) {
|
|
60870
60969
|
const fleet2 = await cloud.getRobots();
|
|
@@ -60881,7 +60980,7 @@ function createOunitechAdapter(credentials, options) {
|
|
|
60881
60980
|
position: null
|
|
60882
60981
|
};
|
|
60883
60982
|
}
|
|
60884
|
-
return
|
|
60983
|
+
return toAdapterRobot2(match);
|
|
60885
60984
|
},
|
|
60886
60985
|
async sendCommand(robotSn, command) {
|
|
60887
60986
|
const options2 = {
|
|
@@ -61419,6 +61518,708 @@ function registerDemoBrand() {
|
|
|
61419
61518
|
}
|
|
61420
61519
|
registerDemoBrand();
|
|
61421
61520
|
|
|
61521
|
+
// src/utils/lift-contract.util.ts
|
|
61522
|
+
var LIFT_DOOR = {
|
|
61523
|
+
CLOSED: 0,
|
|
61524
|
+
MOVING: 1,
|
|
61525
|
+
OPEN: 2
|
|
61526
|
+
};
|
|
61527
|
+
var LIFT_MOTION = {
|
|
61528
|
+
STOPPED: 0,
|
|
61529
|
+
UP: 1,
|
|
61530
|
+
DOWN: 2,
|
|
61531
|
+
UNKNOWN: 3
|
|
61532
|
+
};
|
|
61533
|
+
var LIFT_MODE = {
|
|
61534
|
+
UNKNOWN: 0,
|
|
61535
|
+
HUMAN: 1,
|
|
61536
|
+
AGV: 2,
|
|
61537
|
+
FIRE: 3,
|
|
61538
|
+
OFFLINE: 4,
|
|
61539
|
+
EMERGENCY: 5
|
|
61540
|
+
};
|
|
61541
|
+
var LIFT_REQUEST = {
|
|
61542
|
+
END_SESSION: 0,
|
|
61543
|
+
AGV_MODE: 1,
|
|
61544
|
+
HUMAN_MODE: 2
|
|
61545
|
+
};
|
|
61546
|
+
function isLiftAvailable(state) {
|
|
61547
|
+
if (!state)
|
|
61548
|
+
return false;
|
|
61549
|
+
return state.currentMode === LIFT_MODE.HUMAN || state.currentMode === LIFT_MODE.AGV;
|
|
61550
|
+
}
|
|
61551
|
+
function isSafeToCross(state, floor) {
|
|
61552
|
+
if (!isLiftAvailable(state) || !state)
|
|
61553
|
+
return false;
|
|
61554
|
+
if (state.currentFloor !== floor)
|
|
61555
|
+
return false;
|
|
61556
|
+
if (state.motionState !== LIFT_MOTION.STOPPED)
|
|
61557
|
+
return false;
|
|
61558
|
+
return state.doorState === LIFT_DOOR.OPEN;
|
|
61559
|
+
}
|
|
61560
|
+
function holdsLift(state, sessionId) {
|
|
61561
|
+
if (!state || !sessionId)
|
|
61562
|
+
return false;
|
|
61563
|
+
return state.sessionId === sessionId;
|
|
61564
|
+
}
|
|
61565
|
+
function servesFloor(state, floor) {
|
|
61566
|
+
if (!state || !floor)
|
|
61567
|
+
return false;
|
|
61568
|
+
return state.availableFloors.includes(floor);
|
|
61569
|
+
}
|
|
61570
|
+
function createLiftSimulator(options) {
|
|
61571
|
+
const { name, floors } = options;
|
|
61572
|
+
if (floors.length === 0)
|
|
61573
|
+
throw new Error("A lift must serve some floors.");
|
|
61574
|
+
const msPerFloor = options.msPerFloor ?? 2e3;
|
|
61575
|
+
const doorDwellMs = options.doorDwellMs ?? 5e3;
|
|
61576
|
+
const state = {
|
|
61577
|
+
liftName: name,
|
|
61578
|
+
liftTime: 0,
|
|
61579
|
+
availableFloors: [...floors],
|
|
61580
|
+
currentFloor: options.startFloor ?? floors[0],
|
|
61581
|
+
destinationFloor: options.startFloor ?? floors[0],
|
|
61582
|
+
doorState: LIFT_DOOR.CLOSED,
|
|
61583
|
+
motionState: LIFT_MOTION.STOPPED,
|
|
61584
|
+
currentMode: LIFT_MODE.HUMAN,
|
|
61585
|
+
sessionId: ""
|
|
61586
|
+
};
|
|
61587
|
+
let travelRemaining = 0;
|
|
61588
|
+
let doorTimer = 0;
|
|
61589
|
+
function tick(ms) {
|
|
61590
|
+
state.liftTime += ms;
|
|
61591
|
+
if (state.motionState !== LIFT_MOTION.STOPPED) {
|
|
61592
|
+
travelRemaining -= ms;
|
|
61593
|
+
if (travelRemaining <= 0) {
|
|
61594
|
+
state.currentFloor = state.destinationFloor;
|
|
61595
|
+
state.motionState = LIFT_MOTION.STOPPED;
|
|
61596
|
+
state.doorState = LIFT_DOOR.OPEN;
|
|
61597
|
+
doorTimer = doorDwellMs;
|
|
61598
|
+
}
|
|
61599
|
+
return;
|
|
61600
|
+
}
|
|
61601
|
+
if (state.doorState === LIFT_DOOR.OPEN) {
|
|
61602
|
+
doorTimer -= ms;
|
|
61603
|
+
if (doorTimer <= 0)
|
|
61604
|
+
state.doorState = LIFT_DOOR.CLOSED;
|
|
61605
|
+
}
|
|
61606
|
+
}
|
|
61607
|
+
return {
|
|
61608
|
+
name,
|
|
61609
|
+
state,
|
|
61610
|
+
tick,
|
|
61611
|
+
async read() {
|
|
61612
|
+
return { ...state, availableFloors: [...state.availableFloors] };
|
|
61613
|
+
},
|
|
61614
|
+
async request(request2) {
|
|
61615
|
+
if (request2.requestType === LIFT_REQUEST.END_SESSION) {
|
|
61616
|
+
if (state.sessionId === request2.sessionId) {
|
|
61617
|
+
state.sessionId = "";
|
|
61618
|
+
state.currentMode = LIFT_MODE.HUMAN;
|
|
61619
|
+
}
|
|
61620
|
+
return;
|
|
61621
|
+
}
|
|
61622
|
+
if (state.sessionId && state.sessionId !== request2.sessionId) {
|
|
61623
|
+
throw new Error(`Lift ${name} is held by ${state.sessionId}.`);
|
|
61624
|
+
}
|
|
61625
|
+
if (!state.availableFloors.includes(request2.destinationFloor)) {
|
|
61626
|
+
throw new Error(
|
|
61627
|
+
`Lift ${name} does not serve ${request2.destinationFloor}.`
|
|
61628
|
+
);
|
|
61629
|
+
}
|
|
61630
|
+
state.sessionId = request2.sessionId;
|
|
61631
|
+
state.currentMode = request2.requestType === LIFT_REQUEST.AGV_MODE ? LIFT_MODE.AGV : LIFT_MODE.HUMAN;
|
|
61632
|
+
state.destinationFloor = request2.destinationFloor;
|
|
61633
|
+
if (state.currentFloor === request2.destinationFloor) {
|
|
61634
|
+
state.motionState = LIFT_MOTION.STOPPED;
|
|
61635
|
+
state.doorState = LIFT_DOOR.OPEN;
|
|
61636
|
+
doorTimer = doorDwellMs;
|
|
61637
|
+
return;
|
|
61638
|
+
}
|
|
61639
|
+
const from = state.availableFloors.indexOf(state.currentFloor);
|
|
61640
|
+
const to = state.availableFloors.indexOf(request2.destinationFloor);
|
|
61641
|
+
state.motionState = to > from ? LIFT_MOTION.UP : LIFT_MOTION.DOWN;
|
|
61642
|
+
state.doorState = LIFT_DOOR.CLOSED;
|
|
61643
|
+
travelRemaining = Math.abs(to - from) * msPerFloor;
|
|
61644
|
+
},
|
|
61645
|
+
async refresh(sessionId) {
|
|
61646
|
+
if (state.sessionId !== sessionId)
|
|
61647
|
+
return;
|
|
61648
|
+
if (state.doorState === LIFT_DOOR.OPEN)
|
|
61649
|
+
doorTimer = doorDwellMs;
|
|
61650
|
+
},
|
|
61651
|
+
async release(sessionId) {
|
|
61652
|
+
if (state.sessionId !== sessionId)
|
|
61653
|
+
return;
|
|
61654
|
+
state.sessionId = "";
|
|
61655
|
+
state.currentMode = LIFT_MODE.HUMAN;
|
|
61656
|
+
}
|
|
61657
|
+
};
|
|
61658
|
+
}
|
|
61659
|
+
var LIFT_QUEUE_TTL_MS = 10 * 6e4;
|
|
61660
|
+
var LIFT_LEASE_MS = 3 * 6e4;
|
|
61661
|
+
var LIFT_SIM_MS_PER_FLOOR = 4e3;
|
|
61662
|
+
var LIFT_SIM_DOOR_DWELL_MS = 8e3;
|
|
61663
|
+
var LIFT_SIM_BOARD_MS = 6e3;
|
|
61664
|
+
var LIFT_SESSION_STATUS = [
|
|
61665
|
+
"queued",
|
|
61666
|
+
"active",
|
|
61667
|
+
"released",
|
|
61668
|
+
"expired",
|
|
61669
|
+
"cancelled"
|
|
61670
|
+
];
|
|
61671
|
+
async function simulatedLiftState(options) {
|
|
61672
|
+
const sim = createLiftSimulator({
|
|
61673
|
+
name: options.name,
|
|
61674
|
+
floors: options.floors,
|
|
61675
|
+
msPerFloor: LIFT_SIM_MS_PER_FLOOR,
|
|
61676
|
+
doorDwellMs: LIFT_SIM_DOOR_DWELL_MS
|
|
61677
|
+
});
|
|
61678
|
+
const session = options.session;
|
|
61679
|
+
if (!session || !options.floors.includes(session.fromFloor) || !options.floors.includes(session.toFloor)) {
|
|
61680
|
+
return { state: await sim.read(), phase: "idle" };
|
|
61681
|
+
}
|
|
61682
|
+
const STEP = 250;
|
|
61683
|
+
const elapsed = Math.max(0, options.now - session.activeAt);
|
|
61684
|
+
let phase = "to-pickup";
|
|
61685
|
+
let boardingLeft = LIFT_SIM_BOARD_MS;
|
|
61686
|
+
await sim.request({
|
|
61687
|
+
liftName: options.name,
|
|
61688
|
+
sessionId: session.id,
|
|
61689
|
+
requestType: LIFT_REQUEST.AGV_MODE,
|
|
61690
|
+
destinationFloor: session.fromFloor,
|
|
61691
|
+
doorState: LIFT_DOOR.OPEN
|
|
61692
|
+
});
|
|
61693
|
+
if (isSafeToCross(sim.state, session.fromFloor))
|
|
61694
|
+
phase = "boarding";
|
|
61695
|
+
for (let t = 0; t < elapsed; t += STEP) {
|
|
61696
|
+
const ms = Math.min(STEP, elapsed - t);
|
|
61697
|
+
sim.tick(ms);
|
|
61698
|
+
const s = sim.state;
|
|
61699
|
+
if (phase === "to-pickup") {
|
|
61700
|
+
if (isSafeToCross(s, session.fromFloor))
|
|
61701
|
+
phase = "boarding";
|
|
61702
|
+
} else if (phase === "boarding") {
|
|
61703
|
+
await sim.refresh(session.id);
|
|
61704
|
+
boardingLeft -= ms;
|
|
61705
|
+
if (boardingLeft <= 0) {
|
|
61706
|
+
phase = "to-destination";
|
|
61707
|
+
await sim.request({
|
|
61708
|
+
liftName: options.name,
|
|
61709
|
+
sessionId: session.id,
|
|
61710
|
+
requestType: LIFT_REQUEST.AGV_MODE,
|
|
61711
|
+
destinationFloor: session.toFloor,
|
|
61712
|
+
doorState: LIFT_DOOR.CLOSED
|
|
61713
|
+
});
|
|
61714
|
+
}
|
|
61715
|
+
} else if (phase === "to-destination") {
|
|
61716
|
+
if (isSafeToCross(s, session.toFloor))
|
|
61717
|
+
phase = "arrived";
|
|
61718
|
+
} else if (phase === "arrived") {
|
|
61719
|
+
await sim.refresh(session.id);
|
|
61720
|
+
}
|
|
61721
|
+
}
|
|
61722
|
+
return { state: await sim.read(), phase };
|
|
61723
|
+
}
|
|
61724
|
+
function liftQueueKey(mapId, liftName) {
|
|
61725
|
+
return `${mapId}:${liftName}`;
|
|
61726
|
+
}
|
|
61727
|
+
|
|
61728
|
+
// src/utils/door-contract.util.ts
|
|
61729
|
+
var DOOR_MODE = {
|
|
61730
|
+
CLOSED: 0,
|
|
61731
|
+
MOVING: 1,
|
|
61732
|
+
OPEN: 2,
|
|
61733
|
+
OFFLINE: 3,
|
|
61734
|
+
UNKNOWN: 4
|
|
61735
|
+
};
|
|
61736
|
+
var MODES = new Set(Object.values(DOOR_MODE));
|
|
61737
|
+
function doorModeOf(value) {
|
|
61738
|
+
return typeof value === "number" && MODES.has(value) ? value : DOOR_MODE.UNKNOWN;
|
|
61739
|
+
}
|
|
61740
|
+
function isDoorPassable(state) {
|
|
61741
|
+
return state?.currentMode === DOOR_MODE.OPEN;
|
|
61742
|
+
}
|
|
61743
|
+
|
|
61744
|
+
// src/services/open-rmf.adapter.ts
|
|
61745
|
+
var OPEN_RMF_BRAND = "fleet-core";
|
|
61746
|
+
var OPEN_RMF_DISPLAY_NAME = "HERO Fleet Core";
|
|
61747
|
+
var OPEN_RMF_CAPABILITIES = {
|
|
61748
|
+
readLocation: true,
|
|
61749
|
+
// robot_state.location {map, x, y, yaw}
|
|
61750
|
+
battery: true,
|
|
61751
|
+
// robot_state.battery 0..1
|
|
61752
|
+
floorReporting: true,
|
|
61753
|
+
// location.map = level name
|
|
61754
|
+
multiFloor: true,
|
|
61755
|
+
// RMF rides lifts itself (lift supervisor)
|
|
61756
|
+
startProcess: true,
|
|
61757
|
+
// clean / patrol tasks
|
|
61758
|
+
pauseProcess: true,
|
|
61759
|
+
// interrupt_task / resume_task / cancel_task
|
|
61760
|
+
pauseResume: true,
|
|
61761
|
+
// same calls
|
|
61762
|
+
processCompletion: true,
|
|
61763
|
+
// task_state.status
|
|
61764
|
+
pathAndEta: true,
|
|
61765
|
+
// task_state.estimate_millis
|
|
61766
|
+
sendToDock: true,
|
|
61767
|
+
// go_to_place the robot's charger waypoint
|
|
61768
|
+
navigateToPoint: false,
|
|
61769
|
+
// api takes waypoint names only
|
|
61770
|
+
relocalize: false,
|
|
61771
|
+
// no api call
|
|
61772
|
+
spotClean: false
|
|
61773
|
+
// clean zones are named waypoints, not points
|
|
61774
|
+
};
|
|
61775
|
+
function openRmfConfig(env2 = process.env) {
|
|
61776
|
+
const baseUrl = (env2.OPEN_RMF_API_URL ?? "").trim().replace(/\/+$/, "");
|
|
61777
|
+
if (!/^https?:\/\/\S+$/.test(baseUrl))
|
|
61778
|
+
return null;
|
|
61779
|
+
return { baseUrl, token: (env2.OPEN_RMF_TOKEN ?? "").trim() };
|
|
61780
|
+
}
|
|
61781
|
+
var OpenRmfError = class extends Error {
|
|
61782
|
+
};
|
|
61783
|
+
var TIMEOUT_MS = 4e3;
|
|
61784
|
+
var cache = /* @__PURE__ */ new Map();
|
|
61785
|
+
function createOpenRmfClient(config2, deps) {
|
|
61786
|
+
const doFetch = deps?.fetch ?? globalThis.fetch;
|
|
61787
|
+
const now = deps?.now ?? Date.now;
|
|
61788
|
+
async function call(method, path5, body) {
|
|
61789
|
+
if (!config2)
|
|
61790
|
+
throw new OpenRmfError("Fleet Core is not configured on this server.");
|
|
61791
|
+
let res;
|
|
61792
|
+
try {
|
|
61793
|
+
res = await doFetch(config2.baseUrl + path5, {
|
|
61794
|
+
method,
|
|
61795
|
+
headers: {
|
|
61796
|
+
...config2.token ? { Authorization: `Bearer ${config2.token}` } : {},
|
|
61797
|
+
...body === void 0 ? {} : { "Content-Type": "application/json" }
|
|
61798
|
+
},
|
|
61799
|
+
body: body === void 0 ? void 0 : JSON.stringify(body),
|
|
61800
|
+
signal: AbortSignal.timeout(deps?.timeoutMs ?? TIMEOUT_MS)
|
|
61801
|
+
});
|
|
61802
|
+
} catch (e) {
|
|
61803
|
+
throw new OpenRmfError(
|
|
61804
|
+
`The fleet server did not answer (${e?.name === "TimeoutError" ? "timed out" : "unreachable"}).`
|
|
61805
|
+
);
|
|
61806
|
+
}
|
|
61807
|
+
const text2 = await res.text();
|
|
61808
|
+
if (!res.ok)
|
|
61809
|
+
throw new OpenRmfError(`The fleet server refused ${method} ${path5.split("?")[0]} (HTTP ${res.status}).`);
|
|
61810
|
+
try {
|
|
61811
|
+
return text2 ? JSON.parse(text2) : null;
|
|
61812
|
+
} catch {
|
|
61813
|
+
throw new OpenRmfError("The fleet server sent a reply that is not JSON.");
|
|
61814
|
+
}
|
|
61815
|
+
}
|
|
61816
|
+
function cached(key, ttlMs, load) {
|
|
61817
|
+
const k = `${config2?.baseUrl}|${key}`;
|
|
61818
|
+
const hit = cache.get(k);
|
|
61819
|
+
if (hit && now() - hit.at < ttlMs)
|
|
61820
|
+
return hit.value;
|
|
61821
|
+
const value = load();
|
|
61822
|
+
cache.set(k, { at: now(), value });
|
|
61823
|
+
value.catch(() => cache.delete(k));
|
|
61824
|
+
return value;
|
|
61825
|
+
}
|
|
61826
|
+
const enc2 = encodeURIComponent;
|
|
61827
|
+
return {
|
|
61828
|
+
fleets: () => cached("fleets", 1500, () => call("GET", "/fleets")),
|
|
61829
|
+
buildingMap: () => cached("building_map", 6e4, () => call("GET", "/building_map")),
|
|
61830
|
+
doors: () => call("GET", "/doors"),
|
|
61831
|
+
doorState: (name) => call("GET", `/doors/${enc2(name)}/state`),
|
|
61832
|
+
doorRequest: (name, mode) => call("POST", `/doors/${enc2(name)}/request`, { mode }),
|
|
61833
|
+
liftState: (name) => call("GET", `/lifts/${enc2(name)}/state`),
|
|
61834
|
+
liftRequest: (name, body) => call("POST", `/lifts/${enc2(name)}/request`, body),
|
|
61835
|
+
robotTask: (fleet2, robot, request2) => call("POST", "/tasks/robot_task", {
|
|
61836
|
+
type: "robot_task_request",
|
|
61837
|
+
fleet: fleet2,
|
|
61838
|
+
robot,
|
|
61839
|
+
request: request2
|
|
61840
|
+
}),
|
|
61841
|
+
cancelTask: (taskId) => call("POST", "/tasks/cancel_task", { type: "cancel_task_request", task_id: taskId }),
|
|
61842
|
+
interruptTask: (taskId) => call("POST", "/tasks/interrupt_task", { type: "interrupt_task_request", task_id: taskId, labels: ["iservice365"] }),
|
|
61843
|
+
// RMF answers a resume only when it names the interruption tokens to discard.
|
|
61844
|
+
resumeTask: (taskId, tokens) => call("POST", "/tasks/resume_task", {
|
|
61845
|
+
type: "resume_task_request",
|
|
61846
|
+
for_task: taskId,
|
|
61847
|
+
for_tokens: tokens,
|
|
61848
|
+
labels: ["iservice365"]
|
|
61849
|
+
}),
|
|
61850
|
+
taskState: (taskId) => call("GET", `/tasks/${enc2(taskId)}/state`)
|
|
61851
|
+
};
|
|
61852
|
+
}
|
|
61853
|
+
function floorNoOf(map) {
|
|
61854
|
+
if (typeof map !== "string")
|
|
61855
|
+
return null;
|
|
61856
|
+
const m = /^(L|B)(\d{1,3})$/i.exec(map.trim());
|
|
61857
|
+
if (m)
|
|
61858
|
+
return m[1].toUpperCase() === "B" ? -Number(m[2]) : Number(m[2]);
|
|
61859
|
+
return /^G$/i.test(map.trim()) ? 0 : null;
|
|
61860
|
+
}
|
|
61861
|
+
function splitRobotSn(robotSn) {
|
|
61862
|
+
const i = robotSn.indexOf("/");
|
|
61863
|
+
if (i <= 0 || i === robotSn.length - 1)
|
|
61864
|
+
return null;
|
|
61865
|
+
return { fleet: robotSn.slice(0, i), robot: robotSn.slice(i + 1) };
|
|
61866
|
+
}
|
|
61867
|
+
var hasParam = (v, p) => (v.params ?? []).some((x) => x.name === p);
|
|
61868
|
+
function levelBounds(building, map) {
|
|
61869
|
+
const level2 = building?.levels.find((l) => l.name === map);
|
|
61870
|
+
if (!level2)
|
|
61871
|
+
return null;
|
|
61872
|
+
const xs = [];
|
|
61873
|
+
const ys = [];
|
|
61874
|
+
for (const g of level2.nav_graphs)
|
|
61875
|
+
for (const v of g.vertices)
|
|
61876
|
+
xs.push(v.x), ys.push(v.y);
|
|
61877
|
+
for (const d of level2.doors)
|
|
61878
|
+
xs.push(d.v1_x, d.v2_x), ys.push(d.v1_y, d.v2_y);
|
|
61879
|
+
if (!xs.length)
|
|
61880
|
+
return null;
|
|
61881
|
+
const pad = 3;
|
|
61882
|
+
return { minX: Math.min(...xs) - pad, maxX: Math.max(...xs) + pad, minY: Math.min(...ys) - pad, maxY: Math.max(...ys) + pad };
|
|
61883
|
+
}
|
|
61884
|
+
function planShareOf(building, loc) {
|
|
61885
|
+
if (!loc)
|
|
61886
|
+
return null;
|
|
61887
|
+
const b = levelBounds(building, loc.map);
|
|
61888
|
+
if (!b)
|
|
61889
|
+
return null;
|
|
61890
|
+
const pct = (v) => Math.round(Math.min(100, Math.max(0, v)) * 10) / 10;
|
|
61891
|
+
return { x: pct((loc.x - b.minX) / (b.maxX - b.minX) * 100), y: pct((b.maxY - loc.y) / (b.maxY - b.minY) * 100) };
|
|
61892
|
+
}
|
|
61893
|
+
var MODE_BY_STATUS2 = {
|
|
61894
|
+
idle: "IDLE",
|
|
61895
|
+
working: "WORKING",
|
|
61896
|
+
charging: "CHARGING_CYCLE",
|
|
61897
|
+
error: "MAINTENANCE"
|
|
61898
|
+
};
|
|
61899
|
+
function toAdapterRobot(fleet2, name, s, building, paused = false) {
|
|
61900
|
+
const status = s.status ?? "uninitialized";
|
|
61901
|
+
const online = !["offline", "shutdown", "uninitialized"].includes(status);
|
|
61902
|
+
let mode = online ? MODE_BY_STATUS2[status] ?? "UNAVAILABLE" : "UNAVAILABLE";
|
|
61903
|
+
if (mode === "CHARGING_CYCLE" && (s.battery ?? 0) >= 0.995)
|
|
61904
|
+
mode = "CHARGED";
|
|
61905
|
+
if (paused && mode === "WORKING")
|
|
61906
|
+
mode = "PAUSED";
|
|
61907
|
+
const issue = (s.issues ?? []).find((i) => i?.category);
|
|
61908
|
+
const loc = s.location ?? null;
|
|
61909
|
+
const floorNo2 = floorNoOf(loc?.map);
|
|
61910
|
+
return {
|
|
61911
|
+
robotSn: `${fleet2}/${name}`,
|
|
61912
|
+
name,
|
|
61913
|
+
model: fleet2,
|
|
61914
|
+
online,
|
|
61915
|
+
mode,
|
|
61916
|
+
statusName: s.task_id ? `${status} \xB7 task ${s.task_id.slice(0, 8)}` : status,
|
|
61917
|
+
batteryPercent: typeof s.battery === "number" ? Math.round(s.battery * 100) : null,
|
|
61918
|
+
floorNo: floorNo2,
|
|
61919
|
+
floorKnown: floorNo2 !== null,
|
|
61920
|
+
position: loc ? { x: loc.x, y: loc.y, theta: loc.yaw } : null,
|
|
61921
|
+
planPosition: planShareOf(building, loc),
|
|
61922
|
+
fault: issue ? {
|
|
61923
|
+
code: String(issue.category).slice(0, 60),
|
|
61924
|
+
message: (typeof issue.detail === "string" ? issue.detail : JSON.stringify(issue.detail ?? "")).slice(0, 200)
|
|
61925
|
+
} : null
|
|
61926
|
+
};
|
|
61927
|
+
}
|
|
61928
|
+
function robotGraphIndex(building, loc) {
|
|
61929
|
+
const level2 = loc && building?.levels.find((l) => l.name === loc.map);
|
|
61930
|
+
if (!level2)
|
|
61931
|
+
return null;
|
|
61932
|
+
let best = null;
|
|
61933
|
+
for (const g of level2.nav_graphs) {
|
|
61934
|
+
for (const v of g.vertices) {
|
|
61935
|
+
const d = (v.x - loc.x) ** 2 + (v.y - loc.y) ** 2;
|
|
61936
|
+
if (!best || d < best.d)
|
|
61937
|
+
best = { name: g.name, d };
|
|
61938
|
+
}
|
|
61939
|
+
}
|
|
61940
|
+
return best?.name ?? null;
|
|
61941
|
+
}
|
|
61942
|
+
function waypointsFor(building, loc) {
|
|
61943
|
+
const graph = robotGraphIndex(building, loc);
|
|
61944
|
+
const level2 = loc && building?.levels.find((l) => l.name === loc.map);
|
|
61945
|
+
const vertices = level2?.nav_graphs.find((g) => g.name === graph)?.vertices.filter((v) => v.name) ?? [];
|
|
61946
|
+
return {
|
|
61947
|
+
chargers: vertices.filter((v) => hasParam(v, "is_charger")),
|
|
61948
|
+
cleaningZones: vertices.filter((v) => hasParam(v, "is_cleaning_zone")),
|
|
61949
|
+
places: vertices.filter((v) => !hasParam(v, "is_charger") && !hasParam(v, "is_cleaning_zone"))
|
|
61950
|
+
};
|
|
61951
|
+
}
|
|
61952
|
+
function cleanActivities(zone) {
|
|
61953
|
+
return [
|
|
61954
|
+
{ category: "go_to_place", description: zone },
|
|
61955
|
+
{
|
|
61956
|
+
category: "perform_action",
|
|
61957
|
+
description: {
|
|
61958
|
+
unix_millis_action_duration_estimate: 6e4,
|
|
61959
|
+
category: "clean",
|
|
61960
|
+
expected_finish_location: zone,
|
|
61961
|
+
description: { zone },
|
|
61962
|
+
use_tool_sink: true
|
|
61963
|
+
}
|
|
61964
|
+
}
|
|
61965
|
+
];
|
|
61966
|
+
}
|
|
61967
|
+
var composed = (category, activities) => ({
|
|
61968
|
+
category: "compose",
|
|
61969
|
+
requester: "iservice365",
|
|
61970
|
+
description: {
|
|
61971
|
+
category,
|
|
61972
|
+
phases: [{ activity: { category: "sequence", description: { activities } } }]
|
|
61973
|
+
}
|
|
61974
|
+
});
|
|
61975
|
+
function taskRequestFor(command, robotType, wp) {
|
|
61976
|
+
const pick = (names, allowed, what) => {
|
|
61977
|
+
const known = new Set(allowed.map((v) => v.name));
|
|
61978
|
+
const bad = names.filter((n) => !known.has(n));
|
|
61979
|
+
if (!names.length || bad.length) {
|
|
61980
|
+
throw new OpenRmfError(
|
|
61981
|
+
`Unknown ${what}${bad.length ? `: ${bad.join(", ")}` : ""}. Known: ${[...known].join(", ") || "none"}.`
|
|
61982
|
+
);
|
|
61983
|
+
}
|
|
61984
|
+
return names;
|
|
61985
|
+
};
|
|
61986
|
+
switch (command.kind) {
|
|
61987
|
+
case "full":
|
|
61988
|
+
if (robotType === "security") {
|
|
61989
|
+
return { category: "patrol", requester: "iservice365", description: { places: pick(wp.places.map((v) => v.name), wp.places, "patrol places"), rounds: 1 } };
|
|
61990
|
+
}
|
|
61991
|
+
return composed("clean", pick(wp.cleaningZones.map((v) => v.name), wp.cleaningZones, "cleaning zones").flatMap(cleanActivities));
|
|
61992
|
+
case "area":
|
|
61993
|
+
if (robotType === "security") {
|
|
61994
|
+
return { category: "patrol", requester: "iservice365", description: { places: command.areas.slice(0, 20), rounds: 1 } };
|
|
61995
|
+
}
|
|
61996
|
+
return composed("clean", pick(command.areas.slice(0, 20), wp.cleaningZones, "cleaning zones").flatMap(cleanActivities));
|
|
61997
|
+
case "return": {
|
|
61998
|
+
const charger = wp.chargers[0]?.name;
|
|
61999
|
+
if (!charger)
|
|
62000
|
+
throw new OpenRmfError("This robot has no charger on its current floor.");
|
|
62001
|
+
return composed("go_to_place", [{ category: "go_to_place", description: charger }]);
|
|
62002
|
+
}
|
|
62003
|
+
default:
|
|
62004
|
+
throw new OpenRmfError(`These robots do not take "${command.kind}".`);
|
|
62005
|
+
}
|
|
62006
|
+
}
|
|
62007
|
+
var DOOR_TYPE_SLIDING = /* @__PURE__ */ new Set([1, 2, 3, 4]);
|
|
62008
|
+
function buildingFromRmf(building) {
|
|
62009
|
+
const levels = building.levels.slice(0, 200);
|
|
62010
|
+
const floorOf = (name, i) => floorNoOf(name) ?? i + 1;
|
|
62011
|
+
const byName = new Map(levels.map((l, i) => [l.name, floorOf(l.name, i)]));
|
|
62012
|
+
return {
|
|
62013
|
+
name: String(building.name ?? "Building").slice(0, 60),
|
|
62014
|
+
levels: levels.map((l, i) => ({ floorNo: floorOf(l.name, i), name: l.name, elevationM: l.elevation })),
|
|
62015
|
+
doors: levels.flatMap(
|
|
62016
|
+
(l, i) => l.doors.map((d) => ({
|
|
62017
|
+
name: d.name,
|
|
62018
|
+
floorNo: floorOf(l.name, i),
|
|
62019
|
+
type: DOOR_TYPE_SLIDING.has(d.door_type) ? "sliding" : "hinged",
|
|
62020
|
+
start: { x: d.v1_x, y: d.v1_y },
|
|
62021
|
+
end: { x: d.v2_x, y: d.v2_y }
|
|
62022
|
+
}))
|
|
62023
|
+
),
|
|
62024
|
+
lifts: building.lifts.map((l) => ({
|
|
62025
|
+
name: l.name,
|
|
62026
|
+
x: l.ref_x,
|
|
62027
|
+
y: l.ref_y,
|
|
62028
|
+
widthM: l.width,
|
|
62029
|
+
depthM: l.depth,
|
|
62030
|
+
floors: l.levels.map((n) => byName.get(n)).filter((n) => typeof n === "number")
|
|
62031
|
+
}))
|
|
62032
|
+
};
|
|
62033
|
+
}
|
|
62034
|
+
function openRmfDoorDriver(client, doorName) {
|
|
62035
|
+
return {
|
|
62036
|
+
name: doorName,
|
|
62037
|
+
async read() {
|
|
62038
|
+
const s = await client.doorState(doorName).catch((e) => {
|
|
62039
|
+
if (/HTTP 404/.test(String(e?.message)))
|
|
62040
|
+
return null;
|
|
62041
|
+
throw e;
|
|
62042
|
+
});
|
|
62043
|
+
if (!s)
|
|
62044
|
+
return null;
|
|
62045
|
+
const t = s.door_time ?? {};
|
|
62046
|
+
return {
|
|
62047
|
+
doorName: s.door_name ?? doorName,
|
|
62048
|
+
doorTime: Number(t.sec ?? 0) * 1e3 + Math.round(Number(t.nanosec ?? 0) / 1e6),
|
|
62049
|
+
currentMode: doorModeOf(s.current_mode?.value)
|
|
62050
|
+
};
|
|
62051
|
+
},
|
|
62052
|
+
async request(request2) {
|
|
62053
|
+
if (request2.requestedMode !== DOOR_MODE.OPEN && request2.requestedMode !== DOOR_MODE.CLOSED) {
|
|
62054
|
+
throw new OpenRmfError("A door can only be asked to open or close.");
|
|
62055
|
+
}
|
|
62056
|
+
await client.doorRequest(doorName, request2.requestedMode);
|
|
62057
|
+
}
|
|
62058
|
+
};
|
|
62059
|
+
}
|
|
62060
|
+
function openRmfLiftDriver(client, liftName) {
|
|
62061
|
+
const destinations = /* @__PURE__ */ new Map();
|
|
62062
|
+
const send2 = (requestType, sessionId, destination, doorState) => client.liftRequest(liftName, {
|
|
62063
|
+
request_type: requestType,
|
|
62064
|
+
door_mode: doorState,
|
|
62065
|
+
destination,
|
|
62066
|
+
additional_session_ids: [sessionId]
|
|
62067
|
+
});
|
|
62068
|
+
return {
|
|
62069
|
+
name: liftName,
|
|
62070
|
+
async read() {
|
|
62071
|
+
const s = await client.liftState(liftName).catch((e) => {
|
|
62072
|
+
if (/HTTP 404/.test(String(e?.message)))
|
|
62073
|
+
return null;
|
|
62074
|
+
throw e;
|
|
62075
|
+
});
|
|
62076
|
+
if (!s)
|
|
62077
|
+
return null;
|
|
62078
|
+
const t = s.lift_time ?? {};
|
|
62079
|
+
return {
|
|
62080
|
+
liftName: s.lift_name ?? liftName,
|
|
62081
|
+
liftTime: Number(t.sec ?? 0) * 1e3 + Math.round(Number(t.nanosec ?? 0) / 1e6),
|
|
62082
|
+
availableFloors: Array.isArray(s.available_floors) ? s.available_floors.map(String) : [],
|
|
62083
|
+
currentFloor: String(s.current_floor ?? ""),
|
|
62084
|
+
destinationFloor: String(s.destination_floor ?? ""),
|
|
62085
|
+
doorState: [0, 1, 2].includes(s.door_state) ? s.door_state : 0,
|
|
62086
|
+
motionState: [0, 1, 2, 3].includes(s.motion_state) ? s.motion_state : 3,
|
|
62087
|
+
currentMode: [0, 1, 2, 3, 4, 5].includes(s.current_mode) ? s.current_mode : 0,
|
|
62088
|
+
sessionId: String(s.session_id ?? "")
|
|
62089
|
+
};
|
|
62090
|
+
},
|
|
62091
|
+
async request(r) {
|
|
62092
|
+
destinations.set(r.sessionId, r.destinationFloor);
|
|
62093
|
+
await send2(r.requestType, r.sessionId, r.destinationFloor, r.doorState);
|
|
62094
|
+
},
|
|
62095
|
+
async refresh(sessionId) {
|
|
62096
|
+
const destination = destinations.get(sessionId);
|
|
62097
|
+
if (destination)
|
|
62098
|
+
await send2(LIFT_REQUEST.AGV_MODE, sessionId, destination, 2);
|
|
62099
|
+
},
|
|
62100
|
+
async release(sessionId) {
|
|
62101
|
+
destinations.delete(sessionId);
|
|
62102
|
+
await send2(LIFT_REQUEST.END_SESSION, sessionId, "", 0);
|
|
62103
|
+
}
|
|
62104
|
+
};
|
|
62105
|
+
}
|
|
62106
|
+
function createOpenRmfAdapter(options) {
|
|
62107
|
+
const client = createOpenRmfClient(options && "config" in options ? options.config ?? null : openRmfConfig(), {
|
|
62108
|
+
fetch: options?.fetch,
|
|
62109
|
+
timeoutMs: options?.timeoutMs
|
|
62110
|
+
});
|
|
62111
|
+
async function states() {
|
|
62112
|
+
const [fleets, building] = await Promise.all([client.fleets(), client.buildingMap().catch(() => null)]);
|
|
62113
|
+
return { fleets: fleets ?? [], building };
|
|
62114
|
+
}
|
|
62115
|
+
async function openInterruptions(taskId) {
|
|
62116
|
+
if (!taskId)
|
|
62117
|
+
return [];
|
|
62118
|
+
const t = await client.taskState(taskId).catch(() => null);
|
|
62119
|
+
return Object.entries(t?.interruptions ?? {}).filter(([, v]) => !v?.resumed_by).map(([token]) => token);
|
|
62120
|
+
}
|
|
62121
|
+
async function find(robotSn) {
|
|
62122
|
+
const key = splitRobotSn(robotSn);
|
|
62123
|
+
if (!key)
|
|
62124
|
+
return null;
|
|
62125
|
+
const { fleets, building } = await states();
|
|
62126
|
+
const s = fleets.find((f) => f.name === key.fleet)?.robots?.[key.robot];
|
|
62127
|
+
return s ? { key, s, building } : null;
|
|
62128
|
+
}
|
|
62129
|
+
return {
|
|
62130
|
+
client,
|
|
62131
|
+
brand: OPEN_RMF_BRAND,
|
|
62132
|
+
displayName: OPEN_RMF_DISPLAY_NAME,
|
|
62133
|
+
capabilities: OPEN_RMF_CAPABILITIES,
|
|
62134
|
+
async listRobots() {
|
|
62135
|
+
const { fleets, building } = await states();
|
|
62136
|
+
return fleets.flatMap((f) => Object.entries(f.robots ?? {}).map(([n, s]) => toAdapterRobot(f.name, n, s, building)));
|
|
62137
|
+
},
|
|
62138
|
+
async getRobot(robotSn) {
|
|
62139
|
+
const hit = await find(robotSn);
|
|
62140
|
+
if (!hit)
|
|
62141
|
+
return null;
|
|
62142
|
+
return toAdapterRobot(hit.key.fleet, hit.key.robot, hit.s, hit.building, (await openInterruptions(hit.s.task_id)).length > 0);
|
|
62143
|
+
},
|
|
62144
|
+
async sendCommand(robotSn, command) {
|
|
62145
|
+
const hit = await find(robotSn);
|
|
62146
|
+
if (!hit)
|
|
62147
|
+
throw new OpenRmfError(`The fleet server does not list the robot "${robotSn}".`);
|
|
62148
|
+
const taskId = hit.s.task_id ?? "";
|
|
62149
|
+
if (command.kind === "pause" || command.kind === "resume" || command.kind === "cancel") {
|
|
62150
|
+
if (!taskId)
|
|
62151
|
+
throw new OpenRmfError("This robot has no task to " + command.kind + ".");
|
|
62152
|
+
let res2;
|
|
62153
|
+
if (command.kind === "resume") {
|
|
62154
|
+
const tokens = await openInterruptions(taskId);
|
|
62155
|
+
if (!tokens.length)
|
|
62156
|
+
throw new OpenRmfError("This robot's task is not paused.");
|
|
62157
|
+
res2 = await client.resumeTask(taskId, tokens);
|
|
62158
|
+
} else {
|
|
62159
|
+
res2 = command.kind === "pause" ? await client.interruptTask(taskId) : await client.cancelTask(taskId);
|
|
62160
|
+
}
|
|
62161
|
+
if (res2 && res2.success === false)
|
|
62162
|
+
throw new OpenRmfError(`The fleet server refused to ${command.kind} the task.`);
|
|
62163
|
+
return;
|
|
62164
|
+
}
|
|
62165
|
+
const wp = waypointsFor(hit.building, hit.s.location);
|
|
62166
|
+
const request2 = taskRequestFor(command, wp.cleaningZones.length ? "cleaning" : "security", wp);
|
|
62167
|
+
const res = await client.robotTask(hit.key.fleet, hit.key.robot, request2);
|
|
62168
|
+
if (!res?.success)
|
|
62169
|
+
throw new OpenRmfError("The fleet server did not accept the task.");
|
|
62170
|
+
},
|
|
62171
|
+
/**
|
|
62172
|
+
* The robot's current patrol, from its task state: each phase is
|
|
62173
|
+
* "Go to [place:<name>]", in order, and the active phase is the checkpoint
|
|
62174
|
+
* it is heading for. (A direct robot task keeps no request record on the
|
|
62175
|
+
* api-server, so the state is the only source.)
|
|
62176
|
+
*/
|
|
62177
|
+
async getPatrolRoutes(robotSn) {
|
|
62178
|
+
const none = { routes: [], schedule: [] };
|
|
62179
|
+
const hit = await find(robotSn);
|
|
62180
|
+
const taskId = hit?.s.task_id;
|
|
62181
|
+
if (!hit || !taskId)
|
|
62182
|
+
return none;
|
|
62183
|
+
const t = await client.taskState(taskId).catch(() => null);
|
|
62184
|
+
if (!t || !/^patrol$/i.test(String(t.category ?? "")))
|
|
62185
|
+
return none;
|
|
62186
|
+
const level2 = hit.building?.levels.find((l) => l.name === hit.s.location?.map);
|
|
62187
|
+
const vertex = (name) => level2?.nav_graphs.flatMap((g) => g.vertices).find((v) => v.name === name);
|
|
62188
|
+
const phases = Object.entries(t.phases ?? {}).sort(([a], [b]) => Number(a) - Number(b)).map(([id, p]) => ({ id: Number(id), place: /\[place:([^\]]+)\]/.exec(String(p?.category ?? ""))?.[1] ?? "" })).filter((p) => p.place && vertex(p.place));
|
|
62189
|
+
const checkpoints = phases.map((p) => {
|
|
62190
|
+
const v = vertex(p.place);
|
|
62191
|
+
return { name: p.place, ...planShareOf(hit.building, { map: level2.name, x: v.x, y: v.y, yaw: 0 }) };
|
|
62192
|
+
});
|
|
62193
|
+
const current = phases.findIndex((p) => p.id === t.active);
|
|
62194
|
+
return {
|
|
62195
|
+
routes: [
|
|
62196
|
+
{
|
|
62197
|
+
id: taskId,
|
|
62198
|
+
name: `Patrol \xB7 ${checkpoints.map((c) => c.name).join(" \u2192 ")}`.slice(0, 80),
|
|
62199
|
+
floorNo: floorNoOf(level2?.name),
|
|
62200
|
+
checkpoints,
|
|
62201
|
+
currentCheckpoint: current >= 0 ? current : null
|
|
62202
|
+
}
|
|
62203
|
+
],
|
|
62204
|
+
schedule: []
|
|
62205
|
+
};
|
|
62206
|
+
}
|
|
62207
|
+
};
|
|
62208
|
+
}
|
|
62209
|
+
function registerOpenRmfBrand(env2 = process.env) {
|
|
62210
|
+
if (!openRmfConfig(env2))
|
|
62211
|
+
return false;
|
|
62212
|
+
registerRobotBrand({
|
|
62213
|
+
brand: OPEN_RMF_BRAND,
|
|
62214
|
+
displayName: OPEN_RMF_DISPLAY_NAME,
|
|
62215
|
+
capabilities: OPEN_RMF_CAPABILITIES,
|
|
62216
|
+
types: ["cleaning", "security"],
|
|
62217
|
+
create: () => createOpenRmfAdapter()
|
|
62218
|
+
});
|
|
62219
|
+
return true;
|
|
62220
|
+
}
|
|
62221
|
+
registerOpenRmfBrand();
|
|
62222
|
+
|
|
61422
62223
|
// src/services/robot-fleet.service.ts
|
|
61423
62224
|
function useRobotFleetService(deps) {
|
|
61424
62225
|
const adapterFor = deps?.adapterFor ?? ((robot) => adapterForRobot(robot));
|
|
@@ -61966,213 +62767,6 @@ function robotActionsFor(actor) {
|
|
|
61966
62767
|
);
|
|
61967
62768
|
}
|
|
61968
62769
|
|
|
61969
|
-
// src/utils/lift-contract.util.ts
|
|
61970
|
-
var LIFT_DOOR = {
|
|
61971
|
-
CLOSED: 0,
|
|
61972
|
-
MOVING: 1,
|
|
61973
|
-
OPEN: 2
|
|
61974
|
-
};
|
|
61975
|
-
var LIFT_MOTION = {
|
|
61976
|
-
STOPPED: 0,
|
|
61977
|
-
UP: 1,
|
|
61978
|
-
DOWN: 2,
|
|
61979
|
-
UNKNOWN: 3
|
|
61980
|
-
};
|
|
61981
|
-
var LIFT_MODE = {
|
|
61982
|
-
UNKNOWN: 0,
|
|
61983
|
-
HUMAN: 1,
|
|
61984
|
-
AGV: 2,
|
|
61985
|
-
FIRE: 3,
|
|
61986
|
-
OFFLINE: 4,
|
|
61987
|
-
EMERGENCY: 5
|
|
61988
|
-
};
|
|
61989
|
-
var LIFT_REQUEST = {
|
|
61990
|
-
END_SESSION: 0,
|
|
61991
|
-
AGV_MODE: 1,
|
|
61992
|
-
HUMAN_MODE: 2
|
|
61993
|
-
};
|
|
61994
|
-
function isLiftAvailable(state) {
|
|
61995
|
-
if (!state)
|
|
61996
|
-
return false;
|
|
61997
|
-
return state.currentMode === LIFT_MODE.HUMAN || state.currentMode === LIFT_MODE.AGV;
|
|
61998
|
-
}
|
|
61999
|
-
function isSafeToCross(state, floor) {
|
|
62000
|
-
if (!isLiftAvailable(state) || !state)
|
|
62001
|
-
return false;
|
|
62002
|
-
if (state.currentFloor !== floor)
|
|
62003
|
-
return false;
|
|
62004
|
-
if (state.motionState !== LIFT_MOTION.STOPPED)
|
|
62005
|
-
return false;
|
|
62006
|
-
return state.doorState === LIFT_DOOR.OPEN;
|
|
62007
|
-
}
|
|
62008
|
-
function holdsLift(state, sessionId) {
|
|
62009
|
-
if (!state || !sessionId)
|
|
62010
|
-
return false;
|
|
62011
|
-
return state.sessionId === sessionId;
|
|
62012
|
-
}
|
|
62013
|
-
function servesFloor(state, floor) {
|
|
62014
|
-
if (!state || !floor)
|
|
62015
|
-
return false;
|
|
62016
|
-
return state.availableFloors.includes(floor);
|
|
62017
|
-
}
|
|
62018
|
-
function createLiftSimulator(options) {
|
|
62019
|
-
const { name, floors } = options;
|
|
62020
|
-
if (floors.length === 0)
|
|
62021
|
-
throw new Error("A lift must serve some floors.");
|
|
62022
|
-
const msPerFloor = options.msPerFloor ?? 2e3;
|
|
62023
|
-
const doorDwellMs = options.doorDwellMs ?? 5e3;
|
|
62024
|
-
const state = {
|
|
62025
|
-
liftName: name,
|
|
62026
|
-
liftTime: 0,
|
|
62027
|
-
availableFloors: [...floors],
|
|
62028
|
-
currentFloor: options.startFloor ?? floors[0],
|
|
62029
|
-
destinationFloor: options.startFloor ?? floors[0],
|
|
62030
|
-
doorState: LIFT_DOOR.CLOSED,
|
|
62031
|
-
motionState: LIFT_MOTION.STOPPED,
|
|
62032
|
-
currentMode: LIFT_MODE.HUMAN,
|
|
62033
|
-
sessionId: ""
|
|
62034
|
-
};
|
|
62035
|
-
let travelRemaining = 0;
|
|
62036
|
-
let doorTimer = 0;
|
|
62037
|
-
function tick(ms) {
|
|
62038
|
-
state.liftTime += ms;
|
|
62039
|
-
if (state.motionState !== LIFT_MOTION.STOPPED) {
|
|
62040
|
-
travelRemaining -= ms;
|
|
62041
|
-
if (travelRemaining <= 0) {
|
|
62042
|
-
state.currentFloor = state.destinationFloor;
|
|
62043
|
-
state.motionState = LIFT_MOTION.STOPPED;
|
|
62044
|
-
state.doorState = LIFT_DOOR.OPEN;
|
|
62045
|
-
doorTimer = doorDwellMs;
|
|
62046
|
-
}
|
|
62047
|
-
return;
|
|
62048
|
-
}
|
|
62049
|
-
if (state.doorState === LIFT_DOOR.OPEN) {
|
|
62050
|
-
doorTimer -= ms;
|
|
62051
|
-
if (doorTimer <= 0)
|
|
62052
|
-
state.doorState = LIFT_DOOR.CLOSED;
|
|
62053
|
-
}
|
|
62054
|
-
}
|
|
62055
|
-
return {
|
|
62056
|
-
name,
|
|
62057
|
-
state,
|
|
62058
|
-
tick,
|
|
62059
|
-
async read() {
|
|
62060
|
-
return { ...state, availableFloors: [...state.availableFloors] };
|
|
62061
|
-
},
|
|
62062
|
-
async request(request2) {
|
|
62063
|
-
if (request2.requestType === LIFT_REQUEST.END_SESSION) {
|
|
62064
|
-
if (state.sessionId === request2.sessionId) {
|
|
62065
|
-
state.sessionId = "";
|
|
62066
|
-
state.currentMode = LIFT_MODE.HUMAN;
|
|
62067
|
-
}
|
|
62068
|
-
return;
|
|
62069
|
-
}
|
|
62070
|
-
if (state.sessionId && state.sessionId !== request2.sessionId) {
|
|
62071
|
-
throw new Error(`Lift ${name} is held by ${state.sessionId}.`);
|
|
62072
|
-
}
|
|
62073
|
-
if (!state.availableFloors.includes(request2.destinationFloor)) {
|
|
62074
|
-
throw new Error(
|
|
62075
|
-
`Lift ${name} does not serve ${request2.destinationFloor}.`
|
|
62076
|
-
);
|
|
62077
|
-
}
|
|
62078
|
-
state.sessionId = request2.sessionId;
|
|
62079
|
-
state.currentMode = request2.requestType === LIFT_REQUEST.AGV_MODE ? LIFT_MODE.AGV : LIFT_MODE.HUMAN;
|
|
62080
|
-
state.destinationFloor = request2.destinationFloor;
|
|
62081
|
-
if (state.currentFloor === request2.destinationFloor) {
|
|
62082
|
-
state.motionState = LIFT_MOTION.STOPPED;
|
|
62083
|
-
state.doorState = LIFT_DOOR.OPEN;
|
|
62084
|
-
doorTimer = doorDwellMs;
|
|
62085
|
-
return;
|
|
62086
|
-
}
|
|
62087
|
-
const from = state.availableFloors.indexOf(state.currentFloor);
|
|
62088
|
-
const to = state.availableFloors.indexOf(request2.destinationFloor);
|
|
62089
|
-
state.motionState = to > from ? LIFT_MOTION.UP : LIFT_MOTION.DOWN;
|
|
62090
|
-
state.doorState = LIFT_DOOR.CLOSED;
|
|
62091
|
-
travelRemaining = Math.abs(to - from) * msPerFloor;
|
|
62092
|
-
},
|
|
62093
|
-
async refresh(sessionId) {
|
|
62094
|
-
if (state.sessionId !== sessionId)
|
|
62095
|
-
return;
|
|
62096
|
-
if (state.doorState === LIFT_DOOR.OPEN)
|
|
62097
|
-
doorTimer = doorDwellMs;
|
|
62098
|
-
},
|
|
62099
|
-
async release(sessionId) {
|
|
62100
|
-
if (state.sessionId !== sessionId)
|
|
62101
|
-
return;
|
|
62102
|
-
state.sessionId = "";
|
|
62103
|
-
state.currentMode = LIFT_MODE.HUMAN;
|
|
62104
|
-
}
|
|
62105
|
-
};
|
|
62106
|
-
}
|
|
62107
|
-
var LIFT_QUEUE_TTL_MS = 10 * 6e4;
|
|
62108
|
-
var LIFT_LEASE_MS = 3 * 6e4;
|
|
62109
|
-
var LIFT_SIM_MS_PER_FLOOR = 4e3;
|
|
62110
|
-
var LIFT_SIM_DOOR_DWELL_MS = 8e3;
|
|
62111
|
-
var LIFT_SIM_BOARD_MS = 6e3;
|
|
62112
|
-
var LIFT_SESSION_STATUS = [
|
|
62113
|
-
"queued",
|
|
62114
|
-
"active",
|
|
62115
|
-
"released",
|
|
62116
|
-
"expired",
|
|
62117
|
-
"cancelled"
|
|
62118
|
-
];
|
|
62119
|
-
async function simulatedLiftState(options) {
|
|
62120
|
-
const sim = createLiftSimulator({
|
|
62121
|
-
name: options.name,
|
|
62122
|
-
floors: options.floors,
|
|
62123
|
-
msPerFloor: LIFT_SIM_MS_PER_FLOOR,
|
|
62124
|
-
doorDwellMs: LIFT_SIM_DOOR_DWELL_MS
|
|
62125
|
-
});
|
|
62126
|
-
const session = options.session;
|
|
62127
|
-
if (!session || !options.floors.includes(session.fromFloor) || !options.floors.includes(session.toFloor)) {
|
|
62128
|
-
return { state: await sim.read(), phase: "idle" };
|
|
62129
|
-
}
|
|
62130
|
-
const STEP = 250;
|
|
62131
|
-
const elapsed = Math.max(0, options.now - session.activeAt);
|
|
62132
|
-
let phase = "to-pickup";
|
|
62133
|
-
let boardingLeft = LIFT_SIM_BOARD_MS;
|
|
62134
|
-
await sim.request({
|
|
62135
|
-
liftName: options.name,
|
|
62136
|
-
sessionId: session.id,
|
|
62137
|
-
requestType: LIFT_REQUEST.AGV_MODE,
|
|
62138
|
-
destinationFloor: session.fromFloor,
|
|
62139
|
-
doorState: LIFT_DOOR.OPEN
|
|
62140
|
-
});
|
|
62141
|
-
if (isSafeToCross(sim.state, session.fromFloor))
|
|
62142
|
-
phase = "boarding";
|
|
62143
|
-
for (let t = 0; t < elapsed; t += STEP) {
|
|
62144
|
-
const ms = Math.min(STEP, elapsed - t);
|
|
62145
|
-
sim.tick(ms);
|
|
62146
|
-
const s = sim.state;
|
|
62147
|
-
if (phase === "to-pickup") {
|
|
62148
|
-
if (isSafeToCross(s, session.fromFloor))
|
|
62149
|
-
phase = "boarding";
|
|
62150
|
-
} else if (phase === "boarding") {
|
|
62151
|
-
await sim.refresh(session.id);
|
|
62152
|
-
boardingLeft -= ms;
|
|
62153
|
-
if (boardingLeft <= 0) {
|
|
62154
|
-
phase = "to-destination";
|
|
62155
|
-
await sim.request({
|
|
62156
|
-
liftName: options.name,
|
|
62157
|
-
sessionId: session.id,
|
|
62158
|
-
requestType: LIFT_REQUEST.AGV_MODE,
|
|
62159
|
-
destinationFloor: session.toFloor,
|
|
62160
|
-
doorState: LIFT_DOOR.CLOSED
|
|
62161
|
-
});
|
|
62162
|
-
}
|
|
62163
|
-
} else if (phase === "to-destination") {
|
|
62164
|
-
if (isSafeToCross(s, session.toFloor))
|
|
62165
|
-
phase = "arrived";
|
|
62166
|
-
} else if (phase === "arrived") {
|
|
62167
|
-
await sim.refresh(session.id);
|
|
62168
|
-
}
|
|
62169
|
-
}
|
|
62170
|
-
return { state: await sim.read(), phase };
|
|
62171
|
-
}
|
|
62172
|
-
function liftQueueKey(mapId, liftName) {
|
|
62173
|
-
return `${mapId}:${liftName}`;
|
|
62174
|
-
}
|
|
62175
|
-
|
|
62176
62770
|
// src/utils/building-map.util.ts
|
|
62177
62771
|
var WALL_HEIGHT_M = 2.5;
|
|
62178
62772
|
var WALL_THICKNESS_M = 0.1;
|
|
@@ -62916,7 +63510,7 @@ function useRobotFleetController(deps) {
|
|
|
62916
63510
|
|
|
62917
63511
|
`);
|
|
62918
63512
|
};
|
|
62919
|
-
const handle = robot.brand === DEMO_BRAND ? startDemoTracking(getFleet2().adapterFor(robot), robotSn, send2) : startRobotTracking({
|
|
63513
|
+
const handle = robot.brand === DEMO_BRAND || robot.brand === OPEN_RMF_BRAND ? startDemoTracking(getFleet2().adapterFor(robot), robotSn, send2) : startRobotTracking({
|
|
62920
63514
|
credentials: {
|
|
62921
63515
|
appid: (robot.appKey ?? "").trim(),
|
|
62922
63516
|
secret: (robot.appToken ?? "").trim()
|
|
@@ -63619,7 +64213,34 @@ function useRobotMapController(deps) {
|
|
|
63619
64213
|
fail(next, e);
|
|
63620
64214
|
}
|
|
63621
64215
|
}
|
|
64216
|
+
async function getOpenRmfBuilding(req, res, next) {
|
|
64217
|
+
const { error, value } = import_joi78.default.object({ site: hexId, appSlug: import_joi78.default.string().allow("") }).validate(req.query);
|
|
64218
|
+
if (error)
|
|
64219
|
+
return fail(next, new import_node_server_utils162.BadRequestError(error.message));
|
|
64220
|
+
try {
|
|
64221
|
+
await requireSiteReach(req, value.site);
|
|
64222
|
+
const config2 = openRmfConfig();
|
|
64223
|
+
if (!config2)
|
|
64224
|
+
throw new import_node_server_utils162.NotFoundError("Fleet Core is not configured on this server.");
|
|
64225
|
+
const client = createOpenRmfClient(config2);
|
|
64226
|
+
const building = buildingFromRmf(await client.buildingMap());
|
|
64227
|
+
const [doorStates, liftStates] = await Promise.all([
|
|
64228
|
+
Promise.all(building.doors.slice(0, 100).map((d) => openRmfDoorDriver(client, d.name).read().catch(() => null))),
|
|
64229
|
+
Promise.all(building.lifts.slice(0, 20).map((l) => openRmfLiftDriver(client, l.name).read().catch(() => null)))
|
|
64230
|
+
]);
|
|
64231
|
+
res.json({
|
|
64232
|
+
source: "fleet-core",
|
|
64233
|
+
readOnly: true,
|
|
64234
|
+
...building,
|
|
64235
|
+
doorStates: doorStates.filter(Boolean),
|
|
64236
|
+
liftStates: liftStates.filter(Boolean)
|
|
64237
|
+
});
|
|
64238
|
+
} catch (e) {
|
|
64239
|
+
fail(next, e instanceof OpenRmfError ? new import_node_server_utils162.AppError(e.message, 502) : e);
|
|
64240
|
+
}
|
|
64241
|
+
}
|
|
63622
64242
|
return {
|
|
64243
|
+
getOpenRmfBuilding,
|
|
63623
64244
|
listMaps,
|
|
63624
64245
|
getMap,
|
|
63625
64246
|
createMap,
|
|
@@ -63935,7 +64556,7 @@ function useRobotSiteController() {
|
|
|
63935
64556
|
}
|
|
63936
64557
|
|
|
63937
64558
|
// src/controllers/robot-network.controller.ts
|
|
63938
|
-
var
|
|
64559
|
+
var MODES2 = ["IDLE", "CHARGED", "WORKING", "PAUSED", "CHARGING_CYCLE", "MAINTENANCE", "IN_TRANSIT", "MANUAL", "UNAVAILABLE"];
|
|
63939
64560
|
var NETWORK_STATES_MAX = 50;
|
|
63940
64561
|
function useRobotNetworkController() {
|
|
63941
64562
|
const hex = import_joi80.default.string().hex().length(24).allow("", null);
|
|
@@ -63951,7 +64572,7 @@ function useRobotNetworkController() {
|
|
|
63951
64572
|
brand: import_joi80.default.string().trim().max(60).allow("", null),
|
|
63952
64573
|
faultsOnly: import_joi80.default.boolean().default(false),
|
|
63953
64574
|
offlineOnly: import_joi80.default.boolean().default(false),
|
|
63954
|
-
status: import_joi80.default.string().valid(...
|
|
64575
|
+
status: import_joi80.default.string().valid(...MODES2).allow("", null)
|
|
63955
64576
|
});
|
|
63956
64577
|
const faultsSchema = import_joi80.default.object({
|
|
63957
64578
|
page: import_joi80.default.number().integer().min(1).max(1e4).default(1),
|
|
@@ -97423,6 +98044,7 @@ function usePersonalEmergencyChainController() {
|
|
|
97423
98044
|
DEMO_ROUTES,
|
|
97424
98045
|
DEVICE_STATUS,
|
|
97425
98046
|
DOBStatus,
|
|
98047
|
+
DOOR_MODE,
|
|
97426
98048
|
DUPLICATE_TERMS_VERSION_MESSAGE,
|
|
97427
98049
|
DayOfWeek,
|
|
97428
98050
|
E164,
|
|
@@ -97562,6 +98184,9 @@ function usePersonalEmergencyChainController() {
|
|
|
97562
98184
|
NotificationModule,
|
|
97563
98185
|
NotificationService,
|
|
97564
98186
|
OFFLINE_FAULT_CODE,
|
|
98187
|
+
OPEN_RMF_BRAND,
|
|
98188
|
+
OPEN_RMF_CAPABILITIES,
|
|
98189
|
+
OPEN_RMF_DISPLAY_NAME,
|
|
97565
98190
|
ORG_MARKETPLACE_VENDOR_FIELD,
|
|
97566
98191
|
ORG_OWNER_REPAIR_CLAIM_STALE_MS,
|
|
97567
98192
|
ORG_OWNER_REPAIR_CLAIM_TAKEN_REASON,
|
|
@@ -97570,6 +98195,7 @@ function usePersonalEmergencyChainController() {
|
|
|
97570
98195
|
OUNITECH_BRAND,
|
|
97571
98196
|
OUNITECH_CAPABILITIES,
|
|
97572
98197
|
OUNITECH_PENDING_COMMANDS,
|
|
98198
|
+
OpenRmfError,
|
|
97573
98199
|
OrgNature,
|
|
97574
98200
|
OvernightParkingRequestSort,
|
|
97575
98201
|
OvernightParkingRequestStatus,
|
|
@@ -97666,6 +98292,7 @@ function usePersonalEmergencyChainController() {
|
|
|
97666
98292
|
attendanceSchema,
|
|
97667
98293
|
attendanceSettingsSchema,
|
|
97668
98294
|
buildSelfServiceEmailContext,
|
|
98295
|
+
buildingFromRmf,
|
|
97669
98296
|
buildingMapBodySchema,
|
|
97670
98297
|
buildingMapCreateSchema,
|
|
97671
98298
|
buildingMapFromRobotMaps,
|
|
@@ -97707,6 +98334,8 @@ function usePersonalEmergencyChainController() {
|
|
|
97707
98334
|
createDemoAdapter,
|
|
97708
98335
|
createLiftSimulator,
|
|
97709
98336
|
createManpowerRemarksDaily,
|
|
98337
|
+
createOpenRmfAdapter,
|
|
98338
|
+
createOpenRmfClient,
|
|
97710
98339
|
createOunitechAdapter,
|
|
97711
98340
|
createSseParser,
|
|
97712
98341
|
customerSchema,
|
|
@@ -97729,6 +98358,7 @@ function usePersonalEmergencyChainController() {
|
|
|
97729
98358
|
deviceHttpTimeoutMs,
|
|
97730
98359
|
deviceProbeTtlSeconds,
|
|
97731
98360
|
disconnectedState,
|
|
98361
|
+
doorModeOf,
|
|
97732
98362
|
emitNotificationCreated,
|
|
97733
98363
|
emptyPersonalEmergencyChain,
|
|
97734
98364
|
encodeGreyscalePng,
|
|
@@ -97745,6 +98375,7 @@ function usePersonalEmergencyChainController() {
|
|
|
97745
98375
|
ffmpegFrameArgs,
|
|
97746
98376
|
ffmpegPath,
|
|
97747
98377
|
filterByAccess,
|
|
98378
|
+
floorNoOf,
|
|
97748
98379
|
formatCapabilityTrace,
|
|
97749
98380
|
formatDahuaDate,
|
|
97750
98381
|
getIO,
|
|
@@ -97767,6 +98398,7 @@ function usePersonalEmergencyChainController() {
|
|
|
97767
98398
|
isAvailableForWork,
|
|
97768
98399
|
isCameraEntitled,
|
|
97769
98400
|
isDispatchable,
|
|
98401
|
+
isDoorPassable,
|
|
97770
98402
|
isDuplicateMemberError,
|
|
97771
98403
|
isDuplicateVersionError,
|
|
97772
98404
|
isLiftAvailable,
|
|
@@ -97821,6 +98453,9 @@ function usePersonalEmergencyChainController() {
|
|
|
97821
98453
|
occurrence_book_namespace_collection,
|
|
97822
98454
|
onBookTimezonesChanged,
|
|
97823
98455
|
online_forms_namespace_collection,
|
|
98456
|
+
openRmfConfig,
|
|
98457
|
+
openRmfDoorDriver,
|
|
98458
|
+
openRmfLiftDriver,
|
|
97824
98459
|
orgLevelRoles,
|
|
97825
98460
|
orgModulesHandlers,
|
|
97826
98461
|
orgOwnerRepairHandlers,
|
|
@@ -97843,6 +98478,7 @@ function usePersonalEmergencyChainController() {
|
|
|
97843
98478
|
planDayFromJsDay,
|
|
97844
98479
|
planDemoRobots,
|
|
97845
98480
|
planOrgOwnerRepair,
|
|
98481
|
+
planShareOf,
|
|
97846
98482
|
platform_terms_namespace_collection,
|
|
97847
98483
|
playbackRelays,
|
|
97848
98484
|
playbackWindowRefusal,
|
|
@@ -97859,6 +98495,7 @@ function usePersonalEmergencyChainController() {
|
|
|
97859
98495
|
refuseServiceProviderInviteAction,
|
|
97860
98496
|
registerCameraTransport,
|
|
97861
98497
|
registerDemoBrand,
|
|
98498
|
+
registerOpenRmfBrand,
|
|
97862
98499
|
registerOunitechBrand,
|
|
97863
98500
|
registerRobotBrand,
|
|
97864
98501
|
registeredRobotBrands,
|
|
@@ -98059,6 +98696,7 @@ function usePersonalEmergencyChainController() {
|
|
|
98059
98696
|
site_people_namespace_collection,
|
|
98060
98697
|
snapshotEndpoint,
|
|
98061
98698
|
snapshotRefusalReason,
|
|
98699
|
+
splitRobotSn,
|
|
98062
98700
|
staffMayBypass,
|
|
98063
98701
|
startDemoTracking,
|
|
98064
98702
|
startRobotTracking,
|
|
@@ -98068,6 +98706,8 @@ function usePersonalEmergencyChainController() {
|
|
|
98068
98706
|
subscriptionPlanSchema,
|
|
98069
98707
|
summariseBulkCameraPlan,
|
|
98070
98708
|
supports,
|
|
98709
|
+
taskRequestFor,
|
|
98710
|
+
toAdapterRobot,
|
|
98071
98711
|
trackingBackoffMs,
|
|
98072
98712
|
uncontrollableFleetWarning,
|
|
98073
98713
|
updateRemarksStatusEod,
|
|
@@ -98316,6 +98956,7 @@ function usePersonalEmergencyChainController() {
|
|
|
98316
98956
|
userSchema,
|
|
98317
98957
|
vehicleCategoryFor,
|
|
98318
98958
|
vehicleHistoryEntry,
|
|
98959
|
+
vehicleHistoryValue,
|
|
98319
98960
|
vehicleListViewQuery,
|
|
98320
98961
|
vehicleSchema,
|
|
98321
98962
|
vehicleViewOf,
|
|
@@ -98324,6 +98965,7 @@ function usePersonalEmergencyChainController() {
|
|
|
98324
98965
|
visitors_namespace_collection,
|
|
98325
98966
|
wallConfig,
|
|
98326
98967
|
wallsFromOccupancyGrid,
|
|
98968
|
+
waypointsFor,
|
|
98327
98969
|
withLiveLink,
|
|
98328
98970
|
workOrderSchema,
|
|
98329
98971
|
work_orders2_namespace_collection,
|