chenyc
2024-09-04 0f38c5e72493ee138a68ddc0bd838f1aa314f4b4
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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:""
}
let faceInfo:info={
    type:"人脸识别",
    state:2,
    deviceName:"",
    result:"",
    resultTime:""
}
export const sockteStore =defineStore('sockteInfo',()=>{
    const isLink=ref(false) // sockte 链接状态
    const netLink=ref(true) // 网络链接状态
    const pcName=ref('')
   
  
     /**
      * 默认true,  判断是否有体重归零状态
      */
     const is测量准备=ref(true)
 
    
 
    // 温度
    const wendu=ref(0)
    const weightSockte=ref(weightInfo) // 体重秤sockte结果
    const xyjSockte=ref(xyjInfo) // 血压计sockte结果
    const dkqSockte=ref(dkqInfo) // 读卡器sockte结果
    const faceInfoSockte=ref(faceInfo)
    // 更新温度
    function setWendu(wen_du:number){
        wendu.value=wen_du
    }
    // 更新连接状态
    function setsockteIsLink(Link:boolean){
        isLink.value=Link
    }
    // 更新网络连接状态
    function setnetLink(Link:boolean){
        netLink.value=Link
    }
    /**
     * 更新体重秤结果
     * @param infoObj 体重结果
     */
    function setweightSockte(infoObj:info){
        if(Number(infoObj.result)>10||Number(infoObj.result)===0){
            weightSockte.value.deviceName=infoObj.deviceName
            weightSockte.value.result=infoObj.result
            weightSockte.value.resultTime=infoObj.resultTime
            weightSockte.value.state=infoObj.state
        }else{
            console.log('体重不足10kg')
        }
       
    }
     /**
     * 更新体重秤工作状态
     * @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
    }
    /**
     * 更新人脸识别
     * @param info 
     */
    function setfaceSockte(info:info){
        faceInfoSockte.value.deviceName=info.deviceName
        faceInfoSockte.value.result=info.result
        faceInfoSockte.value.resultTime=info.resultTime
 
    }
    function setPcName(name:any){
        pcName.value=name
    }
    /**
     * 更新体重准备
     */
    function setis测量准备(value:boolean){
        is测量准备.value=value
    }
 
    return {isLink,netLink,weightSockte,xyjSockte,dkqSockte,wendu,faceInfoSockte,pcName,is测量准备,setsockteIsLink,setnetLink,setweightSockte,
        setweightState,setPcName,setXtjState,setfaceSockte,setWendu,
        setxyjSockte,setdkqSockte,setis测量准备}
})