#include "stdafx.h" #include "DetectorConfiguration.h" #include "Detector_Model_Def.h" DetectorConfiguration::DetectorConfiguration(string ConfigPath) { m_strConfigPath = ConfigPath; } DetectorConfiguration::~DetectorConfiguration() { } bool DetectorConfiguration::LoadConfigurations(DeviceIndexStruct & DeviceConf, ResDataObject & ACQMODElist) { if (!m_ConfigAll.loadFile(m_strConfigPath.c_str())) { printf( "Load configuration file failed!!! \n"); //mLog::Error("load {$} fail!", m_strConfigPath); return false; } try { m_Configurations = m_ConfigAll["CONFIGURATION"]; DeviceConf.strDeviceName = (string)m_Configurations[DetectorDescription]; int maxImageSize = 0; int nModeCount = (int)m_Configurations["ModeTable"].GetKeyCount("DetectorMode"); for (int i = 0; i < nModeCount; i++) { DeviceConf.nRawWidth = m_Configurations["ModeTable"][i]["RawImgWidth"]; DeviceConf.nRawHeight = m_Configurations["ModeTable"][i]["RawImgHeight"]; DeviceConf.nFullImageWidth = m_Configurations["ModeTable"][i]["ImageWidth"]; DeviceConf.nFullImageHeight = m_Configurations["ModeTable"][i]["ImageHeight"]; DeviceConf.fPixelSpace = m_Configurations["ModeTable"][i]["PixelPitch"]; DeviceConf.nImageBits = (int)m_Configurations["ModeTable"][i]["PhySizeInfoBit"]; DeviceConf.nDoseOfEXI = (int)m_Configurations["ModeTable"][i]["Sensitivity"]; DeviceConf.nSyncMode = (int)m_Configurations["ModeTable"][i]["SyncType"]; if (DeviceConf.nRawWidth * DeviceConf.nRawHeight > maxImageSize) { maxImageSize = DeviceConf.nRawWidth * DeviceConf.nRawHeight; DeviceConf.nMaxImageWidth = DeviceConf.nRawWidth; DeviceConf.nMaxImageHeight = DeviceConf.nRawHeight; } } //mLog::Info("DeviceConf.nMaxImageWidth:{$},DeviceConf.nMaxImageHeight:{$}", DeviceConf.nMaxImageWidth, DeviceConf.nMaxImageHeight); } catch (ResDataObjectExption &e) { printf("Get config error: %s \r\n", e.what()); //mLog::Error("Get config error: {$}", e.what()); return false; } return true; } bool DetectorConfiguration::SaveConfig() { try { m_ConfigAll["CONFIGURATION"] = m_Configurations; } catch (...) { return false; } return m_ConfigAll.SaveFile((m_strConfigPath).c_str()); } bool DetectorConfiguration::LoadCalibrationDose(string& strWorkPath, ResDataObject& CalibDoseList, int& nCalibTotalExpNum) { ResDataObject RdoCalibDoseList; try { string strCalibDosePath = strWorkPath + (string)m_Configurations["CalibrationDosePath"] + "\\CalibrationDose_CareRay.xml"; //mLog::Info("start load calibDose file: {$}", strCalibDosePath); struct stat buffer; if (stat(strCalibDosePath.c_str(), &buffer) == 0) { RdoCalibDoseList.loadFile(strCalibDosePath.c_str()); CalibDoseList = RdoCalibDoseList["List"]; //mLog::Info("CalibDoseList: {$} ", CalibDoseList.encode()); for (int i = 0; i < CalibDoseList.size(); i++) { ResDataObject temp = CalibDoseList[i]; int nExpNum = temp["ExpNum"]; nCalibTotalExpNum += nExpNum; ////mLog::Info("temp: {$} ", temp.encode()); } } else { //mLog::Error("{$} file not exist!", strCalibDosePath); return false; } } catch (exception e) { //mLog::Error("Get calibDose error: {$}", e.what()); return false; } return true; }