feat: 在机器人状态枚举中新增“未知”状态,增强状态管理;在播放 WebSocket 中合并机器人状态与业务数据,确保状态值的有效性;在运动监控页面中添加调试代码以自动设置回放日期和时间
This commit is contained in:
parent
648d27d196
commit
6033553196
@ -16,6 +16,7 @@ export enum RobotType {
|
||||
export const ROBOT_TYPE_OPTIONS = <Array<[string, RobotType]>>Object.entries(RobotType).filter(([, v]) => isNumber(v));
|
||||
|
||||
export enum RobotState {
|
||||
未知 = -1,
|
||||
任务执行中 = 1,
|
||||
充电中,
|
||||
停靠中,
|
||||
|
@ -2,7 +2,7 @@
|
||||
import { message } from 'ant-design-vue';
|
||||
import { type Ref, ref, type ShallowRef, shallowRef } from 'vue';
|
||||
|
||||
import type { RobotRealtimeInfo } from '../apis/robot';
|
||||
import { type RobotRealtimeInfo, RobotState } from '../apis/robot';
|
||||
import type { EditorService } from '../services/editor.service';
|
||||
import { useViewState } from '../services/useViewState';
|
||||
import ws from '../services/ws';
|
||||
@ -166,7 +166,9 @@ export function usePlaybackWebSocket(editorService: ShallowRef<EditorService | u
|
||||
updates.forEach(({ id, data }) => {
|
||||
const robotExists = editor.checkRobotById(id);
|
||||
if (robotExists) {
|
||||
const { x, y, angle, ...rest } = data;
|
||||
const { x, y, angle, state, ...rest } = data;
|
||||
const pen = editor.getPenById(id);
|
||||
const currentState = pen?.robot?.state;
|
||||
// 将业务数据和位置数据合并到一个对象中,通过 setValue 一次性更新
|
||||
editor.setValue(
|
||||
{
|
||||
@ -175,7 +177,11 @@ export function usePlaybackWebSocket(editorService: ShallowRef<EditorService | u
|
||||
y: y - 60,
|
||||
rotate: -angle! + 180,
|
||||
visible: true,
|
||||
robot: rest, // 将业务数据挂载到图元的 robot 属性上
|
||||
robot: {
|
||||
...rest,
|
||||
// 增加更严格的校验:确保 state 的值存在于 RobotState 枚举中
|
||||
state: RobotState[state] ? state : currentState ?? RobotState.未知,
|
||||
}, // 将业务数据挂载到图元的 robot 属性上
|
||||
},
|
||||
{ render: false },
|
||||
);
|
||||
|
@ -384,6 +384,10 @@ onMounted(async () => {
|
||||
await monitorScene();
|
||||
} else {
|
||||
playback.connect(props.sid);
|
||||
// [调试代码] 自动设置回放日期和时间
|
||||
const debugDate = dayjs('2025-09-28 09:00:00');
|
||||
selectedDate.value = debugDate;
|
||||
playback.seek(debugDate.valueOf());
|
||||
}
|
||||
|
||||
await editor.value?.initRobots();
|
||||
|
Loading…
x
Reference in New Issue
Block a user