54 lines
1.5 KiB
C++
54 lines
1.5 KiB
C++
#include "ConfigManager.h"
|
|
|
|
#include "PathManager.h"
|
|
#include "VrError.h"
|
|
#include "VrLog.h"
|
|
|
|
bool ConfigManager::Initialize(const std::string& configFilePath)
|
|
{
|
|
LOG_INFO("ConfigManager initializing for ParkingSpaceGuideApp...\n");
|
|
|
|
if (configFilePath.empty()) {
|
|
m_configFilePath = PathManager::GetInstance().GetConfigFilePath().toStdString();
|
|
} else {
|
|
m_configFilePath = configFilePath;
|
|
}
|
|
|
|
if (!IVrConfig::CreateInstance(&m_pVrConfig) || !m_pVrConfig) {
|
|
LOG_ERROR("Failed to create VrConfig instance\n");
|
|
return false;
|
|
}
|
|
|
|
if (!LoadConfigFromFile(m_configFilePath)) {
|
|
LOG_WARNING("Failed to load ParkingSpaceGuide config, using defaults\n");
|
|
_InitializeDefaultConfig();
|
|
}
|
|
|
|
LOG_INFO("ConfigManager initialized for ParkingSpaceGuideApp\n");
|
|
return true;
|
|
}
|
|
|
|
bool ConfigManager::LoadConfigFromFile(const std::string& filePath)
|
|
{
|
|
if (!m_pVrConfig) {
|
|
LOG_ERROR("VrConfig instance not available\n");
|
|
return false;
|
|
}
|
|
|
|
ConfigResult configResult;
|
|
const int ret = m_pVrConfig->LoadConfig(filePath, configResult);
|
|
if (ret != LOAD_CONFIG_SUCCESS) {
|
|
LOG_ERROR("Failed to load ParkingSpaceGuide config: %s, error=%d\n", filePath.c_str(), ret);
|
|
return false;
|
|
}
|
|
|
|
configResult.Normalize();
|
|
return _ApplyLoadedConfig(configResult, filePath);
|
|
}
|
|
|
|
bool ConfigManager::OnSwitchWorkPositionCommand(const SwitchWorkPositionParam& param)
|
|
{
|
|
LOG_INFO("ParkingSpaceGuide switch work position command: %s\n", param.workPositionId);
|
|
return true;
|
|
}
|