123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- #include "stdafx.h"
- #include "DetectorConfiguration.h"
- #include "Detector_Model_Def.h"
- #include "common_api.h"
- extern Log4CPP::Logger* gLogger;
- DetectorConfiguration::DetectorConfiguration(string ConfigPath)
- {
- m_strConfigPath = ConfigPath;
- }
- DetectorConfiguration::~DetectorConfiguration()
- {
- }
- bool DetectorConfiguration::LoadConfigurations(DeviceIndexStruct & DeviceConf, ResDataObject & ACQMODElist)
- {
- Info("LoadConfigurations m_strConfigPath:{$}", m_strConfigPath);
- if (!m_ConfigAll.loadFile((m_strConfigPath).c_str()))
- {
- return false;
- }
- try{
- m_Configurations = m_ConfigAll["CONFIGURATION"];
- TransferModuleJosnConfig2DriverConfig(m_Configurations);
- DeviceConf.strDeviceName = (string)m_Configurations[DetectorDescription];
- DeviceConf.nCalibModeNum = m_Configurations["CalibrationModeNum"];
- DeviceConf.nOffsetInterval = m_Configurations["OffsetInterval"];
- int nModeCount = m_Configurations["ModeTable"].size();
- FINFO("ModuleTable Count {$}", nModeCount);
- FINFO("DeviceName: {$}", DeviceConf.strDeviceName);
- 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.bSupportDDR = false;
- try
- {
- int nTemp = (int)m_Configurations["SupportDDR"];
- if (nTemp == 1)
- {
- DeviceConf.bSupportDDR = true;
- }
- }
- catch (...)
- {
- }
- }
- catch (ResDataObjectExption &e)
- {
- Error("Get config error, reason:{$}", 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)
- {
- ResDataObject RdoCalibDoseList;
- try
- {
- FINFO("Befor Load Got config {$}", m_Configurations.encode());
- string strCalibDosePath = strWorkPath + (string)m_Configurations["CalibrationDosePath"] + "\\CalibrationDose_Rayence.xml";
- Info("start load calibDose file: {$}", strCalibDosePath);
- struct stat buffer;
- if (stat(strCalibDosePath.c_str(), &buffer) == 0)
- {
- RdoCalibDoseList.loadFile(strCalibDosePath.c_str());
- CalibDoseList = RdoCalibDoseList["List"];
- Info("CalibDoseList: {$} ", CalibDoseList.encode());
- for (int i = 0; i < CalibDoseList.size(); i++)
- {
- ResDataObject temp = CalibDoseList[i];
- }
- }
- else
- {
- Error("{$} file not exist!", strCalibDosePath);
- return false;
- }
- }
- catch (exception e)
- {
- Error("Get calibDose error: {$}", e.what());
- return false;
- }
- return true;
- }
- bool DetectorConfiguration::LoadDetectorMode(string& strWorkPath, ResDataObject& DetectorModeList)
- {
- ResDataObject RdoDetectorModeList;
- try
- {
- string strDetectorModePath = strWorkPath + (string)m_Configurations["DetectorModePath"] + "\\DetectorModes" + (string)m_Configurations["ProductID"] + ".xml";
- Info("start load detector mode file: {$}", strDetectorModePath);
- struct stat buffer;
- if (stat(strDetectorModePath.c_str(), &buffer) == 0)
- {
- RdoDetectorModeList.loadFile(strDetectorModePath.c_str());
- DetectorModeList = RdoDetectorModeList["List"];
- Info("DetectorModeList: {$} ", DetectorModeList.encode());
- }
- else
- {
- Error("{$} file not exist!", strDetectorModePath);
- return false;
- }
- }
- catch (exception e)
- {
- Error("load detector mode error: {$}", e.what());
- return false;
- }
- return true;
- }
|