#include "stdafx.h" #include "FileVersion.hpp" #include "CCOS.Dev.FPD.AxsDM.h" #include "common_api.h" #include "DICOMImageHeadKey.h" #include "AxsCtrl.h" #include namespace nsFPD = CCOS::Dev::Detail::Detector; //----------------------------------------------------------------------------- // CFPDDeviceAXS //----------------------------------------------------------------------------- extern CAXSCtrl* g_pDetector; //----------------------------------------------------------------------------- // GetIODriver & CreateIODriver //----------------------------------------------------------------------------- static nsFPD::CAXSDriver gIODriver; Log4CPP::Logger* gLogger = nullptr; extern const char* g_szMouldPath; /// /// [DONE.CHECKED.] /// /// extern "C" CCOS::Dev::IODriver * __cdecl GetIODriver() // 返回静态对象的引用, 调用者不能删除 ! { return &gIODriver; } /// /// [DONE.TO BE TESTED.] /// /// extern "C" CCOS::Dev::IODriver * __cdecl CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 ! { return new nsFPD::CAXSDriver(); } /// /// 驱动构造函数 /// [DONE.CHECKED.] /// nsFPD::CAXSDriver::CAXSDriver() { m_pObjDev = nullptr; m_bConnect = false; //缺省为false m_pAttribute.reset(new ResDataObject()); m_pDescription.reset(new ResDataObject()); } /// /// [DONE.TO BE TESTED.] /// nsFPD::CAXSDriver::~CAXSDriver() { if (m_pObjDev != nullptr) { delete m_pObjDev; m_pObjDev = nullptr; } Close(); Log4CPP::ThreadContext::Map::Clear(); gLogger = nullptr; } /// /// 驱动的准备,可以做一些特殊的操作 /// new完Driver后最先执行的函数 /// void nsFPD::CAXSDriver::Prepare() { printf("--Driver-- prepare \r\n"); string strLogPath = GetProcessDirectory() + R"(\Conf\Log4CPP.Config.xml)"; auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str()); gLogger = Log4CPP::LogManager::GetLogger("Module"); FINFO("Code Build datetime [{$} {$}]", __DATE__, __TIME__); #ifdef _WIN64 FINFO("=============================Version: {$} (64-bit)==================================", FileVersion(g_szMouldPath).GetVersionString()); #else FINFO("=============================Version: {$} (32-bit)==================================", FileVersion(g_szMouldPath).GetVersionString()); #endif FINFO("Driver Prepare get logger"); } /// /// 获取配置文件的配置信息并返回给web端显示,配置文件可配置读写权限和是否显示(重要) /// /// string std::string nsFPD::CAXSDriver::GetResource() { printf("AXS driver: GetResource m_ConfigFileName:%s\r\n", m_ConfigFileName.c_str()); FINFO("AXS driver: GetResource m_ConfigFileName:{$}", m_ConfigFileName.c_str()); 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; //用于读取整型配置信息 string strValue = ""; //用于存储配置的值 string strType = ""; //用于存储配置的类型 int/float/string... string strAccess = ""; //用于存储权限的类型 R/W/RW string strRequired = ""; // TRUE/FALSE string strDefaultValue = ""; string strRangeMin = ""; string strRangeMax = ""; 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 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(); //FINFO("GetResource res:{$}", res.c_str()); printf("AXS driver module: get resource over \r\n"); FINFO("AXS driver module: get resource over \r\n"); return res; } /// /// 驱动的连接,创建设备对象 new CFPDDeviceAXS /// /// bool nsFPD::CAXSDriver::Connect() { printf("AXS driver module: Connect \r\n"); FINFO("--Func-- driver connect\n"); //从IODriver继承的EventCenter和m_ConfigFileName m_pObjDev = new CFPDDeviceAXS(EventCenter, m_ConfigFileName); m_bConnect = true; //connect执行完毕,置为true printf("AXS driver module: Connect over new CFPDDeviceAXS\r\n"); FINFO("AXS driver module: Connect over new CFPDDeviceAXS"); return true; } /// /// 驱动创建设备丢下,然后 给 上层返回 IODevice 对象指针 /// [DONE.CHECKED.] /// /// /// auto nsFPD::CAXSDriver::CreateDevice(int index)->std::unique_ptr { printf("AXS driver module: CreateDevice \r\n"); FINFO("--Func-- driver createdevice \n"); auto Device = std::unique_ptr(new IODevice(m_pObjDev)); m_pObjDev->CreateDevice(); m_pObjDev->Register(); return Device; } /// /// 驱动断开连接,释放设备对象 /// void nsFPD::CAXSDriver::Disconnect() { printf("AXS driver module: Disconnect \r\n"); FINFO("--Func-- driver disconnect \n"); if (m_pObjDev != nullptr) { delete m_pObjDev; m_pObjDev = nullptr; } m_bConnect = false; //disconnect置为false } bool nsFPD::CAXSDriver::isConnected() const { printf("AXS driver module: isConnected \r\n"); return m_bConnect; } /// /// 驱动信息检索 TODO : 需要重新定义 /// /// std::string nsFPD::CAXSDriver::DriverProbe() { printf("AXS driver module: Driver Probe \r\n"); ResDataObject r_config, HardwareInfo; if (r_config.loadFile(m_ConfigFileName.c_str())) { HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]); HardwareInfo.add("MinorID", r_config["CONFIGURATION"]["MinorID"]); HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]); HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]); HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]); } else { HardwareInfo.add("MajorID", "Detector"); HardwareInfo.add("MinorID", "DM"); HardwareInfo.add("VendorID", "AXS"); HardwareInfo.add("ProductID", "AXS"); HardwareInfo.add("SerialID", "Driver"); } string str = HardwareInfo.encode(); return str; } /// /// 设备信息检索 TODO : 需要重新定义,TBD. /// /// std::string nsFPD::CAXSDriver::DeviceProbe() { printf("AXS driver module: Device Probe \r\n"); ResDataObject r_config, HardwareInfo; if (r_config.loadFile(m_ConfigFileName.c_str())) { HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]); HardwareInfo.add("MinorID", "Device"); HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]); HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]); HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]); } else { HardwareInfo.add("MajorID", "Detector"); HardwareInfo.add("MinorID", "Device"); HardwareInfo.add("VendorID", "AXS"); HardwareInfo.add("ProductID", "AXS"); HardwareInfo.add("SerialID", "1234"); } string str = HardwareInfo.encode(); return str; } /// /// 设备配置读取接口 /// [DONE.CHECKED.] /// /// /// bool nsFPD::CAXSDriver::GetDeviceConfig(std::string& Cfg) { Cfg = m_DeviceConfig.encode(); FINFO("GetDeviceConfig Cfg:{$}",Cfg.c_str()); return true; } /// /// 提供给web配置中心的 配置写入接口 /// [DONE.CHECKED.] /// /// /// bool nsFPD::CAXSDriver::SetDeviceConfig(std::string Cfg) { FINFO("SetDeviceConfig Cfg:{$}", 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("SetDriverConfig crashed: {$}", e.what()); return false; } } } if (bSaveFile) { //4. 重新保存配置文件 SaveConfigFile(true); } return true; } /// /// 保存配置到文件 /// [DONE.TO BE TESTED.] /// /// /// bool nsFPD::CAXSDriver::SaveConfigFile(bool bSendNotify) { m_ConfigAll["CONFIGURATION"] = m_Configurations; m_ConfigAll.SaveFile(m_ConfigFileName.c_str()); FINFO("SaveConfigFile m_ConfigAll:{$}", m_ConfigAll.encode()); return true; } /// /// 读取当前配置项 /// TBD. 审视参数列表 /// /// /// /// /// /// bool nsFPD::CAXSDriver::GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue) { strValue = ""; string strTemp = pInnerKey; if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取 { if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp) { strValue = (string)config["connections"][pInnerKey]; } else if (DetectorVender == strTemp || DetectorModel == strTemp || DetectorDescription == strTemp || DetectorSerialNumber == strTemp) { strValue = (string)config[pInnerKey]; } else if (SyncType == strTemp || FPDWorkStation == strTemp || RawImgWidth == strTemp || RawImgHeight == 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 || "CalibMode" == strTemp || ShowBattery == strTemp || ShowBluetooth == strTemp || OnlyHaveFpd == strTemp || FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp || CcosDetectorAttachedFlag == strTemp) { strValue = (string)config[pInnerKey]; } else { strValue = ""; FERROR("Error Configuration item: {$}", pInnerKey); } } printf("GetDeviceConfigValue pInnerKey:%s,strValue:%s\n", pInnerKey, strValue.c_str()); //FINFO("GetDeviceConfigValue pInnerKey:{$},strValue:{$}", pInnerKey, strValue.c_str()); return true; } /// /// 设置写入设备参数实现,这里过滤需要设置本探测器接受的参数 /// 参数项和内容来源于 探测器配置文件 /// TBD. 具体内容 /// comment by chenggw 2023.2.7 /// /// /// /// /// /// bool nsFPD::CAXSDriver::SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey, int nPathID, const char* szValue) { string strTemp = pInnerKey; printf("SetDeviceConfigValue pInnerKey:%s,szValue:%s", pInnerKey, szValue); FINFO("SetDeviceConfigValue pInnerKey:{$},szValue:{$}", 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 || RawImgWidth == strTemp || RawImgHeight == 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 || "CalibMode" == strTemp || ShowBattery == strTemp || ShowBluetooth == strTemp || OnlyHaveFpd == strTemp || FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp || CcosDetectorAttachedFlag == strTemp) { config[pInnerKey] = szValue; } else { FERROR("Error Configuration item: {$}", pInnerKey); return false; } } return true; } //CAXSDriver的Connect函数new CFPDDeviceAXS()时传入EventCenter 和 strConfigPath nsFPD::CFPDDeviceAXS::CFPDDeviceAXS(std::shared_ptr center, std::string strConfigPath) : m_nCalibTotalExposureNum(0), m_nCalibCurrentCalibrationRound(0), m_nCalibCurrentExposureIndex(0), m_nCalibCurrentExposureNum(0), m_bImagePendingOrNot(false), m_bResetDetector(false) { m_pDetectors = nullptr; m_strWorkPath = GetProcessDirectory(); m_bPreviewEnable = false; m_nImgBits = 16; m_nPreViewImgWidth = 0; m_nPreViewImgHeight = 0; m_nImgWidth = 0; m_nImgHeight = 0; m_pPreviewImageHead = nullptr; m_pImageHead = nullptr; m_pwPreviewImg = nullptr; m_pwRawImageData = nullptr; m_pwImageData = nullptr; m_nAngle = 0; m_nPixelSpacing = 0; m_fDose = 0.0f; m_fDoseParam = 0.0f; m_eAppStatus = APP_STATUS_IDLE; m_bConnect = false; m_eSyncMode = SYNC_AED; m_eCalibMode = CCOS_CALIBRATION_MODE_ZSKK; m_fFactorEXI2UGY = 0.0f; m_bForceGridSuppress = false; m_bAttached = false; m_nBatteryCapacity = 0; m_nBatteryCharges = 0; m_fBatteryTemperature = 0.0f; m_nShockCounts = 0; m_bOnlyHaveFpd = false; m_bFirstGetCalibImageLeft = true; m_nAcqMode = -1; m_DetectorCtrlUnit.reset(new CAxsCtrlUnit(center, this)); m_AcqUnit.reset(new CAxsAcq(center, this)); m_SyncUnit.reset(new CAxsSync(center, this)); m_CalibUnit.reset(new CAxsCalib(center, this)); m_DetectorConfiguration.reset(new DetectorConfiguration(strConfigPath)); //探测器告警及错误消息 m_WarnAndError.reset(new FPDErrorWarning(center, DetectorUnitType, m_strWorkPath)); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_INIT)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_MAX)); EventCenter = center; } nsFPD::CFPDDeviceAXS::~CFPDDeviceAXS() { if (m_pPreviewImageHead) { delete m_pPreviewImageHead; m_pPreviewImageHead = nullptr; } if (m_pImageHead) { delete m_pImageHead; m_pImageHead = nullptr; } if (m_pwPreviewImg) { delete m_pwPreviewImg; m_pwPreviewImg = nullptr; } if (m_pwRawImageData) { delete m_pwRawImageData; m_pwRawImageData = nullptr; } if (m_pwImageData) { delete m_pwImageData; m_pwImageData = nullptr; } } std::string nsFPD::CFPDDeviceAXS::GetGUID() const { printf("AXS device module: GetGUID \r\n"); return DetectorUnitType; } //在Driver Create Device时调用,读取配置信息,下发配置信息到ctrl bool nsFPD::CFPDDeviceAXS::CreateDevice() { printf("--Func-- CreateDevice \r\n"); FINFO("================ CreateDevice"); if (!LoadConfig()) { return false; } if (nullptr == g_pDetector) { if (nullptr == m_pDetectors) { m_pDetectors = new CAXSCtrl(); FINFO("Create SDK ctrl ok\n"); g_pDetector = (CAXSCtrl*)m_pDetectors; } } else { m_pDetectors = g_pDetector; FERROR("SDK ctrl Already exit\n"); } g_pDetector->DriverEntry(this, m_DetectorConfiguration->m_Configurations); return true; } //在Driver Create Device时调用 void nsFPD::CFPDDeviceAXS::Register() { FINFO("--Func-- device register"); auto Disp = &Dispatch; RegisterCtrl(Disp); RegisterAcq(Disp); RegisterSync(Disp); RegisterCalib(Disp); RegisterOthers(Disp); //RegisterAutonumous(Disp); } //在Register之后调用 bool nsFPD::CFPDDeviceAXS::Prepare() { printf("AXS device module: Prepare \r\n"); FINFO("--Func-- device prepare \n"); EventCenter->OnMaxBlockSize("AxsDmQue",m_stDeviceConfig.nMaxImgWidth * m_stDeviceConfig.nMaxImgHeight * 2, 3, 1500 * 1500 * 2, 1); Connect(); return true; } //在device prepare时调用 RET_STATUS nsFPD::CFPDDeviceAXS::Connect() { printf("==========Fun Connect ========== \r\n"); FINFO("==========Fun Connect =========="); RET_STATUS ret = RET_STATUS::RET_FAILED; if (g_pDetector->Connect(this, m_strWorkPath.c_str())) { m_bConnect = true; ret = RET_STATUS::RET_SUCCEED; FINFO("FPD is connected!"); } return ret; } RET_STATUS nsFPD::CFPDDeviceAXS::EnterExam(int nExamMode) { FINFO("==========Fun EnterExam =========="); FINFO("EnterExam nExamMode:{$}", nExamMode); switch (nExamMode) { case APP_STATUS_WORK_BEGIN: FINFO("Enter into Exam Windows"); m_eAppStatus = APP_STATUS_WORK_BEGIN; 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: m_eAppStatus = APP_STATUS_IDLE; 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); return RET_STATUS::RET_SUCCEED; } /*** * 这是切换探测器的接口 ***/ RET_STATUS nsFPD::CFPDDeviceAXS::ActiveDetector(int nDetectorIndex, bool bActive) { FINFO("==========Fun ActiveDetector =========="); printf("ActiveDetector (%d) to (%d) \r\n", nDetectorIndex, bActive); FINFO("ActiveDetector {$} to {$}\n", nDetectorIndex, bActive); RET_STATUS ret = RET_STATUS::RET_SUCCEED; if (g_pDetector == nullptr) { printf("AXSCtrl object is not exist, return RET_FAILED\n"); FERROR("AXSCtrl object is not exist, return RET_FAILED"); return RET_STATUS::RET_FAILED; } return ret; } bool nsFPD::CFPDDeviceAXS::GetLogicMode(string& strAcqMode, int& nLogicMode) { if (strAcqMode == "RAD") { nLogicMode = RAD; } else if (strAcqMode == "AEC") { nLogicMode = AEC; } else if (strAcqMode == "1") { nLogicMode = RAD; } else if (strAcqMode == "2") { nLogicMode = AEC; } else { FERROR("Not support mode!"); return false; } return true; } //设置采集模式 1-RAD 2-RAD-preview 3-动态 RET_STATUS nsFPD::CFPDDeviceAXS::SetAcqMode(string strAcqMode) { FINFO("==========Fun SetAcqMode =========="); printf("SetAcqMode %s \n", strAcqMode.c_str()); FINFO("SetAcqMode start, nMode:{$}", strAcqMode); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { FERROR("Detector not connected, return"); return ret; } int nMode = RAD; bool bRet = GetLogicMode(strAcqMode,nMode); if (!bRet) { return ret; } if (m_nAcqMode == nMode) { FINFO("Same acq mode! return"); ret = RET_STATUS::RET_SUCCEED; return ret; } else { m_nAcqMode = nMode; } bool m_config_have = false; //如果没连接,不执行 try { ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations; int nModeCount = (int)objModeConfig["ModeTable"].GetKeyCount("DetectorMode"); for (int i = 0; i < nModeCount; i++) { int nLogicMode = (int)objModeConfig["ModeTable"][i]["LogicMode"]; if (nLogicMode == nMode) { printf("find LogicMode == AcqMode\n"); FINFO("find LogicMode == AcqMode"); m_config_have = true; m_bPreviewEnable = (int)objModeConfig["ModeTable"][i]["HavePreview"]; m_nImgWidth = (int)objModeConfig["ModeTable"][i]["ImageWidth"]; m_nImgHeight = (int)objModeConfig["ModeTable"][i]["ImageHeight"]; m_nImgBits = (int)objModeConfig["ModeTable"][i]["PhySizeInfoBit"]; //m_nAngle = (int)objModeConfig["ModeTable"][i]["RotateAngle"]; m_nPixelSpacing = (int)objModeConfig["ModeTable"][i]["PixelPitch"]; m_eSyncMode = (SYNC_MODE)(int)objModeConfig["ModeTable"][i]["SyncType"]; string strDose = (string)objModeConfig["ModeTable"][i]["CalibConfig"]["NodeInfo"]["Dose"]; //先写死成一个校正点 m_fDose = stof(strDose); /*if (m_nAngle == 90 || m_nAngle == 270) { m_AcqUnit->SetFulImageInfo(m_nImgWidth, m_nImgHeight, m_nImgBits, false); }*/ if (m_bPreviewEnable) { m_nPreViewImgWidth = (int)objModeConfig["ModeTable"][i]["PreviewImageWidth"]; m_nPreViewImgHeight = (int)objModeConfig["ModeTable"][i]["PreviewImageHeight"]; m_AcqUnit->SetPrevImageInfo(true, m_nPreViewImgHeight, m_nPreViewImgWidth, false); } else { m_AcqUnit->SetPrevImageInfo(false, 0, 0, false); } m_AcqUnit->SetFulImageInfo(m_nImgHeight, m_nImgWidth, m_nImgBits, false); if (((CAXSCtrl*)m_pDetectors)->SetAcqMode(nLogicMode, this)) { ret = RET_STATUS::RET_SUCCEED; } FINFO("config file LogicMode:{$} SyncType:{$}", nLogicMode, (int)m_eSyncMode); //读取DetectorMode配置,并为imagebuffer申请内存空间 if (((CAXSCtrl*)m_pDetectors)->SelectExamMode(nLogicMode, this)) { ret = RET_STATUS::RET_SUCCEED; } printf("m_eSyncMode (%d) \r\n", m_eSyncMode); FINFO("m_eSyncMode ({$})", (int)m_eSyncMode); g_pDetector->SetSynMode(m_eSyncMode); break; } } if (!m_config_have) { FERROR("Illegal mode!"); ret = RET_STATUS::RET_FAILED; } } catch (ResDataObjectExption& e) { FERROR("Read configuration failed, Error code: {$}", e.what()); } FINFO("SetAcqMode end"); return ret; } RET_STATUS nsFPD::CFPDDeviceAXS::PrepareAcquisition() { printf("--Func-- PrepareAcquisition \n"); FINFO("==========Fun PrepareAcquisition =========="); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { FERROR("Detector not connected, return"); return ret; } if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) || (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE)) { printf("PrepareAcquisition failed. Detector at Calibration status.\n"); FERROR("PrepareAcquisition failed. Detector at Calibration status"); return ret; } //如果已经调用StartAcquisition 那么直接返回成功 if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus()) { printf("Detector already at Acq status.\n"); FERROR("Detector already at Acq status"); ret = RET_STATUS::RET_SUCCEED; } m_SyncUnit->FPDReadyNotify(false); //prepare前置为初值 if (g_pDetector->PrepareAcquisition(this)) { ret = RET_STATUS::RET_SUCCEED; //因为PrepareAcquisition会等待探测器回调ready消息,回调后在通知app Ready状态 FINFO("set detector status standby"); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); } else { FERROR("fail to prepare acquisition!"); } FINFO("==============================PrepareAcquisition over"); return ret; } RET_STATUS nsFPD::CFPDDeviceAXS::StartAcquisition(string in) { printf("--Func-- StartAcquisition \n"); FINFO("==========Fun StartAcquisition =========="); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { FERROR("Detector not connected, return"); return ret; } if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus()) { FINFO("StartAcquisition detector status is not standby!"); if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) || (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE)) { printf("StartAcquisition failed. Detector at Calibration status.\n"); FERROR("StartAcquisition failed. Detector at Calibration status."); } if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus()) { printf("Detector already at Acq status.\n"); 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 { printf("StartAcquisition fail!\n"); FINFO("StartAcquisition fail!"); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); } } FINFO("==============================StartAcquisition over"); return ret; } //LMAM3-IZ85c一般情况下不会调用stop RET_STATUS nsFPD::CFPDDeviceAXS::StopAcquisition() { printf("--Func-- StopAcquisition \n"); FINFO("==========Fun StopAcquisition =========="); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { FERROR("Detector not connected, return"); return ret; } if (DETECTOR_STATUS_STANDBY == m_DetectorCtrlUnit->GetDetectorStatus()) { printf("Detector status already is standby\n"); FINFO("Detector status already is standby"); 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("==============================StopAcquisition over"); return ret; } RET_STATUS nsFPD::CFPDDeviceAXS::ActiveCalibration(CCOS_CALIBRATION_TYPE eType) { printf("--Func-- ActiveCalibration %d \n", eType); FINFO("==========Fun ActiveCalibration =========="); FINFO("ActiveCalibration type {$}", (int)eType); RET_STATUS ret = RET_SUCCEED; if (!m_bConnect) { printf("Detector not connected, return\n"); FERROR("Detector not connected, return"); ret = RET_STATUS::RET_FAILED; return ret; } if (eType == CCOS_CALIBRATION_TYPE_NONE || eType == CCOS_CALIBRATION_TYPE_MAX) { ret = RET_STATUS::RET_INVALID; return ret; } try { ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations; m_eCalibMode = (CCOS_CALIBRATION_MODE)(int)objModeConfig["CalibMode"]; //告诉Ctrl 校正模式是ZSKK还是OTHER printf("m_eCalibMode (%d) \r\n", m_eCalibMode); FINFO("m_eCalibMode ({$})", (int)m_eCalibMode); g_pDetector->SetCalibMode(m_eCalibMode); } catch (ResDataObjectExption& e) { FERROR("Read configuration failed, Error code: {$}", e.what()); } m_eAppStatus = APP_STATUS_CAL_BEGIN; //设置ZSKK GAIN 校正的校正轮次,OTHER GAIN 校正需要曝光的次数在GetCalibrationStep中获取 if (m_eCalibMode == CCOS_CALIBRATION_MODE_ZSKK && eType == CCOS_CALIBRATION_TYPE_XRAY) { printf("ZSKK calibration, type: XRAY\n"); FINFO("ZSKK calibration, type: XRAY"); int nCalibrationRounds = (int)m_CalibDoseList.size(); g_pDetector->SetReferenceNum(nCalibrationRounds); //重置亮场校正流程参数 m_nCalibCurrentCalibrationRound = 1; m_nCalibCurrentExposureIndex = 1; m_nCalibCurrentExposureNum = 0; } else if (m_eCalibMode == CCOS_CALIBRATION_MODE_OEM && eType == CCOS_CALIBRATION_TYPE_XRAY) { //开始激活校正的时候肯定是需要获取剩余需要曝光的图像张数的 m_bFirstGetCalibImageLeft = true; } if (g_pDetector->ActiveCalibration(this, eType)) { m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ACTIVE)); m_CalibUnit->SetCalibrationProgress("0"); } else { printf("Active calibration failed!\n"); FERROR("Active calibration failed!"); ret = RET_STATUS::RET_FAILED; } printf("ActiveCalibration over\n"); FINFO("==============================ActiveCalibration over"); return ret; } RET_STATUS nsFPD::CFPDDeviceAXS::PrepareCalibration() { printf("--Func-- PrepareCalibration------ \n"); FINFO("==========Fun PrepareCalibration =========="); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { printf("Detector not connected, return\n"); FERROR("Detector not connected, return"); return ret; } m_SyncUnit->FPDReadyNotify(false); //prepare前置为初值 if (g_pDetector->PrepareCalibration(this)) { //此处不通知ready,等到探测器回调Ready事件后再通知 ret = RET_STATUS::RET_SUCCEED; } else { printf("Prepare calibration failed\n"); FERROR("Prepare calibration failed"); } m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); printf("PrepareCalibration over\n"); FINFO("==============================PrepareCalibration over"); return ret; } RET_STATUS nsFPD::CFPDDeviceAXS::GetRequestedDose(std::string& strDose) { FINFO("==========Fun GetRequestedDose =========="); printf("--Func-- GetRequestedDose------ \n"); if (!m_stDeviceConfig.bConnectStatus) { return RET_STATUS::RET_THREAD_INVALID; } RET_STATUS Ret = RET_STATUS::RET_SUCCEED; bool bGetDoseInfo = false; ResDataObject out; CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType(); FINFO("GetRequestedDose calib type is {$}",(int)nCalibrationType); printf("GetRequestedDose calib type is %d\n",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); bGetDoseInfo = true; } else if (CCOS_CALIBRATION_TYPE_XRAY == nCalibrationType) { FINFO("calib dose list size is {$}",m_CalibDoseList.size()); printf("calib dose list size is %d\n",(int)m_CalibDoseList.size()); for (int i = 0; i < m_CalibDoseList.size(); i++) { ResDataObject temp = m_CalibDoseList[i]; int nDose = temp["Dose"]; int nDoseParem = (int)(m_fDoseParam * 1000); if (nDoseParem == nDose) { out.add("Dose", nDoseParem); out.add("kV", temp["kV"]); out.add("mA", temp["mA"]); out.add("ms", temp["ms"]); out.add("mAs", temp["mAs"]); bGetDoseInfo = true; FINFO("Find target dose parameter"); break; } } } else { FERROR("Can not support CalibrationType({$})", (int)nCalibrationType); Ret = RET_STATUS::RET_FAILED; } if (bGetDoseInfo) { strDose = out.encode(); FINFO("GetRequestedDose:{$}", strDose.c_str()); } else { FERROR("GetRequestedDose failed"); } FINFO("==============================GetRequestedDose over"); return Ret; } RET_STATUS nsFPD::CFPDDeviceAXS::StartCalibration() { printf("--Func-- StartCalibration------ \n"); FINFO("==========Fun StartCalibration =========="); RET_STATUS Ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { FERROR("detector is not connected"); return Ret; } if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus()) { if (DETECTOR_STATUS_CALIB == m_DetectorCtrlUnit->GetDetectorStatus()) { FERROR("StartCalibration Detector already at calibration status"); Ret = RET_STATUS::RET_SUCCEED; return Ret; } } if (((CAXSCtrl*)m_pDetectors)->StartCalibration(this)) { printf("start calibration success set detector status\n"); FINFO("start calibration success set detector status"); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_CALIB)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING)); Ret = RET_STATUS::RET_SUCCEED; } else { Ret = RET_STATUS::RET_FAILED; } printf("StartCalibration over\n"); FINFO("==============================StartCalibration over"); return Ret; } RET_STATUS nsFPD::CFPDDeviceAXS::StopCalibration() { FINFO("==========Fun StopCalibration =========="); printf("--Func-- StopCalibration------ \n"); RET_STATUS Ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { FERROR("Detector not connected, return"); return Ret; } m_eAppStatus = APP_STATUS_CAL_END; if (((CAXSCtrl*)m_pDetectors)->StopCalibration(this)) { m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); Ret = RET_STATUS::RET_SUCCEED; } else { Ret = RET_STATUS::RET_FAILED; } m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); FINFO("==============================StopCalibration over"); return Ret; } //create device 时调用 bool nsFPD::CFPDDeviceAXS::LoadConfig() { printf("--Func-- LoadConfig \r\n"); FINFO("================ LoadConfig\n"); if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_ACQMODElist)) { FERROR("Load configuration file failed!!!"); return false; } //获取校正模式 0-ZSKK 1-OTHER m_eCalibMode = (CCOS_CALIBRATION_MODE)m_stDeviceConfig.nCalibMode; //新增一个配置项代表当前系统中是否只有一个真是的平板探测器,其他设备没有或者是demo的 size_t keyCount = m_DetectorConfiguration->m_Configurations.GetKeyCount("OnlyHaveFpd"); FINFO("LoadConfig OnlyHaveFpd keyCount:{$}", keyCount); if (keyCount) { m_bOnlyHaveFpd = (bool)m_DetectorConfiguration->m_Configurations["OnlyHaveFpd"]; if (m_bOnlyHaveFpd) FINFO("current system only have FPD!"); } if (m_stDeviceConfig.nForceGridSuppress > 0) { m_bForceGridSuppress = true; } else { m_bForceGridSuppress = false; } int nAttached = (int)m_DetectorConfiguration->m_Configurations[CcosDetectorAttachedFlag]; if (nAttached == 1) { m_bAttached = true; m_DetectorCtrlUnit->SetAttachStatus("1"); } else { m_bAttached = false; m_stDeviceConfig.bConnectStatus = false; } m_DetectorCtrlUnit->SetDetectorType("LMAM3-IZ85c"); string strFPDinfo; strFPDinfo = (string)m_DetectorConfiguration->m_Configurations["Description"]; m_DetectorCtrlUnit->SetDescription(strFPDinfo); m_DetectorCtrlUnit->SetDetectorConditionsNominalFlag("YES"); auto strFinfo = std::to_string(m_stDeviceConfig.nDoseOfEXI); m_DetectorCtrlUnit->SetFPDSensitivity(strFinfo); //子系统将UI的TargetEXI 乘以 FPDSensitivity再传给imagesave,用作计算EXI和DI并填写ecm头。还原原始值,不再用100去除。 m_fFactorEXI2UGY = 100.0f / (float)atof(strFinfo.c_str()) * 1.0f; FINFO("m_fFactorEXI2UGY = {$}", m_fFactorEXI2UGY); m_DetectorCtrlUnit->SetPixelData(""); m_DetectorCtrlUnit->SetTargetEXI("5000"); m_Battery.reset(new DeviceBatteryMould("GetRemainPowerValue", 0, m_stDeviceConfig.nBatteryLimit, m_stDeviceConfig.nBatteryWarning, 100, 0, 100, 100, 0, EventCenter)); m_Temperature.reset(new DeviceTemperatureMould("GetTemperatureValue", 0.0f, m_stDeviceConfig.fTemperatureMin, m_stDeviceConfig.fTemperLowLimit, m_stDeviceConfig.fTemperatureMax, m_stDeviceConfig.fTemperMaxLimit, 0.0f, 0.0f, 0.0f, EventCenter)); m_Wifi.reset(new DeviceWifiMould("GetWifiStrengthValue", 0, m_stDeviceConfig.nWifiLimit, m_stDeviceConfig.nWifiWarning, 100, 0, 100, 100, 0, EventCenter)); ResDataObject CalibDoseList; string strCalibDose = m_strWorkPath + R"(\OEMDrivers\Detector\AXSDetector\CalibrationDose_AXS.xml)"; FINFO("start load calib dose file: {$}", strCalibDose.c_str()); struct stat buffer; if (stat(strCalibDose.c_str(), &buffer) == 0) { try { CalibDoseList.loadFile(strCalibDose.c_str()); m_CalibDoseList = CalibDoseList["List"]; FINFO("m_CalibDoseList: {$} ", m_CalibDoseList.encode()); for (int i = 0; i < m_CalibDoseList.size(); i++) { ResDataObject temp = m_CalibDoseList[i]; int nExpNum = temp["ExpNum"]; m_nCalibTotalExposureNum += nExpNum; //FINFO("temp: {$} ", temp.encode()); } FINFO("CalibTotalExposureNum: {$}", m_nCalibTotalExposureNum); } catch (exception e) { FERROR("Get calibDose error: {$}", e.what()); } } else { FERROR("{$} file not exist!"); } return true; } void nsFPD::CFPDDeviceAXS::RegisterCtrl(nsDetail::Dispatch* Dispatch) { Dispatch->Action.Push(ActionKey::ActiveDetector, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSActiveDetector); Dispatch->Action.Push(ActionKey::AttachConnect, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSAttachConnect); Dispatch->Action.Push(ActionKey::CancelAttach, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSCancelAttach); Dispatch->Action.Push(ActionKey::ResetConnect, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSResetConnect); Dispatch->Action.Push(ActionKey::DisConnectFPD, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSDisConnectFPD); Dispatch->Action.Push(ActionKey::UpdateFirmware, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSUpdateFirmware); Dispatch->Action.Push(ActionKey::GetFPDinformation, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorInfo); Dispatch->Action.Push(ActionKey::EnterExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSEnterExam); Dispatch->Action.Push(ActionKey::ExitExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSExitExam); Dispatch->Action.Push(ActionKey::RecoverImage, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRecoverImage); Dispatch->Action.Push("GetRecoverImageState", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageState); Dispatch->Action.Push(ActionKey::SaveSensitivity, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSaveSensitivity); Dispatch->Action.Push(ActionKey::RESET, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRESET); Dispatch->Action.Push(ActionKey::SetExposureTimes, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetExposureTimes); Dispatch->Get.Push(AttrKey::DetectorConnectStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetConnectStatus); Dispatch->Get.Push(AttrKey::DetectorInitialStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetInitialStatus); Dispatch->Get.Push(AttrKey::DetectorUpdateFWStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetUpdateFWStatus); Dispatch->Get.Push(AttrKey::DetectorAttach, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachResult);//event Dispatch->Get.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDStatus); Dispatch->Get.Push(AttrKey::FPDAttached, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachStatus); Dispatch->Get.Push(AttrKey::FPDShockSensorInfo, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetShockSensorInfo); Dispatch->Get.Push("RecoverImageState", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageState);//event Dispatch->Get.Push("RecoverImageEvent", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetRecoverImageEvent);//event Dispatch->Get.Push(AttrKey::FieldofViewShape, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFieldofViewShape); Dispatch->Get.Push(AttrKey::FieldofViewDimension, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFieldofViewDimension); 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::DateofLastDetectorCalibration, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDateofLastDetectorCalibration); Dispatch->Get.Push(AttrKey::TimeofLastDetectorCalibration, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTimeofLastDetectorCalibration); Dispatch->Get.Push(AttrKey::DetectorConditionsNominalFlag, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorConditionsNominalFlag); 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); } void nsFPD::CFPDDeviceAXS::RegisterAcq(nsDetail::Dispatch* Dispatch) { Dispatch->Action.Push(ActionKey::SetAcqMode, m_AcqUnit.get(), &AcqUnit::JSSetAcqMode); Dispatch->Get.Push(AttrKey::ZskkFPDState, m_AcqUnit.get(), &AcqUnit::JSGetZskkFPDState); Dispatch->Get.Push(AttrKey::NoNeedWaitImage, m_AcqUnit.get(), &AcqUnit::JSGetNoNeedWaitImage); Dispatch->Get.Push(AttrKey::ImgDataInfo, m_AcqUnit.get(), &AcqUnit::JSGetLastImage); Dispatch->Get.Push(AttrKey::AutonumousMapFinish, m_AcqUnit.get(), &AcqUnit::JSAutonumousMapFinish); } void nsFPD::CFPDDeviceAXS::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->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::SyncMode, m_SyncUnit.get(), &SyncUnit::JSGetSyncMode); Dispatch->Get.Push(AttrKey::XrayON, m_SyncUnit.get(), &SyncUnit::JSGetXrayON); } void nsFPD::CFPDDeviceAXS::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::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::HaveImgCalibration, m_CalibUnit.get(), &CalibUnit::JSGetHaveImgCalibration); Dispatch->Get.Push(AttrKey::UploadCalibrationFilesResult, m_CalibUnit.get(), &CalibUnit::JSGetUploadCalibrationFilesResult); Dispatch->Get.Push(AttrKey::SaveCalibrationFileFinish, m_CalibUnit.get(), &CalibUnit::JSGetSaveCalibrationFileFinish); } void nsFPD::CFPDDeviceAXS::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); } void nsFPD::CFPDDeviceAXS::RegisterAutonumous(nsDetail::Dispatch* Dispatch) { Dispatch->Action.Push("OfflineFPD", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSOfflineFPD); Dispatch->Action.Push("OnlineFPD", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSOnlineFPD); Dispatch->Action.Push("GetAutonumousImageList", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAutonumousImageList); Dispatch->Action.Push("RemoveAutonumousImageList", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRemoveAutonumousImageList); Dispatch->Action.Push("RemoveAutonumousAll", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRemoveAutonumousAll); Dispatch->Action.Push("GetImageMetaData", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetImageMetaData); Dispatch->Action.Push("ExportAutonumousAll", m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSExportAutonumousAll); } void nsFPD::CFPDDeviceAXS::SendTemperatureValue(float fValue) { int nStatus = 0; m_Temperature->SetTemperature(fValue, nStatus); FINFO("SendTemperatureValue: {$}, status {$}", fValue, nStatus); } void nsFPD::CFPDDeviceAXS::SendWifiValue(int nValue) { int nStatus = 0; m_Wifi->SetSignalValue(nValue, nStatus); FINFO("SendWifiValue: {$}, status {$}", nValue, nStatus); } void nsFPD::CFPDDeviceAXS::SendBatteryValue(int nValue) { int nStatus = 0; m_Battery->SetRemainPowerValue(nValue, nStatus); FINFO("SendBatteryValue: {$}, status {$}", nValue, nStatus); } /// /// 探测器设备 所有 事件处理入口 @PZ_FPD /// conf/info/status/data/warning/error /// /// /// /// /// /// /// /// /// void nsFPD::CFPDDeviceAXS::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::CFPDDeviceAXS::NotifyXWindowOn() { m_SyncUnit->XWindowOnNotify(); } // 通知子系统关窗 void nsFPD::CFPDDeviceAXS::NotifyXWindowOff() { m_SyncUnit->XWindowOffNotify(); } bool nsFPD::CFPDDeviceAXS::GetOnlyHaveFpd() { return m_bOnlyHaveFpd; } int nsFPD::CFPDDeviceAXS::GetGainExposureNum() { return m_nCalibTotalExposureNum; } /// /// 探测器设备 配置 事件处理 @PZ_FPD /// 暂不支持 配置 /// /// /// /// /// /// /// /// /// void nsFPD::CFPDDeviceAXS::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; FINFO("Receive Panel {$} SN {$}", nDetectorID, pszMsg); m_DetectorCtrlUnit->SetDetectorID(m_stDeviceConfig.strPanelSerial); break; } case EVT_CONF_RAW_WIDTH: { if (m_stDeviceConfig.nFullImageWidth != nParam1) { m_stDeviceConfig.nFullImageWidth = nParam1; } FINFO("Panel {$} nRawWidth:{$}", nDetectorID, m_stDeviceConfig.nRawWidth); break; } case EVT_CONF_RAW_HIGHT: { if (m_stDeviceConfig.nFullImageHeight != nParam1) { m_stDeviceConfig.nFullImageHeight = nParam1; } FINFO("Panel {$} nRawHeight:{$}", nDetectorID, m_stDeviceConfig.nRawHeight); break; } case EVT_CONF_RAW_BITS: { m_stDeviceConfig.nImageBits = nParam1; FINFO("Panel {$} nImageBits:{$}", nDetectorID, m_stDeviceConfig.nImageBits); break; } case EVT_CONF_PIXELSPACE: { m_stDeviceConfig.nPixelSpace = (int)fParam2; FINFO("Panel {$} nPixelSpace:{$}", nDetectorID, m_stDeviceConfig.nPixelSpace); break; } case EVT_CONF_PREVIEW_WIDTH: { if (m_stDeviceConfig.nPreviewWidth != nParam1) { m_stDeviceConfig.nPreviewWidth = nParam1; } FINFO("Panel {$} nPreviewWidth:{$}", nDetectorID, m_stDeviceConfig.nPreviewWidth); break; } case EVT_CONF_PREVIEW_HIGHT: { if (m_stDeviceConfig.nPreviewHeight != nParam1) { m_stDeviceConfig.nPreviewHeight = nParam1; } FINFO("Panel {$} nPreviewHeight:{$}", nDetectorID, m_stDeviceConfig.nPreviewHeight); break; } case EVT_CONF_MODULE_TYPE: { //m_strModuleType = pszMsg; FINFO("Receive Panel {$} ModuleType {$}", nDetectorID, pszMsg); break; } case EVT_CONF_MODULE_IP: { //m_strModuleIP = pszMsg; FINFO("Receive Panel {$} ModuleIP {$}", nDetectorID, pszMsg); break; } case EVT_CONF_MODULE_SN: { //m_strModuleSN = pszMsg; FINFO("Receive Panel {$} ModuleSN {$}", nDetectorID, pszMsg); break; } case EVT_CONF_FIRWARE_UPDATE: { m_stDeviceConfig.nFirmwareStatus = nParam1; FINFO("Panel {$} FirmwareUpdate:{$}", nDetectorID, m_stDeviceConfig.nFirmwareStatus); break; } case EVT_CONF_PART_NUMBER: { m_stDeviceConfig.strPartNumber = pszMsg; FINFO("Panel {$} PartNumber:{$}", nDetectorID, pszMsg); break; } case EVT_CONF_BATTERY_SN: { //m_strBatterySN = pszMsg; FINFO("Panel {$} Battery SN:{$}", nDetectorID, pszMsg); break; } case EVT_CONF_WIFI_SSID: { m_stDeviceConfig.strWifiSSID = pszMsg; FINFO("Panel {$} WifiSSID:{$}", nDetectorID, pszMsg); break; } case EVT_CONF_IFBOARD: { m_stDeviceConfig.strInterfaceBoard = pszMsg; FINFO("Panel {$} InterfaceBoard:{$}", nDetectorID, pszMsg); break; } case EVT_CONF_DATECODE: { m_stDeviceConfig.strDateCode = pszMsg; FINFO("Panel {$} DateCode:{$}", nDetectorID, pszMsg); break; } case EVT_CONF_LIFETIME: { int nLifeTime = nParam1; if ((nLifeTime != m_stDeviceConfig.nLifeTime) /*&& (m_strBatterySN != "")*/) { FINFO("LifeTime:{$}", nLifeTime); m_stDeviceConfig.nLifeTime = nLifeTime; } break; } default: break; } } /// /// 探测器设备 Info 事件处理 @PZ_FPD /// 暂不支持 Info /// /// /// /// /// /// /// /// /// void nsFPD::CFPDDeviceAXS::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; FINFO("Detector {$} PowerOn:{$}", nID, nPowerOn); if ((nPowerOn != m_stDeviceConfig.nPowerOn) /*&& (m_strBatterySN != "")*/) { m_stDeviceConfig.nPowerOn = nPowerOn; } break; } case EVT_INFO_BATTERY_CAPACITY: { int nBatteryCapacity = nParam1; if ((nBatteryCapacity != m_nBatteryCapacity) /*&& (m_strBatterySN != "")*/) { FINFO("{$}", nBatteryCapacity); m_nBatteryCapacity = nBatteryCapacity; } break; } case EVT_INFO_BATTERY_TEMPERATURE: { float fBatteryTemper = fParam2; if (((fBatteryTemper - m_fBatteryTemperature) >= 0.1f) /*&& (m_strBatterySN != "")*/) { FINFO("temperature:{$:f2}", fBatteryTemper); m_fBatteryTemperature = fBatteryTemper; } break; } case EVT_INFO_BATTERY_CHARGES: { int nBatteryCharges = nParam1; if ((nBatteryCharges != m_nBatteryCharges)/* && (m_strBatterySN != "")*/) { FINFO("Charge number:{$}", nBatteryCharges); m_nBatteryCharges = nBatteryCharges; } break; } case EVT_INFO_WIFI_DATARATE: { m_stDeviceConfig.nWifiDataRate = nParam1; FINFO("Detector {$} WifiDataRate:{$}", nID, m_stDeviceConfig.nWifiDataRate); break; } case EVT_INFO_WIFI_CHANNEL: { m_stDeviceConfig.nWifiChannel = nParam1; FINFO("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; FINFO("Panel {$} WifiNoisePower:{$}", nID, m_stDeviceConfig.nWifiNoisePower); break; } case EVT_INFO_FIRMWARE: { m_stDeviceConfig.strFirmware = pszMsg; FINFO("Panel {$} Firmware:{$}", nID, pszMsg); break; } case EVT_INFO_SHOCKSENSOR_INFO: { FINFO("Receive ShockSensor Info"); //m_strShockSensor = pszMsg; //m_DetectorCtrlUnit->SetShockSensorInfo(m_strShockSensor); break; } case EVT_INFO_CALIBRATIOIN_TIME: { m_stDeviceConfig.strCalibrationDate = pszMsg; FINFO("Panel {$} Calibration Time:{$}", nID, pszMsg); m_DetectorCtrlUnit->SetDateofLastDetectorCalibration(m_stDeviceConfig.strCalibrationDate); m_DetectorCtrlUnit->SetTimeofLastDetectorCalibration(""); //m_stDeviceConfig.strCalibrationDue = m_CalibProcess->GetCalibDueDate(m_stDeviceConfig, m_stDeviceConfig.strCalibrationDate); break; } case EVT_INFO_CALIBRATIOIN_TIMEL: { m_stDeviceConfig.strCalibrationLTEDate = pszMsg; FINFO("Panel {$} Calibration LTE Time:{$}", nID, pszMsg); //m_stDeviceConfig.strCalibrationLTEDue = m_CalibProcess->GetCalibDueDate(m_stDeviceConfig, m_stDeviceConfig.strCalibrationLTEDate); break; } case EVT_INFO_FPVOLTAGE: { //m_strVoltage = pszMsg; break; } default: break; } } /// /// 探测器设备状态事件 处理@PZ_FPD /// /// /// /// /// /// /// /// /// void nsFPD::CFPDDeviceAXS::OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { switch (nEventID) { case EVT_STATUS_INIT: { if (PANEL_EVENT_END_OK == nParam1) { FINFO("Detector init success set connect status is true"); m_stDeviceConfig.bConnectStatus = true; m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_SUCCESS)); } else if (PANEL_EVENT_END_ERROR == nParam1) { m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_FAILED)); } else if (PANEL_EVENT_END == nParam1) //未连接探测器 { m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_SUCCESS)); } else if (PANEL_EVENT_START == nParam1) { m_DetectorCtrlUnit->SetInitialStatus(to_string(DETECTOR_INI_START)); } break; } case EVT_STATUS_MOTION: { //m_strMotionStatus = pszMsg; break; } case EVT_STATUS_UPDATE_FIRMWARE: { if (PANEL_EVENT_START == nParam1) { FINFO("Start update firmware"); m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_START)); } else if (PANEL_EVENT_BEGIN == nParam1) { FINFO("Update firmware begin"); m_stDeviceConfig.bConnectStatus = false; } else if (PANEL_EVENT_END_ERROR == nParam1) { FINFO("Update firmware failed"); //SendDetectorInfo(); //更新探测器状态图标 m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_ERROR)); } else if (PANEL_EVENT_SUCCESS == nParam1) { FINFO("update firmware success"); //SendDetectorInfo(); m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_SUCCESS)); } break; } case EVT_STATUS_SELFTEST: { break; } case EVT_STATUS_DETECTORSHARE: { ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1; switch (eStatus) { case PANEL_ATTACH_START: m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_ATTACH_START)); //重置status,避免服务判重,两次attach失败时,不将第二次的失败信息发送给客户端 FINFO("New Detector Attach start"); break; case PANEL_ATTACH_OVER: FINFO("New Detector Attach Over,Prepare to Connecting"); //m_DetectorCtrlUnit->SetAttachResult(true, m_stDeviceConfig.strDeviceName.c_str(), m_strModuleSN.c_str()); break; case PANEL_ATTACH_FAILED: //UI显示Failed FERROR("New Detector Attach failed"); m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_ATTACH_FAILED)); break; case PANEL_CONNECT_OK: FINFO("OnEventProcessStatus panel connect ok set connect status is true"); m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK)); m_stDeviceConfig.bConnectStatus = true; break; case PANEL_CONNECT_ERROR: m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_ERROR)); break; case PANEL_DISCONNECT_SUCCESS: m_nBatteryCapacity = 0; //m_strBatterySN = ""; m_stDeviceConfig.bExisted = false; m_stDeviceConfig.bConnectStatus = false; m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS)); break; case PANEL_DISCONNECT_ERROR: m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_ERROR)); break; default: break; } break; } case EVT_STATUS_SINGLEINIT: { break; } case EVT_STATUS_SELECTPANEL: { break; } case EVT_STATUS_PANEL: { ENUM_PANEL_STATUS m_ePanelStatus = (ENUM_PANEL_STATUS)nParam1; if (PANEL_XWINDOW_ON == nParam1) //Xwindow On { m_stImgCreateTime = { 0 }; GetLocalTime(&m_stImgCreateTime); FINFO("XWindow on time {$}:{$}:{$}:{$}", m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds); m_SyncUnit->XWindowOnNotify(); } else if (PANEL_XWINDOW_OFF == nParam1) // Xwindow Off { m_stImgCreateTime = { 0 }; GetLocalTime(&m_stImgCreateTime); FINFO("XWindow off time {$}:{$}:{$}:{$}", m_stImgCreateTime.wHour, m_stImgCreateTime.wMinute, m_stImgCreateTime.wSecond, m_stImgCreateTime.wMilliseconds); m_SyncUnit->XWindowOffNotify(); } else if (PANEL_READY_EXP == nParam1) { m_SyncUnit->FPDReadyNotify(true); m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_READY)); } else if (PANEL_GAIN_READY_EXP == nParam1) { m_SyncUnit->FPDReadyNotify(true); m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_READY)); } else if (PANEL_XRAY_ON == nParam1) { m_SyncUnit->XrayOnNotify(); } else if (PANEL_XRAY_OFF == nParam1) { m_SyncUnit->XrayOffNotify(); } else if (PANEL_CLOSE == nParam1) { FINFO("notify FPD not ready"); m_SyncUnit->FPDReadyNotify(false); //右上角图标变灰色 m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_SHUTDOWN)); } break; } case EVT_STATUS_CALIBRATIOIN: { ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1; switch (eStatus) { case PANEL_EVENT_END_OK: FINFO("Calibration process end ok"); CompleteCalibration(); break; case PANEL_EVENT_END_ERROR: FINFO("Calibration process end error"); break; case PANEL_EVENT_START: FINFO("Calibration process start"); break; case PANEL_EVENT_SUCCESS: FINFO("Calibration process success"); break; case PANEL_EVENT_END: FINFO("Calibration process end"); break; case PANEL_EVENT_BEGIN: FINFO("Calibration process begin"); break; case PANEL_EVENT_TIMEOUT: FINFO("Calibration timeout"); break; default: break; } break; } case EVT_STATUS_SAVECALIB: { if (PANEL_EVENT_START == nParam1) { FINFO("Begin to Save Calibration Files"); } else if (PANEL_EVENT_END_ERROR == nParam1) { FINFO("Save Calibration Files failed"); } else if (PANEL_EVENT_END == nParam1) { FINFO("Save Calibration Files Success"); } break; } case EVT_STATUS_SAVEDEFECT: { if (PANEL_EVENT_START == nParam1) { FINFO("Begin to Save Defect Files"); } else if (PANEL_EVENT_END_ERROR == nParam1) { FINFO("Save Defect Files failed"); } else if (PANEL_EVENT_END == nParam1) { FINFO("Save Defect Files Success"); m_stDeviceConfig.bTaskEnd = true; } break; } case EVT_STATUS_ACQUISITION: { ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1; switch (eStatus) { case PANEL_EVENT_START: FINFO("Acquisition start"); break; case PANEL_EVENT_END_OK: FINFO("Acquisition end"); break; case PANEL_EVENT_END_ERROR: //目前不会报错,不会走到这里 break; default: break; } break; } case EVT_STATUS_SINGLEEXP: { if (DOSE_TOO_HIGH == nParam1) { FINFO("Dose too high"); StopCalibration(); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_CalibUnit->SetCalibrationProgress("100"); m_AcqUnit->SendNoNeedWaitImage(true); } else if (DOSE_TOO_LOW == nParam1) { FINFO("Dose too low"); StopCalibration(); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_CalibUnit->SetCalibrationProgress("100"); m_AcqUnit->SendNoNeedWaitImage(true); } else if (DOSE_OBJECT == nParam1) { FINFO("Dose object"); StopCalibration(); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_AcqUnit->SendNoNeedWaitImage(true); } else if (DOSE_ACCEPT == nParam1) { FINFO("Calibration Result is acceptable"); //m_WarnAndError->OnErrorX("ERR_FPD_DOSE_INVALID"); } else if (EVT_STATUS_LASTERROR == nParam1) { //m_strLastError = pszMsg; //FINFO("Panel {$} LastError {$}", nID, pszMsg); } break; } case EVT_STATUS_IMAGEPENDING: { string strTemp = pszMsg; if (strTemp.find("true") != std::string::npos) { m_bImagePendingOrNot = true; } else { m_bImagePendingOrNot = false; } if (m_bImagePendingOrNot) // && !m_bResetDetector { //OnError(nID, "ERR_FPD_IMAGE_PENDING"); } else { m_bResetDetector = false;//可以再次reset //m_WarnAndError->OnErrorX("ERR_FPD_IMAGE_PENDING"); } break; } case EVT_STATUS_TEMPERATURE: { float fTemperature = fParam2; OnProcessTemperature(nDetectorID, fTemperature); m_stDeviceConfig.fCurrentTemperValue = fTemperature; FINFO("Detector {$} Temperature Value:{$}", nDetectorID, fTemperature); SendTemperatureValue(m_stDeviceConfig.fCurrentTemperValue); break; } case EVT_STATUS_WIFI: { int nWifiLevel = nParam1; if (m_stDeviceConfig.strDeviceName.find("AXS") >= 0) { nWifiLevel = int(nWifiLevel / 0.75); if (nWifiLevel > 100) { nWifiLevel = 100; } } FINFO("Detector {$} Wifi Value:{$}", nDetectorID, nWifiLevel); //strWarnErrorCode = "ERR_FPD_WIFI_LOW"; if (nWifiLevel == 0) //WIFI值为0 表明是有线连接,不报错 { //m_WarnAndError->OnErrorX(strWarnErrorCode); } else if (nWifiLevel < m_stDeviceConfig.nWifiLimit) { //wifi error //OnError(nID, strWarnErrorCode); } else if (nWifiLevel <= m_stDeviceConfig.nWifiWarning) { //wifi error //m_WarnAndError->OnErrorX(strWarnErrorCode); //strWarnErrorCode = "WAR_FPD_WIFI_LOW"; //OnWarn(nID, strWarnErrorCode); } else { //m_WarnAndError->OnErrorX(strWarnErrorCode); } FINFO("detector wifi level:{$}", nWifiLevel); if (nWifiLevel != m_stDeviceConfig.nCurrentWifiValue) { FINFO("Channel:{$},SignalPower:{$},NoisePower:{$},DataRate:{$}", m_stDeviceConfig.nWifiChannel, m_stDeviceConfig.nWifiSignalPower, m_stDeviceConfig.nWifiNoisePower, m_stDeviceConfig.nWifiDataRate); } //endif m_stDeviceConfig.nCurrentWifiValue = nWifiLevel; SendWifiValue(m_stDeviceConfig.nCurrentWifiValue); break; } case EVT_STATUS_BATTERY_VALUE: { int nBatteryValue = nParam1; FINFO("Detector {$} Battery:{$}", nDetectorID, nParam1); if (nBatteryValue < m_stDeviceConfig.nBatteryLimit) { //battery error //if (!m_bBatteryCharging) //如果没有充电; //{ // strWarnErrorCode = "ERR_FPD_BATTERY_LOW"; // OnError(nID, strWarnErrorCode); //} } else if (nBatteryValue < m_stDeviceConfig.nBatteryWarning) { //battery error //strWarnErrorCode = "ERR_FPD_BATTERY_LOW"; //m_WarnAndError->OnErrorX(strWarnErrorCode); //strWarnErrorCode = "WAR_FPD_BATTERY_LOW"; //OnWarn(nID, strWarnErrorCode); } else { //strWarnErrorCode = "ERR_FPD_BATTERY_LOW"; //m_WarnAndError->OnErrorX(strWarnErrorCode); } m_stDeviceConfig.nCurrentBatteryValue = nBatteryValue; FINFO("Detector {$} Battery Value:{$}", nDetectorID, nBatteryValue); SendBatteryValue(m_stDeviceConfig.nCurrentBatteryValue); 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 strLog; //PRINTA_INFO("Panel %d Shock Sensor Number:%d", nID, m_nShockCounts); //if ((m_nShockCounts >= m_stDeviceConfig.nMaxShockNumber) && (m_stDeviceConfig.nShockTimes != m_nShockCounts))//避免频繁发送 //{ // PRINTA_INFO("Reach Max Shock Sensor Number"); // OnWarn(nID, WAR_FPD_MAX_SHOCK_NUM); // SendInfoLog("DEV_LOG_FPD_SHOCKSENSOR", m_strShockSensor); //} //m_stDeviceConfig.nShockTimes = m_nShockCounts; break; } case EVT_STATUS_HALL_SENSOR: { //int nWorkstaion = nParam1; //PRINTA_INFO("Update Hall Status : %d ", nWorkstaion); //PRINTA_INFO("Panel %d WS:%d,Current OGP WS:%d ", nID, nWorkstaion, m_nWorkStation); //m_stDeviceConfig.nWorkstation = nWorkstaion; break; } case EVT_STATUS_PING: { break; } case EVT_STATUS_PMSNOTOPEN: { string strTemp = pszMsg; if (strTemp.find("true") != std::string::npos) { FINFO("PMS isn't open"); } break; } case EVT_STATUS_RESTOREFILES: { //string strTemp = pszMsg; //if (strTemp.find("true") != std::string::npos) //{ // PRINTA_INFO("Restore calibration files"); // string wcsPanelType = "3543dr"; // if (m_stDeviceConfig.strDeviceName.find("3543EZ") >= 0) // { // wcsPanelType = "3543ezh"; // } // else if (m_stDeviceConfig.strDeviceName.find("2430EZ") != std::string::npos) // { // wcsPanelType = "2430ez"; // } // m_CalibProcess->UpdateFDCalibList(m_nLTEenable, m_stDeviceConfig.strPanelSerial, wcsPanelType.c_str()); //} break; } case EVT_STATUS_LASTERROR: { //m_strLastError = pszMsg; //PRINTA_INFO("Panel {$} LastError {$}", nID, pszMsg); 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) { // //OnError(nID,ERR_FPD_RESET,L""); } break; } case EVT_AUTONUMOUS_STATUS: { ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1; switch (eStatus) { case PANEL_CONNECT_ERROR: { m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_ERROR)); break; } case PANEL_CONNECT_OK: { m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK)); m_stDeviceConfig.bConnectStatus = true; break; } case PANEL_DISCONNECT_SUCCESS: { m_nBatteryCapacity = 0; m_stDeviceConfig.bExisted = false; m_stDeviceConfig.bConnectStatus = false; m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS)); break; } case PANEL_DISCONNECT_ERROR: { m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_ERROR)); break; } case PANEL_START_STOREDIMAGE: { FINFO("Send start autonumous to server"); m_AcqUnit->SendAutonumousMapFinish(0); break; } case PANEL_END_STOREDIMAGE: { FINFO("Send finish autonumous to server"); m_AcqUnit->SendAutonumousMapFinish(1); break; } case PANEL_EXPORT_AUTONUMOUS_FINISH: { FINFO("Send finish export local autonumous to server"); m_AcqUnit->SendAutonumousMapFinish(2); break; } default: break; } break; } default: break; } } /// /// 探测器设备图像数据事件 处理 @PZ_FPD /// /// /// /// /// /// /// /// /// void nsFPD::CFPDDeviceAXS::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("Image Arrived"); if (APP_STATUS_IDLE == m_eAppStatus) { FERROR("Omit Image in Idle Status"); return; } FINFO("Currenct FPD FullImage Width:{$},FullImage Height:{$}", m_stDeviceConfig.nFullImageWidth, m_stDeviceConfig.nFullImageHeight); float fImageReferUGY = 2.5; if (APP_STATUS_WORK_BEGIN == m_eAppStatus) //如果是在检查中 { fImageReferUGY = 2.5; } if (NULL == m_pwRawImageData) { m_pwRawImageData = new WORD[m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight]; } memcpy(m_pwRawImageData, pParam, m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight * sizeof(WORD)); OnProcessImage(m_pwRawImageData, m_stDeviceConfig.nFullImageWidth, m_stDeviceConfig.nFullImageHeight, fImageReferUGY); break; } case EVT_DATA_PREVIEW_IMAGE: { FINFO("Preview Image Arrved"); FINFO("Current FPD preview image width: {$}, height: {$}", m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight); m_SyncUnit->ImageReadingNotify(); //因为AEC图像的像素大小是4 不是 2 故这里要再乘以2 if (nullptr == m_pwPreviewImg) { m_pwPreviewImg = new WORD[m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * 2]; } else { memset(m_pwPreviewImg, 0, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * 4); } memcpy(m_pwPreviewImg, pParam, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * 4); OnProcessPreviewImage(m_pwPreviewImg, m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight); break; } case EVT_DATA_DOSEPARAM: { m_fDoseParam = fParam2; break; } default: FERROR("Not support this eventID ({$})", nEventID); break; } } /// /// 探测器设备 ERROR 事件处理 @PZ_FPD /// /// /// /// /// /// /// /// /// void nsFPD::CFPDDeviceAXS::OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { 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; m_stDeviceConfig.fCurrentTemperValue = 0.0f; m_stDeviceConfig.nCurrentWifiValue = 0; m_stDeviceConfig.nCurrentBatteryValue = 0; SendWifiValue(m_stDeviceConfig.nCurrentWifiValue); SendBatteryValue(m_stDeviceConfig.nCurrentBatteryValue); SendTemperatureValue(m_stDeviceConfig.fCurrentTemperValue); //OnError(nDetectorID, strErrorName); } else if (strTemp.find("false") != std::string::npos)//成功时交给WIFI发送SendDetectorInfo { m_stDeviceConfig.bConnectStatus = true; //if (m_WarnAndError->IsErrorExist("ERR_FPD_DISCONNECT")) //如果已经恢复了通讯,不再重复发送LOG //{ // m_WarnAndError->OnErrorX(strErrorName); //} } break; } case EVT_ERR_EXP_REQUEST: FERROR("OnEventProcessError EVT_ERR_EXP_REQUEST"); break; case EVT_ERR_GET_IMAGE: FERROR("OnEventProcessError EVT_ERR_GET_IMAGE"); break; case EVT_ERR_MAX_NUMBER: FERROR("OnEventProcessError EVT_ERR_MAX_NUMBER"); break; case EVT_ERR_SN_NOTINLIST: FERROR("OnEventProcessError EVT_ERR_SN_NOTINLIST"); break; case EVT_ERR_POWER_OFF: FERROR("OnEventProcessError EVT_ERR_POWER_OFF"); break; case EVT_ERR_INIT_FAILED: { string strTemp = pszMsg; if (strTemp.find("true") != std::string::npos) { //AddErrMsg("6", "initialize error"); } else if (strTemp.find("false") != std::string::npos) { //一般不可恢复 } break; } default: FERROR("Not support this error({$})", nEventID); break; } } /// /// 探测器设备 WARNING 事件 处理 @PZ_FPD /// 当前版本不支持,TBD. /// /// /// /// /// /// /// /// /// void nsFPD::CFPDDeviceAXS::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { FERROR("Not support this warn({$})", nEventID); } bool nsFPD::CFPDDeviceAXS::OnProcessPreviewImage(WORD* pwRawImage, int nWidth, int nHeight) { FINFO("Currenct PreviewImage Width:{$},Height:{$}", m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight); PrevImageDateArrived(pwRawImage); return true; } void nsFPD::CFPDDeviceAXS::PrevImageDateArrived(WORD* pImg) { //LMAM3-IZ85c的pre image 像素大小是4,单字节:宽*高*4 双字节:宽*高*2 AddFrameWithRawHead(IMAGE_PREVIEW, pImg, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * 2); } void nsFPD::CFPDDeviceAXS::FullImageDateArrived(WORD* pImg) { //LMAM3-IZ85c的有效图像像素大小是2,单字节:宽*高*2 双字节:宽*高 AddFrameWithRawHead(IMAGE_FULL, pImg, m_stDeviceConfig.nFullImageWidth * m_stDeviceConfig.nFullImageHeight); } RET_STATUS nsFPD::CFPDDeviceAXS::AddFrameWithRawHead(IMAGE_VIEW_TYPE Type, WORD* pFrameBuff, DWORD FrameSize) { string strImageHead = MakeImageHead(Type); FINFO("str image head:{$}",strImageHead.c_str()); printf("str image head:%s", strImageHead.c_str()); FINFO("FrameSize:{$}", FrameSize); return m_AcqUnit->AddFrameWithRawHead(Type, strImageHead, pFrameBuff, FrameSize); } string nsFPD::CFPDDeviceAXS::MakeImageHead(IMAGE_VIEW_TYPE Type) { if (m_pImageHead != NULL) { delete m_pImageHead; m_pImageHead = nullptr; } if (Type == IMAGE_FULL) { if (m_pImageHead == NULL) { m_pImageHead = new ResDataObject; ResDataObject json; json.add(SM_IMAGE_TYPE, (int)Type); json.add(SM_IMAGE_WIDTH, m_stDeviceConfig.nFullImageWidth); json.add(SM_IMAGE_HEIGHT, m_stDeviceConfig.nFullImageHeight); json.add(SM_IMAGE_BIT, 16); json.add(SM_IMAGE_TAG, 1); json.add(SM_IMAGE_INDEX, 1); json.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear); json.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth); json.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay); json.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour); json.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute); json.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond); json.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds); json.add(SM_IMAGE_LSB, "5000"); json.add(SM_IMAGE_DOSE, m_stDeviceConfig.nDoseOfEXI); json.add(SM_IMAGE_PIXELREPRESENTATION, "1"); json.add(SM_IMAGE_PIXELSPACING, m_stDeviceConfig.nPixelSpace); json.add(SM_IMAGE_ROTATION, "No"); json.add(SM_IMAGE_FLIP, "No"); json.add(SM_IMAGE_ORIGINX, "0"); json.add(SM_IMAGE_ORIGINY, "0"); json.add(SM_IMAGE_EXI2UGY, m_fFactorEXI2UGY); json.add(SM_IMAGE_TEMP, 0.0f); m_pImageHead->add(SM_IMAGE_HEAD, json); } else { (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_YEAR] = m_stImgCreateTime.wYear; (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MONTH] = m_stImgCreateTime.wMonth; (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_DAY] = m_stImgCreateTime.wDay; (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_HOUR] = m_stImgCreateTime.wHour; (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MINUTE] = m_stImgCreateTime.wMinute; (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_SEC] = m_stImgCreateTime.wSecond; (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MILLSEC] = m_stImgCreateTime.wMilliseconds; (*m_pImageHead)[SM_IMAGE_HEAD][SM_IMAGE_TEMP] = m_stDeviceConfig.fCurrentTemperValue; } return (*m_pImageHead).encode(); } else { if (m_pPreviewImageHead == NULL) { m_pPreviewImageHead = new ResDataObject; ResDataObject json; json.add(SM_IMAGE_TYPE, (int)Type); json.add(SM_IMAGE_WIDTH, m_stDeviceConfig.nPreviewWidth); json.add(SM_IMAGE_HEIGHT, m_stDeviceConfig.nPreviewHeight); json.add(SM_IMAGE_BIT, 16); json.add(SM_IMAGE_TAG, 1); json.add(SM_IMAGE_INDEX, 1); json.add(SM_IMAGE_YEAR, m_stImgCreateTime.wYear); json.add(SM_IMAGE_MONTH, m_stImgCreateTime.wMonth); json.add(SM_IMAGE_DAY, m_stImgCreateTime.wDay); json.add(SM_IMAGE_HOUR, m_stImgCreateTime.wHour); json.add(SM_IMAGE_MINUTE, m_stImgCreateTime.wMinute); json.add(SM_IMAGE_SEC, m_stImgCreateTime.wSecond); json.add(SM_IMAGE_MILLSEC, m_stImgCreateTime.wMilliseconds); json.add(SM_IMAGE_LSB, "5000"); json.add(SM_IMAGE_DOSE, m_stDeviceConfig.nDoseOfEXI); json.add(SM_IMAGE_ROTATION, "No"); json.add(SM_IMAGE_FLIP, "No"); json.add(SM_IMAGE_ORIGINX, "0"); json.add(SM_IMAGE_ORIGINY, "0"); json.add(SM_IMAGE_PIXELSPACING, m_stDeviceConfig.nPixelSpace); json.add(SM_IMAGE_PIXELREPRESENTATION, "1"); json.add(SM_IMAGE_TEMP, m_stDeviceConfig.fCurrentTemperValue); m_pPreviewImageHead->add(SM_IMAGE_HEAD, json); } else { (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_YEAR] = m_stImgCreateTime.wYear; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MONTH] = m_stImgCreateTime.wMonth; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_DAY] = m_stImgCreateTime.wDay; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_HOUR] = m_stImgCreateTime.wHour; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MINUTE] = m_stImgCreateTime.wMinute; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_SEC] = m_stImgCreateTime.wSecond; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MILLSEC] = m_stImgCreateTime.wMilliseconds; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_TEMP] = m_stDeviceConfig.fCurrentTemperValue; } return (*m_pPreviewImageHead).encode(); } } bool nsFPD::CFPDDeviceAXS::OnProcessImage(WORD* pwRawImage, int nImageWidth, int nImageHeight, float fImageReferUGY) { FINFO("CFPDDeviceAXS OnProcessImage"); if (pwRawImage == NULL) { FERROR("OnProcessImage src ImgData is null!"); return false; } if (!m_pwImageData) { m_pwImageData = new WORD[nImageWidth * nImageHeight]; } if (!m_pwImageData) { FERROR("OnProcessImage new error!"); return false; } memcpy(m_pwImageData, pwRawImage, nImageWidth * nImageHeight * sizeof(WORD)); //图像预处理完成 m_pwImageData[0] = 65535;//坐标原点 bug 8164 //如果环境中只有探测器,那么这里增加一个推送状态 if (m_bOnlyHaveFpd) { FINFO("OnProcessImage OnlyHaveFpd Sleep 1s then set fpd standby(4)"); Sleep(1000); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); } FullImageDateArrived(m_pwImageData); FINFO("OnProcessImage Write Frame Over"); return true; } RET_STATUS nsFPD::CFPDDeviceAXS::AcceptCalibration() { FINFO("==========Fun AcceptCalibration =========="); printf("--func-- AcceptCalibration\n"); RET_STATUS ret = RET_STATUS::RET_SUCCEED; if (((CAXSCtrl*)m_pDetectors)->AcceptCalibration()) { FINFO("AcceptCalibration over"); ret = RET_STATUS::RET_SUCCEED; } else { FERROR("AcceptCalibration error"); ret = RET_STATUS::RET_FAILED; } if (m_eCalibMode == CCOS_CALIBRATION_MODE_ZSKK) { 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; ResDataObject temp = m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]; int nDose = temp["Dose"]; m_fDoseParam = nDose / 1000.0f; } else { m_nCalibCurrentExposureIndex++; } } else { if (m_nCalibCurrentExposureIndex == m_nCalibTotalExposureNum) { FINFO("Calibration Round: {$}, Exposure Index: {$}, Finished", m_nCalibCurrentCalibrationRound, m_nCalibCurrentExposureIndex); m_nCalibCurrentExposureIndex = 1; m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_CalibUnit->SetCalibrationProgress("100"); return ret; } else { m_fDoseParam = 2500 / 1000.0f; m_nCalibCurrentExposureIndex++; } } //在GetCalibrationStep中会把校正曝光的总次数和当前已接受的曝光次数传给app,app收到后会根据m_nCalibCurrentExposureNum和m_nCalibTotalExposureNum //进行比较,如果相同则认为亮场校正完成,app会主动调用CompleteCalibration m_nCalibCurrentExposureNum++; m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); FINFO("==============================AcceptCalibration over"); return ret; } RET_STATUS nsFPD::CFPDDeviceAXS::RejectCalibration() { printf("--Func-- RejectCalibration \n"); FINFO("==========Fun RejectCalibration =========="); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; if (((CAXSCtrl*)m_pDetectors)->RejectCalibration()) { Ret = RET_STATUS::RET_SUCCEED; } else { FERROR("RejectCalibration error"); Ret = RET_STATUS::RET_FAILED; } m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); FINFO("==============================RejectCalibration over"); return Ret; } RET_STATUS nsFPD::CFPDDeviceAXS::SaveCalibrationFile(bool bSaveFlag) { printf("--Func-- SaveCalibrationFile \n"); FINFO("==========Fun SaveCalibrationFile =========="); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; FINFO("SaveCalibrationFile by user: {$}", bSaveFlag); if (!bSaveFlag) { FERROR("Not save calibration file"); return Ret; } if(m_eCalibMode == CCOS_CALIBRATION_MODE_ZSKK) { if (((CAXSCtrl*)m_pDetectors)->SaveCalibrationFile()) { FINFO("SaveCalibrationFile over"); m_CalibUnit->SetSaveCalibrationFileFinish(true); Ret = RET_STATUS::RET_SUCCEED; } else { FERROR("SaveCalibrationFile error"); m_CalibUnit->SetSaveCalibrationFileFinish(false); Ret = RET_STATUS::RET_FAILED; } } FINFO("==============================SaveCalibrationFile over"); return Ret; } RET_STATUS nsFPD::CFPDDeviceAXS::SetRequestedDose(std::string strDose) { FINFO("==========Fun SetRequestedDose =========="); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; return Ret; } RET_STATUS nsFPD::CFPDDeviceAXS::GetCalibrationStep(int nDetectorID, string& strCalibrationStepInfo) { printf("--func-- GetCalibrationStep\n"); FINFO("==========Fun GetCalibrationStep =========="); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; FINFO("Calibration DetectorID: {$}", nDetectorID); ResDataObject out; if (m_eCalibMode == CCOS_CALIBRATION_MODE_ZSKK) { int nCalibrationRounds = (int)m_CalibDoseList.size(); int nExposureNumCurrentRound = (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"];//当前轮需要曝光的次数(有效) ((CAXSCtrl*)m_pDetectors)->GetCalibrationStep(m_nCalibCurrentCalibrationRound, nCalibrationRounds, m_nCalibCurrentExposureIndex, nExposureNumCurrentRound); //告诉app曝光情况,根据m_nCalibTotalExposureNum和m_nCalibCurrentExposureNum判断是否亮场校正完成 out.add("CalibrationRounds", (int)m_CalibDoseList.size()); out.add("TotalExposureNum", m_nCalibTotalExposureNum); out.add("CurrentCalibrationRound", m_nCalibCurrentCalibrationRound); out.add("ExposureNumCurrentRound", nExposureNumCurrentRound); out.add("CurrentExposureIndex", m_nCalibCurrentExposureIndex); out.add("CurrentExposureNum", m_nCalibCurrentExposureNum); } else { if (m_bFirstGetCalibImageLeft) { //获取需要曝光的次数 int nLeftCount = ((CAXSCtrl*)m_pDetectors)->GetCalImagesLeftCount(); FINFO("First Get Calib Images Left,count:{$}",nLeftCount); m_nCalibTotalExposureNum = nLeftCount; m_bFirstGetCalibImageLeft = false; } ((CAXSCtrl*)m_pDetectors)->GetCalibrationStep(m_nCalibCurrentCalibrationRound, 1, m_nCalibCurrentExposureIndex, m_nCalibTotalExposureNum); out.add("CalibrationRounds", 1); out.add("TotalExposureNum", m_nCalibTotalExposureNum); out.add("CurrentCalibrationRound", 1); out.add("ExposureNumCurrentRound", m_nCalibTotalExposureNum); out.add("CurrentExposureIndex", m_nCalibCurrentExposureIndex); out.add("CurrentExposureNum", m_nCalibCurrentExposureNum); } strCalibrationStepInfo = out.encode(); FINFO("GetCalibrationStep over,strCalibrationStepInfo: {$}", strCalibrationStepInfo.c_str()); return Ret; } //LMAM3-IZ85c不支持暂停校正 RET_STATUS nsFPD::CFPDDeviceAXS::PauseCalibration() { printf("--Func-- PauseCalibration\n"); FINFO("==========Fun PauseCalibration =========="); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; FINFO("==============================PauseCalibration over"); return Ret; } bool nsFPD::CFPDDeviceAXS::CompleteCalibration() { printf("--func-- CompleteCalibration \n"); FINFO("==========Fun CompleteCalibration =========="); m_eAppStatus = APP_STATUS_CAL_END; ((CAXSCtrl*)m_pDetectors)->CompleteCalibration(this); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); if (m_bOnlyHaveFpd) { //通知子系统结束暗场校正太快了,导致后边的服务通知app的消息混乱了,故此处延时1s printf("Sleep 1s,then send progress 100\n"); FINFO("Sleep 1s,then send progress 100"); Sleep(1000); } m_CalibUnit->SetCalibrationProgress("100"); FINFO("==============================CompleteCalibration over"); return true; } void nsFPD::CFPDDeviceAXS::AbortCalibration() { printf("--func-- AbortCalibration\n"); FINFO("==========Fun AbortCalibration =========="); CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType(); if (CCOS_CALIBRATION_TYPE_DARK == nCalibrationType) { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ERROR)); m_CalibUnit->SetCalibrationProgress("100"); FINFO("==============================AbortCalibration over"); return; } m_eAppStatus = APP_STATUS_CAL_END; ((CAXSCtrl*)m_pDetectors)->AbortCalibration(); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ERROR)); m_CalibUnit->SetCalibrationProgress("100"); m_AcqUnit->SendNoNeedWaitImage(true);//什么用意不太清楚 FINFO("==============================AbortCalibration over"); } void nsFPD::CFPDDeviceAXS::OnProcessTemperature(int nID, float fTemperature) { string strWarnErrorCode = ""; float fMaxTempGap = 6.0f; if (m_stDeviceConfig.strDeviceName.find("AXS") >= 0) { fMaxTempGap = 12.0f; } if (fTemperature >= m_stDeviceConfig.fTemperMaxLimit) { FINFO("Exceed Max Temperature"); m_stDeviceConfig.nTemperatureStatus = TEMP_TOO_HIGH; if (m_stDeviceConfig.bActived) { strWarnErrorCode = "ERR_FPD_TEMPHIGH_NOT_ACQ"; //OnError(nID, strWarnErrorCode); } } else if (fTemperature <= m_stDeviceConfig.fTemperMinLimit) { m_stDeviceConfig.nTemperatureStatus = TEMP_TOO_LOW; if (m_stDeviceConfig.bActived) { FINFO("Exceed Min Temperature"); strWarnErrorCode = "ERR_FPD_TEMPLOW_NOT_ACQ"; //OnError(nID, strWarnErrorCode); } } else if (fTemperature <= m_stDeviceConfig.fTemperLowLimit) { m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING; FINFO("Exceed Temperature Low Warning"); //m_WarnAndError->OnErrorX("ERR_FPD_TEMPHIGH_NOT_ACQ"); //m_WarnAndError->OnErrorX("ERR_FPD_TEMPLOW_NOT_ACQ"); strWarnErrorCode = "WAR_FPD_TEMPERTURE_LOW"; //OnWarn(nID, strWarnErrorCode); } else if (fTemperature > m_stDeviceConfig.fTemperWarning) { FINFO("Exceed Temperature High Warning"); //m_WarnAndError->OnErrorX("ERR_FPD_TEMPHIGH_NOT_ACQ"); //m_WarnAndError->OnErrorX("ERR_FPD_TEMPLOW_NOT_ACQ"); m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING; strWarnErrorCode = "WAR_FPD_TEMPERATURE_HIGH"; //OnWarn(nID, strWarnErrorCode); } else if ((m_stDeviceConfig.fCalibTemperature > 1.0f) && (abs(fTemperature - m_stDeviceConfig.fCalibTemperature) >= fMaxTempGap)) { FINFO("Exceed Calibration Temperature"); m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING; strWarnErrorCode = "WAR_FPD_EXCEED_CALB_TEMPER"; //m_WarnAndError->OnErrorX("ERR_FPD_TEMPHIGH_NOT_ACQ"); //m_WarnAndError->OnErrorX("ERR_FPD_TEMPLOW_NOT_ACQ"); //OnWarn(nID, strWarnErrorCode); } else if ((fTemperature <= m_stDeviceConfig.fTemperWarning) && (fTemperature > m_stDeviceConfig.fTemperLowLimit)) { FINFO("Temperature Normal"); //m_WarnAndError->OnErrorX("ERR_FPD_TEMPHIGH_NOT_ACQ"); //m_WarnAndError->OnErrorX("ERR_FPD_TEMPLOW_NOT_ACQ"); //m_stDeviceConfig.nTemperatureStatus = TEMP_NORMAL; } } //慎重调用,可能会导致板出问题,硬reset需要很长时间 RET_STATUS nsFPD::CFPDDeviceAXS::Reset() { printf("--Func-- Reset\n"); FINFO("==========Fun Reset =========="); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; if (((CAXSCtrl*)m_pDetectors)->ResetDetector(this)) { Ret = RET_STATUS::RET_SUCCEED; } else { Ret = RET_STATUS::RET_FAILED; } FINFO("==============================Reset over"); return Ret; } /*** * 客户端获取探测器信息 ***/ RET_STATUS nsFPD::CFPDDeviceAXS::GetDetectorInfo(string& strFDI) { ResDataObject strDetectorInfo; string strTempTemp = " "; FINFO("==========Fun GetDetectorInfo =========="); if (m_stDeviceConfig.strPanelSerial == "") { FERROR("Get Detector Info Failed, Send Default Info"); strDetectorInfo.add("DetectorName", "Simulator"); strDetectorInfo.add("DetectorSN", "Simulator"); strDetectorInfo.add("Firmware", " "); strDetectorInfo.add("APFirmware", " "); strDetectorInfo.add("Software", m_stDeviceConfig.strSoftware.c_str()); strDetectorInfo.add("SSID", " "); strDetectorInfo.add("LifeTime", "0"); strDetectorInfo.add("PowerOn", "0"); strDetectorInfo.add("DateCode", " "); strDetectorInfo.add("PartNumber", " "); strDetectorInfo.add("WifiDataRate", " "); strDetectorInfo.add("WifiChannel", "0"); strDetectorInfo.add("DetectorExist", "0"); strDetectorInfo.add("SystemAS", "0"); strDetectorInfo.add("CalibrationDate", "0"); strDetectorInfo.add("CalibrationDue", "0"); strDetectorInfo.add("CalibrationExist", "0"); strDetectorInfo.add("CommunicationStatus", "0"); strDetectorInfo.add("DetectorTemperature", "0"); strDetectorInfo.add("FDCalibrationTemperature", "0"); strDetectorInfo.add("TemperatureStatus", "0"); strDetectorInfo.add("WaitTime", "0"); strDetectorInfo.add("DetectorWifiSignal", "0"); strDetectorInfo.add("DetectorBattery", "0"); strDetectorInfo.add("ShockSensor", "NULL"); strDetectorInfo.add("FirmwareUpdate", "0"); //encode strFDI = strDetectorInfo.encode(); return RET_STATUS::RET_SUCCEED; } strDetectorInfo.add("DetectorName", m_stDeviceConfig.strDeviceName.c_str()); strDetectorInfo.add("DetectorSN", m_stDeviceConfig.strPanelSerial.c_str()); strDetectorInfo.add("Firmware", m_stDeviceConfig.strFirmware.c_str()); strDetectorInfo.add("APFirmware", "NULL"); strDetectorInfo.add("Software", m_stDeviceConfig.strSoftware.c_str()); strDetectorInfo.add("SSID", m_stDeviceConfig.strWifiSSID.c_str()); strDetectorInfo.add("LifeTime", m_stDeviceConfig.nLifeTime); strDetectorInfo.add("PowerOn", m_stDeviceConfig.nPowerOn); //strDetectorInfo.add("FD_Voltage_List1", m_strVoltage.c_str()); strDetectorInfo.add("DateCode", m_stDeviceConfig.strDateCode.c_str()); strDetectorInfo.add("PartNumber", m_stDeviceConfig.strPartNumber.c_str()); strDetectorInfo.add("WifiDataRate", m_stDeviceConfig.nWifiDataRate); strDetectorInfo.add("WifiChannel", m_stDeviceConfig.nWifiChannel); strDetectorInfo.add("DetectorExist", m_stDeviceConfig.bExisted); //System Workstation if (m_stDeviceConfig.strDeviceName.find("AXS") >= 0) { strDetectorInfo.add("SystemAS", 3); } else { strDetectorInfo.add("SystemAS", 2); } //DetectorCalibrationDate if (m_stDeviceConfig.strCalibrationDate != " ") { if (m_stDeviceConfig.strCalibrationDate.find("19700101") != std::string::npos) { strDetectorInfo.add("CalibrationDate", "0"); strDetectorInfo.add("CalibrationDue", "0"); strDetectorInfo.add("CalibrationExist", 0); } else { strDetectorInfo.add("CalibrationDate", m_stDeviceConfig.strCalibrationDate.c_str()/*"20210610"*/); strDetectorInfo.add("CalibrationDue", m_stDeviceConfig.strCalibrationDue.c_str()/*"20210610"*/); strDetectorInfo.add("CalibrationExist", 1); } } else { strDetectorInfo.add("CalibrationDate", "0"); strDetectorInfo.add("CalibrationDue", "0"); strDetectorInfo.add("CalibrationExist", 0); } if (m_stDeviceConfig.bConnectStatus) { strDetectorInfo.add("CommunicationStatus", 1); } else { strDetectorInfo.add("CommunicationStatus", 0); } strDetectorInfo.add("FDCalibrationTemperature", m_stDeviceConfig.fCalibTemperature); strDetectorInfo.add("ShockSensor", m_nShockCounts); strDetectorInfo.add("FirmwareUpdate", 0); strFDI = strDetectorInfo.encode(); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::CFPDDeviceAXS::ResetConnect() { FINFO("==========Fun ResetConnect =========="); ((CAXSCtrl*)m_pDetectors)->Disconnect(); ((CAXSCtrl*)m_pDetectors)->Connect(this,m_strWorkPath.c_str()); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::CFPDDeviceAXS::SetExposureTimes(int nTimes) { FINFO("==========Fun SetExposureTimes =========="); FINFO("SetExposureTimes nTimes:{$}", nTimes); stringstream sValue; sValue << nTimes; EventCenter->OnNotify((int)ATTRACTION_SET, "ProjectionNum", sValue.str().c_str()); return RET_STATUS::RET_SUCCEED; }