From c41205f1e637baa1e58ca27c32bd209f75074191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=A2=A6=E8=BF=9C?= <1063331231@qq.com> Date: Thu, 31 Jul 2025 18:40:24 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E6=B6=B2=E9=85=8D=E6=96=B9=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/craft/index.vue | 100 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 87 insertions(+), 13 deletions(-) diff --git a/src/views/craft/index.vue b/src/views/craft/index.vue index 4d204a9..acd300e 100644 --- a/src/views/craft/index.vue +++ b/src/views/craft/index.vue @@ -4,26 +4,27 @@ import { getSolsList } from 'apis/solution' import { ElMessageBox } from 'element-plus' import { FtMessage } from 'libs/message' import { socket } from 'libs/socket' +import { useHomeStore } from 'stores/homeStore' import { onMounted, onUnmounted, ref } from 'vue' const loading = ref(false) const statisticNumber = ref(0) +const homeStore = useHomeStore() onMounted(async () => { loading.value = true - socket.init(receiveMessage, 'pump_position') await getSolutionList() await getCraftList() loading.value = false + socket.init(receiveMessage, 'pump_position') }) - -onUnmounted(() => { +/* onUnmounted(() => { socket.unregisterCallback(receiveMessage, 'pump_position') -}) - +}) */ const receiveMessage = (data: number) => { - statisticNumber.value = data + console.log(`接收到泵的转数${data}`) + statisticNumber.value = statisticNumber.value + data } const form = ref({}) @@ -83,8 +84,6 @@ const nameClick = (item: Craft.CraftItem) => { const solution = solutionList.value.find(s => s.id === item.solutionId) form.value = { ...item, - concentration: solution?.concentration, - scale: solution?.scale, } } @@ -103,6 +102,77 @@ const delHandle = async (id: number | undefined) => { loading.value = false FtMessage.success('删除成功') } +let currentCommandId = '' +// 正转 反转 +const pumpRotate = async (direction: string) => { + currentCommandId = Date.now().toString() + if (direction === 'FORWARD') { + const params = { + commandId: currentCommandId, + command: 'pump_rotate_start', + params: { + direction: 'FORWARD', + position: form.value.revolutions, + solutionId: form.value.solutionId, + concentration: form.value.concentration, + }, + } + await homeStore.sendControl(params) + } + else { + const params = { + commandId: currentCommandId, + command: 'pump_rotate_start', + params: { + direction: 'BACKWARD', + solutionId: form.value.solutionId, + concentration: form.value.concentration, + position: form.value.revolutions, + }, + } + await homeStore.sendControl(params) + } +} +// 停止 +const pumpStop = async () => { + currentCommandId = Date.now().toString() + const params = { + commandId: currentCommandId, + command: 'pump_rotate_stop', + params: { + solutionId: form.value.solutionId, + concentration: form.value.concentration, + }, + } + await homeStore.sendControl(params) +} +// 预充 +const pumpPreFill = async () => { + currentCommandId = Date.now().toString() + const params = { + commandId: currentCommandId, + command: 'solution_pre_fill_start', + params: { + solutionId: form.value.solutionId, + concentration: form.value.concentration, + }, + } + await homeStore.sendControl(params) +} +// 加液 +const pumpAddSolution = async () => { + currentCommandId = Date.now().toString() + const params = { + commandId: currentCommandId, + command: 'solution_add_start', + params: { + solutionId: form.value.solutionId, + concentration: form.value.concentration, + position: form.value.revolutions, + }, + } + await homeStore.sendControl(params) +}