#include "stdafx.h" #include "FileVersion.hpp" #include "CCOS.Dev.FPD.PZMedicalDM.h" #include "common_api.h" #include "DICOMImageHeadKey.h" #include "PZMedicalCtrl.h" #include namespace nsFPD = CCOS::Dev::Detail::Detector; //----------------------------------------------------------------------------- // FPDDevicePZMedical //----------------------------------------------------------------------------- extern PZMedicalCtrl* g_pDetector; //----------------------------------------------------------------------------- // GetIODriver & CreateIODriver //----------------------------------------------------------------------------- static nsFPD::PZMedicalDriver gIODriver; Log4CPP::Logger* //mLog::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::PZMedicalDriver(); } /// /// 驱动构造函数 /// [DONE.CHECKED.] /// nsFPD::PZMedicalDriver::PZMedicalDriver() { m_pObjDev = nullptr; m_bDriverConnect = false; //缺省为false m_pAttribute.reset(new ResDataObject()); m_pDescription.reset(new ResDataObject()); } /// /// [DONE.TO BE TESTED.] /// nsFPD::PZMedicalDriver::~PZMedicalDriver() { if(m_pObjDev != nullptr) { delete m_pObjDev; m_pObjDev = nullptr; } //mLog::Close(); Log4CPP::ThreadContext::Map::Clear(); //mLog::gLogger = nullptr; } /// /// 驱动的准备,可以做一些特殊的操作 /// [DONE.CHECKED.] TBD. /// void nsFPD::PZMedicalDriver::Prepare() { printf("--Driver-- prepare \r\n"); string strLogPath = GetProcessDirectory() + R"(\Conf\Log4CPP.Config.xml)"; auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str()); //mLog::gLogger = Log4CPP::LogManager::GetLogger("Module"); //mLog::FINFO("Code Build datetime [{$} {$}]", __DATE__, __TIME__); #ifdef _WIN64 //mLog::FINFO("=============================Version: {$} (64-bit)==================================", FileVersion(g_szMouldPath).GetVersionString()); #else //mLog::FINFO("=============================Version: {$} (32-bit)==================================", FileVersion(g_szMouldPath).GetVersionString()); #endif //mLog::FINFO("Driver Prepare get logger"); } /// /// 驱动的连接,创建设备对象 /// [DONE.CHECKED.] /// /// bool nsFPD::PZMedicalDriver::Connect() { printf("PZMedical driver module: Connect \r\n"); //mLog::FINFO("--Func-- driver connect"); m_pObjDev = new FPDDevicePZMedical(EventCenter, m_ConfigFileName); m_bDriverConnect = true; //connect执行完毕,置为true printf("PZMedical driver module: Connect over\r\n"); return true; } /// /// 驱动断开连接,释放设备对象 /// void nsFPD::PZMedicalDriver::Disconnect() { printf("PZMedical driver module: Disconnect \r\n"); //mLog::FINFO("--Func-- driver disconnect"); if (m_pObjDev != nullptr) { delete m_pObjDev; m_pObjDev = nullptr; } m_bDriverConnect = false; //disconnect置为false } bool nsFPD::PZMedicalDriver::isConnected() const { return m_bDriverConnect; } /// /// 驱动创建设备丢下,然后 给 上层返回 IODevice 对象指针 /// [DONE.CHECKED.] /// /// /// auto nsFPD::PZMedicalDriver::CreateDevice(int index)->std::unique_ptr { printf("PZMedical driver module: CreateDevice \r\n"); //mLog::FINFO("--Func-- driver createdevice"); auto Device = std::unique_ptr(new IODevice(m_pObjDev)); m_pObjDev->CreateDevice(); m_pObjDev->Register(); return Device; } /// /// 驱动信息检索 TODO : 需要重新定义 /// /// std::string nsFPD::PZMedicalDriver::DriverProbe() { printf("PZMedical 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", "PZMedical"); HardwareInfo.add("ProductID", "PZMedical"); HardwareInfo.add("SerialID", "Driver"); } string str = HardwareInfo.encode(); return str; } /// /// 从配置文件中返回给上层 配置对象 /// 标准代码 /// [DONE.CHECKED.] /// /// std::string nsFPD::PZMedicalDriver::GetResource() { printf("PZMedical driver: GetResource \r\n"); //mLog::FINFO("PZMedical driver: GetResource"); printf("m_ConfigFileName:%s\n", m_ConfigFileName.c_str()); //mLog::FINFO("m_ConfigFileName:{$}", m_ConfigFileName); ResDataObject r_config, temp; if (!temp.loadFile(m_ConfigFileName.c_str())) { return ""; } m_ConfigAll = temp; r_config = temp["CONFIGURATION"]; m_Configurations = r_config; ResDataObject DescriptionTemp; ResDataObject ListTemp; string strTemp = ""; //用于读取字符串配置信息 string strIndex = ""; //用于读取配置信息中的List项 int nTemp = -1; //用于读取整型配置信息 char sstream[10] = { 0 }; //用于转换值 string strValue = ""; //用于存储配置的值 string strType = ""; //用于存储配置的类型 int/float/string... string strAccess = ""; //用于存储权限的类型 R/W/RW string strRequired = ""; // TRUE/FALSE string strDefaultValue = ""; string strRangeMin = ""; string strRangeMax = ""; try { int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo"); ////mLog::FINFO(g_pFPDCtrlLog, "ConfigInfo Count: {$}", nConfigInfoCount); m_pAttribute->clear(); m_pDescription->clear(); for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++) { DescriptionTemp.clear(); ListTemp.clear(); //AttributeType strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Type"]; DescriptionTemp.add(AttributeType, strTemp.c_str()); ////mLog::FINFO("DescriptionTemp--> {$}: {$}", 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]; //sprintf_s(sstream, "{$}", 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) { //mLog::FERROR("Get config error: {$}", e.what()); return ""; } ResDataObject resDeviceResource; resDeviceResource.add(ConfKey::CcosDetectorAttribute, (*m_pAttribute)); resDeviceResource.add(ConfKey::CcosDetectorDescription, (*m_pDescription)); ResDataObject DescriptionTempEx; DescriptionTempEx.add(ConfKey::CcosDetectorConfig, resDeviceResource); m_DeviceConfig = DescriptionTempEx; string res = DescriptionTempEx.encode(); printf("PZMedical driver module: get resource over \r\n"); return res; } /// /// 设备信息检索 TODO : 需要重新定义,TBD. /// /// std::string nsFPD::PZMedicalDriver::DeviceProbe() { printf("PZMedical 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", "PZMedical"); HardwareInfo.add("ProductID", "PZMedical"); HardwareInfo.add("SerialID", "1234"); } string str = HardwareInfo.encode(); return str; } /// /// 设备配置读取接口 /// [DONE.CHECKED.] /// /// /// bool nsFPD::PZMedicalDriver::GetDeviceConfig(std::string& Cfg) { Cfg = m_DeviceConfig.encode(); //mLog::FINFO("GetDeviceConfig over"); return true; } /// /// 提供给web配置中心的 配置写入接口 /// [DONE.CHECKED.] /// /// /// bool nsFPD::PZMedicalDriver::SetDeviceConfig(std::string Cfg) { //mLog::FINFO("--Func-- SetDeviceConfig {$}\n", Cfg.c_str()); ResDataObject DeviceConfig; DeviceConfig.decode(Cfg.c_str()); ResDataObject DescriptionTempEx; DescriptionTempEx = DeviceConfig["DeviceConfig"]; bool bSaveFile = false; //true:重新保存配置文件 string strAccess = ""; for (int i = 0; i < DescriptionTempEx.size(); i++) { ResDataObject temp = DescriptionTempEx[i]; //mLog::FINFO("{$}", temp.encode()); for (int j = 0; j < temp.size(); j++) { string strKey = temp.GetKey(j); //mLog::FINFO("{$}", strKey.c_str()); try { if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0) { strAccess = (string)(*m_pDescription)[strKey.c_str()]["Access"]; if ("RW" == strAccess || "rw" == strAccess) { //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值 //1. 修改内存中的值,用于给上层发消息 (*m_pAttribute)[strKey.c_str()] = temp[j]; //2. 拿到Innerkey int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo"); //mLog::FINFO("ConfigInfo Count: {$}", nConfigInfoCount); string strTemp = ""; //存储AttributeKey for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++) { strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"]; if (strTemp == strKey) { strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"]; break; } } //3. 修改配置文件中的值 if (SetDeviceConfigValue(m_Configurations, strTemp.c_str(), 1, temp[j])) { bSaveFile = true; } } else { //mLog::FINFO("{$} is not a RW configuration item", strKey.c_str()); } } } catch (ResDataObjectExption& e) { //mLog::FERROR("SetDriverConfig crashed: {$}", e.what()); return false; } } } if (bSaveFile) { //4. 重新保存配置文件 SaveConfigFile(true); } return true; } /// /// 保存配置到文件 /// [DONE.TO BE TESTED.] /// /// /// bool nsFPD::PZMedicalDriver::SaveConfigFile(bool bSendNotify) { m_ConfigAll["CONFIGURATION"] = m_Configurations; m_ConfigAll.SaveFile(m_ConfigFileName.c_str()); //mLog::FINFO("SaveConfigFile over, m_ConfigAll:{$}", m_ConfigAll.encode()); return true; } /// /// 读取当前配置项 /// TBD. 审视参数列表 /// /// /// /// /// /// bool nsFPD::PZMedicalDriver::GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue) { strValue = ""; string strTemp = pInnerKey; if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取 { if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp) { strValue = (string)config["connections"][pInnerKey]; } else if (DetectorVender == strTemp || DetectorModel == strTemp || DetectorDescription == strTemp || DetectorSerialNumber == strTemp) { strValue = (string)config[pInnerKey]; } else if (SyncType == strTemp || FPDWorkStation == strTemp || ImageWidth == strTemp || IsSaveRaw == strTemp || ImageHeight == strTemp || RawImgWidth == strTemp || RawImgHeight == strTemp || WidthOffset == strTemp || HeightOffset == strTemp) { strValue = (string)config["ModeTable"]["DetectorMode"][pInnerKey]; } else if (TempMaxLimit == strTemp || TempMinLimit == strTemp || TempUpperLimit == strTemp || TempLowerLimit == strTemp || ReConnect == strTemp || BatLowerLimit == strTemp || BatMiniLimit == strTemp || BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp || WifiMiniLimit == strTemp || HighPowerTimeout == strTemp || ShowTemperature == strTemp || ShowWifi == strTemp || ShowBattery == strTemp || ShowBluetooth == strTemp || FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp || CcosDetectorAttachedFlag == strTemp) { strValue = (string)config[pInnerKey]; } else { strValue = ""; //mLog::FERROR("Error Configuration item: {$}", pInnerKey); } } return true; } /// /// 设置写入设备参数实现,这里过滤需要设置本探测器接受的参数 /// 参数项和内容来源于 探测器配置文件 /// TBD. 具体内容 /// comment by chenggw 2023.2.7 /// /// /// /// /// /// bool nsFPD::PZMedicalDriver::SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey, int nPathID, const char* szValue) { string strTemp = pInnerKey; //mLog::FINFO("Begin to change {$} item value to {$}", pInnerKey, szValue); if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取 { if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp) { config["connections"][pInnerKey] = szValue; } else if (DetectorVender == strTemp || DetectorModel == strTemp || DetectorDescription == strTemp || DetectorSerialNumber == strTemp) { config[pInnerKey] = szValue; } else if (SyncType == strTemp || FPDWorkStation == strTemp || ImageWidth == strTemp || IsSaveRaw == strTemp || ImageHeight == strTemp || RawImgWidth == strTemp || RawImgHeight == strTemp || WidthOffset == strTemp || HeightOffset == strTemp) { config["ModeTable"]["DetectorMode"][pInnerKey] = szValue; } else if (TempMaxLimit == strTemp || TempMinLimit == strTemp || TempUpperLimit == strTemp || TempLowerLimit == strTemp || ReConnect == strTemp || BatLowerLimit == strTemp || BatMiniLimit == strTemp || BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp || WifiMiniLimit == strTemp || HighPowerTimeout == strTemp || ShowTemperature == strTemp || ShowWifi == strTemp || ShowBattery == strTemp || ShowBluetooth == strTemp || FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp || CcosDetectorAttachedFlag == strTemp) { config[pInnerKey] = szValue; } else { //mLog::FERROR("Error Configuration item: {$}", pInnerKey); return false; } } return true; } nsFPD::FPDDevicePZMedical::FPDDevicePZMedical(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_bConnect = false; m_nFullImageHeight = 0; m_nFullImageWidth = 0; m_nImageBits = 0; m_nPixelSpacing = 0; m_pwFullImageData = nullptr; m_pwPreviewImg = nullptr; m_nSensitivity = 0; m_nRotateAngle = 180; m_eAppStatus = APP_STATUS_IDLE; m_eSyncMode = SYNC_SOFTWARE; m_nShockCounts = 0; m_strWorkPath = GetProcessDirectory(); m_DetectorCtrlUnit.reset(new PZMedicalCtrlUnit(center, this)); m_AcqUnit.reset(new PZMedicalAcq(center, this)); m_SyncUnit.reset(new PZMedicalSync(center, this)); m_CalibUnit.reset(new PZMedicalCalib(center, this)); m_DetectorConfiguration.reset(new DetectorConfiguration(strConfigPath)); //探测器告警及错误消息 m_WarnAndError.reset(new FPDErrorWarning(center, DetectorUnitType, m_strWorkPath)); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_INIT)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_WaitCalibDoseEvt = CreateEvent(NULL, FALSE, FALSE, NULL); m_PauseCalibrationEvt = CreateEvent(NULL, FALSE, FALSE, NULL); m_UploadCalibMapOver = CreateEvent(NULL, FALSE, FALSE, NULL); m_pFullImageHead = nullptr; m_pPreviewImageHead = nullptr; EventCenter = center; m_strCurrentAcqMode = ""; } nsFPD::FPDDevicePZMedical::~FPDDevicePZMedical() { if (m_pwFullImageData) { delete[]m_pwFullImageData; m_pwFullImageData = nullptr; } if (m_pwPreviewImg) { delete[]m_pwPreviewImg; m_pwPreviewImg = nullptr; } if (m_WaitCalibDoseEvt) { CloseHandle(m_WaitCalibDoseEvt); m_WaitCalibDoseEvt = nullptr; } if (m_PauseCalibrationEvt) { CloseHandle(m_PauseCalibrationEvt); m_PauseCalibrationEvt = nullptr; } if (m_UploadCalibMapOver) { CloseHandle(m_UploadCalibMapOver); m_UploadCalibMapOver = nullptr; } } std::string nsFPD::FPDDevicePZMedical::GetGUID() const { printf("--Func-- GetGUID \r\n"); //mLog::FINFO("--Func-- GetGUID"); return DetectorUnitType; } bool nsFPD::FPDDevicePZMedical::Prepare() { printf("--Func-- Prepare \r\n"); //mLog::FINFO("--Func-- device prepare"); EventCenter->OnMaxBlockSize("PZDmQue", 4000 * 4000 * 2, 3, 1500 * 1500 * 2, 1); Connect(); return true; } bool nsFPD::FPDDevicePZMedical::CreateDevice() { printf("--Func-- CreateDevice \r\n"); //mLog::FINFO("--Func-- CreateDevice"); if (!LoadConfig()) { return false; } if (nullptr == g_pDetector) { g_pDetector = new PZMedicalCtrl(); //mLog::FINFO("Create PZMedicalCtrl"); } else { //mLog::FERROR("PZMedicalCtrl Already exit"); } g_pDetector->DriverEntry(this, m_DetectorConfiguration->m_Configurations); return true; } void nsFPD::FPDDevicePZMedical::Register() { auto Disp = &Dispatch; RegisterCtrl(Disp); RegisterAcq(Disp); RegisterSync(Disp); RegisterCalib(Disp); RegisterOthers(Disp); } RET_STATUS nsFPD::FPDDevicePZMedical::Connect() { printf("--Func-- Connect \r\n"); //mLog::FINFO("--Func-- Connect"); RET_STATUS ret = RET_STATUS::RET_FAILED; //mLog::FINFO("Connect m_strWorkPath:{$}", m_strWorkPath.c_str()); if (g_pDetector->Connect(this, m_strWorkPath.c_str())) { ret = RET_STATUS::RET_SUCCEED; } return ret; } RET_STATUS nsFPD::FPDDevicePZMedical::EnterExam(int nExamMode) { //mLog::FINFO("--Func-- EnterExam {$}", nExamMode); switch (nExamMode) { case APP_STATUS_WORK_BEGIN: //mLog::FINFO("Enter into Exam Windows"); m_eAppStatus = APP_STATUS_WORK_BEGIN; break; case APP_STATUS_WORK_END: //mLog::FINFO("Quit Exam Windows"); m_eAppStatus = APP_STATUS_WORK_END; break; case APP_STATUS_DETSHARE_BEGIN: //mLog::FINFO("Enter into Detector Share Windows"); m_eAppStatus = APP_STATUS_DETSHARE_BEGIN; break; case APP_STATUS_DETSHAR_END: m_eAppStatus = APP_STATUS_IDLE; //mLog::FINFO("Quit Detector Share Windows"); m_eAppStatus = APP_STATUS_DETSHAR_END; break; case APP_STATUS_CAL_BEGIN: //mLog::FINFO("Enter into Calibration Windows"); m_eAppStatus = APP_STATUS_CAL_BEGIN; break; case APP_STATUS_CAL_END: //mLog::FINFO("Quit Calibration Windows"); m_eAppStatus = APP_STATUS_CAL_END; break; case APP_STATUS_WORK_IN_SENSITIVITY: //mLog::FINFO("Enter into sensitivity test interface"); m_eAppStatus = APP_STATUS_WORK_IN_SENSITIVITY; break; default: break; } g_pDetector->EnterExamMode(nExamMode); return RET_STATUS::RET_SUCCEED; } /*** * 这是切换探测器的接口 ***/ RET_STATUS nsFPD::FPDDevicePZMedical::ActiveDetector(int nDetectorIndex, bool bActive) { printf("--Func-- ActiveDetector(%d) to (%d) \r\n", nDetectorIndex, bActive); //mLog::FINFO("--Func-- ActiveDetector {$} to {$}", nDetectorIndex, bActive); RET_STATUS ret = RET_STATUS::RET_SUCCEED; if (g_pDetector == nullptr) { printf("PZMedicalCtrl object is not exist, return RET_FAILED\n"); //mLog::FERROR("PZMedicalCtrl object is not exist, return RET_FAILED"); return RET_STATUS::RET_FAILED; } return ret; } //品臻板目前不支持AEC bool nsFPD::FPDDevicePZMedical::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 { //mLog::FERROR("Not support mode!"); return false; } return true; } //设置采集模式 1-RAD 2-AEC RET_STATUS nsFPD::FPDDevicePZMedical::SetAcqMode(string strAcqMode) { printf("--Func-- SetAcqMode %s \n", strAcqMode.c_str()); //mLog::FINFO("--Func-- SetAcqMode {$}", strAcqMode); RET_STATUS ret = RET_STATUS::RET_FAILED; //如果没连接则返回 if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); return ret; } if (m_strCurrentAcqMode == strAcqMode) { //mLog::FINFO("Same acq mode, return true"); return RET_STATUS::RET_SUCCEED; } int nMode = RAD; bool bRet = GetLogicMode(strAcqMode, nMode); if (!bRet) { return ret; } try { ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations; int nModeCount = (int)objModeConfig["ModeTable"].size(); for (int i = 0; i < nModeCount; i++) { int nLogicMode = (int)objModeConfig["ModeTable"][i]["LogicMode"]; if (nLogicMode == nMode) { //mLog::FINFO("find LogicMode == AcqMode"); //由于3025ZF出图的宽高不定,所以宽高不从配置文件读取,上图之前调用接口查询宽高然后再推图 //m_nFullImageWidth = (int)objModeConfig["ModeTable"][i]["ImageWidth"]; //m_nFullImageHeight = (int)objModeConfig["ModeTable"][i]["ImageHeight"]; m_nImageBits = (int)objModeConfig["ModeTable"][i]["PhySizeInfoBit"]; m_nPixelSpacing = (int)objModeConfig["ModeTable"][i]["PixelPitch"]; m_nSensitivity = (int)objModeConfig["ModeTable"][i]["Sensitivity"]; m_eSyncMode = (SYNC_MODE)(int)objModeConfig["ModeTable"][i]["SyncType"]; m_nRotateAngle = (int)objModeConfig["ModeTable"][i]["RotateAngle"]; //mLog::FINFO("m_nImageBits:{$},m_nPixelSpacing:{$},m_nSensitivity:{$},m_eSyncMode:{$},RotateAngle:{$}", m_nImageBits, m_nPixelSpacing, m_nSensitivity, (int)m_eSyncMode, m_nRotateAngle); string strSensitivity = to_string(m_nSensitivity); m_DetectorCtrlUnit->SetFPDSensitivity(strSensitivity); m_fFactorEXI2UGY = 100.0f / (float)atof(strSensitivity.c_str()) * 1.0f;//子系统将UI的TargetEXI 乘以 FPDSensitivity再传给imagesave,用作计算EXI和DI并填写ecm头 //mLog::FINFO("m_fFactorEXI2UGY = {$}", m_fFactorEXI2UGY); //读取DetectorMode配置,并为imagebuffer申请内存空间 if (g_pDetector->SetAcqMode(nLogicMode, this)) { ret = RET_STATUS::RET_SUCCEED; } break; } } } catch (ResDataObjectExption& e) { //mLog::FERROR("Read configuration failed, Error code: {$}", e.what()); } return ret; } RET_STATUS nsFPD::FPDDevicePZMedical::PrepareAcquisition() { printf("--Func-- PrepareAcquisition \n"); //mLog::FINFO("--Func-- PrepareAcquisition"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); return ret; } if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) || (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE)) { printf("PrepareAcquisition failed. Detector at Calibration status.\n"); //mLog::FERROR("PrepareAcquisition failed. Detector at Calibration status"); return ret; } if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus()) { printf("Detector already at Acq status.\n"); //mLog::FERROR("Detector already at Acq status"); ret = RET_STATUS::RET_SUCCEED; //进检查后退检查,如果再次调用prepare,在这里防护 } if (g_pDetector->PrepareAcquisition(this)) { ret = RET_STATUS::RET_SUCCEED; } //mLog::FINFO("--Func-- PrepareAcquisition over"); return ret; } RET_STATUS nsFPD::FPDDevicePZMedical::StartAcquisition(string in) { printf("--Func-- StartAcquisition \n"); //mLog::FINFO("--Func-- StartAcquisition"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); return ret; } if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus()) { if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) || (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE)) { printf("PrepareAcquisition failed. Detector at Calibration status.\n"); //mLog::FERROR("PrepareAcquisition failed. Detector at Calibration status."); } if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus()) { printf("Detector already at Acq status.\n"); //mLog::FERROR("Detector already at Acq status."); } } else { if (g_pDetector->StartAcquisition(this)) { ret = RET_STATUS::RET_SUCCEED; } else { printf("StartAcquisition fail!\n"); //mLog::FINFO("StartAcquisition fail!"); } } //mLog::FINFO("--Func-- StartAcquisition over"); return ret; } RET_STATUS nsFPD::FPDDevicePZMedical::StopAcquisition() { printf("--Func-- StopAcquisition \n"); //mLog::FINFO("--Func-- StopAcquisition"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); return ret; } if (DETECTOR_STATUS_STANDBY == m_DetectorCtrlUnit->GetDetectorStatus()) { printf("Detector status already is standby\n"); //mLog::FINFO("Detector status already is standby"); ret = RET_STATUS::RET_SUCCEED; } else { printf("StopAcquisition 111\n"); //mLog::FINFO("StopAcquisition 111"); if (g_pDetector->StopAcquisition(this)) { ret = RET_STATUS::RET_SUCCEED; m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//StopAcquisition } } //mLog::FINFO("--Func-- StopAcquisition over"); return ret; } RET_STATUS nsFPD::FPDDevicePZMedical::ActiveCalibration(CCOS_CALIBRATION_TYPE eType) { printf("--Func-- ActiveCalibration %d \n", eType); //mLog::FINFO("--Func-- ActiveCalibration type {$}", (int)eType); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { printf("Detector not connected, return\n"); //mLog::FERROR("Detector not connected, return"); return ret; } if (eType == CCOS_CALIBRATION_TYPE_NONE || eType == CCOS_CALIBRATION_TYPE_MAX) { return RET_STATUS::RET_INVALID; } if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus()) { printf("detector status is not standby!\n"); //mLog::FERROR("detector status is not standby!"); if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus()) { printf("ActiveCalibration->Detector at Acq status need stop acquisition\n"); //mLog::FERROR("ActiveCalibration->Detector at Acq status need stop acquisition"); printf("ActiveCalibration stop acquisition\n"); //mLog::FERROR("ActiveCalibration stop acquisition"); ret = StopAcquisition(); if (ret != RET_STATUS::RET_SUCCEED) { printf("stop acquisition error\n"); //mLog::FERROR("stop acquisition error"); return ret; } } } m_eAppStatus = APP_STATUS_CAL_BEGIN; if (eType == CCOS_CALIBRATION_TYPE_XRAY) { printf("calibration type: CCOS_CALIBRATION_TYPE_XRAY\n"); //mLog::FINFO("calibration type: CCOS_CALIBRATION_TYPE_XRAY"); int nCalibrationRounds = (int)m_CalibDoseList.size(); g_pDetector->SetReferenceNum(nCalibrationRounds); } if (g_pDetector->ActiveCalibration(this, eType)) { m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ACTIVE)); m_CalibUnit->SetCalibrationProgress("0"); if (eType == CCOS_CALIBRATION_TYPE_XRAY) { //mLog::FINFO("start to waitting CalibDoseEvt"); printf("start to waitting CalibDoseEvt\n"); DWORD nRet = WaitForSingleObject(m_WaitCalibDoseEvt, INFINITE); } m_nXrayCalibNum = 0; } else { printf("Active calibration failed!\n"); //mLog::FERROR("Active calibration failed!"); } //重置校正流程参数 m_nCalibCurrentCalibrationRound = 1; m_nCalibCurrentExposureIndex = 1; m_nCalibCurrentExposureNum = 0; ret = RET_STATUS::RET_SUCCEED; printf("ActiveCalibration over\n"); //mLog::FINFO("--Func-- ActiveCalibration over"); return ret; } RET_STATUS nsFPD::FPDDevicePZMedical::PrepareCalibration() { printf("--Func-- PrepareCalibration------ \n"); //mLog::FINFO("--Func-- PrepareCalibration"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { printf("Detector not connected, return\n"); //mLog::FERROR("Detector not connected, return"); return ret; } if (g_pDetector->PrepareCalibration(this)) { ret = RET_STATUS::RET_SUCCEED; } else { //mLog::FERROR("Prepare calibration failed"); } //mLog::FINFO("--Func-- PrepareCalibration over"); return ret; } RET_STATUS nsFPD::FPDDevicePZMedical::GetRequestedDose(std::string& strDose) { printf("--Func-- GetRequestedDose------ \n"); //mLog::FINFO("--Func-- GetRequestedDose"); if (!m_bConnect) { 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(); //mLog::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) { //mLog::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; //mLog::FINFO("Find target dose parameter"); break; } } } else { //mLog::FERROR("Can not support CalibrationType($)", (int)nCalibrationType); Ret = RET_STATUS::RET_FAILED; } if (bGetDoseInfo) { strDose = out.encode(); //mLog::FINFO("GetRequestedDose:{$}", strDose.c_str()); } else { //mLog::FERROR("GetRequestedDose failed"); } //mLog::FINFO("--Func-- GetRequestedDose over"); return Ret; } RET_STATUS nsFPD::FPDDevicePZMedical::StartCalibration() { printf("--Func-- StartCalibration------ \n"); //mLog::FINFO("--Func-- StartCalibration"); RET_STATUS Ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { Ret = RET_STATUS::RET_THREAD_INVALID; //mLog::FERROR("detector is not connected"); return Ret; } if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus()) { if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus()) { //mLog::FERROR("ActiveCalibration failed. Detector at Acq status"); } Ret = RET_STATUS::RET_FAILED; return Ret; } if (g_pDetector->StartCalibration(this)) { printf("start calibration success set detector status\n"); //mLog::FINFO("start calibration success set detector status"); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING)); Ret = RET_STATUS::RET_SUCCEED; } else { Ret = RET_STATUS::RET_FAILED; } printf("StartCalibration over\n"); //mLog::FINFO("--Func-- StartCalibration over"); return Ret; } RET_STATUS nsFPD::FPDDevicePZMedical::StopCalibration() { printf("--Func-- StopCalibration------ \n"); //mLog::FINFO("--Func-- StopCalibration"); RET_STATUS Ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); return Ret; } m_eAppStatus = APP_STATUS_CAL_END; if (RET_STATUS::RET_SUCCEED == g_pDetector->AbortCalibration(this)) { m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); Ret = RET_STATUS::RET_SUCCEED; m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//AbortCalibration } else { Ret = RET_STATUS::RET_FAILED; } //mLog::FINFO("--Func-- StopCalibration over"); return Ret; } //create device 时调用 bool nsFPD::FPDDevicePZMedical::LoadConfig() { printf("--Func-- LoadConfig \r\n"); //mLog::FINFO("--Func-- LoadConfig"); if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_ACQMODElist)) { //mLog::FERROR("Load configuration file failed!!!"); return false; } if (!m_DetectorConfiguration->LoadCalibrationDose(m_strWorkPath, m_CalibDoseList, m_nCalibTotalExposureNum)) { //mLog::FERROR("Load Calibration Dose failed!!!"); return false; } if (m_stDeviceConfig.nForceGridSuppress > 0) { m_bForceGridSuppress = true; } else { m_bForceGridSuppress = false; } int nAttached = (int)m_DetectorConfiguration->m_Configurations[CcosDetectorAttachedFlag]; if (nAttached == 1) { m_DetectorCtrlUnit->SetAttachStatus("1"); } else { m_DetectorCtrlUnit->SetAttachStatus("0"); } string strTemp = (string)m_DetectorConfiguration->m_Configurations[DetectorModel]; m_DetectorCtrlUnit->SetDetectorType(strTemp); strTemp = (string)m_DetectorConfiguration->m_Configurations[DetectorDescription]; m_DetectorCtrlUnit->SetDescription(strTemp); 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)); return true; } void nsFPD::FPDDevicePZMedical::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::RecoverImage, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRecoverImage); Dispatch->Action.Push(ActionKey::SaveSensitivity, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSaveSensitivity); Dispatch->Action.Push(ActionKey::RESET, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSRESET); 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::FPDShockSensorInfo, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetShockSensorInfo); Dispatch->Get.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDStatus); Dispatch->Get.Push(AttrKey::FPDAttached, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachStatus); Dispatch->Get.Push(AttrKey::DetectorAttach, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetAttachResult); 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::FPDDevicePZMedical::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::FPDDevicePZMedical::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::XrayON, m_SyncUnit.get(), &SyncUnit::JSGetXrayON); Dispatch->Get.Push(AttrKey::SyncMode, m_SyncUnit.get(), &SyncUnit::JSGetSyncMode); } void nsFPD::FPDDevicePZMedical::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::FPDDevicePZMedical::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::FPDDevicePZMedical::SendTemperatureValue(float fValue) { int nStatus = 0; m_Temperature->SetTemperature(fValue, nStatus); //mLog::FINFO("SendTemperatureValue: {$}, status {$}", fValue, nStatus); } void nsFPD::FPDDevicePZMedical::SendWifiValue(int nValue) { int nStatus = 0; m_Wifi->SetSignalValue(nValue, nStatus); //mLog::FINFO("SendWifiValue: {$}, status {$}", nValue, nStatus); } void nsFPD::FPDDevicePZMedical::SendBatteryValue(int nValue) { int nStatus = 0; m_Battery->SetRemainPowerValue(nValue, nStatus); //mLog::FINFO("SendBatteryValue: {$}, status {$}", nValue, nStatus); } /// /// 探测器设备 所有 事件处理入口 @PZ_FPD /// conf/info/status/data/warning/error /// /// /// /// /// /// /// /// /// void nsFPD::FPDDevicePZMedical::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; } } int nsFPD::FPDDevicePZMedical::GetGainExposureNum() { return m_nCalibTotalExposureNum; } WORD* nsFPD::FPDDevicePZMedical::GetFullImageData() { return m_pwFullImageData; } /// /// 探测器设备 配置 事件处理 @PZ_FPD /// 暂不支持 配置 /// /// /// /// /// /// /// /// /// void nsFPD::FPDDevicePZMedical::OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { switch (nEventID) { case EVT_CONF_PANEL_SERIAL: { m_stDeviceConfig.strPanelSerial = pszMsg; //mLog::FINFO("Detector ID:{$}, SN {$}", nDetectorID, pszMsg); m_DetectorCtrlUnit->SetDetectorID(m_stDeviceConfig.strPanelSerial); break; } case EVT_CONF_RAW_WIDTH: { m_nFullImageWidth = nParam1; m_stDeviceConfig.nFullImageWidth = nParam1; //mLog::FINFO("Call back Detector ID:{$}, Image Width:{$}", nDetectorID, m_nFullImageWidth); break; } case EVT_CONF_RAW_HIGHT: { m_nFullImageHeight = nParam1; m_stDeviceConfig.nFullImageHeight = nParam1; //mLog::FINFO("Call back Detector ID:{$}, Image Height:{$}", nDetectorID, m_nFullImageHeight); break; } case EVT_CONF_RAW_BITS: { m_nImageBits = nParam1; m_stDeviceConfig.nImageBits = nParam1; //mLog::FINFO("Detector ID:{$}, Image Bit:{$}", nDetectorID, m_nImageBits); break; } case EVT_CONF_PIXELSPACE: { m_nPixelSpacing = (int)fParam2;; m_stDeviceConfig.nPixelSpace = (int)fParam2; //mLog::FINFO("Detector ID:{$}, nPixelSpace:{$}", nDetectorID, m_nPixelSpacing); break; } case EVT_CONF_PREVIEW_WIDTH: { if (m_stDeviceConfig.nPreviewWidth != nParam1) { m_stDeviceConfig.nPreviewWidth = nParam1; } //mLog::FINFO("Detector ID:{$}, nPreviewWidth:{$}", nDetectorID, m_stDeviceConfig.nPreviewWidth); break; } case EVT_CONF_PREVIEW_HIGHT: { if (m_stDeviceConfig.nPreviewHeight != nParam1) { m_stDeviceConfig.nPreviewHeight = nParam1; } //mLog::FINFO("Detector ID:{$}, nPreviewHeight:{$}", nDetectorID, m_stDeviceConfig.nPreviewHeight); break; } case EVT_CONF_MODULE_TYPE: { //m_strModuleType = pszMsg; //mLog::FINFO("Detector ID:{$}, ModuleType {$}", nDetectorID, pszMsg); break; } case EVT_CONF_MODULE_IP: { //m_strModuleIP = pszMsg; //mLog::FINFO("Detector ID:{$}, ModuleIP {$}", nDetectorID, pszMsg); break; } case EVT_CONF_MODULE_SN: { //m_strModuleSN = pszMsg; //mLog::FINFO("Detector ID:{$}, ModuleSN {$}", nDetectorID, pszMsg); break; } case EVT_CONF_FIRWARE_UPDATE: { m_stDeviceConfig.nFirmwareStatus = nParam1; //mLog::FINFO("Detector ID:{$}, FirmwareUpdate:{$}", nDetectorID, m_stDeviceConfig.nFirmwareStatus); break; } case EVT_CONF_PART_NUMBER: { m_stDeviceConfig.strPartNumber = pszMsg; //mLog::FINFO("Detector ID:{$}, PartNumber:{$}", nDetectorID, pszMsg); break; } case EVT_CONF_BATTERY_SN: { //m_strBatterySN = pszMsg; //mLog::FINFO("Detector ID:{$}, Battery SN:{$}", nDetectorID, pszMsg); break; } case EVT_CONF_WIFI_SSID: { m_stDeviceConfig.strWifiSSID = pszMsg; //mLog::FINFO("Detector ID:{$}, WifiSSID:{$}", nDetectorID, pszMsg); break; } case EVT_CONF_IFBOARD: { m_stDeviceConfig.strInterfaceBoard = pszMsg; //mLog::FINFO("Detector ID:{$}, InterfaceBoard:{$}", nDetectorID, pszMsg); break; } case EVT_CONF_DATECODE: { m_stDeviceConfig.strDateCode = pszMsg; //mLog::FINFO("Detector ID:{$}, DateCode:{$}", nDetectorID, pszMsg); break; } case EVT_CONF_LIFETIME: { int nLifeTime = nParam1; if ((nLifeTime != m_stDeviceConfig.nLifeTime)) { //mLog::FINFO("LifeTime:{$}", nLifeTime); m_stDeviceConfig.nLifeTime = nLifeTime; } break; } default: break; } } /// /// 探测器设备 Info 事件处理 @PZ_FPD /// 暂不支持 Info /// /// /// /// /// /// /// /// /// void nsFPD::FPDDevicePZMedical::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; //mLog::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 != "")*/) { //mLog::FINFO("{$}", nBatteryCapacity); m_nBatteryCapacity = nBatteryCapacity; } break; } case EVT_INFO_BATTERY_TEMPERATURE: { float fBatteryTemper = fParam2; if (((fBatteryTemper - m_fBatteryTemperature) >= 0.1f) /*&& (m_strBatterySN != "")*/) { //mLog::FINFO("temperature:%.2f", fBatteryTemper); m_fBatteryTemperature = fBatteryTemper; } break; } case EVT_INFO_BATTERY_CHARGES: { int nBatteryCharges = nParam1; if ((nBatteryCharges != m_nBatteryCharges)/* && (m_strBatterySN != "")*/) { //mLog::FINFO("Charge number:{$}", nBatteryCharges); m_nBatteryCharges = nBatteryCharges; } break; } case EVT_INFO_WIFI_DATARATE: { m_stDeviceConfig.nWifiDataRate = nParam1; //mLog::FINFO("Detector {$} WifiDataRate:{$}", nID, m_stDeviceConfig.nWifiDataRate); break; } case EVT_INFO_WIFI_CHANNEL: { m_stDeviceConfig.nWifiChannel = nParam1; //mLog::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; //mLog::FINFO("Panel {$} WifiNoisePower:{$}", nID, m_stDeviceConfig.nWifiNoisePower); break; } case EVT_INFO_FIRMWARE: { m_stDeviceConfig.strFirmware = pszMsg; //mLog::FINFO("Panel {$} Firmware:{$}", nID, pszMsg); break; } case EVT_INFO_SHOCKSENSOR_INFO: { //mLog::FINFO("Receive ShockSensor Info"); //m_strShockSensor = pszMsg; //m_DetectorCtrlUnit->SetShockSensorInfo(m_strShockSensor); break; } case EVT_INFO_CALIBRATIOIN_TIME: { m_stDeviceConfig.strCalibrationDate = pszMsg; //mLog::FINFO("Panel {$} Calibration Time:{$}", nID, pszMsg); m_DetectorCtrlUnit->SetDateofLastDetectorCalibration(m_stDeviceConfig.strCalibrationDate); m_DetectorCtrlUnit->SetTimeofLastDetectorCalibration(""); break; } case EVT_INFO_CALIBRATIOIN_TIMEL: { m_stDeviceConfig.strCalibrationLTEDate = pszMsg; //mLog::FINFO("Panel {$} Calibration LTE Time:{$}", nID, pszMsg); break; } case EVT_INFO_FPVOLTAGE: { //m_strVoltage = pszMsg; break; } default: break; } } /// /// 探测器设备状态事件 处理@PZ_FPD /// /// /// /// /// /// /// /// /// void nsFPD::FPDDevicePZMedical::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) { //mLog::FINFO("EVT_STATUS_INIT PANEL_EVENT_END_OK"); 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) { //mLog::FINFO("Start update firmware"); m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_START)); } else if (PANEL_EVENT_BEGIN == nParam1) { //mLog::FINFO("Update firmware begin"); m_stDeviceConfig.bConnectStatus = false; m_bConnect = false; } else if (PANEL_EVENT_END_ERROR == nParam1) { //mLog::FINFO("Update firmware failed"); //SendDetectorInfo(); //更新探测器状态图标 m_DetectorCtrlUnit->SetUpdateFWStatus(to_string(DETECTOR_UFW_ERROR)); } else if (PANEL_EVENT_SUCCESS == nParam1) // { //mLog::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失败时,不将第二次的失败信息发送给客户端 //mLog::FINFO("New Detector Attach start"); break; case PANEL_ATTACH_OVER: { //mLog::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 { //mLog::FERROR("New Detector Attach failed\n"); m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_ATTACH_FAILED)); break; } case PANEL_CONNECT_OK: { //mLog::FINFO("EVT_STATUS_DETECTORSHARE PANEL_CONNECT_OK"); m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK)); 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_bConnect = 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) { m_SystemTime = { 0 }; GetLocalTime(&m_SystemTime); //mLog::FINFO("XWindow on time {$}:{$}:{$}:{$}", m_SystemTime.wHour, m_SystemTime.wMinute, m_SystemTime.wSecond, m_SystemTime.wMilliseconds); m_SyncUnit->XWindowOnNotify(); } else if (PANEL_XWINDOW_OFF == nParam1) { m_SystemTime = { 0 }; GetLocalTime(&m_SystemTime); //mLog::FINFO("XWindow off time {$}:{$}:{$}:{$}", m_SystemTime.wHour, m_SystemTime.wMinute, m_SystemTime.wSecond, m_SystemTime.wMilliseconds); m_SyncUnit->XWindowOffNotify(); } else if (PANEL_READY_EXP == nParam1) { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//PANEL_READY_EXP } else if (PANEL_XRAY_ON == nParam1) { m_SyncUnit->XrayOnNotify(); } else if (PANEL_XRAY_OFF == nParam1) { m_SyncUnit->XrayOffNotify(); } else if (PANEL_START_ACQ == nParam1) { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ)); } break; } case EVT_STATUS_CALIBRATIOIN: { ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1; switch (eStatus) { case PANEL_EVENT_END_OK: //mLog::FINFO("Calibration process end ok"); CompleteCalibration(); break; case PANEL_EVENT_END_ERROR: //mLog::FINFO("Calibration process end error"); break; case PANEL_EVENT_START: //mLog::FINFO("Calibration process start"); break; case PANEL_EVENT_SUCCESS: //mLog::FINFO("Calibration process success"); break; case PANEL_EVENT_END: //mLog::FINFO("Calibration process end"); break; case PANEL_EVENT_BEGIN: //mLog::FINFO("Calibration process begin"); break; case PANEL_EVENT_TIMEOUT: //mLog::FINFO("Calibration timeout"); break; default: break; } break; } case EVT_STATUS_SAVECALIB: { if (PANEL_EVENT_START == nParam1) { //mLog::FINFO("Begin to Save Calibration Files"); } else if (PANEL_EVENT_END_ERROR == nParam1) { //mLog::FINFO("Save Calibration Files failed"); SetEvent(m_UploadCalibMapOver); } else if (PANEL_EVENT_END == nParam1) { //mLog::FINFO("Save Calibration Files Success"); SetEvent(m_UploadCalibMapOver); } break; } case EVT_STATUS_SAVEDEFECT: { if (PANEL_EVENT_START == nParam1) { //mLog::FINFO("Begin to Save Defect Files"); } else if (PANEL_EVENT_END_ERROR == nParam1) { //mLog::FINFO("Save Defect Files failed"); SetEvent(m_UploadCalibMapOver); } else if (PANEL_EVENT_END == nParam1) { //mLog::FINFO("Save Defect Files Success"); m_stDeviceConfig.bTaskEnd = true; SetEvent(m_UploadCalibMapOver); } break; } case EVT_STATUS_ACQUISITION: { ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1; switch (eStatus) { case PANEL_EVENT_START: //mLog::FINFO("Acquisition start"); break; case PANEL_EVENT_END_OK: //mLog::FINFO("Acquisition end"); break; case PANEL_EVENT_END_ERROR: //目前不会报错,不会走到这里 break; default: break; } break; } case EVT_STATUS_SINGLEEXP: { if (DOSE_TOO_HIGH == nParam1) { //mLog::FINFO("Dose too high"); StopCalibration(); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_CalibUnit->SetCalibrationProgress("100");//make progress m_AcqUnit->SendNoNeedWaitImage(true); } else if (DOSE_TOO_LOW == nParam1) { //mLog::FINFO("Dose too low"); StopCalibration(); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_CalibUnit->SetCalibrationProgress("100");//make progress m_AcqUnit->SendNoNeedWaitImage(true); } else if (DOSE_OBJECT == nParam1) { //mLog::FINFO("Dose object"); StopCalibration(); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); //m_CalibUnit->SetCalibrationProgress(100);//make progress m_AcqUnit->SendNoNeedWaitImage(true); } else if (DOSE_ACCEPT == nParam1) { //mLog::FINFO("Calibration Result is acceptable"); //m_WarnAndError->OnErrorX("ERR_FPD_DOSE_INVALID"); SetEvent(m_PauseCalibrationEvt); } else if (EVT_STATUS_LASTERROR == nParam1) { //m_strLastError = pszMsg; ////mLog::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; } break; } case EVT_STATUS_TEMPERATURE: { float fTemperature = fParam2; OnProcessTemperature(nDetectorID, fTemperature); m_stDeviceConfig.fCurrentTemperValue = fTemperature; ////mLog::FINFO("Detector {$} Temperature Value:{$}", nDetectorID, fTemperature); SendTemperatureValue(m_stDeviceConfig.fCurrentTemperValue); break; } case EVT_STATUS_WIFI: { int nWifiLevel = nParam1; if (m_stDeviceConfig.strDeviceName.find("PZMEDICAL") >= 0 || m_stDeviceConfig.strDeviceName.find("PZMedical") >= 0) { nWifiLevel = int(nWifiLevel / 0.75); if (nWifiLevel > 100) { nWifiLevel = 100; } } //mLog::FINFO("Detector {$} Wifi Value:{$}", nDetectorID, nWifiLevel); if (nWifiLevel == 0) //WIFI值为0 表明是有线连接,不报错 { //mLog::FINFO("nWifiLevel == 0, wired connection"); } else if (nWifiLevel < m_stDeviceConfig.nWifiLimit) { //达到wifi最低值限制 } else if (nWifiLevel <= m_stDeviceConfig.nWifiWarning) { //达到wifi警告值 } //mLog::FINFO("detector wifi level:%d", nWifiLevel); if (nWifiLevel != m_stDeviceConfig.nCurrentWifiValue) { //mLog::FINFO("Channel:{$},SignalPower:{$},NoisePower:{$},DataRate:{$}", m_stDeviceConfig.nWifiChannel, m_stDeviceConfig.nWifiSignalPower, m_stDeviceConfig.nWifiNoisePower, m_stDeviceConfig.nWifiDataRate); } m_stDeviceConfig.nCurrentWifiValue = nWifiLevel; SendWifiValue(m_stDeviceConfig.nCurrentWifiValue); break; } case EVT_STATUS_BATTERY_VALUE: { int nBatteryValue = nParam1; m_stDeviceConfig.nCurrentBatteryValue = nBatteryValue; //mLog::FINFO("Detector {$} Battery Value:{$}", nDetectorID, nBatteryValue); SendBatteryValue(m_stDeviceConfig.nCurrentBatteryValue); break; } case EVT_STATUS_BATTERY_CHARGING: { break; } case EVT_STATUS_SHOCK_SENSOR: { break; } case EVT_STATUS_HALL_SENSOR: { break; } case EVT_STATUS_PING: { break; } case EVT_STATUS_PMSNOTOPEN: { string strTemp = pszMsg; if (strTemp.find("true") != std::string::npos) { //mLog::FINFO("PMS isn't open"); } break; } case EVT_STATUS_RESTOREFILES: { break; } case EVT_STATUS_LASTERROR: { 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: { //mLog::FINFO("EVT_AUTONUMOUS_STATUS PANEL_CONNECT_OK"); m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK)); m_stDeviceConfig.bConnectStatus = true; m_bConnect = true;//EVT_AUTONUMOUS_STATUS break; } case PANEL_DISCONNECT_SUCCESS: { m_nBatteryCapacity = 0; m_stDeviceConfig.bExisted = false; m_stDeviceConfig.bConnectStatus = false; m_bConnect = 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: { //mLog::FINFO("Send start autonumous to server"); m_AcqUnit->SendAutonumousMapFinish(0); break; } case PANEL_END_STOREDIMAGE: { //mLog::FINFO("Send finish autonumous to server"); m_AcqUnit->SendAutonumousMapFinish(1); break; } case PANEL_EXPORT_AUTONUMOUS_FINISH: { //mLog::FINFO("Send finish export local autonumous to server"); m_AcqUnit->SendAutonumousMapFinish(2); break; } default: break; } break; } default: break; } } /// /// 探测器设备图像数据事件 处理 @PZ_FPD /// /// /// /// /// /// /// /// /// void nsFPD::FPDDevicePZMedical::OnEventProcessData(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { switch (nEventID) { case EVT_DATA_RAW_IMAGE: { //mLog::FINFO("Image Arrived Width:{$},Image Height:{$}", m_nFullImageWidth, m_nFullImageHeight); if (m_nRotateAngle == 90 || m_nRotateAngle == 270) { m_AcqUnit->SetFulImageInfo(m_nFullImageWidth, m_nFullImageHeight, m_nImageBits, false); } else { m_AcqUnit->SetFulImageInfo(m_nFullImageHeight, m_nFullImageWidth, m_nImageBits, false); } m_AcqUnit->ImagerPixelSpacingNotify(m_nPixelSpacing); if (nullptr != m_pwFullImageData) { delete m_pwFullImageData; m_pwFullImageData = nullptr; } m_pwFullImageData = new WORD[m_nFullImageWidth * m_nFullImageHeight]; memcpy(m_pwFullImageData, pParam, m_nFullImageWidth * m_nFullImageHeight * sizeof(WORD)); if (0 != m_nRotateAngle) { //mLog::FINFO("rotate image, m_nRotateAngle:{$}", m_nRotateAngle); m_AcqUnit->RotateImage(m_pwFullImageData, m_nFullImageHeight, m_nFullImageWidth, m_nRotateAngle); } OnProcessImage(m_pwFullImageData); break; } case EVT_DATA_PREVIEW_IMAGE: { //mLog::FINFO("Preview Image Arrved"); //mLog::FINFO("Current FPD preview image width: %d, height: %d", m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight); m_SyncUnit->ImageReadingNotify(); if (NULL == m_pwPreviewImg) { m_pwPreviewImg = new WORD[m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight]; } memcpy(m_pwPreviewImg, pParam, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight * sizeof(WORD)); OnProcessPreviewImage(m_pwPreviewImg, m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight); break; } case EVT_DATA_DOSEPARAM: { m_fDoseParam = fParam2; SetEvent(m_WaitCalibDoseEvt); break; } default: //mLog::FERROR("Not support this eventID (%d)", nEventID); break; } } /// /// 探测器设备 ERROR 事件处理 @PZ_FPD /// /// /// /// /// /// /// /// /// void nsFPD::FPDDevicePZMedical::OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { switch (nEventID) { case EVT_ERR_COMMUNICATE: { string strTemp = pszMsg; if (strTemp.find("true") != std::string::npos) { m_stDeviceConfig.nWorkstation = -1; m_stDeviceConfig.bConnectStatus = false; m_bConnect = 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); m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_SHUTDOWN)); m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS)); } else if (strTemp.find("false") != std::string::npos) { //mLog::FINFO("EVT_ERR_COMMUNICATE false"); m_stDeviceConfig.bConnectStatus = true; m_bConnect = true;//EVT_ERR_COMMUNICATE m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_READY)); m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK)); } break; } case EVT_ERR_EXP_REQUEST: //mLog::FERROR("OnEventProcessError EVT_ERR_EXP_REQUEST"); break; case EVT_ERR_GET_IMAGE: //mLog::FERROR("OnEventProcessError EVT_ERR_GET_IMAGE"); break; case EVT_ERR_MAX_NUMBER: //mLog::FERROR("OnEventProcessError EVT_ERR_MAX_NUMBER"); break; case EVT_ERR_SN_NOTINLIST: //mLog::FERROR("OnEventProcessError EVT_ERR_SN_NOTINLIST"); break; case EVT_ERR_POWER_OFF: //mLog::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: //mLog::FERROR("Not support this error(%d)", nEventID); break; } } /// /// 探测器设备 WARNING 事件 处理 @PZ_FPD /// 当前版本不支持,TBD. /// /// /// /// /// /// /// /// /// void nsFPD::FPDDevicePZMedical::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { //mLog::FERROR("Not support this warn(%d)", nEventID); } bool nsFPD::FPDDevicePZMedical::OnProcessPreviewImage(WORD* pwRawImage, int nWidth, int nHeight) { //mLog::FINFO("--Func-- OnProcessPreviewImage Width:{$},Height:{$}", m_stDeviceConfig.nPreviewWidth, m_stDeviceConfig.nPreviewHeight); PrevImageDateArrived(pwRawImage); return true; } void nsFPD::FPDDevicePZMedical::PrevImageDateArrived(WORD* pImg) { AddFrameWithRawHead(IMAGE_PREVIEW, pImg, m_stDeviceConfig.nPreviewWidth * m_stDeviceConfig.nPreviewHeight); } RET_STATUS nsFPD::FPDDevicePZMedical::AddFrameWithRawHead(IMAGE_VIEW_TYPE Type, WORD* pFrameBuff, DWORD FrameSize) { string strImageHead = MakeImageHead(Type); //mLog::FINFO("str image head:{$}",strImageHead); return m_AcqUnit->AddFrameWithRawHead(Type, strImageHead, pFrameBuff, FrameSize); } string nsFPD::FPDDevicePZMedical::MakeImageHead(IMAGE_VIEW_TYPE Type) { if (m_pFullImageHead != NULL) { delete m_pFullImageHead; m_pFullImageHead = nullptr; } m_SystemTime = { 0 }; GetLocalTime(&m_SystemTime); if (Type == IMAGE_FULL) { if (m_pFullImageHead == NULL) { m_pFullImageHead = new ResDataObject; ResDataObject json; json.add(SM_IMAGE_TYPE, (int)Type); json.add(SM_IMAGE_BIT, 16); json.add(SM_IMAGE_TAG, 1); json.add(SM_IMAGE_INDEX, 1); json.add(SM_IMAGE_YEAR, m_SystemTime.wYear); json.add(SM_IMAGE_MONTH, m_SystemTime.wMonth); json.add(SM_IMAGE_DAY, m_SystemTime.wDay); json.add(SM_IMAGE_HOUR, m_SystemTime.wHour); json.add(SM_IMAGE_MINUTE, m_SystemTime.wMinute); json.add(SM_IMAGE_SEC, m_SystemTime.wSecond); json.add(SM_IMAGE_MILLSEC, m_SystemTime.wMilliseconds); json.add(SM_IMAGE_LSB, "5000"); json.add(SM_IMAGE_DOSE, m_nSensitivity); json.add(SM_IMAGE_PIXELREPRESENTATION, "1"); json.add(SM_IMAGE_PIXELSPACING, m_nPixelSpacing); 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); if (90 == m_nRotateAngle || 270 == m_nRotateAngle) { json.add(SM_IMAGE_WIDTH, m_nFullImageHeight); json.add(SM_IMAGE_HEIGHT, m_nFullImageWidth); json.add(SM_IMAGE_ROTATION, "Yes"); } else if (180 == m_nRotateAngle) { json.add(SM_IMAGE_WIDTH, m_nFullImageWidth); json.add(SM_IMAGE_HEIGHT, m_nFullImageHeight); json.add(SM_IMAGE_ROTATION, "Yes"); } else { json.add(SM_IMAGE_WIDTH, m_nFullImageWidth); json.add(SM_IMAGE_HEIGHT, m_nFullImageHeight); json.add(SM_IMAGE_ROTATION, "No"); } m_pFullImageHead->add(SM_IMAGE_HEAD, json); } else { (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_YEAR] = m_SystemTime.wYear; (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MONTH] = m_SystemTime.wMonth; (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_DAY] = m_SystemTime.wDay; (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_HOUR] = m_SystemTime.wHour; (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MINUTE] = m_SystemTime.wMinute; (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_SEC] = m_SystemTime.wSecond; (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MILLSEC] = m_SystemTime.wMilliseconds; (*m_pFullImageHead)[SM_IMAGE_HEAD][SM_IMAGE_TEMP] = m_stDeviceConfig.fCurrentTemperValue; } return (*m_pFullImageHead).encode(); } else { if (m_pPreviewImageHead == NULL) { m_pPreviewImageHead = new ResDataObject; ResDataObject json; json.add(SM_IMAGE_TYPE, (int)Type); json.add(SM_IMAGE_WIDTH, m_stDeviceConfig.nPreviewWidth); json.add(SM_IMAGE_HEIGHT, m_stDeviceConfig.nPreviewHeight); json.add(SM_IMAGE_BIT, 16); json.add(SM_IMAGE_TAG, 1); json.add(SM_IMAGE_INDEX, 1); json.add(SM_IMAGE_YEAR, m_SystemTime.wYear); json.add(SM_IMAGE_MONTH, m_SystemTime.wMonth); json.add(SM_IMAGE_DAY, m_SystemTime.wDay); json.add(SM_IMAGE_HOUR, m_SystemTime.wHour); json.add(SM_IMAGE_MINUTE, m_SystemTime.wMinute); json.add(SM_IMAGE_SEC, m_SystemTime.wSecond); json.add(SM_IMAGE_MILLSEC, m_SystemTime.wMilliseconds); json.add(SM_IMAGE_LSB, "5000"); json.add(SM_IMAGE_DOSE, m_nSensitivity); 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_nPixelSpacing); 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_SystemTime.wYear; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MONTH] = m_SystemTime.wMonth; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_DAY] = m_SystemTime.wDay; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_HOUR] = m_SystemTime.wHour; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MINUTE] = m_SystemTime.wMinute; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_SEC] = m_SystemTime.wSecond; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_MILLSEC] = m_SystemTime.wMilliseconds; (*m_pPreviewImageHead)[SM_IMAGE_HEAD][SM_IMAGE_TEMP] = m_stDeviceConfig.fCurrentTemperValue; } return (*m_pPreviewImageHead).encode(); } } bool nsFPD::FPDDevicePZMedical::OnProcessImage(WORD* pwRawImage) { //mLog::FINFO("--Func-- OnProcessImage"); if (pwRawImage == NULL) { //mLog::FERROR("pwRawImage is null!"); return false; } FullImageDateArrived(pwRawImage); //mLog::FINFO("OnProcessImage Write Frame Over"); return true; } RET_STATUS nsFPD::FPDDevicePZMedical::AcceptCalibration() { printf("--func-- AcceptCalibration\n"); //mLog::FINFO("--Func-- AcceptCalibration"); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; if (g_pDetector->AcceptCalibration()) { //mLog::FINFO("AcceptCalibration over"); Ret = RET_STATUS::RET_SUCCEED; } else { //mLog::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)) { //mLog::FINFO("Calibration Round: {$}, Exposure Index: {$}, Finished", m_nCalibCurrentCalibrationRound, m_nCalibCurrentExposureIndex); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//expose over m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_CalibUnit->SetCalibrationProgress("100"); return Ret; } if (m_nCalibCurrentExposureIndex >= nExposureNumCurrentRound) //跳到下一轮校正参数 { m_nCalibCurrentCalibrationRound++; m_nCalibCurrentExposureIndex = 1; ResDataObject temp = m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]; int nDose = temp["Dose"]; m_fDoseParam = nDose / 1000.0f; } else { m_nCalibCurrentExposureIndex++; } m_nCalibCurrentExposureNum++; m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//AcceptCalibration //mLog::FINFO("--func-- AcceptCalibration over"); return Ret; } RET_STATUS nsFPD::FPDDevicePZMedical::RejectCalibration() { printf("--Func-- RejectCalibration \n"); //mLog::FINFO("--func-- RejectCalibration"); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; if (g_pDetector->RejectCalibration()) { Ret = RET_STATUS::RET_SUCCEED; } else { //mLog::FERROR("RejectCalibration error"); Ret = RET_STATUS::RET_FAILED; } m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//RejectCalibration //mLog::FINFO("--func-- RejectCalibration over"); return Ret; } RET_STATUS nsFPD::FPDDevicePZMedical::SaveCalibrationFile(bool bSaveFlag) { printf("--Func-- SaveCalibrationFile \n"); //mLog::FINFO("--func-- SaveCalibrationFile"); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; //mLog::FINFO("SaveCalibrationFile by user: {$}", bSaveFlag); if (!bSaveFlag) { //mLog::FERROR("Not save calibration file"); return Ret; } if (g_pDetector->SaveCalibrationFile()) { //mLog::FINFO("SaveCalibrationFile over"); m_CalibUnit->SetSaveCalibrationFileFinish(true); Ret = RET_STATUS::RET_SUCCEED; } else { //mLog::FERROR("SaveCalibrationFile error"); m_CalibUnit->SetSaveCalibrationFileFinish(false); Ret = RET_STATUS::RET_FAILED; } //mLog::FINFO("--func-- SaveCalibrationFile over"); return Ret; } void nsFPD::FPDDevicePZMedical::FullImageDateArrived(WORD* pImg) { //mLog::FINFO("--func-- FullImageDateArrived"); AddFrameWithRawHead(IMAGE_FULL, pImg, m_nFullImageWidth * m_nFullImageHeight); } RET_STATUS nsFPD::FPDDevicePZMedical::SetRequestedDose(std::string strDose) { //mLog::FINFO("--func-- SetRequestedDose"); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; return Ret; } RET_STATUS nsFPD::FPDDevicePZMedical::GetCalibrationStep(int nDetectorID, string& strCalibrationStepInfo) { printf("--func-- GetCalibrationStep\n"); //mLog::FINFO("--func-- GetCalibrationStep"); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; //mLog::FINFO("Calibration DetectorID: {$}", nDetectorID); 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)) { //mLog::FINFO("PZMedicalCtrl GetCalibrationStep success"); Ret = RET_STATUS::RET_SUCCEED; } else { //mLog::FERROR("GetCalibrationStep error"); Ret = RET_STATUS::RET_FAILED; } out.add("CalibrationRounds", (int)m_CalibDoseList.size()); out.add("TotalExposureNum", m_nCalibTotalExposureNum); out.add("CurrentCalibrationRound", m_nCalibCurrentCalibrationRound); out.add("ExposureNumCurrentRound", (int)m_CalibDoseList[m_nCalibCurrentCalibrationRound - 1]["ExpNum"]); out.add("CurrentExposureIndex", m_nCalibCurrentExposureIndex); out.add("CurrentExposureNum", m_nCalibCurrentExposureNum); strCalibrationStepInfo = out.encode(); //mLog::FINFO("GetCalibrationStep over,strCalibrationStepInfo: {$}", strCalibrationStepInfo.c_str()); return Ret; } RET_STATUS nsFPD::FPDDevicePZMedical::PauseCalibration() { printf("--Func-- PauseCalibration\n"); //mLog::FINFO("--func-- PauseCalibration"); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; m_nXrayCalibNum++; int nDose = (int)m_fDoseParam; if (nDose == 25 && m_nXrayCalibNum == m_nCalibTotalExposureNum) { //mLog::FINFO("start to waitting CalibDoseEvt"); DWORD nRet = WaitForSingleObject(m_WaitCalibDoseEvt, INFINITE); //m_nXrayCalibNum = 0; } else if (nDose != 25) { if (m_nXrayCalibNum != m_nCalibTotalExposureNum) { //mLog::FINFO("start to waitting CalibDoseEvt"); DWORD nRet = WaitForSingleObject(m_WaitCalibDoseEvt, INFINITE); } } if (m_nXrayCalibNum != m_nCalibTotalExposureNum) { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//PauseCalibration m_CalibUnit->PauseCalibration(); } //mLog::FINFO("Driver PauseCalibration over,m_nXrayCalibNum {$}", m_nXrayCalibNum); //mLog::FINFO("--func-- PauseCalibration over"); return Ret; } bool nsFPD::FPDDevicePZMedical::CompleteCalibration() { printf("--func-- CompleteCalibration \n"); //mLog::FINFO("--func-- CompleteCalibration"); m_stDeviceConfig.fCalibTemperature2 = m_stDeviceConfig.fCurrentTemperValue; m_stDeviceConfig.fCalibTemperature = (m_stDeviceConfig.fCalibTemperature1 + m_stDeviceConfig.fCalibTemperature2) / 2; g_pDetector->CompleteCalibration(this); if (g_pDetector->GetPZMedicalCtrlCalibType() == CCOS_CALIBRATION_TYPE_DARK) { //mLog::FINFO("CompleteCalibration get Calibration Type:{$}", (int)CCOS_CALIBRATION_TYPE_DARK); printf("CompleteCalibration get Calibration Type: dark\n"); } else if (g_pDetector->GetPZMedicalCtrlCalibType() == CCOS_CALIBRATION_TYPE_XRAY) { //mLog::FINFO("PZMedical Ctrl Calibration Type:{$}", (int)CCOS_CALIBRATION_TYPE_XRAY); printf("CompleteCalibration get Calibration Type: xray\n"); DWORD nRet = WaitForSingleObject(m_UploadCalibMapOver, 60000); if (WAIT_OBJECT_0 == nRet) { //mLog::FINFO("got event m_UploadCalibMapOver"); } else if (WAIT_TIMEOUT == nRet) { //mLog::FINFO("wait event m_UploadCalibMapOver timeout"); } else { //mLog::FINFO("wait event m_UploadCalibMapOver error"); } } printf("CompleteCalibration set detector status standby\n"); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//CompleteCalibration m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); //通知子系统结束暗场校正太快了,导致后边的服务通知app的消息混乱了(不是一个进程的原因)acqservice,故此处延时1s printf("Sleep 1s,then send progress 100\n"); //mLog::FINFO("Sleep 1s,then send progress 100"); Sleep(1000); m_CalibUnit->SetCalibrationProgress("100"); //mLog::FINFO("--func-- CompleteCalibration over"); return true; } void nsFPD::FPDDevicePZMedical::AbortCalibration() { printf("--func-- AbortCalibration\n"); //mLog::FINFO("--func--AbortCalibration"); CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType(); if (CCOS_CALIBRATION_TYPE_DARK == nCalibrationType) { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//AbortCalibration dark m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_CalibUnit->SetCalibrationProgress("100"); //mLog::FINFO("--func-- AbortCalibration over"); return; } m_eAppStatus = APP_STATUS_CAL_END; g_pDetector->AbortCalibration(this); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));//AbortCalibration gain m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_CalibUnit->SetCalibrationProgress("100"); m_AcqUnit->SendNoNeedWaitImage(true); //mLog::FINFO("--func-- AbortCalibration over"); } void nsFPD::FPDDevicePZMedical::OnProcessTemperature(int nID, float fTemperature) { string strWarnErrorCode = ""; float fMaxTempGap = 6.0f; if (m_stDeviceConfig.strDeviceName.find("PZMEDICAL") >= 0 || m_stDeviceConfig.strDeviceName.find("PZMedical") >= 0) { fMaxTempGap = 12.0f; } if (fTemperature >= m_stDeviceConfig.fTemperMaxLimit) { //mLog::FINFO("Exceed Max Temperature"); m_stDeviceConfig.nTemperatureStatus = TEMP_TOO_HIGH; if (m_stDeviceConfig.bActived) { strWarnErrorCode = "ERR_FPD_TEMPHIGH_NOT_ACQ"; } } else if (fTemperature <= m_stDeviceConfig.fTemperMinLimit) { m_stDeviceConfig.nTemperatureStatus = TEMP_TOO_LOW; if (m_stDeviceConfig.bActived) { //mLog::FINFO("Exceed Min Temperature"); strWarnErrorCode = "ERR_FPD_TEMPLOW_NOT_ACQ"; } } else if (fTemperature <= m_stDeviceConfig.fTemperLowLimit) { m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING; //mLog::FINFO("Exceed Temperature Low Warning"); strWarnErrorCode = "WAR_FPD_TEMPERTURE_LOW"; } else if (fTemperature > m_stDeviceConfig.fTemperUpperLimit) { //mLog::FINFO("Exceed Temperature High Warning"); m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING; strWarnErrorCode = "WAR_FPD_TEMPERATURE_HIGH"; } else if ((m_stDeviceConfig.fCalibTemperature > 1.0f) && (abs(fTemperature - m_stDeviceConfig.fCalibTemperature) >= fMaxTempGap)) { //mLog::FINFO("Exceed Calibration Temperature"); m_stDeviceConfig.nTemperatureStatus = TEMP_WARNING; strWarnErrorCode = "WAR_FPD_EXCEED_CALB_TEMPER"; } else if ((fTemperature <= m_stDeviceConfig.fTemperUpperLimit) && (fTemperature > m_stDeviceConfig.fTemperLowLimit)) { ////mLog::FINFO("Temperature Normal"); } } //慎重调用,可能会导致板出问题,硬reset需要很长时间 RET_STATUS nsFPD::FPDDevicePZMedical::Reset() { printf("--Func-- Reset\n"); //mLog::FINFO("--func-- Reset"); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; if (g_pDetector->ResetDetector(this)) { Ret = RET_STATUS::RET_SUCCEED; } else { Ret = RET_STATUS::RET_FAILED; } //mLog::FINFO("--func-- Reset over"); return Ret; } /*** * 客户端获取探测器信息 ***/ RET_STATUS nsFPD::FPDDevicePZMedical::GetDetectorInfo(string& strFDI) { ResDataObject strDetectorInfo; //mLog::FINFO("GetDetectorInfo m_stDeviceConfig.strPanelSerial:{$}", m_stDeviceConfig.strPanelSerial); if (m_stDeviceConfig.strPanelSerial == "") { //mLog::FERROR("strPanelSerial is null!!! 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"); strFDI = strDetectorInfo.encode(); return RET_STATUS::RET_SUCCEED; } strDetectorInfo.add("DetectorName", m_stDeviceConfig.strDeviceName.c_str()); strDetectorInfo.add("DetectorSN", m_stDeviceConfig.strPanelSerial.c_str()); strDetectorInfo.add("Firmware", m_stDeviceConfig.strFirmware.c_str()); strDetectorInfo.add("APFirmware", "NULL"); strDetectorInfo.add("Software", m_stDeviceConfig.strSoftware.c_str()); strDetectorInfo.add("SSID", m_stDeviceConfig.strWifiSSID.c_str()); strDetectorInfo.add("LifeTime", m_stDeviceConfig.nLifeTime); strDetectorInfo.add("PowerOn", m_stDeviceConfig.nPowerOn); strDetectorInfo.add("DateCode", 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("PZMEDICAL") >= 0 || m_stDeviceConfig.strDeviceName.find("PZMedical") >= 0) { strDetectorInfo.add("SystemAS", 3); } else { strDetectorInfo.add("SystemAS", 3); } //DetectorCalibrationDate if (m_stDeviceConfig.strCalibrationDate != " ") { if (m_stDeviceConfig.strCalibrationDate.find("19700101") != std::string::npos) { strDetectorInfo.add("CalibrationDate", "0"); strDetectorInfo.add("CalibrationDue", "0"); strDetectorInfo.add("CalibrationExist", 0); } else { strDetectorInfo.add("CalibrationDate", m_stDeviceConfig.strCalibrationDate.c_str()/*"20210610"*/); strDetectorInfo.add("CalibrationDue", m_stDeviceConfig.strCalibrationDue.c_str()/*"20210610"*/); strDetectorInfo.add("CalibrationExist", 1); } } else { strDetectorInfo.add("CalibrationDate", "0"); strDetectorInfo.add("CalibrationDue", "0"); strDetectorInfo.add("CalibrationExist", 0); } if (m_stDeviceConfig.bConnectStatus) { strDetectorInfo.add("CommunicationStatus", 1); } else { strDetectorInfo.add("CommunicationStatus", 0); } strDetectorInfo.add("FDCalibrationTemperature", m_stDeviceConfig.fCalibTemperature); strDetectorInfo.add("ShockSensor", m_nShockCounts); strDetectorInfo.add("FirmwareUpdate", 0); strFDI = strDetectorInfo.encode(); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDevicePZMedical::ResetConnect() { //mLog::FINFO("--Func-- ResetConnect"); g_pDetector->Disconnect(); g_pDetector->Connect(this,m_strWorkPath.c_str()); return RET_STATUS::RET_SUCCEED; }