Browse Source

test

master
maochaoying 2 years ago
parent
commit
4b9e54ed09
  1. 69
      src/components/Test.vue
  2. 16
      src/mock/command.js
  3. 45
      src/store/modules/test.js
  4. 53
      src/store/modules/websocket.js

69
src/components/Test.vue

@ -2,7 +2,7 @@
<div class="test_container">
<div class="common_set switch_wrap">
<p class="title">加液蠕动泵</p>
<p class="num">000 RPM</p>
<p class="num">{{ Math.abs(testStore.chargingPump) }} RPM</p>
<div class="btn_wrap">
<div
:class="testStore.feedingPeristalticPumpStatus ? 'close' : 'open'"
@ -20,7 +20,7 @@
</div>
<div class="common_set switch_wrap">
<p class="title">喷液蠕动泵</p>
<p class="num">000 RPM</p>
<p class="num">{{ testStore.sprinklerPump }} RPM</p>
<div class="btn_wrap">
<div
:class="testStore.sprayPeristalticPump ? 'close' : 'open'"
@ -38,7 +38,7 @@
</div>
<div class="common_set switch_wrap">
<p class="title">空压机</p>
<p class="num">000 A</p>
<p class="num">{{ testStore?.airCompressorObj?.currentVal }} A</p>
<div class="btn_wrap">
<div
:class="testStore.airCompressor ? 'close' : 'open'"
@ -56,7 +56,7 @@
</div>
<div class="common_set switch_wrap">
<p class="title">风机</p>
<p class="num">000 RPM</p>
<p class="num">{{ testStore?.airBlowerObj?.currentVal }} RPM</p>
<div class="btn_wrap">
<div
:class="testStore.draughtFan ? 'close' : 'open'"
@ -72,6 +72,24 @@
</div>
</div>
</div>
<div class="common_set switch_wrap">
<p class="title">加热片</p>
<p class="num">{{ testStore?.heatingStripObj?.currentVal }} </p>
<div class="btn_wrap">
<div
:class="testStore.heatingStrip ? 'close' : 'open'"
@click="changeHeatingStatus(1)"
>
打开
</div>
<div
:class="!testStore.heatingStrip ? 'close' : 'open'"
@click="changeHeatingStatus(2)"
>
关闭
</div>
</div>
</div>
<div class="common_set update_wrap">
<p class="title">水浸</p>
<p class="num">有水</p>
@ -105,18 +123,31 @@
<script setup>
import { ref } from 'vue'
import { useTestStore, useDeviceStore } from '@/store'
import {
useTestStore,
useDeviceStore,
useWebSocketStore,
useSettingStore,
} from '@/store'
import { someAirSwitchJSON, liquidpumpctrlJSON } from '@/mock/command'
const testStore = useTestStore()
const deviceStore = useDeviceStore()
const websocketStore = useWebSocketStore()
const settingStore = useSettingStore()
const changeFeedingStatus = flag => {
if (flag == 1) {
if (!testStore.feedingPeristalticPumpStatus) {
//
websocketStore.sendCommandMsg(
liquidpumpctrlJSON(1, settingStore.addLiquidConfigVal),
)
testStore.updateFeedingPeristalticPumpStatus(true)
}
} else {
if (testStore.feedingPeristalticPumpStatus) {
websocketStore.sendCommandMsg(liquidpumpctrlJSON(1, 0))
testStore.updateFeedingPeristalticPumpStatus(false)
}
}
@ -125,22 +156,46 @@ const changeFeedingStatus = flag => {
const changeSprayStatus = flag => {
if (flag == 1) {
if (!testStore.sprayPeristalticPump) {
websocketStore.sendCommandMsg(
liquidpumpctrlJSON(2, settingStore.sprayLiquidConfigVal),
)
testStore.updateSprayPeristalticPump(true)
}
} else {
if (testStore.sprayPeristalticPump) {
websocketStore.sendCommandMsg(liquidpumpctrlJSON(2, 0))
testStore.updateSprayPeristalticPump(false)
}
}
}
const changeHeatingStatus = flag => {
if (flag == 1) {
if (!testStore.heatingStrip) {
websocketStore.sendCommandMsg(someAirSwitchJSON(4, 1))
websocketStore.sendCommandMsg(someAirSwitchJSON(5, 1))
testStore.updateHeatingStrip(true)
}
} else {
if (testStore.heatingStrip) {
websocketStore.sendCommandMsg(someAirSwitchJSON(4, 0))
websocketStore.sendCommandMsg(someAirSwitchJSON(5, 0))
testStore.updateHeatingStrip(false)
}
}
}
const changeAirStatus = flag => {
if (flag == 1) {
if (!testStore.airCompressor) {
websocketStore.sendCommandMsg(someAirSwitchJSON(0, 1))
websocketStore.sendCommandMsg(someAirSwitchJSON(1, 1))
testStore.updateAirCompressor(true)
}
} else {
if (testStore.airCompressor) {
websocketStore.sendCommandMsg(someAirSwitchJSON(0, 0))
websocketStore.sendCommandMsg(someAirSwitchJSON(1, 0))
testStore.updateAirCompressor(false)
}
}
@ -149,10 +204,14 @@ const changeAirStatus = flag => {
const changeDraughtStatus = flag => {
if (flag == 1) {
if (!testStore.draughtFan) {
websocketStore.sendCommandMsg(someAirSwitchJSON(2, 1))
websocketStore.sendCommandMsg(someAirSwitchJSON(3, 1))
testStore.updateDraughtFan(true)
}
} else {
if (testStore.draughtFan) {
websocketStore.sendCommandMsg(someAirSwitchJSON(2, 0))
websocketStore.sendCommandMsg(someAirSwitchJSON(3, 0))
testStore.updateDraughtFan(false)
}
}

16
src/mock/command.js

@ -82,3 +82,19 @@ export const setSettingValJSON = (settingName, settingVal) => {
// RealtimeSensorDataReport
// 实时传感器信息上报
// 控制加液体泵转动 1 控制喷液体泵转动 2
export const liquidpumpctrlJSON = (num, speed) => {
return {
command: 'exceCanCmd',
cancmd: `pumpctrl_c1004 ${num} 300 ${speed}`, // 1 泵编号 300 是加速度, 1000是转速
}
}
// 空压机
export const someAirSwitchJSON = (num, flag) => {
return {
command: 'exceCanCmd',
cancmd: `writeio ${num} ${flag}`,
}
}

45
src/store/modules/test.js

@ -5,17 +5,60 @@ export const useTestStore = defineStore({
state: () => {
return {
// 加液蠕动泵开关
feedingPeristalticPumpStatus: true,
feedingPeristalticPumpStatus: false,
// 喷液蠕动泵开关
sprayPeristalticPump: false,
// 空压机开关
airCompressor: false,
// 风机开关
draughtFan: false,
// 加热
heatingStrip: false,
sprinklerPump: 0,
chargingPump: 0,
airCompressorObj: {},
airBlowerObj: {},
heatingStripObj: {},
}
},
// actions
actions: {
updateAirCompressorObj(airCompressorObj) {
const { io1, io2, currentVal } = airCompressorObj
if (io1 == 1 && io2 == 1) {
this.airCompressor = true
} else {
this.airCompressor = false
}
this.airCompressorObj = airCompressorObj
},
updateAirBlowerObj(airBlowerObj) {
const { io1, io2, currentVal } = airBlowerObj
if (io1 == 1 && io2 == 1) {
this.draughtFan = true
} else {
this.draughtFan = false
}
this.airBlowerObj = airBlowerObj
},
updateHeatingStripObj(heatingStripObj) {
const { io1, io2, currentVal } = heatingStripObj
if (io1 == 1 && io2 == 1) {
this.heatingStrip = true
} else {
this.heatingStrip = false
}
this.heatingStripObj = heatingStripObj
},
updateHeatingStrip(heatingStrip) {
this.heatingStrip = heatingStrip
},
updateSprinklerPump(sprinklerPump) {
this.sprinklerPump = sprinklerPump
},
updateChargingPump(chargingPump) {
this.chargingPump = chargingPump
},
updateFeedingPeristalticPumpStatus(status) {
this.feedingPeristalticPumpStatus = status
},

53
src/store/modules/websocket.js

@ -24,6 +24,8 @@ export const useWebSocketStore = defineStore({
const init = new Socket(url)
const settingStore = useSettingStore()
const userStore = useUserStore()
const testStore = useTestStore()
const deviceStore = useDeviceStore()
const operatorStore = useOperatorStore()
init.connect()
init.ws.onmessage = function (ev) {
@ -40,11 +42,49 @@ export const useWebSocketStore = defineStore({
estimatedRemainingTimeS,
disinfection_id,
isLogin,
permissionLevel,
sensor_data,
} = state || {}
if (!isLogin) {
window.location.href = '/login'
return
}
const {
h2o2_1,
h2o2_2,
h2o2_3,
humid_1,
humid_2,
humid_3,
temp_1,
temp_2,
temp_3,
airCompressor,
disinfectant_volume,
heatingStrip,
airBlower,
sprinklerPump,
chargingPump,
} = sensor_data
// 将sensor_data中的数据更新到store中
testStore.updateAirCompressorObj(airCompressor)
testStore.updateAirBlowerObj(airBlower)
testStore.updateHeatingStripObj(heatingStrip)
testStore.updateSprinklerPump(sprinklerPump)
testStore.updateChargingPump(chargingPump)
settingStore.updateDeviceIp('127.0.0.1')
deviceStore.updateDisinfectantCapacity(disinfectant_volume)
deviceStore.updateBinTemperature(temp_1)
deviceStore.updateBinHumidity(humid_1)
deviceStore.updateBinHP(h2o2_1)
deviceStore.updateEnvirTemperature1(temp_2)
deviceStore.updateEnvirHumidity1(humid_2)
deviceStore.updateEnvirHP1(h2o2_2)
deviceStore.updateEnvirTemperature2(temp_3)
deviceStore.updateEnvirHumidity2(humid_3)
deviceStore.updateEnvirHP2(h2o2_3)
userStore.updatePermission(permissionLevel)
settingStore.updateInitLoading()
operatorStore.updateDisinfectStatus(workState)
operatorStore.updateEstimatedRemainingTimeS(
@ -102,12 +142,19 @@ export const useWebSocketStore = defineStore({
temp_1,
temp_2,
temp_3,
air_compressor,
airCompressor,
disinfectant_volume,
heating_strip,
sprinkler_pump,
heatingStrip,
airBlower,
sprinklerPump,
chargingPump,
} = sensor_data
// 将sensor_data中的数据更新到store中
testStore.updateAirCompressorObj(airCompressor)
testStore.updateAirBlowerObj(airBlower)
testStore.updateHeatingStripObj(heatingStrip)
testStore.updateSprinklerPump(sprinklerPump)
testStore.updateChargingPump(chargingPump)
settingStore.updateDeviceIp('127.0.0.1')
deviceStore.updateDisinfectantCapacity(disinfectant_volume)
deviceStore.updateBinTemperature(temp_1)

Loading…
Cancel
Save