From f6d62eaf70440d3183cad494d08a9e8c96c3d9d8 Mon Sep 17 00:00:00 2001
From: chenyc <501753378@qq.com>
Date: 星期五, 08 九月 2023 12:02:36 +0800
Subject: [PATCH] 增加体重秤串口通讯
---
/dev/null | 0
src/views/home/index.vue | 9 ++++
src/stores/StoresConfing.ts | 5 ++
package.json | 2
src/samples/deviceApi/zhiRongT605.ts | 67 +++++++++++++++++++++++++++++++++
electron/main/index.ts | 4 +-
src/main.ts | 2
7 files changed, 83 insertions(+), 6 deletions(-)
diff --git a/electron/main/index.ts b/electron/main/index.ts
index bd0a2ad..771a6e6 100644
--- a/electron/main/index.ts
+++ b/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,
diff --git a/imgs/1693286128018.png b/imgs/1693286128018.png
deleted file mode 100644
index f88bfbf..0000000
--- a/imgs/1693286128018.png
+++ /dev/null
Binary files differ
diff --git a/package.json b/package.json
index 7ff1350..064dbab 100644
--- a/package.json
+++ b/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": "",
diff --git a/src/main.ts b/src/main.ts
index 634c503..dba4d47 100644
--- a/src/main.ts
+++ b/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内核浏览器' });
diff --git a/src/samples/deviceApi/zhiRongT605.ts b/src/samples/deviceApi/zhiRongT605.ts
new file mode 100644
index 0000000..cf10332
--- /dev/null
+++ b/src/samples/deviceApi/zhiRongT605.ts
@@ -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,
+}
diff --git a/src/stores/StoresConfing.ts b/src/stores/StoresConfing.ts
index 4668ffd..09f71de 100644
--- a/src/stores/StoresConfing.ts
+++ b/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
})
/**
diff --git a/src/views/home/index.vue b/src/views/home/index.vue
index 722ce91..992881b 100644
--- a/src/views/home/index.vue
+++ b/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) {
--
Gitblit v1.8.0