Browse Source

注释调试数据

master
zhangjiming 5 months ago
parent
commit
3ae87923e1
  1. 24
      src/services/socket.ts
  2. 158
      src/stores/status.ts

24
src/services/socket.ts

@ -89,7 +89,8 @@ export type StatusDatagram = {
// heatingStatus: boolean; // heatingStatus: boolean;
// 加热区列表 // 加热区列表
heatArea: Array<{ heatArea: Array<{
heaterId: string;
// heaterId: string;
hardwareId: string;
trayStatus: 0 | 1 | 2; // 0为无托盘,1为有托盘,2为托盘抬起 trayStatus: 0 | 1 | 2; // 0为无托盘,1为有托盘,2为托盘抬起
isHeating: boolean; // 是否正在加热 isHeating: boolean; // 是否正在加热
capStatus: boolean; // 是否存在拍子 capStatus: boolean; // 是否存在拍子
@ -117,20 +118,20 @@ export type StatusDatagram = {
}; };
export type CraftState = { export type CraftState = {
type: "crafts"
type: "crafts";
data: { data: {
heatId: string | number
methodIndex: string| number
status: string| number
}
}
heatId: string | number;
methodIndex: string | number;
status: string | number;
};
};
export type ContainerDatagram = { export type ContainerDatagram = {
type: "container",
type: "container";
data: { data: {
containerList: Container[]; containerList: Container[];
}
}
};
};
export type Datagram = CmdDatagram | WarnDatagram | StatusDatagram | CraftDatagram | ContainerDatagram; export type Datagram = CmdDatagram | WarnDatagram | StatusDatagram | CraftDatagram | ContainerDatagram;
export type DatagramType = Datagram["type"]; export type DatagramType = Datagram["type"];
@ -251,6 +252,7 @@ export const createWebSocket = (url: string): WebSocketClient => {
} }
}; };
// export const sharedWsUrl = `ws://${window.location.hostname}:8080/ws`;
export const sharedWsUrl = `ws://${import.meta.env.VITE_API_HOST}:${import.meta.env.VITE_API_PORT}${ export const sharedWsUrl = `ws://${import.meta.env.VITE_API_HOST}:${import.meta.env.VITE_API_PORT}${
import.meta.env.VITE_WS_PATH import.meta.env.VITE_WS_PATH
}`;
}`;

158
src/stores/status.ts

