#include "stdafx.h" #include "CCOS.Dev.FPD.Rayence.h" #include "common_api.h" #include "DICOMImageHeadKey.h" #include "Detector_Rayence.h" #include namespace nsFPD = CCOS::Dev::Detail::Detector; static nsFPD::RayenceDriver gIODriver; Log4CPP::Logger* //mLog::gLogger = nullptr; extern Detector_Rayence* g_pDetector; extern "C" CCOS::Dev::IODriver * __cdecl GetIODriver() // 返回静态对象的引用, 调用者不能删除 ! { return &gIODriver; } extern "C" CCOS::Dev::IODriver * __cdecl CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 ! { return new nsFPD::RayenceDriver(); } nsFPD::RayenceDriver::RayenceDriver() { pObjDev = nullptr; m_bDriverConnect = false; //缺省为false m_pAttribute.reset(new ResDataObject()); m_pDescription.reset(new ResDataObject()); } nsFPD::RayenceDriver::~RayenceDriver() { //mLog::Close(); Log4CPP::ThreadContext::Map::Clear(); //mLog::gLogger = nullptr; } void nsFPD::RayenceDriver::Prepare() { //mLog::FINFO("--Func Driver-- Prepare Start"); string strLogPath = GetProcessDirectory() + R"(\OEMDrivers\Detector\Conf\Log4CPP.Config.FPD.xml)"; Log4CPP::GlobalContext::Map::Set(ZSKK::Utility::Hash("LogFileName"), "FPD.Rayence"); auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str()); //mLog::gLogger = Log4CPP::LogManager::GetLogger("FPD.Rayence"); //mLog::FINFO("Driver Prepare Over"); } bool nsFPD::RayenceDriver::Connect() { //mLog::FINFO("--Func Driver-- Connect Start"); pObjDev = new FPDDeviceRayence(EventCenter, m_ConfigFileName); m_bDriverConnect = true; //connect执行完毕,置为true //mLog::FINFO("Driver Connect Over"); return true; } void nsFPD::RayenceDriver::Disconnect() { //mLog::FINFO("--Func Driver-- Disconnect Start"); m_bDriverConnect = false; //disconnect置为false //mLog::FINFO("Driver Disconnect Over"); } bool nsFPD::RayenceDriver::isConnected() const { return m_bDriverConnect; } auto nsFPD::RayenceDriver::CreateDevice(int index)->std::unique_ptr { //mLog::FINFO("--Func Driver-- CreateDevice Start"); auto Device = std::unique_ptr(new IODevice(pObjDev)); pObjDev->CreateDevice(); pObjDev->Register(); //mLog::FINFO("Driver CreateDevice Over"); return Device; } std::string nsFPD::RayenceDriver::DriverProbe() { //mLog::FINFO("--Func Driver-- DriverProbe Start"); 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", "RF"); HardwareInfo.add("VendorID", "Rayence"); #ifdef Rayence0909FCC HardwareInfo.add("ProductID", "0909FCC"); #endif // Rayence0909FCC #ifdef Rayence1717FCC HardwareInfo.add("ProductID", "1717FCC"); #endif // Rayence1717FCC HardwareInfo.add("SerialID", "Driver"); } string str = HardwareInfo.encode(); //mLog::FINFO("Driver DriverProbe Over"); return str; } /*** ** 获取ID和配置 ***/ std::string nsFPD::RayenceDriver::GetResource() { //mLog::FINFO("--Func Driver-- GetResource Start"); ResDataObject r_config, temp; if (!temp.loadFile(m_ConfigFileName.c_str())) { //mLog::FERROR("load file FERROR! file name:{$}",m_ConfigFileName.c_str()); return ""; } m_ConfigAll = temp; r_config = temp["CONFIGURATION"]; m_Configurations = r_config; ResDataObject DescriptionTemp; ResDataObject ListTemp; string strTemp = ""; //用于读取字符串配置信息 int nTemp = -1; //用于读取整型配置信息 string strValue = ""; //用于存储配置的值 string strType = ""; //用于存储配置的类型 int/float/string... /*** * 1. 通过循环,将所有配置项写到pDeviceConfig * 2. 记录配置项的内部key以及配置类型,类型对应了不同配置文件路径,用于读写真实值 ***/ 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 (exception e) { //mLog::FERROR("Get config FERROR: {$}", e.what()); return ""; } ResDataObject resDeviceResource; resDeviceResource.add(ConfKey::CcosDetectorAttribute, (*m_pAttribute)); resDeviceResource.add(ConfKey::CcosDetectorDescription, (*m_pDescription)); ResDataObject DescriptionTempEx; DescriptionTempEx.add(ConfKey::CcosDetectorConfig, resDeviceResource); m_DeviceConfig = DescriptionTempEx; string res = DescriptionTempEx.encode(); //mLog::FINFO("Driver GetResouce Over"); return res; } std::string nsFPD::RayenceDriver::DeviceProbe() { //mLog::FINFO("--Func Driver-- DeviceProbe Start"); ResDataObject r_config, HardwareInfo; if (r_config.loadFile(m_ConfigFileName.c_str())) { HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]); HardwareInfo.add("MinorID", "Device"); HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]); HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]); HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]); } else { HardwareInfo.add("MajorID", "Detector"); HardwareInfo.add("MinorID", "Device"); HardwareInfo.add("VendorID", "Rayence"); #ifdef Rayence0909FCC HardwareInfo.add("ProductID", "0909FCC"); #endif // Rayence0909FCC #ifdef Rayence1717FCC HardwareInfo.add("ProductID", "1717FCC"); #endif // Rayence1717FCC HardwareInfo.add("SerialID", "1234"); } string str = HardwareInfo.encode(); //mLog::FINFO("Driver DeviceProve Over"); return str; } bool nsFPD::RayenceDriver::GetDeviceConfig(std::string& Cfg) { //mLog::FINFO("--Func Driver-- GetDeviceConfig Start"); Cfg = m_DeviceConfig.encode(); //mLog::FINFO("Driver GetDeviceConfig Over"); return true; } bool nsFPD::RayenceDriver::SetDeviceConfig(std::string Cfg) { //mLog::FINFO("--Func Driver-- SetDeviceConfig Start"); //mLog::FINFO("DeviceConfig: {$}", 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) { //3. 重新保存配置文件 SaveConfigFile(true); } //mLog::FINFO("Driver SetDeviceConfig Over"); return true; } bool nsFPD::RayenceDriver::SaveConfigFile(bool bSendNotify) { //mLog::FINFO("--Func Driver-- SaveConfigFile Start"); //mLog::FINFO("ConfigFileName:{$}", m_ConfigFileName); m_ConfigAll["CONFIGURATION"] = m_Configurations; m_ConfigAll.SaveFile(m_ConfigFileName.c_str()); //mLog::FINFO("Driver SaveConfigFile Over"); return true; } bool nsFPD::RayenceDriver::GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue) { return true; } bool nsFPD::RayenceDriver::SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey, int nPathID, const char* szValue) { return true; } //----------------------------------------------------------------------------- // FPDDeviceRayence //----------------------------------------------------------------------------- nsFPD::FPDDeviceRayence::FPDDeviceRayence(std::shared_ptr center,std::string strConfigPath) :m_pDetector{}, m_pImgBuffer{}, m_nImageWidth{}, m_nImageHeight{}, m_nImgBits{}, m_nAngle{}, m_nPixelSpacing{}, m_nSensitivity{}, m_fCurrentPPS{}, m_fDose(2.4), m_bConnect(false) { m_strWorkPath = GetProcessDirectory(); m_DetectorCtrlUnit.reset(new OemCtrl(center, this)); m_AcqUnit.reset(new OemAcq(center, this)); m_SyncUnit.reset(new OemSync(center, this)); m_CalibUnit.reset(new OemCalib(center, this)); m_DetectorConfiguration.reset(new DetectorConfiguration(strConfigPath)); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); EventCenter = center; } nsFPD::FPDDeviceRayence::~FPDDeviceRayence() { if (nullptr != m_pDetector) { delete m_pDetector; m_pDetector = nullptr; } if (nullptr != m_pImgBuffer) { delete m_pImgBuffer; m_pImgBuffer = nullptr; } } std::string nsFPD::FPDDeviceRayence::GetGUID() const { return DetectorUnitType; } bool nsFPD::FPDDeviceRayence::Prepare() { //mLog::FINFO("--Func Device-- Prepare Start"); //mLog::FINFO("MaxImgWidth: {$}, MaxImgHeight: {$}", m_stDeviceConfig.nMaxImgWidth, m_stDeviceConfig.nMaxImgHeight); EventCenter->OnMaxBlockSize("RfQue", 4000 * 4000 * 8, 20, 1500 * 1500 * 2, 1); Connect(); //mLog::FINFO("Device Prepare Over"); return true; } bool nsFPD::FPDDeviceRayence::CreateDevice() { //mLog::FINFO("--Func Device-- CreateDevice Start"); if (!LoadConfig()) { return false; } if (nullptr == g_pDetector) { if (nullptr == m_pDetector) { m_pDetector = new Detector_Rayence(); g_pDetector = (Detector_Rayence*)m_pDetector; } } else { m_pDetector = g_pDetector; } ((Detector_Rayence*)m_pDetector)->DriverEntry(this, m_DetectorConfiguration->m_Configurations); //mLog::FINFO("Device CreateDevice Over"); return true; } bool nsFPD::FPDDeviceRayence::LoadConfig() { //mLog::FINFO("--Func Device-- LoadConfig Start"); if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_ACQMODElist)) { //mLog::FERROR("Load configuration file failed!!!"); return false; } if (!m_DetectorConfiguration->LoadCalibrationDose(m_strWorkPath, m_CalibDoseList)) { //mLog::FERROR("Load Calibration Dose failed!!!"); return false; } if (!m_DetectorConfiguration->LoadDetectorMode(m_strWorkPath, m_DetectorModeList)) { //mLog::FERROR("Load Detector Mode failed!!!"); return false; } unsigned long dpi = 0; try { for (size_t i = 0; i < m_DetectorModeList.size(); i++) { ResDataObject temp = m_DetectorModeList[i]; int nModeID = temp["ModeID"]; int nWidth = temp["ImageWidth"]; int nHeight = temp["ImageHeight"]; int BinningMode = temp["BinningMode"]; int nFrameRate = temp["FrameRate"]; int nCalImgNum = temp["CalImgNum"]; //mLog::FINFO("Detector Mode {$} Width:{$} Height:{$} Binning:{$} FrameRate:{$}, CalImgNum:{$}", nModeID, nWidth, nHeight, BinningMode, nFrameRate, nCalImgNum); DetectorMode tempMode; tempMode.ModeID = nModeID; tempMode.imageWidth = nWidth; tempMode.imageHeight = nHeight; tempMode.binningMode = BinningMode; tempMode.FrameRate = nFrameRate; tempMode.CalImgNum = nCalImgNum; m_vDetectorModeList.push_back(tempMode); if ((unsigned long)nWidth * (unsigned long)nHeight > dpi) { dpi = nWidth * nHeight; m_stDeviceConfig.nMaxImgWidth = nWidth; m_stDeviceConfig.nMaxImgHeight = nHeight; } } } catch (ResDataObjectExption& e) { //mLog::FERROR("Get detector mode FERROR: {$}", e.what()); return false; } //mLog::FINFO("m_stDeviceConfig.nMaxImgWidth:{$},m_stDeviceConfig.nMaxImgHeight:{$}", m_stDeviceConfig.nMaxImgWidth, m_stDeviceConfig.nMaxImgHeight); if (m_pImgBuffer) { delete m_pImgBuffer; m_pImgBuffer = nullptr; } m_pImgBuffer = new WORD[(size_t)m_stDeviceConfig.nMaxImgWidth * (size_t)m_stDeviceConfig.nMaxImgHeight]; char szFDinfo[MAX_STRING] = { 0 }; string strFPDinfo; sprintf_s(szFDinfo, "%d", m_nSensitivity); strFPDinfo = szFDinfo; m_DetectorCtrlUnit->SetFPDSensitivity(strFPDinfo); m_DetectorCtrlUnit->SetPixelData(""); m_DetectorCtrlUnit->SetTargetEXI("5000"); m_AcqUnit->SetMaxFrameRate(m_fMaxFrameRate); //mLog::FINFO("Device LoadConfig Over"); return true; } void nsFPD::FPDDeviceRayence::Register() { auto Disp = &Dispatch; RegisterCtrl(Disp); RegisterAcq(Disp); RegisterSync(Disp); RegisterCalib(Disp); } RET_STATUS nsFPD::FPDDeviceRayence::Connect() { //mLog::FINFO("--Func Device-- Connect Start"); RET_STATUS ret = RET_STATUS::RET_FAILED; if(((Detector_Rayence*)m_pDetector)->Connect(this, m_strWorkPath.c_str())) { m_bConnect = true; if (m_stDeviceConfig.bSupportDDR) //是否支持DDR采集功能 { m_DetectorCtrlUnit->SetSupportDDR("YES"); } else { m_DetectorCtrlUnit->SetSupportDDR("NO"); } ret = RET_STATUS::RET_SUCCEED; } //mLog::FINFO("Device Connect Over"); return ret; } RET_STATUS nsFPD::FPDDeviceRayence::EnterExam(int nExamMode) { //mLog::FINFO("--Func Device-- EnterExam Start"); //mLog::FINFO("EnterExam: {$}", nExamMode); switch (nExamMode) { case APP_STATUS::APP_STATUS_WORK_BEGIN: //mLog::FINFO("Enter into Exam Windows"); m_eAppStatus = APP_STATUS::APP_STATUS_WORK_BEGIN; break; case APP_STATUS::APP_STATUS_WORK_END: //mLog::FINFO("Quit Exam Windows"); m_eAppStatus = APP_STATUS::APP_STATUS_WORK_END; break; case APP_STATUS::APP_STATUS_DETSHARE_BEGIN: //mLog::FINFO("Enter into Detector Share Windows"); m_eAppStatus = APP_STATUS::APP_STATUS_DETSHARE_BEGIN; break; case APP_STATUS::APP_STATUS_DETSHAR_END: //mLog::FINFO("Quit Detector Share Windows"); m_eAppStatus = APP_STATUS::APP_STATUS_DETSHAR_END; break; case APP_STATUS::APP_STATUS_CAL_BEGIN: //mLog::FINFO("Enter into Calibration Windows"); m_eAppStatus = APP_STATUS::APP_STATUS_CAL_BEGIN; break; case APP_STATUS::APP_STATUS_CAL_END: //mLog::FINFO("Quit Calibration Windows"); m_eAppStatus = APP_STATUS::APP_STATUS_CAL_END; break; case APP_STATUS::APP_STATUS_WORK_IN_SENSITIVITY: //mLog::FINFO("Enter into sensitivity test interface"); m_eAppStatus = APP_STATUS::APP_STATUS_WORK_IN_SENSITIVITY; break; default: break; } g_pDetector->EnterExamMode(nExamMode); //mLog::FINFO("EnterExam Over"); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceRayence::SetAcqMode(string strMode) { //mLog::FINFO("--Func Device-- SetAcqMode Start"); //mLog::FINFO("SetAcqMode Mode: {$}", strMode); RET_STATUS ret = RET_STATUS::RET_FAILED; //如果没连接,不执行 if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); return ret; } if (DETECTOR_STATUS::DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus()) { //mLog::FINFO("SetAcqMode detector is not standby!"); ret = StopAcquisition(); if (ret != RET_STATUS::RET_SUCCEED) { //mLog::FERROR("SetAcqMode StopAcquisition fail!!!!"); return ret; } else { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS::DETECTOR_STATUS_STANDBY)); } } else { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS::DETECTOR_STATUS_STANDBY)); } try { ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations; int nModeCount = (int)objModeConfig["ModeTable"].size(); for (int i = 0; i < nModeCount; i++) { std::string strAppMode = (std::string)objModeConfig["ModeTable"][i]["ExamType"]; if (strAppMode == strMode) { if (strAppMode == "RAD") { m_nImageWidth = (int)objModeConfig["ModeTable"][i]["ImageWidth"]; m_nImageHeight = (int)objModeConfig["ModeTable"][i]["ImageHeight"]; } m_nImgBits = (int)objModeConfig["ModeTable"][i]["PhySizeInfoBit"]; m_nPixelSpacing = (int)objModeConfig["ModeTable"][i]["PixelPitch"]; break; } } } catch (ResDataObjectExption& e) { //mLog::FERROR("Read configuration failed, FERROR code: {$}", e.what()); ret = RET_STATUS::RET_FAILED; return ret; } //更新属性 m_strCurrentAcqMode = strMode; if (g_pDetector->SetAcqMode(strMode)) { ret = RET_STATUS::RET_SUCCEED; m_AcqUnit->AcqModeNotify(strMode); } else { ret = RET_STATUS::RET_FAILED; } //mLog::FINFO("Device SetAcqMode Over"); return ret; } RET_STATUS nsFPD::FPDDeviceRayence::PrepareAcquisition() { //mLog::FINFO("--Func Device-- PrepareAcquisition Start"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); return ret; } if (DETECTOR_STATUS::DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus()) { if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS::CCOS_CALIBRATION_STATUS_RUNNING) || (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS::CCOS_CALIBRATION_STATUS_ACTIVE)) { //mLog::FERROR("PrepareAcquisition failed. Detector at Calibration status"); } if (DETECTOR_STATUS::DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus()) { //mLog::Warn("Detector already at Acq status"); ret = RET_STATUS::RET_SUCCEED; } } else { m_SyncUnit->FPDReadyNotify(false); //prepare前置为初值 if (g_pDetector->PrepareAcquisition(this)) { ret = RET_STATUS::RET_SUCCEED; m_SyncUnit->FPDReadyNotify(true); //prepare succeed } } //mLog::FINFO("Device PrepareAcquisition Over"); return ret; } RET_STATUS nsFPD::FPDDeviceRayence::StartAcquisition(string in) { //mLog::FINFO("--Func Device-- StartAcquisition Start"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); return ret; } //mLog::FINFO("StartAcquisition param in: {$}", in); //mLog::FINFO("StartAcquisition m_strCurrentAcqMode: {$}", m_strCurrentAcqMode); if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus()) { if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) || (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE)) { //mLog::FERROR("PrepareAcquisition failed. Detector at Calibration status."); } if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus()) { //mLog::FERROR("Detector already at Acq status."); } } else { if (g_pDetector->StartAcquisition(this)) { ret = RET_STATUS::RET_SUCCEED; m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ)); } else { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); } } //mLog::FINFO("Device StartAcquisition Over"); return ret; } RET_STATUS nsFPD::FPDDeviceRayence::StopAcquisition() { //mLog::FINFO("--Func Device-- StopAcquisition Start"); 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()) { //mLog::FINFO("Detector already at stanby status."); ret = RET_STATUS::RET_SUCCEED; } else { //mLog::FINFO("Call Detector StopAcquisition"); if (g_pDetector->StopAcquisition(this)) { //mLog::FINFO("Detector StopAcquisition Result is True"); ret = RET_STATUS::RET_SUCCEED; m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); } } //mLog::FINFO("StopAcquisition Result: {$}", to_string(ret)); //mLog::FINFO("Device StopAcquisition Over"); return ret; } RET_STATUS nsFPD::FPDDeviceRayence::SetFluPPS(float fFluPPS) { //mLog::FINFO("--Func Device-- SetFluPPS Start"); //mLog::FINFO("SetFluPPS:{$}", fFluPPS); if (m_strCurrentAcqMode != "CF" && m_strCurrentAcqMode != "PF") { //mLog::FERROR("Current Acq Mode is not Flu, needn't set flu pps"); return RET_STATUS::RET_FAILED; } m_fCurrentPPS = fFluPPS; //更新m_fFrameRate值 float fRealFps = g_pDetector->SetFluPPS(fFluPPS); if (fRealFps > 0.0f) { m_AcqUnit->FluPPSNotify(fRealFps); } //mLog::FINFO("Device SetFluPPS Over"); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceRayence::GetFluPPS(float& fFluPPS) { //mLog::FINFO("--Func Device-- GetFluPPS Start"); g_pDetector->GetFluPPS(fFluPPS); //mLog::FINFO("Device GetFluPPS Over"); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceRayence::SetExposureTimes(int nTimes) { //mLog::FINFO("--Func Device-- SetExposureTimes Test"); return RET_STATUS::RET_SUCCEED; } RET_STATUS nsFPD::FPDDeviceRayence::ActiveCalibration(CCOS_CALIBRATION_TYPE eType) { //mLog::FINFO("--Func Device-- ActiveCalibration Start"); //mLog::FINFO("ActiveCalibration {$}", (int)eType); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { //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()) { if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus()) { //mLog::FERROR("ActiveCalibration failed. Detector at Acq status"); } return RET_STATUS::RET_FAILED; } if (g_pDetector->ActiveCalibration(this, eType)) { ret = RET_STATUS::RET_SUCCEED; m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ACTIVE)); m_CalibUnit->SetCalibrationProgress("0"); } else { //mLog::FERROR("Active calibration failed"); } //mLog::FINFO("Device ActiveCalibration Over"); return ret; } RET_STATUS nsFPD::FPDDeviceRayence::PrepareCalibration() { //mLog::FINFO("--Func Device-- PrepareCalibration Start"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); return ret; } m_SyncUnit->FPDReadyNotify(false); //prepare前置为初值 if (g_pDetector->PrepareCalibration(this)) { ret = RET_STATUS::RET_SUCCEED; m_SyncUnit->FPDReadyNotify(true); //prepare succeed } else { //mLog::FERROR("Prepare calibration failed"); } //mLog::FINFO("Device PrepareCalibration Over"); return ret; } RET_STATUS nsFPD::FPDDeviceRayence::GetRequestedDose(std::string& strDose) { //mLog::FINFO("--Func Device-- GetRequestedDose Start"); RET_STATUS Ret = RET_STATUS::RET_SUCCEED; bool bGetDoseInfo = false; ResDataObject out; CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType(); if (CCOS_CALIBRATION_TYPE_DARK == nCalibrationType) { out.add("Dose", 0.0f); out.add("kV", 0.0f); out.add("mA", 0.0f); out.add("ms", 0.0f); out.add("mAs", 0.0f); bGetDoseInfo = true; } else if (CCOS_CALIBRATION_TYPE_XRAY == nCalibrationType) { for (int i = 0; i < m_CalibDoseList.size(); i++) { ResDataObject temp = m_CalibDoseList[i]; int nDose = temp["Dose"]; int nDoseParem = (int)(m_fDose * 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; break; } } } else { Ret = RET_STATUS::RET_FAILED; } if (bGetDoseInfo) { strDose = out.encode(); //mLog::FINFO("GetRequestedDose {$} over", strDose.c_str()); } else { //mLog::FERROR("GetRequestedDose failed"); } //mLog::FINFO("Device GetRequestedDose Over"); return Ret; } RET_STATUS nsFPD::FPDDeviceRayence::StartCalibration() { //mLog::FINFO("--Func Device-- StartCalibration Start"); 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_PAUSE) && (m_CalibUnit->GetCalibrationStatus() != CCOS_CALIBRATION_STATUS_ACTIVE)) { //mLog::FERROR("Start calibration failed, in {$} status", (int)m_CalibUnit->GetCalibrationStatus()); return ret; } if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus()) { if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus()) { //mLog::FERROR("Start calibration failed. Detector at Acq status"); } return ret; } if (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) { //mLog::FERROR("Detector already at calib status"); return ret; } if (g_pDetector->StartCalibration(this)) { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING)); ret = RET_STATUS::RET_SUCCEED; } else { //mLog::FERROR("Start calibration failed"); } //mLog::FINFO("Device StartCalibration Over"); return ret; } RET_STATUS nsFPD::FPDDeviceRayence::StopCalibration() { //mLog::FINFO("--Func Device-- StopCalibration Start"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); return ret; } if (g_pDetector->StopCalibration(this)) { ret = RET_STATUS::RET_SUCCEED; m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_CalibUnit->SetCalibrationProgress("100"); } else { //mLog::FERROR("Start calibration failed"); } //mLog::FINFO("Device StopCalibration Over"); return ret; } RET_STATUS nsFPD::FPDDeviceRayence::StartOffset(bool isAll) { //mLog::FINFO("--Func Device-- StartOffset Start"); RET_STATUS ret = RET_STATUS::RET_FAILED; //mLog::FINFO("StartOffset Paramer: {$}", isAll); if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); } if (isAll) { m_CalibUnit->SetOffsetCounts(to_string(m_stDeviceConfig.nCalibModeNum)); m_CalibUnit->SetOffsetInterval(to_string(m_stDeviceConfig.nOffsetInterval)); } else { m_CalibUnit->SetOffsetCounts(to_string(1)); m_CalibUnit->SetOffsetInterval(to_string(m_stDeviceConfig.nOffsetInterval)); } //mLog::FINFO("isAll: {$}", isAll); m_CalibUnit->SetOffsetStatus("Running"); if (g_pDetector->StartOffset(this, isAll, m_vDetectorModeList)) { ret = RET_STATUS::RET_SUCCEED; } //mLog::FINFO("Device StartOffset Over"); return ret; } RET_STATUS nsFPD::FPDDeviceRayence::AbortOffset() { //mLog::FINFO("--Func Device-- AbortOffset Start"); RET_STATUS ret = RET_STATUS::RET_FAILED; if (!m_bConnect) { //mLog::FERROR("Detector not connected, return"); } if (g_pDetector->AbortOffset()) { ret = RET_STATUS::RET_SUCCEED; } m_CalibUnit->SetOffsetStatus("Idle"); //mLog::FINFO("Device AbortOffset Over"); return ret; } bool nsFPD::FPDDeviceRayence::Support_DarkCalib() { return true; } bool nsFPD::FPDDeviceRayence::Support_XrayCalib() { return true; } void nsFPD::FPDDeviceRayence::RegisterCtrl(nsDetail::Dispatch* Dispatch) { Dispatch->Action.Push(ActionKey::CcosActiveDetector, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSActiveDetector); Dispatch->Action.Push(ActionKey::EnterExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSEnterExam); Dispatch->Action.Push(ActionKey::ExitExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSExitExam); Dispatch->Action.Push(ActionKey::SetXrayOnNum, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetXrayOnNum); Dispatch->Action.Push(ActionKey::SetExposureTimes, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetExposureTimes); Dispatch->Get.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDStatus); Dispatch->Get.Push(AttrKey::Description, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDescription); Dispatch->Get.Push(AttrKey::FPDSensitivity, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDSensitivity); Dispatch->Get.Push(AttrKey::TargetEXI, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTargetEXI); Dispatch->Get.Push(SupportDDR, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetSupportDDR); Dispatch->Get.Push(AttrKey::DetectorID, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorID); Dispatch->Get.Push(AttrKey::DetectorType, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorType); Dispatch->Get.Push(AttrKey::PixelData, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetPixelData); Dispatch->Set.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorStatus); Dispatch->Set.Push(AttrKey::Description, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDescription); Dispatch->Set.Push(AttrKey::FPDSensitivity, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetFPDSensitivity); Dispatch->Set.Push(AttrKey::TargetEXI, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetTargetEXI); Dispatch->Set.Push(SupportDDR, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetSupportDDR); Dispatch->Set.Push(AttrKey::DetectorID, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorID); Dispatch->Set.Push(AttrKey::DetectorType, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorType); Dispatch->Set.Push(AttrKey::PixelData, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetPixelData); } void nsFPD::FPDDeviceRayence::RegisterAcq(nsDetail::Dispatch* Dispatch) { Dispatch->Action.Push(ActionKey::SetAcqMode, m_AcqUnit.get(), &AcqUnit::JSSetAcqMode); Dispatch->Action.Push(ActionKey::SetValue_PPS, m_AcqUnit.get(), &AcqUnit::JSSetFluPPS); Dispatch->Get.Push(AttrKey::AcqMode, m_AcqUnit.get(), &AcqUnit::JSGetAcqMode); Dispatch->Get.Push(AttrKey::ZskkFPDState, m_AcqUnit.get(), &AcqUnit::JSGetZskkFPDState); Dispatch->Get.Push(AttrKey::NoNeedWaitImage, m_AcqUnit.get(), &AcqUnit::JSGetNoNeedWaitImage); Dispatch->Get.Push(AttrKey::ImgDataInfo, m_AcqUnit.get(), &AcqUnit::JSGetLastImage); Dispatch->Get.Push(AttrKey::MaxFrameRate, m_AcqUnit.get(), &AcqUnit::JSGetMaxFrameRate); Dispatch->Get.Push(AttrKey::FluPPS, m_AcqUnit.get(), &AcqUnit::JSGetFluPPS); Dispatch->Set.Push(AttrKey::ZskkFPDState, m_AcqUnit.get(), &AcqUnit::SetZskkFPDState); Dispatch->Set.Push(AttrKey::NoNeedWaitImage, m_AcqUnit.get(), &AcqUnit::JSSetNoNeedWaitImage); } void nsFPD::FPDDeviceRayence::RegisterSync(nsDetail::Dispatch* Dispatch) { 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->Set.Push(AttrKey::FPDReadyStatus, m_SyncUnit.get(), &SyncUnit::JSSetFPDReady); Dispatch->Set.Push(AttrKey::XwindowStatus, m_SyncUnit.get(), &SyncUnit::JSSetXWindowStatus); Dispatch->Set.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSSetImageReadingStatus); } void nsFPD::FPDDeviceRayence::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::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::StartOffset, m_CalibUnit.get(), &CalibUnit::JSStartOffset); Dispatch->Action.Push(ActionKey::AbortOffset, m_CalibUnit.get(), &CalibUnit::JSAbortOffset); Dispatch->Get.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::JSGetCalibStatus); Dispatch->Get.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::JSGetCalibProgress); Dispatch->Get.Push(AttrKey::UploadCalibrationFilesResult, m_CalibUnit.get(), &CalibUnit::JSGetUploadCalibrationFilesResult); Dispatch->Get.Push(AttrKey::OffsetStatus, m_CalibUnit.get(), &CalibUnit::JSGetOffsetStatus); Dispatch->Get.Push(AttrKey::OffsetProgress, m_CalibUnit.get(), &CalibUnit::JSGetOffsetProgress); Dispatch->Get.Push(AttrKey::OffsetCounts, m_CalibUnit.get(), &CalibUnit::JSGetOffsetCounts); Dispatch->Get.Push(AttrKey::OffsetInterval, m_CalibUnit.get(), &CalibUnit::JSGetOffsetInterval); Dispatch->Set.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::SetCalibrationStatus); Dispatch->Set.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::SetCalibrationProgress); Dispatch->Set.Push(AttrKey::UploadCalibrationFilesResult, m_CalibUnit.get(), &CalibUnit::SetUploadCalibrationFilesResult); Dispatch->Set.Push(AttrKey::OffsetStatus, m_CalibUnit.get(), &CalibUnit::SetOffsetStatus); Dispatch->Set.Push(AttrKey::OffsetProgress, m_CalibUnit.get(), &CalibUnit::SetOffsetProgress); Dispatch->Set.Push(AttrKey::OffsetCounts, m_CalibUnit.get(), &CalibUnit::SetOffsetCounts); Dispatch->Set.Push(AttrKey::OffsetInterval, m_CalibUnit.get(), &CalibUnit::SetOffsetInterval); Dispatch->Update.Push(AttrKey::OffsetInterval, m_CalibUnit.get(), &CalibUnit::JSUpdateOffsetInterval); } void nsFPD::FPDDeviceRayence::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::FPDDeviceRayence::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("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; } if (m_nImageWidth != nParam1) { m_nImageWidth = nParam1; } //mLog::FINFO("Ratate angle: {$}", m_nAngle); if (m_nAngle == 90 || m_nAngle == 270) { m_AcqUnit->SetFulImageInfo(m_nImageWidth, m_nImageHeight, m_nImgBits, false); } else { m_AcqUnit->SetFulImageInfo(m_nImageHeight, m_nImageWidth, m_nImgBits, false); } //mLog::FINFO("Panel {$} m_nImageWidth:{$}", nDetectorID, m_nImageWidth); break; } case EVT_CONF_RAW_HIGHT: { if (m_stDeviceConfig.nFullImageHeight != nParam1) { m_stDeviceConfig.nFullImageHeight = nParam1; } if (m_nImageHeight != nParam1) { m_nImageHeight = nParam1; } //mLog::FINFO("Ratate angle: {$}", m_nAngle); if (m_nAngle == 90 || m_nAngle == 270) { m_AcqUnit->SetFulImageInfo(m_nImageWidth, m_nImageHeight, m_nImgBits, false); } else { m_AcqUnit->SetFulImageInfo(m_nImageHeight, m_nImageWidth, m_nImgBits, false); } //mLog::FINFO("Panel {$} m_nImageHeight:{$}", nDetectorID, m_nImageHeight); break; } } } void nsFPD::FPDDeviceRayence::OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { switch (nEventID) { case EVT_INFO_OFFSET_PROGRESS: { string strOffsetProgress = to_string(nParam1); m_CalibUnit->SetOffsetProgress(strOffsetProgress); } break; case EVT_INFO_OFFSET_STATUS: { string strTemp; if (nParam1 == 1) { strTemp = "Idle"; } m_CalibUnit->SetOffsetStatus(strTemp); } break; default: //mLog::FWARN("Not support this FINFO({$})", nEventID); break; } } void nsFPD::FPDDeviceRayence::OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { switch (nEventID) { case EVT_STATUS_PANEL: { ENUM_PANEL_STATUS ePanelStatus = (ENUM_PANEL_STATUS)nParam1; if (PANEL_END_ACQ == nParam1) { //mLog::FINFO("Panel Status: End acq"); if (g_pDetector->StopAcquisition(this)) { m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); } } else if (PANEL_STANDBY == nParam1) { //mLog::FINFO("Panel Status: Standby"); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); } else if(PANEL_OFFSET_CAL == nParam1) { //mLog::FINFO("Panel Status: Offset"); m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_CALIB)); } else if (PANEL_XWINDOW_ON == nParam1) //Xwindow On { //mLog::FINFO("XWindowOnNotify"); m_SyncUnit->XWindowOnNotify(); } else if (PANEL_XWINDOW_OFF == nParam1) // Xwindow Off { //mLog::FINFO("XWindowOffNotify"); m_SyncUnit->XWindowOffNotify(); } } break; case EVT_STATUS_CALIBRATIOIN: { ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1; switch (eStatus) { case PANEL_EVENT_START: break; case PANEL_EVENT_END_OK: case PANEL_EVENT_END_ERROR: m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY)); m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY)); m_CalibUnit->SetCalibrationProgress("100");//make progress break; case PANEL_EVENT_TIMEOUT: break; default: break; } break; } default: //mLog::FWARN("Not support this status({$})", nEventID); break; } } void nsFPD::FPDDeviceRayence::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"); //mLog::FINFO("m_nImageWidth: {$}, m_nImageHeight: {$}", m_nImageWidth, m_nImageHeight); memcpy(m_pImgBuffer, pParam, (size_t)m_nImageWidth * (size_t)m_nImageHeight * sizeof(WORD)); //暂时先用假值,有需要再改 SYSTEMTIME stImgCreateTime = { 0 }; GetLocalTime(&stImgCreateTime); ResDataObject objImageHead, objTemp; objTemp.add(SM_IMAGE_TYPE, (int)IMAGE_FULL); objTemp.add(SM_IMAGE_BIT, 16); objTemp.add(SM_IMAGE_TAG, 1); objTemp.add(SM_IMAGE_INDEX, 1); objTemp.add(SM_IMAGE_YEAR, stImgCreateTime.wYear); objTemp.add(SM_IMAGE_MONTH, stImgCreateTime.wMonth); objTemp.add(SM_IMAGE_DAY, stImgCreateTime.wDay); objTemp.add(SM_IMAGE_HOUR, stImgCreateTime.wHour); objTemp.add(SM_IMAGE_MINUTE, stImgCreateTime.wMinute); objTemp.add(SM_IMAGE_SEC, stImgCreateTime.wSecond); objTemp.add(SM_IMAGE_MILLSEC, stImgCreateTime.wMilliseconds); objTemp.add(SM_IMAGE_LSB, "5000"); objTemp.add(SM_IMAGE_DOSE, m_nSensitivity); objTemp.add(SM_IMAGE_PIXELSPACING, m_nPixelSpacing); objTemp.add(SM_IMAGE_PIXELREPRESENTATION, "1"); objTemp.add(SM_IMAGE_FLIP, "No"); objTemp.add(SM_IMAGE_ORIGINX, "0"); objTemp.add(SM_IMAGE_ORIGINY, "0"); m_AcqUnit->RotateImage(m_pImgBuffer, m_nImageHeight, m_nImageWidth, m_nAngle); if (90 == m_nAngle || 270 == m_nAngle) { objTemp.add(SM_IMAGE_WIDTH, m_nImageHeight); objTemp.add(SM_IMAGE_HEIGHT, m_nImageWidth); objTemp.add(SM_IMAGE_ROTATION, "Yes"); } else { objTemp.add(SM_IMAGE_WIDTH, m_nImageWidth); objTemp.add(SM_IMAGE_HEIGHT, m_nImageHeight); objTemp.add(SM_IMAGE_ROTATION, "No"); } objImageHead.add(SM_IMAGE_HEAD, objTemp); //mLog::Trace("Full image head: {$}", objImageHead.encode()); RET_STATUS ret = RET_STATUS::RET_FAILED; ret = m_AcqUnit->AddFrameWithRawHead(IMAGE_FULL, objImageHead.encode(), m_pImgBuffer, m_nImageWidth * m_nImageHeight); //mLog::FINFO("Add image over"); } break; default: //mLog::FWARN("Not support this data({$})", nEventID); break; } } void nsFPD::FPDDeviceRayence::OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { switch (nEventID) { case EVT_ERR_COMMUNICATE: break; case EVT_ERR_INIT_FAILED: break; case EVT_ERR_OFFSET_FAILED: m_CalibUnit->SetOffsetStatus("FERROR"); break; default: //mLog::FWARN("Not support this FERROR({$})", nEventID); break; } } void nsFPD::FPDDeviceRayence::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam) { //mLog::FWARN("Not support this warn({$})", nEventID); }