Browse Source

feat: 增加心跳间隔时间,适配设备新协议

master
liujiangyong 3 weeks ago
parent
commit
11c0e7231a
  1. 37
      CHANGELOGS/V1.2.5.md
  2. 6
      README.md
  3. 4
      package-lock.json
  4. 2
      package.json
  5. 4
      src/main/ipcRouter.js

37
CHANGELOGS/V1.2.5.md

@ -0,0 +1,37 @@
# V1.2.5 更新日志
- **更新日期**: 2026年07月22日
- **版本号**: 1.2.5
## 功能调整
### 1. 心跳超时机制适配设备新协议
- **适配设备 30 秒心跳周期**:根据设备端协议变更,将上位机心跳接收预期从“高频心跳”调整为“30 秒一次”
- **延长断连判定窗口**:心跳超时时间调整为 `60 秒`,避免设备在正常上报周期内被误判掉线
- **优化检测轮询频率**:心跳检测间隔调整为 `15 秒`,在保证及时发现异常的同时降低无效轮询
## 技术细节
### 心跳参数调整
- `HEARTBEAT_INTERVAL`: `5000ms` -> `15000ms`
- `HEARTBEAT_TIMEOUT`: `10000ms` -> `60000ms`
### 协议说明同步
- 更新 README 中的心跳机制说明
- 同步最新安装包版本下载链接为 `1.2.5`
## 影响范围
- 设备 TCP 连接保活与掉线判定逻辑
- 心跳超时后的自动断连与自动重连触发时机
- 项目版本元数据与发布文档
## 依赖更新
- 无依赖包更新
## 注意事项
1. 本版本假定设备按新协议每 `30 秒` 上报一次心跳包;若设备端再次调整周期,需要同步评估上位机超时参数。
2. 上位机仍仅将 `heartbeat:reply` 识别为心跳包,设备端需继续保持现有消息类型与换行分帧格式。
---
**完整更新内容请查看项目 Git 提交记录**

6
README.md

@ -3,11 +3,11 @@
> 基于 Electron + React + Vite 开发的光电挠度仪上位机应用程序 > 基于 Electron + React + Vite 开发的光电挠度仪上位机应用程序
![Platform](https://img.shields.io/badge/platform-Windows-lightgrey.svg) ![Platform](https://img.shields.io/badge/platform-Windows-lightgrey.svg)
![Version](https://img.shields.io/badge/version-1.2.1-green.svg) ![Version](https://img.shields.io/badge/version-1.2.5-green.svg)
--- ---
## 最新版本下载 ## 最新版本下载
- [Latest Releases](https://iotfileres.anxinyun.cn/FlexometerSetup/FlexometerSetup-1.2.4-setup.exe) 下载最新安装包 - [Latest Releases](https://iotfileres.anxinyun.cn/FlexometerSetup/FlexometerSetup-1.2.5-setup.exe) 下载最新安装包
## 目录 ## 目录
@ -363,7 +363,7 @@ WRITE_CSV_HEADER // 写入CSV文件头
- 默认端口: 2233 - 默认端口: 2233
- 协议: JSON over TCP - 协议: JSON over TCP
- 消息格式: `{"command": "xxx", "type": "xxx", "values": "xxx"}\n\n` - 消息格式: `{"command": "xxx", "type": "xxx", "values": "xxx"}\n\n`
- 心跳机制: 设备每2秒发送心跳包,应用5秒检测一次,10秒无心跳则认为断开 - 心跳机制: 设备每30秒发送心跳包,应用15秒检测一次,60秒无心跳则认为断开
#### 自动重连机制 #### 自动重连机制

4
package-lock.json

@ -1,12 +1,12 @@
{ {
"name": "FlexometerSetup", "name": "FlexometerSetup",
"version": "1.2.0", "version": "1.2.5",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "FlexometerSetup", "name": "FlexometerSetup",
"version": "1.2.0", "version": "1.2.5",
"hasInstallScript": true, "hasInstallScript": true,
"dependencies": { "dependencies": {
"@ant-design/icons": "^5.6.1", "@ant-design/icons": "^5.6.1",

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "FlexometerSetup", "name": "FlexometerSetup",
"version": "1.2.4", "version": "1.2.5",
"description": "An Electron application with React", "description": "An Electron application with React",
"main": "./out/main/index.js", "main": "./out/main/index.js",
"author": "cles", "author": "cles",

4
src/main/ipcRouter.js

@ -165,8 +165,8 @@ reconnectManager.on('reconnect-status', handleReconnectStatus)
const tcpConnectionData = new Map() // 存储连接参数 const tcpConnectionData = new Map() // 存储连接参数
// 心跳检测相关配置 // 心跳检测相关配置
const HEARTBEAT_INTERVAL = 5000 // 心跳检测间隔 5秒(设备每2秒发送,我们5秒检测一次) const HEARTBEAT_INTERVAL = 15000 // 心跳检测间隔 15秒(设备每30秒发送,我们15秒检测一次)
const HEARTBEAT_TIMEOUT = 10000 // 心跳超时时间 10秒(设备每2秒发送,超过10秒没收到就认为断开) const HEARTBEAT_TIMEOUT = 60000 // 心跳超时时间 60秒(设备每30秒发送,超过60秒没收到就认为断开)
const heartbeatTimers = new Map() // 保存每个IP的心跳检测定时器 const heartbeatTimers = new Map() // 保存每个IP的心跳检测定时器
const lastHeartbeatTime = new Map() // 保存每个IP的最后心跳时间 const lastHeartbeatTime = new Map() // 保存每个IP的最后心跳时间

Loading…
Cancel
Save