#include "stdafx.h" #include "CCOS.Dev.FPD.iRayDM.h" #include "IRayDMCtrl.h" #include "FileVersion.hpp" #include "DICOMImageHeadKey.h" #pragma comment(lib, "Version.lib") namespace nsFPD = CCOS::Dev::Detail::Detector; Log4CPP::Logger* gLogger = nullptr; static nsFPD::IRayDriver gIODriver; //================================================================================================================================================================================= // GetIODriver & CreateIODriver //================================================================================================================================================================================= extern "C" CCOS::Dev::IODriver * __cdecl GetIODriver() // 返回静态对象的引用, 调用者不能删除 ! { return &gIODriver; } extern "C" CCOS::Dev::IODriver * __cdecl CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 ! { return new nsFPD::IRayDriver(); } //============================================================================== // 驱动对象 //============================================================================== nsFPD::IRayDriver::IRayDriver() { dev = NULL; m_bConnect = false; m_pAttribute.reset(new ResDataObject()); m_pDescription.reset(new ResDataObject()); } nsFPD::IRayDriver::~IRayDriver() { } //驱动准备 void nsFPD::IRayDriver::Prepare() { string strLogPath = GetProcessDirectory() + R"(\OEMDrivers\Detector\Conf\Log4CPP.Config.FPD.xml)"; Log4CPP::GlobalContext::Map::Set(ZSKK::Utility::Hash("LogFileName"), "FPD.iRayDM"); bool bRet = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str()); if (bRet == false) { return; } gLogger = Log4CPP::LogManager::GetLogger("FPD.iRayDM"); string szMouldPath = GetProcessDirectory() + R"(\OEMDrivers\Detector\IRayDM\CCOS.Dev.FPD.iRayDM.dll)"; #ifdef _WIN64 Force("------------------------ Version: {$} (64-bit) ------------------------", FileVersion(szMouldPath.c_str()).GetVersionString()); #else Force("------------------------ Version: {$} (32-bit) ------------------------", FileVersion(szMouldPath.c_str()).GetVersionString()); #endif Info("IRay Driver Prepare"); dev = new FPDDeviceIRay(EventCenter, m_ConfigFileName); Info("new FPDDeviceIRay over"); } //驱动连接 bool nsFPD::IRayDriver::Connect() { Info("IRay Driver Connect"); m_bConnect = true; return true; } //驱动断连 void nsFPD::IRayDriver::Disconnect() { m_bConnect = false; } //判断驱动是否连接 bool nsFPD::IRayDriver::isConnected() const { return m_bConnect; } //驱动创建设备对象 auto nsFPD::IRayDriver::CreateDevice(int index) -> std::unique_ptr { Info("CreateDevice({$})", index); auto Driver = std::unique_ptr (new IODevice(dev)); dev->CreateDevice(); dev->Register(); return Driver; } //驱动探针 std::string nsFPD::IRayDriver::DriverProbe() { Info("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", "Generator"); HardwareInfo.add("MinorID", "Dr"); HardwareInfo.add("VendorID", "iRay"); HardwareInfo.add("ProductID", "Mars"); HardwareInfo.add("SerialID", "Driver"); } string ret = HardwareInfo.encode(); Info("Diver_Probe over"); return ret; } //获取驱动配置 bool nsFPD::IRayDriver::GetDeviceConfig(std::string& Cfg) { Cfg = m_DeviceConfig.encode(); Info("GetDeviceConfig over"); return true; } //驱动设置设备配置 bool nsFPD::IRayDriver::SetDeviceConfig(std::string Cfg) { Info("SetDeviceConfig {$} ", Cfg.c_str()); Info("SetDeviceConfig over"); return true; ResDataObject DeviceConfig; DeviceConfig.decode(Cfg.c_str()); ResDataObject DescriptionTempEx; DescriptionTempEx = DeviceConfig["DeviceConfig"]["Attribute"]; Info("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("ConfigInfo Count: {$}", nConfigInfoCount); string strTemp = ""; //存储AttributeKey for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++) { strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"]; if (strTemp == strKey) { strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"]; break; } } //3. 修改配置文件中的值 if (SetDeviceConfigValue(m_Configurations, strTemp.c_str(), 1, DescriptionTempEx[i])) { bSaveFile = true; } } else { Info("{$} is not a RW configuration item", strKey.c_str()); } } else { Warn("without this attribute {$}", strKey.c_str()); } } catch (...) { Error("SetDriverConfig crashed"); return false; } } if (bSaveFile) { //3. 重新保存配置文件 m_ConfigAll["CONFIGURATION"] = m_Configurations; m_ConfigAll.SaveFile(m_ConfigFileName.c_str()); Info("SaveConfigFile over"); } Info("SetDriverConfig over"); return true; } //驱动获取设备配置内容 bool nsFPD::IRayDriver::GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue) { strValue = ""; string strTemp = pInnerKey; //Trace("Inner key: {$}", strTemp); 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::IRayDriver::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自己的配置文件读取 { 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; } } return true; } //获取设备资源 std::string nsFPD::IRayDriver::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"); //Trace(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()); //Trace(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())); //Trace(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), atoi(strValue.c_str())); } else if ("float" == strType) { (*m_pAttribute).add(strTemp.c_str(), atof(strValue.c_str())); //Trace(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), atof(strValue.c_str())); } else //其它先按string类型处理 { (*m_pAttribute).add(strTemp.c_str(), strValue.c_str()); //Trace(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), strValue.c_str()); } //AttributeAccess strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Access"]; DescriptionTemp.add(AttributeAccess, strTemp.c_str()); //Trace(g_pFPDCtrlLog, "{$}: {$}", AttributeAccess, strTemp.c_str()); //AttributeRangeMin strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMin"]; if (strTemp != "") //不需要的配置项为空 { DescriptionTemp.add(AttributeRangeMin, strTemp.c_str()); //Trace(g_pFPDCtrlLog, "{$}: {$}", AttributeRangeMin, strTemp.c_str()); } //AttributeRangeMax strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMax"]; if (strTemp != "") //不需要的配置项为空 { DescriptionTemp.add(AttributeRangeMax, strTemp.c_str()); //Trace(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, "%d", nListIndex); ListTemp.add(sstream, strTemp.c_str()); //Trace(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()); //Trace(g_pFPDCtrlLog, "{$}: {$}", AttributeRequired, strTemp.c_str()); //AttributeDefaultValue strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["DefaultValue"]; if (strTemp != "") //不需要的配置项为空 { DescriptionTemp.add(AttributeDefaultValue, strTemp.c_str()); //Trace(g_pFPDCtrlLog, "{$}: {$}", AttributeDefaultValue, strTemp.c_str()); } strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"]; (*m_pDescription).add(strTemp.c_str(), DescriptionTemp); } } catch (exception 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 = DescriptionTempEx; string res = DescriptionTempEx.encode(); //Debug("resDeviceResource :{$} ", DescriptionTempEx.encode()); //if (dev) //{ // dev->SyncErrorList(); //} return res; } //设备探针 std::string nsFPD::IRayDriver::DeviceProbe() { 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", "iRay"); HardwareInfo.add("ProductID", "Mars"); HardwareInfo.add("SerialID", "1234"); } string ret = HardwareInfo.encode(); return ret; } //================================================================================================================================================================================= // 设备对象 //================================================================================================================================================================================= extern IRayCtrl* g_pIRayCtrl; #define MAX_STRING 1024 nsFPD::FPDDeviceIRay::FPDDeviceIRay(std::shared_ptr center, string ConfigPath) :m_strWorkPath(""), m_nDeviceIndex(0), m_eAppStatus(APP_STATUS_WORK_END), m_bHasGrid(false), m_nGridLicense(0), m_strVoltage(""), m_strLastError(""), m_strCalibTime(""), m_strLogFilePath(""), m_bOpened(false), m_bBatteryCharging(false), m_bRecoveringImage(false), m_bAbortRecover(false), m_bSNListExisted(false), m_bUIReady(false), m_bImagePendingOrNot(false), m_bResetDetector(false), m_nTemperCheckResult(0), m_nXCUStatus(0), m_nBatteryCapacity(0), m_nBatteryCharges(0), m_nShockCounts(0), m_nWorkStation(0), m_fDoseParam(0), m_nFullImgWidth(0), m_nFullImgHeight(0), m_nTopOffset(0), m_nLeftOffset(0), m_nImageBits(0), m_fFactorEXI2UGY(0.0f), m_bPreviewEnable(false), m_bTestSensitivity(false), m_fBatteryTemperature(0.0f), m_nXrayCalibNum(0), m_bCalibReportFailed(false), m_pwFullImageData(nullptr), m_pwRawImageData(nullptr), m_pwPreviewImg(nullptr), m_pPreviewImageHead(nullptr), m_pFullImageHead(nullptr), m_pDetectors(nullptr), m_bConnect2XCU(false), m_bXCUresult(false), m_nActiveState(FPD_NOT_ACTIVE), m_bDueDateWarnSend(false), m_bCallFDConnectOver(false), m_bDisConnected(false), m_ExitEvt(nullptr), m_bAttached(false), m_hNotifyThread(nullptr), m_bRecoverImageStatusInit(false), m_bSaveRaw(false), m_bUIConfirmRecover(false), m_nCalibrationType(CCOS_CALIBRATION_TYPE_MAX), m_fLTEthreshold(450.0f), m_CalTemperlowWarn(0.0f), m_CalTemperupWarn(0.0f), m_LETCalTemperlowWarn(0.0f), m_LETCalTemperupWarn(0.0f), m_CalTemperWarnInitialed(false), m_lowBatteryBuda(0), m_pmsLoginStatus(false), m_nClinicalApplicationMode(0), m_nFilterMode(0), m_bStatusInAEC(false) { g_strAppPath = 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 OemDetectorCtrl(center, this)); m_Battery.reset(new DeviceBatteryMould("DetectorIRayBattery", 0, 10, 20, 30, 40, 100, 100, 0, center)); //m_Temperature.reset(new DeviceTemperatureMould("DetectorIRayTemperature", ABS_ZERO_TEMPERATURE, 0.0f, 10.0f, 60.0f, 20.0f, 40.0f, 70.0f, 0.0f, center)); m_Wifi.reset(new DeviceWifiMould("DetectorIRayWifi", 0, 20, 30, 40, 50, 100, 100, 0, center)); m_DetectorConfiguration.reset(new DetectorConfiguration(ConfigPath)); m_WarnAndError.reset(new FPDErrorWarning(center, DetectorUnitType, g_strAppPath)); m_CalibProcess.reset(new CalibrationProcess()); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_WaitCalibDoseEvt = CreateEvent(0, 1, 0, 0); m_OffsetCalibrationEvt = CreateEvent(0, 0, 0, 0); m_PauseCalibrationEvt = CreateEvent(0, 1, 0, 0); m_CompleteCalibrationEvt = CreateEvent(0, 1, 0, 0); m_CrateCalibReportEvt = CreateEvent(0, 0, 0, 0); m_UploadCalibMapOver = CreateEvent(0, 1, 0, 0); m_hXCUresult = CreateEvent(0, 1, 0, 0); m_ExitEvt = CreateEvent(0, 1, 0, 0); m_CalibGapEvt = CreateEvent(0, 1, 0, 0); m_WriteCumstomFileEvt = CreateEvent(0, 1, 0, 0); EventCenter = center; } nsFPD::FPDDeviceIRay::~FPDDeviceIRay() { SetEvent(m_ExitEvt); CloseHandle(m_WaitCalibDoseEvt); CloseHandle(m_OffsetCalibrationEvt); CloseHandle(m_PauseCalibrationEvt); CloseHandle(m_CompleteCalibrationEvt); CloseHandle(m_CrateCalibReportEvt); CloseHandle(m_WriteCumstomFileEvt); CloseHandle(m_UploadCalibMapOver); CloseHandle(m_hXCUresult); CloseHandle(m_CalibGapEvt); if (m_hNotifyThread != NULL) { CloseHandle(m_hNotifyThread); } } std::string nsFPD::FPDDeviceIRay::GetGUID() const { return DetectorUnitType; } bool nsFPD::FPDDeviceIRay::Prepare() { Info("Device Prepare"); //EventCenter->OnMaxBlockSize("DrQue", 3000 * 3000 * 2, 3, 1500 * 1500 * 2, 1); //SetMaxBlockSize(const char *pQueName, DWORD FullBlockSize, DWORD FullBlockCount, DWORD PrevBlockSize, DWORD PrevBlockCount) EventCenter->OnMaxBlockSize("RfQue", 6000 * 6000 * 2, 8, 3000 * 3000 * 2, 8); //开辟共享内存 Connect(); return true; } void nsFPD::FPDDeviceIRay::RegisterCtrl(nDetail::Dispatch* Dispatch) { Dispatch->Action.Push(ActionKey::GetDetectorInfo, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorInfo); Dispatch->Action.Push("ActiveDetector", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSActiveDetector); Dispatch->Action.Push("RESET", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRESET); Dispatch->Action.Push("EnterExam", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSEnterExam); Dispatch->Action.Push("ExitExam", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSExitExam); Dispatch->Action.Push("RecoverImage", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRecoverImage); Dispatch->Action.Push("ResetConnect", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSResetConnect); Dispatch->Action.Push("DisConnectFPD", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSDisConnectFPD); Dispatch->Action.Push("DisConnectFPDForce", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSDisConnectFPDForce); Dispatch->Action.Push("UpdateFirmware", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateFirmware); Dispatch->Action.Push("SaveSensitivity", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSaveSensitivity); Dispatch->Action.Push("GetRecoverImageState", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageState); Dispatch->Get.Push("RecoverImageState", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageState);//event Dispatch->Get.Push("RecoverImageEvent", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageEvent);//event Dispatch->Get.Push(CcosDetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDStatus); Dispatch->Get.Push(CcosDetectorConnectStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetConnectStatus); Dispatch->Get.Push(CcosDetectorAttach, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachResult); Dispatch->Get.Push(CcosDetectorAttachedFlag, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachStatus); Dispatch->Get.Push(CcosDetectorInitialStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetInitialStatus); Dispatch->Get.Push(CcosDetectorUpdateFWStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetUpdateFWStatus); Dispatch->Get.Push("FPDShockSensorInfo", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetShockSensorInfo); 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("FPDSensitivityResult", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDSensitivityResult); Dispatch->Get.Push("PixelData", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetPixelData); Dispatch->Get.Push("TargetEXI", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTargetEXI); Dispatch->Get.Push("FPDLastError", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetLastError); //Dispatch->Get.Push("FirmwareStatus", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFirmwareStatus); } void nsFPD::FPDDeviceIRay::RegisterAcq(nDetail::Dispatch* Dispatch) { Dispatch->Action.Push("SetAcqMode", m_AcqUnit.get(), &AcqUnit::JSSetAcqMode); Dispatch->Get.Push(CcosZskkFPDState, m_AcqUnit.get(), &AcqUnit::JSGetZskkFPDState); Dispatch->Get.Push("NoNeedWaitImage", m_AcqUnit.get(), &AcqUnit::JSGetNoNeedWaitImage); Dispatch->Get.Push("ImgDataInfo", m_AcqUnit.get(), &AcqUnit::JSGetLastImage); } void nsFPD::FPDDeviceIRay::RegisterSync(nDetail::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->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); } void nsFPD::FPDDeviceIRay::RegisterCalib(nDetail::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("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->Get.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::JSGetCalibStatus); Dispatch->Get.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::JSGetCalibProgress); Dispatch->Get.Push("UploadCalibrationFilesResult", m_CalibUnit.get(), &CalibUnit::JSGetUploadCalibrationFilesResult); } void nsFPD::FPDDeviceIRay::Register() { auto Disp = &Dispatch; RegisterCtrl(Disp); RegisterAcq(Disp); RegisterSync(Disp); RegisterCalib(Disp); } void nsFPD::FPDDeviceIRay::OnFPDCallback(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { m_nDeviceIndex = nDetectorID; 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::FPDDeviceIRay::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); char cDetectorID[17] = { 0 }; memcpy(cDetectorID, m_stDeviceConfig.strPanelSerial.c_str(), 16); string strDetectorID = cDetectorID; m_DetectorCtrlUnit->SetDetectorID(strDetectorID); Info("SedDetectorID {$}", strDetectorID.c_str()); if (!m_bRecoverImageStatusInit) { m_RecoverImageStatus.add("DetectorName", m_stDeviceConfig.strDeviceName.c_str()); m_RecoverImageStatus.add("DetectorSN", m_stDeviceConfig.strPanelSerial.c_str()); m_RecoverImageStatus.add("DetectorWifiSignal", "1"); m_RecoverImageStatus.add("Result", "-1"); m_bRecoverImageStatusInit = true; } 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_FIRWARE_UPDATE: { m_stDeviceConfig.nFirmwareStatus = nParam1; m_DetectorCtrlUnit->SetFirmwareStatus(to_string(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_WIFI_SSID: { m_stDeviceConfig.strWifiSSID = pszMsg; Info("Panel {$} WifiSSID:{$}", nDetectorID, pszMsg); break; } case EVT_CONF_IFBOARD: { m_stDeviceConfig.strInterfaceBoard = pszMsg; Info("Panel {$} InterfaceBoard:{$}", nDetectorID, pszMsg); break; } case EVT_CONF_DATECODE: { m_stDeviceConfig.strDateCode = pszMsg; Info("Panel {$} DateCode:{$}", nDetectorID, pszMsg); break; } default: { break; } } } void nsFPD::FPDDeviceIRay::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); m_stDeviceConfig.nPowerOn = nPowerOn; 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_CALIBRATIOIN_TIMEL: { m_stDeviceConfig.strCalibrationLTETime = pszMsg; Info("Panel {$} LTE Calibration Time:{$}", nID, pszMsg); break; } case EVT_INFO_FPVOLTAGE: { m_strVoltage = pszMsg; break; } default: { break; } } } void nsFPD::FPDDeviceIRay::OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { string strWarnErrorCode = ""; switch (nEventID) { case EVT_STATUS_INIT: { if (PANEL_EVENT_END_OK == nParam1) { //OnInitResult(true); m_stDeviceConfig.bConnectStatus = true; m_stDeviceConfig.bInitOK = true; } else if (PANEL_EVENT_END_ERROR == nParam1) { //OnInitResult(false); } 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_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"); m_SyncUnit->FPDReadyNotify(true); } else if (PANEL_OFFSET_CAL == nParam1) { Info("Panel Status:PANEL_OFFSET_CAL"); } else if (PANEL_OFFSET_FINISH == nParam1) { Info("Panel Status:PANEL_OFFSET_FINISH"); //StopCalibrationInside(); } else if (PANEL_OFFSET_FAILED == nParam1) { Info("Panel Status:PANEL_OFFSET_FAILED"); //AbortCalibration(); } 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(); } 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) { m_SyncUnit->FPDReadyNotify(true); } else { Info("Panel {$} Status Unknown: {$}", nDetectorID, (int)m_ePanelStatus); } break; } case EVT_STATUS_CALIBRATIOIN: { ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1; //string strSNote; switch (eStatus) { case PANEL_EVENT_START: break; case PANEL_EVENT_END_OK: Info("Calibration process is success"); //CompleteCalibration(); SetEvent(m_CompleteCalibrationEvt); 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: //由于断线造成指令执行失败 { string strWarnErrorCode = ERR_FPD_ACQ_FAILED; break; } default: break; } break; } case EVT_STATUS_PREPARE_EDNCALIBRATION: break; case EVT_STATUS_IMAGEPENDING: { string strTemp = pszMsg; if (strTemp.find("true") != std::string::npos) { m_bImagePendingOrNot = true; } else { m_bImagePendingOrNot = false; } break; } case EVT_STATUS_IMAGERECOVERAUTO: { m_RecoverImageStatus["Result"] = "0"; Info("m_RecoverImageStatus[Result] = 0 by auto"); m_DetectorCtrlUnit->SetRecoverImageState(m_RecoverImageStatus.encode()); m_bAbortRecover = false; //终止恢复图像的变量也要重置 m_bRecoveringImage = false; //不再恢复图像过程中 m_nRecoverImageTimes = 0; //下次恢复图像,重置 m_bSendRecoverMessage = false; //下次恢复图像仍需判断; break; } case EVT_STATUS_TEMPERATURE: { float fTemperature = fParam2; //OnProcessTemperature(nID, fTemperature); m_stDeviceConfig.fCurrentTemperValue = fTemperature; Info("Detector {$} Temperature Value:{$}", nDetectorID, fTemperature); //SendTemperatureValue(fTemperature); break; } case EVT_STATUS_WIFI: { int nWifiLevel = nParam1; Info("Detector {$} Wifi Value:{$}", nDetectorID, nWifiLevel); m_stDeviceConfig.nCurrentWifiValue = nWifiLevel; //SendWifiValue(nWifiLevel); break; } case EVT_STATUS_BATTERY_VALUE: { int nBatteryValue = nParam1; m_lowBatteryBuda = m_lowBatteryBuda + 1; if (m_lowBatteryBuda >= 10000) { m_lowBatteryBuda = 10000; } Info("Detector {$} Battery:{$}", nDetectorID, nParam1); //SendInfoLog("DEV_LOG_FPD_BATTERY", nBatteryValue); if (nBatteryValue < m_stDeviceConfig.nBatteryLimit) { //battery error if (!m_bBatteryCharging) //如果没有充电; { strWarnErrorCode = ERR_FPD_BATTERY_LOW; //OnError(strWarnErrorCode); strWarnErrorCode = WAR_FPD_BATTERY_LOW; //OnWarnX(strWarnErrorCode); } } else if (nBatteryValue < m_stDeviceConfig.nBatteryWarning) { strWarnErrorCode = ERR_FPD_BATTERY_LOW; //OnErrorX(strWarnErrorCode); strWarnErrorCode = WAR_FPD_BATTERY_LOW; } else { strWarnErrorCode = ERR_FPD_BATTERY_LOW; //OnErrorX(strWarnErrorCode); strWarnErrorCode = WAR_FPD_BATTERY_LOW; //OnWarnX(strWarnErrorCode); } m_stDeviceConfig.nCurrentBatteryValue = nBatteryValue; Info("Detector {$} Battery Value:{$}", nDetectorID, nBatteryValue); if (nBatteryValue < m_stDeviceConfig.nBatteryWarning) { //防止探测器电池电量状态异常跳变 if (m_lowBatteryBuda >= 2) { //SendBatteryValue(nBatteryValue); } } else { //SendBatteryValue(nBatteryValue); } 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: { m_nShockCounts = nParam1; string strWarn = WAR_FPD_MAX_SHOCK_NUM; Info("Panel {$} Shock Sensor Number:{$}", nDetectorID, m_nShockCounts); m_stDeviceConfig.nShockTimes = m_nShockCounts; break; } case EVT_STATUS_HALL_SENSOR: { int nWorkstaion = nParam1; Info("Update Hall Status : {$} ", nWorkstaion); Info("Panel {$} WS:{$},Current OGP WS:{$} ", nDetectorID, nWorkstaion, m_nWorkStation); m_stDeviceConfig.nWorkstation = nWorkstaion; break; } case EVT_STATUS_PING: { break; } case EVT_STATUS_RESET: { int nStatus = nParam1; if (PANEL_RESET_BEGIN == nStatus) { } else if (PANEL_RESET_OK == nStatus) { m_bResetDetector = false; } else if (PANEL_RESET_ERROR == nStatus) { } break; } default: { break; } } } void nsFPD::FPDDeviceIRay::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("Image Arrive"); if (APP_STATUS_IDLE == m_eAppStatus) { Error("Omit Image in Idle Status"); return; } Info("Currenct FPD FullImage Width:{$}, FullImage Height:{$}", m_stDeviceConfig.nFullImageWidth, m_stDeviceConfig.nFullImageHeight); float fImageReferUGY = 2.5f; if (APP_STATUS_WORK_BEGIN == m_eAppStatus) { fImageReferUGY = 2.5f; } 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)); if (m_bSaveRaw) { //SaveRaw("iRaySDK"); string strFullImageName = "FullImage.raw"; SaveRawImage(strFullImageName, m_pwRawImageData, m_stDeviceConfig.nFullImageWidth, m_stDeviceConfig.nFullImageHeight); } OnProcessImage(m_pwRawImageData, m_stDeviceConfig.nFullImageWidth, m_stDeviceConfig.nFullImageHeight, fImageReferUGY); m_bStatusInAEC = false; break; } case EVT_DATA_PREVIEW_IMAGE: { Info("Preview Image Arrive"); 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_AEC_PREEXP_IMAGE: { Info("AEC PreExp Image Arrive"); 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)); if (m_bSaveRaw) { //SaveImage(L"PreviewImage.raw", pwRawImage, nHeight, nWidth); string strImageName = "PreExpImage.raw"; SaveRawImage(strImageName, m_pwPreviewImg, m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight); } OnProcessPreExpImage(m_pwPreviewImg, m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight); m_bStatusInAEC = true; break; } case EVT_DATA_DOSEPARAM: { m_fDoseParam = nParam1;// static_cast(fParam2 * 1000); Info("calibration dose {$}, Param1 {$}", m_fDoseParam, nParam1); SetEvent(m_WaitCalibDoseEvt); break; } default: { break; } } } void nsFPD::FPDDeviceIRay::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: { strErrorName = ERR_FPD_DISCONNECT; string strTemp = pszMsg; if (strTemp.find("true") != std::string::npos) { m_stDeviceConfig.nWorkstation = -1; m_stDeviceConfig.bConnectStatus = false; m_nBatteryCapacity = 0; //SendDetectorInfo(); m_lowBatteryBuda = 0; m_stDeviceConfig.nCurrentWifiValue = 0; m_stDeviceConfig.nCurrentBatteryValue = 0; } else if (strTemp.find("false") != std::string::npos)//成功时交给WIFI发送SendDetectorInfo { m_stDeviceConfig.bConnectStatus = true; } break; } case EVT_ERR_EXP_REQUEST: { string strTemp = pszMsg; 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!"); } //endif } else if (strTemp.find("false") != std::string::npos) { m_bAbortRecover = false; //终止恢复图像的变量也要重置 m_bRecoveringImage = false; //不再恢复图像过程中 m_nRecoverImageTimes = 0; //下次恢复图像,重置 m_bSendRecoverMessage = false; //下次恢复图像仍需判断; } break; } case EVT_ERR_INIT_FAILED: { strErrorName = ERR_FPD_FATAL_ERROR; string strTemp = pszMsg; break; } default: { break; } } } void nsFPD::FPDDeviceIRay::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { } DWORD nsFPD::FPDDeviceIRay::OnNotify(LPVOID pParam) { return 0; } bool nsFPD::FPDDeviceIRay::CreateDevice() { if (!LoadConfig()) { Info("Load configuration file failed!!!"); return false; } bool bDemo = false; bool bRet = false; int nDemo = (int)m_DetectorConfiguration->m_Configurations["DemoEnable"]; if (nDemo != 0) { bDemo = true; } if (bDemo) { return bRet; } if ((g_pIRayCtrl != nullptr) || (m_pDetectors != nullptr)) { Info("CreateDevice failed!"); return false; } m_pDetectors = new IRayCtrl(); g_pIRayCtrl = reinterpret_cast(m_pDetectors); bRet = m_pDetectors->Init(g_strAppPath); m_pDetectors->AddDPCs(this, m_DetectorConfiguration->m_Configurations, m_stDeviceConfig); Info("Create Device over"); return bRet; } RET_STATUS nsFPD::FPDDeviceIRay::Connect() { Info("------------------------ FPD type {$}, Device {$} Start running. ------------------------ ", m_stDeviceConfig.strDeviceName.c_str(), this); bool bRet = m_pDetectors->Connect(g_strAppPath, this); if (!bRet) { //SendConnectStatusToUI(false); return RET_STATUS::RET_FAILED; } Info("Device Connect detector over "); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::GetDeviceDictionary(std::string& out) { return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::EnterExam(int nExamStatus) { Info("EnterExam"); switch (nExamStatus) { case APP_STATUS_WORK_BEGIN: Info("Enter into Exam Windows"); m_eAppStatus = APP_STATUS_WORK_BEGIN; break; case APP_STATUS_WORK_END: Info("Quit Exam Windows"); m_bTestSensitivity = false; m_eAppStatus = APP_STATUS_WORK_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; default: break; } m_pDetectors->EnterExam(m_eAppStatus); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::ActiveDetector(bool bActive) { if (bActive) { Info("ActiveDetector"); m_nActiveState = FPD_ACTIVE; bool bRet = (m_pDetectors)->ActivePanel(this, bActive); if (!bRet) { return RET_STATUS::RET_FAILED; } } else { Info("UnActiveDetector"); bool bRet = (m_pDetectors)->ActivePanel(this, bActive); if (!bRet) { return RET_STATUS::RET_FAILED; } m_nActiveState = FPD_NOT_ACTIVE; } return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::SetAcqMode(int mode) { /*if (!m_stDeviceConfig.bConnectStatus) { Error("m_stDeviceConfig.bConnectStatus = false "); return RET_STATUS::RET_THREAD_INVALID; }*/ Info("Device SetAcqMode: {$}", mode); int nOmMode = 1; int nFilterMode = m_stDeviceConfig.nFilterMode; int nPanelID = m_nDeviceIndex + 1; if (m_bStatusInAEC == true) { Info("In AEC MainExposure..."); //激活应用配置模式:Manual曝光 //m_pDetectors->ActiveConfigurationMode(nPanelID, 1); return RET_STATUS::RET_SUCCEED; } if (mode == 3) //AEC模式 { nOmMode = 2; Info("In AEC PreExposure..."); //激活应用配置模式:AEC PreExp曝光 m_pDetectors->ActiveConfigurationMode(nPanelID, nOmMode); } else { nOmMode = 1; //激活应用配置模式:Manual曝光 m_pDetectors->ActiveConfigurationMode(nPanelID, nOmMode); } m_pDetectors->SelectMode(0, nOmMode, nFilterMode); try { //nOmMode = m_ACQMODElist[CcosAcqModeIdx]; /*if (nOmMode != mode) { Info("input param invalid, can not support "); return RET_STATUS::RET_INVALID; }*/ //int nWidth = (int)m_ACQMODElist[CcosImageWidth]; //int nheight = (int)m_ACQMODElist[CcosImageHeight]; //int nbit = (int)m_ACQMODElist[CcosImageBits]; m_AcqUnit->SetFulImageInfo(m_stDeviceConfig.nFullImageHeight, m_stDeviceConfig.nFullImageWidth, m_stDeviceConfig.nImageBits, false); m_AcqUnit->SetPrevImageInfo(m_stDeviceConfig.bPreviewEnable, m_stDeviceConfig.nPreviewHeight, m_stDeviceConfig.nPreviewWidth, false); } catch (...) { Info("Illegal mode index!!! "); return RET_STATUS::RET_NOSUPPORT; } if (m_pDetectors->SelectExamMode(nOmMode, this)) { return RET_STATUS::RET_SUCCEED; } return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::SetSyncMode(SYNC_MODE nSyncMode, HARDWARE_TRIGGER_MODE TriggerMode) { if (!(m_pDetectors->SetSyncMode(nSyncMode, TriggerMode))) { return RET_STATUS::RET_FAILED; } return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::SetXwindow(float XwindowSize) { return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::SetSID(int nSID) { return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::ActiveCalibration(CCOS_CALIBRATION_TYPE in) { return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::PrepareCalibration() { return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::GetRequestedDose(string& strDose) { return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::StartCalibration() { return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::StopCalibration() { return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::SetCorrectionType(CCOS_CORRECTION_TYPE in) { return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::ResetConnect() { return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::DisConnectFPD() { return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::RecoverImage(bool bRecoverIt) { return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::GetRecoverImageState(string& strREI) { return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::GetDetectorInfo(string& strFDI) { string strTempTemp = " "; Info("Get Detector Info"); strFDI = "jishinull"; return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::UploadCalibrationFiles(string strFileName) { return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::ResetError() { return RET_STATUS::RET_SUCCEED; } bool nsFPD::FPDDeviceIRay::LoadConfig() { if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_ACQMODElist)) { Fatal("Load configuration file failed!!! "); return false; } Info("m_ACQMODElist: {$} ", m_ACQMODElist.encode()); m_nFullImgWidth = m_stDeviceConfig.nFullImageWidth; m_nFullImgHeight = m_stDeviceConfig.nFullImageHeight; m_nTopOffset = m_stDeviceConfig.nImageTopffset; m_nBottomOffset = m_stDeviceConfig.nImageBottomOffset; m_nLeftOffset = m_stDeviceConfig.nImageLeftOffset; m_nRightOffset = m_stDeviceConfig.nImageRightOffset; m_bPreviewEnable = m_stDeviceConfig.bPreviewEnable; Info("set previewEnable {$} ", m_bPreviewEnable ? "true" : "false"); if (m_stDeviceConfig.nForceGridSuppress > 0) { m_bForceGridSuppress = true; } else { m_bForceGridSuppress = false; } int nAttached = (int)m_DetectorConfiguration->m_Configurations[CcosDetectorAttachedFlag]; m_stDeviceConfig.bConnectStatus = false; m_bSaveRaw = (bool)m_DetectorConfiguration->m_Configurations["SaveRaw"]; Info("set SaveRaw {$} ", m_bSaveRaw ? "true" : "false"); m_nClinicalApplicationMode = (int)m_DetectorConfiguration->m_Configurations["ClinicalApplicationMode"]; Info("Clinical Application Mode: {$} ", m_nClinicalApplicationMode); m_nFilterMode = (int)m_DetectorConfiguration->m_Configurations["FilterMode"]; Info("Clinical Filter Mode: {$} ", m_nFilterMode); string strFPDinfo; strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["FieldofViewShape"]; m_DetectorCtrlUnit->SetFieldofViewShape(strFPDinfo); strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["FieldofViewDimension"]; //m_DetectorCtrlUnit->SetFieldofViewDimension(strFPDinfo); strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["VendorID"]; //m_DetectorCtrlUnit->SetDetectorType("IRAY1012F2"); strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["Description"]; //m_DetectorCtrlUnit->SetDescription(strFPDinfo); auto szFDinfo = std::to_string(m_stDeviceConfig.nDoseOfEXI); m_fFactorEXI2UGY = 100.0f / (float)atof(szFDinfo.c_str()) * 1.0f;//统一使用IEC标准 呈现四角信息,无单位 ugy * 100 -ugy。所有Zskk探测器的FactorEXI2UGY均需*100 Info("m_fFactorEXI2UGY = {$} ", m_fFactorEXI2UGY); auto strFPDcoef = std::to_string(m_fFactorEXI2UGY); m_DetectorCtrlUnit->SetFPDSensitivity(strFPDcoef);//image process 重算ROIl的EXI需要此值 //m_DetectorCtrlUnit->SetPixelData(""); //m_DetectorCtrlUnit->SetTargetEXI("5000"); return true; } RET_STATUS nsFPD::FPDDeviceIRay::PrepareAcquisition() { Info("==============================PrepareAcquisition"); /*if (!m_stDeviceConfig.bConnectStatus) { return RET_STATUS::RET_THREAD_INVALID; } if (!m_stDeviceConfig.bInitOK) { return RET_STATUS::RET_FAILED; }*/ m_SyncUnit->FPDReadyNotify(false); if (m_pDetectors->PrepareAcquisition(this) == RET_STATUS::RET_SUCCEED) { m_SyncUnit->FPDReadyNotify(true); Info("Send FPD Ready to Subsystem"); } Info("PrepareAcquisition over"); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::StartAcquisition(string in) { Info("StartAcquisition"); m_bAbortRecover = false; //能执行StartAcq,说明没有错误可以ready曝光。不再影响abort后再次recoverimage功能 RET_STATUS Ret = RET_STATUS::RET_FAILED; if (RET_STATUS::RET_SUCCEED == m_pDetectors->StartAcquisition(this)) { Ret = RET_STATUS::RET_SUCCEED; m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ)); Info("Send DETECTOR_STATUS_ACQ to Subsystem"); } else { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); Info("Send DETECTOR_STATUS_STANDBY to Subsystem"); Error("StartAcquisition failed"); } Info("StartAcquisition over"); return Ret; } RET_STATUS nsFPD::FPDDeviceIRay::StopAcquisition() { Info("StopAcquisition "); /*if (!m_stDeviceConfig.bConnectStatus) { return RET_STATUS::RET_THREAD_INVALID; }*/ RET_STATUS Ret = RET_STATUS::RET_FAILED; if (RET_STATUS::RET_SUCCEED == m_pDetectors->StopAcquisition(this)) { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); Info("Send DETECTOR_STATUS_STANDBY to Subsystem"); Ret = RET_STATUS::RET_SUCCEED; } Info("StopAcquisition over "); return Ret; } RET_STATUS nsFPD::FPDDeviceIRay::XWindowOnNotify() { RET_STATUS Ret = RET_STATUS::RET_FAILED; m_SyncUnit->XWindowOnNotify(); Info("--- WindowOn ---"); m_stImgCreateTime = { 0 }; GetLocalTime(&m_stImgCreateTime); Info("Full image create time-{$}:{$}:{$}:{$}", m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceIRay::XWindowOffNotify() { RET_STATUS Ret = RET_STATUS::RET_FAILED; m_SyncUnit->XWindowOffNotify(); Info("--- WindowOff ---"); return RET_STATUS::RET_SUCCEED; } string nsFPD::FPDDeviceIRay::MakeImageHead(IMAGE_VIEW_TYPE Type) { if (Type == IMAGE_FULL) { 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, "0"); 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, m_fFactorEXI2UGY); json.add(SM_IMAGE_TEMP, m_stDeviceConfig.fCurrentTemperValue); 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((*m_pFullImageHead).encode()); 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, "0"); 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::FPDDeviceIRay::AddFrameWithRawHead(IMAGE_VIEW_TYPE Type, WORD* pFrameBuff, DWORD FrameSize) { string strImageHead = MakeImageHead(Type); return m_AcqUnit->AddFrameWithRawHead(Type, strImageHead, pFrameBuff, FrameSize); } //======================================================================预览图==================================================================// bool nsFPD::FPDDeviceIRay::OnProcessPreviewImage(WORD* pwRawImage, int nWidth, int nHeight) { //m_stFPDHeader.fFPDHeaderVersion = 0.0; //m_stFPDHeader.nImageType = m_nCurrentAcqMode; //m_stFPDHeader.nImageHeight = nHeight; //m_stFPDHeader.nImageWidth = nWidth; //m_stFPDHeader.nImageBits = m_nImageBits; //m_stFPDHeader.fFactorEXI2UGY = m_fFactorEXI2UGY; //m_stFPDHeader.fImageReferUGY = 2.5f; //m_stFPDHeader.fTemperature = m_stDeviceConfig.fCurrentTemperValue; //m_stFPDHeader.fPixelSpace = m_stDeviceConfig.fPixelSpace; Info("Currenct PreviewImage Width:{$}, Height:{$}", m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight); if (m_stDeviceConfig.nSaveRaw > 1) { //SaveImage(L"PreviewImage.raw", pwRawImage, nHeight, nWidth); } return true; } void nsFPD::FPDDeviceIRay::PrevImageDateArrived(WORD* pImg) { AddFrameWithRawHead(IMAGE_PREVIEW, pImg, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight); } //======================================================================AEC预曝光图============================================================// bool nsFPD::FPDDeviceIRay::OnProcessPreExpImage(WORD* pwRawImage, int nWidth, int nHeight) { //m_stFPDHeader.fFPDHeaderVersion = 0.0; //m_stFPDHeader.nImageType = m_nCurrentAcqMode; //m_stFPDHeader.nImageHeight = nHeight; //m_stFPDHeader.nImageWidth = nWidth; //m_stFPDHeader.nImageBits = m_nImageBits; //m_stFPDHeader.fFactorEXI2UGY = m_fFactorEXI2UGY; //m_stFPDHeader.fImageReferUGY = 2.5f; //m_stFPDHeader.fTemperature = m_stDeviceConfig.fCurrentTemperValue; //m_stFPDHeader.fPixelSpace = m_stDeviceConfig.fPixelSpace; Info("Currenct AEC PreExp Image Width:{$}, Height:{$}", m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight); PreExpImageDateArrived(pwRawImage); return true; } void nsFPD::FPDDeviceIRay::PreExpImageDateArrived(WORD* pImg) { AddFrameWithRawHead(IMAGE_AEC_PREVIEW, pImg, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight); } //======================================================================大图==================================================================// bool nsFPD::FPDDeviceIRay::OnProcessImage(WORD* pwRawImage, int nImageWidth, int nImageHeight, float fImageReferUGY) { Info("Process Full Image"); Info("Currenct Full Image Width:{$}, Height:{$}", m_stDeviceConfig.nFullImageWidth, m_stDeviceConfig.nFullImageHeight); Info("Image EXI2UGY factor: {$}, Image Refer UGY: {$}", m_fFactorEXI2UGY, fImageReferUGY); //图像预处理完成 FullImageDateArrived(pwRawImage); Info("Write Frame Over"); return true; } void nsFPD::FPDDeviceIRay::FullImageDateArrived(WORD* pImg) { AddFrameWithRawHead(IMAGE_FULL, pImg, m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight); } void nsFPD::FPDDeviceIRay::SaveRaw(string RawName) { Info("Begin save image"); char szTemp[30] = { 0 }; FILE* fp; string strFileName = g_strAppPath + "Image\\" + RawName + ".raw"; if ((fp = fopen(strFileName.c_str(), "wb")) == NULL) { DWORD dw = GetLastError(); Error("fopen %s failed, %d", strFileName.c_str(), dw); return; } fwrite(m_pwRawImageData, sizeof(WORD), m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight, fp); fclose(fp); Info("Save image over"); } bool nsFPD::FPDDeviceIRay::SaveRawImage(string strImageName, WORD* pwRawImage, int nWidth, int nHeight) { Info("Save raw image: {$}", strImageName); char szTemp[30] = { 0 }; FILE* fp; string strFileName = g_strAppPath + "Image\\" + strImageName; if ((fp = fopen(strFileName.c_str(), "wb")) == NULL) { DWORD dw = GetLastError(); Error("fopen %s failed, %d", strFileName.c_str(), dw); return false; } fwrite(pwRawImage, sizeof(WORD), nWidth * nHeight, fp); fclose(fp); Info("Save raw image over"); return true; }