156 lines
3.9 KiB
C
Raw Normal View History

2026-01-13 08:31:31 +08:00
#ifndef IVRCONFIG_H
#define IVRCONFIG_H
#include <iostream>
#include <string>
#include <vector>
// 包含公共配置结构体
#include "VrCommonConfig.h"
2026-01-25 01:27:01 +08:00
/**
* @brief
*/
struct VrScrewParam
{
double rodDiameter = 10.0; // 螺杆直径 (mm)
bool isHorizonScan = true; // 水平扫描模式
};
/**
* @brief
*/
struct VrCornerParam
{
double minEndingGap = 20.0;
double minEndingGap_z = 5.0;
double scale = 2.5;
double cornerTh = 60.0;
double jumpCornerTh_1 = 15.0;
double jumpCornerTh_2 = 60.0;
};
/**
* @brief
*/
struct VrOutlierFilterParam
{
double continuityTh = 20.0; // meanK
double outlierTh = 5.0; // stddevMul
};
/**
* @brief
*/
struct VrTreeGrowParam
{
double yDeviation_max = 20.0;
double zDeviation_max = 50.0;
int maxLineSkipNum = 10;
double maxSkipDistance = 20.0;
double minLTypeTreeLen = 10.0;
double minVTypeTreeLen = 10.0;
};
/**
* @brief ScrewPosition
*/
struct VrAlgorithmParams
{
VrScrewParam screwParam;
VrCornerParam cornerParam;
VrOutlierFilterParam filterParam;
VrTreeGrowParam growParam;
VrPlaneCalibParam planeCalibParam;
};
2026-01-13 08:31:31 +08:00
/**
* @brief
*/
struct ConfigResult
{
std::vector<DeviceInfo> cameraList; // 相机设备列表
VrDebugParam debugParam; // 调试参数
SerialConfig serialConfig; // 串口配置
2026-01-25 01:27:01 +08:00
uint16_t tcpPort = 8100; // TCP服务器端口
VrAlgorithmParams algorithmParams; // 算法参数
2026-01-13 08:31:31 +08:00
// 显式赋值构造函数,确保正确的深拷贝
ConfigResult& operator=(const ConfigResult& other) {
if (this != &other) {
cameraList = other.cameraList;
debugParam = other.debugParam;
serialConfig = other.serialConfig;
tcpPort = other.tcpPort;
2026-01-25 01:27:01 +08:00
algorithmParams = other.algorithmParams;
2026-01-13 08:31:31 +08:00
}
return *this;
}
// 显式复制构造函数
ConfigResult(const ConfigResult& other)
: cameraList(other.cameraList)
, debugParam(other.debugParam)
, serialConfig(other.serialConfig)
2026-01-25 01:27:01 +08:00
, tcpPort(other.tcpPort)
, algorithmParams(other.algorithmParams) {
2026-01-13 08:31:31 +08:00
}
// 默认构造函数
ConfigResult() = default;
};
/**
* @brief
*/
enum LoadConfigErrorCode
{
LOAD_CONFIG_SUCCESS = 0, // 加载成功
LOAD_CONFIG_FILE_NOT_FOUND = -1, // 配置文件不存在
LOAD_CONFIG_PARSE_ERROR = -2, // 配置文件解析错误
LOAD_CONFIG_INVALID_FORMAT = -3, // 配置文件格式无效
LOAD_CONFIG_UNKNOWN_ERROR = -99 // 未知错误
};
/**
* @brief VrConfig接口类
*/
class IVrConfig
{
public:
/**
* @brief
*/
virtual ~IVrConfig() {}
/**
* @brief
* @return
*/
static bool CreateInstance(IVrConfig** ppVrConfig);
/**
* @brief
* @param filePath
* @param configResult
* @return (LoadConfigErrorCode): 0=,
*/
virtual int LoadConfig(const std::string& filePath, ConfigResult& configResult) = 0;
/**
* @brief
* @param filePath
* @param configResult
* @return
*/
virtual bool SaveConfig(const std::string& filePath, ConfigResult& configResult) = 0;
/**
* @brief
* @param notify
*/
virtual void SetConfigChangeNotify(IVrConfigChangeNotify* notify) = 0;
};
#endif // IVRCONFIG_H