Compare commits

...

3 Commits

4 changed files with 15 additions and 4 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 {
= 0,
= 1,
,
,

View File

@ -147,7 +147,7 @@ const getDoInfo = (information: AmrRedisState['information'] | undefined) => {
<a-tag v-if="robot.state !== undefined">
<i class="dot mr-4" :class="stateDot" />
<span>{{ $t(RobotState[robot.state]) }}</span>
<span>{{ RobotState[robot.state] || '未知' }}</span>
</a-tag>
</a-space>
</a-col>

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