From b7b73d339a42d09ecc3f0115c49e23dc46893d5e Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期四, 11 七月 2024 11:34:04 +0800
Subject: [PATCH] 更新优化

---
 src/samples/deviceApi/RBP-9000c.ts |   50 +++++++++++++++++++++++++++++++++-----------------
 1 files changed, 33 insertions(+), 17 deletions(-)

diff --git a/src/samples/deviceApi/RBP-9000c.ts b/src/samples/deviceApi/RBP-9000c.ts
index 1a99da9..f6dd278 100644
--- a/src/samples/deviceApi/RBP-9000c.ts
+++ b/src/samples/deviceApi/RBP-9000c.ts
@@ -26,27 +26,43 @@
         console.log('端口异常端口链接断开')
         console.log(err)
     })
+    //                 AA E0 03 28 64 02 71 06 44 51 A2 01 84 40 40 C0 5D D0
     // 解析分割数据流   AA 80 09 0F 01 06 00 17 05 0E 10 11 0F 00 8D 00 44 00 56 8C
     //AA 80 09 0F 01 06 00 17 05 0E 0F 37 37 00 74 00 46 00 50 70
     const parser = serialport.pipe(new ByteLengthParser({ length: 20 }))
-    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[14]+','+list[16]+','+list[18],
-                  resultTime:new Date().toString(),
-                  state:2
-              }
-          )
-        }
+    // 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[14]+','+list[16]+','+list[18],
+    //               resultTime:new Date().toString(),
+    //               state:2
+    //           }
+    //       )
+    //     }
         
-    })
+    // })
+    parser.on('data',(value: string | any[]) =>{
+        console.log('-----------------')
+        if(value.length>=20){
+            sockteStore().setxyjSockte(
+                {
+                    deviceName:'HBP-9030',
+                    type:"血压计",
+                    result:value[14]+','+value[16]+','+value[18],
+                    resultTime:new Date().toString(),
+                    state:2
+                }
+            )
+        }
+        console.log(value,'血压计数据')
+    }) 
 }
 
 export {

--
Gitblit v1.8.0