chenyc
2023-09-08 f6d62eaf70440d3183cad494d08a9e8c96c3d9d8
增加体重秤串口通讯
5个文件已修改
1个文件已删除
1个文件已添加
89 ■■■■■ 已修改文件
electron/main/index.ts 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
imgs/1693286128018.png 补丁 | 查看 | 原始文档 | blame | 历史
package.json 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main.ts 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/samples/deviceApi/zhiRongT605.ts 67 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/stores/StoresConfing.ts 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/home/index.vue 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
electron/main/index.ts
@@ -65,10 +65,10 @@
  win = new BrowserWindow({
    title: 'Main window',
    transparent: true,
    frame:false,
    frame:store.get('debug'),//关闭菜单栏
    fullscreen: true,// 开启默认全屏
    kiosk: true,
    autoHideMenuBar:store.get('debug'), //关闭菜单栏
    // autoHideMenuBar:store.get('debug'),
    webPreferences: {
      preload: splash,
      nodeIntegration: true,
imgs/1693286128018.png
Binary files differ
package.json
@@ -1,6 +1,6 @@
{
  "name": "sign-tool",
  "version": "2.6.9",
  "version": "2.7.0",
  "icon": "public/favicon.ico",
  "main": "dist/electron/main/index.js",
  "author": "",
src/main.ts
@@ -12,7 +12,7 @@
function getUserMedia(constrains:any, success:any, error:any) {
  if (navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
      //最新标准API
      ElMessage({ type: 'success', message: '支持最新标准API' });
      ElMessage({ type: 'success', message: '支持人脸识别最新Api' });
      navigator.mediaDevices.getUserMedia(constrains).then(success).catch(error);
  } else if (navigator.webkitGetUserMedia) {
    ElMessage({ type: 'success', message: '支持webkit内核浏览器' });
src/samples/deviceApi/zhiRongT605.ts
New file
@@ -0,0 +1,67 @@
// 欧姆龙 HBP-9030 115200
import { ElMessage } from 'element-plus'
const { SerialPort } = require('serialport')
const { DelimiterParser } = require('@serialport/parser-delimiter')
const { ReadyParser } = require('@serialport/parser-ready')
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)
    })
    // 解析分割数据流
    //     No:4742
    // Gross:  75.0kg
    //  Tare:   0.0kg
    //   Net:  75.0kg
    //
    //
    //
    //
    //
    // 20 20 20 4E6F 3A 34 37 34 31 0A47 72 6F 73 73 3A 20 20 3733 2E 37 6B 67 0A 20 5461 72 65 3A 20 20 2030 2E 30 6B 67 0A 20 204E 65 74 3A 20 20 3733 2E 37 6B 67 0A 0A0A 0A 0A
    const parser = serialport.pipe(new DelimiterParser({ delimiter:Buffer.from([10,10,10,10,10]),includeDelimiter:true }))
    parser.on('data', (value: string | any[])=>{
        console.log(value.toString())
        const str=value.toString()
        const list=str.split('Net:')
        console.log(list)
        if(list.length===2){
            const re=list[1].trim()
            const res=re.substring(0,re.length-2)
            console.log(res)
            sockteStore().setweightSockte(
                {
                    deviceName:'志荣T605',
                    type:"体重秤",
                    result:res,
                    resultTime:new Date().toString(),
                    state:2
                }
            )
        }else{
            console.log('数据格式不对')
        }
    }) // all data after READY is received
}
export {
    initPort,
}
src/stores/StoresConfing.ts
@@ -15,7 +15,10 @@
        baudRate:115200,
        Is_xyj:false,
        xueyanjiPortPath:"COM35",
        xueyanjiBaudRate:115200
        xueyanjiBaudRate:115200,
        Is_tzc:false,
        tzcPortPath:"COM34",
        tzcBaudRate:1200
        
    })
    /**
src/views/home/index.vue
@@ -221,6 +221,8 @@
import {base64toFile} from '@/samples/faceApi'
import{initPort} from '@/samples/portApi'
import{initPort as oumulongHbp9030 } from '@/samples/deviceApi/oumulong-HBP-9030'
import{initPort as zhiRongT605 } from '@/samples/deviceApi/zhiRongT605'
import { ElLoading, ElMessage } from 'element-plus'
let trackerTask: any = null;
// 标识用的画布
@@ -660,6 +662,7 @@
onMounted(() => {
  console.log('页面初始化', os.hostname())
  setTimeout(()=>{
    console.log('8秒后执行')
    console.log('打印设置文件')
    console.log(configData.value)
@@ -671,7 +674,11 @@
    if(configData.value.Is_xyj){
      oumulongHbp9030(configData.value.xueyanjiPortPath,configData.value.xueyanjiBaudRate)
    }
      // 是否开启脸识别
    // 是否开启志荣体重秤联机
    if(configData.value.Is_tzc){
      zhiRongT605(configData.value.tzcPortPath,configData.value.tzcBaudRate)
    }
    // 是否开启脸识别
    isUseFaceRecogService.value = configData.value.isUseFaceRecogService
    console.log('人脸识别',isUseFaceRecogService.value)
    if (isUseFaceRecogService.value) {