|
|
import { debugControl } from 'apis/system' import { FtMessage } from 'libs/message' import { cmdNameMap } from 'libs/utils' import { defineStore } from 'pinia' import { useSystemStore } from 'stores/systemStore'
export const useDebugStore = defineStore('debug', { state: (): Debug.DebugStore => ({ formData: { // 加液机械臂
liquidArmData: { largeArmAngle: undefined, smallArmAngle: undefined, largeArmRotationVelocity: undefined, smallArmRotationVelocity: undefined, }, // 加液泵
liquidPumpData: { index: undefined, // direction: 'forward',
volume: 20, velocity: 3, }, // 摇匀速度
shakeSpeed: { velocity: undefined, }, // 加热区
heatArea: { index: 'heat_module_01', heatMotorData: { distance: undefined, velocity: undefined, times: undefined, }, heatTemperature: { temperature: undefined, }, coldTrap: { temperature: undefined, }, }, // 转运模组
transferModule: { // X轴
xMotorData: { xDimDistance: undefined, xDimVelocity: undefined, times: undefined, direction: 'backward', }, // y轴
yMotorData: { yDimDistance: undefined, yDimVelocity: undefined, times: undefined, direction: 'backward', }, // z轴
zMotorData: { zDimDistance: undefined, zDimVelocity: undefined, times: undefined, direction: 'forward', }, // 夹爪
JawData: { velocity: undefined, openDistance: undefined, closeDistance: undefined, times: undefined, }, }, // 拍子模组
lidData: { velocity: undefined, distance: undefined, }, }, }), actions: { async sendControl(params: System.CmdControlParams<{ [key: string]: any }>) { if (!params.commandId) { params.commandId = Date.now().toString() } const systemStore = useSystemStore()
systemStore.systemList = []
// 提取 params.command 中的 xxx 部分
const commandKey = params.command.replace(/^debug_/, '')
// 使用提取的 key 匹配 cmdNameMap
const cmdName = cmdNameMap[commandKey as keyof typeof cmdNameMap] || params.command
await debugControl(params) systemStore.updateStreamVisible(true) FtMessage.success(`[${cmdName}]已发送`) }, }, persist: true, })
|