Browse Source

初始化

master
maochaoying 2 years ago
parent
commit
87fc6daef6
  1. 50
      src/components/info/AirSwitchConfig.vue
  2. 16
      src/store/modules/websocket.js

50
src/components/info/AirSwitchConfig.vue

@ -73,7 +73,7 @@ import {
airInletProportionalValve_getStateJSON, airInletProportionalValve_getStateJSON,
AirOutletProportionalValve_getStateJSON, AirOutletProportionalValve_getStateJSON,
} from '@/mock/command' } from '@/mock/command'
import { ref, onMounted } from 'vue'
import { ref, onMounted, watch } from 'vue'
const activeTab = ref('1') const activeTab = ref('1')
const sealStore = useSealStore() const sealStore = useSealStore()
@ -87,39 +87,59 @@ const bottomText = ref('0%')
const topChange = ({ selectedOptions, selectedValues }) => { const topChange = ({ selectedOptions, selectedValues }) => {
topText.value = selectedOptions[0].text topText.value = selectedOptions[0].text
webSocketStore.sendCommandMsg( webSocketStore.sendCommandMsg(
AirInletProportionalValve_setStateJSON([parseInt(selectedValues[0]) * 10]),
AirInletProportionalValve_setStateJSON([parseInt(selectedValues[0])]),
) )
sealStore.updateAirInletProportionalValue(parseInt(selectedValues[0]) * 10)
sealStore.updateAirInletProportionalValue(parseInt(selectedValues[0]))
} }
const bottomChange = ({ selectedOptions, selectedValues }) => { const bottomChange = ({ selectedOptions, selectedValues }) => {
bottomText.value = selectedOptions[0].text bottomText.value = selectedOptions[0].text
webSocketStore.sendCommandMsg( webSocketStore.sendCommandMsg(
AirOutletProportionalValve_setStateJSON([parseInt(selectedValues[0]) * 10]),
AirOutletProportionalValve_setStateJSON([parseInt(selectedValues[0])]),
) )
sealStore.updateAirOutletProportionalValue(parseInt(selectedValues[0]) * 10)
sealStore.updateAirOutletProportionalValue(parseInt(selectedValues[0]))
} }
const columns = ref([ const columns = ref([
{ text: '0%', value: '0' }, { text: '0%', value: '0' },
{ text: '10%', value: '1' },
{ text: '20%', value: '2' },
{ text: '30%', value: '3' },
{ text: '40%', value: '4' },
{ text: '50%', value: '5' },
{ text: '60%', value: '6' },
{ text: '70%', value: '7' },
{ text: '80%', value: '8' },
{ text: '90%', value: '9' },
{ text: '100%', value: '10' },
{ text: '10%', value: '10' },
{ text: '20%', value: '20' },
{ text: '30%', value: '30' },
{ text: '40%', value: '40' },
{ text: '50%', value: '50' },
{ text: '60%', value: '60' },
{ text: '70%', value: '70' },
{ text: '80%', value: '80' },
{ text: '90%', value: '90' },
{ text: '100%', value: '100' },
]) ])
const selectedValuesTop = ref(['0']) const selectedValuesTop = ref(['0'])
const selectedValuesBottom = ref(['0']) const selectedValuesBottom = ref(['0'])
onMounted(() => { onMounted(() => {
setTimeout(() => {
webSocketStore.sendCommandMsg(airInletProportionalValve_getStateJSON) webSocketStore.sendCommandMsg(airInletProportionalValve_getStateJSON)
webSocketStore.sendCommandMsg(AirOutletProportionalValve_getStateJSON) webSocketStore.sendCommandMsg(AirOutletProportionalValve_getStateJSON)
}, 1000)
}) })
watch(
() => sealStore.airInletProportionalInitVal,
(newVal, oldVal) => {
console.log('airInletProportionalInitVal', newVal)
selectedValuesTop.value = [newVal + '']
topText.value = `${newVal}%`
},
)
watch(
() => sealStore.airOutletProportionalInitVal,
(newVal, oldVal) => {
console.log('airOutletProportionalInitVal', newVal)
selectedValuesBottom.value = [newVal + '']
bottomText.value = `${newVal}%`
},
)
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

16
src/store/modules/websocket.js

@ -94,9 +94,7 @@ export const useWebSocketStore = defineStore({
AirOutletProportionalValve, AirOutletProportionalValve,
} = sensor_data } = sensor_data
const { channelState } = airCompressor || {} const { channelState } = airCompressor || {}
testStore.updateAirCompressorChannel(
channelState == 0 ? false : true,
)
testStore.updateAirCompressorChannel(channelState)
const { nowlog, targetlog } = disinfectionState || {} const { nowlog, targetlog } = disinfectionState || {}
deviceStore.updateTargetLog(targetlog) deviceStore.updateTargetLog(targetlog)
// 必须开始的时候才改变log 否则不懂 // 必须开始的时候才改变log 否则不懂
@ -175,8 +173,20 @@ export const useWebSocketStore = defineStore({
userStore.updateUserList(dbval) userStore.updateUserList(dbval)
break break
case 'AirInletProportionalValve_getState': case 'AirInletProportionalValve_getState':
const { ackcode: inletValAckCode, ack: inAck } = JSON.parse(ev.data)
if (inletValAckCode == 0) {
// 值初始化
sealStore.updateAirInletProportionalInitVal(inAck || 0)
}
break break
case 'airOutletProportionalValve_getState': case 'airOutletProportionalValve_getState':
const { ackcode: outletValAckCode, ack: outAck } = JSON.parse(
ev.data,
)
if (outletValAckCode == 0) {
// 值初始化
sealStore.updateAirOutletProportionalInitVal(outAck || 0)
}
break break
case 'chpasswd': case 'chpasswd':
const { ackcode: chpasswdCode } = JSON.parse(ev.data) const { ackcode: chpasswdCode } = JSON.parse(ev.data)

Loading…
Cancel
Save