Browse Source

状态字段变更

feature/layout_0214
zhangjiming 5 months ago
parent
commit
2e6e48eab6
  1. 2
      src/App.vue
  2. 106
      src/services/socket.ts
  3. 25
      src/stores/setting.ts
  4. 2
      src/views/debug/debug.vue

2
src/App.vue

@ -18,7 +18,7 @@ wsClient.dataOb.subscribe(data => {
statusStore.setStatus(data.data);
} else if (data.type === "warn") {
ElMessage({
message: data.data.message,
message: data.data.msg,
type: "warning",
});
}

106
src/services/socket.ts

@ -1,4 +1,5 @@
import { Subject } from "rxjs";
import type { StepCmd } from "./globalCmd/globalCmd";
export type CmdSuccess = "D0000";
export type CmdFailure = "D1111";
@ -13,10 +14,24 @@ export type CmdDatagram = {
};
};
export type CraftDatagram = {
type: "crafts";
data: {
// 当前工艺执行状态,0 表示未执行,1 表示正在执行,2 表示暂停执行,3 表示停止执行。
status: 0 | 1 | 2 | 3;
// 当前正在执行的具体工艺方法
method: StepCmd;
// 加热区 ID
heatId: number;
};
};
export type WarnDatagram = {
type: "warn"; // 报警
data: {
message: string;
code: string;
msg: string;
module: string;
};
};
@ -24,58 +39,81 @@ export type StatusDatagram = {
type: "status"; // 状态
data: {
emergencyStop: boolean; // 硬件急停信号,true 为急停触发,false 为正常运行
doorStatus: 0 | 1; // 门的状态,0 表示关闭,1 表示开启
railArm: {
x: number;
y: number;
z: number;
joint1: number;
joint2: number;
joint3: number;
distance: number; // 当前机械臂(轴 3)上下移动的距离
railDistance: number;
clawDistance: number;
speed: number;
isZeroPos: 0 | 1; // 导轨是否在原点,0 表示不在原点,非 0 表示在原点
isLimitPos: 0 | 1; // 导轨是否在限位点,0 表示不在限位点,非 0 表示在限位点
clawStatus: boolean; // 夹爪状态,true 为张开,false 为闭合
isZeroPos: boolean; // 导轨是否在原点
isLimitPos: boolean; // 导轨是否在限位点
};
liquidArm: {
x: number;
y: number;
z: number;
joint1: number;
joint2: number;
speed: number;
// 操作区(加液、摇匀、拍照)状态
liquidArea: {
liquidArm: {
x: number;
y: number;
z: number;
joint1: number;
joint2: number;
pump: Array<{
pumpId: number;
isPumping: boolean; // 是否正在加液,true正在加液
}>;
};
isShaking: boolean; // 是否正在摇匀
liquidTray: boolean; // 是否存在托盘
// 溶液容器状态
solutionBucket: Array<{
isEmpty: boolean; // 容器是否为空
isFull: boolean; // 容器是否已满
}>;
};
// 加液泵状态列表
motors: Array<{
pumpId: string;
speed: number;
position: number; // 电机实时位置
isZeroPos: 0 | 1; // 电机是否在原点,0 表示不在原点,非 0 表示在原点
isLimitPos: 0 | 1; // 电机是否在限位点,0 表示不在限位点,非 0 表示在限位点
}>;
heatingStatus: boolean;
// 加热器状态列表
// motors: Array<{
// pumpId: string;
// speed: number;
// position: number; // 电机实时位置
// isZeroPos: 0 | 1; // 电机是否在原点,0 表示不在原点,非 0 表示在原点
// isLimitPos: 0 | 1; // 电机是否在限位点,0 表示不在限位点,非 0 表示在限位点
// }>;
// heatingStatus: boolean;
// 加热列表
heater: Array<{
heaterId: string;
temperature: number;
current: number;
trayStatus: 0 | 1 | 2; // 0为无托盘,1为有托盘,2为托盘抬起
isHeating: boolean; // 是否正在加热
capStatus: boolean; // 是否存在拍子
isSealed: boolean; // 拍子密封状态,true为已密封,false为未密封
temperature: number; // 当前温度
}>;
trayStatus: boolean[]; // 加热位托盘状态列表,true 为存在托盘,false 为无托盘
capStatus: boolean[]; // 拍子状态列表,true 为存在拍子,false 为无拍子
// 酸液桶状态
lyeTank: {
isEmpty: boolean;
isFull: boolean;
// 碱容器状态(废液桶)
alkaliBucket: {
isEmpty: boolean; // 容器是否为空
isFull: boolean; // 容器是否已满
};
// trayStatus: boolean[]; // 加热位托盘状态列表,true 为存在托盘,false 为无托盘
// capStatus: boolean[]; // 拍子状态列表,true 为存在拍子,false 为无拍子
// 酸液桶状态
// lyeTank: {
// isEmpty: boolean;
// isFull: boolean;
// };
// 废液桶状态
wasteTank: {
isEmpty: boolean;
isFull: boolean;
};
// wasteTank: {
// isEmpty: boolean;
// isFull: boolean;
// };
};
};
export type Datagram = CmdDatagram | WarnDatagram | StatusDatagram;
export type Datagram = CmdDatagram | WarnDatagram | StatusDatagram | CraftDatagram;
export type DatagramType = Datagram["type"];
export type SocketState = "open" | "close" | "error";

25
src/stores/setting.ts

@ -2,7 +2,7 @@ import type { Liquid } from "@/services/liquid/liquidManage";
import type { ConfigItem, Container } from "@/services/sysConfig/sysConfig";
import { defineStore } from "pinia";
import { computed, ref } from "vue";
import * as R from 'ramda';
import * as R from "ramda";
export const useSettingStore = defineStore("setting", () => {
const configs = ref<ConfigItem[] | undefined>();
@ -10,24 +10,35 @@ export const useSettingStore = defineStore("setting", () => {
configs.value = usr;
};
// 所有容器 : 8酸桶+1废桶
const containerConf = ref<Container[] | undefined>();
const setContainerConf = (containers: Container[]) => {
containerConf.value = containers;
};
// 酸液列表
const liquidList = ref<Liquid[] | undefined>();
const setLiquidList = (liquids: Liquid[]) => {
liquidList.value = liquids;
};
// 酸液列表 ID映射表: 使用方法 liquidIdMap[液体ID] -> Liquid对象
const liquidIdMap = computed(() => {
//@ts-ignore
return R.groupBy(l => l.id, liquidList.value || []);
});
// 8个酸桶
const heatContainers = computed(() => {
if (!containerConf.value) return [];
return containerConf.value.filter(c => c.type === 0);
});
// 配置了酸液的桶
const heatContainerWithLiquid = computed(() => {
return heatContainers.value.filter(c => c.solutionId);
});
// 配置了桶的酸液
const availableLiquids = computed(() => {
const solIds = heatContainers.value.filter(h => h.solutionId).map(h => h.solutionId)
return R.innerJoin((record, id) => record.id === id, liquidList.value || [], solIds)
})
const solIds = heatContainers.value.filter(h => h.solutionId).map(h => h.solutionId);
return R.innerJoin((record, id) => record.id === id, liquidList.value || [], solIds);
});
const heatAreaConfig = computed(() => {
if (!configs.value) return [];
return (configs.value.find(c => c.code === "heat_area")?.children || []).map(c => {
@ -67,6 +78,8 @@ export const useSettingStore = defineStore("setting", () => {
systemSetting,
containerConf,
liquidList,
liquidIdMap,
heatContainerWithLiquid,
heatContainers,
availableLiquids,
setLiquidList,

2
src/views/debug/debug.vue

@ -79,7 +79,7 @@
</div>
<div>
<label for="">当前温度</label>
<span class="text-warn">{{ (statusStore.status?.heater || []).map(h => h.current).join(",") }}</span>
<span class="text-warn">{{ (statusStore.status?.heater || []).map(h => h.temperature).join(",") }}</span>
</div>
</div>

Loading…
Cancel
Save