#include "stdafx.h" #include "FileVersion.hpp" #include "CCOS.Dev.FPD.CareRayRF.h" #include "common_api.h" #include "DICOMImageHeadKey.h" #include "Detector_CareRayRF.h" #include namespace nsFPD = CCOS::Dev::Detail::Detector; static nsFPD::CareRayDriver gIODriver; Log4CPP::Logger* //mLog::gLogger = nullptr; extern Detector_CareRayRF* g_pDetector; extern const char* g_szMouldPath; extern "C" CCOS::Dev::IODriver * __cdecl GetIODriver() // 返回静态对象的引用, 调用者不能删除 ! { return &gIODriver; } extern "C" CCOS::Dev::IODriver * __cdecl CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 ! { return new nsFPD::CareRayDriver(); } nsFPD::CareRayDriver::CareRayDriver() { pObjDev = nullptr; m_bDriverConnect = false; //缺省为false m_pAttribute.reset(new ResDataObject()); m_pDescription.reset(new ResDataObject()); } nsFPD::CareRayDriver::~CareRayDriver() { if (pObjDev != nullptr) { delete pObjDev; pObjDev = nullptr; } //mLog::Close(); Log4CPP::ThreadContext::Map::Clear(); //mLog::gLogger = nullptr; } void nsFPD::CareRayDriver::Prepare() { printf("--Driver-- prepare \r\n"); string strLogPath = GetProcessDirectory() + R"(\Conf\Log4CPP.Config.xml)"; auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str()); //mLog::gLogger = Log4CPP::LogManager::GetLogger("Module"); //mLog::FINFO("Code Build datetime [{$} {$}]", __DATE__, __TIME__); #ifdef _WIN64 //mLog::FINFO("=============================Version: {$} (64-bit)==================================", FileVersion(g_szMouldPath).GetVersionString()); #else //mLog::FINFO("=============================Version: {$} (32-bit)==================================", FileVersion(g_szMouldPath).GetVersionString()); #endif //mLog::FINFO("Driver Prepare get logger"); } bool nsFPD::CareRayDriver::Connect() { printf("--Func-- driver connect \r\n"); //mLog::FINFO("--Func-- driver connect"); pObjDev = new FPDDeviceCareRay(EventCenter, m_ConfigFileName); m_bDriverConnect = true; //connect执行完毕,置为true printf("CareRayRF driver module: Connect over\r\n"); return true; } void nsFPD::CareRayDriver::Disconnect() { printf("--Func-- driver disconnect \r\n"); //mLog::FINFO("--Func-- driver disconnect"); if (pObjDev != nullptr) { delete pObjDev; pObjDev = nullptr; } m_bDriverConnect = false; } bool nsFPD::CareRayDriver::isConnected() const { return m_bDriverConnect; } auto nsFPD::CareRayDriver::CreateDevice(int index)->std::unique_ptr { printf("--Func-- driver createdevice \r\n"); //mLog::FINFO("--Func-- driver createdevice \n"); auto Device = std::unique_ptr(new IODevice(pObjDev)); pObjDev->CreateDevice(); pObjDev->Register(); return Device; } std::string nsFPD::CareRayDriver::DriverProbe() { printf("--Func-- driver DriverProbe \r\n"); //mLog::FINFO("--Func-- driver DriverProbe \n"); ResDataObject r_config, HardwareInfo; if (r_config.loadFile(m_ConfigFileName.c_str())) { HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]); HardwareInfo.add("MinorID", r_config["CONFIGURATION"]["MinorID"]); HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]); HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]); HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]); } else { HardwareInfo.add("MajorID", "Detector"); HardwareInfo.add("MinorID", "RF"); HardwareInfo.add("VendorID", "CareRay"); HardwareInfo.add("ProductID", "CareRay"); HardwareInfo.add("SerialID", "Driver"); } string str = HardwareInfo.encode(); return str; } /*** ** 获取ID和配置 ***/ std::string nsFPD::CareRayDriver::GetResource() { printf("--Func-- driver GetResource \r\n"); //mLog::FINFO("--Func-- driver GetResource"); ResDataObject r_config, temp; if (!temp.loadFile(m_ConfigFileName.c_str())) { //mLog::FERROR("load file error! file name:{$}",m_ConfigFileName.c_str()); return ""; } m_ConfigAll = temp; r_config = temp["CONFIGURATION"]; m_Configurations = r_config; ResDataObject DescriptionTemp; ResDataObject ListTemp; string strTemp = ""; //用于读取字符串配置信息 string strIndex = ""; //用于读取配置信息中的List项 int nTemp = -1; //用于读取整型配置信息 char sstream[10] = { 0 }; //用于转换值 string strValue = ""; //用于存储配置的值 string strType = ""; //用于存储配置的类型 int/float/string... /*** * 1. 通过循环,将所有配置项写到pDeviceConfig * 2. 记录配置项的内部key以及配置类型,类型对应了不同配置文件路径,用于读写真实值 ***/ try { int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo"); ////mLog::FINFO(g_pFPDCtrlLog, "ConfigInfo Count: {$}", nConfigInfoCount); m_pAttribute->clear(); m_pDescription->clear(); for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++) { DescriptionTemp.clear(); ListTemp.clear(); //AttributeType strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Type"]; DescriptionTemp.add(AttributeType, strTemp.c_str()); ////mLog::FINFO(g_pFPDCtrlLog, "--> {$}: {$}", AttributeType, strTemp.c_str()); strType = strTemp; //记录配置项的类型 //AttributeKey //1. 根据AttributeType,内部key和配置路径,拿到当前的真实值 strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"]; nTemp = (int)m_Configurations["ConfigToolInfo"][nInfoIndex]["PathID"]; GetDeviceConfigValue(r_config, strTemp.c_str(), nTemp, strValue); //2. 赋值 strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"]; if ("int" == strType) { (*m_pAttribute).add(strTemp.c_str(), atoi(strValue.c_str())); ////mLog::FINFO(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), atoi(strValue.c_str())); } else if ("float" == strType) { (*m_pAttribute).add(strTemp.c_str(), atof(strValue.c_str())); ////mLog::FINFO(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), atof(strValue.c_str())); } else //其它先按string类型处理 { (*m_pAttribute).add(strTemp.c_str(), strValue.c_str()); ////mLog::FINFO(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), strValue.c_str()); } //AttributeAccess strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Access"]; DescriptionTemp.add(AttributeAccess, strTemp.c_str()); ////mLog::FINFO(g_pFPDCtrlLog, "{$}: {$}", AttributeAccess, strTemp.c_str()); //AttributeRangeMin strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMin"]; if (strTemp != "") //不需要的配置项为空 { DescriptionTemp.add(AttributeRangeMin, strTemp.c_str()); ////mLog::FINFO(g_pFPDCtrlLog, "{$}: {$}", AttributeRangeMin, strTemp.c_str()); } //AttributeRangeMax strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMax"]; if (strTemp != "") //不需要的配置项为空 { DescriptionTemp.add(AttributeRangeMax, strTemp.c_str()); ////mLog::FINFO(g_pFPDCtrlLog, "{$}: {$}", AttributeRangeMax, strTemp.c_str()); } //AttributeList nTemp = m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListNum"]; if (nTemp > 0) //ListNum不大于0时说明不需要list配置 { for (int nListIndex = 0; nListIndex < nTemp; nListIndex++) { strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListInfo"][nListIndex]; //sprintf_s(sstream, "{$}", nListIndex); auto temKey = std::to_string(nListIndex); ListTemp.add(temKey.c_str(), strTemp.c_str()); ////mLog::FINFO(g_pFPDCtrlLog, "list {$}: {$}", nListIndex, strTemp.c_str()); } DescriptionTemp.add(AttributeList, ListTemp); } //AttributeRequired strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Required"]; DescriptionTemp.add(AttributeRequired, strTemp.c_str()); ////mLog::FINFO(g_pFPDCtrlLog, "{$}: {$}", AttributeRequired, strTemp.c_str()); //AttributeDefaultValue strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["DefaultValue"]; if (strTemp != "") //不需要的配置项为空 { DescriptionTemp.add(AttributeDefaultValue, strTemp.c_str()); ////mLog::FINFO(g_pFPDCtrlLog, "{$}: {$}", AttributeDefaultValue, strTemp.c_str()); } strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"]; (*m_pDescription).add(strTemp.c_str(), DescriptionTemp); } } catch (exception e) { //mLog::FERROR("Get config error: {$}", e.what()); return ""; } ResDataObject resDeviceResource; resDeviceResource.add(ConfKey::CcosDetectorAttribute, (*m_pAttribute)); resDeviceResource.add(ConfKey::CcosDetectorDescription, (*m_pDescription)); ResDataObject DescriptionTempEx; DescriptionTempEx.add(ConfKey::CcosDetectorConfig, resDeviceResource); m_DeviceConfig = DescriptionTempEx; string res = DescriptionTempEx.encode(); printf("CareRayRF driver module: get resource over \r\n"); ////mLog::FINFO("get resource over {$}", res.c_str());//此处在调试读取配置的时候再放开,不然打印很长查日志不方便 //mLog::FINFO("get resource over!"); return res; } std::string nsFPD::CareRayDriver::DeviceProbe() { printf("--Func-- driver DeviceProbe \r\n"); //mLog::FINFO("--Func-- driver DeviceProbe \n"); ResDataObject r_config, HardwareInfo; if (r_config.loadFile(m_ConfigFileName.c_str())) { HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]); HardwareInfo.add("MinorID", "Device"); HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]); HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]); HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]); } else { HardwareInfo.add("MajorID", "Detector"); HardwareInfo.add("MinorID", "Device"); HardwareInfo.add("VendorID", "CareRay"); HardwareInfo.add("ProductID", "CareRay"); HardwareInfo.add("SerialID", "1234"); } string str = HardwareInfo.encode(); return str; } bool nsFPD::CareRayDriver::GetDeviceConfig(std::string& Cfg) { printf("--Func-- driver GetDeviceConfig \r\n"); //mLog::FINFO("--Func-- driver GetDeviceConfig \n"); Cfg = m_DeviceConfig.encode(); //mLog::FINFO("GetDeviceConfig over"); return true; } bool nsFPD::CareRayDriver::SetDeviceConfig(std::string Cfg) { printf("--Func-- driver SetDeviceConfig \r\n"); //mLog::FINFO("--Func-- SetDeviceConfig {$}", Cfg.c_str()); ResDataObject DeviceConfig; DeviceConfig.decode(Cfg.c_str()); ResDataObject DescriptionTempEx; DescriptionTempEx = DeviceConfig["DeviceConfig"]; bool bSaveFile = false; //true:重新保存配置文件 string strAccess = ""; for (int i = 0; i < DescriptionTempEx.size(); i++) { ResDataObject temp = DescriptionTempEx[i]; //mLog::FINFO("{$}", temp.encode()); for (int j = 0; j < temp.size(); j++) { string strKey = temp.GetKey(j); //mLog::FINFO("{$}", strKey.c_str()); try { if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0) { strAccess = (string)(*m_pDescription)[strKey.c_str()]["Access"]; if ("RW" == strAccess || "rw" == strAccess) { //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值 //1. 修改内存中的值,用于给上层发消息 (*m_pAttribute)[strKey.c_str()] = temp[j]; //2. 拿到Innerkey int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo"); //mLog::FINFO("ConfigInfo Count: {$}", nConfigInfoCount); string strTemp = ""; //存储AttributeKey for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++) { strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"]; if (strTemp == strKey) { strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"]; break; } } //3. 修改配置文件中的值 if (SetDeviceConfigValue(m_Configurations, strTemp.c_str(), 1, temp[j])) { bSaveFile = true; } } else { //mLog::FINFO("{$} is not a RW configuration item", strKey.c_str()); } } } catch (ResDataObjectExption& e) { //mLog::FERROR("SetDriverConfig crashed: {$}", e.what()); return false; } } } if (bSaveFile) { //3. 重新保存配置文件 SaveConfigFile(true); } return true; } bool nsFPD::CareRayDriver::SaveConfigFile(bool bSendNotify) { //mLog::FINFO("SaveConfigFile start m_ConfigFileName:{$}", m_ConfigFileName); m_ConfigAll["CONFIGURATION"] = m_Configurations; m_ConfigAll.SaveFile(m_ConfigFileName.c_str()); //mLog::FINFO("SaveConfigFile over"); return true; } bool nsFPD::CareRayDriver::GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue) { //strValue = ""; //string strTemp = pInnerKey; //if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取 //{ // if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp) // { // strValue = (string)config["connections"][pInnerKey]; // } // else if (DetectorVender == strTemp || DetectorModel == strTemp || // DetectorDescription == strTemp || DetectorSerialNumber == strTemp) // { // strValue = (string)config[pInnerKey]; // } // else if (SyncType == strTemp || FPDWorkStation == strTemp || OperationMode == strTemp || ExamType == strTemp || ExiThreshold == strTemp || // ImageWidth == strTemp || ImageHeight == strTemp || RawImgWidth == strTemp || RawImgHeight == strTemp) // { // strValue = (string)config["ModeTable"]["DetectorMode"][pInnerKey]; // } // else if (TempMaxLimit == strTemp || ReConnect == strTemp || // TempUpperLimit == strTemp || TempLowerLimit == strTemp || TempMinLimit == strTemp || // BatLowerLimit == strTemp || BatMiniLimit == strTemp || // BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp || // WifiMiniLimit == strTemp || HighPowerTimeout == strTemp || // ShowTemperature == strTemp || ShowWifi == strTemp || // ShowBattery == strTemp || ShowBluetooth == strTemp || // FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp || CcosDetectorAttachedFlag == strTemp) // { // strValue = (string)config[pInnerKey]; // } // else // { // strValue = ""; // //mLog::FERROR("Error Configuration item: {$}", pInnerKey); // } //} return true; } bool nsFPD::CareRayDriver::SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey, int nPathID, const char* szValue) { //string strTemp = pInnerKey; ////mLog::FINFO("Begin to change {$} item value to {$}", pInnerKey, szValue); //if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取 //{ // if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp) // { // config["connections"][pInnerKey] = szValue; // } // else if (DetectorVender == strTemp || DetectorModel == strTemp || // DetectorDescription == strTemp || DetectorSerialNumber == strTemp) // { // config[pInnerKey] = szValue; // } // else if (SyncType == strTemp || FPDWorkStation == strTemp || OperationMode == strTemp || ExamType == strTemp || ExiThreshold == strTemp || // ImageWidth == strTemp || ImageHeight == strTemp || RawImgWidth == strTemp || RawImgHeight == strTemp) // { // config["ModeTable"]["DetectorMode"][pInnerKey] = szValue; // } // else if (TempMaxLimit == strTemp || ReConnect == strTemp || // TempUpperLimit == strTemp || TempLowerLimit == strTemp || // BatLowerLimit == strTemp || BatMiniLimit == strTemp || // BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp || // WifiMiniLimit == strTemp || HighPowerTimeout == strTemp || // ShowTemperature == strTemp || ShowWifi == strTemp || // ShowBattery == strTemp || ShowBluetooth == strTemp || // FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp || CcosDetectorAttachedFlag == strTemp) // { // config[pInnerKey] = szValue; // } // else // { // //mLog::FERROR("Error Configuration item: {$}", pInnerKey); // return false; // } //} return true; } nsFPD::FPDDeviceCareRay::FPDDeviceCareRay(std::shared_ptr center,std::string strConfigPath) { m_strWorkPath = GetProcessDirectory(); m_nImageWidth = 0; m_nImageHeight = 0; m_nImgBits = 0; m_nAngle = 0; m_nPixelSpacing = 0; m_nSensitivity = 0; m_fDose = 0.0f; m_pImgBuffer = nullptr; m_eAppStatus = APP_STATUS_IDLE; m_bConnect = false; m_nCurrentAcqMode = 0; m_DetectorCtrlUnit.reset(new OemCtrl(center, this)); m_AcqUnit.reset(new OemAcq(center, this)); m_SyncUnit.reset(new OemSync(center, this)); m_CalibUnit.reset(new OemCalib(center, this)); m_DetectorConfiguration.reset(new DetectorConfiguration(strConfigPath)); m_WarnAndError.reset(new FPDErrorWarning(center, DetectorUnitType, m_strWorkPath)); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_INIT)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); EventCenter = center; m_vDetectorModeList.clear(); m_fCurrentPPS = 15.0f; m_fMaxFrameRate = 30.0f; m_vAcqModeInfoList.clear(); m_nImageIndex = 1; m_fFactorEXI2UGY = 0.0f; } nsFPD::FPDDeviceCareRay::~FPDDeviceCareRay() { //mLog::FINFO("~FPDDeviceCareRay"); if (nullptr != g_pDetector) { delete g_pDetector; g_pDetector = nullptr; } if (nullptr != m_pImgBuffer) { delete m_pImgBuffer; m_pImgBuffer = nullptr; } m_vDetectorModeList.clear(); m_vAcqModeInfoList.clear(); } std::string nsFPD::FPDDeviceCareRay::GetGUID() const { return DetectorUnitType; } bool nsFPD::FPDDeviceCareRay::Prepare() { printf("--Func-- device Prepare \r\n"); //mLog::FINFO("--Func-- device prepare nMaxImgWidth:{$},nMaxImgHeight:{$}", m_stDeviceConfig.nMaxImgWidth, m_stDeviceConfig.nMaxImgHeight); //blockname, fullimage blocksize, blockcount,previewimage blocksize,blockcount EventCenter->OnMaxBlockSize("CareRayRfQue",m_stDeviceConfig.nMaxImgWidth * m_stDeviceConfig.nMaxImgHeight * 2, 20, 1500 * 1500 * 2, 1); Connect(); return true; } bool nsFPD::FPDDeviceCareRay::CreateDevice() { printf("--Func-- device CreateDevice \r\n"); //mLog::FINFO("--Func-- device CreateDevice \n"); if (!LoadConfig()) { return false; } if (nullptr == g_pDetector) { g_pDetector = new Detector_CareRayRF(); } g_pDetector->DriverEntry(this, m_DetectorConfiguration->m_Configurations); return true; } bool nsFPD::FPDDeviceCareRay::LoadConfig() { printf("--Func-- device LoadConfig \r\n"); //mLog::FINFO("--Func-- device LoadConfig start"); //LoadConfigurations必须比下边俩函数先调用,否则会有问题 if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_ACQMODElist, m_vAcqModeInfoList)) { //mLog::FERROR("Load configuration file failed!!!"); return false; } m_DetectorCtrlUnit->SetDetectorWidth(to_string(m_stDeviceConfig.nDetectorWidth)); m_DetectorCtrlUnit->SetDetectorHeight(to_string(m_stDeviceConfig.nDetectorHeight)); m_stDeviceConfig.nMaxImgWidth = m_stDeviceConfig.nDetectorWidth; m_stDeviceConfig.nMaxImgHeight = m_stDeviceConfig.nDetectorHeight; m_CalibUnit->SetOffsetInterval(to_string(m_stDeviceConfig.nOffsetInterval)); m_CalibUnit->SetOffsetStatus("Idle"); m_CalibUnit->SetOffsetProgress(to_string(0)); if (m_stDeviceConfig.bSupportDDR) //是否支持DDR采集功能 { m_DetectorCtrlUnit->SetSupportDDR("1"); } else { m_DetectorCtrlUnit->SetSupportDDR("0"); } //加载校正时使用的剂量文件 if (!m_DetectorConfiguration->LoadCalibrationDose(m_strWorkPath, m_CalibDoseList)) { //mLog::FERROR("Load Calibration Dose failed!!!"); return false; } m_DetectorCtrlUnit->SetTargetEXI("5000"); //const char* strkey, int initialvalue, int min, int WarnMin, int WarnMax, int CalibWarnMin, int CalibWarnMax, int max, int accuracy, std::shared_ptr EventCenter m_Battery.reset(new DeviceBatteryMould("DetectorBattery", 0, m_stDeviceConfig.nBatteryLimit, m_stDeviceConfig.nBatteryWarning, 90, 20, 90, 100, 0, EventCenter)); //const char* strkey, float initialvalue, float min, float WarnMin, float WarnMax, float CalibWarnMin, float CalibWarnMax, float max, float accuracy,std::shared_ptr EventCenter m_Temperature.reset(new DeviceTemperatureMould("DetectorTemperature", 0.0f, m_stDeviceConfig.fTemperatureErrorMin, m_stDeviceConfig.fTemperatureWarnMin, m_stDeviceConfig.fTemperatureWarnMax, 20.0f, 100.0f, m_stDeviceConfig.fTemperatureErrorMax, 0.0f, EventCenter)); //const char* strkey, int initialvalue, int min, int WarnMin, int WarnMax, int CalibWarnMin, int CalibWarnMax, int max, int accuracy, std::shared_ptr EventCenter m_Wifi.reset(new DeviceWifiMould("DetectorWifi", 0, m_stDeviceConfig.nWifiLimit, m_stDeviceConfig.nWifiWarning, 100, 10, 100, 100, 0, EventCenter)); //mLog::FINFO("--Func-- device LoadConfig end"); return true; } void nsFPD::FPDDeviceCareRay::Register() { auto Disp = &Dispatch; RegisterCtrl(Disp); RegisterAcq(Disp); RegisterSync(Disp); RegisterCalib(Disp); RegisterOthers(Disp); } RET_STATUS nsFPD::FPDDeviceCareRay::Connect() { printf("--Func-- device Connect \r\n"); //mLog::FINFO("--Func-- device Connect \n"); m_DetectorCtrlUnit->SetAttachStatus("1"); //没有attach功能,直接上发1,使客户端显示探测器状态 if(g_pDetector->Connect(this, m_strWorkPath.c_str(), m_DetectorModeList)) { m_bConnect = true; } else { //mLog::FERROR("Connect Detector fail!"); return RET_STATUS::RET_FAILED; } //读取detector mode list 后把内容保存到Vector中,当设置PPS时,从Vector中查找适合当前帧率的最大分辨率的模式 unsigned long dpi = 0; float fTempMax = 0.0f; try { for (size_t i = 0; i < m_DetectorModeList.size(); i++) { ResDataObject temp = m_DetectorModeList[i]; int nModeID = temp["ModeID"]; int nWidth = temp["ImageWidth"]; int nHeight = temp["ImageHeight"]; int nCutOffX = temp["CutOffX"]; int nCutOffY = temp["CutOffY"]; string strBinningMode = temp["BinningMode"]; float fMaxFrameRate = temp["MaxFrameRate"]; int nGainID = temp["GainID"]; int nExpTime = temp["ExpTime"]; //mLog::FINFO("Detector ModeID:{$} Width:{$} Height:{$} nCutOffX:{$} nCutOffY:{$} Binning:{$} MaxFrameRate:{$} GainID:{$} ExpTime:{$}", nModeID, nWidth, nHeight, nCutOffX, nCutOffY, strBinningMode, fMaxFrameRate, nGainID, nExpTime); DetectorMode tempMode; tempMode.modeID = nModeID; tempMode.imageWidth = nWidth; tempMode.imageHeight = nHeight; tempMode.cutOffX = nCutOffX; tempMode.cutOffY = nCutOffY; tempMode.binningMode = strBinningMode; tempMode.maxFrameRate = fMaxFrameRate; tempMode.gainID = nGainID; tempMode.expTime = nExpTime; m_vDetectorModeList.push_back(tempMode); if ((unsigned long)nWidth * (unsigned long)nHeight > dpi) { dpi = nWidth * nHeight; m_stDeviceConfig.nMaxImgWidth = nWidth; m_stDeviceConfig.nMaxImgHeight = nHeight; } if (fMaxFrameRate > fTempMax) { fTempMax = fMaxFrameRate; } } } catch (ResDataObjectExption& e) { //mLog::FERROR("Get detector mode error: {$}", e.what()); return RET_STATUS::RET_FAILED; } //mLog::FINFO("m_stDeviceConfig.nMaxImgWidth:{$},m_stDeviceConfig.nMaxImgHeight:{$}", m_stDeviceConfig.nMaxImgWidth, m_stDeviceConfig.nMaxImgHeight); if (m_pImgBuffer) { delete m_pImgBuffer; m_pImgBuffer = nullptr; } m_pImgBuffer = new WORD[(size_t)m_stDeviceConfig.nMaxImgWidth * (size_t)m_stDeviceConfig.nMaxImgHeight]; //mLog::FINFO("Current detector max frame rate is:{$}", fTempMax); m_fMaxFrameRate = fTempMax; m_AcqUnit->SetMaxFrameRate(m_fMaxFrameRate); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceCareRay::EnterExam(int nExamMode) { //mLog::FINFO("--Func-- EnterExam {$}", nExamMode); switch (nExamMode) { case APP_STATUS_WORK_BEGIN: //mLog::FINFO("Enter into Exam Windows"); m_eAppStatus = APP_STATUS_WORK_BEGIN; break; case APP_STATUS_WORK_END: //mLog::FINFO("Quit Exam Windows"); m_eAppStatus = APP_STATUS_WORK_END; break; case APP_STATUS_DETSHARE_BEGIN: //mLog::FINFO("Enter into Detector Share Windows"); m_eAppStatus = APP_STATUS_DETSHARE_BEGIN; break; case APP_STATUS_DETSHAR_END: m_eAppStatus = APP_STATUS_IDLE; //mLog::FINFO("Quit Detector Share Windows"); m_eAppStatus = APP_STATUS_DETSHAR_END; break; case APP_STATUS_CAL_BEGIN: //mLog::FINFO("Enter into Calibration Windows"); m_eAppStatus = APP_STATUS_CAL_BEGIN; break; case APP_STATUS_CAL_END: //mLog::FINFO("Quit Calibration Windows"); m_eAppStatus = APP_STATUS_CAL_END; break; case APP_STATUS_WORK_IN_SENSITIVITY: //mLog::FINFO("Enter into sensitivity test interface"); m_eAppStatus = APP_STATUS_WORK_IN_SENSITIVITY; break; default: break; } g_pDetector->EnterExamMode(nExamMode); return RET_STATUS::RET_SUCCEED; } bool nsFPD::FPDDeviceCareRay::GetLogicMode(string& strAcqMode, int& nLogicMode) { if (strAcqMode == "RAD") { nLogicMode = RAD; } else if (strAcqMode == "CF") { nLogicMode = CF; } else if (strAcqMode == "PF") { nLogicMode = PF; } else if (strAcqMode == "1") { nLogicMode = RAD; } else if (strAcqMode == "2") { nLogicMode = CF; } else if (strAcqMode == "3") { nLogicMode = PF; } else { //mLog::FERROR("Not support mode!"); return false; } return true; } RET_STATUS nsFPD::FPDDeviceCareRay::SetAcqMode(string strAcqMode) { printf("--Func-- SetAcqMode(%s) \r\n", strAcqMode.c_str()); //mLog::FINFO("--Func-- SetAcqMode strAcqMode:{$}", strAcqMode); RET_STATUS ret = RET_STATUS::RET_FAILED; //如果没连接,不执行 if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); return ret; } //由于动态需要ready快,故通知探测器ready状态在这里通知 if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus() || DETECTOR_STATUS_CALIB == m_DetectorCtrlUnit->GetDetectorStatus()) { //mLog::FINFO("SetAcqMode detector is not standby!"); ret = StopAcquisition(); if (ret != RET_STATUS::RET_SUCCEED) { //mLog::FERROR("SetAcqMode StopAcquisition fail!!!"); return ret; } else { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); } } else { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); } int nMode = RAD; bool bRet = GetLogicMode(strAcqMode, nMode); if (!bRet) { return RET_STATUS::RET_FAILED; } //只有RAD模式读取配置文件,CF和PF不读取全部配置文件,只读取部分 try { ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations; int nModeCount = (int)objModeConfig["ModeTable"].size(); for (int i = 0; i < nModeCount; i++) { ////mLog::FINFO("ModeTable {$}, {$}",i, objModeConfig["ModeTable"][i].encode()); int nAppModeID = (int)objModeConfig["ModeTable"][i]["LogicMode"]; if (nAppModeID == nMode) { if (nMode == RAD) { m_nImageWidth = (int)objModeConfig["ModeTable"][i]["ImageWidth"]; m_nImageHeight = (int)objModeConfig["ModeTable"][i]["ImageHeight"]; } m_nImgBits = (int)objModeConfig["ModeTable"][i]["PhySizeInfoBit"]; m_nPixelSpacing = (int)objModeConfig["ModeTable"][i]["PixelPitch"]; m_nSensitivity = (int)objModeConfig["ModeTable"][i]["Sensitivity"]; m_nAngle = (int)objModeConfig["ModeTable"][i]["RotateAngle"]; string strDoseOfExi = std::to_string(m_nSensitivity); m_fFactorEXI2UGY = 100.0f / stof(strDoseOfExi) * 1.0f;//统一使用IEC标准 呈现四角信息,无单位 ugy * 100 -ugy。所有Zskk探测器的FactorEXI2UGY均需*100 //mLog::FINFO("m_fFactorEXI2UGY = {$} ", m_fFactorEXI2UGY); m_DetectorCtrlUnit->SetFPDSensitivity(std::to_string(m_fFactorEXI2UGY)); break; } } } catch (ResDataObjectExption& e) { //mLog::FERROR("Read configuration failed, Error code: {$}", e.what()); ret = RET_STATUS::RET_FAILED; return ret; } m_nCurrentAcqMode = nMode; if (g_pDetector->SetAcqMode(nMode)) { ret = RET_STATUS::RET_SUCCEED; m_AcqUnit->AcqModeNotify(strAcqMode); } else { ret = RET_STATUS::RET_FAILED; } return ret; } RET_STATUS nsFPD::FPDDeviceCareRay::PrepareAcquisition() { printf("--Func-- PrepareAcquisition \r\n"); //mLog::FINFO("--Func-- PrepareAcquisition"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); return ret; } if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) || (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE)) { //mLog::FERROR("PrepareAcquisition failed! Detector at Calibration status!"); return ret; } if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus()) { //mLog::FERROR("Detector at Acq status!"); return ret; } if (g_pDetector->PrepareAcquisition(this)) { ret = RET_STATUS::RET_SUCCEED; } //mLog::FINFO("PrepareAcquisition over"); return ret; } RET_STATUS nsFPD::FPDDeviceCareRay::StartAcquisition(string in) { printf("--Func-- StartAcquisition \r\n"); //mLog::FINFO("--Func-- StartAcquisition"); //mLog::FINFO("StartAcquisition param in:{$}", in); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); return ret; } //mLog::FINFO("StartAcquisition m_nCurrentAcqMode:{$}", m_nCurrentAcqMode); //RAD时用固定的模式,从配置文件读取 if (in == "RAD" || in == "CF" || in == "PF") { ret = SetAcqMode(in); if (ret != RET_STATUS::RET_SUCCEED) { //mLog::FERROR("StartAcquisition SetAcqMode fail!"); return ret; } } else { //mLog::FERROR("Not support this mode, mode name:{$}",in); return ret; } ret = PrepareAcquisition(); if (ret != RET_STATUS::RET_SUCCEED) { //mLog::FERROR("StartAcquisition PrepareAcquisition fail!"); return ret; } if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus()) { if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) || (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE)) { //printf(("PrepareAcquisition failed. Detector at Calibration status.\n"); //mLog::FERROR("PrepareAcquisition failed. Detector at Calibration status."); } if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus()) { //printf(("Detector already at Acq status.\n"); //mLog::FERROR("Detector already at Acq status."); } } else { if (g_pDetector->StartAcquisition(this)) { ret = RET_STATUS::RET_SUCCEED; m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ)); m_nImageIndex = 1; } else { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); } } //mLog::FINFO("StartAcquisition over"); return ret; } RET_STATUS nsFPD::FPDDeviceCareRay::StopAcquisition() { printf("--Func-- StopAcquisition \r\n"); //mLog::FINFO("--Func-- StopAcquisition"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); return ret; } if (DETECTOR_STATUS_STANDBY == m_DetectorCtrlUnit->GetDetectorStatus()) { //printf(("Detector already at stanby status.\n"); //mLog::FINFO("Detector already at stanby status."); ret = RET_STATUS::RET_SUCCEED; } else { if (g_pDetector->StopAcquisition(this)) { ret = RET_STATUS::RET_SUCCEED; m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); } } //mLog::FINFO("StopAcquisition over"); return ret; } RET_STATUS nsFPD::FPDDeviceCareRay::SetFluPPS(float fFluPPS) { //mLog::FINFO("--Func-- SetFluPPS:{$}", fFluPPS); m_fCurrentPPS = fFluPPS; bool bFind = false; //更新m_fFrameRate值 for (size_t i = 0; i < m_vAcqModeInfoList.size(); i++) { if (m_vAcqModeInfoList[i].fFrequency == fFluPPS) { //mLog::FINFO("find config pps"); bFind = true; g_pDetector->UpdateModeInRunning(m_vAcqModeInfoList[i].nModeID,fFluPPS); m_AcqUnit->FluPPSNotify(fFluPPS); break; } } if (!bFind) { //mLog::FINFO("not find config pps"); float fRealFps = g_pDetector->SetFluPPS(fFluPPS, m_vDetectorModeList); if (fRealFps > 0.0f) { m_AcqUnit->FluPPSNotify(fRealFps); } } return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceCareRay::GetFluPPS(float& fFluPPS) { g_pDetector->GetFluPPS(fFluPPS); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceCareRay::SetXrayOnNum() { //mLog::FINFO("--Func-- SetXrayOnNum"); if (g_pDetector->SetXrayOnNum()) { return RET_STATUS::RET_SUCCEED; } return RET_STATUS::RET_FAILED; } RET_STATUS nsFPD::FPDDeviceCareRay::SetExposureTimes(int nTimes) { //mLog::FINFO("--Func-- SetExposureTimes({$})", nTimes); if (g_pDetector->SetExposureTimes(nTimes)) { return RET_STATUS::RET_SUCCEED; } return RET_STATUS::RET_FAILED; } RET_STATUS nsFPD::FPDDeviceCareRay::ActiveCalibration(CCOS_CALIBRATION_TYPE eType) { printf("--Func-- ActiveCalibration eType:%d \r\n", eType); //mLog::FINFO("--Func-- ActiveCalibration {$}", (int)eType); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); return ret; } if (eType == CCOS_CALIBRATION_TYPE_NONE || eType == CCOS_CALIBRATION_TYPE_MAX) { return RET_STATUS::RET_INVALID; } if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus()) { if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus()) { //printf(("ActiveCalibration failed. Detector at Acq status\r\n"); //mLog::FERROR("ActiveCalibration failed. Detector at Acq status"); } return RET_STATUS::RET_FAILED; } if (g_pDetector->ActiveCalibration(this, eType)) { ret = RET_STATUS::RET_SUCCEED; m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ACTIVE)); m_CalibUnit->SetCalibrationProgress("0"); } else { //mLog::FERROR("Active calibration failed"); } //mLog::FINFO("ActiveCalibration over"); return ret; } RET_STATUS nsFPD::FPDDeviceCareRay::PrepareCalibration() { printf("--Func-- PrepareCalibration \r\n"); //mLog::FINFO("--Func-- PrepareCalibration"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); return ret; } if (g_pDetector->PrepareCalibration(this)) { ret = RET_STATUS::RET_SUCCEED; } else { //mLog::FERROR("Prepare calibration failed"); } //mLog::FINFO("PrepareCalibration over"); return ret; } RET_STATUS nsFPD::FPDDeviceCareRay::GetRequestedDose(std::string& strDose) { printf("--Func-- GetRequestedDose \r\n"); //mLog::FINFO("--Func-- GetRequestedDose"); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; bool bGetDoseInfo = false; ResDataObject out; CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType(); if (CCOS_CALIBRATION_TYPE_DARK == nCalibrationType) { out.add("Dose", 0.0f); out.add("kV", 0.0f); out.add("mA", 0.0f); out.add("ms", 0.0f); out.add("mAs", 0.0f); bGetDoseInfo = true; } else if (CCOS_CALIBRATION_TYPE_XRAY == nCalibrationType) { for (int i = 0; i < m_CalibDoseList.size(); i++) { ResDataObject temp = m_CalibDoseList[i]; int nDose = temp["Dose"]; int nDoseParem = (int)(m_fDose * 1000); if (nDoseParem == nDose) { out.add("Dose", nDoseParem); out.add("kV", temp["kV"]); out.add("mA", temp["mA"]); out.add("ms", temp["ms"]); out.add("mAs", temp["mAs"]); bGetDoseInfo = true; break; } } } else { Ret = RET_STATUS::RET_FAILED; } if (bGetDoseInfo) { strDose = out.encode(); //mLog::FINFO("GetRequestedDose {$} over", strDose.c_str()); } else { //mLog::FERROR("GetRequestedDose failed"); } return Ret; } RET_STATUS nsFPD::FPDDeviceCareRay::StartCalibration() { printf("--Func-- StartCalibration \r\n"); //mLog::FINFO("--Func-- StartCalibration"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); return ret; } if ((m_CalibUnit->GetCalibrationStatus() != CCOS_CALIBRATION_STATUS_PAUSE) && (m_CalibUnit->GetCalibrationStatus() != CCOS_CALIBRATION_STATUS_ACTIVE)) { //mLog::FERROR("Start calibration failed, in {$} status", (int)m_CalibUnit->GetCalibrationStatus()); return ret; } if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus()) { if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus()) { //mLog::FERROR("Start calibration failed. Detector already at Acq status"); } return ret; } if (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) { //mLog::FERROR("Detector already at calib status"); return ret; } if (g_pDetector->StartCalibration(this)) { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING)); ret = RET_STATUS::RET_SUCCEED; } else { //mLog::FERROR("Start calibration failed"); return ret; } //mLog::FINFO("StartCalibration over"); return ret; } RET_STATUS nsFPD::FPDDeviceCareRay::StopCalibration() { printf("--Func-- StopCalibration \r\n"); //mLog::FINFO("--Func-- StopCalibration"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); return ret; } if (g_pDetector->StopCalibration(this)) { ret = RET_STATUS::RET_SUCCEED; m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_CalibUnit->SetCalibrationProgress("100"); } else { //mLog::FERROR("Start calibration failed"); } //mLog::FINFO("StopCalibration over"); return ret; } bool nsFPD::FPDDeviceCareRay::Support_DarkCalib() { return true; } bool nsFPD::FPDDeviceCareRay::Support_XrayCalib() { return true; } //理论上定义的Action和Attr的名称要在CCOS.Dev.FPDDeviceMould.hpp中定义,之前由于不清楚导致有的名称在Detector_Model_Def.h中定义的 以后要规范 void nsFPD::FPDDeviceCareRay::RegisterCtrl(nsDetail::Dispatch* Dispatch) { Dispatch->Action.Push(ActionKey::GetFPDinformation, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorInfo); Dispatch->Action.Push(ActionKey::ActiveDetector, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSActiveDetector); Dispatch->Action.Push(ActionKey::EnterExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSEnterExam); Dispatch->Action.Push(ActionKey::ExitExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSExitExam); Dispatch->Action.Push(ActionKey::SetXrayOnNum, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetXrayOnNum); Dispatch->Action.Push(ActionKey::SetExposureTimes, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetExposureTimes); Dispatch->Get.Push(AttrKey::DetectorConnectStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetConnectStatus); Dispatch->Get.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDStatus); Dispatch->Get.Push(AttrKey::Description, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDescription); Dispatch->Get.Push(AttrKey::FPDSensitivity, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDSensitivity); Dispatch->Get.Push(AttrKey::TargetEXI, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTargetEXI); Dispatch->Get.Push(SupportDDR, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetSupportDDR); Dispatch->Get.Push(AttrKey::DetectorID, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorID); Dispatch->Get.Push(AttrKey::DetectorType, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorType); Dispatch->Get.Push(AttrKey::PixelData, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetPixelData); Dispatch->Get.Push(AttrKey::DetectorWidth, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorWidth); Dispatch->Get.Push(AttrKey::DetectorHeight, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorHeight); Dispatch->Get.Push(AttrKey::FPDAttached, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachStatus); Dispatch->Set.Push(AttrKey::DetectorConnectStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetConnectStatus); Dispatch->Set.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorStatus); Dispatch->Set.Push(AttrKey::Description, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDescription); Dispatch->Set.Push(AttrKey::FPDSensitivity, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetFPDSensitivity); Dispatch->Set.Push(AttrKey::TargetEXI, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetTargetEXI); Dispatch->Set.Push(SupportDDR, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetSupportDDR); Dispatch->Set.Push(AttrKey::DetectorID, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorID); Dispatch->Set.Push(AttrKey::DetectorType, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorType); Dispatch->Set.Push(AttrKey::PixelData, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetPixelData); Dispatch->Set.Push(AttrKey::FPDAttached, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetAttachStatus); } void nsFPD::FPDDeviceCareRay::RegisterAcq(nsDetail::Dispatch* Dispatch) { Dispatch->Action.Push(ActionKey::SetAcqMode, m_AcqUnit.get(), &AcqUnit::JSSetAcqMode); Dispatch->Action.Push(ActionKey::SetValue_PPS, m_AcqUnit.get(), &AcqUnit::JSSetFluPPS); Dispatch->Get.Push(AttrKey::AcqMode, m_AcqUnit.get(), &AcqUnit::JSGetAcqMode); Dispatch->Get.Push(AttrKey::ZskkFPDState, m_AcqUnit.get(), &AcqUnit::JSGetZskkFPDState); Dispatch->Get.Push(AttrKey::NoNeedWaitImage, m_AcqUnit.get(), &AcqUnit::JSGetNoNeedWaitImage); Dispatch->Get.Push(AttrKey::ImgDataInfo, m_AcqUnit.get(), &AcqUnit::JSGetLastImage); Dispatch->Get.Push(AttrKey::MaxFrameRate, m_AcqUnit.get(), &AcqUnit::JSGetMaxFrameRate); Dispatch->Get.Push(AttrKey::FluPPS, m_AcqUnit.get(), &AcqUnit::JSGetFluPPS); Dispatch->Set.Push(AttrKey::ZskkFPDState, m_AcqUnit.get(), &AcqUnit::SetZskkFPDState); Dispatch->Set.Push(AttrKey::NoNeedWaitImage, m_AcqUnit.get(), &AcqUnit::JSSetNoNeedWaitImage); Dispatch->Update.Push(AttrKey::ModeInRunning, m_AcqUnit.get(), &AcqUnit::JSUpdateModeInRunning); } void nsFPD::FPDDeviceCareRay::RegisterSync(nsDetail::Dispatch* Dispatch) { Dispatch->Action.Push(ActionKey::PrepareAcquisition, m_SyncUnit.get(), &SyncUnit::JSPrepareAcquisition); Dispatch->Action.Push(ActionKey::StartAcquisition, m_SyncUnit.get(), &SyncUnit::JSStartAcquisition); Dispatch->Action.Push(ActionKey::StopAcquisition, m_SyncUnit.get(), &SyncUnit::JSStopAcquisition); Dispatch->Get.Push(AttrKey::FPDReadyStatus, m_SyncUnit.get(), &SyncUnit::JSGetFPDReady); Dispatch->Get.Push(AttrKey::XwindowStatus, m_SyncUnit.get(), &SyncUnit::JSGetXWindowStatus); Dispatch->Get.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSGetImageReadingStatus); Dispatch->Set.Push(AttrKey::FPDReadyStatus, m_SyncUnit.get(), &SyncUnit::JSSetFPDReady); Dispatch->Set.Push(AttrKey::XwindowStatus, m_SyncUnit.get(), &SyncUnit::JSSetXWindowStatus); Dispatch->Set.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSSetImageReadingStatus); } void nsFPD::FPDDeviceCareRay::RegisterCalib(nsDetail::Dispatch* Dispatch) { Dispatch->Action.Push(ActionKey::ActiveCalibration, m_CalibUnit.get(), &CalibUnit::JSActiveCalibration); Dispatch->Action.Push(ActionKey::GetRequestedDose, m_CalibUnit.get(), &CalibUnit::JSGetRequestedDose); Dispatch->Action.Push(ActionKey::PrepareCalibration, m_CalibUnit.get(), &CalibUnit::JSPrepareCalibration); Dispatch->Action.Push(ActionKey::StartCalibration, m_CalibUnit.get(), &CalibUnit::JSStartCalibration); Dispatch->Action.Push(ActionKey::StopCalibration, m_CalibUnit.get(), &CalibUnit::JSStopCalibration); Dispatch->Action.Push(ActionKey::SetCorrectionType, m_CalibUnit.get(), &CalibUnit::JSSetCorrectionType); Dispatch->Action.Push(ActionKey::StartOffset, m_CalibUnit.get(), &CalibUnit::JSStartOffset); Dispatch->Action.Push(ActionKey::AbortOffset, m_CalibUnit.get(), &CalibUnit::JSAbortOffset); Dispatch->Get.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::JSGetCalibStatus); Dispatch->Get.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::JSGetCalibProgress); Dispatch->Get.Push(AttrKey::UploadCalibrationFilesResult, m_CalibUnit.get(), &CalibUnit::JSGetUploadCalibrationFilesResult); Dispatch->Get.Push(AttrKey::OffsetStatus, m_CalibUnit.get(), &CalibUnit::JSGetOffsetStatus); Dispatch->Get.Push(AttrKey::OffsetCounts, m_CalibUnit.get(), &CalibUnit::JSGetOffsetCounts); Dispatch->Get.Push(AttrKey::OffsetProgress, m_CalibUnit.get(), &CalibUnit::JSGetOffsetProgress); Dispatch->Get.Push(AttrKey::OffsetInterval, m_CalibUnit.get(), &CalibUnit::JSGetOffsetInterval); Dispatch->Set.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::SetCalibrationStatus); Dispatch->Set.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::SetCalibrationProgress); Dispatch->Set.Push(AttrKey::UploadCalibrationFilesResult, m_CalibUnit.get(), &CalibUnit::SetUploadCalibrationFilesResult); Dispatch->Set.Push(AttrKey::OffsetStatus, m_CalibUnit.get(), &CalibUnit::SetOffsetStatus); Dispatch->Set.Push(AttrKey::OffsetCounts, m_CalibUnit.get(), &CalibUnit::SetOffsetCounts); Dispatch->Set.Push(AttrKey::OffsetProgress, m_CalibUnit.get(), &CalibUnit::SetOffsetProgress); Dispatch->Set.Push(AttrKey::OffsetInterval, m_CalibUnit.get(), &CalibUnit::SetOffsetInterval); Dispatch->Update.Push(AttrKey::OffsetInterval, m_CalibUnit.get(), &CalibUnit::JSUpdateOffsetInterval); } void nsFPD::FPDDeviceCareRay::RegisterOthers(nsDetail::Dispatch* Dispatch) { Dispatch->Get.Push(AttrKey::Temperature_Value, m_Temperature.get(), &DeviceTemperatureMould::JSGetCurrentTemperatureValue); Dispatch->Get.Push(AttrKey::Remain_Power_Value, m_Battery.get(), &DeviceBatteryMould::JSGetCurrentBatteryValue); Dispatch->Get.Push(AttrKey::Wifi_Strength_Value, m_Wifi.get(), &DeviceWifiMould::JSGetCurrentSignalValue); Dispatch->Get.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMax); Dispatch->Get.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMin); Dispatch->Get.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMax); Dispatch->Get.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMin); Dispatch->Get.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureCalibWarningMax); Dispatch->Get.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureCalibWarningMin); Dispatch->Get.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryWarningMin); Dispatch->Get.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryErrorMin); Dispatch->Get.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalWarningMin); Dispatch->Get.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalErrorMin); Dispatch->Set.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMax); Dispatch->Set.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMin); Dispatch->Set.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMax); Dispatch->Set.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMin); Dispatch->Set.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureCalibWarningMax); Dispatch->Set.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureCalibWarningMin); Dispatch->Set.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryWarningMin); Dispatch->Set.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryErrorMin); Dispatch->Set.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalWarningMin); Dispatch->Set.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalErrorMin); Dispatch->Update.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMax); Dispatch->Update.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMin); Dispatch->Update.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMax); Dispatch->Update.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMin); Dispatch->Update.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureCalibWarningMax); Dispatch->Update.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureCalibWarningMin); Dispatch->Update.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryWarningMin); Dispatch->Update.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryErrorMin); Dispatch->Update.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalWarningMin); Dispatch->Update.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalErrorMin); } void nsFPD::FPDDeviceCareRay::OnFPDCallback(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { switch (nEventLevel) { case EVT_LEVEL_CONFIGURATION: { OnEventProcessConf(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam); break; } case EVT_LEVEL_INFORMATOION: { OnEventProcessInfo(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam); break; } case EVT_LEVEL_STATUS: { OnEventProcessStatus(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam); break; } case EVT_LEVEL_DATA: { OnEventProcessData(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam); break; } case EVT_LEVEL_WARNING: { OnEventProcessWarning(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam); break; } case EVT_LEVEL_ERROR: { OnEventProcessError(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam); break; } default: break; } } void nsFPD::FPDDeviceCareRay::OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { switch (nEventID) { case EVT_CONF_PANEL_SERIAL: { m_stDeviceConfig.strPanelSerial = pszMsg; //mLog::FINFO("Receive Panel {$} SN {$}", nDetectorID, pszMsg); m_DetectorCtrlUnit->SetDetectorID(m_stDeviceConfig.strPanelSerial); break; } case EVT_CONF_RAW_WIDTH: { if (m_stDeviceConfig.nFullImageWidth != nParam1) { m_stDeviceConfig.nFullImageWidth = nParam1; } if (m_nImageWidth != nParam1) { m_nImageWidth = nParam1; } //mLog::FINFO("Ratate angle: {$}", m_nAngle); if (m_nAngle == 90 || m_nAngle == 270) { m_AcqUnit->SetFulImageInfo(m_nImageWidth, m_nImageHeight, m_nImgBits, false); } else { m_AcqUnit->SetFulImageInfo(m_nImageHeight, m_nImageWidth, m_nImgBits, false); } //mLog::FINFO("Panel {$} m_nImageWidth:{$}", nDetectorID, m_nImageWidth); break; } case EVT_CONF_RAW_HIGHT: { if (m_stDeviceConfig.nFullImageHeight != nParam1) { m_stDeviceConfig.nFullImageHeight = nParam1; } if (m_nImageHeight != nParam1) { m_nImageHeight = nParam1; } //mLog::FINFO("Ratate angle: {$}", m_nAngle); if (m_nAngle == 90 || m_nAngle == 270) { m_AcqUnit->SetFulImageInfo(m_nImageWidth, m_nImageHeight, m_nImgBits, false); } else { m_AcqUnit->SetFulImageInfo(m_nImageHeight, m_nImageWidth, m_nImgBits, false); } //mLog::FINFO("Panel {$} m_nImageHeight:{$}", nDetectorID, m_nImageHeight); break; } } } void nsFPD::FPDDeviceCareRay::OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { //mLog::FERROR("Not support this info({$})", nEventID); } void nsFPD::FPDDeviceCareRay::OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { switch (nEventID) { case EVT_STATUS_PANEL: { ENUM_PANEL_STATUS ePanelStatus = (ENUM_PANEL_STATUS)nParam1; if (PANEL_END_ACQ == nParam1) { //mLog::FINFO("Panel Status: End acq"); if (g_pDetector->StopAcquisition(this)) { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); } } else if (PANEL_XWINDOW_ON == nParam1) //Xwindow On { //mLog::FINFO("XWindowOnNotify"); m_SyncUnit->XWindowOnNotify(); } else if (PANEL_XWINDOW_OFF == nParam1) // Xwindow Off { //mLog::FINFO("XWindowOffNotify"); m_SyncUnit->XWindowOffNotify(); } break; } case EVT_STATUS_CALIBRATIOIN: { ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1; switch (eStatus) { case PANEL_EVENT_START: break; case PANEL_EVENT_END_OK: case PANEL_EVENT_END_ERROR: m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_CalibUnit->SetCalibrationProgress("100");//make progress break; case PANEL_EVENT_TIMEOUT: break; default: break; } break; } case EVT_STATUS_OFFSET: { ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1; switch (eStatus) { case PANEL_EVENT_END_OK: m_CalibUnit->SetOffsetStatus("Idle"); break; case PANEL_EVENT_END_ERROR: m_CalibUnit->SetOffsetStatus("Error"); break; case PANEL_EVENT_START: m_CalibUnit->SetOffsetStatus("Running"); break; default: break; } break; } case EVT_STATUS_OFFSET_PROGRESS: { //mLog::FINFO("EVT_STATUS_OFFSET_PROGRESS param:{$}", nParam1); int nOffsetProgress = nParam1; m_CalibUnit->SetOffsetProgress(to_string(nOffsetProgress)); break; } case EVT_STATUS_SINGLEEXP: { if (DOSE_ACCEPT == nParam1) { //mLog::FINFO("Calibration Result is acceptable"); } else { //mLog::FERROR("Not support this param(%d)", nParam1); } break; } //case EVT_STATUS_TEMPERATURE: //{ // float fTemperature = fParam2; // if (fTemperature > m_fTemperMaxLimit) // { // AddErrMsg("14", "temperature_toohigh"); // } // else if (fTemperature >= m_fTemperWarning) // { // AddWarnMsg("14", "temperature_high"); // } // else if (fTemperature < m_fTemperMinLimit) // { // AddErrMsg("14", "temperature_toolow"); // } // else if (fTemperature <= m_fTemperLowLimit) // { // AddWarnMsg("14", "temperature_low"); // } // else // { // DelErrMsg("14"); // } // SendTemperatureValue(fTemperature); //} //break; //case EVT_STATUS_WIFI: //{ // int nWifiLevel = nParam1; // if (nWifiLevel < m_nWifiLimit) // { // AddErrMsg("15", "wifi_toolow"); // } // else if (nWifiLevel <= m_nWifiWarning) // { // AddWarnMsg("15", "wifi_low"); // } // else // { // DelErrMsg("15"); // } // SendWifiValue(nWifiLevel); //} //break; //case EVT_STATUS_BATTERY_VALUE: //{ // int nBatteryValue = nParam1; // if (nBatteryValue < m_nBatteryLimit) // { // AddErrMsg("16", "battery_toolow"); // } // else if (nBatteryValue <= m_nBatteryWarning) // { // AddWarnMsg("16", "battery_low"); // } // else // { // DelErrMsg("16"); // } // SendBatteryValue(nBatteryValue); //} //break; default: //mLog::FERROR("Not support this status({$})", nEventID); break; } } void nsFPD::FPDDeviceCareRay::OnEventProcessData(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { switch (nEventID) { case EVT_DATA_RAW_IMAGE: { //mLog::FINFO("EVT_DATA_RAW_IMAGE"); //mLog::FINFO("m_nImageWidth:{$},m_nImageHeight:{$}", m_nImageWidth, m_nImageHeight); memcpy(m_pImgBuffer, pParam, (size_t)m_nImageWidth * (size_t)m_nImageHeight * sizeof(WORD)); //暂时先用假值,有需要再改 SYSTEMTIME stImgCreateTime = { 0 }; GetLocalTime(&stImgCreateTime); ResDataObject objImageHead, objTemp; objTemp.add(SM_IMAGE_TYPE, (int)IMAGE_FULL); objTemp.add(SM_IMAGE_BIT, m_nImgBits); objTemp.add(SM_IMAGE_TAG, 1); if (m_nCurrentAcqMode == CF || m_nCurrentAcqMode == PF) { objTemp.add(SM_IMAGE_INDEX, m_nImageIndex); m_nImageIndex++; } else { objTemp.add(SM_IMAGE_INDEX, 1); } objTemp.add(SM_IMAGE_YEAR, stImgCreateTime.wYear); objTemp.add(SM_IMAGE_MONTH, stImgCreateTime.wMonth); objTemp.add(SM_IMAGE_DAY, stImgCreateTime.wDay); objTemp.add(SM_IMAGE_HOUR, stImgCreateTime.wHour); objTemp.add(SM_IMAGE_MINUTE, stImgCreateTime.wMinute); objTemp.add(SM_IMAGE_SEC, stImgCreateTime.wSecond); objTemp.add(SM_IMAGE_MILLSEC, stImgCreateTime.wMilliseconds); objTemp.add(SM_IMAGE_LSB, "5000"); objTemp.add(SM_IMAGE_DOSE, m_nSensitivity); objTemp.add(SM_IMAGE_PIXELSPACING, m_nPixelSpacing); objTemp.add(SM_IMAGE_PIXELREPRESENTATION, "1"); objTemp.add(SM_IMAGE_FLIP, "No"); objTemp.add(SM_IMAGE_ORIGINX, "0"); objTemp.add(SM_IMAGE_ORIGINY, "0"); objTemp.add(SM_IMAGE_EXI2UGY, m_fFactorEXI2UGY);//此项不添加的话会导致ImageSave计算EXI的值为0 m_AcqUnit->RotateImage(m_pImgBuffer, m_nImageHeight, m_nImageWidth, m_nAngle); if (90 == m_nAngle || 270 == m_nAngle) { objTemp.add(SM_IMAGE_WIDTH, m_nImageHeight); objTemp.add(SM_IMAGE_HEIGHT, m_nImageWidth); objTemp.add(SM_IMAGE_ROTATION, "Yes"); } else { objTemp.add(SM_IMAGE_WIDTH, m_nImageWidth); objTemp.add(SM_IMAGE_HEIGHT, m_nImageHeight); objTemp.add(SM_IMAGE_ROTATION, "No"); } objImageHead.add(SM_IMAGE_HEAD, objTemp); //mLog::FINFO("Full image head: {$}", objImageHead.encode()); RET_STATUS ret = RET_STATUS::RET_FAILED; ret = m_AcqUnit->AddFrameWithRawHead(IMAGE_FULL, objImageHead.encode(), m_pImgBuffer, m_nImageWidth * m_nImageHeight); //mLog::FINFO("Add image over"); } break; default: //mLog::FERROR("Not support this data({$})", nEventID); break; } } void nsFPD::FPDDeviceCareRay::OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { switch (nEventID) { case EVT_ERR_COMMUNICATE: //{ // string strTemp = pszMsg; // if (strTemp.find("true") != std::string::npos) // { // AddErrMsg("0", "communication error"); // SendTemperatureValue(0); // SendWifiValue(0); // SendBatteryValue(0); // } // else if (strTemp.find("false") != std::string::npos) // { // DelErrMsg("0"); // } //} break; case EVT_ERR_INIT_FAILED: //{ // string strTemp = pszMsg; // if (strTemp.find("true") != std::string::npos) // { // AddErrMsg("6", "initialize error"); // } // else if (strTemp.find("false") != std::string::npos) // { // //一般不可恢复 // } //} break; default: //mLog::FERROR("Not support this error({$})", nEventID); break; } } void nsFPD::FPDDeviceCareRay::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { //mLog::FERROR("Not support this warn({$})", nEventID); } RET_STATUS nsFPD::FPDDeviceCareRay::StartOffset(bool isAll) { //mLog::FINFO("--Func-- StartOffset isAll:{$}", isAll); if (isAll) { m_CalibUnit->SetOffsetCounts(to_string(m_vDetectorModeList.size())); g_pDetector->SetFreshAllOffsetEvent(m_vDetectorModeList); } else { m_CalibUnit->SetOffsetCounts(to_string(2)); g_pDetector->SetfreshOffsetEvent(); } return RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceCareRay::AbortOffset() { //mLog::FINFO("--Func-- AbortOffset"); g_pDetector->AbortFreshOffset(); return RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceCareRay::UpdateModeInRunning(std::vector& vAcqModeList) { //mLog::FINFO("--Func-- UpdateModeInRunning"); m_vAcqModeInfoList.assign(vAcqModeList.begin(),vAcqModeList.end()); for (size_t i = 0; i < m_vAcqModeInfoList.size(); i++) { if (m_vAcqModeInfoList[i].fFrequency == m_fCurrentPPS) { g_pDetector->UpdateModeInRunning(m_vAcqModeInfoList[i].nModeID, m_vAcqModeInfoList[i].fFrequency); break; } } return RET_SUCCEED; } /*** * 客户端获取探测器信息 ***/ RET_STATUS nsFPD::FPDDeviceCareRay::GetDetectorInfo(string& strInfo) { //mLog::FINFO("--Func-- GetDetectorInfo"); ResDataObject strDetectorInfo; if (m_stDeviceConfig.strPanelSerial == "") { //mLog::FWARN("strPanelSerial is null, Send Default Info"); strDetectorInfo.add("DetectorName", "Simulator"); strDetectorInfo.add("DetectorSN", "Simulator"); strDetectorInfo.add("SSID", " "); strDetectorInfo.add("LifeTime", "0"); strDetectorInfo.add("PowerOn", "0"); strDetectorInfo.add("DateCode", " "); strDetectorInfo.add("PartNumber", " "); strDetectorInfo.add("WifiDataRate", " "); strDetectorInfo.add("WifiChannel", "0"); strDetectorInfo.add("DetectorExist", "0"); strDetectorInfo.add("SystemAS", "0"); strDetectorInfo.add("CalibrationDate", "0"); strDetectorInfo.add("CalibrationDue", "0"); strDetectorInfo.add("CalibrationExist", "0"); strDetectorInfo.add("CommunicationStatus", "0"); strDetectorInfo.add("DetectorTemperature", "0"); strDetectorInfo.add("FDCalibrationTemperature", "0"); strDetectorInfo.add("TemperatureStatus", "0"); strDetectorInfo.add("WaitTime", "0"); strDetectorInfo.add("DetectorWifiSignal", "0"); strDetectorInfo.add("DetectorBattery", "0"); strDetectorInfo.add("ShockSensor", "NULL"); strDetectorInfo.add("FirmwareUpdate", "0"); strInfo = strDetectorInfo.encode(); return RET_STATUS::RET_SUCCEED; } strDetectorInfo.add("DetectorName", m_stDeviceConfig.strDeviceName.c_str()); strDetectorInfo.add("DetectorSN", m_stDeviceConfig.strPanelSerial.c_str()); //strDetectorInfo.add("Firmware", m_stDeviceConfig.strFirmware.c_str()); //strDetectorInfo.add("APFirmware", "NULL"); //strDetectorInfo.add("Software", m_stDeviceConfig.strSoftware.c_str()); //strDetectorInfo.add("SSID", m_stDeviceConfig.strWifiSSID.c_str()); //strDetectorInfo.add("LifeTime", m_stDeviceConfig.nLifeTime); //strDetectorInfo.add("PowerOn", m_stDeviceConfig.nPowerOn); //strDetectorInfo.add("FD_Voltage_List1", m_strVoltage.c_str()); //strDetectorInfo.add("DateCode", m_stDeviceConfig.strDateCode.c_str()); //strDetectorInfo.add("PartNumber", m_stDeviceConfig.strPartNumber.c_str()); //strDetectorInfo.add("WifiDataRate", m_stDeviceConfig.nWifiDataRate); //strDetectorInfo.add("WifiChannel", m_stDeviceConfig.nWifiChannel); //strDetectorInfo.add("DetectorExist", m_stDeviceConfig.bExisted); //strDetectorInfo.add("SystemAS", m_stDeviceConfig.pDetModeInfoStruct[0].nWorkStation); strInfo = strDetectorInfo.encode(); return RET_STATUS::RET_SUCCEED; }