Compare commits

...

2 Commits

Author SHA1 Message Date
yiyi
11c615d0c9 编译ARM应用 & 调整撕裂协议文档 2026-02-21 16:34:38 +08:00
yiyi
a88e30cb76 撕裂增加实时上传功能 2026-02-21 13:53:33 +08:00
7 changed files with 2616 additions and 2577 deletions

View File

@ -351,6 +351,7 @@ void BeltTearingPresenter::sendSimulationData()
SendDetectionResultToRobot(simulationResults); // 发送检测结果到机械臂 SendDetectionResultToRobot(simulationResults); // 发送检测结果到机械臂
m_tearingProtocol->sendDetectResult(simulationResults, QImage()); m_tearingProtocol->sendDetectResult(simulationResults, QImage());
m_tearingProtocol->sendRealtimeResult(simulationResults, QImage());
} }
bool BeltTearingPresenter::initializeCamera() bool BeltTearingPresenter::initializeCamera()

View File

@ -143,7 +143,17 @@ void TearingTcpProtocol::sendDetectResult(const std::vector<SSG_beltTearingInfo>
// 构造数据帧 // 构造数据帧
QByteArray frame = buildFrame(jsonData); QByteArray frame = buildFrame(jsonData);
// 发送给所有客户端 // 检查是否有客户端开启了实时传输
bool hasRealtimeClient = false;
for (auto it = m_clientRealtimeEnabled.begin(); it != m_clientRealtimeEnabled.end(); ++it) {
if (it.value()) {
hasRealtimeClient = true;
break;
}
}
if (!hasRealtimeClient) {
// 没有客户端开启实时传输,广播给所有客户端
bool success = m_tcpServer->SendAllData(frame.constData(), frame.size()); bool success = m_tcpServer->SendAllData(frame.constData(), frame.size());
if (success) { if (success) {
LOG_DEBUG("Sent DETECT_RESULT to all clients, count=%d, historyMax=%d, historyMaxId=%d\n", LOG_DEBUG("Sent DETECT_RESULT to all clients, count=%d, historyMax=%d, historyMaxId=%d\n",
@ -151,6 +161,27 @@ void TearingTcpProtocol::sendDetectResult(const std::vector<SSG_beltTearingInfo>
} else { } else {
LOG_WARNING("Failed to send DETECT_RESULT to clients\n"); LOG_WARNING("Failed to send DETECT_RESULT to clients\n");
} }
} else {
// 有客户端开启了实时传输,逐个发送,跳过已开启实时传输的客户端
int sentCount = 0;
int skippedCount = 0;
for (auto it = m_clientPointers.begin(); it != m_clientPointers.end(); ++it) {
QString clientId = it.key();
if (m_clientRealtimeEnabled.value(clientId, false)) {
skippedCount++;
continue;
}
const TCPClient* pClient = it.value();
bool success = m_tcpServer->SendData(pClient, frame.constData(), frame.size());
if (success) {
sentCount++;
} else {
LOG_WARNING("Failed to send DETECT_RESULT to client %s\n", clientId.toStdString().c_str());
}
}
LOG_DEBUG("Sent DETECT_RESULT to %d clients (skipped %d realtime clients), count=%d, historyMax=%d, historyMaxId=%d\n",
sentCount, skippedCount, count, m_historyMaxLength, m_historyMaxId);
}
} }
void TearingTcpProtocol::sendRealtimeResult(const std::vector<SSG_beltTearingInfo>& results, const QImage& visImage) void TearingTcpProtocol::sendRealtimeResult(const std::vector<SSG_beltTearingInfo>& results, const QImage& visImage)

View File

@ -1,7 +1,7 @@
#ifndef VERSION_H #ifndef VERSION_H
#define VERSION_H #define VERSION_H
#define BELT_TEARING_SERVER_VERSION_STRING "2.0.6" #define BELT_TEARING_SERVER_VERSION_STRING "2.0.7"
#define BELT_TEARING_SERVER_VERSION_BUILD "1" #define BELT_TEARING_SERVER_VERSION_BUILD "1"
#define BELT_TEARING_SERVER_PRODUCT_NAME "BeltTearingServer" #define BELT_TEARING_SERVER_PRODUCT_NAME "BeltTearingServer"
#define BELT_TEARING_SERVER_COMPANY_NAME "VisionRobot" #define BELT_TEARING_SERVER_COMPANY_NAME "VisionRobot"

View File

@ -1,3 +1,7 @@
# 2.0.7
## build_1 2026-02-21
1. 增加实时传输功能
# 2.0.6 # 2.0.6
## build_1 2026-02-03 ## build_1 2026-02-03
1. 增加授权 1. 增加授权

View File

@ -1,18 +1,19 @@
# 皮带撕裂检测系统 TCP 通信协议 # 皮带撕裂检测系统 TCP 通信协议
## 版本 ## 版本
版本: 1.3 版本: 1.4
日期: 2026-02-12 日期: 2026-02-21
--- ---
### 版本历史 ### 版本历史
| 版本 | 日期 | 修改内容 | 作者 | | 版本 | 日期 | 修改内容 |
|------|------------|------------------|-------| |------|------------|------------------|
| 1.3 | 2026-02-12 | 增加实时传输检测结果功能(SET_REALTIME/REALTIME_RESULT) | | | 1.4 | 2026-02-21 | 开启实时上报时不再发送DETECT_RESULT避免重复输出<br/>增加CMD汇总表格 |
| 1.2 | 2025-11-30 | 增加最大撕裂ID字段(maxId) | | | 1.3 | 2026-02-12 | 增加实时传输检测结果功能(SET_REALTIME/REALTIME_RESULT) |
| 1.1 | 2025-11-16 | 修改协议长度的格式 | | | 1.2 | 2025-11-30 | 增加最大撕裂ID字段(maxId) |
| 1.0 | 2025-11-11 | 初始版本 | | | 1.1 | 2025-11-16 | 修改协议长度的格式 |
| 1.0 | 2025-11-11 | 初始版本 |
--- ---
@ -36,6 +37,19 @@
- 支持命令应答机制 - 支持命令应答机制
- UTF-8编码 - UTF-8编码
### 1.3 CMD 汇总表
| msgType | 方向 | 说明 | 详细章节 |
|---------|------|------|----------|
| `DETECT_RESULT` | 服务器 → 客户端 | 撕裂检测结果上报(历史最大值),<br/>仅发送给**未开启**实时传输的客户端 | 4.1 |
| `REALTIME_RESULT` | 服务器 → 客户端 | 实时检测结果上报(所有撕裂详细数据),<br/>仅发送给**已开启**实时传输的客户端 | 4.2 |
| `SET_SPEED` | 客户端 → 服务器 | 设置皮带速度mm/s | 5.1 |
| `SET_CONTROL` | 客户端 → 服务器 | 启动/停止检测 | 5.2 |
| `SET_REALTIME` | 客户端 → 服务器 | 开启/关闭实时传输 | 5.3 |
| `CMD_RESPONSE` | 服务器 → 客户端 | 控制命令的统一应答 | 6.1 |
| `HEARTBEAT` | 客户端 → 服务器 | 心跳消息 | 9.1 |
| `HEARTBEAT_ACK` | 服务器 → 客户端 | 心跳应答 | 9.1 |
--- ---
## 2. 数据帧格式 ## 2. 数据帧格式
@ -89,7 +103,6 @@
### 4.1 撕裂检测结果上报 ### 4.1 撕裂检测结果上报
**消息类型**: `DETECT_RESULT` **消息类型**: `DETECT_RESULT`
**JSON格式**: **JSON格式**:
```json ```json
{ {
@ -124,15 +137,12 @@
"visimg": "/9j/4AAQSkZJRgABAQEAYABgAAD..." "visimg": "/9j/4AAQSkZJRgABAQEAYABgAAD..."
} }
``` ```
--- ---
### 4.2 实时检测结果上报 ### 4.2 实时检测结果上报
当客户端开启实时传输功能后,服务器在每次检测完成时主动上报检测结果,包含所有撕裂的详细数据。 当客户端开启实时传输功能后,服务器在每次检测完成时主动上报检测结果,包含所有撕裂的详细数据。
**消息类型**: `REALTIME_RESULT` **消息类型**: `REALTIME_RESULT`
**JSON格式**: **JSON格式**:
```json ```json
{ {
@ -153,13 +163,6 @@
"length": 85, "length": 85,
"width": 20, "width": 20,
"depth": 5 "depth": 5
},
{
"id": 10003,
"status": 1,
"length": 42,
"width": 15,
"depth": 3
} }
], ],
"visimg": "iVBORw0KGgoAAAANSUhEUgAAAAUA..." "visimg": "iVBORw0KGgoAAAANSUhEUgAAAAUA..."
@ -200,7 +203,7 @@
- 实时传输功能需要客户端通过 `SET_REALTIME` 命令开启 - 实时传输功能需要客户端通过 `SET_REALTIME` 命令开启
- 开启后,服务器每次完成一帧检测即上报一次结果 - 开启后,服务器每次完成一帧检测即上报一次结果
- 关闭实时传输后,服务器停止上报 `REALTIME_RESULT` 消息 - 关闭实时传输后,服务器停止上报 `REALTIME_RESULT` 消息
- `REALTIME_RESULT``DETECT_RESULT` 独立,互不影响 - `REALTIME_RESULT``DETECT_RESULT` 互斥:开启实时传输的客户端只收到 `REALTIME_RESULT`,未开启的客户端只收到 `DETECT_RESULT`
- 当 count 为 0 时tears 为空数组 `[]` - 当 count 为 0 时tears 为空数组 `[]`
**示例**(无撕裂时): **示例**(无撕裂时):

View File

@ -36,7 +36,7 @@ win32 {
unix { unix {
# Unix/Linux 平台使用 OpenCV 3.2.0 ARM # Unix/Linux 平台使用 OpenCV 3.2.0 ARM
INCLUDEPATH += $$PWD/../../SDK/OpenCV320/Arm/aarch64/include INCLUDEPATH += $$PWD/../../SDK/OpenCV320/include
LIBS += -L$$PWD/../../SDK/OpenCV320/Arm/aarch64 LIBS += -L$$PWD/../../SDK/OpenCV320/Arm/aarch64
LIBS += -lopencv_core -lopencv_imgproc -lopencv_calib3d -lopencv_features2d LIBS += -lopencv_core -lopencv_imgproc -lopencv_calib3d -lopencv_features2d

2
Utils

@ -1 +1 @@
Subproject commit ed67ff85ff3bfdd54fb4b85899086a703853128b Subproject commit 7071da62403ea703981ffe77fff948266b66fdf3