115 lines
3.2 KiB
C
115 lines
3.2 KiB
C
|
|
#ifndef IVRCONFIG_H
|
|||
|
|
#define IVRCONFIG_H
|
|||
|
|
|
|||
|
|
#include <iostream>
|
|||
|
|
#include <string>
|
|||
|
|
#include <vector>
|
|||
|
|
|
|||
|
|
// 包含公共配置结构体
|
|||
|
|
#include "VrCommonConfig.h"
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief BinocularMark TCP 客户端配置
|
|||
|
|
*/
|
|||
|
|
struct BinocularMarkClientConfig
|
|||
|
|
{
|
|||
|
|
std::string serverIP = "127.0.0.1"; // BinocularMarkApp 服务器IP
|
|||
|
|
int serverPort = 5901; // BinocularMarkApp 服务器端口
|
|||
|
|
int reconnectInterval = 5000; // 重连间隔(毫秒)
|
|||
|
|
int heartbeatInterval = 30000; // 心跳间隔(毫秒)
|
|||
|
|
};
|
|||
|
|
|
|||
|
|
/**
|
|||
|
|
* @brief 配置加载结果
|
|||
|
|
*/
|
|||
|
|
struct ConfigResult
|
|||
|
|
{
|
|||
|
|
// BinocularMarkReceiver 连接配置
|
|||
|
|
BinocularMarkClientConfig binocularMarkConfig;
|
|||
|
|
|
|||
|
|
// EpicEyeDevice 配置(仅 WorkpiecePositionApp 使用)
|
|||
|
|
std::vector<DeviceInfo> epicEyeDeviceList;
|
|||
|
|
|
|||
|
|
// 调试参数
|
|||
|
|
VrDebugParam debugParam;
|
|||
|
|
|
|||
|
|
// 串口配置(可选,用于机械臂通信)
|
|||
|
|
SerialConfig serialConfig;
|
|||
|
|
|
|||
|
|
// 显式赋值构造函数,确保正确的深拷贝
|
|||
|
|
ConfigResult& operator=(const ConfigResult& other) {
|
|||
|
|
if (this != &other) {
|
|||
|
|
binocularMarkConfig = other.binocularMarkConfig;
|
|||
|
|
epicEyeDeviceList = other.epicEyeDeviceList;
|
|||
|
|
debugParam = other.debugParam;
|
|||
|
|
serialConfig = other.serialConfig;
|
|||
|
|
}
|
|||
|
|
return *this;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 显式复制构造函数
|
|||
|
|
ConfigResult(const ConfigResult& other)
|
|||
|
|
: binocularMarkConfig(other.binocularMarkConfig)
|
|||
|
|
, epicEyeDeviceList(other.epicEyeDeviceList)
|
|||
|
|
, debugParam(other.debugParam)
|
|||
|
|
, serialConfig(other.serialConfig) {
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
// 默认构造函数
|
|||
|
|
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
|