DetectorConfiguration.cpp 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #include "stdafx.h"
  2. #include "DetectorConfiguration.h"
  3. #include "Detector_Model_Def.h"
  4. #include "common_api.h"
  5. extern Log4CPP::Logger* //mLog::gLogger;
  6. DetectorConfiguration::DetectorConfiguration(string ConfigPath)
  7. {
  8. m_strConfigPath = ConfigPath;
  9. }
  10. DetectorConfiguration::~DetectorConfiguration()
  11. {
  12. }
  13. bool DetectorConfiguration::LoadConfigurations(DeviceIndexStruct & DeviceConf, ResDataObject & ACQMODElist)
  14. {
  15. //mLog::Info("LoadConfigurations m_strConfigPath:{$}", m_strConfigPath);
  16. if (!m_ConfigAll.loadFile((m_strConfigPath).c_str()))
  17. {
  18. return false;
  19. }
  20. try{
  21. m_Configurations = m_ConfigAll["CONFIGURATION"];
  22. TransferModuleJosnConfig2DriverConfig(m_Configurations);
  23. DeviceConf.strDeviceName = (string)m_Configurations[DetectorDescription];
  24. DeviceConf.nCalibModeNum = m_Configurations["CalibrationModeNum"];
  25. DeviceConf.nOffsetInterval = m_Configurations["OffsetInterval"];
  26. int nModeCount = m_Configurations["ModeTable"].size();
  27. //mLog::FINFO("ModuleTable Count {$}", nModeCount);
  28. //mLog::FINFO("DeviceName: {$}", DeviceConf.strDeviceName);
  29. for (int i = 0; i < nModeCount; i++)
  30. {
  31. DeviceConf.nRawWidth = m_Configurations["ModeTable"][i]["RawImgWidth"];
  32. DeviceConf.nRawHeight = m_Configurations["ModeTable"][i]["RawImgHeight"];
  33. DeviceConf.nFullImageWidth = m_Configurations["ModeTable"][i]["ImageWidth"];
  34. DeviceConf.nFullImageHeight = m_Configurations["ModeTable"][i]["ImageHeight"];
  35. DeviceConf.fPixelSpace = m_Configurations["ModeTable"][i]["PixelPitch"];
  36. DeviceConf.nImageBits = (int)m_Configurations["ModeTable"][i]["PhySizeInfoBit"];
  37. DeviceConf.nDoseOfEXI = (int)m_Configurations["ModeTable"][i]["Sensitivity"];
  38. }
  39. DeviceConf.bSupportDDR = false;
  40. try
  41. {
  42. int nTemp = (int)m_Configurations["SupportDDR"];
  43. if (nTemp == 1)
  44. {
  45. DeviceConf.bSupportDDR = true;
  46. }
  47. }
  48. catch (...)
  49. {
  50. }
  51. }
  52. catch (ResDataObjectExption &e)
  53. {
  54. //mLog::Error("Get config error, reason:{$}", e.what());
  55. return false;
  56. }
  57. return true;
  58. }
  59. bool DetectorConfiguration::SaveConfig()
  60. {
  61. try{
  62. m_ConfigAll["CONFIGURATION"] = m_Configurations;
  63. }
  64. catch (...)
  65. {
  66. return false;
  67. }
  68. return m_ConfigAll.SaveFile((m_strConfigPath).c_str());
  69. }
  70. bool DetectorConfiguration::LoadCalibrationDose(string& strWorkPath, ResDataObject& CalibDoseList)
  71. {
  72. ResDataObject RdoCalibDoseList;
  73. try
  74. {
  75. //mLog::FINFO("Befor Load Got config {$}", m_Configurations.encode());
  76. string strCalibDosePath = strWorkPath + (string)m_Configurations["CalibrationDosePath"] + "\\CalibrationDose_Rayence.xml";
  77. //mLog::Info("start load calibDose file: {$}", strCalibDosePath);
  78. struct stat buffer;
  79. if (stat(strCalibDosePath.c_str(), &buffer) == 0)
  80. {
  81. RdoCalibDoseList.loadFile(strCalibDosePath.c_str());
  82. CalibDoseList = RdoCalibDoseList["List"];
  83. //mLog::Info("CalibDoseList: {$} ", CalibDoseList.encode());
  84. for (int i = 0; i < CalibDoseList.size(); i++)
  85. {
  86. ResDataObject temp = CalibDoseList[i];
  87. }
  88. }
  89. else
  90. {
  91. //mLog::Error("{$} file not exist!", strCalibDosePath);
  92. return false;
  93. }
  94. }
  95. catch (exception e)
  96. {
  97. //mLog::Error("Get calibDose error: {$}", e.what());
  98. return false;
  99. }
  100. return true;
  101. }
  102. bool DetectorConfiguration::LoadDetectorMode(string& strWorkPath, ResDataObject& DetectorModeList)
  103. {
  104. ResDataObject RdoDetectorModeList;
  105. try
  106. {
  107. string strDetectorModePath = strWorkPath + (string)m_Configurations["DetectorModePath"] + "\\DetectorModes" + (string)m_Configurations["ProductID"] + ".xml";
  108. //mLog::Info("start load detector mode file: {$}", strDetectorModePath);
  109. struct stat buffer;
  110. if (stat(strDetectorModePath.c_str(), &buffer) == 0)
  111. {
  112. RdoDetectorModeList.loadFile(strDetectorModePath.c_str());
  113. DetectorModeList = RdoDetectorModeList["List"];
  114. //mLog::Info("DetectorModeList: {$} ", DetectorModeList.encode());
  115. }
  116. else
  117. {
  118. //mLog::Error("{$} file not exist!", strDetectorModePath);
  119. return false;
  120. }
  121. }
  122. catch (exception e)
  123. {
  124. //mLog::Error("load detector mode error: {$}", e.what());
  125. return false;
  126. }
  127. return true;
  128. }