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-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
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @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; // 调试参数
|
|
|
|
|
|
BeltTearingProjectType projectType; // 项目类型
|
2025-09-21 22:20:24 +08:00
|
|
|
|
|
2025-09-10 00:31:27 +08:00
|
|
|
|
int serverPort = 5900; // 服务端端口
|
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)
|
|
|
|
|
|
Q_DECLARE_METATYPE(BeltTearingConfigResult)
|
2025-08-24 23:24:33 +08:00
|
|
|
|
|
|
|
|
|
|
#endif // IVRBELTTEARINGCONFIG_H
|