1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459 |
- #include "stdafx.h"
- #include "CCOS.Dev.FPD.Rayence.h"
- #include "common_api.h"
- #include "DICOMImageHeadKey.h"
- #include "Detector_Rayence.h"
- #include <sys/stat.h>
- namespace nsFPD = CCOS::Dev::Detail::Detector;
- static nsFPD::RayenceDriver gIODriver;
- Log4CPP::Logger* 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()
- {
- Close();
- Log4CPP::ThreadContext::Map::Clear();
- gLogger = nullptr;
- }
- void nsFPD::RayenceDriver::Prepare()
- {
- 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());
- gLogger = Log4CPP::LogManager::GetLogger("FPD.Rayence");
- FINFO("Driver Prepare Over");
- }
- bool nsFPD::RayenceDriver::Connect()
- {
- FINFO("--Func Driver-- Connect Start");
- pObjDev = new FPDDeviceRayence(EventCenter, m_ConfigFileName);
- m_bDriverConnect = true; //connect执行完毕,置为true
- FINFO("Driver Connect Over");
- return true;
- }
- void nsFPD::RayenceDriver::Disconnect()
- {
- FINFO("--Func Driver-- Disconnect Start");
- m_bDriverConnect = false; //disconnect置为false
- FINFO("Driver Disconnect Over");
- }
- bool nsFPD::RayenceDriver::isConnected() const
- {
- return m_bDriverConnect;
- }
- auto nsFPD::RayenceDriver::CreateDevice(int index)->std::unique_ptr <IODevice>
- {
- FINFO("--Func Driver-- CreateDevice Start");
- auto Device = std::unique_ptr<IODevice>(new IODevice(pObjDev));
- pObjDev->CreateDevice();
- pObjDev->Register();
- FINFO("Driver CreateDevice Over");
- return Device;
- }
-
- std::string nsFPD::RayenceDriver::DriverProbe()
- {
- 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();
- FINFO("Driver DriverProbe Over");
- return str;
- }
- /***
- ** 获取ID和配置
- ***/
- std::string nsFPD::RayenceDriver::GetResource()
- {
- FINFO("--Func Driver-- GetResource Start");
- ResDataObject r_config, temp;
- if (!temp.loadFile(m_ConfigFileName.c_str()))
- {
- 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)
- {
- FERROR("Get config FERROR: {$}", e.what());
- return "";
- }
- ResDataObject resDeviceResource;
- resDeviceResource.add(ConfKey::CcosDetectorAttribute, (*m_pAttribute));
- resDeviceResource.add(ConfKey::CcosDetectorDescription, (*m_pDescription));
- ResDataObject DescriptionTempEx;
- DescriptionTempEx.add(ConfKey::CcosDetectorConfig, resDeviceResource);
- m_DeviceConfig = DescriptionTempEx;
- string res = DescriptionTempEx.encode();
- FINFO("Driver GetResouce Over");
- return res;
- }
- std::string nsFPD::RayenceDriver::DeviceProbe()
- {
- FINFO("--Func Driver-- DeviceProbe Start");
- ResDataObject r_config, HardwareInfo;
- if (r_config.loadFile(m_ConfigFileName.c_str()))
- {
- HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
- HardwareInfo.add("MinorID", "Device");
- HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
- HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
- HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
- }
- else
- {
- HardwareInfo.add("MajorID", "Detector");
- HardwareInfo.add("MinorID", "Device");
- HardwareInfo.add("VendorID", "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();
- FINFO("Driver DeviceProve Over");
- return str;
- }
- bool nsFPD::RayenceDriver::GetDeviceConfig(std::string& Cfg)
- {
- FINFO("--Func Driver-- GetDeviceConfig Start");
- Cfg = m_DeviceConfig.encode();
- FINFO("Driver GetDeviceConfig Over");
- return true;
- }
- bool nsFPD::RayenceDriver::SetDeviceConfig(std::string Cfg)
- {
- FINFO("--Func Driver-- SetDeviceConfig Start");
- 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];
- FINFO("{$}", temp.encode());
- for (int j = 0; j < temp.size(); j++)
- {
- string strKey = temp.GetKey(j);
- FINFO("{$}", strKey.c_str());
- try
- {
- if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0)
- {
- strAccess = (string)(*m_pDescription)[strKey.c_str()]["Access"];
- if ("RW" == strAccess || "rw" == strAccess)
- {
- //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值
- //1. 修改内存中的值,用于给上层发消息
- (*m_pAttribute)[strKey.c_str()] = temp[j];
- //2. 拿到Innerkey
- int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
- FINFO("ConfigInfo Count: {$}", nConfigInfoCount);
- string strTemp = ""; //存储AttributeKey
- for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- if (strTemp == strKey)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
- break;
- }
- }
- //3. 修改配置文件中的值
- if (SetDeviceConfigValue(m_Configurations, strTemp.c_str(), 1, temp[j]))
- {
- bSaveFile = true;
- }
- }
- else
- {
- FINFO("{$} is not a RW configuration item", strKey.c_str());
- }
- }
- }
- catch (ResDataObjectExption& e)
- {
- FERROR("SetDriverConfig crashed: {$}", e.what());
- return false;
- }
- }
- }
- if (bSaveFile)
- {
- //3. 重新保存配置文件
- SaveConfigFile(true);
- }
- FINFO("Driver SetDeviceConfig Over");
- return true;
- }
- bool nsFPD::RayenceDriver::SaveConfigFile(bool bSendNotify)
- {
- FINFO("--Func Driver-- SaveConfigFile Start");
- FINFO("ConfigFileName:{$}", m_ConfigFileName);
- m_ConfigAll["CONFIGURATION"] = m_Configurations;
- m_ConfigAll.SaveFile(m_ConfigFileName.c_str());
- 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<IOEventCenter> 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()
- {
- FINFO("--Func Device-- Prepare Start");
- FINFO("MaxImgWidth: {$}, MaxImgHeight: {$}", m_stDeviceConfig.nMaxImgWidth, m_stDeviceConfig.nMaxImgHeight);
- EventCenter->OnMaxBlockSize("RfQue",
- 4000 * 4000 * 8,
- 20, 1500 * 1500 * 2, 1);
- Connect();
- FINFO("Device Prepare Over");
- return true;
- }
- bool nsFPD::FPDDeviceRayence::CreateDevice()
- {
- 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);
- FINFO("Device CreateDevice Over");
- return true;
- }
- bool nsFPD::FPDDeviceRayence::LoadConfig()
- {
- FINFO("--Func Device-- LoadConfig Start");
- if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_ACQMODElist))
- {
- FERROR("Load configuration file failed!!!");
- return false;
- }
- if (!m_DetectorConfiguration->LoadCalibrationDose(m_strWorkPath, m_CalibDoseList))
- {
- FERROR("Load Calibration Dose failed!!!");
- return false;
- }
- if (!m_DetectorConfiguration->LoadDetectorMode(m_strWorkPath, m_DetectorModeList))
- {
- 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"];
- 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)
- {
- FERROR("Get detector mode FERROR: {$}", e.what());
- return false;
- }
- 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);
- 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()
- {
- 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;
- }
- FINFO("Device Connect Over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceRayence::EnterExam(int nExamMode)
- {
- FINFO("--Func Device-- EnterExam Start");
- FINFO("EnterExam: {$}", nExamMode);
- switch (nExamMode)
- {
- case APP_STATUS::APP_STATUS_WORK_BEGIN:
- FINFO("Enter into Exam Windows");
- m_eAppStatus = APP_STATUS::APP_STATUS_WORK_BEGIN;
- break;
- case APP_STATUS::APP_STATUS_WORK_END:
- FINFO("Quit Exam Windows");
- m_eAppStatus = APP_STATUS::APP_STATUS_WORK_END;
- break;
- case APP_STATUS::APP_STATUS_DETSHARE_BEGIN:
- FINFO("Enter into Detector Share Windows");
- m_eAppStatus = APP_STATUS::APP_STATUS_DETSHARE_BEGIN;
- break;
- case APP_STATUS::APP_STATUS_DETSHAR_END:
- FINFO("Quit Detector Share Windows");
- m_eAppStatus = APP_STATUS::APP_STATUS_DETSHAR_END;
- break;
- case APP_STATUS::APP_STATUS_CAL_BEGIN:
- FINFO("Enter into Calibration Windows");
- m_eAppStatus = APP_STATUS::APP_STATUS_CAL_BEGIN;
- break;
- case APP_STATUS::APP_STATUS_CAL_END:
- FINFO("Quit Calibration Windows");
- m_eAppStatus = APP_STATUS::APP_STATUS_CAL_END;
- break;
- case APP_STATUS::APP_STATUS_WORK_IN_SENSITIVITY:
- FINFO("Enter into sensitivity test interface");
- m_eAppStatus = APP_STATUS::APP_STATUS_WORK_IN_SENSITIVITY;
- break;
- default:
- break;
- }
- g_pDetector->EnterExamMode(nExamMode);
- FINFO("EnterExam Over");
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceRayence::SetAcqMode(string strMode)
- {
- FINFO("--Func Device-- SetAcqMode Start");
- FINFO("SetAcqMode Mode: {$}", strMode);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- //如果没连接,不执行
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- if (DETECTOR_STATUS::DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus())
- {
- FINFO("SetAcqMode detector is not standby!");
- ret = StopAcquisition();
- if (ret != RET_STATUS::RET_SUCCEED)
- {
- 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)
- {
- 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;
- }
- FINFO("Device SetAcqMode Over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceRayence::PrepareAcquisition()
- {
- FINFO("--Func Device-- PrepareAcquisition Start");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- 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))
- {
- FERROR("PrepareAcquisition failed. Detector at Calibration status");
- }
- if (DETECTOR_STATUS::DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- 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
- }
- }
- FINFO("Device PrepareAcquisition Over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceRayence::StartAcquisition(string in)
- {
- FINFO("--Func Device-- StartAcquisition Start");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- FINFO("StartAcquisition param in: {$}", in);
- 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))
- {
- FERROR("PrepareAcquisition failed. Detector at Calibration status.");
- }
- if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- FERROR("Detector already at Acq status.");
- }
- }
- else
- {
- if (g_pDetector->StartAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
- }
- else
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- }
- }
- FINFO("Device StartAcquisition Over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceRayence::StopAcquisition()
- {
- FINFO("--Func Device-- StopAcquisition Start");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- if (DETECTOR_STATUS_STANDBY == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- FINFO("Detector already at stanby status.");
- ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FINFO("Call Detector StopAcquisition");
- if (g_pDetector->StopAcquisition(this))
- {
- FINFO("Detector StopAcquisition Result is True");
- ret = RET_STATUS::RET_SUCCEED;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- }
- }
- FINFO("StopAcquisition Result: {$}", to_string(ret));
- FINFO("Device StopAcquisition Over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceRayence::SetFluPPS(float fFluPPS)
- {
- FINFO("--Func Device-- SetFluPPS Start");
- FINFO("SetFluPPS:{$}", fFluPPS);
- if (m_strCurrentAcqMode != "CF" && m_strCurrentAcqMode != "PF")
- {
- 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);
- }
- FINFO("Device SetFluPPS Over");
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceRayence::GetFluPPS(float& fFluPPS)
- {
- FINFO("--Func Device-- GetFluPPS Start");
- g_pDetector->GetFluPPS(fFluPPS);
- FINFO("Device GetFluPPS Over");
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceRayence::SetExposureTimes(int nTimes)
- {
- FINFO("--Func Device-- SetExposureTimes Test");
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceRayence::ActiveCalibration(CCOS_CALIBRATION_TYPE eType)
- {
- FINFO("--Func Device-- ActiveCalibration Start");
- FINFO("ActiveCalibration {$}", (int)eType);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- 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())
- {
- 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
- {
- FERROR("Active calibration failed");
- }
- FINFO("Device ActiveCalibration Over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceRayence::PrepareCalibration()
- {
- FINFO("--Func Device-- PrepareCalibration Start");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- 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
- {
- FERROR("Prepare calibration failed");
- }
- FINFO("Device PrepareCalibration Over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceRayence::GetRequestedDose(std::string& strDose)
- {
- 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();
- FINFO("GetRequestedDose {$} over", strDose.c_str());
- }
- else
- {
- FERROR("GetRequestedDose failed");
- }
- FINFO("Device GetRequestedDose Over");
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceRayence::StartCalibration()
- {
- FINFO("--Func Device-- StartCalibration Start");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- if ((m_CalibUnit->GetCalibrationStatus() != CCOS_CALIBRATION_STATUS_PAUSE) && (m_CalibUnit->GetCalibrationStatus() != CCOS_CALIBRATION_STATUS_ACTIVE))
- {
- 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())
- {
- FERROR("Start calibration failed. Detector at Acq status");
- }
- return ret;
- }
- if (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING)
- {
- 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
- {
- FERROR("Start calibration failed");
- }
- FINFO("Device StartCalibration Over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceRayence::StopCalibration()
- {
- FINFO("--Func Device-- StopCalibration Start");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- 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
- {
- FERROR("Start calibration failed");
- }
- FINFO("Device StopCalibration Over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceRayence::StartOffset(bool isAll)
- {
- FINFO("--Func Device-- StartOffset Start");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- FINFO("StartOffset Paramer: {$}", isAll);
- if (!m_bConnect)
- {
- 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));
- }
-
- FINFO("isAll: {$}", isAll);
- m_CalibUnit->SetOffsetStatus("Running");
- if (g_pDetector->StartOffset(this, isAll, m_vDetectorModeList))
- {
- ret = RET_STATUS::RET_SUCCEED;
- }
- FINFO("Device StartOffset Over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceRayence::AbortOffset()
- {
- FINFO("--Func Device-- AbortOffset Start");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bConnect)
- {
- FERROR("Detector not connected, return");
- }
- if (g_pDetector->AbortOffset())
- {
- ret = RET_STATUS::RET_SUCCEED;
- }
- m_CalibUnit->SetOffsetStatus("Idle");
- 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;
- 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;
- }
- 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);
- }
- 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;
- }
- 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);
- }
- 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:
- 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)
- {
- FINFO("Panel Status: End acq");
- if (g_pDetector->StopAcquisition(this))
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- }
- }
- else if (PANEL_STANDBY == nParam1)
- {
- FINFO("Panel Status: Standby");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- }
- else if(PANEL_OFFSET_CAL == nParam1)
- {
- FINFO("Panel Status: Offset");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_CALIB));
- }
- else if (PANEL_XWINDOW_ON == nParam1) //Xwindow On
- {
- FINFO("XWindowOnNotify");
- m_SyncUnit->XWindowOnNotify();
- }
- else if (PANEL_XWINDOW_OFF == nParam1) // Xwindow Off
- {
- 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:
- 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:
- {
- FINFO("Image Arrived");
- 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);
- 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);
- FINFO("Add image over");
- }
- break;
- default:
- 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:
- 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)
- {
- FWARN("Not support this warn({$})", nEventID);
- }
|