chenyc
2023-07-26 96882efacd0fd9ce750e1b226fe046b52cd36df0
新增血压计HBP9020通讯
2个文件已修改
1个文件已添加
65 ■■■■■ 已修改文件
src/samples/deviceApi/oumulong-HBP-9030.ts 55 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stores/StoresConfing.ts 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/home/index.vue 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/samples/deviceApi/oumulong-HBP-9030.ts
New file
@@ -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,
}
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
        
    })
    /**
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)