forked from gzt/A8000
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.2 KiB
56 lines
1.2 KiB
import { defineStore } from 'pinia'
|
|
import { ref } from 'vue'
|
|
import * as R from 'ramda'
|
|
|
|
import type {
|
|
DeviceWorkStateMessage,
|
|
FooterMessageState,
|
|
SensorStateMessage,
|
|
} from '../../websocket/socket'
|
|
|
|
export const useDeviceStore = defineStore('device', () => {
|
|
const deviceState = ref<DeviceWorkStateMessage['data']>({
|
|
workState: 'IDLE',
|
|
pending: false,
|
|
} as DeviceWorkStateMessage['data'])
|
|
|
|
function setDeviceState(data: DeviceWorkStateMessage['data']) {
|
|
if (!R.equals(data, deviceState.value)) {
|
|
deviceState.value = data
|
|
}
|
|
}
|
|
|
|
const sensorState = ref<SensorStateMessage['data']>({
|
|
pboxTemperature: 20,
|
|
incubateBoxTemperature: 20,
|
|
wasteBinFullFlag: false,
|
|
})
|
|
const setSensorState = (data: SensorStateMessage['data']) => {
|
|
if (!R.equals(data, sensorState.value)) {
|
|
sensorState.value = data
|
|
}
|
|
}
|
|
|
|
const messageState = ref<FooterMessageState['data']>({
|
|
topMessage: {
|
|
time: 0,
|
|
messageLevel: 'Info',
|
|
message: '空闲',
|
|
},
|
|
messageBoxList: [],
|
|
})
|
|
const setMessageState = (data: FooterMessageState['data']) => {
|
|
messageState.value = data
|
|
}
|
|
|
|
return {
|
|
deviceState,
|
|
setDeviceState,
|
|
|
|
sensorState,
|
|
setSensorState,
|
|
|
|
messageState,
|
|
setMessageState,
|
|
}
|
|
})
|