4 changed files with 128 additions and 91 deletions
-
78src/services/globalCmd/cmdTypes.ts
-
33src/services/socket.ts
-
106src/services/wsTypes.ts
-
2src/stores/equipmentStatus.ts
@ -0,0 +1,106 @@ |
|||
|
|||
export type CmdDatagram = { |
|||
type: "cmd"; // 指令
|
|||
data: { |
|||
commandId: string; |
|||
commandName: string; |
|||
status: "D0000" | "D1111"; |
|||
message: string; |
|||
success: boolean; |
|||
}; |
|||
}; |
|||
|
|||
type WarnType = "wash_complete" | "prefill_complete" | "dehumidify_complete" | "spray_complete" | "error"; |
|||
|
|||
export type WarnDatagram = { |
|||
type: "warn"; // 报警
|
|||
data: { |
|||
code: WarnType; |
|||
msg: string; |
|||
}; |
|||
}; |
|||
|
|||
export type StatusDatagram = { |
|||
type: "status"; // 状态
|
|||
data: EquipmentStatusType; |
|||
}; |
|||
|
|||
export type EquipmentStatusType = { |
|||
emergencyStop: boolean; //急停状态
|
|||
pause: boolean; |
|||
|
|||
//X轴电机状态
|
|||
xAxisPosition: number; //电机位置
|
|||
xAxisSpeed: number; //电机速度
|
|||
xAxisMovementEnded: boolean; |
|||
xAxisAtOrigin: boolean; |
|||
xAxisLimited: boolean; |
|||
|
|||
//Y轴电机状态
|
|||
yAxisPosition: number; |
|||
yAxisSpeed: number; |
|||
yAxisMovementEnded: boolean; |
|||
yAxisAtOrigin: boolean; |
|||
yAxisLimited: boolean; |
|||
|
|||
//Z轴电机状态
|
|||
zAxisPosition: number; |
|||
zAxisSpeed: number; |
|||
zAxisMovementEnded: boolean; |
|||
zAxisAtOrigin: boolean; |
|||
zAxisLimited: boolean; |
|||
|
|||
//三通阀状态
|
|||
threeWayValvePosition: "Dehumidification" | "Cleaning" | "Nozzle"; |
|||
|
|||
// 流量计状态
|
|||
flowRate: number; |
|||
|
|||
// 温湿度传感器状态
|
|||
temperature: number; |
|||
humidity: number; |
|||
|
|||
//注射泵状态
|
|||
syringePumpNormal: boolean; |
|||
}; |
|||
|
|||
export const defaultStatus: EquipmentStatusType = { |
|||
emergencyStop: false, //急停状态
|
|||
pause: false, |
|||
|
|||
//X轴电机状态
|
|||
xAxisPosition: 0, //电机位置
|
|||
xAxisSpeed: 0, //电机速度
|
|||
xAxisMovementEnded: false, |
|||
xAxisAtOrigin: false, |
|||
xAxisLimited: false, |
|||
|
|||
//Y轴电机状态
|
|||
yAxisPosition: 0, |
|||
yAxisSpeed: 0, |
|||
yAxisMovementEnded: false, |
|||
yAxisAtOrigin: false, |
|||
yAxisLimited: false, |
|||
|
|||
//Z轴电机状态
|
|||
zAxisPosition: 0, |
|||
zAxisSpeed: 0, |
|||
zAxisMovementEnded: false, |
|||
zAxisAtOrigin: false, |
|||
zAxisLimited: false, |
|||
|
|||
//三通阀状态
|
|||
threeWayValvePosition: "Nozzle", |
|||
|
|||
// 流量计状态
|
|||
flowRate: 0, |
|||
|
|||
// 温湿度传感器状态
|
|||
temperature: 0, |
|||
humidity: 20, |
|||
|
|||
//注射泵状态
|
|||
syringePumpNormal: false, |
|||
}; |
|||
|
|||
export type Datagram = CmdDatagram | WarnDatagram | StatusDatagram ; |
Write
Preview
Loading…
Cancel
Save
Reference in new issue