From 96882efacd0fd9ce750e1b226fe046b52cd36df0 Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期三, 26 七月 2023 20:24:32 +0800
Subject: [PATCH] 新增血压计HBP9020通讯

---
 src/views/home/index.vue                   |    5 ++
 src/stores/StoresConfing.ts                |    5 ++
 src/samples/deviceApi/oumulong-HBP-9030.ts |   55 +++++++++++++++++++++++++++
 3 files changed, 64 insertions(+), 1 deletions(-)

diff --git a/src/samples/deviceApi/oumulong-HBP-9030.ts b/src/samples/deviceApi/oumulong-HBP-9030.ts
new file mode 100644
index 0000000..05c711d
--- /dev/null
+++ b/src/samples/deviceApi/oumulong-HBP-9030.ts
@@ -0,0 +1,55 @@
+// 欧姆龙 HBP-9030 115200 
+import { ElMessage } from 'element-plus'
+const { SerialPort } = require('serialport')
+const { DelimiterParser } = require('@serialport/parser-delimiter')
+const { ByteLengthParser } = require('@serialport/parser-byte-length')
+import {sockteStore} from '@/stores/sockteInfo'
+
+
+const initPort=(path:String,baudRate:Number)=>{
+    console.log('初始化打开测温端口')
+    const serialport  = new SerialPort({ path, baudRate }, (err: any) => {
+        if (err) {
+            console.log(err)
+            ElMessage({
+                message: '端口打开失败!',
+                type: 'error',
+            })
+            console.log(err)
+        }else{
+            ElMessage({
+                message: '端口打开成功',
+                type: 'success',
+            })
+        } 
+    })
+    serialport.on("close",(err: any)=>{
+        console.log('端口异常端口链接断开')
+        console.log(err)
+    })
+    // 解析分割数据流
+    const parser = serialport.pipe(new ByteLengthParser({ length: 14*4-1 }))
+    parser.on('data', (value: string | any[])=>{
+        console.log(value.toString())
+        const str=value.toString()
+        const list=str.split(',')
+        console.log(list)
+        if(list.length===11){
+
+            sockteStore().setxyjSockte(
+              {
+                  deviceName:'HBP-9030',
+                  type:"血压计",
+                  result:list[7]+','+list[8]+','+list[9],
+                  resultTime:new Date().toString(),
+                  state:2
+              }
+          )
+        }
+        
+    })
+}
+
+export {
+    initPort,
+}
diff --git a/src/stores/StoresConfing.ts b/src/stores/StoresConfing.ts
index 8eeb2d1..4668ffd 100644
--- a/src/stores/StoresConfing.ts
+++ b/src/stores/StoresConfing.ts
@@ -12,7 +12,10 @@
         face_push:3,
         Is_ce_wen:false,
         portPath:'COM5',
-        baudRate:115200
+        baudRate:115200,
+        Is_xyj:false,
+        xueyanjiPortPath:"COM35",
+        xueyanjiBaudRate:115200
         
     })
     /**
diff --git a/src/views/home/index.vue b/src/views/home/index.vue
index 22fade6..5be345a 100644
--- a/src/views/home/index.vue
+++ b/src/views/home/index.vue
@@ -219,6 +219,7 @@
 import { confingInfoStore } from '@/stores/StoresConfing'
 import {base64toFile} from '@/samples/faceApi'
 import{initPort} from '@/samples/portApi'
+import{initPort as oumulongHbp9030 } from '@/samples/deviceApi/oumulong-HBP-9030'
 import { ElLoading, ElMessage } from 'element-plus'
 let trackerTask: any = null;
 // 标识用的画布
@@ -715,6 +716,10 @@
     if(is_ce_wen.value){
       initPort(configData.value.portPath,configData.value.baudRate)
     }
+    // 是否开启血压计联机
+    if(configData.value.Is_xyj){
+      oumulongHbp9030(configData.value.xueyanjiPortPath,configData.value.xueyanjiBaudRate)
+    }
       // 是否开启脸识别
     isUseFaceRecogService.value = configData.value.isUseFaceRecogService
     console.log('人脸识别',isUseFaceRecogService.value)

--
Gitblit v1.8.0