Browse Source

实时获取

master
maochaoying 2 years ago
parent
commit
702fc77644
  1. 8
      src/components/SealTest.vue
  2. 5
      src/mock/command.js
  3. 13
      src/store/modules/websocket.js

8
src/components/SealTest.vue

@ -86,6 +86,7 @@ import StopTest from '@/assets/img/seal/stoptest.png'
import { import {
someAirSwitchJSON, someAirSwitchJSON,
airCompressor_setStateJSON, airCompressor_setStateJSON,
airCompressorGetPressureDirectIntervalJSON,
airCompressor_channelCtrlJSON, airCompressor_channelCtrlJSON,
AirInletProportionalValve_setStateJSON, AirInletProportionalValve_setStateJSON,
AirOutletProportionalValve_setStateJSON, AirOutletProportionalValve_setStateJSON,
@ -300,9 +301,9 @@ const newStartTest = async flag => {
} }
const timer = ref(null) const timer = ref(null)
const timerData = ref(null)
onBeforeUnmount(() => { onBeforeUnmount(() => {
timer.value = null
timerStart.value = null
clearInterval(timerData.value)
clearInterval(timer.value) clearInterval(timer.value)
clearInterval(timerStart.value) clearInterval(timerStart.value)
}) })
@ -379,6 +380,9 @@ onMounted(() => {
}, 1000) }, 1000)
websocketStore.sendCommandMsg(airInletProportionalValve_getStateJSON) websocketStore.sendCommandMsg(airInletProportionalValve_getStateJSON)
websocketStore.sendCommandMsg(AirOutletProportionalValve_getStateJSON) websocketStore.sendCommandMsg(AirOutletProportionalValve_getStateJSON)
timerData.value = setInterval(() => {
websocketStore.sendCommandMsg(airCompressorGetPressureDirectIntervalJSON)
}, 100)
}) })
</script> </script>

5
src/mock/command.js

@ -409,3 +409,8 @@ export const airCompressorGetPressureDirectJSON = {
command: 'DeviceIOControlService.airCompressor_getPressureDirect', command: 'DeviceIOControlService.airCompressor_getPressureDirect',
messageId: 'airCompressor_getPressureDirect', messageId: 'airCompressor_getPressureDirect',
} }
export const airCompressorGetPressureDirectIntervalJSON = {
command: 'DeviceIOControlService.airCompressor_getPressureDirect',
messageId: 'airCompressor_getPressureDirect_interval',
}

13
src/store/modules/websocket.js

@ -108,7 +108,6 @@ export const useWebSocketStore = defineStore({
operatorStore.updateStopReady(false) operatorStore.updateStopReady(false)
} }
sealStore.updateAllPressure(pressure) sealStore.updateAllPressure(pressure)
sealStore.updateCurrentAirPressure(pressure[1])
settingStore.updateSprinklerPumpGPM(sprinklerPumpGPM) settingStore.updateSprinklerPumpGPM(sprinklerPumpGPM)
settingStore.updateChargingPumpRPM(chargingPumpRPM) settingStore.updateChargingPumpRPM(chargingPumpRPM)
settingStore.updateSprinklerPumpRPM(sprinklerPumpRPM) settingStore.updateSprinklerPumpRPM(sprinklerPumpRPM)
@ -189,10 +188,20 @@ export const useWebSocketStore = defineStore({
) )
if (getPressureCode == 0) { if (getPressureCode == 0) {
// 值初始化 // 值初始化
console.log('pressureAck', pressureAck)
console.log('pressureAck[0]', pressureAck[0].toFixed(1))
sealStore.updateOldAirPressure(pressureAck[0].toFixed(1) || 0) sealStore.updateOldAirPressure(pressureAck[0].toFixed(1) || 0)
} }
break break
case 'airCompressor_getPressureDirect_interval':
const { ackcode: getPressureInterCode, ack: pressureIntervalAck } =
JSON.parse(ev.data)
if (getPressureInterCode == 0) {
// 值初始化
sealStore.updateCurrentAirPressure(
pressureIntervalAck[0].toFixed(1) || 0,
)
}
break
case 'chpasswd': case 'chpasswd':
const { ackcode: chpasswdCode } = JSON.parse(ev.data) const { ackcode: chpasswdCode } = JSON.parse(ev.data)
if (chpasswdCode != 0) { if (chpasswdCode != 0) {

Loading…
Cancel
Save