#include "stdafx.h" #include "CCOS.Dev.FPDDeviceMould.hpp" #include "DetectorConfiguration.h" #include "Detector_Model_Def.h" #include "CCOSConfigurations.h" namespace nsFPD = CCOS::Dev::Detail::Detector; nsFPD::DetectorConfiguration::DetectorConfiguration(string ConfigPath) { m_strConfigPath = ConfigPath; } nsFPD::DetectorConfiguration::~DetectorConfiguration() { } bool nsFPD::DetectorConfiguration::LoadConfigurations(DeviceIndexStruct & DeviceConf, ResDataObject & ACQMODElist) { FINFO("LoadConfigurations start m_strConfigPath:{$}", m_strConfigPath.c_str()); if (!m_ConfigAll.loadFile(m_strConfigPath.c_str())) { FERROR("Load {$} failed!!!", m_strConfigPath.c_str()); return false; } try { int nModeCount = 0; //探测器采集模式总数 int nTemp = 0; m_Configurations = m_ConfigAll[NODE_CONFIGURATION]; auto Child_table = m_Configurations[NODE_ModeTable]; DeviceConf.strDeviceName = (string)m_Configurations[NODE_Description]; nModeCount = (int)Child_table.size(); if (nModeCount > 0) { DeviceConf.nDetModeCount = nModeCount; DeviceConf.pDetModeInfoStruct = new DetModeInfoStruct[nModeCount]; m_DeviceInfo.pDetModeInfoStruct = new DetModeInfoStruct[nModeCount]; //add by wxx for 万东:20230725 } for (int i = 0; i < nModeCount; i++) { //加载所有modeinfo到结构体 auto stChild = DeviceConf.pDetModeInfoStruct[i]; stChild.nLogicMode = (int)Child_table[i][NODE_LogicMode]; stChild.nImageWidth = (int)Child_table[i][NODE_ImageWidth]; stChild.nImageHeight = (int)Child_table[i][NODE_ImageHeight]; stChild.nWidthOffset = (int)Child_table[i][NODE_WidthOffset]; stChild.nHeightOffset = (int)Child_table[i][NODE_HeightOffset]; stChild.nRawImgWidth = (int)Child_table[i][NODE_RawImgWidth]; stChild.nRawImgHeight = (int)Child_table[i][NODE_RawImgHeight]; stChild.nPhySizeInfoBit = (int)Child_table[i][NODE_PhySizeInfoBit]; stChild.nSensitivity = (int)Child_table[i][NODE_Sensitivity]; nTemp = (int)Child_table[i][NODE_PreviewEnable]; if (0 == nTemp) { stChild.bPreviewEnable = false; } else { stChild.bPreviewEnable = true; } stChild.nPreviewWidth = (int)Child_table[i][NODE_PreviewWidth]; stChild.nPreviewHeight = (int)Child_table[i][NODE_PreviewHeight]; FINFO("i={$},nLogicMode={$},nRawImgWidth={$},nRawImgHeight={$},nImageWidth={$},nImageHeight={$}", i, stChild.nLogicMode, stChild.nRawImgWidth, stChild.nRawImgHeight, stChild.nImageWidth, stChild.nImageHeight); stChild.nPixelPitch = (int)Child_table[i][NODE_PixelPitch]; stChild.nSyncType = (int)Child_table[i][NODE_SyncType]; stChild.nXwindow = (int)Child_table[i][NODE_XwindowSize]; stChild.nIsSaveRaw = (int)Child_table[i][NODE_IsSaveRaw]; stChild.nRotateAngle = (int)Child_table[i][NODE_RotateAngle]; stChild.nBinningDx = (int)Child_table[i][NODE_BinningX]; stChild.nBinningDy = (int)Child_table[i][NODE_BinningY]; stChild.nGainValue = (int)Child_table[i][NODE_GainValue]; stChild.nFrequency = (int)Child_table[i][NODE_Frequency]; stChild.nFrameCount = (int)Child_table[i][NODE_FrameCount]; stChild.nWorkStation = (int)Child_table[i][NODE_WorkStation]; //获取所有模式中最大图像尺寸,用于申请共享内存 if (stChild.nImageWidth * stChild.nImageHeight > DeviceConf.nMaxImgWidth * DeviceConf.nMaxImgHeight) { DeviceConf.nMaxImgWidth = stChild.nImageWidth; DeviceConf.nMaxImgHeight = stChild.nImageHeight; } //加载采集模式到acqmodelist,用于反馈给上层(目前还没反馈) ResDataObject mode; mode.add(CcosAcqModeIdx, stChild.nLogicMode); mode.add(CcosAcqModeName, stChild.nLogicMode); mode.add(CcosImageWidth, stChild.nImageWidth); mode.add(CcosImageHeight, stChild.nImageHeight); mode.add(CcosImageBits, stChild.nPhySizeInfoBit); mode.add(CcosGainTitle, stChild.nGainValue); mode.add(CcosBinningX, stChild.nBinningDx); mode.add(CcosBinningY, stChild.nBinningDy); mode.add(CcosFrameRate, stChild.nFrequency); mode.add(CcosImagePixelSpacing, stChild.nPixelPitch); mode.add(CcosImageFPDSensitivity, stChild.nSensitivity); ACQMODElist.add(NODE_DetectorMode, mode); //加载校正配置 int nNodeCount = 0; //校正曝光节点总数 auto Child_Calib = m_Configurations[NODE_ModeTable][i][NODE_CalibConfig]; nNodeCount = (int)Child_Calib.GetKeyCount(NODE_NodeInfo); if (nNodeCount > 0) { DeviceConf.stDetCalibInfo.nDetCalibNodeCount = nNodeCount; DeviceConf.stDetCalibInfo.pDetCalibNodeInfo = new DetCalibNodeInfo[nNodeCount]; } for (int j = 0; j < nNodeCount; j++) { auto stChild = DeviceConf.stDetCalibInfo.pDetCalibNodeInfo[j]; stChild.nImgCount = (int)Child_Calib[j][NODE_ImgCount]; stChild.fDose = (float)Child_Calib[j][NODE_Dose]; } m_DeviceInfo.pDetModeInfoStruct[i] = stChild;//add by wxx for 万东:20230725 } //end for DeviceConf.fTemperMaxLimit = (float)m_Configurations[ConfKey::CcosTempMaxLimit]; DeviceConf.fTemperMaxWarn = (float)m_Configurations[ConfKey::CcosTempUpperLimit]; DeviceConf.fTemperLowLimit = (float)m_Configurations[ConfKey::CcosTempLowerLimit]; DeviceConf.fTemperMinWarn = (float)m_Configurations[ConfKey::CcosTempMinLimit]; DeviceConf.nBatteryWarning = (int)m_Configurations[ConfKey::CcosBatLowerLimit]; DeviceConf.nBatteryLimit = (int)m_Configurations[ConfKey::CcosBatMiniLimit]; DeviceConf.nWifiWarning = (int)m_Configurations[ConfKey::CcosWifiLowerLimit]; DeviceConf.nWifiLimit = (int)m_Configurations[ConfKey::CcosWifiMiniLimit]; DeviceConf.strCalibrationDate = (string)m_Configurations["DateofLastDetectorCalibration"]; DeviceConf.strCalibrationTime = (string)m_Configurations["TimeofLastDetectorCalibration"]; DeviceConf.fSid = (float)m_Configurations[NODE_SID]; DeviceConf.fSod = (float)m_Configurations[NODE_SOD]; DeviceConf.fAmplificationFactor = (float)m_Configurations[NODE_AmplificationFactor]; m_DeviceInfo = DeviceConf; } catch (ResDataObjectExption &e) { printf("Get config error: %s \r\n", e.what()); return false; } FINFO("LoadConfigurations over"); return true; } /*** * 根据nMode,获取对应的ModeInfo * nMode: 上层下发的AcqMode index ***/ bool nsFPD::DetectorConfiguration::GetDetModeInfo(DetModeInfoStruct& DetModeInfo, DetCalibInfo& DetCalibInfo, int nMode) { bool bFind = false; for (int i = 0; i < m_DeviceInfo.nDetModeCount; i++) { auto stChild = m_DeviceInfo.pDetModeInfoStruct[i]; if (nMode == stChild.nLogicMode) { DetModeInfo = m_DeviceInfo.pDetModeInfoStruct[i]; DetCalibInfo = m_DeviceInfo.stDetCalibInfo; bFind = true; break; } } return bFind; } bool nsFPD::DetectorConfiguration::SaveConfig() { try { m_ConfigAll["CONFIGURATION"] = m_Configurations; } catch (...) { return false; } return m_ConfigAll.SaveFile((m_strConfigPath).c_str()); }