#include "stdafx.h" #include "CCOS.Dev.FPD.TrixellDR.h" #include "TrixellCtrl.h" #include "common_api.h" #include "FileVersion.hpp" #include "GridSuppression.h" #include "DICOMImageHeadKey.h" #pragma comment(lib, "Version.lib") namespace nsFPD = CCOS::Dev::Detail::Detector; static nsFPD::TrixellDriver gIODriver; Log4CPP::Logger* gLogger = nullptr; extern const char* g_szMouldPath; extern "C" CCOS::Dev::IODriver * __cdecl GetIODriver() // 返回静态对象的引用, 调用者不能删除 ! { return &gIODriver; } extern "C" CCOS::Dev::IODriver * __cdecl CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 ! { return new nsFPD::TrixellDriver(); } nsFPD::TrixellDriver::TrixellDriver() { pObjDev = nullptr; m_bConnect = false; //缺省为false m_pAttribute.reset(new ResDataObject()); m_pDescription.reset(new ResDataObject()); } nsFPD::TrixellDriver::~TrixellDriver() { if (nullptr != pObjDev) { delete pObjDev; pObjDev = nullptr; } } /*** ** 类似于重构前的DriverEntry(),多板时会顺序调用每个平板dpc的这个接口 ** 之后的接口调用上层是多线程执行的,不能保证先后顺序 ***/ void nsFPD::TrixellDriver::Prepare() { /*string strLogPath = GetProcessDirectory() + R"(\OEMDrivers\Detector\Conf\Log4CPP.Config.FPD.xml)"; Log4CPP::GlobalContext::Map::Set(ZSKK::Utility::Hash("LogFileName"), "FPD.TrixellDR"); auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str()); gLogger = Log4CPP::LogManager::GetLogger("FPD.TrixellDR");*/ string strLogPath = GetProcessDirectory() + R"(\Conf\Log4CPP.Config.xml)"; auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str()); gLogger = Log4CPP::LogManager::GetLogger("Module"); #ifdef _WIN64 Force("=============================Version: {$} (64-bit)==================================", FileVersion(g_szMouldPath).GetVersionString()); #else Force("=============================Version: {$} (32-bit)==================================", FileVersion(g_szMouldPath).GetVersionString()); #endif pObjDev = new FPDDeviceTrixell(EventCenter, m_ConfigFileName); pObjDev->CreateDevice(); pObjDev->Register(); Info("driver prepare over"); } bool nsFPD::TrixellDriver::Connect() { Info("--Func-- driver connect"); m_bConnect = pObjDev->m_stDeviceConfig.bConnectStatus; return m_bConnect; } void nsFPD::TrixellDriver::Disconnect() { Info("--Func-- driver disconnect"); m_bConnect = false; } bool nsFPD::TrixellDriver::isConnected() const { return m_bConnect; } auto nsFPD::TrixellDriver::CreateDevice(int index)->std::unique_ptr { Info("--Func-- driver createdevice"); auto Device = std::unique_ptr(new IODevice(pObjDev)); return Device; } std::string nsFPD::TrixellDriver::DriverProbe() { Trace("--Func-- Driver Probe"); 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", "DR"); HardwareInfo.add("VendorID", "Trixell"); HardwareInfo.add("ProductID", "Trixell"); HardwareInfo.add("SerialID", "Driver"); } string str = HardwareInfo.encode(); return str; } /*** ** 获取ID和配置 ***/ std::string nsFPD::TrixellDriver::GetResource() { ResDataObject r_config, temp; if (!temp.loadFile(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"); //Info(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()); //Info(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())); //Info(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), atoi(strValue.c_str())); } else if ("float" == strType) { (*m_pAttribute).add(strTemp.c_str(), atof(strValue.c_str())); //Info(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), atof(strValue.c_str())); } else //其它先按string类型处理 { (*m_pAttribute).add(strTemp.c_str(), strValue.c_str()); //Info(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), strValue.c_str()); } //AttributeAccess strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Access"]; DescriptionTemp.add(AttributeAccess, strTemp.c_str()); //Info(g_pFPDCtrlLog, "{$}: {$}", AttributeAccess, strTemp.c_str()); //AttributeRangeMin strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMin"]; if (strTemp != "") //不需要的配置项为空 { DescriptionTemp.add(AttributeRangeMin, strTemp.c_str()); //Info(g_pFPDCtrlLog, "{$}: {$}", AttributeRangeMin, strTemp.c_str()); } //AttributeRangeMax strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMax"]; if (strTemp != "") //不需要的配置项为空 { DescriptionTemp.add(AttributeRangeMax, strTemp.c_str()); //Info(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()); //Info(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()); //Info(g_pFPDCtrlLog, "{$}: {$}", AttributeRequired, strTemp.c_str()); //AttributeDefaultValue strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["DefaultValue"]; if (strTemp != "") //不需要的配置项为空 { DescriptionTemp.add(AttributeDefaultValue, strTemp.c_str()); //Info(g_pFPDCtrlLog, "{$}: {$}", AttributeDefaultValue, strTemp.c_str()); } strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"]; (*m_pDescription).add(strTemp.c_str(), DescriptionTemp); } } catch (ResDataObjectExption& e) { Error("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.clear(); m_DeviceConfig = DescriptionTempEx; string res = DescriptionTempEx.encode(); Trace("get resource over {$}", DescriptionTempEx.encode()); return res; } std::string nsFPD::TrixellDriver::DeviceProbe() { Trace("--Func-- Device Probe"); 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", "Trixell"); HardwareInfo.add("ProductID", "Trixell"); HardwareInfo.add("SerialID", "1234"); } string str = HardwareInfo.encode(); return str; } bool nsFPD::TrixellDriver::GetDeviceConfig(std::string& Cfg) { Cfg = m_DeviceConfig.encode(); Info("GetDeviceConfig over"); return true; } bool nsFPD::TrixellDriver::SetDeviceConfig(std::string Cfg) { Info("--Func-- SetDeviceConfig {$}\n", Cfg.c_str()); ResDataObject DeviceConfig; DeviceConfig.decode(Cfg.c_str()); ResDataObject DescriptionTempEx; DescriptionTempEx = DeviceConfig["DeviceConfig"]["Attribute"]; Trace("Attribute:{$}", DescriptionTempEx.encode()); bool bSaveFile = false; //true:重新保存配置文件 string strAccess = ""; for (int i = 0; i < DescriptionTempEx.size(); i++) { string strKey = DescriptionTempEx.GetKey(i); Info("{$}", strKey.c_str()); try { if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0) { strAccess = (string)(*m_pDescription)[strKey.c_str()]["Access"]; if ("RW" == strAccess) { //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值 //1. 修改内存中的值,用于给上层发消息 (*m_pAttribute)[strKey.c_str()] = DescriptionTempEx[i]; //2. 拿到Innerkey int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo"); Info("nConfigInfoCount {$}", 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, DescriptionTempEx[i])) { Trace("SetDeviceConfigValue over"); bSaveFile = true; } } else { Info("{$} is not a RW configuration item", strKey.c_str()); } } else { Info("without this attribute {$}", strKey.c_str()); } } catch (ResDataObjectExption& e) { Error("SetDriverConfig crashed: {$}", e.what()); return false; } } if (bSaveFile) { //3. 重新保存配置文件 SaveConfigFile(true); } return true; } bool nsFPD::TrixellDriver::SaveConfigFile(bool bSendNotify) { m_ConfigAll["CONFIGURATION"] = m_Configurations; bool bRt = m_ConfigAll.SaveFile(m_ConfigFileName.c_str()); Info("SaveConfigFile over {$}", bRt); return true; } bool nsFPD::TrixellDriver::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 || ImageWidth == strTemp || ImageHeight == 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 = ""; Warn("Error Configuration item: {$}", pInnerKey); } } return true; } bool nsFPD::TrixellDriver::SetDeviceConfigValue(ResDataObject & config, const char* pInnerKey, int nPathID, const char* szValue) { string strTemp = pInnerKey; Trace("Begin to change {$} item value to {$}", pInnerKey, szValue); if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取 { try { 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 || ImageWidth == strTemp || ImageHeight == 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) { config[pInnerKey] = szValue; } else { Warn("Error Configuration item: {$}", pInnerKey); return false; } } catch (ResDataObjectExption& e) { Error("SetDriverConfigvalue crashed: {$}", e.what()); return false; } } return true; } //----------------------------------------------------------------------------- // FPDDeviceTrixell //----------------------------------------------------------------------------- extern TrixellCtrl* g_pDetector; nsFPD::FPDDeviceTrixell::FPDDeviceTrixell(std::shared_ptr center, std::string strConfigPath) : m_hNotifyThread(nullptr) , m_NotifyThreadID(0) , m_nDeviceIndex(-1) , m_eAppStatus(APP_STATUS_IDLE) , m_strLastError("") , m_bBatteryCharging(false) , m_bImagePendingOrNot(false) , m_bResetDetector(false) , m_nCalibTotalExposureNum(0) , m_nCalibCurrentCalibrationRound(0) , m_nCalibCurrentExposureIndex(0) , m_nCalibCurrentExposureNum(0) , m_bNotifyCalWarn(true) { m_pDetectors = nullptr; m_strWorkPath = GetProcessDirectory(); m_AcqUnit.reset(new OemAcq(center, this)); m_SyncUnit.reset(new OemSync(center, this)); m_CalibUnit.reset(new OemCalib(center, this)); m_DetectorCtrlUnit.reset(new OemCtrl(center, this)); m_DetectorConfiguration.reset(new DetectorConfiguration(strConfigPath)); m_WarnAndError.reset(new FPDErrorWarning(center, DetectorUnitType, m_strWorkPath + "\\OEMDrivers\\Detector\\Trixell\\TrixellDRDetector")); //m_CalibProcess.reset(new CalibrationProcess()); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_SHUTDOWN)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_WaitCalibDoseEvt = CreateEvent(NULL, FALSE, FALSE, NULL); m_PauseCalibrationEvt = CreateEvent(NULL, FALSE, FALSE, NULL); m_ExitEvt = CreateEvent(NULL, FALSE, FALSE, NULL); m_ConnectEvt = CreateEvent(NULL, FALSE, FALSE, NULL); EventCenter = center; } nsFPD::FPDDeviceTrixell::~FPDDeviceTrixell() { SetEvent(m_ExitEvt); if (m_PauseCalibrationEvt) { CloseHandle(m_PauseCalibrationEvt); m_PauseCalibrationEvt = nullptr; } if (m_ExitEvt) { CloseHandle(m_ExitEvt); m_ExitEvt = nullptr; } if (m_ConnectEvt) { CloseHandle(m_ConnectEvt); m_ConnectEvt = nullptr; } if (m_WaitCalibDoseEvt) { CloseHandle(m_WaitCalibDoseEvt); m_WaitCalibDoseEvt = nullptr; } } std::string nsFPD::FPDDeviceTrixell::GetGUID() const { return DetectorUnitType; } bool nsFPD::FPDDeviceTrixell::Prepare() { Info("--Func-- device prepare \n"); EventCenter->OnMaxBlockSize("DrQue",m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight * 2, 3, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * 2, 1); m_hNotifyThread = CreateThread(0, 0, OnNotify, this, 0, &m_NotifyThreadID); if (m_hNotifyThread == NULL) { Info("Start Process Thread Failed!"); } else { Info("Start Process Thread End"); } SetEvent(m_ConnectEvt); //Connect(); return true; } void nsFPD::FPDDeviceTrixell::RegisterCtrl(nsDetail::Dispatch* Dispatch) { Dispatch->Get.Push("DetectorConnectStatus", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetConnectStatus); Dispatch->Get.Push("DetectorInitialStatus", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetInitialStatus); Dispatch->Get.Push("DetectorUpdateFWStatus", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetUpdateFWStatus); Dispatch->Get.Push("FPDShockSensorInfo", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetShockSensorInfo); Dispatch->Get.Push("DetectorStatus", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetFPDStatus); Dispatch->Get.Push("FPDAttached", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetAttachStatus); Dispatch->Get.Push("DetectorAttach", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetAttachResult);//event Dispatch->Get.Push("RecoverImageState", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageState);//event Dispatch->Get.Push("RecoverImageEvent", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageEvent);//event Dispatch->Get.Push("FieldofViewShape", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetFieldofViewShape); Dispatch->Get.Push("FieldofViewDimension", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetFieldofViewDimension); Dispatch->Get.Push("DetectorType", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetDetectorType); Dispatch->Get.Push("Description", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetDescription); Dispatch->Get.Push("DetectorID", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetDetectorID); Dispatch->Get.Push("DateofLastDetectorCalibration", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetDateofLastDetectorCalibration); Dispatch->Get.Push("TimeofLastDetectorCalibration", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetTimeofLastDetectorCalibration); Dispatch->Get.Push("DetectorConditionsNominalFlag", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetDetectorConditionsNominalFlag); Dispatch->Get.Push("FPDSensitivity", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetFPDSensitivity); Dispatch->Get.Push("PixelData", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetPixelData); Dispatch->Get.Push("TargetEXI", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetTargetEXI); //Dispatch->Action.Push("SetFilterType", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::); Dispatch->Action.Push("ActiveDetector", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSActiveDetector); //Dispatch->Action.Push("SleepDetector", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::); //Dispatch->Action.Push("WakeupDetector", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::); Dispatch->Action.Push("AttachConnect", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSAttachConnect); Dispatch->Action.Push("CancelAttach", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSCancelAttach); Dispatch->Action.Push("ResetConnect", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSResetConnect); Dispatch->Action.Push("DisConnectFPD", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSDisConnectFPD); Dispatch->Action.Push("UpdateFirmware", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSUpdateFirmware); Dispatch->Action.Push(ActionKey::GetDetectorInfo, m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetDetectorInfo); Dispatch->Action.Push("EnterExam", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSEnterExam); Dispatch->Action.Push("RecoverImage", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSRecoverImage); Dispatch->Action.Push("GetRecoverImageState", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSGetRecoverImageState); Dispatch->Action.Push("SaveSensitivity", m_DetectorCtrlUnit.get (), &DetectorCtrlUnit::JSSaveSensitivity); Dispatch->Action.Push("RESET", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRESET); Dispatch->Action.Push("SaveRawDataMode", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSaveRawDataMode); } void nsFPD::FPDDeviceTrixell::RegisterAcq(nsDetail::Dispatch* Dispatch) { Dispatch->Action.Push("SetAcqMode", m_AcqUnit.get(), &AcqUnit::JSSetAcqMode); Dispatch->Get.Push("ZskkFPDState", m_AcqUnit.get(), &AcqUnit::JSGetZskkFPDState); Dispatch->Get.Push("NoNeedWaitImage", m_AcqUnit.get(), &AcqUnit::JSGetNoNeedWaitImage); Dispatch->Get.Push("ImgDataInfo", m_AcqUnit.get(), &AcqUnit::JSGetLastImage); Dispatch->Get.Push("AutonumousMapFinish", m_AcqUnit.get(), &AcqUnit::JSAutonumousMapFinish); } void nsFPD::FPDDeviceTrixell::RegisterSync(nsDetail::Dispatch* Dispatch) { Dispatch->Action.Push("SetSyncMode", m_SyncUnit.get(), &SyncUnit::JSSetSyncMode); Dispatch->Action.Push("SetXwindowSize", m_SyncUnit.get(), &SyncUnit::JSSetXwindowSize); Dispatch->Action.Push("PrepareAcquisition", m_SyncUnit.get(), &SyncUnit::JSPrepareAcquisition); Dispatch->Action.Push("StartAcquisition", m_SyncUnit.get(), &SyncUnit::JSStartAcquisition); Dispatch->Action.Push("StopAcquisition", m_SyncUnit.get(), &SyncUnit::JSStopAcquisition); Dispatch->Action.Push("ActiveSyncMode", m_SyncUnit.get(), &SyncUnit::JSActiveSyncMode); Dispatch->Get.Push(CcosFPDReadyStatus, m_SyncUnit.get(), &SyncUnit::JSGetFPDReady); Dispatch->Get.Push(CcosXwindowStatus, m_SyncUnit.get(), &SyncUnit::JSGetXWindowStatus); Dispatch->Get.Push(CcosImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSGetImageReadingStatus); Dispatch->Get.Push("SupportSyncMode", m_SyncUnit.get(), &SyncUnit::JSGetSupportSyncMode); } void nsFPD::FPDDeviceTrixell::RegisterCalib(nsDetail::Dispatch* Dispatch) { //Dispatch->Action.Push("UploadCalibrationFiles", m_CalibUnit.get(), &CalibUnit::JSUploadCalibrationFiles); //Dispatch->Action.Push("SetSID", m_CalibUnit.get(), &CalibUnit::JSSetSID); Dispatch->Action.Push("ActiveCalibration", m_CalibUnit.get(), &CalibUnit::JSActiveCalibration); Dispatch->Action.Push("GetRequestedDose", m_CalibUnit.get(), &CalibUnit::JSGetRequestedDose); Dispatch->Action.Push("SetRequestedDose", m_CalibUnit.get(), &CalibUnit::JSSetRequestedDose); Dispatch->Action.Push("PrepareCalibration", m_CalibUnit.get(), &CalibUnit::JSPrepareCalibration); Dispatch->Action.Push("StartCalibration", m_CalibUnit.get(), &CalibUnit::JSStartCalibration); Dispatch->Action.Push("StopCalibration", m_CalibUnit.get(), &CalibUnit::JSStopCalibration); Dispatch->Action.Push("SetCorrectionType", m_CalibUnit.get(), &CalibUnit::JSSetCorrectionType); Dispatch->Action.Push("GetCalibrationStep", m_CalibUnit.get(), &CalibUnit::JSGetCalibrationStep); Dispatch->Action.Push("SaveCalibrationFile", m_CalibUnit.get(), &CalibUnit::JSSaveCalibrationFile); Dispatch->Action.Push("AcceptCalibration", m_CalibUnit.get(), &CalibUnit::JSAcceptCalibration); Dispatch->Action.Push("RejectCalibration", m_CalibUnit.get(), &CalibUnit::JSRejectCalibration); Dispatch->Get.Push("HaveImgCalibration", m_CalibUnit.get(), &CalibUnit::JSGetHaveImgCalibration); Dispatch->Get.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::JSGetCalibStatus); Dispatch->Get.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::JSGetCalibProgress); Dispatch->Get.Push("SaveCalibrationFileFinish", m_CalibUnit.get(), &CalibUnit::JSGetSaveCalibrationFileFinish); Dispatch->Get.Push(AttrKey::CalibMode, m_CalibUnit.get(), &CalibUnit::JSGetCalibMode); Dispatch->Get.Push(AttrKey::LastCalibrationDate, m_CalibUnit.get(), &CalibUnit::JSGetLastCalibrationDate); Dispatch->Get.Push(AttrKey::CalibrationFileExpireTime, m_CalibUnit.get(), &CalibUnit::JSGetCalibrationFileExpireTime); Dispatch->Set.Push(AttrKey::LastCalibrationDate, m_CalibUnit.get(), &CalibUnit::SetLastCalibrationDate); Dispatch->Set.Push(AttrKey::CalibrationFileExpireTime, m_CalibUnit.get(), &CalibUnit::SetCalibrationFileExpireTime); Dispatch->Update.Push(AttrKey::CalibMode, m_CalibUnit.get(), &CalibUnit::JSUpdateCalibMode); Dispatch->Update.Push(AttrKey::LastCalibrationDate, m_CalibUnit.get(), &CalibUnit::JSUpdateLastCalibrationDate); Dispatch->Update.Push(AttrKey::CalibrationFileExpireTime, m_CalibUnit.get(), &CalibUnit::JSUpdateCalibrationFileExpireTime); Dispatch->Update.Push(AttrKey::CalibrationFileExpirationReminder, [this](std::string in, std::string& out) {out = in; this->m_bNotifyCalWarn = (in == "1") ? true : false; return RET_STATUS::RET_SUCCEED; }); } void nsFPD::FPDDeviceTrixell::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(m_WarnAndError->m_MSGUnit->GetKey().c_str(), [this](std::string& out) { out = m_WarnAndError->m_MSGUnit->JSGet(); return RET_STATUS::RET_SUCCEED; }); Dispatch->Get.Push(nDetail::AttrKey::ErrorList, m_WarnAndError.get(), &FPDErrorWarning::JSGetErrorList); Dispatch->Get.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMax); Dispatch->Get.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMin); Dispatch->Get.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMax); Dispatch->Get.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMin); Dispatch->Get.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryErrorMin); Dispatch->Get.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryWarningMin); Dispatch->Get.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalErrorMin); Dispatch->Get.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalWarningMin); Dispatch->Set.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMax); Dispatch->Set.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMin); Dispatch->Set.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMax); Dispatch->Set.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMin); Dispatch->Set.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryErrorMin); Dispatch->Set.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryWarningMin); Dispatch->Set.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalErrorMin); Dispatch->Set.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalWarningMin); Dispatch->Update.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMax); Dispatch->Update.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMin); Dispatch->Update.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMax); Dispatch->Update.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMin); Dispatch->Update.Push(TemperatureCalibUpWarn, [](std::string in, std::string& out) {out = in; return RET_STATUS::RET_SUCCEED; }); Dispatch->Update.Push(TemperatureCalibLowWarn, [](std::string in, std::string& out) {out = in; return RET_STATUS::RET_SUCCEED; }); Dispatch->Update.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryErrorMin); Dispatch->Update.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryWarningMin); Dispatch->Update.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalErrorMin); Dispatch->Update.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalWarningMin); } //离线采集接口 void nsFPD::FPDDeviceTrixell::RegisterAutonumous(nsDetail::Dispatch* Dispatch) { Dispatch->Action.Push("OfflineFPD", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSOfflineFPD); Dispatch->Action.Push("OnlineFPD", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSOnlineFPD); Dispatch->Action.Push("GetAutonumousImageList", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAutonumousImageList); Dispatch->Action.Push("RemoveAutonumousImageList", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRemoveAutonumousImageList); Dispatch->Action.Push("RemoveAutonumousAll", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRemoveAutonumousAll); Dispatch->Action.Push("GetImageMetaData", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetImageMetaData); Dispatch->Action.Push("ExportAutonumousAll", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSExportAutonumousAll); } void nsFPD::FPDDeviceTrixell::Register() { auto Disp = &Dispatch; RegisterCtrl(Disp); RegisterAcq(Disp); RegisterSync(Disp); RegisterCalib(Disp); RegisterOthers(Disp); RegisterAutonumous(Disp); } bool nsFPD::FPDDeviceTrixell::LoadConfig() { if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig)) { Error("Load configuration file failed!!!"); return false; } try { m_nFullImgWidth = m_stDeviceConfig.nFullImageWidth; m_nFullImgHeight = m_stDeviceConfig.nFullImageHeight; m_nLeftOffset = m_stDeviceConfig.nImageLeftOffset; m_nTopOffset = m_stDeviceConfig.nImageTopffset; m_bPreviewEnable = m_stDeviceConfig.bPreviewEnable; if (m_stDeviceConfig.nForceGridSuppress > 0) { m_bForceGridSuppress = true; } else { m_bForceGridSuppress = false; } int nAttached = (int)m_DetectorConfiguration->m_Configurations[CcosDetectorAttachedFlag]; if (nAttached == 1) { m_bAttached = true; m_DetectorCtrlUnit->SetAttachStatus("1"); } else { m_bAttached = false; m_stDeviceConfig.bConnectStatus = false; } string strFPDinfo; strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["FieldofViewShape"]; m_DetectorCtrlUnit->SetFieldofViewShape(strFPDinfo); strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["FieldofViewDimension"]; m_DetectorCtrlUnit->SetFieldofViewDimension(strFPDinfo); m_DetectorCtrlUnit->SetDetectorType("SCINTILLATOR"); strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["Description"]; m_DetectorCtrlUnit->SetDescription(strFPDinfo); m_DetectorCtrlUnit->SetDetectorConditionsNominalFlag("YES"); auto strFinfo = std::to_string(m_stDeviceConfig.nDoseOfEXI); m_DetectorCtrlUnit->SetFPDSensitivity(strFinfo); m_fFactorEXI2UGY = 100.0f / (float)atof(strFinfo.c_str()) * 1.0f;//子系统将UI的TargetEXI 乘以FPDSensitivity再传给imagesave,用作计算EXI和DI并填写ecm头。 Info("FactorEXI2UGY = {$}", m_fFactorEXI2UGY); m_DetectorCtrlUnit->SetPixelData(""); m_DetectorCtrlUnit->SetTargetEXI("5000"); m_Battery.reset(new DeviceBatteryMould("DetectorTrixellBattery", 0, m_stDeviceConfig.nBatteryLimit, m_stDeviceConfig.nBatteryWarning, 100, 30, 100, 100, 0, EventCenter)); m_Temperature.reset(new DeviceTemperatureMould("DetectorTrixellTemperature", 0.0f, m_stDeviceConfig.fTemperMinLimit, m_stDeviceConfig.fTemperLowLimit, m_stDeviceConfig.fTemperUpperLimit, 50.0f, 100.0f, m_stDeviceConfig.fTemperMaxLimit, 0.0f, EventCenter)); m_Wifi.reset(new DeviceWifiMould("DetectorTrixellWifi", 0, m_stDeviceConfig.nWifiLimit, m_stDeviceConfig.nWifiWarning, 100, 50, 100, 100, 0, EventCenter)); //------------------------------------可支持的同步模式 ResDataObject jsonSupportSyncType; jsonSupportSyncType = m_DetectorConfiguration->m_Configurations["SupportSyncMode"]; Debug("SupportSyncMode: {$}", jsonSupportSyncType.encode()); m_SyncUnit->JSSetSupportSyncMode(jsonSupportSyncType.encode()); //校正日期 m_CalibUnit->SetLastCalibrationDate(m_stDeviceConfig.strLastCalibrationDate); m_CalibUnit->SetCalibrationFileExpireTime(m_stDeviceConfig.strCalibrationFileExpireTime); m_bNotifyCalWarn = ((int)m_DetectorConfiguration->m_Configurations["CalibrationFileExpirationReminder"] == 1) ? true : false; //校正参数 ResDataObject CalibDoseList; string strCalibDose = m_strWorkPath + R"(\OEMDrivers\Detector\Trixell\TrixellDRDetector\CalibrationDose_Trixell.xml)"; Info("start load calibDose file: {$}", strCalibDose.c_str()); struct stat buffer; if (stat(strCalibDose.c_str(), &buffer) == 0) { CalibDoseList.loadFile(strCalibDose.c_str()); m_CalibDoseList = CalibDoseList["List"]; Info("m_CalibDoseList: {$} ", m_CalibDoseList.encode()); for (int i = 0; i < m_CalibDoseList.size(); i++) { ResDataObject temp = m_CalibDoseList[i]; int nExpNum = temp["ExpNum"]; m_nCalibTotalExposureNum += nExpNum; //Info("temp: {$} ", temp.encode()); } Info("CalibTotalExposureNum: {$}", m_nCalibTotalExposureNum); } else { Error("{$} file not exist!", strCalibDose); } } catch (exception e) { Error("Get calibDose error: {$}", e.what()); } return true; } bool nsFPD::FPDDeviceTrixell::CreateDevice() { if (!LoadConfig()) { return false; } if (nullptr == g_pDetector) { if (nullptr == m_pDetectors) { m_pDetectors = new TrixellCtrl(); Info("Create SDK ctrl ok\n"); g_pDetector = (TrixellCtrl*)m_pDetectors; } } else { m_pDetectors = g_pDetector; Info("SDK ctrl Already exit\n"); } return ((TrixellCtrl*)m_pDetectors)->AddDPCs(this, m_DetectorConfiguration->m_Configurations, m_stDeviceConfig); } RET_STATUS nsFPD::FPDDeviceTrixell::Connect() { Info("------------------------ FPD {$} Start running ------------------------", m_stDeviceConfig.strDeviceName.c_str()); bool bRet = m_pDetectors->Connect(m_strWorkPath.c_str(), this); if (!bRet) { Error("Connect detector failed!!!"); return RET_STATUS::RET_FAILED; } Info("Connect detector success"); return RET_STATUS::RET_SUCCEED; } DWORD nsFPD::FPDDeviceTrixell::OnNotify(LPVOID pParam) { Info("OnNotify Loop Entry-----------"); FPDDeviceTrixell* pNotifyOpr = (FPDDeviceTrixell*)pParam; int nHandlesNum = 3; HANDLE* pHandles = new HANDLE[nHandlesNum]; pHandles[0] = pNotifyOpr->m_PauseCalibrationEvt; pHandles[1] = pNotifyOpr->m_ExitEvt; pHandles[2] = pNotifyOpr->m_ConnectEvt; while (1) { DWORD dwResult = WaitForMultipleObjects(nHandlesNum, pHandles, FALSE, INFINITE); if (dwResult == WAIT_OBJECT_0) //m_PauseCalibrationEvt { Info("OnNotify get PauseCalibration evt"); pNotifyOpr->PauseCalibration(); } else if (dwResult == WAIT_OBJECT_0 + 1) //m_ExitEvt { Info("Exit OnNotify Thread"); break; } else if (dwResult == WAIT_OBJECT_0 + 2) //m_ConnectEvt { Info("Get ConnectEVT"); pNotifyOpr->Connect(); ResetEvent(pNotifyOpr->m_ConnectEvt); } } delete[] pHandles; Info("Exit OnNotify Thread over"); return 0; } RET_STATUS nsFPD::FPDDeviceTrixell::ActiveDetector(bool bActive) { if (!m_stDeviceConfig.bConnectStatus) { return RET_STATUS::RET_THREAD_INVALID; } if (bActive) { bool bRet = ((TrixellCtrl*)m_pDetectors)->ActivePanel(this); if (!bRet) { return RET_STATUS::RET_FAILED; } } return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceTrixell::WakeupDetector() { Info("--Func-- Wakeup FPD {$}", m_nDeviceIndex); if (((TrixellCtrl*)m_pDetectors)->WakeupDetector(m_nDeviceIndex)) { return RET_STATUS::RET_SUCCEED; } return RET_STATUS::RET_FAILED; } RET_STATUS nsFPD::FPDDeviceTrixell::PrepareAcquisition() { Info("==============================PrepareAcquisition"); if (!m_stDeviceConfig.bConnectStatus || m_WarnAndError->IsErrorExist()) { Error("Detector status is error. Disable Ready."); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ERROR)); return RET_STATUS::RET_FAILED; } auto strFinfo = std::to_string(m_stDeviceConfig.nDoseOfEXI); m_DetectorCtrlUnit->SetFPDSensitivity(strFinfo); m_SyncUnit->FPDReadyNotify(false); RET_STATUS Ret = RET_STATUS::RET_FAILED; if (RET_STATUS::RET_SUCCEED == m_pDetectors->PrepareAcquisition(this)) { m_SyncUnit->FPDReadyNotify(true); Ret = RET_STATUS::RET_SUCCEED; } m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); Info("==============================PrepareAcquisition over"); return Ret; } RET_STATUS nsFPD::FPDDeviceTrixell::StartAcquisition(string in) { Info("==============================StartAcquisition"); if (!m_stDeviceConfig.bConnectStatus) { return RET_STATUS::RET_THREAD_INVALID; } if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus()) { if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) || (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE)) { Error("StartAcquisition failed. Detector at Calibration status"); return RET_STATUS::RET_FAILED; } if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus()) { Warn("Detector already at Acq status"); return RET_STATUS::RET_SUCCEED; } } RET_STATUS Ret = RET_STATUS::RET_FAILED; if (RET_STATUS::RET_SUCCEED == ((TrixellCtrl*)m_pDetectors)->StartAcquisition(this)) { Ret = RET_STATUS::RET_SUCCEED; m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ)); } else { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); } Info("==============================StartAcquisition over"); return Ret; } RET_STATUS nsFPD::FPDDeviceTrixell::StopAcquisition() { Info("==============================StopAcquisition"); if (!m_stDeviceConfig.bConnectStatus) { return RET_STATUS::RET_THREAD_INVALID; } if (DETECTOR_STATUS_STANDBY == m_DetectorCtrlUnit->GetDetectorStatus()) { Warn("Detector already at Standby status"); return RET_STATUS::RET_SUCCEED; } RET_STATUS Ret = RET_STATUS::RET_FAILED; if (RET_STATUS::RET_SUCCEED == ((TrixellCtrl*)m_pDetectors)->StopAcquisition(this)) { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); Ret = RET_STATUS::RET_SUCCEED; } Info("==============================StopAcquisition over"); return Ret; } string nsFPD::FPDDeviceTrixell::GetFileVersion(string strFilePathName) { DWORD dwVerSize = GetFileVersionInfoSize(strFilePathName.c_str(), NULL); if (dwVerSize == 0) { return "null"; } LPVOID pVersionBuffer = malloc(dwVerSize); if (pVersionBuffer == nullptr) { return "null"; } GetFileVersionInfo(strFilePathName.c_str(), 0, dwVerSize, pVersionBuffer); VS_FIXEDFILEINFO* pInfo; UINT nInfoLen; char szValue[MAX_PATH] = { 0 }; if (VerQueryValue(pVersionBuffer, ("\\"), (void**)&pInfo, &nInfoLen)) { sprintf_s(szValue, ("%d.%d.%d.%d"), HIWORD(pInfo->dwFileVersionMS), LOWORD(pInfo->dwFileVersionMS), HIWORD(pInfo->dwFileVersionLS), LOWORD(pInfo->dwFileVersionLS)); } string strVersion = szValue; return strVersion; } void nsFPD::FPDDeviceTrixell::SendTemperatureValue() { int nStatus = 0; m_Temperature->SetTemperature(m_stDeviceConfig.fCurrentTemperValue, nStatus); Info("SendTemperatureValue: {$}, status {$}\n", m_stDeviceConfig.fCurrentTemperValue, nStatus); } void nsFPD::FPDDeviceTrixell::SendWifiValue() { int nStatus = 0; m_Wifi->SetSignalValue(m_stDeviceConfig.nCurrentWifiValue, nStatus); Info("SendWifiValue: {$}, status {$}\n", m_stDeviceConfig.nCurrentWifiValue, nStatus); } void nsFPD::FPDDeviceTrixell::SendBatteryValue() { int nStatus = 0; m_Battery->SetRemainPowerValue(m_stDeviceConfig.nCurrentBatteryValue, nStatus); Info("SendBatteryValue: {$}, status {$}\n", m_stDeviceConfig.nCurrentBatteryValue, nStatus); } RET_STATUS nsFPD::FPDDeviceTrixell::XWindowOnNotify() { RET_STATUS Ret = RET_STATUS::RET_FAILED; m_SyncUnit->XWindowOnNotify(); Info("WindowOn\n"); m_stImgCreateTime = { 0 }; GetLocalTime(&m_stImgCreateTime); Info("Full image create time-%02d:%02d:%02d:%03d", m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds); return Ret; } RET_STATUS nsFPD::FPDDeviceTrixell::XWindowOffNotify() { RET_STATUS Ret = RET_STATUS::RET_FAILED; m_SyncUnit->XWindowOffNotify(); Info("WindowOff\n"); return Ret; } RET_STATUS nsFPD::FPDDeviceTrixell::ActiveCalibration(CCOS_CALIBRATION_TYPE eType) { Info("==============================ActiveCalibration is {$}", (int)eType); m_DetectorCtrlUnit->SetFPDSensitivity("100"); if (!m_stDeviceConfig.bConnectStatus) { return RET_STATUS::RET_THREAD_INVALID; } 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()) { Error("ActiveCalibration {$} failed. Detector at Acq status", (int)eType); } return RET_STATUS::RET_FAILED; }*/ m_eAppStatus = APP_STATUS_CAL_BEGIN; if (eType == CCOS_CALIBRATION_TYPE_XRAY) { ResetEvent(m_WaitCalibDoseEvt); int nCalibrationRounds = (int)m_CalibDoseList.size(); ((TrixellCtrl*)m_pDetectors)->SetReferenceNum(nCalibrationRounds); } RET_STATUS Ret = ((TrixellCtrl*)m_pDetectors)->ActiveCalibration(eType); if (RET_STATUS::RET_SUCCEED == Ret) { m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ACTIVE)); m_CalibUnit->SetCalibrationProgress("0"); if (eType == CCOS_CALIBRATION_TYPE_XRAY) { Info("start to waitting CalibDoseEvt"); DWORD nRet = WaitForSingleObject(m_WaitCalibDoseEvt, INFINITE); } m_nXrayCalibNum = 0; } //重置校正流程参数 m_nCalibCurrentCalibrationRound = 1; m_nCalibCurrentExposureIndex = 1; m_nCalibCurrentExposureNum = 0; Info("==============================ActiveCalibration over"); return Ret; } RET_STATUS nsFPD::FPDDeviceTrixell::GetRequestedDose(std::string& strDose) { Info("==============================GetRequestedDose"); if (!m_stDeviceConfig.bConnectStatus) { return RET_STATUS::RET_THREAD_INVALID; } 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_fDoseParam * 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; Info("Find target dose parameter"); break; } } } else { Warn("Can not support CalibrationType({$})", (int)nCalibrationType); Ret = RET_STATUS::RET_FAILED; } if (bGetDoseInfo) { strDose = out.encode(); Info("GetRequestedDose {$} over", strDose.c_str()); } else { Error("GetRequestedDose failed"); } return Ret; } RET_STATUS nsFPD::FPDDeviceTrixell::SetRequestedDose(std::string strDose) { Info("==============================SetRequestedDose"); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; return Ret; } RET_STATUS nsFPD::FPDDeviceTrixell::PrepareCalibration() { Info("==============================PrepareCalibration"); if (!m_stDeviceConfig.bConnectStatus) { return RET_STATUS::RET_THREAD_INVALID; } m_SyncUnit->FPDReadyNotify(false); RET_STATUS Ret = RET_STATUS::RET_FAILED; if (RET_STATUS::RET_SUCCEED == ((TrixellCtrl*)m_pDetectors)->PrepareCalibration(this)) { m_SyncUnit->FPDReadyNotify(true); Ret = RET_STATUS::RET_SUCCEED; } else { Ret = RET_STATUS::RET_FAILED; } m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); Info("==============================PrepareCalibration over"); return Ret; } RET_STATUS nsFPD::FPDDeviceTrixell::StartCalibration() { Info("==============================StartCalibration"); if (!m_stDeviceConfig.bConnectStatus) { return RET_STATUS::RET_THREAD_INVALID; } /*if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus()) { if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus()) { Error("ActiveCalibration failed. Detector at Acq status"); } return RET_STATUS::RET_FAILED; }*/ RET_STATUS Ret = RET_STATUS::RET_FAILED; CCOS_CALIBRATION_TYPE eCalibrationType = m_CalibUnit->GetCalibrationType(); if (eCalibrationType == CCOS_CALIBRATION_TYPE_DARK) { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_CalibUnit->SetCalibrationProgress("100"); Info("DarkCalibration finish"); Info("==============================StartCalibration over"); return RET_STATUS::RET_SUCCEED; } m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING)); if (RET_STATUS::RET_SUCCEED == m_pDetectors->StartCalibration(this)) { Ret = RET_STATUS::RET_SUCCEED; } else { Ret = RET_STATUS::RET_FAILED; } Info("==============================StartCalibration over"); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceTrixell::PauseCalibration() { RET_STATUS Ret = RET_STATUS::RET_SUCCEED; m_nXrayCalibNum++; int nDose = (int)m_fDoseParam; if (nDose == 25 && m_nXrayCalibNum == 10) { Info("start to waitting CalibDoseEvt"); DWORD nRet = WaitForSingleObject(m_WaitCalibDoseEvt, INFINITE); //m_nXrayCalibNum = 0; } else if (nDose != 25) { if (m_nXrayCalibNum != 13) { Info("start to waitting CalibDoseEvt"); DWORD nRet = WaitForSingleObject(m_WaitCalibDoseEvt, INFINITE); } } ResetEvent(m_PauseCalibrationEvt); ResetEvent(m_WaitCalibDoseEvt); m_AcqUnit->SendNoNeedWaitImage(true); if (m_nXrayCalibNum != 13) { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); m_CalibUnit->PauseCalibration(); } Info("Driver PauseCalibration over,m_nXrayCalibNum {$}", m_nXrayCalibNum); return Ret; } RET_STATUS nsFPD::FPDDeviceTrixell::StopCalibration() { Info("==============================StopCalibration"); if (!m_stDeviceConfig.bConnectStatus) { return RET_STATUS::RET_THREAD_INVALID; } /*if (m_CalibUnit->GetCalibrationStatus() != CCOS_CALIBRATION_STATUS_RUNNING && m_CalibUnit->GetCalibrationStatus() != CCOS_CALIBRATION_STATUS_PAUSE) { return RET_STATUS::RET_FAILED; }*/ RET_STATUS Ret = RET_STATUS::RET_FAILED; m_eAppStatus = APP_STATUS_CAL_END; if (RET_STATUS::RET_SUCCEED == ((TrixellCtrl*)m_pDetectors)->AbortCalibration(this)) { m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); Ret = RET_STATUS::RET_SUCCEED; } else { Ret = RET_STATUS::RET_FAILED; } m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); Info("==============================StopCalibration over"); return RET_STATUS::RET_SUCCEED; } bool nsFPD::FPDDeviceTrixell::CompleteCalibration() { m_stDeviceConfig.fCalibTemperature2 = m_stDeviceConfig.fCurrentTemperValue; m_stDeviceConfig.fCalibTemperature = (m_stDeviceConfig.fCalibTemperature1 + m_stDeviceConfig.fCalibTemperature2) / 2; ResetEvent(m_UploadCalibMapOver); ((TrixellCtrl*)m_pDetectors)->CompleteCalibration(this); DWORD nRet = WaitForSingleObject(m_UploadCalibMapOver, 60000); if (WAIT_OBJECT_0 == nRet) { Info("got event m_UploadCalibMapOver"); } else if (WAIT_TIMEOUT == nRet) { Info("wait event m_UploadCalibMapOver timeout"); } else { Info("wait event m_UploadCalibMapOver error"); } m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); { m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_CalibUnit->SetCalibrationProgress("100"); } return true; } void nsFPD::FPDDeviceTrixell::AbortCalibration() { Info("AbortCalibration"); CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType(); if (CCOS_CALIBRATION_TYPE_DARK == nCalibrationType) { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ERROR)); m_CalibUnit->SetCalibrationProgress("100"); Info("AbortDarkCalibration over"); return; } m_eAppStatus = APP_STATUS_CAL_END; ((TrixellCtrl*)m_pDetectors)->AbortCalibration(this); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ERROR)); m_CalibUnit->SetCalibrationProgress("100"); m_AcqUnit->SendNoNeedWaitImage(true); Info("AbortCalibration over"); } RET_STATUS nsFPD::FPDDeviceTrixell::GetCalibrationStep(int nDetectorID, string& strCalibrationStepInfo) { Info("## GetCalibrationStep ##"); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; Info("Calibration DetectorID: {$}", nDetectorID); ResDataObject out; int nCalibrationRounds = (int)m_CalibDoseList.size(); int nExposureNumCurrentRound = (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"]; if (((TrixellCtrl*)m_pDetectors)->GetCalibrationStep(m_nCalibCurrentCalibrationRound, nCalibrationRounds, m_nCalibCurrentExposureIndex, nExposureNumCurrentRound)) { Info("GetCalibrationStep over"); Ret = RET_STATUS::RET_SUCCEED; } else { Error("GetCalibrationStep error"); Ret = RET_STATUS::RET_FAILED; } out.add("CalibrationRounds", (int)m_CalibDoseList.size()); out.add("TotalExposureNum", m_nCalibTotalExposureNum); out.add("CurrentCalibrationRound", m_nCalibCurrentCalibrationRound); out.add("ExposureNumCurrentRound", (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"]); out.add("CurrentExposureIndex", m_nCalibCurrentExposureIndex); out.add("CurrentExposureNum", m_nCalibCurrentExposureNum); strCalibrationStepInfo = out.encode(); Info("GetCalibrationStep over \n{$}", strCalibrationStepInfo.c_str()); return Ret; } RET_STATUS nsFPD::FPDDeviceTrixell::AcceptCalibration() { Info("## AcceptCalibration ##"); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; if (((TrixellCtrl*)m_pDetectors)->AcceptCalibration()) { Info("AcceptCalibration over"); Ret = RET_STATUS::RET_SUCCEED; } else { Error("AcceptCalibration error"); Ret = RET_STATUS::RET_FAILED; } int nExposureNumCurrentRound = (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"]; //完成校正条件:轮数够了,曝光次数够了 if ((m_nCalibCurrentCalibrationRound == (int)m_CalibDoseList.size()) && (m_nCalibCurrentExposureIndex == nExposureNumCurrentRound)) { Info("Calibration Round: {$}, Exposure Index: {$}, Finished", m_nCalibCurrentCalibrationRound, m_nCalibCurrentExposureIndex); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_CalibUnit->SetCalibrationProgress("100"); return Ret; } if (m_nCalibCurrentExposureIndex >= nExposureNumCurrentRound) //跳到下一轮校正参数 { m_nCalibCurrentCalibrationRound++; m_nCalibCurrentExposureIndex = 1; ResDataObject temp = m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]; int nDose = temp["Dose"]; m_fDoseParam = nDose / 1000.0f; } else { m_nCalibCurrentExposureIndex++; } m_nCalibCurrentExposureNum++; m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); return Ret; } RET_STATUS nsFPD::FPDDeviceTrixell::RejectCalibration() { Info("## RejectCalibration ##"); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; if (((TrixellCtrl*)m_pDetectors)->RejectCalibration()) { Info("RejectCalibration over"); Ret = RET_STATUS::RET_SUCCEED; } else { Error("RejectCalibration error"); Ret = RET_STATUS::RET_FAILED; } m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); return Ret; } RET_STATUS nsFPD::FPDDeviceTrixell::SaveCalibrationFile(bool bSaveFlag) { Info("## SaveCalibrationFile ##"); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; Info("SaveCalibrationFile by user: {$}", bSaveFlag); if (!bSaveFlag) { Warn("Not save calibration file"); return Ret; } if (((TrixellCtrl*)m_pDetectors)->SaveCalibrationFile()) { Info("SaveCalibrationFile over"); m_CalibUnit->SetSaveCalibrationFileFinish(true); Ret = RET_STATUS::RET_SUCCEED; //更新配置文件中校正日期和时间 time_t localtime = time(NULL); string strLocalTime = DatetimeToString(localtime); Info("strLocalTime:{$}", strLocalTime); m_CalibUnit->SetLastCalibrationDate(strLocalTime); //清除校正文件相关警告 m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_NOT_EXIST); m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_OUTDATE); } else { Error("SaveCalibrationFile error"); m_CalibUnit->SetSaveCalibrationFileFinish(false); Ret = RET_STATUS::RET_FAILED; } return Ret; } RET_STATUS nsFPD::FPDDeviceTrixell::GetDeviceDictionary(std::string& out) { ResDataObject m_DeviceDictionary; ResDataObject FPDinfo; //先用虚拟值 FPDinfo.add("SysVersion", "1.1"); FPDinfo.add("SubVersion", "1.1"); FPDinfo.add("FPGAVersion", "1.1"); m_DeviceDictionary.add("DriverType", "StaticDetector"); m_DeviceDictionary.add("DeviceName", "Trixell"); m_DeviceDictionary.add("DateOfManufacture", "2019.4.19"); m_DeviceDictionary.add("SoftwareVersion", "1.1"); m_DeviceDictionary.add("HardwareVersion", FPDinfo); m_DeviceDictionary.add("Description", m_stDeviceConfig.strDeviceName.c_str()); m_DeviceDictionary.add("Model", "Pixium"); m_DeviceDictionary.add("SerialNumber", m_DetectorConfiguration->m_Configurations["SerialNumber"]); out = m_DeviceDictionary.encode(); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceTrixell::ResetConnect() { ((TrixellCtrl*)m_pDetectors)->DisConnect(this); ((TrixellCtrl*)m_pDetectors)->Connect(m_strWorkPath.c_str(), this); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceTrixell::DisConnectFPD() { return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceTrixell::DisConnectFPDForce() { return RET_STATUS::RET_SUCCEED; } void nsFPD::FPDDeviceTrixell::FullImageDateArrived(WORD* pImg) { AddFrameWithRawHead(IMAGE_FULL, pImg, m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight); } void nsFPD::FPDDeviceTrixell::PrevImageDateArrived(WORD* pImg) { AddFrameWithRawHead(IMAGE_PREVIEW, pImg, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight); } RET_STATUS nsFPD::FPDDeviceTrixell::EnterExam(int nExamMode) { Info("EnterExam"); switch (nExamMode) { case APP_STATUS_WORK_BEGIN: Info("Enter into Exam Windows"); m_eAppStatus = APP_STATUS_WORK_BEGIN; ResetError(); CheckCalibrationDue(); break; case APP_STATUS_WORK_END: Info("Quit Exam Windows"); m_eAppStatus = APP_STATUS_WORK_END; m_WarnAndError->ClearAllWarn(); break; case APP_STATUS_DETSHARE_BEGIN: Info("Enter into Detector Share Windows"); m_eAppStatus = APP_STATUS_DETSHARE_BEGIN; break; case APP_STATUS_DETSHAR_END: m_eAppStatus = APP_STATUS_IDLE; Info("Quit Detector Share Windows"); m_eAppStatus = APP_STATUS_DETSHAR_END; break; case APP_STATUS_CAL_BEGIN: Info("Enter into Calibration Windows"); m_eAppStatus = APP_STATUS_CAL_BEGIN; break; case APP_STATUS_CAL_END: Info("Quit Calibration Windows"); m_eAppStatus = APP_STATUS_CAL_END; break; case APP_STATUS_WORK_IN_SENSITIVITY: Info("Enter into sensitivity test interface"); m_eAppStatus = APP_STATUS_WORK_IN_SENSITIVITY; break; default: break; } m_pDetectors->EnterExam(m_eAppStatus); return RET_STATUS::RET_SUCCEED; } bool nsFPD::FPDDeviceTrixell::GetLogicMode(string& strAcqMode, int& nLogicMode) { if (strAcqMode == "RAD") { nLogicMode = RAD; } else if (strAcqMode == "DDR") { nLogicMode = DDR; } else if (strAcqMode == "1") { nLogicMode = RAD; } else if (strAcqMode == "2") { nLogicMode = DDR; } else { Error("Not support mode!"); return false; } return true; } RET_STATUS nsFPD::FPDDeviceTrixell::SetAcqMode(string strAcqMode) { Info("nsFPD::FPDDeviceTrixell::SetAcqMode(string)"); if (!m_stDeviceConfig.bConnectStatus) { Error("m_stDeviceConfig.bConnectStatus = false"); return RET_STATUS::RET_FAILED; } int nAcqMode = 1; int nWidth = m_stDeviceConfig.nFullImageWidth; int nHeight = m_stDeviceConfig.nFullImageHeight; int nBit = m_stDeviceConfig.nImageBits; Info("ImageSize({$} {$}), bits({$})", nWidth, nHeight, nBit); m_AcqUnit->SetFulImageInfo(nHeight, nWidth, nBit, false); m_AcqUnit->SetPrevImageInfo(m_stDeviceConfig.bPreviewEnable, m_stDeviceConfig.nPreviewHeight, m_stDeviceConfig.nPreviewWidth, false); if (m_pDetectors->SelectExamMode(nAcqMode, this)) { return RET_STATUS::RET_SUCCEED; } return RET_STATUS::RET_FAILED; } //设置采集模式 RET_STATUS nsFPD::FPDDeviceTrixell::SetAcqMode(int nMode) { Info("nsFPD::FPDDeviceTrixell::SetAcqMode"); if (!m_stDeviceConfig.bConnectStatus) { Error("m_stDeviceConfig.bConnectStatus = false"); return RET_STATUS::RET_FAILED; } int nWidth = m_stDeviceConfig.nFullImageWidth; int nHeight = m_stDeviceConfig.nFullImageHeight; int nBit = m_stDeviceConfig.nImageBits; Info("ImageSize({$} {$}), bits({$})", nWidth, nHeight, nBit); m_AcqUnit->SetFulImageInfo(nHeight, nWidth, nBit, false); m_AcqUnit->SetPrevImageInfo(m_stDeviceConfig.bPreviewEnable, m_stDeviceConfig.nPreviewHeight, m_stDeviceConfig.nPreviewWidth, false); if (m_pDetectors->SelectExamMode(1, this)) { return RET_STATUS::RET_SUCCEED; } return RET_STATUS::RET_FAILED; } void nsFPD::FPDDeviceTrixell::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::FPDDeviceTrixell::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; Info("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; } Info("Panel {$} nRawWidth:{$}", nDetectorID, m_stDeviceConfig.nRawWidth); break; } case EVT_CONF_RAW_HIGHT: { if (m_stDeviceConfig.nFullImageHeight != nParam1) { m_stDeviceConfig.nFullImageHeight = nParam1; } Info("Panel {$} nRawHeight:{$}", nDetectorID, m_stDeviceConfig.nRawHeight); break; } case EVT_CONF_RAW_BITS: { m_stDeviceConfig.nImageBits = nParam1; Info("Panel {$} nImageBits:{$}", nDetectorID, m_stDeviceConfig.nImageBits); break; } case EVT_CONF_PIXELSPACE: { m_stDeviceConfig.nPixelSpace = (int)fParam2; Info( "Panel {$} nPixelSpace:{$}", nDetectorID, m_stDeviceConfig.nPixelSpace); break; } case EVT_CONF_PREVIEW_WIDTH: { if (m_stDeviceConfig.nPreviewWidth != nParam1) { m_stDeviceConfig.nPreviewWidth = nParam1; } Info("Panel {$} nPreviewWidth:{$}", nDetectorID, m_stDeviceConfig.nPreviewWidth); break; } case EVT_CONF_PREVIEW_HIGHT: { if (m_stDeviceConfig.nPreviewHeight != nParam1) { m_stDeviceConfig.nPreviewHeight = nParam1; } Info("Panel {$} nPreviewHeight:{$}", nDetectorID, m_stDeviceConfig.nPreviewHeight); break; } case EVT_CONF_MODULE_TYPE: { //m_strModuleType = pszMsg; Info("Receive Panel {$} ModuleType {$}", nDetectorID, pszMsg); break; } case EVT_CONF_MODULE_IP: { //m_strModuleIP = pszMsg; Info("Receive Panel {$} ModuleIP {$}", nDetectorID, pszMsg); break; } case EVT_CONF_MODULE_SN: { //m_strModuleSN = pszMsg; Info("Receive Panel {$} ModuleSN {$}", nDetectorID, pszMsg); break; } case EVT_CONF_FIRWARE_UPDATE: { m_stDeviceConfig.nFirmwareStatus = nParam1; Info("Panel {$} FirmwareUpdate:{$}", nDetectorID, m_stDeviceConfig.nFirmwareStatus); break; } case EVT_CONF_PART_NUMBER: { m_stDeviceConfig.strPartNumber = pszMsg; Info("Panel {$} PartNumber:{$}", nDetectorID, pszMsg); break; } case EVT_CONF_BATTERY_SN: { Info("Panel {$} Battery SN:{$}", nDetectorID, pszMsg); break; } case EVT_CONF_WIFI_SSID: { m_stDeviceConfig.strWifiSSID = pszMsg; Info("Panel {$} WifiSSID:{$}", nDetectorID, pszMsg); break; } case EVT_CONF_IFBOARD: { Info("Panel {$} InterfaceBoard:{$}", nDetectorID, pszMsg); break; } case EVT_CONF_DATECODE: { Info("Panel {$} DateCode:{$}", nDetectorID, pszMsg); break; } case EVT_CONF_LIFETIME: { int nLifeTime = nParam1; if ((nLifeTime != m_stDeviceConfig.nLifeTime)) { Info("LifeTime:{$}", nLifeTime); m_stDeviceConfig.nLifeTime = nLifeTime; } break; } default: break; } } void nsFPD::FPDDeviceTrixell::OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { int nID = nDetectorID; switch (nEventID) { case EVT_INFO_POWER_ON: { int nPowerOn = nParam1; Info("Detector {$} PowerOn:{$}", nID, nPowerOn); if ((nPowerOn != m_stDeviceConfig.nPowerOn)) { m_stDeviceConfig.nPowerOn = nPowerOn; } break; } case EVT_INFO_BATTERY_CAPACITY: { int nBatteryCapacity = nParam1; if ((nBatteryCapacity != m_nBatteryCapacity)) { Info("{$}", nBatteryCapacity); m_nBatteryCapacity = nBatteryCapacity; } break; } case EVT_INFO_BATTERY_TEMPERATURE: { Info("Battery temperature: {$}", fParam2); break; } case EVT_INFO_BATTERY_CHARGES: { int nBatteryCharges = nParam1; if (nBatteryCharges != m_nBatteryCharges) { Info("Charge number:{$}", nBatteryCharges); m_nBatteryCharges = nBatteryCharges; } break; } case EVT_INFO_WIFI_DATARATE: { m_stDeviceConfig.nWifiDataRate = nParam1; Info("Detector {$} WifiDataRate:{$}", nID, m_stDeviceConfig.nWifiDataRate); break; } case EVT_INFO_WIFI_CHANNEL: { m_stDeviceConfig.nWifiChannel = nParam1; Info("Panel {$} WifiChannel:{$}", nID, m_stDeviceConfig.nWifiChannel); break; } case EVT_INFO_WIFI_SIGNALPOWER: { m_stDeviceConfig.nWifiSignalPower = nParam1; break; } case EVT_INFO_WIFI_NOISEPOWER: { m_stDeviceConfig.nWifiNoisePower = nParam1; Info("Panel {$} WifiNoisePower:{$}", nID, m_stDeviceConfig.nWifiNoisePower); break; } case EVT_INFO_FIRMWARE: { m_stDeviceConfig.strFirmware = pszMsg; Info("Panel {$} Firmware:{$}", nID, pszMsg); break; } case EVT_INFO_SHOCKSENSOR_INFO: { Info("Receive ShockSensor Info"); break; } case EVT_INFO_CALIBRATIOIN_TIME: { m_stDeviceConfig.strCalibrationDate = pszMsg; Info("Panel {$} Calibration Time:{$}", nID, pszMsg); m_DetectorCtrlUnit->SetDateofLastDetectorCalibration(m_stDeviceConfig.strCalibrationDate); m_DetectorCtrlUnit->SetTimeofLastDetectorCalibration(""); break; } case EVT_INFO_CALIBRATIOIN_TIMEL: { Info("Panel {$} Calibration LTE Time:{$}", nID, pszMsg); break; } case EVT_INFO_FPVOLTAGE: { break; } default: break; } } void nsFPD::FPDDeviceTrixell::OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { int nID = nDetectorID; switch (nEventID) { case EVT_STATUS_INIT: { string strPath = m_strWorkPath + "\\OEMDrivers\\Detector\\Trixell\\TrixellDRDetector\\PIXIUMAPI\\pixrad.dll"; m_stDeviceConfig.strSoftware = GetFileVersion(strPath); Info("pixrad.dll version : {$} init staus {$}", m_stDeviceConfig.strSoftware.c_str(), nParam1); printf("-------- pixrad EVT_STATUS_INIT %d \n", nParam1); if (PANEL_EVENT_END_OK == nParam1) { OnInitResult(true); m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_SUCCESS)); Info("connect FPD ok. Start Status Polling"); } else if (PANEL_EVENT_END_ERROR == nParam1) { OnInitResult(false); m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_FAILED)); } else if (PANEL_EVENT_END == nParam1) //未连接探测器 { m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_SUCCESS)); } else if (PANEL_EVENT_START == nParam1) { m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_START)); } break; } case EVT_STATUS_MOTION: { break; } case EVT_STATUS_UPDATE_FIRMWARE: { if (PANEL_EVENT_START == nParam1) { Info("Start update firmware"); m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_START)); } else if (PANEL_EVENT_BEGIN == nParam1) { Info("Update firmware begin"); m_stDeviceConfig.bConnectStatus = false; } else if (PANEL_EVENT_END_ERROR == nParam1) { Info("Update firmware failed"); //SendDetectorInfo(); //更新探测器状态图标 m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_ERROR)); } else if (PANEL_EVENT_SUCCESS == nParam1) { Info("update firmware success"); //SendDetectorInfo(); m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_SUCCESS)); } break; } case EVT_STATUS_SELFTEST: { break; } case EVT_STATUS_DETECTORSHARE: { break; } case EVT_STATUS_SINGLEINIT: { break; } case EVT_STATUS_SELECTPANEL: { break; } case EVT_STATUS_PANEL: { ENUM_PANEL_STATUS m_ePanelStatus = (ENUM_PANEL_STATUS)nParam1; if (PANEL_STANDBY == nParam1) { Info("Panel Status:PREPARE"); } else if (PANEL_READY_EXP == nParam1) { Info("Panel Status:READY"); Action_ExpReady(); } else if (PANEL_OFFSET_CAL == nParam1) { Info("Panel Status:PANEL_OFFSET_CAL"); } else if (PANEL_OFFSET_FINISH == nParam1) { Info("Panel Status:PANEL_OFFSET_FINISH"); } else if (PANEL_XWINDOW_ON == nParam1) //Xwindow On { Info("Panel Status:XWINDOW_ON"); XWindowOnNotify(); } else if (PANEL_XWINDOW_OFF == nParam1) // Xwindow Off { Info("Panel Status:XWINDOW_OFF"); XWindowOffNotify(); if (APP_STATUS_CAL_BEGIN == m_eAppStatus) { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); } } else if (PANEL_GET_IMAGE == nParam1) { Info("Panel Status: PANEL_GET_IMAGE"); } else if (PANEL_GAIN_FINISH == nParam1) { Info("Panel Status:CALIBRATION_FINISH"); } else if (PANEL_GAIN_PREPARE == nParam1) { Info("Detector Notify Xray Prepare"); } else if (PANEL_GAIN_READY_EXP == nParam1) { Action_ExpReady(); } else if (PANEL_AED_XRAY_ON == nParam1) { Info("AED xray on"); m_SyncUnit->XrayOnNotify(); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ)); } else if (PANEL_AED_XRAY_OFF == nParam1) { Info("AED xray off"); m_SyncUnit->XrayOffNotify(); } else { Info("Panel {$} Status is :{$}", nID, (int)m_ePanelStatus); } 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: Info("Calibration process is success"); CompleteCalibration(); break; case PANEL_EVENT_END_ERROR: Info("Calibration process is failed"); break; case PANEL_EVENT_TIMEOUT: Info("Calibration timeout"); Info("Calibration process is failed"); break; default: break; } break; } case EVT_STATUS_SAVECALIB: { if (PANEL_EVENT_START == nParam1) { Info("Begin to Save Calibration Files"); } else if (PANEL_EVENT_END_ERROR == nParam1) { SetEvent(m_UploadCalibMapOver); Info("Save Calibration Files failed"); } else if (PANEL_EVENT_END == nParam1) { SetEvent(m_UploadCalibMapOver); Info("Save Calibration Files Success"); } break; } case EVT_STATUS_SAVEDEFECT: { if (PANEL_EVENT_START == nParam1) { Info("Begin to Save Defect Files"); } else if (PANEL_EVENT_END_ERROR == nParam1) { SetEvent(m_UploadCalibMapOver); Info("Save Defect Files failed"); } else if (PANEL_EVENT_END == nParam1) { m_stDeviceConfig.bTaskEnd = true; Info("Save Defect Files Success"); SetEvent(m_UploadCalibMapOver); } break; } case EVT_STATUS_ACQUISITION: { ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1; switch (eStatus) { case PANEL_EVENT_START: break; case PANEL_EVENT_END_OK: break; case PANEL_EVENT_END_ERROR: break; default: break; } break; } case EVT_STATUS_SINGLEEXP: { if (DOSE_TOO_HIGH == nParam1) { Info("Dose too high"); OnError(nID, "ERR_FPD_DOSE_INVALID", m_strLastError); StopCalibration(); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_CalibUnit->SetCalibrationProgress("100"); m_AcqUnit->SendNoNeedWaitImage(true); } else if (DOSE_TOO_LOW == nParam1) { Info("Dose too low"); OnError(nID, "ERR_FPD_DOSE_INVALID", m_strLastError); StopCalibration(); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_CalibUnit->SetCalibrationProgress("100"); m_AcqUnit->SendNoNeedWaitImage(true); } else if (DOSE_OBJECT == nParam1) { Info("Dose object"); OnError(nID, "ERR_FPD_DOSE_INVALID", m_strLastError); StopCalibration(); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_AcqUnit->SendNoNeedWaitImage(true); } else if (DOSE_ACCEPT == nParam1) { Info("Calibration Result is acceptable"); SetEvent(m_PauseCalibrationEvt); } else if (EVT_STATUS_LASTERROR == nParam1) { m_strLastError = pszMsg; Info("Panel {$} LastError {$}", nID, pszMsg); } //endif break; } case EVT_STATUS_IMAGEPENDING: { string strTemp = pszMsg; if (strTemp.find("true") != std::string::npos) { m_bImagePendingOrNot = true; } else { m_bImagePendingOrNot = false; } if (m_bImagePendingOrNot) // && !m_bResetDetector { OnError(nID, "ERR_FPD_IMAGE_PENDING"); } else { m_bResetDetector = false;//可以再次reset } break; } case EVT_STATUS_TEMPERATURE: { float fTemperature = fParam2; OnProcessTemperature(nID, fTemperature); m_stDeviceConfig.fCurrentTemperValue = fTemperature; SendTemperatureValue(); break; } case EVT_STATUS_WIFI: { int nWifiLevel = nParam1; if (m_stDeviceConfig.strDeviceName.find("3543DR") >= 0) { nWifiLevel = int(nWifiLevel / 0.75); if (nWifiLevel > 100) { nWifiLevel = 100; } } Info("Detector {$} Wifi Value:{$}", nID, nWifiLevel); if (nWifiLevel == 0) //WIFI值为0 表明是有线连接,不报错 { ClearError(nID, ERR_FPD_WIFI_LOW); ClearWarn(nID, WAR_FPD_WIFI_LOW); } else if (nWifiLevel < m_stDeviceConfig.nWifiLimit) { ClearWarn(nID, WAR_FPD_WIFI_LOW); OnError(nID, ERR_FPD_WIFI_LOW); } else if (nWifiLevel <= m_stDeviceConfig.nWifiWarning) { ClearError(nID, ERR_FPD_WIFI_LOW); OnWarn(nID, WAR_FPD_WIFI_LOW); } else { ClearWarn(nID, WAR_FPD_WIFI_LOW); ClearError(nID, ERR_FPD_WIFI_LOW); } if (nWifiLevel != m_stDeviceConfig.nCurrentWifiValue) { Info("Channel:{$},SignalPower:{$},NoisePower:{$},DataRate:{$}", m_stDeviceConfig.nWifiChannel, m_stDeviceConfig.nWifiSignalPower, m_stDeviceConfig.nWifiNoisePower, m_stDeviceConfig.nWifiDataRate); } //endif m_stDeviceConfig.nCurrentWifiValue = nWifiLevel; SendWifiValue(); //SendDetectorInfo(); break; } case EVT_STATUS_BATTERY_VALUE: { int nBatteryValue = nParam1; Info("Detector {$} Battery:{$}", nID, nParam1); if (nBatteryValue < m_stDeviceConfig.nBatteryLimit) { //battery error ClearWarn(nID, WAR_FPD_BATTERY_LOW); OnError(nID, ERR_FPD_BATTERY_LOW); } else if (nBatteryValue < m_stDeviceConfig.nBatteryWarning) { //battery warning ClearError(nID, ERR_FPD_BATTERY_LOW); OnWarn(nID, WAR_FPD_BATTERY_LOW); } else { ClearWarn(nID, WAR_FPD_BATTERY_LOW); ClearError(nID, ERR_FPD_BATTERY_LOW); } m_stDeviceConfig.nCurrentBatteryValue = nBatteryValue; Info("Detector {$} Battery Value:{$}", nID, nBatteryValue); SendBatteryValue(); break; } case EVT_STATUS_BATTERY_CHARGING: { string strTemp = pszMsg; if (strTemp.find("true") != std::string::npos) { m_bBatteryCharging = true; } else { m_bBatteryCharging = false; } break; } case EVT_STATUS_SHOCK_SENSOR: { break; } case EVT_STATUS_HALL_SENSOR: { break; } case EVT_STATUS_PING: { break; } case EVT_STATUS_RESTOREFILES: { break; } case EVT_STATUS_LASTERROR: { m_strLastError = pszMsg; Info("Panel {$} LastError {$}", nID, pszMsg); break; } case EVT_STATUS_RESET: { Info("Detector reset status: {$}", nParam1); break; } case EVT_AUTONUMOUS_STATUS: { ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1; switch (eStatus) { case PANEL_CONNECT_ERROR: { break; } case PANEL_CONNECT_OK: { m_stDeviceConfig.bConnectStatus = true; break; } case PANEL_DISCONNECT_SUCCESS: { m_nBatteryCapacity = 0; m_stDeviceConfig.bExisted = false; m_stDeviceConfig.bConnectStatus = false; break; } case PANEL_DISCONNECT_ERROR: { break; } case PANEL_START_STOREDIMAGE: { Info("Send start autonumous to server"); m_AcqUnit->SendAutonumousMapFinish(0); break; } case PANEL_END_STOREDIMAGE: { Info("Send finish autonumous to server"); m_AcqUnit->SendAutonumousMapFinish(1); break; } case PANEL_EXPORT_AUTONUMOUS_FINISH: { Info("Send finish export local autonumous to server"); m_AcqUnit->SendAutonumousMapFinish(2); break; } default: break; } break; } default: break; } } void nsFPD::FPDDeviceTrixell::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: { Info("EVT_DATA_RAW_IMAGE"); Info("Currenct Image Width:{$}, Height:{$}", m_stDeviceConfig.nFullImageWidth, m_stDeviceConfig.nFullImageHeight); float fImageReferUGY = 2.5; if (APP_STATUS_WORK_BEGIN == m_eAppStatus) //如果是在检查中 { fImageReferUGY = 2.5; } if (NULL == m_pwRawImageData) { m_pwRawImageData = new WORD[m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight]; } memcpy(m_pwRawImageData, pParam, m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight * sizeof(WORD)); OnProcessImage(m_pwRawImageData, m_stDeviceConfig.nFullImageWidth, m_stDeviceConfig.nFullImageHeight, fImageReferUGY); break; } case EVT_DATA_PREVIEW_IMAGE: { Info("Preview Image Arrved"); Info("Current FPD preview image width: {$}, height: {$}", m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight); m_SyncUnit->ImageReadingNotify(); if (NULL == m_pwPreviewImg) { m_pwPreviewImg = new WORD[m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight]; } memcpy(m_pwPreviewImg, pParam, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * sizeof(WORD)); OnProcessPreviewImage(m_pwPreviewImg, m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight); break; } case EVT_DATA_DOSEPARAM: { m_fDoseParam = fParam2; SetEvent(m_WaitCalibDoseEvt); break; } default: break; } } void nsFPD::FPDDeviceTrixell::OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { string strErrorName = ""; switch (nEventID) { case EVT_ERR_COMMUNICATE: { string strTemp = pszMsg; if (strTemp.find("true") != std::string::npos) { m_stDeviceConfig.nWorkstation = -1; m_stDeviceConfig.bConnectStatus = false; m_nBatteryCapacity = 0; m_stDeviceConfig.fCurrentTemperValue = 0.0f; m_stDeviceConfig.nCurrentWifiValue = 0; m_stDeviceConfig.nCurrentBatteryValue = 0; SendWifiValue(); SendBatteryValue(); SendTemperatureValue(); OnError(nDetectorID, ERR_FPD_DISCONNECT, ""); m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_ERROR)); } else if (strTemp.find("false") != std::string::npos)//成功时交给WIFI发送SendDetectorInfo { m_stDeviceConfig.bConnectStatus = true; ClearError(nDetectorID, ERR_FPD_DISCONNECT); m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK)); } break; } case EVT_ERR_EXP_REQUEST: { string strTemp = pszMsg; if (strTemp.find("true") != std::string::npos) { } else { return; } strErrorName = "ERR_FPD_ACQ_FAILED"; break; } case EVT_ERR_GET_IMAGE: { string strTemp = pszMsg; if (strTemp.find("true") != std::string::npos) { if (APP_STATUS_WORK_BEGIN != m_eAppStatus) //如果不在检查界面; { Fatal("there are image exist in current detector,do you want to continue"); } else //if (m_bSiemensCmd) { Fatal("FPD has exposed Image!"); //CallSiemensRecoverAction(true); } //endif } else if (strTemp.find("false") != std::string::npos) { //CallSiemensRecoverAction(false); } break; } case EVT_ERR_MAX_NUMBER: { //strErrorName = ERR_FPD_MAX_NUMBER; //string strTemp = pszMsg; //if (strTemp.find("true") != std::string::npos) //{ // Error("Exceed max number"); // OnError(nDetectorID, strErrorName); //} break; } case EVT_ERR_SN_NOTINLIST: { //strErrorName = ERR_FPD_SN_NOT_LIST; //Error("Not in List"); //string strTemp = pszMsg; //if (strTemp.find("true") != std::string::npos) //{ // OnError(nDetectorID, strErrorName); //} break; } case EVT_ERR_POWER_OFF: { strErrorName = "ERR_FPD_POWEROFF"; string strTemp = pszMsg; if (strTemp.find("true") != std::string::npos) { OnError(nDetectorID, strErrorName); m_stDeviceConfig.bConnectStatus = false; } else if (strTemp.find("false") != std::string::npos) { m_WarnAndError->ClearError(strErrorName); } break; } case EVT_ERR_INIT_FAILED: { strErrorName = "ERR_FPD_FATAL_ERROR"; string strTemp = pszMsg; if (strTemp.find("true") != std::string::npos) { OnError(nDetectorID, strErrorName); m_stDeviceConfig.bConnectStatus = false; } else if (strTemp.find("false") != std::string::npos) { //m_WarnAndError->OnErrorX(strErrorName); } break; } default: break; } } void nsFPD::FPDDeviceTrixell::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { Warn("Not support this warn({$})", nEventID); } bool nsFPD::FPDDeviceTrixell::OnInitResult(bool bSuccess) { if (bSuccess) { m_stDeviceConfig.bConnectStatus = true; //CheckCalibartionDue(); //LoadSensitivity(); } else { m_stDeviceConfig.bConnectStatus = false; } m_stDeviceConfig.bExisted = true; return true; } bool nsFPD::FPDDeviceTrixell::OnProcessPreviewImage(WORD* pwRawImage, int nWidth, int nHeight) { Info("Currenct PreviewImage Width:{$},Height:{$}", m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight); PrevImageDateArrived(pwRawImage); Info("Write PreviewImage Over"); return true; } bool nsFPD::FPDDeviceTrixell::OnProcessImage(WORD* pwRawImage, int nImageWidth, int nImageHeight, float fImageReferUGY) { Info("OnProcessImage start"); if (nImageWidth < m_nFullImgWidth + m_nLeftOffset) { Info("nImageWidth:{$},m_nFullImgWidth: {$},m_nLeftOffset:{$}", nImageWidth, m_nFullImgWidth, m_nLeftOffset); m_nFullImgWidth = nImageWidth; m_nLeftOffset = 0; } if (nImageHeight < m_nFullImgHeight + m_nTopOffset) { Info("nImageHeight:{$},m_nFullImgHeight: {$},m_nLeftOffset:{$}", nImageHeight, m_nFullImgHeight, m_nTopOffset); m_nFullImgHeight = nImageHeight; m_nTopOffset = 0; } /*bool bResult = GetEffectiveImage(pwRawImage, nImageWidth); if (!bResult) { return true; }*/ //m_pwFullImageData[0] = 65535;//坐标原点 bug 8164 //FullImageDateArrived(m_pwFullImageData); FullImageDateArrived(pwRawImage); Info("Write Frame Over"); Info("OnProcessImage end"); return true; } /*************************************************************** 功能:将原始尺寸的图像裁剪为有效尺寸的图像 [IN][OUT]:pOutImg 有效尺寸图像信息 [IN]:pInImgData 原始尺寸图像数据 [IN]:nInWidth 原始尺寸图像的宽度 [IN]:nUpHeightOffset 要裁剪的上边高度 [IN]:nLeftWidthOffset要裁剪的左边宽度 ************************************************************/ bool nsFPD::FPDDeviceTrixell::GetEffectiveImage(WORD* pwInImgData, int nRawImageWidth) { if (pwInImgData == NULL) { return false; } if (!m_pwFullImageData) { Info("Full ImgHeight:{$},Full ImgWidth:{$}", m_stDeviceConfig.nFullImageWidth, m_stDeviceConfig.nFullImageHeight); m_pwFullImageData = new WORD[m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight]; } memcpy(m_pwFullImageData, pwInImgData, m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight * sizeof(WORD)); return true; try { Info("TopOffset:{$},LeftOffset:{$},RawImgWidth:{$}", m_nTopOffset, m_nLeftOffset, nRawImageWidth); for (int i = 0; i < m_nFullImgHeight; i++) { memcpy(m_pwFullImageData + i * m_nFullImgWidth, pwInImgData + (i + m_nTopOffset) * nRawImageWidth + m_nLeftOffset, m_nFullImgWidth * sizeof(WORD)); } } catch (...) { Info("Get Effective Image Crash"); return false; } return true; } void nsFPD::FPDDeviceTrixell::OnProcessTemperature(int nID, float fTemperature) { if (fTemperature >= m_stDeviceConfig.fTemperMaxLimit) { Info("Exceed Max Temperature"); m_stDeviceConfig.nTemperatureStatus = TEMP_TOO_HIGH; ClearWarn(nID, WAR_FPD_TEMPERATURE_HIGH); ClearWarn(nID, WAR_FPD_TEMPERATURE_LOW); ClearError(nID, ERR_FPD_TEMPERATURE_LOW); OnError(nID, ERR_FPD_TEMPERATURE_HIGH); } else if (fTemperature <= m_stDeviceConfig.fTemperMinLimit) { Info("Exceed Min Temperature"); m_stDeviceConfig.nTemperatureStatus = TEMP_TOO_LOW; ClearWarn(nID, WAR_FPD_TEMPERATURE_HIGH); ClearWarn(nID, WAR_FPD_TEMPERATURE_LOW); ClearError(nID, ERR_FPD_TEMPERATURE_HIGH); OnError(nID, ERR_FPD_TEMPERATURE_LOW); } else if (fTemperature >= m_stDeviceConfig.fTemperUpperLimit) { Info("Exceed Temperature High Warning"); m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING; ClearError(nID, ERR_FPD_TEMPERATURE_LOW); ClearError(nID, ERR_FPD_TEMPERATURE_HIGH); ClearWarn(nID, WAR_FPD_TEMPERATURE_LOW); OnWarn(nID, WAR_FPD_TEMPERATURE_HIGH); } else if (fTemperature <= m_stDeviceConfig.fTemperLowLimit) { Info("Exceed Temperature Low Warning"); m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING; ClearError(nID, ERR_FPD_TEMPERATURE_LOW); ClearError(nID, ERR_FPD_TEMPERATURE_HIGH); ClearWarn(nID, WAR_FPD_TEMPERATURE_HIGH); OnWarn(nID, WAR_FPD_TEMPERATURE_LOW); } else if ((fTemperature < m_stDeviceConfig.fTemperUpperLimit) && (fTemperature > m_stDeviceConfig.fTemperLowLimit)) { //Info("Temperature Normal"); m_stDeviceConfig.nTemperatureStatus = TEMP_NORMAL; ClearError(nID, ERR_FPD_TEMPERATURE_LOW); ClearError(nID, ERR_FPD_TEMPERATURE_HIGH); ClearWarn(nID, WAR_FPD_TEMPERATURE_HIGH); ClearWarn(nID, WAR_FPD_TEMPERATURE_LOW); }//end if } void nsFPD::FPDDeviceTrixell::Action_ExpReady() { m_SyncUnit->FPDReadyNotify(true); } /*** * 客户端获取探测器信息 ***/ RET_STATUS nsFPD::FPDDeviceTrixell::GetDetectorInfo(string& strFDI) { ResDataObject strDetectorInfo; string strTempTemp = " "; Info("Get Detector Info"); if (m_stDeviceConfig.strPanelSerial == "") { Info("Get Detector Info Failed, Send Default Info"); strDetectorInfo.add("DetectorName", "Simulator"); strDetectorInfo.add("DetectorSN", "Simulator"); strDetectorInfo.add("Firmware", " "); strDetectorInfo.add("APFirmware", " "); strDetectorInfo.add("Software", m_stDeviceConfig.strSoftware.c_str()); 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"); //encode strFDI = 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("DateCode", " "); 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); //System Workstation if (m_stDeviceConfig.strDeviceName.find("3543") != std::string::npos) { strDetectorInfo.add("SystemAS", /*m_stDeviceConfig.nWorkstation*/3); } else { strDetectorInfo.add("SystemAS", /*m_stDeviceConfig.nWorkstation*/3); } //DetectorCalibrationDate if (m_stDeviceConfig.strCalibrationDate != " ") { if (m_stDeviceConfig.strCalibrationDate.find("19700101") != std::string::npos) { strDetectorInfo.add("CalibrationDate", "0"); strDetectorInfo.add("CalibrationDue", "0"); strDetectorInfo.add("CalibrationExist", 0); } else { strDetectorInfo.add("CalibrationDate", m_stDeviceConfig.strCalibrationDate.c_str()/*"20210610"*/); strDetectorInfo.add("CalibrationDue", m_stDeviceConfig.strCalibrationDue.c_str()/*"20210610"*/); strDetectorInfo.add("CalibrationExist", 1); } } else { strDetectorInfo.add("CalibrationDate", "0"); strDetectorInfo.add("CalibrationDue", "0"); strDetectorInfo.add("CalibrationExist", 0); } if (m_stDeviceConfig.bConnectStatus) { strDetectorInfo.add("CommunicationStatus", 1); } else { strDetectorInfo.add("CommunicationStatus", 0); } strDetectorInfo.add("FDCalibrationTemperature", m_stDeviceConfig.fCalibTemperature); strDetectorInfo.add("ShockSensor", m_nShockCounts); strDetectorInfo.add("FirmwareUpdate", 0); //Info( "{$}", strDetectorInfo.encode()); strFDI = strDetectorInfo.encode(); return RET_STATUS::RET_SUCCEED; } string nsFPD::FPDDeviceTrixell::MakeImageHead(IMAGE_VIEW_TYPE Type) { if (Type == IMAGE_FULL) { float fFactorEXI2UGY = 1.0f; if (APP_STATUS_WORK_BEGIN == m_eAppStatus) { fFactorEXI2UGY = m_fFactorEXI2UGY; } if (m_pFullImageHead == NULL) { m_pFullImageHead = new ResDataObject; ResDataObject json; json.add(SM_IMAGE_TYPE, (int)Type); json.add(SM_IMAGE_WIDTH, m_stDeviceConfig.nFullImageWidth); json.add(SM_IMAGE_HEIGHT, m_stDeviceConfig.nFullImageHeight); json.add(SM_IMAGE_BIT, 16); json.add(SM_IMAGE_TAG, 1); json.add(SM_IMAGE_INDEX, 1); json.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear); json.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth); json.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay); json.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour); json.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute); json.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond); json.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds); json.add(SM_IMAGE_LSB, "5000"); json.add(SM_IMAGE_DOSE, m_stDeviceConfig.nDoseOfEXI); json.add(SM_IMAGE_PIXELREPRESENTATION, "1"); json.add(SM_IMAGE_PIXELSPACING, m_stDeviceConfig.nPixelSpace); json.add(SM_IMAGE_ROTATION, "No"); json.add(SM_IMAGE_FLIP, "No"); json.add(SM_IMAGE_ORIGINX, "0"); json.add(SM_IMAGE_ORIGINY, "0"); json.add(SM_IMAGE_EXI2UGY, fFactorEXI2UGY); json.add(SM_IMAGE_TEMP, 0.0f); m_pFullImageHead->add(SM_IMAGE_HEAD, json); } else { (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_YEAR] = m_stImgCreateTime.wYear; (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MONTH] = m_stImgCreateTime.wMonth; (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_DAY] = m_stImgCreateTime.wDay; (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_HOUR] = m_stImgCreateTime.wHour; (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MINUTE] = m_stImgCreateTime.wMinute; (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_SEC] = m_stImgCreateTime.wSecond; (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MILLSEC] = m_stImgCreateTime.wMilliseconds; (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_TEMP] = m_stDeviceConfig.fCurrentTemperValue; Info("Temperature in image is {$}", m_stDeviceConfig.fCurrentTemperValue); } return (*m_pFullImageHead).encode(); } else { if (m_pPreviewImageHead == NULL) { m_pPreviewImageHead = new ResDataObject; ResDataObject json; json.add(SM_IMAGE_TYPE, (int)Type); json.add(SM_IMAGE_WIDTH, m_stDeviceConfig.nPreviewWidth); json.add(SM_IMAGE_HEIGHT, m_stDeviceConfig.nPreviewHeight); json.add(SM_IMAGE_BIT, 16); json.add(SM_IMAGE_TAG, 1); json.add(SM_IMAGE_INDEX, 1); json.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear); json.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth); json.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay); json.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour); json.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute); json.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond); json.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds); json.add(SM_IMAGE_LSB, "5000"); json.add(SM_IMAGE_DOSE, m_stDeviceConfig.nDoseOfEXI); json.add(SM_IMAGE_ROTATION, "No"); json.add(SM_IMAGE_FLIP, "No"); json.add(SM_IMAGE_ORIGINX, "0"); json.add(SM_IMAGE_ORIGINY, "0"); json.add(SM_IMAGE_PIXELSPACING, m_stDeviceConfig.nPixelSpace); json.add(SM_IMAGE_PIXELREPRESENTATION, "1"); json.add(SM_IMAGE_TEMP, m_stDeviceConfig.fCurrentTemperValue); m_pPreviewImageHead->add(SM_IMAGE_HEAD, json); } else { (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_YEAR] = m_stImgCreateTime.wYear; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MONTH] = m_stImgCreateTime.wMonth; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_DAY] = m_stImgCreateTime.wDay; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_HOUR] = m_stImgCreateTime.wHour; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MINUTE] = m_stImgCreateTime.wMinute; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_SEC] = m_stImgCreateTime.wSecond; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MILLSEC] = m_stImgCreateTime.wMilliseconds; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_TEMP] = m_stDeviceConfig.fCurrentTemperValue; } return (*m_pPreviewImageHead).encode(); } return ""; } RET_STATUS nsFPD::FPDDeviceTrixell::AddFrameWithRawHead(IMAGE_VIEW_TYPE Type, WORD* pFrameBuff, DWORD FrameSize) { string strImageHead = MakeImageHead(Type); return m_AcqUnit->AddFrameWithRawHead(Type, strImageHead, pFrameBuff, FrameSize); } void nsFPD::FPDDeviceTrixell::OnError(int nIndex, string strErrCode, string strErr) { m_WarnAndError->SendError(strErrCode, strErr); } void nsFPD::FPDDeviceTrixell::ClearError(int nDetectorID, std::string strErrorCode, std::string strErr) { m_WarnAndError->ClearError(strErrorCode); } void nsFPD::FPDDeviceTrixell::OnWarn(int nIndex, string strWarnCode, string strWarn) { m_WarnAndError->SendWarn(strWarnCode, strWarn); } void nsFPD::FPDDeviceTrixell::ClearWarn(int nDetectorID, std::string strWarnCode, std::string strWarn) { m_WarnAndError->ClearWarn(strWarnCode); } RET_STATUS nsFPD::FPDDeviceTrixell::ResetError() { m_WarnAndError->ClearAllError(); m_WarnAndError->ClearAllWarn(); return RET_STATUS::RET_SUCCEED; } void nsFPD::FPDDeviceTrixell::SendAllError() { m_WarnAndError->SendAllError(); } RET_STATUS nsFPD::FPDDeviceTrixell::SetSaveRawDataMode(int nSaveRawDataMode) { Info("## SetSaveRawDataMode ##"); string strSaveMode = ""; switch (nSaveRawDataMode) { case CCOS_NO_SAVE_RAW: strSaveMode = "No save raw image"; break; case CCOS_SAVE_ORIGINAL: strSaveMode = "Save original raw image"; break; case CCOS_SAVE_AFTER_CROP: strSaveMode = "Save after crop raw image"; break; case CCOS_SAVE_AFTER_CALIB: strSaveMode = "Save after calibration raw image"; break; case CCOS_SAVE_AFTER_GRID_SUPPRESSION: strSaveMode = "Save after GridSuppression raw image"; break; case CCOS_SAVE_ALL: strSaveMode = "Save all raw image"; break; default: strSaveMode = "Undefined"; break; } Info("Set SaveRawData Mode: {$}({$})", strSaveMode, nSaveRawDataMode); m_pDetectors->SetSaveRawDataMode(nSaveRawDataMode); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceTrixell::OfflineFPD(int nOfflineFPDMode) { Info("## OfflineFPD ##"); Info("Offline FPD mode: {$}", nOfflineFPDMode); if (nOfflineFPDMode == 1) { m_pDetectors->DisconnectDetector(0); } else if (nOfflineFPDMode == 2) { m_pDetectors->OfflineFPD(0); } return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceTrixell::OnlineFPD(int nOnlineFPDMode) { Info("## OnlineFPD ##"); Info("Online FPD mode: {$}", nOnlineFPDMode); if (nOnlineFPDMode == 1) { m_pDetectors->ConnectDetector(false, 0); } else if (nOnlineFPDMode == 2) { m_pDetectors->OnlineFPD(0); } return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceTrixell::GetAutonumousImageList(int nDetectorID, vector& AutonumousList) { Info("## GetAutonumousImageList ##"); if (!m_pDetectors->GetAutonumousImageList(nDetectorID, AutonumousList)) { Error("Get autonumous image list error"); return RET_STATUS::RET_FAILED; } Info("Get autonumous image list success"); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceTrixell::RemoveAutonumousImageList(string strMeta) { Info("## RemoveAutonumousImageList ##"); Info("Remove item: {$}", strMeta); if (!m_pDetectors->RemoveAutonumousImageList(strMeta)) { Error("Remove autonumous image error"); return RET_STATUS::RET_FAILED; } Error("Remove autonumous image success"); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceTrixell::RemoveAutonumousAll() { Info("## RemoveAutonumousAll ##"); if (!m_pDetectors->RemoveAutonumousAll()) { Error("Remove autonumous all image error"); return RET_STATUS::RET_FAILED; } Info("Remove autonumous all image success"); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceTrixell::GetImageMetaData(string strMetaData) { Info("## GetImageMetaData ##"); if (!m_pDetectors->GetImageMetaData(strMetaData)) { Error("Get autonumous Meta Data error"); return RET_STATUS::RET_FAILED; } Info("Get autonumous Meta Data success"); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceTrixell::ExportAutonumousAll() { Info("## ExportAutonumousAll ##"); if (!m_pDetectors->ExportAutonumousAll()) { Error("Get autonumous all image error"); return RET_STATUS::RET_FAILED; } Info("Get autonumous all image success"); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceTrixell::ActiveSyncMode(int nSyncMode) { Info("ActiveSyncMode: {$}", nSyncMode); if (!m_pDetectors->SetSyncMode(0, nSyncMode)) { Error("Set sync mode failed"); } Info("ActiveSyncMode success"); return RET_STATUS::RET_SUCCEED; } void nsFPD::FPDDeviceTrixell::CheckCalibrationDue() { Info("[Checking Calibration Date]"); if (!m_stDeviceConfig.bConnectStatus) { Error("m_stDeviceConfig.bConnectStatus = false"); return; } Info("LastCalibrationDate: {$}, DueDay: {$}", m_stDeviceConfig.strLastCalibrationDate, m_stDeviceConfig.strCalibrationFileExpireTime); if (!m_bNotifyCalWarn) { Info("skip notify calibration"); return; } //进检查时判断当前校正文件是否过期,如果即将过期或者已过期都向上通知 if (m_stDeviceConfig.strLastCalibrationDate == "0000-00-00 00:00:00") { //没有做过校正 Warn("No calibration file, please make a calibration!"); m_WarnAndError->SendWarn(ERR_FPD_CAL_FILE_NOT_EXIST, ""); } else { time_t lastCalibDate = StringToDatetime(m_stDeviceConfig.strLastCalibrationDate); int nExpireTime = std::stoi(m_stDeviceConfig.strCalibrationFileExpireTime);//单位:天 Info("nExpireTime:{$}", nExpireTime); time_t localtime = time(NULL); //判断是否过期 if (localtime > lastCalibDate + nExpireTime * 24 * 3600) { //过期了报错 Warn("Calibration file is expired! please make a calibration!"); m_WarnAndError->SendWarn(ERR_FPD_CAL_FILE_OUTDATE, ""); } } return; }