2025-11-01 17:39:39 +08:00
|
|
|
|
#include "ConfigManager.h"
|
|
|
|
|
|
#include "VrLog.h"
|
2025-11-26 22:44:38 +08:00
|
|
|
|
#include "VrError.h"
|
2025-11-01 17:39:39 +08:00
|
|
|
|
|
2025-11-26 22:44:38 +08:00
|
|
|
|
// Workpiece 应用的 ConfigManager 实现
|
|
|
|
|
|
// 所有通用功能都在 BaseConfigManager 中实现
|
|
|
|
|
|
// 这里只实现 Workpiece 特定的功能
|
2025-11-01 17:39:39 +08:00
|
|
|
|
|
2025-11-26 22:44:38 +08:00
|
|
|
|
// 实现 LoadConfigFromFile 以适配 Workpiece 的 IVrConfig API
|
|
|
|
|
|
// Workpiece 使用引用参数方式:int LoadConfig(const std::string& filePath, ConfigResult& configResult)
|
2025-11-01 17:39:39 +08:00
|
|
|
|
bool ConfigManager::LoadConfigFromFile(const std::string& filePath)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!m_pVrConfig) {
|
|
|
|
|
|
LOG_ERROR("VrConfig instance not available\n");
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
ConfigResult configResult;
|
|
|
|
|
|
|
2025-11-26 22:44:38 +08:00
|
|
|
|
// Workpiece 使用引用参数方式
|
|
|
|
|
|
int ret = m_pVrConfig->LoadConfig(filePath, configResult);
|
|
|
|
|
|
if (ret != SUCCESS) {
|
|
|
|
|
|
LOG_ERROR("Failed to load config from file: %s, error: %d\n", filePath.c_str(), ret);
|
2025-11-01 17:39:39 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-26 22:44:38 +08:00
|
|
|
|
// 使用基类的公共逻辑应用配置
|
|
|
|
|
|
return _ApplyLoadedConfig(configResult, filePath);
|
2025-11-01 17:39:39 +08:00
|
|
|
|
|
2025-11-26 22:44:38 +08:00
|
|
|
|
} catch (const std::exception& e) {
|
|
|
|
|
|
LOG_ERROR("Failed to load configuration from file %s: %s\n", filePath.c_str(), e.what());
|
2025-11-01 17:39:39 +08:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-11-26 22:44:38 +08:00
|
|
|
|
bool ConfigManager::OnSwitchWorkPositionCommand(const SwitchWorkPositionParam& param)
|
2025-11-01 17:39:39 +08:00
|
|
|
|
{
|
2025-11-26 22:44:38 +08:00
|
|
|
|
LOG_INFO("Workpiece: Received switch work position command: workPositionId=%s\n", param.workPositionId);
|
2025-11-01 17:39:39 +08:00
|
|
|
|
|
2025-11-26 22:44:38 +08:00
|
|
|
|
// Workpiece 应用特有的工作点切换逻辑
|
|
|
|
|
|
// 这里需要根据实际需求实现工作点切换
|
|
|
|
|
|
// 可能需要:
|
|
|
|
|
|
// 1. 重新加载不同的配置文件
|
|
|
|
|
|
// 2. 更新算法参数
|
|
|
|
|
|
// 3. 切换检测区域
|
|
|
|
|
|
// 4. 更新标定矩阵
|
|
|
|
|
|
// 5. 通知UI更新
|
2025-11-01 17:39:39 +08:00
|
|
|
|
|
2025-11-26 22:44:38 +08:00
|
|
|
|
// TODO: 实现具体的工作点切换逻辑
|
2025-11-01 17:39:39 +08:00
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|