2025-08-24 23:24:33 +08:00
|
|
|
|
#ifndef IVRBELTTEARINGCONFIG_H
|
|
|
|
|
|
#define IVRBELTTEARINGCONFIG_H
|
|
|
|
|
|
|
2025-09-21 22:20:24 +08:00
|
|
|
|
#include <iostream>
|
2025-08-24 23:24:33 +08:00
|
|
|
|
#include <string>
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
#include <utility>
|
|
|
|
|
|
#include <algorithm>
|
2025-09-29 00:56:53 +08:00
|
|
|
|
#include <QtCore/QMetaType>
|
2025-08-24 23:24:33 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 项目类型枚举
|
|
|
|
|
|
*/
|
|
|
|
|
|
enum class BeltTearingProjectType
|
|
|
|
|
|
{
|
|
|
|
|
|
BeltTearing = 0, // 皮带撕裂检测
|
|
|
|
|
|
BeltMonitoring = 1, // 皮带监控
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-11-30 15:38:27 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief ModbusTCP协议类型枚举
|
|
|
|
|
|
*/
|
|
|
|
|
|
enum class ModbusTCPProtocolType
|
|
|
|
|
|
{
|
|
|
|
|
|
Standard = 0, // 标准协议(支持5个撕裂信息,每个包含ID、状态、宽度、深度)
|
|
|
|
|
|
Simplified = 1, // 简化协议(仅报警标志、最大长度、最大宽度、最大撕裂ID和复位)
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-09-29 00:56:53 +08:00
|
|
|
|
enum class ByteDataType {
|
|
|
|
|
|
Text = 0x01,
|
|
|
|
|
|
Image = 0x02,
|
|
|
|
|
|
ReadConfig = 0x03,
|
|
|
|
|
|
WriteConfig = 0x04,
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-08-24 23:24:33 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 服务器信息结构
|
|
|
|
|
|
*/
|
|
|
|
|
|
struct ServerInfo
|
|
|
|
|
|
{
|
|
|
|
|
|
std::string name; // 服务器名称
|
|
|
|
|
|
std::string ip; // 服务器IP地址
|
|
|
|
|
|
int port; // 服务器端口
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-09-21 22:20:24 +08:00
|
|
|
|
* @brief 皮带撕裂检测参数 - 简化版本
|
2025-08-24 23:24:33 +08:00
|
|
|
|
*/
|
|
|
|
|
|
struct BeltTearingParam
|
|
|
|
|
|
{
|
2025-09-21 22:20:24 +08:00
|
|
|
|
double scanXScale = 1.0; // 3D扫描仪X方向标尺
|
|
|
|
|
|
double scanYScale = 1.0; // 3D扫描仪Y方向标尺
|
|
|
|
|
|
double differnceBinTh = 1.0; // 一层次分割阈值调整
|
|
|
|
|
|
double tearingMinLen = 5.0; // 最小撕裂长度
|
|
|
|
|
|
double tearingMinGap = 2.0; // 撕裂间距阈值
|
|
|
|
|
|
|
|
|
|
|
|
// 特征提取参数
|
|
|
|
|
|
double sameGapTh = 2.0; // 相同gap阈值
|
|
|
|
|
|
int gapChkWin = 5; // gap检查窗口
|
2025-08-24 23:24:33 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 监控参数
|
|
|
|
|
|
*/
|
|
|
|
|
|
struct MonitoringParam
|
|
|
|
|
|
{
|
|
|
|
|
|
int checkInterval = 1000; // 检查间隔(毫秒)
|
2025-09-21 22:20:24 +08:00
|
|
|
|
double alertThreshold = 3.0; // 报警阈值
|
2025-08-24 23:24:33 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
2025-11-19 00:23:09 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 队列处理参数
|
|
|
|
|
|
*/
|
|
|
|
|
|
struct QueueProcessParam
|
|
|
|
|
|
{
|
|
|
|
|
|
int maxQueueSize = 300; // 最大队列大小
|
|
|
|
|
|
int generationInterval = 100; // 图像生成间隔(每N条线生成一次)
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-11-10 00:19:20 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 相机配置参数
|
|
|
|
|
|
*/
|
|
|
|
|
|
struct CameraParam
|
|
|
|
|
|
{
|
|
|
|
|
|
std::string name = ""; // 相机名称
|
|
|
|
|
|
std::string cameraIP = ""; // 相机IP地址
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-11-26 22:44:38 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 串口配置参数(用于 Modbus RTU)
|
|
|
|
|
|
*/
|
|
|
|
|
|
struct SerialPortParam
|
|
|
|
|
|
{
|
|
|
|
|
|
std::string portName = ""; // 串口名称(如 /dev/ttyS4 或 COM10)
|
|
|
|
|
|
int baudRate = 115200; // 波特率
|
|
|
|
|
|
char parity = 'N'; // 校验位(N=无校验, E=偶校验, O=奇校验)
|
|
|
|
|
|
int dataBits = 8; // 数据位
|
|
|
|
|
|
int stopBits = 1; // 停止位
|
|
|
|
|
|
|
|
|
|
|
|
SerialPortParam()
|
|
|
|
|
|
{
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
|
|
portName = "COM10"; // Windows 默认串口
|
|
|
|
|
|
#else
|
|
|
|
|
|
portName = "/dev/ttyS4"; // ARM/Linux 默认串口
|
|
|
|
|
|
#endif
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-08-24 23:24:33 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* @brief 调试参数
|
|
|
|
|
|
*/
|
|
|
|
|
|
struct DebugParam
|
|
|
|
|
|
{
|
|
|
|
|
|
bool enableDebug = false; // 是否开启调试模式
|
|
|
|
|
|
bool saveDebugImage = false; // 是否保存调试图像
|
|
|
|
|
|
bool printDetailLog = false; // 是否打印详细日志
|
|
|
|
|
|
std::string debugOutputPath = ""; // 调试输出路径
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 算法参数配置结构
|
|
|
|
|
|
*/
|
|
|
|
|
|
struct BeltTearingAlgorithmParams
|
|
|
|
|
|
{
|
|
|
|
|
|
BeltTearingParam beltTearingParam; // 皮带撕裂检测参数
|
|
|
|
|
|
MonitoringParam monitoringParam; // 监控参数
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 配置加载结果
|
|
|
|
|
|
*/
|
|
|
|
|
|
struct BeltTearingConfigResult
|
|
|
|
|
|
{
|
2025-11-08 00:28:59 +08:00
|
|
|
|
std::vector<ServerInfo> servers; // 服务器列表
|
|
|
|
|
|
BeltTearingAlgorithmParams algorithmParams; // 算法参数
|
|
|
|
|
|
DebugParam debugParam; // 调试参数
|
2025-11-10 00:19:20 +08:00
|
|
|
|
BeltTearingProjectType projectType; // 项目类型
|
|
|
|
|
|
std::vector<CameraParam> cameras; // 相机列表
|
2025-11-19 00:23:09 +08:00
|
|
|
|
QueueProcessParam queueProcessParam; // 队列处理参数
|
2025-11-26 22:44:38 +08:00
|
|
|
|
SerialPortParam serialPortParam; // 串口参数(用于 Modbus RTU)
|
2025-11-30 15:38:27 +08:00
|
|
|
|
ModbusTCPProtocolType modbusTCPProtocol; // ModbusTCP协议类型(默认使用简化协议)
|
2025-09-21 22:20:24 +08:00
|
|
|
|
|
2025-11-26 22:44:38 +08:00
|
|
|
|
int serverPort = 5900; // 上下位机通信端口
|
|
|
|
|
|
int tcpPort = 5800; // 客户协议-TCP协议端口(新协议-TearingTcpProtocol)
|
2025-11-30 15:38:27 +08:00
|
|
|
|
|
|
|
|
|
|
// 构造函数,设置默认值
|
|
|
|
|
|
BeltTearingConfigResult()
|
|
|
|
|
|
: projectType(BeltTearingProjectType::BeltTearing)
|
|
|
|
|
|
, modbusTCPProtocol(ModbusTCPProtocolType::Simplified) // 默认使用简化协议
|
|
|
|
|
|
{}
|
2025-08-24 23:24:33 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 配置改变通知接口
|
|
|
|
|
|
*/
|
|
|
|
|
|
class IVrBeltTearingConfigChangeNotify
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
virtual ~IVrBeltTearingConfigChangeNotify() {}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 配置数据改变通知
|
|
|
|
|
|
* @param configResult 新的配置数据
|
|
|
|
|
|
*/
|
|
|
|
|
|
virtual void OnConfigChanged(const BeltTearingConfigResult& configResult) = 0;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief BeltTearingConfig接口类
|
|
|
|
|
|
*/
|
|
|
|
|
|
class IVrBeltTearingConfig
|
|
|
|
|
|
{
|
|
|
|
|
|
public:
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 虚析构函数
|
|
|
|
|
|
*/
|
|
|
|
|
|
virtual ~IVrBeltTearingConfig() = default;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 创建实例
|
|
|
|
|
|
* @return 实例
|
|
|
|
|
|
*/
|
|
|
|
|
|
static bool CreateInstance(IVrBeltTearingConfig** ppVrConfig);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 加载配置文件
|
|
|
|
|
|
* @param filePath 配置文件路径
|
|
|
|
|
|
* @return 加载的配置结果
|
|
|
|
|
|
*/
|
|
|
|
|
|
virtual BeltTearingConfigResult LoadConfig(const std::string& filePath) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 保存配置文件
|
|
|
|
|
|
* @param filePath 配置文件路径
|
|
|
|
|
|
* @param configResult 配置结果
|
|
|
|
|
|
* @return 是否保存成功
|
|
|
|
|
|
*/
|
|
|
|
|
|
virtual bool SaveConfig(const std::string& filePath, BeltTearingConfigResult& configResult) = 0;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @brief 设置配置改变通知回调
|
|
|
|
|
|
* @param notify 通知接口指针
|
|
|
|
|
|
*/
|
|
|
|
|
|
virtual void SetConfigChangeNotify(IVrBeltTearingConfigChangeNotify* notify) = 0;
|
2025-09-29 00:56:53 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 声明元类型,以便在QVariant中使用
|
|
|
|
|
|
Q_DECLARE_METATYPE(ServerInfo)
|
|
|
|
|
|
Q_DECLARE_METATYPE(BeltTearingParam)
|
2025-11-10 00:19:20 +08:00
|
|
|
|
Q_DECLARE_METATYPE(CameraParam)
|
2025-11-26 22:44:38 +08:00
|
|
|
|
Q_DECLARE_METATYPE(SerialPortParam)
|
2025-09-29 00:56:53 +08:00
|
|
|
|
Q_DECLARE_METATYPE(BeltTearingConfigResult)
|
2025-08-24 23:24:33 +08:00
|
|
|
|
|
|
|
|
|
|
#endif // IVRBELTTEARINGCONFIG_H
|