map中 增加显示障碍物代码 未测试,优化显示实时路径,完善返航点、分区的绘制显示 障碍物 支持拖动半径显示 地图增加图例,优化机器人任务界面的逻辑 无需收到刷新接口,根据传输任务完成情况 调用接口,已测试
This commit is contained in:
@@ -43,6 +43,7 @@ export default class DeviceController {
|
||||
this.onRequestControlStatusChange = null;
|
||||
this.onPermissionRequest = null;
|
||||
this.onRoutePost = null;
|
||||
this.deviceStatusChangedMsg = null;
|
||||
this.onIsFinished = null;
|
||||
this.onIsExecuting = null;
|
||||
this.handleArrivedPoint = null;
|
||||
@@ -118,34 +119,46 @@ export default class DeviceController {
|
||||
try { msg = JSON.parse(event.data); } catch (e) { return; }
|
||||
|
||||
console.log('[DeviceController] 收到全量设备状态 初始状态', msg);
|
||||
if (msg?.type !== 'mapPush') return;
|
||||
const list = Array.isArray(msg?.data) && msg.data.length
|
||||
? msg.data
|
||||
: [];
|
||||
if (!list.length) return;
|
||||
if (msg?.type == 'mapPush') {
|
||||
const list = Array.isArray(msg?.data) && msg.data.length
|
||||
? msg.data
|
||||
: [];
|
||||
if (!list.length) return;
|
||||
|
||||
const next = {};
|
||||
list.forEach((it) => {
|
||||
const key = String(it?.id ?? '');
|
||||
if (!key) return;
|
||||
next[key] = {
|
||||
id: key,
|
||||
lng: String(it?.lng ?? it?.lon ?? it?.longitude),
|
||||
lat: String(it?.lat ?? it?.latitude),
|
||||
yaw: it?.y,
|
||||
fix: it?.f !== undefined ? String(it.f) : undefined,
|
||||
fixStatus: it?.f !== undefined ? String(it.f) : undefined,
|
||||
altitude: it?.a !== undefined ? String(it.a) : undefined,
|
||||
status: it?.s ?? it?.status,
|
||||
taskId: it?.t ?? it?.taskId ?? null,
|
||||
battery: it?.b !== undefined ? Number(it.b) : (it?.batteryLevel !== undefined ? Number(it.batteryLevel) : undefined),
|
||||
hasAlarm: !!it?.ha || !!it?.hasAlarm,
|
||||
updateTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
controlMode: it?.cm ?? it?.controlMode,
|
||||
};
|
||||
});
|
||||
console.log('[DeviceController] 收到全量设备状态', next);
|
||||
this.onMapPush?.(next);
|
||||
}
|
||||
if (msg?.type == 'device_task_change') {
|
||||
if (msg.status == "FINISH") {
|
||||
console.log('task finish');
|
||||
this.onIsFinished?.(true);
|
||||
}
|
||||
if (msg.status == "EXECUTING" || msg.status == "CANCELLED" || msg.status == "FAILED") {
|
||||
this.onIsExecuting?.(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const next = {};
|
||||
list.forEach((it) => {
|
||||
const key = String(it?.id ?? '');
|
||||
if (!key) return;
|
||||
next[key] = {
|
||||
id: key,
|
||||
lng: String(it?.lng ?? it?.lon ?? it?.longitude),
|
||||
lat: String(it?.lat ?? it?.latitude),
|
||||
yaw: it?.y,
|
||||
fix: it?.f !== undefined ? String(it.f) : undefined,
|
||||
fixStatus: it?.f !== undefined ? String(it.f) : undefined,
|
||||
altitude: it?.a !== undefined ? String(it.a) : undefined,
|
||||
status: it?.s ?? it?.status,
|
||||
taskId: it?.t ?? it?.taskId ?? null,
|
||||
battery: it?.b !== undefined ? Number(it.b) : (it?.batteryLevel !== undefined ? Number(it.batteryLevel) : undefined),
|
||||
hasAlarm: !!it?.ha || !!it?.hasAlarm,
|
||||
updateTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
controlMode: it?.cm ?? it?.controlMode,
|
||||
};
|
||||
});
|
||||
console.log('[DeviceController] 收到全量设备状态', next);
|
||||
this.onMapPush?.(next);
|
||||
};
|
||||
|
||||
ws.onerror = () => {
|
||||
@@ -447,10 +460,10 @@ export default class DeviceController {
|
||||
break;
|
||||
}
|
||||
case "device_task_change": {
|
||||
if (msg.deviceId != this.connectedDeviceSn) return;
|
||||
console.log('task change:', msg);
|
||||
|
||||
if (msg.status == "FINISH") {
|
||||
console.log('task finish');
|
||||
this.onIsFinished?.(true);
|
||||
}
|
||||
if (msg.status == "EXECUTING") {
|
||||
@@ -479,7 +492,6 @@ export default class DeviceController {
|
||||
}
|
||||
|
||||
case 'detectionReport':
|
||||
if (msg.data?.deviceId !== this.connectedDeviceSn) return;
|
||||
const { isSecure, obstacle } = msg.data;
|
||||
if (isSecure) return;
|
||||
const type = obstacle?.type;
|
||||
@@ -500,6 +512,14 @@ export default class DeviceController {
|
||||
|
||||
break;
|
||||
|
||||
case 'device_status_changed':
|
||||
this.deviceStatusChangedMsg?.(msg);
|
||||
break;
|
||||
|
||||
case 'remoteControl':
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user