From b42da8415e2ef0aa45f0a9e32baa82e06ef533b0 Mon Sep 17 00:00:00 2001 From: maochaoying <925670706@qq.com> Date: Mon, 13 Nov 2023 17:53:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env | 8 +-- src/components/SealTest.vue | 29 +++++++-- src/components/Test.vue | 140 ++++++++++++++++++++++++++++++----------- src/store/modules/seal.js | 16 ++++- src/store/modules/websocket.js | 3 +- 5 files changed, 147 insertions(+), 49 deletions(-) diff --git a/.env b/.env index c4ae906..fe3f0dd 100644 --- a/.env +++ b/.env @@ -1,5 +1,5 @@ -# VITE_BASE_WS1_URL=ws://192.168.8.10:19001/ -# VITE_BASE_WS2_URL=ws://192.168.8.10:19002/ +VITE_BASE_WS1_URL=ws://192.168.8.10:19001/ +VITE_BASE_WS2_URL=ws://192.168.8.10:19002/ -VITE_BASE_WS1_URL=ws://127.0.0.1:19001/ -VITE_BASE_WS2_URL=ws://127.0.0.1:19002/ \ No newline at end of file +# VITE_BASE_WS1_URL=ws://127.0.0.1:19001/ +# VITE_BASE_WS2_URL=ws://127.0.0.1:19002/ \ No newline at end of file diff --git a/src/components/SealTest.vue b/src/components/SealTest.vue index 0f3b25e..6358b90 100644 --- a/src/components/SealTest.vue +++ b/src/components/SealTest.vue @@ -32,6 +32,18 @@ :src="StopTest" alt="" /> + +
@@ -85,11 +97,15 @@ import { airInletProportionalValve_getStateJSON, } from '@/mock/command' import { useSealStore, useTestStore, useWebSocketStore } from '@/store' +import { storeToRefs } from 'pinia' const sealStore = useSealStore() const testStore = useTestStore() const websocketStore = useWebSocketStore() +const { airInletProportionalInitVal, airOutletProportionalInitVal } = + storeToRefs(sealStore) + const sealCharts = ref(null) const sealOptions = ref({ series: [ @@ -222,7 +238,10 @@ const wait = async ms => { await new Promise(resolve => setTimeout(resolve, ms)) } -const newStartTest = flag => { +const sleepVal1 = ref(1000) +const sleepVal2 = ref(5000) + +const newStartTest = async flag => { if (flag == 1) { // 开始测试 // 启动计时器 @@ -239,7 +258,7 @@ const newStartTest = flag => { // 空压机打开 websocketStore.sendCommandMsg(airCompressor_setStateJSON([1])) // 等待1s - wait(1000) + await wait(sleepVal1.value) // 空压机关闭 websocketStore.sendCommandMsg(airCompressor_setStateJSON([0])) // 空压机电子阀1关闭 空压机电子阀2关闭 @@ -248,7 +267,7 @@ const newStartTest = flag => { // 空压机选通阀切换到通道1 (入气口) websocketStore.sendCommandMsg(airCompressorChannelSelectJSON([1])) // 等待5s - wait(5000) + await wait(sleepVal2.value) // 记录当前压力数值作为初始压力值 websocketStore.sendCommandMsg(airCompressorGetPressureDirectJSON) } @@ -267,12 +286,12 @@ const newStartTest = flag => { // 数值为刚开始记录的数值 websocketStore.sendCommandMsg( AirInletProportionalValve_setStateJSON([ - sealStore.airInletProportionalInitVal, + airInletProportionalInitVal.value[0], ]), ) websocketStore.sendCommandMsg( AirOutletProportionalValve_setStateJSON([ - sealStore.airOutletProportionalInitVal, + airOutletProportionalInitVal.value[0], ]), ) // 停止计时器 diff --git a/src/components/Test.vue b/src/components/Test.vue index 6fe9e6e..819f425 100644 --- a/src/components/Test.vue +++ b/src/components/Test.vue @@ -194,31 +194,44 @@
- 打开 + 空气
- 关闭 + 内管道
-
-

水浸

-

{{ testStore.waterImmersionSensor1 ? '有水' : '没水' }}

-
- 更新读取水浸状态 +
+
+ 水浸 +

+ {{ testStore.waterImmersionSensor1 ? '有水' : '没水' }} +

+
+ +
+ 液位 +

+ {{ + deviceStore.disinfectantCapacity <= 0 + ? 0 + : deviceStore.disinfectantCapacity + }} + g +

@@ -235,38 +248,60 @@ 压力4 {{ sealStore.allPressure[3] }}

-
-

液位

-

- {{ - deviceStore.disinfectantCapacity <= 0 - ? 0 - : deviceStore.disinfectantCapacity - }} - g -

-
- 更新读取液位状态 -
-

仓内

温度 {{ deviceStore.binTemperature }} ℃

湿度 {{ deviceStore.binHumidity }} ℃

过氧化氢浓度 {{ deviceStore.binHP }} PPM

- { return value } +const changeAirValve1 = flag => { + if (flag == '1') { + // 打开 + websocketStore.sendCommandMsg(airCompressorSetValve1JSON([1])) + sealStore.updateAirCompressorValve1(1) + } + if (flag == '2') { + // 关闭 + websocketStore.sendCommandMsg(airCompressorSetValve1JSON([0])) + sealStore.updateAirCompressorValve1(0) + } +} + +const changeAirValve2 = flag => { + if (flag == '1') { + // 打开 + websocketStore.sendCommandMsg(airCompressorSetValve2JSON([1])) + sealStore.updateAirCompressorValve2(1) + } + if (flag == '2') { + // 关闭 + websocketStore.sendCommandMsg(airCompressorSetValve2JSON([0])) + sealStore.updateAirCompressorValve2(0) + } +} + const isFirstClick = ref(true) const hideAllKeyboards = flag => { isFirstClick.value = true @@ -551,11 +615,11 @@ const changeDraughtStatus = flag => { const changeChannel = flag => { if (flag == 1) { - websocketStore.sendCommandMsg(airCompressor_channelCtrlJSON([1])) - testStore.updateAirCompressorChannel(true) + websocketStore.sendCommandMsg(airCompressorChannelSelectJSON([2])) + sealStore.updateAirCompressorChannelSelectVal(2) } else { - websocketStore.sendCommandMsg(airCompressor_channelCtrlJSON([0])) - testStore.updateAirCompressorChannel(false) + websocketStore.sendCommandMsg(airCompressorChannelSelectJSON([1])) + sealStore.updateAirCompressorChannelSelectVal(1) } } diff --git a/src/store/modules/seal.js b/src/store/modules/seal.js index 989e4c9..9797513 100644 --- a/src/store/modules/seal.js +++ b/src/store/modules/seal.js @@ -14,10 +14,22 @@ export const useSealStore = defineStore({ airInletProportionalInitVal: 0, airOutletProportionalInitVal: 0, allPressure: [0, 0, 0, 0], + airCompressorValve1: 0, + airCompressorValve2: 0, + airCompressorChannelSelectVal: 1, } }, // actions actions: { + updateAirCompressorChannelSelectVal(airCompressorChannelSelectVal) { + this.airCompressorChannelSelectVal = airCompressorChannelSelectVal + }, + updateAirCompressorValve1(airCompressorValve1) { + this.airCompressorValve1 = airCompressorValve1 + }, + updateAirCompressorValve2(airCompressorValve2) { + this.airCompressorValve2 = airCompressorValve2 + }, updateAllPressure(allPressure) { this.allPressure = allPressure }, @@ -47,7 +59,9 @@ export const useSealStore = defineStore({ differenceValue(state) { if (state.isStartTest) { if (state.oldAirPressure != null && state.currentAirPressure != null) { - return Math.abs(state.oldAirPressure - state.currentAirPressure) + return Math.abs( + state.oldAirPressure - state.currentAirPressure, + ).toFixed(1) } } return null diff --git a/src/store/modules/websocket.js b/src/store/modules/websocket.js index 1edbd06..5e26df2 100644 --- a/src/store/modules/websocket.js +++ b/src/store/modules/websocket.js @@ -189,7 +189,8 @@ export const useWebSocketStore = defineStore({ ) if (getPressureCode == 0) { // 值初始化 - sealStore.updateOldAirPressure(pressureAck || 0) + console.log('pressureAck', pressureAck) + sealStore.updateOldAirPressure(pressureAck[0].toFixed(1) || 0) } break case 'chpasswd':