feat: 在机器人状态枚举中新增“未知”状态,增强状态管理;在播放 WebSocket 中合并机器人状态与业务数据,确保状态值的有效性;在运动监控页面中添加调试代码以自动设置回放日期和时间

This commit is contained in:
xudan 2025-10-11 09:40:06 +08:00
parent 648d27d196
commit 6033553196
3 changed files with 14 additions and 3 deletions

View File

@ -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,
,
,

View File

@ -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 },
);

View File

@ -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();