From a95f5000323ef94475b80ab4134457381e376673 Mon Sep 17 00:00:00 2001 From: zhangjiming Date: Sun, 2 Mar 2025 11:34:27 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8A=B6=E6=80=81=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/services/globalCmd/cmdTypes.ts | 114 ++++++++++++++++++++++++------------- src/stores/equipmentStatus.ts | 24 ++++---- 2 files changed, 88 insertions(+), 50 deletions(-) diff --git a/src/services/globalCmd/cmdTypes.ts b/src/services/globalCmd/cmdTypes.ts index ed733c1..2561e07 100644 --- a/src/services/globalCmd/cmdTypes.ts +++ b/src/services/globalCmd/cmdTypes.ts @@ -6,11 +6,11 @@ export type ControlType = { }; export type SyringeType = { - params : { + params: { rotationSpeed: number; direction: string | number; time: number; - } + }; }; type PositionType = { x: number; @@ -24,68 +24,106 @@ export type WorkType = { nitrogenAirPressure: number; matrixFlowVelocity: number; voltage: number; - needPower?: boolean; + needPower?: boolean; height: number; movementSpeed: number; position: PositionListType; }; - export type MachineryType = { - axis: string, - position: string | number -} + axis: string; + position: string | number; +}; -export type ControlNitrogen = 'Dehumidification' | 'Cleaning' | 'Nozzle' +export type ControlNitrogen = "Dehumidification" | "Cleaning" | "Nozzle"; export type VoltageType = { - params:{ - voltage: number - } -} + params: { + voltage: number; + }; +}; export type ControlValueType = { params: { - valveType: ControlNitrogen, - isOpen:boolean - } -} + valveType: ControlNitrogen; + isOpen: boolean; + }; +}; export type EquipmentStatusType = { - emergencyStop: boolean //急停状态 - pause: boolean, + 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: number //电机位置 - xAxisSpeed: number //电机速度 - xAxisMovementEnded: boolean - xAxisAtOrigin: boolean - xAxisLimited: boolean + xAxisPosition: 0, //电机位置 + xAxisSpeed: 0, //电机速度 + xAxisMovementEnded: false, + xAxisAtOrigin: false, + xAxisLimited: false, //Y轴电机状态 - yAxisPosition: number - yAxisSpeed: number - yAxisMovementEnded: boolean - yAxisAtOrigin: boolean - yAxisLimited:boolean + yAxisPosition: 0, + yAxisSpeed: 0, + yAxisMovementEnded: false, + yAxisAtOrigin: false, + yAxisLimited: false, //Z轴电机状态 - zAxisPosition: number - zAxisSpeed: number - zAxisMovementEnded: boolean - zAxisAtOrigin: boolean - zAxisLimited:boolean + zAxisPosition: 0, + zAxisSpeed: 0, + zAxisMovementEnded: false, + zAxisAtOrigin: false, + zAxisLimited: false, //三通阀状态 - threeWayValvePosition: string + threeWayValvePosition: "Nozzle", // 流量计状态 - flowRate: number + flowRate: 0, // 温湿度传感器状态 - temperature:number - humidity: number + temperature: 0, + humidity: 0, //注射泵状态 - syringePumpNormal: boolean + syringePumpNormal: false, } \ No newline at end of file diff --git a/src/stores/equipmentStatus.ts b/src/stores/equipmentStatus.ts index a90fa2d..1d5cfa0 100644 --- a/src/stores/equipmentStatus.ts +++ b/src/stores/equipmentStatus.ts @@ -1,18 +1,18 @@ import { defineStore } from "pinia"; -import { ref } from "vue"; +import { ref } from "vue"; import * as R from "ramda"; -import type { EquipmentStatusType } from '../services/globalCmd/cmdTypes' +import { defaultStatus, type EquipmentStatusType } from "../services/globalCmd/cmdTypes"; export const useEquipmentStatusStore = defineStore("equipmentStatus", () => { - const equipmentStatus = ref(); - const setEquipmentStatus = (data: EquipmentStatusType[]) => { - if (!R.equals(equipmentStatus.value, data)) { - equipmentStatus.value = data; - } + const equipmentStatus = ref(defaultStatus); + const setEquipmentStatus = (data: EquipmentStatusType) => { + if (!R.equals(equipmentStatus.value, data)) { + equipmentStatus.value = data; + } }; - return { - equipmentStatus, - setEquipmentStatus - } -}) \ No newline at end of file + return { + equipmentStatus, + setEquipmentStatus, + }; +});