#include "CCOS.Dev.FPD.TiRayDR.h" #include "common_api.h" #include "DICOMImageHeadKey.h" #include "Detector_TiRayDR.h" #include "LogLocalHelper.h" #include "Log4CPP.h" namespace nsFPD = CCOS::Dev::Detail::Detector; //----------------------------------------------------------------------------- // FPDDeviceTiRay //----------------------------------------------------------------------------- extern Detector_TiRayDR* g_pDetector; static nsFPD::TiRayDriver gIODriver; //Log4CPP::Logger* mLog::gLogger = nullptr; extern "C" CCOS::Dev::IODriver * GetIODriver() // 返回静态对象的引用, 调用者不能删除 ! { return &gIODriver; } extern "C" CCOS::Dev::IODriver * CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 ! { return new nsFPD::TiRayDriver(); } nsFPD::TiRayDriver::TiRayDriver() { pObjDev = nullptr; m_bDriverConnect = false; //缺省为false m_pAttribute.reset(new ResDataObject()); m_pDescription.reset(new ResDataObject()); } nsFPD::TiRayDriver::~TiRayDriver() { if (pObjDev != nullptr) { delete pObjDev; pObjDev = nullptr; } } void nsFPD::TiRayDriver::Prepare() { // 初始化日志系统 std::string strLogPath = GetProcessDirectory() + R"(/Conf/log_config.xml)"; std::string LogHost = "DevTiRay"; // 确保这是正确的值 std::string moduleName = "DevTiRay"; bool ret = initLogModule( LogHost, // 主机名(用于日志路径中的{host}占位符) moduleName, // 唯一模块名 strLogPath, // 配置文件路径 true // 是否输出到控制台(可选) ); if (!ret) { std::cerr << "Log init failed!" << std::endl; return; } TiRaySetLocalModuleName(moduleName); FINFO("Code Build datetime [{$} {$}]", __DATE__, __TIME__); } bool nsFPD::TiRayDriver::Connect() { FINFO("--Func-- Driver Connect Start"); bool bWired = false; bool bWireless = false; if (pObjDev == nullptr) { pObjDev = new FPDDeviceTiRay(EventCenter, m_ConfigFileName); } /*m_DetectorConfiguration.reset(new DetectorConfiguration(m_ConfigFileName)); ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations; std::string strWiredIP = (std::string)objModeConfig["DetectorWiredIP"]; std::string strWiressIP = (std::string)objModeConfig["DetectorWirelessIP"]; bWired = CheckConnect(strWiredIP); if (strWiressIP != "0.0.0.0") bWireless = CheckConnect(strWiressIP); FINFO("Driver Connect Over"); if (bWired || bWireless) { m_bDriverConnect = true; return true; } else { m_bDriverConnect = false; return false; }*/ m_bDriverConnect = true; return true; } void nsFPD::TiRayDriver::Disconnect() { FINFO("--Func-- Driver Disconnect Start"); m_bDriverConnect = false; //disconnect置为false FINFO("Driver Disconnect Over"); } bool nsFPD::TiRayDriver::isConnected() const { return m_bDriverConnect; } bool nsFPD::TiRayDriver::CheckConnect(std::string strIP) { CMyPingip obPingIp; if (!obPingIp.PingFunction(strIP.c_str())) { FINFO("ping {$} Failed", strIP); return false; } return true; } auto nsFPD::TiRayDriver::CreateDevice(int index)->std::unique_ptr { FINFO("--Func-- Driver CreateDevice Start"); auto Device = std::unique_ptr(new IODevice(pObjDev)); pObjDev->CreateDevice(); pObjDev->Register(); FINFO("Driver CreateDevice Over"); return Device; } std::string nsFPD::TiRayDriver::DriverProbe() { FINFO("--Func-- Driver DriverProbe Start"); FINFO("DriverProbe Config Name: {$}", m_ConfigFileName); 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", "TiRay"); #ifdef TiRay4343 HardwareInfo.add("ProductID", "DY4343"); #endif // TiRay4343 #ifdef TiRay2530W HardwareInfo.add("ProductID", "DY2530W"); #endif // TiRay2530W #ifdef TiRay4343W HardwareInfo.add("ProductID", "DY4343W"); #endif // TiRay4343W HardwareInfo.add("SerialID", "Driver"); } string str = HardwareInfo.encode(); return str; } /*** ** 获取ID和配置 ***/ std::string nsFPD::TiRayDriver::GetResource() { FINFO("--Func-- Driver GetResource Start"); ResDataObject r_config, temp; FINFO("m_ConfigFileName:{$}", m_ConfigFileName); 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 = ""; //用于读取字符串配置信息 int nTemp = -1; //用于读取整型配置信息 string strValue = ""; //用于存储配置的值 string strType = ""; //用于存储配置的类型 int/float/string... string strAccess = ""; //用于存储权限的类型 R/W/RW try { int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo"); 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()); 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())); } else if ("float" == strType) { (*m_pAttribute).add(strTemp.c_str(), atof(strValue.c_str())); } else //其它先按string类型处理 { (*m_pAttribute).add(strTemp.c_str(), strValue.c_str()); } //AttributeAccess strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Access"]; DescriptionTemp.add(AttributeAccess, strTemp.c_str()); //AttributeRangeMin strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMin"]; if (strTemp != "") //不需要的配置项为空 { DescriptionTemp.add(AttributeRangeMin, strTemp.c_str()); } //AttributeRangeMax strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMax"]; if (strTemp != "") //不需要的配置项为空 { DescriptionTemp.add(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]; auto temKey = std::to_string(nListIndex); ListTemp.add(temKey.c_str(), strTemp.c_str()); } DescriptionTemp.add(AttributeList, ListTemp); } //AttributeRequired strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Required"]; DescriptionTemp.add(AttributeRequired, strTemp.c_str()); //AttributeDefaultValue strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["DefaultValue"]; if (strTemp != "") //不需要的配置项为空 { DescriptionTemp.add(AttributeDefaultValue, strTemp.c_str()); } strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"]; (*m_pDescription).add(strTemp.c_str(), DescriptionTemp); } } catch (ResDataObjectExption& e) { FERROR("Get config FERROR: {$}", 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(); FINFO("Driver GetResource Over"); return res; } std::string nsFPD::TiRayDriver::DeviceProbe() { FINFO("--Func-- Driver DeviceProbe Start"); 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", "TiRay"); #ifdef TiRay4343 HardwareInfo.add("ProductID", "DY4343"); #endif // TiRay4343 #ifdef TiRay2530W HardwareInfo.add("ProductID", "DY2530W"); #endif // TiRay2530W #ifdef TiRay4343W HardwareInfo.add("ProductID", "DY4343W"); #endif // TiRay4343W HardwareInfo.add("SerialID", "1234"); } string str = HardwareInfo.encode(); FINFO("Driver DeviceProbe Over"); return str; } bool nsFPD::TiRayDriver::GetDeviceConfig(std::string& Cfg) { FINFO("--Func-- Driver GetDeviceConfig Start"); Cfg = m_DeviceConfig.encode(); FINFO("Cfg:{$}", Cfg); FINFO("Driver GetDeviceConfig Over"); return true; } bool nsFPD::TiRayDriver::SetDeviceConfig(std::string Cfg) { FINFO("--Func-- Driver SetDeviceConfig Start"); FINFO("SetDeviceConfig {$}", Cfg.c_str()); ResDataObject DeviceConfig; DeviceConfig.decode(Cfg.c_str()); ResDataObject DescriptionTempEx; DescriptionTempEx = DeviceConfig["DeviceConfig"]; bool bSaveFile = false; //true:重新保存配置文件 string strAccess = ""; for (int i = 0; i < DescriptionTempEx.size(); i++) { ResDataObject temp = DescriptionTempEx[i]; FINFO("{$}", temp.encode()); for (int j = 0; j < temp.size(); j++) { string strKey = temp.GetKey(j); FINFO("{$}", strKey.c_str()); try { if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0) { strAccess = (string)(*m_pDescription)[strKey.c_str()]["Access"]; if ("RW" == strAccess || "rw" == strAccess) { //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值 //1. 修改内存中的值,用于给上层发消息 (*m_pAttribute)[strKey.c_str()] = temp[j]; //2. 拿到Innerkey int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo"); FINFO("ConfigInfo Count: {$}", nConfigInfoCount); string strTemp = ""; //存储AttributeKey for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++) { strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"]; if (strTemp == strKey) { strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"]; break; } } //3. 修改配置文件中的值 if (SetDeviceConfigValue(m_Configurations, strTemp.c_str(), 1, temp[j])) { bSaveFile = true; } } else { FINFO("{$} is not a RW configuration item", strKey.c_str()); } } } catch (ResDataObjectExption& e) { FERROR("SetDeviceConfig crashed: {$}", e.what()); return false; } } } if (bSaveFile) { //3. 重新保存配置文件 SaveConfigFile(true); } FINFO("Driver SetDeviceConfig Over"); return true; } bool nsFPD::TiRayDriver::SaveConfigFile(bool bSendNotify) { FINFO("--Func-- Driver SaveConfigFile Start"); FINFO("ConfigFileName:{$}", m_ConfigFileName); m_ConfigAll["CONFIGURATION"] = m_Configurations; bool ret = m_ConfigAll.SaveFile(m_ConfigFileName.c_str()); FINFO("Driver SaveConfigFile Over"); if (ret) { FINFO("SaveConfigFile Success!"); return true; } else { FERROR("SaveConfigFile Fail!"); return false; } } bool nsFPD::TiRayDriver::GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue) { FINFO("--Func-- Driver GetDeviceConfigValue Start"); 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 = ""; FERROR("FERROR Configuration item: {$}", pInnerKey); } } FINFO("Driver GetDeviceConfigValue Over"); return true; } bool nsFPD::TiRayDriver::SetDeviceConfigValue(ResDataObject &config, const char* pInnerKey, int nPathID, const char* szValue) { FINFO("--Func-- Driver SetDeviceConfigValue Start"); FINFO("SetDeviceConfigValue change {$} item value to {$}", pInnerKey, szValue); string strTemp = pInnerKey; 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 || CcosDetectorAttachedFlag == strTemp) { config[pInnerKey] = szValue; } else { FERROR("FERROR Configuration item: {$}", pInnerKey); return false; } } FINFO("Driver SetDeviceConfigValue Over"); return true; } nsFPD::FPDDeviceTiRay::FPDDeviceTiRay(std::shared_ptr center, std::string strConfigPath) : FPDDeviceMould("DevTiRay"), m_nFPDExpReadyTime(1000), m_nCalibTotalExposureNum{}, m_nCalibCurrentCalibrationRound{1}, m_nCalibCurrentExposureIndex{}, m_nCalibCurrentExposureNum{}, m_nFullImageHeight{}, m_nFullImageWidth{}, m_nImgBits{}, m_nPixelSpacing{}, m_nSensitivity{}, m_fDose{}, m_fFactorEXI2UGY{}, m_eSyncMode(SYNC_SOFTWARE), m_eAppStatus(APP_STATUS_IDLE), m_bDeviceConnect(false), m_pFullImgBuffer(nullptr) { m_strWorkPath = GetProcessDirectory(); m_DetectorCtrlUnit.reset(new OemCtrl(center, this)); m_AcqUnit.reset(new OemAcq(center, this)); m_SyncUnit.reset(new OemSync(center, this)); m_CalibUnit.reset(new OemCalib(center, this)); m_DetectorConfiguration.reset(new DetectorConfiguration(strConfigPath)); std::string strErrorInfoPath = m_strWorkPath + "\\OEMDrivers\\Detector\\Conf\\"; //m_WarnAndError.reset(new FPDErrorWarning(center, DetectorUnitType, strErrorInfoPath)); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_INIT)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ERROR)); EventCenter = center; } nsFPD::FPDDeviceTiRay::~FPDDeviceTiRay() { if (nullptr != m_pFullImgBuffer) { delete[] m_pFullImgBuffer; m_pFullImgBuffer = nullptr; } } std::string nsFPD::FPDDeviceTiRay::GetGUID() const { return DetectorUnitType; } bool nsFPD::FPDDeviceTiRay::Prepare() { FINFO("--Func Device-- Prepare Start"); //EventCenter->OnMaxBlockSize("DrTiRay", 4000 * 4000 * 2, 6, 1500 * 1500 * 2, 2); Connect(); FINFO("Device Prepare Over"); return true; } bool nsFPD::FPDDeviceTiRay::CreateDevice() { FINFO("--Func Device-- CreateDevice Start"); if (!LoadConfig()) { return false; } if (nullptr == g_pDetector) { g_pDetector = new Detector_TiRayDR(); } g_pDetector->DriverEntry(this, m_DetectorConfiguration->m_Configurations); FINFO("Device CreateDevice Over"); return true; } void nsFPD::FPDDeviceTiRay::Register() { FINFO("--Func Device-- Register Start"); auto Disp = m_Dispatch.Lock().As(); RegisterCtrl(Disp); RegisterAcq(Disp); RegisterSync(Disp); RegisterCalib(Disp); RegisterOthers(Disp); FINFO("Device Register Over"); } RET_STATUS nsFPD::FPDDeviceTiRay::ScanDetector(string& strDetectorInfo) { if (nullptr == g_pDetector) { std::cerr << "[FPDDeviceTiRay::ScanDetector] g_pDetector is not initialized!" << std::endl; return RET_STATUS::RET_FAILED; } return g_pDetector->ScanDetector(strDetectorInfo) ? RET_STATUS::RET_SUCCEED : RET_STATUS::RET_FAILED; } RET_STATUS nsFPD::FPDDeviceTiRay::Connect() { FINFO("--Func Device-- Connect Start"); m_DetectorCtrlUnit->SetAttachStatus(to_string(1)); //没有attach功能,直接上发1,使客户端显示探测器状态 RET_STATUS ret = RET_STATUS::RET_FAILED; if (g_pDetector->Connect(this, m_strWorkPath.c_str())) { m_SyncUnit->SetSupportSyncMode(m_stDeviceConfig.strSupportSyncMode); string strTemp = (string)m_DetectorConfiguration->m_Configurations["SerialNumber"]; m_DetectorCtrlUnit->SetSerialNumber(strTemp); //m_CalibUnit->SetLastCalibrationDate(m_stDeviceConfig.strLastCalibrationDate); //m_CalibUnit->SetCalibrationFileExpireTime(m_stDeviceConfig.strCalibrationFileExpireTime); if (m_stDeviceConfig.bSupportDDR) //是否支持DDR采集功能 { m_DetectorCtrlUnit->SetSupportDDR("YES"); } else { m_DetectorCtrlUnit->SetSupportDDR("NO"); } ret = RET_STATUS::RET_SUCCEED; } FINFO("Device Connect Over"); return ret; } RET_STATUS nsFPD::FPDDeviceTiRay::EnterExam(int nExamMode) { FINFO("--Func Device-- EnterExam Start"); switch (nExamMode) { case APP_STATUS_WORK_BEGIN: FINFO("Enter into Exam Windows"); m_eAppStatus = APP_STATUS_WORK_BEGIN; FINFO("m_stDeviceConfig.strLastCalibrationDate:{$}", m_stDeviceConfig.strLastCalibrationDate); //进检查时判断当前校正文件是否过期,如果即将过期或者已过期都向上通知 //if (m_stDeviceConfig.strLastCalibrationDate == "0000-00-00 00:00:00") //{ // //没有做过校正 // FWARN("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);//单位:天 // FINFO("nExpireTime:{$}", nExpireTime); // time_t localtime = time(NULL); // //判断是否过期 // if (localtime > lastCalibDate + nExpireTime * 24 * 3600) // { // //过期了报错 // FWARN("Calibration file is expired! please make a calibration!"); // //m_WarnAndError->SendWarn(ERR_FPD_CAL_FILE_OUTDATE, ""); // } //} break; case APP_STATUS_WORK_END: FINFO("Quit Exam Windows"); m_eAppStatus = APP_STATUS_WORK_END; break; case APP_STATUS_DETSHARE_BEGIN: FINFO("Enter into Detector Share Windows"); m_eAppStatus = APP_STATUS_DETSHARE_BEGIN; break; case APP_STATUS_DETSHAR_END: FINFO("Quit Detector Share Windows"); m_eAppStatus = APP_STATUS_DETSHAR_END; break; case APP_STATUS_CAL_BEGIN: FINFO("Enter into Calibration Windows"); m_eAppStatus = APP_STATUS_CAL_BEGIN; break; case APP_STATUS_CAL_END: FINFO("Quit Calibration Windows"); m_eAppStatus = APP_STATUS_CAL_END; break; case APP_STATUS_WORK_IN_SENSITIVITY: FINFO("Enter into sensitivity test interface"); m_eAppStatus = APP_STATUS_WORK_IN_SENSITIVITY; break; default: break; } g_pDetector->EnterExamMode(nExamMode); FINFO("Device EnterExam Over"); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceTiRay::SetAcqMode(string strMode) { FINFO("--Func Device-- SetAcqMode Start"); RET_STATUS ret = RET_STATUS::RET_FAILED; //如果没连接,不执行 if (!m_bDeviceConnect) { FERROR("Detector not connected, return"); return ret; } //设置采集模式时发一次非Standby状态,配合子系统走流程,使界面ready状态和探测器同步 m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_WAKEUP)); int nMode = AcqMode::RAD; try { ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations; m_nFullImageWidth = (int)objModeConfig["ModeTable"][0]["ImageWidth"]; m_nFullImageHeight = (int)objModeConfig["ModeTable"][0]["ImageHeight"]; m_nImgBits = (int)objModeConfig["ModeTable"][0]["PhySizeInfoBit"]; m_nPixelSpacing = (int)objModeConfig["ModeTable"][0]["PixelPitch"]; m_nSensitivity = (int)objModeConfig["ModeTable"][0]["Sensitivity"]; m_nFPDExpReadyTime = (int)objModeConfig["ModeTable"][0]["XWindow"]; if (nullptr != m_pFullImgBuffer) { delete[]m_pFullImgBuffer; m_pFullImgBuffer = nullptr; } m_pFullImgBuffer = new unsigned short[(size_t)m_nFullImageWidth * (size_t)m_nFullImageHeight]; m_AcqUnit->SetFulImageInfo(m_nFullImageHeight, m_nFullImageWidth, m_nImgBits, false); m_AcqUnit->SetPrevImageInfo(false, 0, 0, false); string strDoseOfExi = std::to_string(m_nSensitivity); m_fFactorEXI2UGY = 100.0f / stof(strDoseOfExi) * 1.0f;//统一使用IEC标准 呈现四角信息,无单位 ugy * 100 -ugy。所有Zskk探测器的FactorEXI2UGY均需*100 FINFO("m_fFactorEXI2UGY = {$} ", m_fFactorEXI2UGY); m_DetectorCtrlUnit->SetFPDSensitivity(std::to_string(m_fFactorEXI2UGY)); //读取校正时的目标EXI int nTargetCalibExi = (int)objModeConfig["ModeTable"][0]["TargetGainEXI"]; m_nTargetCalibExi = nTargetCalibExi; FINFO("m_nTargetCalibExi:{$}", m_nTargetCalibExi); if (g_pDetector->SetAcqMode(nMode)) { ret = RET_STATUS::RET_SUCCEED; m_AcqUnit->AcqModeNotify(strMode); } else { ret = RET_STATUS::RET_FAILED; } } catch (ResDataObjectExption& e) { FERROR("Read configuration failed, Error code: {$}", e.what()); } FINFO("Device SetAcqMode Over"); return ret; } RET_STATUS nsFPD::FPDDeviceTiRay::GetSyncMode(SYNC_MODE& eSyncMode) { FINFO("--Func Device-- GetSyncMode Start"); eSyncMode = m_eSyncMode; FINFO("Device GetSyncMode Over"); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceTiRay::PrepareAcquisition() { FINFO("--Func Device-- PrepareAcquisition Start"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bDeviceConnect) { FERROR("Detector not connected, return"); return ret; } if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) || (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE)) { FERROR("PrepareAcquisition failed. Detector at Calibration status"); } m_SyncUnit->FPDReadyNotify(false); //prepare前置为初值 if (g_pDetector->PrepareAcquisition(this)) { ret = RET_STATUS::RET_SUCCEED; } FINFO("Device PrepareAcquisition Over"); return ret; } RET_STATUS nsFPD::FPDDeviceTiRay::StartAcquisition(string in) { FINFO("--Func Device-- StartAcquisition Start"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bDeviceConnect) { FERROR("Detector not connected, return"); return ret; } if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus()) { if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) || (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE)) { FERROR("PrepareAcquisition failed. Detector at Calibration status."); } if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus()) { FERROR("Detector already at Acq status."); } } else { if (g_pDetector->StartAcquisition(this)) { ret = RET_STATUS::RET_SUCCEED; m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ)); } else { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); } } FINFO("Device StartAcquisition Over"); return ret; } RET_STATUS nsFPD::FPDDeviceTiRay::StopAcquisition() { FINFO("--Func Device-- StopAcquisition Start"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bDeviceConnect) { FERROR("Detector not connected, return"); return ret; } if (DETECTOR_STATUS_STANDBY == m_DetectorCtrlUnit->GetDetectorStatus()) { FINFO("Detector already at Acq status."); ret = RET_STATUS::RET_SUCCEED; } else { if (g_pDetector->StopAcquisition(this)) { ret = RET_STATUS::RET_SUCCEED; //m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); } } FINFO("Device StopAcquisition Over"); return ret; } RET_STATUS nsFPD::FPDDeviceTiRay::ActiveCalibration(CCOS_CALIBRATION_TYPE eType) { FINFO("--Func Device-- ActiveCalibration Start"); FINFO("ActiveCalibration {$}", (int)eType); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bDeviceConnect) { FERROR("m_bDeviceConnect is false, detector not connect, return"); return ret; } if (eType == CCOS_CALIBRATION_TYPE_NONE || eType == CCOS_CALIBRATION_TYPE_MAX) { FERROR("calibration type is invalid!"); return RET_STATUS::RET_INVALID; } else { m_CalibType = eType; } m_eAppStatus = APP_STATUS_CAL_BEGIN; if (eType == CCOS_CALIBRATION_TYPE_XRAY) { FINFO("calibration type: XRAY"); int nCalibrationRounds = (int)m_CalibDoseList.size(); g_pDetector->SetCalibRounds(nCalibrationRounds); } if (g_pDetector->ActiveCalibration(this, eType)) { ret = RET_STATUS::RET_SUCCEED; m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ACTIVE)); m_CalibUnit->SetCalibrationProgress("0"); } else { FERROR("Active calibration failed"); ret = RET_STATUS::RET_FAILED; } //重置校正流程参数 m_nCalibCurrentCalibrationRound = 1; m_nCalibCurrentExposureIndex = 1; m_nCalibCurrentExposureNum = 0; FINFO("Device ActiveCalibration Over"); return ret; } RET_STATUS nsFPD::FPDDeviceTiRay::PrepareCalibration() { FINFO("--Func Device-- PrepareCalibration Start"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bDeviceConnect) { FERROR("m_bDeviceConnect is false, detector not connect, return"); return ret; } if (g_pDetector->PrepareCalibration(this)) { m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_PREPARE)); CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType(); if (nCalibrationType == CCOS_CALIBRATION_TYPE_XRAY && m_eSyncMode == SYNC_AED) { FINFO("set m_bEnterAcqStatus true"); } ret = RET_STATUS::RET_SUCCEED; m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); } else { FERROR("PrepareCalibration failed!"); return ret; } FINFO("Device PrepareCalibration Over"); return ret; } RET_STATUS nsFPD::FPDDeviceTiRay::GetRequestedDose(std::string& strDose) { FINFO("--Func Device-- GetRequestedDose Start"); RET_STATUS ret = RET_STATUS::RET_FAILED; ResDataObject out; if (!m_bDeviceConnect) { FERROR("m_bDeviceConnect is false, detector not connect, return"); return ret; } CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType(); FINFO("GetRequestedDose calib type is {$}", (int)nCalibrationType); 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); } else if (CCOS_CALIBRATION_TYPE_XRAY == nCalibrationType) { FINFO("calib dose list size is {$}", m_CalibDoseList.size()); ResDataObject temp = m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]; int nTargetExi = (int)temp["TargetGainEXI"]; m_DetectorCtrlUnit->SetTargetEXI(std::to_string(nTargetExi)); FINFO("nTargetExi:{$}", nTargetExi); out.add("Dose", nTargetExi); out.add("kV", temp["KV"]); out.add("mA", temp["MA"]); out.add("ms", temp["MS"]); out.add("mAs", temp["MAS"]); } else { FERROR("Don't support CalibrationType($)", (int)nCalibrationType); return ret; } strDose = out.encode(); FINFO("GetRequestedDose:{$}", strDose); ret = RET_STATUS::RET_SUCCEED; FINFO("Device GetRequestedDose Over"); return ret; } RET_STATUS nsFPD::FPDDeviceTiRay::SetRequestedDose(std::string strDose) { FINFO("--Func Device-- SetRequestedDose Start"); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; FINFO("SetRequestedDose Over"); return Ret; } RET_STATUS nsFPD::FPDDeviceTiRay::GetCalibrationStep(int nDetectorID, string& strCalibrationStepInfo) { FINFO("--Func Device-- GetCalibrationStep Start"); cout << "--Func Device-- GetCalibrationStep Start. DetectorID: " << nDetectorID << endl; RET_STATUS ret = RET_STATUS::RET_SUCCEED; ResDataObject out; int nCalibrationRounds = (int)m_CalibDoseList.size(); int nExposureNumCurrentRound = (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"]; if (g_pDetector->GetCalibrationStep(m_nCalibCurrentCalibrationRound, nCalibrationRounds, m_nCalibCurrentExposureIndex, nExposureNumCurrentRound)) { cout << "g_pDetector->GetCalibrationStep success" << endl; FINFO("GetCalibrationStep success"); } else { cout << "g_pDetector->GetCalibrationStep failed" << endl; FERROR("GetCalibrationStep error"); ret = RET_STATUS::RET_FAILED; return ret; } 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); cout << "Calibration info - Rounds: " << nCalibrationRounds << ", TotalExposures: " << m_nCalibTotalExposureNum << ", CurrentRound: " << m_nCalibCurrentCalibrationRound << ", CurrentIndex: " << m_nCalibCurrentExposureIndex << endl; strCalibrationStepInfo = out.encode(); cout << "strCalibrationStepInfo: " << strCalibrationStepInfo << endl; cout << "Device GetCalibrationStep Over. Return: " << ret << endl; FINFO("strCalibrationStepInfo: {$}", strCalibrationStepInfo.c_str()); FINFO("Device GetCalibrationStep Over"); return ret; } RET_STATUS nsFPD::FPDDeviceTiRay::StartCalibration() { FINFO("--Func Device-- StartCalibration Start"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bDeviceConnect) { FERROR("m_bDeviceConnect is false, detector not connect, return"); return ret; } if (m_CalibUnit->GetCalibrationStatus() != CCOS_CALIBRATION_STATUS_PREPARE) { FERROR("Start calibration failed, in {$} status", (int)m_CalibUnit->GetCalibrationStatus()); return ret; } if (g_pDetector->StartCalibration(this)) { FINFO("start calibration success set detector status"); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING)); ret = RET_STATUS::RET_SUCCEED; if (m_eSyncMode == SYNC_AED) { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));//StartCalibration } } else { FERROR("StartCalibration failed"); ret = RET_STATUS::RET_FAILED; return ret; } FINFO("Device StartCalibration Over"); return ret; } RET_STATUS nsFPD::FPDDeviceTiRay::StopCalibration() { FINFO("--Func Device-- StopCalibration Start"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bDeviceConnect) { FERROR("m_bDeviceConnect is false, detector not connect, return"); return ret; } m_eAppStatus = APP_STATUS_CAL_END; if (g_pDetector->StopCalibration(this)) { ret = RET_STATUS::RET_SUCCEED; m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_BESTOPPED)); } else { FERROR("StopCalibration failed"); } FINFO("Device StopCalibration Over"); return ret; } RET_STATUS nsFPD::FPDDeviceTiRay::AbortCalibration() { FINFO("--Func Device-- AbortCalibration Start"); m_eAppStatus = APP_STATUS_CAL_END; CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType(); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ERROR)); m_CalibUnit->SetCalibrationProgress("100"); if (CCOS_CALIBRATION_TYPE_XRAY == nCalibrationType) { g_pDetector->AbortCalibration(this); m_AcqUnit->SendNoNeedWaitImage(true); } //如果中止的时候探测器在采集状态需要停止采集 return RET_STATUS::RET_SUCCEED; FINFO("Device AbortCalibration Over"); } RET_STATUS nsFPD::FPDDeviceTiRay::AcceptCalibration() { FINFO("--Func Device-- AcceptCalibration Start"); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; if (g_pDetector->AcceptCalibration()) { FINFO("AcceptCalibration success"); Ret = RET_STATUS::RET_SUCCEED; } else { FERROR("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)) { FINFO("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; } else { m_nCalibCurrentExposureIndex++; } m_nCalibCurrentExposureNum++; m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); FINFO("Device AcceptCalibration Over"); return Ret; } RET_STATUS nsFPD::FPDDeviceTiRay::RejectCalibration() { FINFO("--Func Device-- RejectCalibration Start"); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; if (g_pDetector->RejectCalibration()) { Ret = RET_STATUS::RET_SUCCEED; } else { FERROR("RejectCalibration error"); Ret = RET_STATUS::RET_FAILED; } m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); FINFO("Device RejectCalibration Over"); return Ret; } RET_STATUS nsFPD::FPDDeviceTiRay::ActiveDetector(bool bActive) { FINFO("--Func Device-- ActiveDetector Start"); if (!m_stDeviceConfig.bConnectStatus) { return RET_STATUS::RET_THREAD_INVALID; } FINFO("Device ActiveDetector Over"); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceTiRay::CompleteCalibration() { FINFO("--Func Device-- CompleteCalibration Start"); if (!g_pDetector->CompleteCalibration(this)) { FERROR("CompleteCalibration fail!"); return RET_STATUS::RET_FAILED; } if (g_pDetector->GetCalibType() == CCOS_CALIBRATION_TYPE_DARK) { FINFO("CompleteCalibration Calibration Type DARK"); } else if (g_pDetector->GetCalibType() == CCOS_CALIBRATION_TYPE_XRAY) { FINFO("CompleteCalibration Calibration Type XRAY"); m_eAppStatus = APP_STATUS_CAL_END; } FINFO("CompleteCalibration set detector status standby"); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_CalibUnit->SetCalibrationProgress("100"); FINFO("Device CompleteCalibration Over"); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceTiRay::SaveCalibrationFile(bool bSaveFlag) { FINFO("--Func Device-- SaveCalibrationFile Start"); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; FINFO("SaveCalibrationFile bSaveFlag: {$}", bSaveFlag); if (!bSaveFlag) { FERROR("Not save calibration file"); return Ret; } //点击save按钮时先调用compelte再调用save CompleteCalibration(); if (g_pDetector->SaveCalibrationFile()) { m_CalibUnit->SetSaveCalibrationFileFinish(true); Ret = RET_STATUS::RET_SUCCEED; //更新配置文件中校正日期和时间 time_t localtime = time(NULL); string strLocalTime = DatetimeToString(localtime); FINFO("strLocalTime:{$}", strLocalTime); m_CalibUnit->SetLastCalibrationDate(strLocalTime); FINFO("m_CalibUnit->SetLastCalibrationDate Over"); //清除校正文件相关警告 //m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_NOT_EXIST); //m_WarnAndError->ClearWarn(ERR_FPD_CAL_FILE_OUTDATE); } else { FERROR("SaveCalibrationFile error"); m_CalibUnit->SetSaveCalibrationFileFinish(false); Ret = RET_STATUS::RET_FAILED; } FINFO("Device SaveCalibrationFile Over"); return Ret; } bool nsFPD::FPDDeviceTiRay::Support_DarkCalib() { return true; } bool nsFPD::FPDDeviceTiRay::Support_XrayCalib() { return true; } void nsFPD::FPDDeviceTiRay::SendTemperatureValue(float fValue) { int nStatus = 0; m_Temperature->SetTemperature(fValue, nStatus); FINFO("SendTemperatureValue: {$}, status {$}", fValue, nStatus); return; } void nsFPD::FPDDeviceTiRay::SendWifiValue(int nValue) { int nStatus = 0; m_Wifi->SetSignalValue(nValue, nStatus); FINFO("SendWifiValue: {$}, status {$}", nValue, nStatus); return; } void nsFPD::FPDDeviceTiRay::SendBatteryValue(int nValue) { int nStatus = 0; m_Battery->SetRemainPowerValue(nValue, nStatus); FINFO("SendBatteryValue: {$}, status {$}", nValue, nStatus); return; } bool nsFPD::FPDDeviceTiRay::LoadConfig() { FINFO("--Func Device-- LoadConfig Start"); if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_CalibDoseList, m_nCalibTotalExposureNum)) { FERROR("Load configuration file failed!!!"); return false; } ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations; m_nFullImageWidth = (int)objModeConfig["ModeTable"][0]["ImageWidth"]; m_nFullImageHeight = (int)objModeConfig["ModeTable"][0]["ImageHeight"]; m_nImgBits = (int)objModeConfig["ModeTable"][0]["PhySizeInfoBit"]; m_nPixelSpacing = (int)objModeConfig["ModeTable"][0]["PixelPitch"]; m_nSensitivity = (int)objModeConfig["ModeTable"][0]["Sensitivity"]; m_nFPDExpReadyTime = (int)objModeConfig["ModeTable"][0]["XWindow"]; if (nullptr != m_pFullImgBuffer) { delete[]m_pFullImgBuffer; m_pFullImgBuffer = nullptr; } m_pFullImgBuffer = new unsigned short[(size_t)m_nFullImageWidth * (size_t)m_nFullImageHeight]; m_AcqUnit->SetFulImageInfo(m_nFullImageHeight, m_nFullImageWidth, m_nImgBits, false); m_AcqUnit->SetPrevImageInfo(false, 0, 0, false); string strDoseOfExi = std::to_string(m_nSensitivity); m_fFactorEXI2UGY = 100.0f / stof(strDoseOfExi) * 1.0f;//统一使用IEC标准 呈现四角信息,无单位 ugy * 100 -ugy。所有Zskk探测器的FactorEXI2UGY均需*100 m_DetectorCtrlUnit->SetFPDSensitivity(std::to_string(m_fFactorEXI2UGY)); //读取校正时的目标EXI int nTargetCalibExi = (int)objModeConfig["ModeTable"][0]["TargetGainEXI"]; m_nTargetCalibExi = nTargetCalibExi; //FINFO("m_CalibDoseList:{$}", m_CalibDoseList.encode()); //FINFO("m_nCalibTotalExposureNum:{$}", m_nCalibTotalExposureNum); //m_SyncUnit->SetSupportSyncMode(m_stDeviceConfig.strSupportSyncMode); //m_CalibUnit->SetLastCalibrationDate(m_stDeviceConfig.strLastCalibrationDate); //m_CalibUnit->SetCalibrationFileExpireTime(m_stDeviceConfig.strCalibrationFileExpireTime); m_Battery.reset(new DeviceBatteryMould("DetectorBattery", 0, m_stDeviceConfig.nBatteryLimit, m_stDeviceConfig.nBatteryWarning, 100, m_stDeviceConfig.nBatteryLimit, 100, 100, 0, EventCenter)); m_Temperature.reset(new DeviceTemperatureMould("DetectorTemperature", 0.0f, m_stDeviceConfig.fTemperatureErrorMin, m_stDeviceConfig.fTemperatureWarnMin, m_stDeviceConfig.fTemperatureWarnMax, m_stDeviceConfig.fTemperatureWarnMin, m_stDeviceConfig.fTemperatureWarnMax, m_stDeviceConfig.fTemperatureErrorMax, 0.0f, EventCenter)); m_Wifi.reset(new DeviceWifiMould("DetectorWifi", 0, m_stDeviceConfig.nWifiLimit, m_stDeviceConfig.nWifiWarning, 100, m_stDeviceConfig.nWifiLimit, 100, 100, 0, EventCenter)); FINFO("Device LoadConfig Over"); return true; } void nsFPD::FPDDeviceTiRay::RegisterCtrl(nsDetail::Dispatch* Dispatch) { Dispatch->Action.Push(ActionKey::EnterExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSEnterExam); Dispatch->Action.Push(ActionKey::ExitExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSExitExam); Dispatch->Action.Push(ActionKey::SetExposureTimes, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetExposureTimes); Dispatch->Action.Push(ActionKey::SetXrayOnNum, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetXrayOnNum); Dispatch->Action.Push(ActionKey::ActiveDetector, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSActiveDetector); Dispatch->Action.Push(ActionKey::ScanDetector, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSScanDetector); Dispatch->Action.Push(ActionKey::ConnectDetector, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSConnectDetector); Dispatch->Get.Push(AttrKey::DetectorConnectStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetConnectStatus); Dispatch->Get.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDStatus); Dispatch->Get.Push(AttrKey::DetectorType, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorType); Dispatch->Get.Push(AttrKey::Description, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDescription); Dispatch->Get.Push(AttrKey::DetectorID, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorID); Dispatch->Get.Push(AttrKey::FPDSensitivity, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDSensitivity); Dispatch->Get.Push(AttrKey::PixelData, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetPixelData); Dispatch->Get.Push(AttrKey::TargetEXI, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTargetEXI); Dispatch->Get.Push(CcosDetectorAttachedFlag, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachStatus);//CcosDetectorAttachedFlag Dispatch->Get.Push(SupportDDR, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetSupportDDR); Dispatch->Get.Push(AttrKey::SerialNumber, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetSerialNumber); Dispatch->Set.Push(AttrKey::DetectorConnectStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetConnectStatus); Dispatch->Set.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorStatus); Dispatch->Set.Push(AttrKey::DetectorType, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorType); Dispatch->Set.Push(AttrKey::Description, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDescription); Dispatch->Set.Push(AttrKey::DetectorID, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorID); Dispatch->Set.Push(AttrKey::PixelData, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetPixelData); Dispatch->Set.Push(AttrKey::TargetEXI, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetTargetEXI); Dispatch->Set.Push(CcosDetectorAttachedFlag, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetAttachStatus); Dispatch->Set.Push(SupportDDR, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetSupportDDR); Dispatch->Set.Push(AttrKey::SerialNumber, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetSerialNumber); Dispatch->Update.Push(AttrKey::SerialNumber, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateSerialNumber); } void nsFPD::FPDDeviceTiRay::RegisterAcq(nsDetail::Dispatch* Dispatch) { Dispatch->Action.Push(ActionKey::SetAcqMode, m_AcqUnit.get(), &AcqUnit::JSSetAcqMode); Dispatch->Get.Push(AttrKey::AcqMode, m_AcqUnit.get(), &AcqUnit::JSGetAcqMode); Dispatch->Get.Push(AttrKey::ZskkFPDState, m_AcqUnit.get(), &AcqUnit::JSGetZskkFPDState); Dispatch->Get.Push(AttrKey::NoNeedWaitImage, m_AcqUnit.get(), &AcqUnit::JSGetNoNeedWaitImage); Dispatch->Get.Push(AttrKey::ImgDataInfo, m_AcqUnit.get(), &AcqUnit::JSGetLastImage); Dispatch->Set.Push(AttrKey::ZskkFPDState, m_AcqUnit.get(), &AcqUnit::SetZskkFPDState); Dispatch->Set.Push(AttrKey::NoNeedWaitImage, m_AcqUnit.get(), &AcqUnit::JSSetNoNeedWaitImage); } void nsFPD::FPDDeviceTiRay::RegisterSync(nsDetail::Dispatch* Dispatch) { Dispatch->Action.Push(ActionKey::SetSyncMode, m_SyncUnit.get(), &SyncUnit::JSSetSyncMode); Dispatch->Action.Push(ActionKey::SetXwindowSize, m_SyncUnit.get(), &SyncUnit::JSSetXwindowSize); Dispatch->Action.Push(ActionKey::PrepareAcquisition, m_SyncUnit.get(), &SyncUnit::JSPrepareAcquisition); Dispatch->Action.Push(ActionKey::StartAcquisition, m_SyncUnit.get(), &SyncUnit::JSStartAcquisition); Dispatch->Action.Push(ActionKey::StopAcquisition, m_SyncUnit.get(), &SyncUnit::JSStopAcquisition); Dispatch->Action.Push(ActionKey::ActiveSyncMode, m_SyncUnit.get(), &SyncUnit::JSActiveSyncMode); Dispatch->Get.Push(AttrKey::FPDReadyStatus, m_SyncUnit.get(), &SyncUnit::JSGetFPDReady); Dispatch->Get.Push(AttrKey::XwindowStatus, m_SyncUnit.get(), &SyncUnit::JSGetXWindowStatus); Dispatch->Get.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSGetImageReadingStatus); Dispatch->Get.Push(AttrKey::FPDExpReady, m_SyncUnit.get(), &SyncUnit::JSGetExpReadyStatus); Dispatch->Get.Push(AttrKey::SyncMode, m_SyncUnit.get(), &SyncUnit::JSGetSyncMode); Dispatch->Get.Push(AttrKey::SupportSyncMode, m_SyncUnit.get(), &SyncUnit::JSGetSupportSyncMode); Dispatch->Set.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSSetImageReadingStatus); Dispatch->Set.Push(AttrKey::XwindowStatus, m_SyncUnit.get(), &SyncUnit::JSSetXWindowStatus); Dispatch->Set.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSSetImageReadingStatus); Dispatch->Set.Push(AttrKey::SupportSyncMode, m_SyncUnit.get(), &SyncUnit::SetSupportSyncMode); } void nsFPD::FPDDeviceTiRay::RegisterCalib(nsDetail::Dispatch* Dispatch) { Dispatch->Action.Push(ActionKey::ActiveCalibration, m_CalibUnit.get(), &CalibUnit::JSActiveCalibration); Dispatch->Action.Push(ActionKey::GetRequestedDose, m_CalibUnit.get(), &CalibUnit::JSGetRequestedDose); Dispatch->Action.Push(ActionKey::SetRequestedDose, m_CalibUnit.get(), &CalibUnit::JSSetRequestedDose); Dispatch->Action.Push(ActionKey::PrepareCalibration, m_CalibUnit.get(), &CalibUnit::JSPrepareCalibration); Dispatch->Action.Push(ActionKey::StartCalibration, m_CalibUnit.get(), &CalibUnit::JSStartCalibration); Dispatch->Action.Push(ActionKey::StopCalibration, m_CalibUnit.get(), &CalibUnit::JSStopCalibration); Dispatch->Action.Push(ActionKey::AbortCalibration, m_CalibUnit.get(), &CalibUnit::JSAbortCalibration); Dispatch->Action.Push(ActionKey::CompleteCalibration, m_CalibUnit.get(), &CalibUnit::JSCompleteCalibration); Dispatch->Action.Push(ActionKey::SetCorrectionType, m_CalibUnit.get(), &CalibUnit::JSSetCorrectionType); Dispatch->Action.Push(ActionKey::AcceptCalibration, m_CalibUnit.get(), &CalibUnit::JSAcceptCalibration); Dispatch->Action.Push(ActionKey::RejectCalibration, m_CalibUnit.get(), &CalibUnit::JSRejectCalibration); Dispatch->Action.Push(ActionKey::SaveCalibrationFile, m_CalibUnit.get(), &CalibUnit::JSSaveCalibrationFile); Dispatch->Action.Push(ActionKey::GetCalibrationStep, m_CalibUnit.get(), &CalibUnit::JSGetCalibrationStep); Dispatch->Get.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::JSGetCalibStatus); Dispatch->Get.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::JSGetCalibProgress); Dispatch->Get.Push(AttrKey::UploadCalibrationFilesResult, m_CalibUnit.get(), &CalibUnit::JSGetUploadCalibrationFilesResult); Dispatch->Get.Push(AttrKey::SupportCalibrationType, m_CalibUnit.get(), &CalibUnit::JSGetSupportCalibrationType); Dispatch->Get.Push(AttrKey::HaveImgCalibration, m_CalibUnit.get(), &CalibUnit::JSGetHaveImgCalibration); Dispatch->Get.Push(AttrKey::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::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::SetCalibrationStatus); Dispatch->Set.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::SetCalibrationProgress); Dispatch->Set.Push(AttrKey::UploadCalibrationFilesResult, m_CalibUnit.get(), &CalibUnit::SetUploadCalibrationFilesResult); Dispatch->Set.Push(AttrKey::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); } void nsFPD::FPDDeviceTiRay::RegisterOthers(nsDetail::Dispatch* Dispatch) { Dispatch->Get.Push(AttrKey::Temperature_Value, m_Temperature.get(), &DeviceTemperatureMould::JSGetCurrentTemperatureValue); Dispatch->Get.Push(AttrKey::Remain_Power_Value, m_Battery.get(), &DeviceBatteryMould::JSGetCurrentBatteryValue); Dispatch->Get.Push(AttrKey::Wifi_Strength_Value, m_Wifi.get(), &DeviceWifiMould::JSGetCurrentSignalValue); Dispatch->Get.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMax); Dispatch->Get.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMin); Dispatch->Get.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMax); Dispatch->Get.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMin); Dispatch->Get.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureCalibWarningMax); Dispatch->Get.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureCalibWarningMin); Dispatch->Get.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryWarningMin); Dispatch->Get.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryErrorMin); Dispatch->Get.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalWarningMin); Dispatch->Get.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalErrorMin); //Dispatch->Get.Push(nDetail::AttrKey::ErrorList, m_WarnAndError.get(), &FPDErrorWarning::JSGetErrorList); Dispatch->Set.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMax); Dispatch->Set.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMin); Dispatch->Set.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMax); Dispatch->Set.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMin); Dispatch->Set.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureCalibWarningMax); Dispatch->Set.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureCalibWarningMin); Dispatch->Set.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryWarningMin); Dispatch->Set.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryErrorMin); Dispatch->Set.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalWarningMin); Dispatch->Set.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalErrorMin); Dispatch->Update.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMax); Dispatch->Update.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMin); Dispatch->Update.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMax); Dispatch->Update.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMin); Dispatch->Update.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureCalibWarningMax); Dispatch->Update.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureCalibWarningMin); Dispatch->Update.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryWarningMin); Dispatch->Update.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryErrorMin); Dispatch->Update.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalWarningMin); Dispatch->Update.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalErrorMin); } void nsFPD::FPDDeviceTiRay::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::FPDDeviceTiRay::OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { FERROR("Not support this conf({$})", nEventID); } void nsFPD::FPDDeviceTiRay::OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { switch (nEventID) { case EVT_DATA_RAW_IMAGE: { FINFO("EVT_DATA_RAW_IMAGE"); m_AcqUnit->ImagerPixelSpacingNotify(m_nPixelSpacing); //某些值暂时先用假值,有需要再改 ResDataObject objImageHead, objTemp; objTemp.add(SM_IMAGE_TYPE, (int)IMAGE_FULL); objTemp.add(SM_IMAGE_BIT, m_nImgBits); objTemp.add(SM_IMAGE_TAG, 1); objTemp.add(SM_IMAGE_INDEX, 1); objTemp.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear); objTemp.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth); objTemp.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay); objTemp.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour); objTemp.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute); objTemp.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond); objTemp.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds); objTemp.add(SM_IMAGE_LSB, "5000"); objTemp.add(SM_IMAGE_DOSE, m_nSensitivity); objTemp.add(SM_IMAGE_PIXELSPACING, m_nPixelSpacing); objTemp.add(SM_IMAGE_PIXELREPRESENTATION, "1"); objTemp.add(SM_IMAGE_FLIP, "No"); objTemp.add(SM_IMAGE_ORIGINX, "0"); objTemp.add(SM_IMAGE_ORIGINY, "0"); objTemp.add(SM_IMAGE_EXI2UGY, m_fFactorEXI2UGY); objTemp.add(SM_IMAGE_WIDTH, m_nFullImageWidth); objTemp.add(SM_IMAGE_HEIGHT, m_nFullImageHeight); objTemp.add(SM_IMAGE_ROTATION, "No"); objTemp.add("ImagePath", pszMsg); objImageHead.add(SM_IMAGE_HEAD, objTemp); FINFO("Full image head: {$}", objImageHead.encode()); FINFO("Add image Size: FullImageWidth: {$}, FullImageHeight: {$}", m_nFullImageWidth, m_nFullImageHeight); m_AcqUnit->AddFrameWithRawHead(IMAGE_FULL, objImageHead.encode(), m_nFullImageWidth * m_nFullImageHeight); FINFO("Add image over"); break; } default: FERROR("Not support this data({$})", nEventID); break; } } void nsFPD::FPDDeviceTiRay::OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { switch (nEventID) { case EVT_STATUS_INIT: FINFO("EVT_STATUS_INIT nParam1:{$}", nParam1); break; case EVT_STATUS_PANEL: { ENUM_PANEL_STATUS m_ePanelStatus = (ENUM_PANEL_STATUS)nParam1; if (PANEL_CLOSE == nParam1) { FINFO("EVT_STATUS_PANEL PANEL_CLOSE"); m_bDeviceConnect = false; m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_SHUTDOWN)); m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS)); //m_WarnAndError->SendError(ERR_FPD_DISCONNECT, ""); } else if (PANEL_CONNECT == nParam1) { FINFO("EVT_STATUS_PANEL PANEL_CONNECT"); m_bDeviceConnect = true; m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_WAKEUP)); m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK)); //m_WarnAndError->ClearError(ERR_FPD_DISCONNECT); } else if (PANEL_STANDBY == nParam1) { FINFO("EVT_STATUS_PANEL PANEL_STANDBY"); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); } else if (PANEL_SLEEP == nParam1) { FINFO("EVT_STATUS_PANEL PANEL_NOT_READY"); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_WAKEUP)); } else if (PANEL_READY_EXP == nParam1) { FINFO("EVT_STATUS_PANEL PANEL_READY_EXP"); m_SyncUnit->FPDReadyNotify(true); m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_READY)); } else if (PANEL_XWINDOW_ON == nParam1) //Xwindow On { m_stImgCreateTime = { 0 }; GetLocalTime(&m_stImgCreateTime); FINFO("XWindowOn at {$}-{$}-{$} {$}:{$}:{$}:{$}", m_stImgCreateTime.wYear, m_stImgCreateTime.wMonth, m_stImgCreateTime.wDay, m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds); m_SyncUnit->XWindowOnNotify(); FINFO("m_SyncUnit XWindowOnNotify Finished!"); } else if (PANEL_XWINDOW_OFF == nParam1) // Xwindow Off { m_stImgCreateTime = { 0 }; GetLocalTime(&m_stImgCreateTime); FINFO("XWindowOff at {$:d04}-{$:d02}-{$:d02} {$:d02}:{$:d02}:{$:d02}:{$:d03}", m_stImgCreateTime.wYear, m_stImgCreateTime.wMonth, m_stImgCreateTime.wDay, m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds); m_SyncUnit->XWindowOffNotify(); } else if (PANEL_START_ACQ == nParam1) { FINFO("EVT_STATUS_PANEL PANEL_START_ACQ"); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ)); } else if (PANEL_XRAY_ON == nParam1) { FINFO("EVT_STATUS_PANEL PANEL_XRAY_ON"); m_SyncUnit->XrayOnNotify(); } else if (PANEL_XRAY_OFF == nParam1) { FINFO("EVT_STATUS_PANEL PANEL_XRAY_OFF"); m_SyncUnit->XrayOffNotify(); } break; } case EVT_STATUS_CALIBRATIOIN: { FINFO("EVT_STATUS_PANEL EVT_STATUS_CALIBRATIOIN"); ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1; switch (eStatus) { case PANEL_EVENT_START: m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ACTIVE)); break; case PANEL_EVENT_BEGIN: m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING)); break; case PANEL_EVENT_END_OK: case PANEL_EVENT_END_ERROR: m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_CalibUnit->SetCalibrationProgress(to_string(100));//make progress break; case PANEL_EVENT_TIMEOUT: break; default: break; } break; } case EVT_STATUS_SINGLEEXP: { FINFO("EVT_STATUS_PANEL EVT_STATUS_SINGLEEXP"); if (DOSE_ACCEPT == nParam1) { FINFO("Calibration Result is acceptable"); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); m_CalibUnit->PauseCalibration(); } else { FERROR("Not support this param({$})", nParam1); } break; } case EVT_STATUS_TEMPERATURE: { FINFO("EVT_STATUS_PANEL EVT_STATUS_TEMPERATURE"); float fTemperature = fParam2; SendTemperatureValue(fTemperature); break; } case EVT_STATUS_WIFI: { FINFO("EVT_STATUS_PANEL EVT_STATUS_WIFI"); int nWifiLevel = nParam1; SendWifiValue(nWifiLevel); break; } case EVT_STATUS_BATTERY_VALUE: { FINFO("EVT_STATUS_PANEL EVT_STATUS_BATTERY_VALUE"); int nBatteryValue = nParam1; SendBatteryValue(nBatteryValue); break; } default: FERROR("Not support this event({$})", nEventID); break; } } void nsFPD::FPDDeviceTiRay::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: { FINFO("EVT_DATA_RAW_IMAGE"); m_AcqUnit->ImagerPixelSpacingNotify(m_nPixelSpacing); memcpy(m_pFullImgBuffer, pParam, (size_t)m_nFullImageWidth * (size_t)m_nFullImageHeight * sizeof(unsigned short)); //某些值暂时先用假值,有需要再改 ResDataObject objImageHead, objTemp; objTemp.add(SM_IMAGE_TYPE, (int)IMAGE_FULL); objTemp.add(SM_IMAGE_BIT, m_nImgBits); objTemp.add(SM_IMAGE_TAG, 1); objTemp.add(SM_IMAGE_INDEX, 1); objTemp.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear); objTemp.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth); objTemp.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay); objTemp.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour); objTemp.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute); objTemp.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond); objTemp.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds); objTemp.add(SM_IMAGE_LSB, "5000"); objTemp.add(SM_IMAGE_DOSE, m_nSensitivity); objTemp.add(SM_IMAGE_PIXELSPACING, m_nPixelSpacing); objTemp.add(SM_IMAGE_PIXELREPRESENTATION, "1"); objTemp.add(SM_IMAGE_FLIP, "No"); objTemp.add(SM_IMAGE_ORIGINX, "0"); objTemp.add(SM_IMAGE_ORIGINY, "0"); objTemp.add(SM_IMAGE_EXI2UGY, m_fFactorEXI2UGY); objTemp.add(SM_IMAGE_WIDTH, m_nFullImageWidth); objTemp.add(SM_IMAGE_HEIGHT, m_nFullImageHeight); objTemp.add(SM_IMAGE_ROTATION, "No"); objImageHead.add(SM_IMAGE_HEAD, objTemp); FINFO("Full image head: {$}", objImageHead.encode()); FINFO("Add image Size: FullImageWidth: {$}, FullImageHeight: {$}", m_nFullImageWidth, m_nFullImageHeight); m_AcqUnit->AddFrameWithRawHead(IMAGE_FULL, objImageHead.encode(), m_pFullImgBuffer, m_nFullImageWidth * m_nFullImageHeight); FINFO("Add image over"); break; } case EVT_DATA_DOSEPARAM: { m_fDoseParam = fParam2; m_WaitCalibDoseEvt->SetEvent(); break; } default: FERROR("Not support this data({$})", nEventID); break; } } void nsFPD::FPDDeviceTiRay::OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { switch (nEventID) { case EVT_ERR_COMMUNICATE: break; case EVT_ERR_INIT_FAILED: break; default: FERROR("Not support this FERROR({$})", nEventID); break; } } void nsFPD::FPDDeviceTiRay::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { FERROR("Not support this warn({$})", nEventID); } RET_STATUS nsFPD::FPDDeviceTiRay::ActiveSyncMode(int nSyncMode) { FINFO("--Func-- ActiveSyncMode nSyncMode:{$}", nSyncMode); m_eSyncMode = (SYNC_MODE)nSyncMode; if (g_pDetector->SetSyncMode(nSyncMode)) { return RET_SUCCEED; } else { FERROR("ActiveSyncMode fail!"); return RET_FAILED; } } RET_STATUS nsFPD::FPDDeviceTiRay::UpdateCalibMode(CCOS_CALIBRATION_MODE eCalibMode) { FINFO("--Func-- UpdateCalibMode eCalibMode:{$}", (int)eCalibMode); m_stDeviceConfig.nCalibMode = (int)eCalibMode; if (g_pDetector->UpdateCalibMode(eCalibMode)) { FINFO("UpdateCalibMode success!"); return RET_SUCCEED; } else { FERROR("UpdateCalibMode fail!"); return RET_FAILED; } } RET_STATUS nsFPD::FPDDeviceTiRay::UpdateLastCalibrationDate(std::string in) { FINFO("--Func-- UpdateLastCalibrationDate in:{$}", in); m_stDeviceConfig.strLastCalibrationDate = in; return RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceTiRay::UpdateCalibrationFileExpireTime(std::string in) { FINFO("--Func-- UpdateCalibrationFileExpireTime in:{$}", in); m_stDeviceConfig.strCalibrationFileExpireTime = in; return RET_SUCCEED; }