diff --git a/src/App.vue b/src/App.vue
index aa0670a..355b886 100644
--- a/src/App.vue
+++ b/src/App.vue
@@ -10,13 +10,6 @@ exceptionOb.subscribe(exp => {
}
});
-console.log("ws url: ", sharedWsUrl);
-const wsClient = createWebSocket(sharedWsUrl);
-wsClient.dataOb.subscribe(data => {
- console.log(data);
-});
-wsClient.connect();
-
diff --git a/src/services/debug/debugApi.ts b/src/services/debug/debugApi.ts
index 5521979..bb4797e 100644
--- a/src/services/debug/debugApi.ts
+++ b/src/services/debug/debugApi.ts
@@ -1,5 +1,23 @@
import httpRequest, { type BaseResponse } from "../httpRequest";
+export const CmdDescMap: { [k in DebugCmd]: string } = {
+ upTray: "抬起托盘",
+ downTray: "降下托盘",
+ injectFluid: "注入溶液",
+ moveToActionArea: "移至操作区",
+ shakeUp: "摇匀",
+ startHeat: "开始加热",
+ stopHeat: "停止加热",
+ keepHeat: "恒温",
+ takePhoto: "拍照",
+ moveToUnusual: "移至异常区",
+ moveToHeatArea: "移至加热区",
+ takeOffCap: "取下拍子",
+ putBackCap: "装回拍子",
+ moveMachineArm: "移动机械臂",
+ moveTube: "移动试管",
+};
+
export type DebugCmd =
| "upTray" // 抬起托盘
| "downTray" // 降下托盘
diff --git a/src/services/socket.ts b/src/services/socket.ts
index e1fbd5e..9991d6a 100644
--- a/src/services/socket.ts
+++ b/src/services/socket.ts
@@ -1,4 +1,33 @@
import { Subject } from "rxjs";
+import type { DebugCmd } from "./debug/debugApi";
+
+export type CmdSuccess = "D0000";
+export type CmdFailure = "D1111";
+export type CmdDatagram = {
+ type: "cmd"; // 指令
+ data: {
+ commandId: string;
+ commandName: DebugCmd;
+ status: CmdSuccess | CmdFailure;
+ message: string;
+ };
+};
+
+export type WarnDatagram = {
+ type: "warn"; // 报警
+ data: {
+ message: string;
+ };
+};
+export type StatusDatagram = {
+ type: "status"; // 状态
+ data: {
+ message: string;
+ };
+};
+
+export type Datagram = CmdDatagram | WarnDatagram | StatusDatagram;
+export type DatagramType = Datagram['type']
export type SocketState = "open" | "close" | "error";
@@ -9,7 +38,7 @@ class WebSocketClient {
private maxReconnectAttempts: number = 5;
private reconnectInterval: number = 3000;
- private dataSub = new Subject();
+ private dataSub = new Subject();
get dataOb() {
return this.dataSub.asObservable();
}
diff --git a/src/views/debug/debug.vue b/src/views/debug/debug.vue
index 776ca1f..4b3c83b 100644
--- a/src/views/debug/debug.vue
+++ b/src/views/debug/debug.vue
@@ -76,13 +76,32 @@