@ -4,10 +4,158 @@ import * as R from "ramda";
import type { StatusDatagram } from "@/services/socket"; import type { StatusDatagram } from "@/services/socket";
import { BehaviorSubject, Subject } from "rxjs"; import { BehaviorSubject, Subject } from "rxjs";
const defaultStatus: StatusDatagram["data"] = {
emergencyStop: false, // 硬件急停信号,true 为急停触发,false 为正常运行
doorStatus: false, // 门的状态,false 表示关闭,true 表示开启
railArm: {
x: 0,
y: 0,
z: 0,
joint1: 0,
joint2: 0,
distance: 0, // 当前机械臂(轴 3)上下移动的距离
railDistance: 0,
clawDistance: 0,
clawStatus: false, // 夹爪状态,true 为张开,false 为闭合
isZeroPos: true, // 导轨是否在原点
isLimitPos: false, // 导轨是否在限位点
},
// 操作区(加液、摇匀、拍照)状态
liquidArea: {
liquidArm: {
x: 0,
y: 0,
z: 0,
joint1: 0,
joint2: 0,
pump: [
{
pumpId: 1,
isPumping: false, // 是否正在加液,true正在加液
},
{
pumpId: 2,
isPumping: false, // 是否正在加液,true正在加液
},
{
pumpId: 3,
isPumping: false, // 是否正在加液,true正在加液
},
{
pumpId: 4,
isPumping: false, // 是否正在加液,true正在加液
},
{
pumpId: 5,
isPumping: false, // 是否正在加液,true正在加液
},
{
pumpId: 6,
isPumping: false, // 是否正在加液,true正在加液
},
],
},
isShaking: false, // 是否正在摇匀
liquidTray: false, // 是否存在托盘
// 溶液容器状态
solutionBucket: [
{
isEmpty: false, // 容器是否为空
isFull: false, // 容器是否已满
},
{
isEmpty: false, // 容器是否为空
isFull: false, // 容器是否已满
},
{
isEmpty: false, // 容器是否为空
isFull: false, // 容器是否已满
},
{
isEmpty: false, // 容器是否为空
isFull: false, // 容器是否已满
},
{
isEmpty: false, // 容器是否为空
isFull: false, // 容器是否已满
},
{
isEmpty: false, // 容器是否为空
isFull: false, // 容器是否已满
},
{
isEmpty: false, // 容器是否为空
isFull: false, // 容器是否已满
},
{
isEmpty: false, // 容器是否为空
isFull: false, // 容器是否已满
},
],
},
// 加热区列表
heatArea: [
{
hardwareId: "hardware_1",
trayStatus: 0, // 0为无托盘,1为有托盘,2为托盘抬起
isHeating: false, // 是否正在加热
capStatus: false, // 是否存在拍子
isSealed: false, // 拍子密封状态,true为已密封,false为未密封
temperature: 0, // 当前温度
},
{
hardwareId: "hardware_2",
trayStatus: 0, // 0为无托盘,1为有托盘,2为托盘抬起
isHeating: false, // 是否正在加热
capStatus: false, // 是否存在拍子
isSealed: false, // 拍子密封状态,true为已密封,false为未密封
temperature: 0, // 当前温度
},
{
hardwareId: "hardware_3",
trayStatus: 0, // 0为无托盘,1为有托盘,2为托盘抬起
isHeating: false, // 是否正在加热
capStatus: false, // 是否存在拍子
isSealed: false, // 拍子密封状态,true为已密封,false为未密封
temperature: 0, // 当前温度
},
{
hardwareId: "hardware_4",
trayStatus: 0, // 0为无托盘,1为有托盘,2为托盘抬起
isHeating: false, // 是否正在加热
capStatus: false, // 是否存在拍子
isSealed: false, // 拍子密封状态,true为已密封,false为未密封
temperature: 0, // 当前温度
},
{
hardwareId: "hardware_5",
trayStatus: 0, // 0为无托盘,1为有托盘,2为托盘抬起
isHeating: false, // 是否正在加热
capStatus: false, // 是否存在拍子
isSealed: false, // 拍子密封状态,true为已密封,false为未密封
temperature: 0, // 当前温度
},
{
hardwareId: "hardware_6",
trayStatus: 0, // 0为无托盘,1为有托盘,2为托盘抬起
isHeating: false, // 是否正在加热
capStatus: false, // 是否存在拍子
isSealed: false, // 拍子密封状态,true为已密封,false为未密封
temperature: 0, // 当前温度
},
],
// 碱容器状态(废液桶)
alkaliBucket: {
isEmpty: false, // 容器是否为空
isFull: false, // 容器是否已满
},
};
export const useStatusStore = defineStore("status", () => { export const useStatusStore = defineStore("status", () => {
const status = ref<StatusDatagram["data"] | undefined>();
const status = ref<StatusDatagram["data"]>(defaultStatus);
const setStatus = (data: StatusDatagram["data"]) => { const setStatus = (data: StatusDatagram["data"]) => {
if (!R.equals(status.value, data)) {
if (!R.isEmpty(data) && !R.equals(status.value, data)) {
console.log("status: ", data); console.log("status: ", data);
status.value = data; status.value = data;
} }
@ -19,8 +167,8 @@ export const useStatusStore = defineStore("status", () => {
// 进行中状态 // 进行中状态
export type OnGoingStatus = "idle" | "doorOpening" | "doorClosing" | "shaking" | "injecting" | "movingToAct" | "movingToHeat"; export type OnGoingStatus = "idle" | "doorOpening" | "doorClosing" | "shaking" | "injecting" | "movingToAct" | "movingToHeat";
const onGoingStatusSub = new BehaviorSubject<OnGoingStatus>('idle');
const onGoingStatusSub = new BehaviorSubject<OnGoingStatus>("idle");
export const onGoingStatusOb = onGoingStatusSub.asObservable(); export const onGoingStatusOb = onGoingStatusSub.asObservable();
export function setOnGoingStatus(status: OnGoingStatus) { export function setOnGoingStatus(status: OnGoingStatus) {
onGoingStatusSub.next(status)
}
onGoingStatusSub.next(status);
}
Loading…
Cancel
Save