GrabBag/App/BeltTearing/BeltTearingConfig/Inc/IVrBeltTearingConfig.h
2025-09-14 14:51:38 +08:00

153 lines
3.7 KiB
C++

#ifndef IVRBELTTEARINGCONFIG_H
#define IVRBELTTEARINGCONFIG_H
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
/**
* @brief 项目类型枚举
*/
enum class BeltTearingProjectType
{
BeltTearing = 0, // 皮带撕裂检测
BeltMonitoring = 1, // 皮带监控
};
/**
* @brief 服务器信息结构
*/
struct ServerInfo
{
std::string name; // 服务器名称
std::string ip; // 服务器IP地址
int port; // 服务器端口
};
/**
* @brief 皮带撕裂检测参数
*/
struct BeltTearingParam
{
double tearThreshold = 50.0; // 撕裂阈值
double minTearLength = 100.0; // 最小撕裂长度
double maxTearWidth = 30.0; // 最大撕裂宽度
};
/**
* @brief 图像处理参数
*/
struct ImageProcessingParam
{
int blurSize = 5; // 模糊核大小
int cannyThreshold1 = 50; // Canny边缘检测阈值1
int cannyThreshold2 = 150; // Canny边缘检测阈值2
int morphologySize = 3; // 形态学操作核大小
};
/**
* @brief 监控参数
*/
struct MonitoringParam
{
int checkInterval = 1000; // 检查间隔(毫秒)
int alertThreshold = 3; // 报警阈值
int maxHistorySize = 100; // 最大历史记录大小
};
/**
* @brief 调试参数
*/
struct DebugParam
{
bool enableDebug = false; // 是否开启调试模式
bool saveDebugImage = false; // 是否保存调试图像
bool printDetailLog = false; // 是否打印详细日志
std::string debugOutputPath = ""; // 调试输出路径
};
/**
* @brief 算法参数配置结构
*/
struct BeltTearingAlgorithmParams
{
BeltTearingParam beltTearingParam; // 皮带撕裂检测参数
ImageProcessingParam imageProcessingParam; // 图像处理参数
MonitoringParam monitoringParam; // 监控参数
};
/**
* @brief 配置加载结果
*/
struct BeltTearingConfigResult
{
std::vector<ServerInfo> servers; // 服务器列表
BeltTearingAlgorithmParams algorithmParams; // 算法参数
DebugParam debugParam; // 调试参数
BeltTearingProjectType projectType; // 项目类型
int serverPort = 5900; // 服务端端口
};
/**
* @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;
};
#endif // IVRBELTTEARINGCONFIG_H