Browse Source

添加调试命令接口

feature/tray
zhangjiming 6 months ago
parent
commit
556b6bb1f5
  1. 22
      src/services/debug/debugApi.ts
  2. 67
      src/views/debug/debug.vue

22
src/services/debug/debugApi.ts

@ -0,0 +1,22 @@
import httpRequest, { type BaseResponse } from "../httpRequest";
export type DebugCmd =
| "upTray" // 抬起托盘
| "downTray" // 降下托盘
| "injectFluid" // 注入溶液
| "moveToActionArea" // 移至操作区
| "shakeUp" // 摇匀
| "startHeat" // 开始加热
| "stopHeat" // 停止加热
| "keepHeat" // 恒温
| "takePhoto" // 拍照
| "moveToUnusual" // 移至异常区
| "moveToHeatArea" // 移至加热区
| "takeOffCap" // 取下拍子
| "putBackCap" // 装回拍子
| "moveMachineArm" // 移动机械臂
| "moveTube"; // 移动试管
export function debugCmd(params: { command: DebugCmd; params: Record<string, any> }) {
return httpRequest<BaseResponse<string>>({ url: "/api/cmd/", params, method: "POST" });
}

67
src/views/debug/debug.vue

@ -8,13 +8,13 @@
<input type="number" class="rounded-sm px-2" placeholder="指定异常区编号" />
</div>
<div class="flex gap-4 flex-wrap">
<button class="btn-light px-2 py-1">抬起托盘</button>
<button class="btn-light px-2 py-1">降下托盘</button>
<button class="btn-light px-2 py-1">取下拍子</button>
<button class="btn-light px-2 py-1">装回拍子</button>
<button class="btn-light px-2 py-1">移至操作区(加热摇匀拍照)</button>
<button class="btn-light px-2 py-1">移至异常区</button>
<button class="btn-light px-2 py-1">(从操作区)移至加热区</button>
<button class="btn-light px-2 py-1" @click="onCmdClick('upTray')">抬起托盘</button>
<button class="btn-light px-2 py-1" @click="onCmdClick('downTray')">降下托盘</button>
<button class="btn-light px-2 py-1" @click="onCmdClick('takeOffCap')">取下拍子</button>
<button class="btn-light px-2 py-1" @click="onCmdClick('putBackCap')">装回拍子</button>
<button class="btn-light px-2 py-1" @click="onCmdClick('moveToActionArea')">移至操作区(加热摇匀拍照)</button>
<button class="btn-light px-2 py-1" @click="onCmdClick('moveToUnusual')">移至异常区</button>
<button class="btn-light px-2 py-1" @click="onCmdClick('moveToHeatArea')">(从操作区)移至加热区</button>
</div>
</div>
@ -25,11 +25,11 @@
<label for="">注入量:</label>
<input type="number" class="rounded-sm px-2" placeholder="输入注入量" />
<span>ml</span>
<label for="">当前容量</label>
<span class="text-warn">50</span>
<label for="">当前容量</label>
<span class="text-warn">50</span>
</div>
<div class="flex gap-4 flex-wrap">
<button class="btn-light px-2 py-1">注入溶液</button>
<button class="btn-light px-2 py-1" @click="onCmdClick('injectFluid')">注入溶液</button>
</div>
</div>
<div class="frame">
@ -39,39 +39,58 @@
<label>温度:</label>
<input type="number" class="rounded-sm px-2" placeholder="输入温度" />
<span></span>
<label for="">当前温度</label>
<span class="text-warn">50</span>
<label for="">当前温度</label>
<span class="text-warn">50</span>
</div>
<div class="flex gap-4 flex-wrap">
<button class="btn-light px-2 py-1">开始加热</button>
<button class="btn-light px-2 py-1">停止加热</button>
<button class="btn-light px-2 py-1 min-w-20">恒温</button>
<button class="btn-light px-2 py-1" @click="onCmdClick('startHeat')">开始加热</button>
<button class="btn-light px-2 py-1" @click="onCmdClick('stopHeat')">停止加热</button>
<button class="btn-light px-2 py-1 min-w-20" @click="onCmdClick('keepHeat')">恒温</button>
</div>
</div>
<div class="frame">
<div class="flex gap-4 flex-wrap">
<button class="btn-light px-2 py-1 min-w-20">摇匀</button>
<button class="btn-light px-2 py-1 min-w-20">拍照</button>
<button class="btn-light px-2 py-1 min-w-20" @click="onCmdClick('shakeUp')">摇匀</button>
<button class="btn-light px-2 py-1 min-w-20" @click="onCmdClick('takePhoto')">拍照</button>
</div>
</div>
<div class="frame">
<div class="flex items-center gap-4">
X:<input type="number" class="rounded-sm px-1 w-16" /> Y:<input type="number" class="rounded-sm px-1 w-16" />
Z:<input type="number" class="rounded-sm px-1 w-16" />
<label for="">当前位置</label>
<span class="text-warn">505050</span>
<label for="">当前位置</label>
<span class="text-warn">505050</span>
</div>
<button class="btn-light px-2 py-1 min-w-20">移动机械臂</button>
<button class="btn-light px-2 py-1 min-w-20" @click="onCmdClick('moveMachineArm')">移动机械臂</button>
</div>
<div class="frame">
<div class="flex items-center gap-4">
<label>源位置:</label>
<input type="number" class="rounded-sm px-2" />
<label>目标位置:</label>
<input type="number" class="rounded-sm px-2" />
</div>
<button class="btn-light px-2 py-1 min-w-20" @click="onCmdClick('moveTube')">移动试管</button>
</div>
</div>
</template>
<script setup lang="ts"></script>
<script setup lang="ts">
import { debugCmd, type DebugCmd } from "@/services/debug/debugApi";
import { showToast } from "vant";
function onCmdClick(command: DebugCmd) {
debugCmd({ command, params: {} }).then(res => {
if (res.success) {
showToast('已执行,请稍等')
} else {
showToast(res.msg);
}
});
}
</script>
<style lang="scss" scoped>
.frame {
// border-radius: 0.5rem;
// border-width: 1px;
// border-color: #ccc;
border-bottom: solid 1px #ddd;
padding: 1rem 0.5rem;
display: flex;

Loading…
Cancel
Save