Browse Source

新接口

master
maochaoying 2 years ago
parent
commit
b42da8415e
  1. 8
      .env
  2. 29
      src/components/SealTest.vue
  3. 140
      src/components/Test.vue
  4. 16
      src/store/modules/seal.js
  5. 3
      src/store/modules/websocket.js

8
.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/
# VITE_BASE_WS1_URL=ws://127.0.0.1:19001/
# VITE_BASE_WS2_URL=ws://127.0.0.1:19002/

29
src/components/SealTest.vue

@ -32,6 +32,18 @@
:src="StopTest" :src="StopTest"
alt="" alt=""
/> />
<input
type="number"
placeholder="第一次"
v-model="sleepVal1"
style="width: 100px"
/>
<input
type="number"
placeholder="第二次"
v-model="sleepVal2"
style="width: 100px"
/>
</div> </div>
</div> </div>
<div class="right_container"> <div class="right_container">
@ -85,11 +97,15 @@ import {
airInletProportionalValve_getStateJSON, airInletProportionalValve_getStateJSON,
} from '@/mock/command' } from '@/mock/command'
import { useSealStore, useTestStore, useWebSocketStore } from '@/store' import { useSealStore, useTestStore, useWebSocketStore } from '@/store'
import { storeToRefs } from 'pinia'
const sealStore = useSealStore() const sealStore = useSealStore()
const testStore = useTestStore() const testStore = useTestStore()
const websocketStore = useWebSocketStore() const websocketStore = useWebSocketStore()
const { airInletProportionalInitVal, airOutletProportionalInitVal } =
storeToRefs(sealStore)
const sealCharts = ref(null) const sealCharts = ref(null)
const sealOptions = ref({ const sealOptions = ref({
series: [ series: [
@ -222,7 +238,10 @@ const wait = async ms => {
await new Promise(resolve => setTimeout(resolve, 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) { if (flag == 1) {
// //
// //
@ -239,7 +258,7 @@ const newStartTest = flag => {
// //
websocketStore.sendCommandMsg(airCompressor_setStateJSON([1])) websocketStore.sendCommandMsg(airCompressor_setStateJSON([1]))
// 1s // 1s
wait(1000)
await wait(sleepVal1.value)
// //
websocketStore.sendCommandMsg(airCompressor_setStateJSON([0])) websocketStore.sendCommandMsg(airCompressor_setStateJSON([0]))
// 1 2 // 1 2
@ -248,7 +267,7 @@ const newStartTest = flag => {
// 1 // 1
websocketStore.sendCommandMsg(airCompressorChannelSelectJSON([1])) websocketStore.sendCommandMsg(airCompressorChannelSelectJSON([1]))
// 5s // 5s
wait(5000)
await wait(sleepVal2.value)
// //
websocketStore.sendCommandMsg(airCompressorGetPressureDirectJSON) websocketStore.sendCommandMsg(airCompressorGetPressureDirectJSON)
} }
@ -267,12 +286,12 @@ const newStartTest = flag => {
// //
websocketStore.sendCommandMsg( websocketStore.sendCommandMsg(
AirInletProportionalValve_setStateJSON([ AirInletProportionalValve_setStateJSON([
sealStore.airInletProportionalInitVal,
airInletProportionalInitVal.value[0],
]), ]),
) )
websocketStore.sendCommandMsg( websocketStore.sendCommandMsg(
AirOutletProportionalValve_setStateJSON([ AirOutletProportionalValve_setStateJSON([
sealStore.airOutletProportionalInitVal,
airOutletProportionalInitVal.value[0],
]), ]),
) )
// //

140
src/components/Test.vue

@ -194,31 +194,44 @@
<div class="btn_wrap"> <div class="btn_wrap">
<div <div
:class=" :class="
testStore.airCompressorChannel
sealStore.airCompressorChannelSelectVal == '2'
? 'open style-btn mg' ? 'open style-btn mg'
: 'close style-btn mg' : 'close style-btn mg'
" "
@click="changeChannel(1)" @click="changeChannel(1)"
> >
打开
空气
</div> </div>
<div <div
:class=" :class="
!testStore.airCompressorChannel
sealStore.airCompressorChannelSelectVal == '1'
? 'open style-btn' ? 'open style-btn'
: 'close style-btn' : 'close style-btn'
" "
@click="changeChannel(2)" @click="changeChannel(2)"
> >
关闭
内管道
</div> </div>
</div> </div>
</div> </div>
<div class="common_set update_wrap">
<p class="title">水浸</p>
<p class="num">{{ testStore.waterImmersionSensor1 ? '有水' : '没水' }}</p>
<div class="btn_wrap style-btn" @click="handleUpdate" style="opacity: 0">
更新读取水浸状态
<div class="common_set update_wrap pressure">
<div class="title">
水浸
<p class="num">
{{ testStore.waterImmersionSensor1 ? '有水' : '没水' }}
</p>
</div>
<div class="title">
液位
<p class="num">
{{
deviceStore.disinfectantCapacity <= 0
? 0
: deviceStore.disinfectantCapacity
}}
g
</p>
</div> </div>
</div> </div>
<div class="common_set update_wrap pressure"> <div class="common_set update_wrap pressure">
@ -235,38 +248,60 @@
压力4 <span>{{ sealStore.allPressure[3] }}</span> 压力4 <span>{{ sealStore.allPressure[3] }}</span>
</p> </p>
</div> </div>
<div class="common_set update_wrap">
<p class="title">液位</p>
<p class="num">
{{
deviceStore.disinfectantCapacity <= 0
? 0
: deviceStore.disinfectantCapacity
}}
g
</p>
<div class="btn_wrap style-btn" @click="handleUpdate" style="opacity: 0">
更新读取液位状态
</div>
</div>
<div class="common_set info_wrap"> <div class="common_set info_wrap">
<p class="title">仓内</p> <p class="title">仓内</p>
<p class="info">温度 {{ deviceStore.binTemperature }} </p> <p class="info">温度 {{ deviceStore.binTemperature }} </p>
<p class="info">湿度 {{ deviceStore.binHumidity }} </p> <p class="info">湿度 {{ deviceStore.binHumidity }} </p>
<p class="info">过氧化氢浓度 {{ deviceStore.binHP }} PPM</p> <p class="info">过氧化氢浓度 {{ deviceStore.binHP }} PPM</p>
</div> </div>
<!-- <div class="common_set info_wrap">
<p class="title">环境1</p>
<p class="info">温度 {{ deviceStore.envirTemperature1 }} </p>
<p class="info">湿度 {{ deviceStore.envirHumidity1 }} </p>
<p class="info">过氧化氢浓度 {{ deviceStore.envirHP1 }} PPM</p>
<div class="common_set switch_wrap">
<p class="title">空压机阀1</p>
<div class="btn_wrap">
<div
:class="
sealStore.airCompressorValve1 == '1'
? 'open style-btn mg'
: 'close style-btn mg'
"
@click="changeAirValve1(1)"
>
打开
</div>
<div
:class="
sealStore.airCompressorValve1 == '0'
? 'open style-btn'
: 'close style-btn'
"
@click="changeAirValve1(2)"
>
关闭
</div>
</div>
<p class="title">空压机阀2</p>
<div class="btn_wrap">
<div
:class="
sealStore.airCompressorValve2 == '1'
? 'open style-btn mg'
: 'close style-btn mg'
"
@click="changeAirValve2(1)"
>
打开
</div>
<div
:class="
sealStore.airCompressorValve2 == '0'
? 'open style-btn'
: 'close style-btn'
"
@click="changeAirValve2(2)"
>
关闭
</div>
</div>
</div> </div>
<div class="common_set info_wrap">
<p class="title">环境2</p>
<p class="info">温度 {{ deviceStore.envirTemperature2 }} </p>
<p class="info">湿度 {{ deviceStore.envirHumidity2 }} </p>
<p class="info">过氧化氢浓度 {{ deviceStore.envirHP2 }} PPM</p>
</div> -->
<van-number-keyboard <van-number-keyboard
v-model="addLiquidVal" v-model="addLiquidVal"
@input="val => handleInput(val, 1)" @input="val => handleInput(val, 1)"
@ -306,9 +341,12 @@ import {
import { import {
someAirSwitchJSON, someAirSwitchJSON,
liquidpumpctrlJSON, liquidpumpctrlJSON,
airCompressorChannelSelectJSON,
airCompressor_channelCtrlJSON, airCompressor_channelCtrlJSON,
getStateJSON, getStateJSON,
addLiquidCtrlJSON, addLiquidCtrlJSON,
airCompressorSetValve1JSON,
airCompressorSetValve2JSON,
test_replenishingFluidsPumpCtrJSON, test_replenishingFluidsPumpCtrJSON,
sprayLiquidPump_open_for_testJSON, sprayLiquidPump_open_for_testJSON,
} from '@/mock/command' } from '@/mock/command'
@ -372,6 +410,32 @@ const formatter7 = value => {
return value 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 isFirstClick = ref(true)
const hideAllKeyboards = flag => { const hideAllKeyboards = flag => {
isFirstClick.value = true isFirstClick.value = true
@ -551,11 +615,11 @@ const changeDraughtStatus = flag => {
const changeChannel = flag => { const changeChannel = flag => {
if (flag == 1) { if (flag == 1) {
websocketStore.sendCommandMsg(airCompressor_channelCtrlJSON([1]))
testStore.updateAirCompressorChannel(true)
websocketStore.sendCommandMsg(airCompressorChannelSelectJSON([2]))
sealStore.updateAirCompressorChannelSelectVal(2)
} else { } else {
websocketStore.sendCommandMsg(airCompressor_channelCtrlJSON([0]))
testStore.updateAirCompressorChannel(false)
websocketStore.sendCommandMsg(airCompressorChannelSelectJSON([1]))
sealStore.updateAirCompressorChannelSelectVal(1)
} }
} }
</script> </script>

16
src/store/modules/seal.js

@ -14,10 +14,22 @@ export const useSealStore = defineStore({
airInletProportionalInitVal: 0, airInletProportionalInitVal: 0,
airOutletProportionalInitVal: 0, airOutletProportionalInitVal: 0,
allPressure: [0, 0, 0, 0], allPressure: [0, 0, 0, 0],
airCompressorValve1: 0,
airCompressorValve2: 0,
airCompressorChannelSelectVal: 1,
} }
}, },
// actions // actions
actions: { actions: {
updateAirCompressorChannelSelectVal(airCompressorChannelSelectVal) {
this.airCompressorChannelSelectVal = airCompressorChannelSelectVal
},
updateAirCompressorValve1(airCompressorValve1) {
this.airCompressorValve1 = airCompressorValve1
},
updateAirCompressorValve2(airCompressorValve2) {
this.airCompressorValve2 = airCompressorValve2
},
updateAllPressure(allPressure) { updateAllPressure(allPressure) {
this.allPressure = allPressure this.allPressure = allPressure
}, },
@ -47,7 +59,9 @@ export const useSealStore = defineStore({
differenceValue(state) { differenceValue(state) {
if (state.isStartTest) { if (state.isStartTest) {
if (state.oldAirPressure != null && state.currentAirPressure != null) { 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 return null

3
src/store/modules/websocket.js

@ -189,7 +189,8 @@ export const useWebSocketStore = defineStore({
) )
if (getPressureCode == 0) { if (getPressureCode == 0) {
// 值初始化 // 值初始化
sealStore.updateOldAirPressure(pressureAck || 0)
console.log('pressureAck', pressureAck)
sealStore.updateOldAirPressure(pressureAck[0].toFixed(1) || 0)
} }
break break
case 'chpasswd': case 'chpasswd':

Loading…
Cancel
Save