up
chenyc
2022-09-06 0db357a9c5f73f2fc65dee021e52070e3b36d25c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { defineStore } from 'pinia'
import { ref } from 'vue'
import { Session } from '@/utils/storage'
import { boolean, string } from 'yargs'
interface info {
    type:string;
    deviceName:string;
    result:string;
    resultTime:string;
    state:number;
}
 
let weightInfo:info={
    type:"体重秤",
    state:2,
    deviceName:"",
    result:"0",
    resultTime:""
let xyjInfo:info={
    type:"血压计",
    state:2,
    deviceName:"",
    result:"",
    resultTime:""
let dkqInfo:info={
    type:"读卡器",
    state:2,
    deviceName:"",
    result:"",
    resultTime:""
}
export const sockteStore =defineStore('sockteInfo',()=>{
    const isLink=ref(true) // sockte 链接状态
    const netLink=ref(true) // 网络链接状态
    const pcName=ref('')
    const weightSockte=ref(weightInfo) // 体重秤sockte结果
    const xyjSockte=ref(xyjInfo) // 血压计sockte结果
    const dkqSockte=ref(dkqInfo) // 读卡器sockte结果
    // 更新连接状态
    function setsockteIsLink(Link:boolean){
        isLink.value=Link
    }
    // 更新网络连接状态
    function setnetLink(Link:boolean){
        netLink.value=Link
    }
    /**
     * 更新体重秤结果
     * @param info 体重结果
     */
    function setweightSockte(info:info){
        weightSockte.value.deviceName=info.deviceName
        weightSockte.value.result=info.result
        weightSockte.value.resultTime=info.resultTime
        weightSockte.value.state=info.state
        console.debug('体重秤更新')
    }
     /**
     * 更新体重秤工作状态
     * @param state 体重秤运行状态
     */
      function setweightState(state:any){
        weightSockte.value.state=state
    }
      /**
     * 更新血压计结果
     * @param info 体重结果
     */
    function setxyjSockte(info:info){
        xyjSockte.value.deviceName=info.deviceName
        xyjSockte.value.result=info.result
        xyjSockte.value.resultTime=info.resultTime
        weightSockte.value.state=info.state
    }
    function setXtjState(state:any){
        xyjSockte.value.state=state
    }
      /**
     * 更新读卡器结果
     * @param info 读卡器结果
     */
    function setdkqSockte(info:info){
        dkqSockte.value.deviceName=info.deviceName
        dkqSockte.value.result=info.result
        dkqSockte.value.resultTime=info.resultTime
    }
    function setPcName(name:any){
        pcName.value=name
    }
 
    return {isLink,netLink,weightSockte,xyjSockte,dkqSockte,pcName,setsockteIsLink,setnetLink,setweightSockte,
        setweightState,setPcName,setXtjState,
        setxyjSockte,setdkqSockte}
})