12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796 |
- #include "stdafx.h"
- #include "FileVersion.hpp"
- #include "CCOS.Dev.FPD.HaoBoRF.h"
- #include "common_api.h"
- #include "DICOMImageHeadKey.h"
- #include "Detector_HaoBoRF.h"
- #include <sys/stat.h>
- namespace nsFPD = CCOS::Dev::Detail::Detector;
- static nsFPD::HaoBoDriver gIODriver;
- Log4CPP::Logger* gLogger = nullptr;
- extern Detector_HaoBoRF* g_pDetector;
- extern const char* g_szMouldPath;
- HaoBoDriver* gDriver = nullptr;
- extern "C" CCOS::Dev::IODriver * __cdecl GetIODriver() // 返回静态对象的引用, 调用者不能删除 !
- {
- return &gIODriver;
- }
- extern "C" CCOS::Dev::IODriver * __cdecl CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 !
- {
- gDriver = new nsFPD::HaoBoDriver();
- return gDriver;
- }
- nsFPD::HaoBoDriver::HaoBoDriver()
- {
- pObjDev = nullptr;
- m_bDriverConnect = false; //缺省为false
- m_pAttribute.reset(new ResDataObject());
- m_pDescription.reset(new ResDataObject());
- }
- nsFPD::HaoBoDriver::~HaoBoDriver()
- {
- if (pObjDev != nullptr)
- {
- delete pObjDev;
- pObjDev = nullptr;
- }
- Close();
- Log4CPP::ThreadContext::Map::Clear();
- gLogger = nullptr;
- }
- auto nsFPD::HaoBoDriver::CreateDevice(int index)->std::unique_ptr <IODevice>
- {
- printf("--Driver-- createdevice \r\n");
- FINFO("--Driver-- createdevice \n");
- pObjDev = new FPDDeviceHaoBo(EventCenter, m_ConfigFileName);
- auto Device = std::unique_ptr<IODevice>(new IODevice(pObjDev));
- pObjDev->CreateDevice();
- pObjDev->Register();
- return Device;
- }
- bool nsFPD::HaoBoDriver::Connect()
- {
- printf("--Driver-- connect \r\n");
- FINFO("--Driver-- connect");
- if (pObjDev && g_pDetector && !m_bDriverConnect)
- {
- pObjDev->Connect();
- }
-
- return m_bDriverConnect;
- }
- void nsFPD::HaoBoDriver::Disconnect()
- {
- printf("--Driver-- disconnect \r\n");
- FINFO("--Driver-- disconnect");
- if (pObjDev != nullptr)
- {
- delete pObjDev;
- pObjDev = nullptr;
- }
- m_bDriverConnect = false;
- }
- bool nsFPD::HaoBoDriver::isConnected() const
- {
- return m_bDriverConnect;
- }
- void nsFPD::HaoBoDriver::Prepare()
- {
- printf("--Driver-- prepare \r\n");
- string strLogPath = GetProcessDirectory() + R"(\Conf\Log4CPP.Config.xml)";
- auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str());
- gLogger = Log4CPP::LogManager::GetLogger("Module");
- FINFO("Code Build datetime [{$} {$}]", __DATE__, __TIME__);
- #ifdef _WIN64
- FINFO("=============================Version: {$} (64-bit)==================================", FileVersion(g_szMouldPath).GetVersionString());
- #else
- FINFO("=============================Version: {$} (32-bit)==================================", FileVersion(g_szMouldPath).GetVersionString());
- #endif
- FINFO("--Driver-- Prepare get logger");
- }
- std::string nsFPD::HaoBoDriver::DriverProbe()
- {
- printf("--Driver-- DriverProbe \r\n");
- FINFO("--Driver-- DriverProbe");
- 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", "HaoBo");
- HardwareInfo.add("ProductID", "HaoBo");
- HardwareInfo.add("SerialID", "Driver");
- }
- string str = HardwareInfo.encode();
- return str;
- }
- /***
- ** 获取ID和配置
- ***/
- std::string nsFPD::HaoBoDriver::GetResource()
- {
- printf("--Driver-- GetResource \r\n");
- FINFO("--Driver-- GetResource");
- ResDataObject r_config, temp;
- if (!temp.loadFile(m_ConfigFileName.c_str()))
- {
- FERROR("load file error! file name:{$}",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...
- /***
- * 1. 通过循环,将所有配置项写到pDeviceConfig
- * 2. 记录配置项的内部key以及配置类型,类型对应了不同配置文件路径,用于读写真实值
- ***/
- try
- {
- int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
- //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());
- //FINFO(g_pFPDCtrlLog, "--> {$}: {$}", 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()));
- //FINFO(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), atoi(strValue.c_str()));
- }
- else if ("float" == strType)
- {
- (*m_pAttribute).add(strTemp.c_str(), atof(strValue.c_str()));
- //FINFO(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), atof(strValue.c_str()));
- }
- else //其它先按string类型处理
- {
- (*m_pAttribute).add(strTemp.c_str(), strValue.c_str());
- //FINFO(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), strValue.c_str());
- }
- //AttributeAccess
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Access"];
- DescriptionTemp.add(AttributeAccess, strTemp.c_str());
- //FINFO(g_pFPDCtrlLog, "{$}: {$}", AttributeAccess, strTemp.c_str());
- //AttributeRangeMin
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMin"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeRangeMin, strTemp.c_str());
- //FINFO(g_pFPDCtrlLog, "{$}: {$}", AttributeRangeMin, strTemp.c_str());
- }
- //AttributeRangeMax
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMax"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeRangeMax, strTemp.c_str());
- //FINFO(g_pFPDCtrlLog, "{$}: {$}", 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());
- //FINFO(g_pFPDCtrlLog, "list {$}: {$}", nListIndex, strTemp.c_str());
- }
- DescriptionTemp.add(AttributeList, ListTemp);
- }
- //AttributeRequired
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Required"];
- DescriptionTemp.add(AttributeRequired, strTemp.c_str());
- //FINFO(g_pFPDCtrlLog, "{$}: {$}", AttributeRequired, strTemp.c_str());
- //AttributeDefaultValue
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["DefaultValue"];
- if (strTemp != "") //不需要的配置项为空
- {
- DescriptionTemp.add(AttributeDefaultValue, strTemp.c_str());
- //FINFO(g_pFPDCtrlLog, "{$}: {$}", AttributeDefaultValue, strTemp.c_str());
- }
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- (*m_pDescription).add(strTemp.c_str(), DescriptionTemp);
- }
- }
- catch (exception e)
- {
- FERROR("Get config error: {$}", e.what());
- return "";
- }
- ResDataObject resDeviceResource;
- resDeviceResource.add(ConfKey::CcosDetectorAttribute, (*m_pAttribute));
- resDeviceResource.add(ConfKey::CcosDetectorDescription, (*m_pDescription));
- ResDataObject DescriptionTempEx;
- DescriptionTempEx.add(ConfKey::CcosDetectorConfig, resDeviceResource);
- m_DeviceConfig = DescriptionTempEx;
- string res = DescriptionTempEx.encode();
- printf("HaoBoRF driver module: get resource over \r\n");
- //FINFO("get resource over {$}", res.c_str());//此处在调试读取配置的时候再放开,不然打印很长查日志不方便
- FINFO("get resource over!");
- return res;
- }
- std::string nsFPD::HaoBoDriver::DeviceProbe()
- {
- printf("--Driver-- DeviceProbe \r\n");
- FINFO("--Driver-- DeviceProbe");
- 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", "HaoBo");
- HardwareInfo.add("ProductID", "HaoBo");
- HardwareInfo.add("SerialID", "1234");
- }
- string str = HardwareInfo.encode();
- return str;
- }
- bool nsFPD::HaoBoDriver::GetDeviceConfig(std::string& Cfg)
- {
- printf("--Driver-- GetDeviceConfig \r\n");
- FINFO("--Driver-- GetDeviceConfig");
- Cfg = m_DeviceConfig.encode();
- FINFO("GetDeviceConfig over");
- return true;
- }
- bool nsFPD::HaoBoDriver::SetDeviceConfig(std::string Cfg)
- {
- printf("--Driver-- SetDeviceConfig \r\n");
- FINFO("--Driver-- SetDeviceConfig {$}", Cfg.c_str());
- ResDataObject DeviceConfig;
- DeviceConfig.decode(Cfg.c_str());
- ResDataObject DescriptionTempEx;
- DescriptionTempEx = DeviceConfig["DeviceConfig"];
- bool bSaveFile = false; //true:重新保存配置文件
- string strAccess = "";
- for (int i = 0; i < DescriptionTempEx.size(); i++)
- {
- ResDataObject temp = DescriptionTempEx[i];
- FINFO("{$}", temp.encode());
- for (int j = 0; j < temp.size(); j++)
- {
- string strKey = temp.GetKey(j);
- FINFO("{$}", strKey.c_str());
- try
- {
- if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0)
- {
- strAccess = (string)(*m_pDescription)[strKey.c_str()]["Access"];
- if ("RW" == strAccess || "rw" == strAccess)
- {
- //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值
- //1. 修改内存中的值,用于给上层发消息
- (*m_pAttribute)[strKey.c_str()] = temp[j];
- //2. 拿到Innerkey
- int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
- FINFO("ConfigInfo Count: {$}", nConfigInfoCount);
- string strTemp = ""; //存储AttributeKey
- for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
- if (strTemp == strKey)
- {
- strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
- break;
- }
- }
- //3. 修改配置文件中的值
- if (SetDeviceConfigValue(m_Configurations, strTemp.c_str(), 1, temp[j]))
- {
- bSaveFile = true;
- }
- }
- else
- {
- FINFO("{$} is not a RW configuration item", strKey.c_str());
- }
- }
- }
- catch (ResDataObjectExption& e)
- {
- FERROR("SetDriverConfig crashed: {$}", e.what());
- return false;
- }
- }
- }
- if (bSaveFile)
- {
- //3. 重新保存配置文件
- SaveConfigFile(true);
- }
- return true;
- }
- bool nsFPD::HaoBoDriver::SaveConfigFile(bool bSendNotify)
- {
- FINFO("--Driver-- SaveConfigFile start m_ConfigFileName:{$}", m_ConfigFileName);
- m_ConfigAll["CONFIGURATION"] = m_Configurations;
- m_ConfigAll.SaveFile(m_ConfigFileName.c_str());
- FINFO("SaveConfigFile over");
- return true;
- }
- bool nsFPD::HaoBoDriver::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 || OperationMode == strTemp || ExamType == strTemp || ExiThreshold == strTemp ||
- // ImageWidth == strTemp || ImageHeight == strTemp || RawImgWidth == strTemp || RawImgHeight == strTemp)
- // {
- // strValue = (string)config["ModeTable"]["DetectorMode"][pInnerKey];
- // }
- // else if (TempMaxLimit == strTemp || ReConnect == strTemp ||
- // TempUpperLimit == strTemp || TempLowerLimit == strTemp || TempMinLimit == strTemp ||
- // BatLowerLimit == strTemp || BatMiniLimit == strTemp ||
- // BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp ||
- // WifiMiniLimit == strTemp || HighPowerTimeout == strTemp ||
- // ShowTemperature == strTemp || ShowWifi == strTemp ||
- // ShowBattery == strTemp || ShowBluetooth == strTemp ||
- // FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp || CcosDetectorAttachedFlag == strTemp)
- // {
- // strValue = (string)config[pInnerKey];
- // }
- // else
- // {
- // strValue = "";
- // FERROR("Error Configuration item: {$}", pInnerKey);
- // }
- //}
- return true;
- }
- bool nsFPD::HaoBoDriver::SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey,
- int nPathID, const char* szValue)
- {
- //string strTemp = pInnerKey;
- //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 || OperationMode == strTemp || ExamType == strTemp || ExiThreshold == strTemp ||
- // ImageWidth == strTemp || ImageHeight == strTemp || RawImgWidth == strTemp || RawImgHeight == strTemp)
- // {
- // config["ModeTable"]["DetectorMode"][pInnerKey] = szValue;
- // }
- // else if (TempMaxLimit == strTemp || ReConnect == strTemp ||
- // TempUpperLimit == strTemp || TempLowerLimit == strTemp ||
- // BatLowerLimit == strTemp || BatMiniLimit == strTemp ||
- // BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp ||
- // WifiMiniLimit == strTemp || HighPowerTimeout == strTemp ||
- // ShowTemperature == strTemp || ShowWifi == strTemp ||
- // ShowBattery == strTemp || ShowBluetooth == strTemp ||
- // FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp || CcosDetectorAttachedFlag == strTemp)
- // {
- // config[pInnerKey] = szValue;
- // }
- // else
- // {
- // FERROR("Error Configuration item: {$}", pInnerKey);
- // return false;
- // }
- //}
- return true;
- }
- nsFPD::FPDDeviceHaoBo::FPDDeviceHaoBo(std::shared_ptr<IOEventCenter> center,std::string strConfigPath)
- {
- m_strWorkPath = GetProcessDirectory();
- m_nWidth = 0;
- m_nHeight = 0;
- m_nImgBits = 0;
- m_nAngle = 0;
- m_nPixelSpacing = 0;
- m_nSensitivity = 0;
- m_fDose = 0.0f;
- m_pImgBuffer = nullptr;
- m_eAppStatus = APP_STATUS::APP_STATUS_IDLE;
- m_bDeviceConnect = false;
- m_nCurrentAcqMode = 0;
- m_fCurrentPPS = 15.0f;
- m_vAcqModeInfoList.clear();
- m_fFactorEXI2UGY = 0.0f;
- 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_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));
- EventCenter = center;
- }
- nsFPD::FPDDeviceHaoBo::~FPDDeviceHaoBo()
- {
- FINFO("~FPDDeviceHaoBo");
- if (g_pDetector)
- {
- delete g_pDetector;
- g_pDetector = nullptr;
- }
- if (m_pImgBuffer)
- {
- delete m_pImgBuffer;
- m_pImgBuffer = nullptr;
- }
- m_vAcqModeInfoList.clear();
- }
- std::string nsFPD::FPDDeviceHaoBo::GetGUID() const
- {
- return DetectorUnitType;
- }
- bool nsFPD::FPDDeviceHaoBo::CreateDevice()
- {
- printf("--Func-- device CreateDevice \r\n");
- FINFO("--Func-- device CreateDevice \n");
- if (!LoadConfig())
- {
- return false;
- }
- if (nullptr == g_pDetector)
- {
- g_pDetector = new Detector_HaoBoRF();
- }
-
- g_pDetector->DriverEntry(this, m_DetectorConfiguration->m_Configurations, m_strWorkPath.c_str());
- m_DetectorCtrlUnit->SetAttachStatus("1"); //没有attach功能,直接上发1,使客户端显示探测器状态
- m_DetectorCtrlUnit->SetDetectorWidth(to_string(m_stDeviceConfig.nDetectorWidth));
- m_DetectorCtrlUnit->SetDetectorHeight(to_string(m_stDeviceConfig.nDetectorHeight));
- m_DetectorCtrlUnit->SetSupportDDR(to_string(m_stDeviceConfig.nSupportDDR));
- m_DetectorCtrlUnit->SetTargetEXI("5000");
- m_CalibUnit->SetOffsetInterval(to_string(m_stDeviceConfig.nOffsetInterval));
- return true;
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::Connect()
- {
- printf("--Func-- device Connect \r\n");
- FINFO("--Func-- device Connect");
- if (!g_pDetector->Connect(this))
- {
- FERROR("Connect Detector fail!");
- return RET_STATUS::RET_FAILED;
- }
- return RET_STATUS::RET_SUCCEED;
- }
- bool nsFPD::FPDDeviceHaoBo::Prepare()
- {
- printf("--Func-- device Prepare \r\n");
- FINFO("--Func-- device prepare nDetectorWidth:{$},nDetectorHeight:{$}", m_stDeviceConfig.nDetectorWidth, m_stDeviceConfig.nDetectorHeight);
- //blockname, fullimage blocksize, blockcount,previewimage blocksize,blockcount
- EventCenter->OnMaxBlockSize("HaoBoRfQue", 4000 * 4000 * 2, 10, 1500 * 1500 * 2, 1);
- return true;
- }
- bool nsFPD::FPDDeviceHaoBo::LoadConfig()
- {
- printf("--Func-- device LoadConfig \r\n");
- FINFO("--Func-- device LoadConfig start");
- //LoadConfigurations必须比下边俩函数先调用,否则会有问题
- if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_vAcqModeInfoList))
- {
- FERROR("Load configuration file failed!!!");
- return false;
- }
- //const char* strkey, int initialvalue, int min, int WarnMin, int WarnMax, int CalibWarnMin, int CalibWarnMax, int max, int accuracy, std::shared_ptr <CCOS::Dev::IOEventCenter> EventCenter
- m_Battery.reset(new DeviceBatteryMould("DetectorBattery", 0,
- m_stDeviceConfig.nBatteryLimit,
- m_stDeviceConfig.nBatteryWarning,
- 90, 20, 90, 100, 0, EventCenter));
- //const char* strkey, float initialvalue, float min, float WarnMin, float WarnMax, float CalibWarnMin, float CalibWarnMax, float max, float accuracy,std::shared_ptr <CCOS::Dev::IOEventCenter> EventCenter
- m_Temperature.reset(new DeviceTemperatureMould("DetectorTemperature", 0.0f,
- m_stDeviceConfig.fTemperatureErrorMin,
- m_stDeviceConfig.fTemperatureWarnMin,
- m_stDeviceConfig.fTemperatureWarnMax,
- 20.0f, 100.0f,
- m_stDeviceConfig.fTemperatureErrorMax,
- 0.0f, EventCenter));
- //const char* strkey, int initialvalue, int min, int WarnMin, int WarnMax, int CalibWarnMin, int CalibWarnMax, int max, int accuracy, std::shared_ptr <CCOS::Dev::IOEventCenter> EventCenter
- m_Wifi.reset(new DeviceWifiMould("DetectorWifi", 0,
- m_stDeviceConfig.nWifiLimit,
- m_stDeviceConfig.nWifiWarning,
- 100, 10, 100, 100, 0, EventCenter));
- FINFO("--Func-- device LoadConfig end");
- return true;
- }
- void nsFPD::FPDDeviceHaoBo::Register()
- {
- FINFO("--Func-- device Register \n");
- auto Disp = &Dispatch;
- RegisterCtrl(Disp);
- RegisterAcq(Disp);
- RegisterSync(Disp);
- RegisterCalib(Disp);
- RegisterOthers(Disp);
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::EnterExam(int nExamMode)
- {
- FINFO("--Func-- EnterExam {$}", nExamMode);
- switch (nExamMode)
- {
- case APP_STATUS_WORK_BEGIN:
- FINFO("Enter into Exam Windows");
- m_eAppStatus = APP_STATUS_WORK_BEGIN;
- break;
- case APP_STATUS_WORK_END:
- FINFO("Quit Exam Windows");
- m_eAppStatus = APP_STATUS_WORK_END;
- break;
- case APP_STATUS_DETSHARE_BEGIN:
- FINFO("Enter into Detector Share Windows");
- m_eAppStatus = APP_STATUS_DETSHARE_BEGIN;
- break;
- case APP_STATUS_DETSHAR_END:
- m_eAppStatus = APP_STATUS_IDLE;
- FINFO("Quit Detector Share Windows");
- m_eAppStatus = APP_STATUS_DETSHAR_END;
- break;
- case APP_STATUS_CAL_BEGIN:
- FINFO("Enter into Calibration Windows");
- m_eAppStatus = APP_STATUS_CAL_BEGIN;
- break;
- case APP_STATUS_CAL_END:
- FINFO("Quit Calibration Windows");
- m_eAppStatus = APP_STATUS_CAL_END;
- break;
- case APP_STATUS_WORK_IN_SENSITIVITY:
- FINFO("Enter into sensitivity test interface");
- m_eAppStatus = APP_STATUS_WORK_IN_SENSITIVITY;
- break;
- default:
- break;
- }
- g_pDetector->EnterExamMode(nExamMode);
- return RET_STATUS::RET_SUCCEED;
- }
- bool nsFPD::FPDDeviceHaoBo::GetLogicMode(string& strAcqMode, int& nLogicMode)
- {
- if (strAcqMode == "RAD")
- {
- nLogicMode = RAD;
- }
- else if (strAcqMode == "CF")
- {
- nLogicMode = CF;
- }
- else if (strAcqMode == "PF")
- {
- nLogicMode = PF;
- }
- else if (strAcqMode == "1")
- {
- nLogicMode = RAD;
- }
- else if (strAcqMode == "2")
- {
- nLogicMode = CF;
- }
- else if (strAcqMode == "3")
- {
- nLogicMode = PF;
- }
- else
- {
- FERROR("Not support mode!");
- return false;
- }
- return true;
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::SetAcqMode(string strAcqMode)
- {
- printf("--Func-- SetAcqMode(%s) \r\n", strAcqMode.c_str());
- FINFO("--Func-- SetAcqMode strAcqMode:{$}", strAcqMode);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- //如果没连接,不执行
- if (!m_bDeviceConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- //由于动态需要ready快,故通知探测器ready状态在这里通知
- if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus() || DETECTOR_STATUS_CALIB == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- FINFO("Detector is not standby! neet to stop");
- ret = StopAcquisition();
- if (ret != RET_STATUS::RET_SUCCEED)
- {
- FERROR("SetAcqMode StopAcquisition fail!!!");
- return ret;
- }
- else
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- }
- }
- else
- {
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- }
- int nMode = RAD;
- bool bRet = GetLogicMode(strAcqMode, nMode);
- if (!bRet)
- {
- return RET_STATUS::RET_FAILED;
- }
- try
- {
- ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations;
- int nModeCount = (int)objModeConfig["ModeTable"].size();
- for (int i = 0; i < nModeCount; i++)
- {
- //FINFO("ModeTable {$}, {$}",i, objModeConfig["ModeTable"][i].encode());
- int nAppModeID = (int)objModeConfig["ModeTable"][i]["LogicMode"];
- if (nAppModeID == nMode)
- {
- m_nAngle = (int)objModeConfig["ModeTable"][i]["RotateAngle"];
- m_nPixelSpacing = (int)objModeConfig["ModeTable"][i]["PixelPitch"];
- m_nImgBits = (int)objModeConfig["ModeTable"][i]["PhySizeInfoBit"];
- m_nSensitivity = (int)objModeConfig["ModeTable"][i]["Sensitivity"];
- FINFO("m_nAngle:{$}, m_nPixelSpacing:{$}, m_nImgBits:{$}, m_nSensitivity:{$}", m_nAngle, m_nPixelSpacing, m_nImgBits, m_nSensitivity);
- string strDoseOfExi = std::to_string(m_nSensitivity);
- m_fFactorEXI2UGY = 100.0f / stof(strDoseOfExi) * 1.0f;//统一使用IEC标准 呈现四角信息,无单位 ugy * 100 -ugy。所有Zskk探测器的FactorEXI2UGY均需*100
- FINFO("m_fFactorEXI2UGY = {$} ", m_fFactorEXI2UGY);
- m_DetectorCtrlUnit->SetFPDSensitivity(std::to_string(m_fFactorEXI2UGY));
- break;
- }
- }
- }
- catch (ResDataObjectExption& e)
- {
- FERROR("Read configuration failed, Error code: {$}", e.what());
- ret = RET_STATUS::RET_FAILED;
- return ret;
- }
-
- m_nCurrentAcqMode = nMode;
- if (g_pDetector->SetAcqMode(nMode))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_AcqUnit->AcqModeNotify(strAcqMode);
- }
- else
- {
- ret = RET_STATUS::RET_FAILED;
- }
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::PrepareAcquisition()
- {
- printf("--Func-- PrepareAcquisition \r\n");
- FINFO("--Func-- PrepareAcquisition");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) ||
- (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE))
- {
- FERROR("PrepareAcquisition failed! Detector at Calibration status!");
- return ret;
- }
-
- if (g_pDetector->PrepareAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- }
- FINFO("PrepareAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::StartAcquisition(string in)
- {
- printf("--Func-- StartAcquisition \r\n");
- FINFO("--Func-- StartAcquisition");
- FINFO("StartAcquisition param in:{$}", in);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- FINFO("StartAcquisition m_nCurrentAcqMode:{$}", m_nCurrentAcqMode);
- if (in == "RAD" || in == "CF" || in == "PF")
- {
- ret = SetAcqMode(in);
- if (ret != RET_STATUS::RET_SUCCEED)
- {
- FERROR("StartAcquisition SetAcqMode fail!");
- return ret;
- }
- }
- else
- {
- FERROR("Not support this mode, mode name:{$}",in);
- return ret;
- }
- ret = PrepareAcquisition();
- if (ret != RET_STATUS::RET_SUCCEED)
- {
- FERROR("StartAcquisition PrepareAcquisition fail!");
- return ret;
- }
- 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("StartAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::StopAcquisition()
- {
- printf("--Func-- StopAcquisition \r\n");
- FINFO("--Func-- StopAcquisition");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- if (DETECTOR_STATUS_STANDBY == m_DetectorCtrlUnit->GetDetectorStatus())
- {
- //printf(("Detector already at stanby status.\n");
- FINFO("Detector already at stanby status.");
- ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- if (g_pDetector->StopAcquisition(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- }
- }
- FINFO("StopAcquisition over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::SetFluPPS(float fFluPPS)
- {
- FINFO("--Func-- SetFluPPS:{$}", fFluPPS);
- m_fCurrentPPS = fFluPPS;
- bool bFind = false;
- //更新m_fFrameRate值
- for (size_t i = 0; i < m_vAcqModeInfoList.size(); i++)
- {
- if (m_vAcqModeInfoList[i].fFrequency == fFluPPS)
- {
- FINFO("find config pps");
- bFind = true;
- g_pDetector->UpdateModeInRunning(m_vAcqModeInfoList[i].nModeID,fFluPPS);
- m_AcqUnit->FluPPSNotify(fFluPPS);
- break;
- }
- }
- if (!bFind)
- {
- FINFO("not find config pps");
- float fRealFps = g_pDetector->SetFluPPS(fFluPPS);
- if (fRealFps > 0.0f)
- {
- m_AcqUnit->FluPPSNotify(fRealFps);
- }
- }
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::GetFluPPS(float& fFluPPS)
- {
- g_pDetector->GetFluPPS(fFluPPS);
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::SetXrayOnNum()
- {
- FINFO("--Func-- SetXrayOnNum");
- return RET_STATUS::RET_FAILED;
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::SetExposureTimes(int nTimes)
- {
- FINFO("--Func-- SetExposureTimes({$})", nTimes);
- if (g_pDetector->SetExposureTimes(nTimes))
- {
- return RET_STATUS::RET_SUCCEED;
- }
- return RET_STATUS::RET_FAILED;
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::ActiveCalibration(CCOS_CALIBRATION_TYPE eType)
- {
- printf("--Func-- ActiveCalibration eType:%d \r\n", eType);
- FINFO("--Func-- ActiveCalibration {$}", (int)eType);
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- 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())
- {
- //printf(("ActiveCalibration failed. Detector at Acq status\r\n");
- 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("ActiveCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::PrepareCalibration()
- {
- printf("--Func-- PrepareCalibration \r\n");
- FINFO("--Func-- PrepareCalibration");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- FERROR("Detector not connected, return");
- return ret;
- }
- if (g_pDetector->PrepareCalibration(this))
- {
- ret = RET_STATUS::RET_SUCCEED;
- }
- else
- {
- FERROR("Prepare calibration failed");
- }
- FINFO("PrepareCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::GetRequestedDose(std::string& strDose)
- {
- printf("--Func-- GetRequestedDose \r\n");
- FINFO("--Func-- GetRequestedDose");
- 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");
- }
- return Ret;
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::StartCalibration()
- {
- printf("--Func-- StartCalibration \r\n");
- FINFO("--Func-- StartCalibration");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- 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 already 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");
- return ret;
- }
- FINFO("StartCalibration over");
- return ret;
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::StopCalibration()
- {
- printf("--Func-- StopCalibration \r\n");
- FINFO("--Func-- StopCalibration");
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- if (!m_bDeviceConnect)
- {
- 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("StopCalibration over");
- return ret;
- }
- bool nsFPD::FPDDeviceHaoBo::Support_DarkCalib()
- {
- return true;
- }
- bool nsFPD::FPDDeviceHaoBo::Support_XrayCalib()
- {
- return true;
- }
- //理论上定义的Action和Attr的名称要在CCOS.Dev.FPDDeviceMould.hpp中定义,之前由于不清楚导致有的名称在Detector_Model_Def.h中定义的 以后要规范
- void nsFPD::FPDDeviceHaoBo::RegisterCtrl(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Action.Push(ActionKey::GetFPDinformation, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorInfo);
- Dispatch->Action.Push(ActionKey::ActiveDetector, 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->Action.Push(ActionKey::FaultInjection, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSFaultInjection);
- Dispatch->Action.Push(ActionKey::EliminateFault, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSEliminateFault);
- 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->Get.Push(AttrKey::DetectorWidth, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorWidth);
- Dispatch->Get.Push(AttrKey::DetectorHeight, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorHeight);
- 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::FPDDeviceHaoBo::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);
- Dispatch->Update.Push(AttrKey::ModeInRunning, m_AcqUnit.get(), &AcqUnit::JSUpdateModeInRunning);
- }
- void nsFPD::FPDDeviceHaoBo::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::FPDDeviceHaoBo::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::OffsetCounts, m_CalibUnit.get(), &CalibUnit::JSGetOffsetCounts);
- Dispatch->Get.Push(AttrKey::OffsetProgress, m_CalibUnit.get(), &CalibUnit::JSGetOffsetProgress);
- 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::OffsetCounts, m_CalibUnit.get(), &CalibUnit::SetOffsetCounts);
- Dispatch->Set.Push(AttrKey::OffsetProgress, m_CalibUnit.get(), &CalibUnit::SetOffsetProgress);
- Dispatch->Set.Push(AttrKey::OffsetInterval, m_CalibUnit.get(), &CalibUnit::SetOffsetInterval);
- Dispatch->Update.Push(AttrKey::OffsetInterval, m_CalibUnit.get(), &CalibUnit::JSUpdateOffsetInterval);
- }
- void nsFPD::FPDDeviceHaoBo::RegisterOthers(nsDetail::Dispatch* Dispatch)
- {
- Dispatch->Get.Push(AttrKey::Temperature_Value, m_Temperature.get(), &DeviceTemperatureMould::JSGetCurrentTemperatureValue);
- Dispatch->Get.Push(AttrKey::Remain_Power_Value, m_Battery.get(), &DeviceBatteryMould::JSGetCurrentBatteryValue);
- Dispatch->Get.Push(AttrKey::Wifi_Strength_Value, m_Wifi.get(), &DeviceWifiMould::JSGetCurrentSignalValue);
- Dispatch->Get.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMax);
- Dispatch->Get.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMin);
- Dispatch->Get.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMax);
- Dispatch->Get.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMin);
- Dispatch->Get.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureCalibWarningMax);
- Dispatch->Get.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureCalibWarningMin);
- Dispatch->Get.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryWarningMin);
- Dispatch->Get.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryErrorMin);
- Dispatch->Get.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalWarningMin);
- Dispatch->Get.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalErrorMin);
- //ErrorList
- Dispatch->Get.Push(nDetail::AttrKey::ErrorList, m_WarnAndError.get(), &FPDErrorWarning::JSGetErrorList);
- Dispatch->Set.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMax);
- Dispatch->Set.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMin);
- Dispatch->Set.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMax);
- Dispatch->Set.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMin);
- Dispatch->Set.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureCalibWarningMax);
- Dispatch->Set.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureCalibWarningMin);
- Dispatch->Set.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryWarningMin);
- Dispatch->Set.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryErrorMin);
- Dispatch->Set.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalWarningMin);
- Dispatch->Set.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalErrorMin);
- Dispatch->Update.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMax);
- Dispatch->Update.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMin);
- Dispatch->Update.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMax);
- Dispatch->Update.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMin);
- Dispatch->Update.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureCalibWarningMax);
- Dispatch->Update.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureCalibWarningMin);
- Dispatch->Update.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryWarningMin);
- Dispatch->Update.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryErrorMin);
- Dispatch->Update.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalWarningMin);
- Dispatch->Update.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalErrorMin);
- }
- void nsFPD::FPDDeviceHaoBo::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::FPDDeviceHaoBo::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_nWidth != nParam1)
- {
- m_nWidth = nParam1;
- }
- FINFO("Ratate angle: {$}", m_nAngle);
- if (m_nAngle == 90 || m_nAngle == 270)
- {
- m_AcqUnit->SetFulImageInfo(m_nWidth, m_nHeight, m_nImgBits, false);
- }
- else
- {
- m_AcqUnit->SetFulImageInfo(m_nHeight, m_nWidth, m_nImgBits, false);
- }
- FINFO("Panel {$} m_nWidth:{$}", nDetectorID, m_nWidth);
- break;
- }
- case EVT_CONF_RAW_HIGHT:
- {
- if (m_stDeviceConfig.nFullImageHeight != nParam1)
- {
- m_stDeviceConfig.nFullImageHeight = nParam1;
- }
- if (m_nHeight != nParam1)
- {
- m_nHeight = nParam1;
- }
- FINFO("Ratate angle: {$}", m_nAngle);
- if (m_nAngle == 90 || m_nAngle == 270)
- {
- m_AcqUnit->SetFulImageInfo(m_nWidth, m_nHeight, m_nImgBits, false);
- }
- else
- {
- m_AcqUnit->SetFulImageInfo(m_nHeight, m_nWidth, m_nImgBits, false);
- }
- FINFO("Panel {$} m_nHeight:{$}", nDetectorID, m_nHeight);
- break;
- }
- case EVT_CONF_MAX_IMAGESIZE:
- {
- int nImageSize = nParam1;
- FINFO("Receive image size:{$}", nImageSize);
- if (m_pImgBuffer)
- {
- delete m_pImgBuffer;
- m_pImgBuffer = nullptr;
- }
- m_pImgBuffer = new WORD[nImageSize];
- }
- }
- }
- void nsFPD::FPDDeviceHaoBo::OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- FERROR("Not support this info({$})", nEventID);
- }
- void nsFPD::FPDDeviceHaoBo::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_CLOSE == nParam1)
- {
- FINFO("EVT_STATUS_PANEL PANEL_CLOSE");
- m_bDeviceConnect = false;
- gDriver->m_bDriverConnect = false;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_SHUTDOWN));
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS));
- m_WarnAndError->SendError(ERR_FPD_DISCONNECT, "");
- }
- else if (PANEL_CONNECT == nParam1)
- {
- FINFO("EVT_STATUS_PANEL PANEL_CONNECT");
- gDriver->m_bDriverConnect = true;
- m_bDeviceConnect = true;
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_WAKEUP));
- m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK));
- m_WarnAndError->ClearError(ERR_FPD_DISCONNECT);
- }
- else if (PANEL_STANDBY == nParam1)
- {
- FINFO("EVT_STATUS_PANEL PANEL_STANDBY");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_WAKEUP));
- }
- else if (PANEL_READY_EXP == nParam1)
- {
- FINFO("EVT_STATUS_PANEL PANEL_READY_EXP");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
- m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_READY));
- }
- else if (PANEL_XWINDOW_ON == nParam1) //Xwindow On
- {
- FINFO("EVT_STATUS_PANEL PANEL_XWINDOW_ON");
- m_SyncUnit->XWindowOnNotify();
- }
- else if (PANEL_XWINDOW_OFF == nParam1) // Xwindow Off
- {
- FINFO("EVT_STATUS_PANEL PANEL_XWINDOW_OFF");
- m_SyncUnit->XWindowOffNotify();
- }
- else if (PANEL_START_ACQ == nParam1)
- {
- FINFO("EVT_STATUS_PANEL PANEL_START_ACQ");
- m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));//PANEL_START_ACQ
- }
- 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;
- }
- case EVT_STATUS_OFFSET:
- {
- ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
- switch (eStatus)
- {
- case PANEL_EVENT_END_OK:
- m_CalibUnit->SetOffsetStatus("Idle");
- break;
- case PANEL_EVENT_END_ERROR:
- m_CalibUnit->SetOffsetStatus("Error");
- break;
- case PANEL_EVENT_START:
- m_CalibUnit->SetOffsetStatus("Running");
- break;
- default:
- break;
- }
- break;
- }
- case EVT_STATUS_OFFSET_PROGRESS:
- {
- FINFO("EVT_STATUS_OFFSET_PROGRESS param:{$}", nParam1);
- int nOffsetProgress = nParam1;
- m_CalibUnit->SetOffsetProgress(to_string(nOffsetProgress));
- break;
- }
- case EVT_STATUS_TEMPERATURE:
- {
- float fTemperature = fParam2;
- /*if (fTemperature > m_fTemperMaxLimit)
- {
- AddErrMsg("14", "temperature_toohigh");
- }
- else if (fTemperature >= m_fTemperWarning)
- {
- AddWarnMsg("14", "temperature_high");
- }
- else if (fTemperature < m_fTemperMinLimit)
- {
- AddErrMsg("14", "temperature_toolow");
- }
- else if (fTemperature <= m_fTemperLowLimit)
- {
- AddWarnMsg("14", "temperature_low");
- }
- else
- {
- DelErrMsg("14");
- }*/
- //SendTemperatureValue(fTemperature);
- break;
- }
- case EVT_STATUS_WIFI:
- {
- int nWifiLevel = nParam1;
- /*if (nWifiLevel < m_nWifiLimit)
- {
- AddErrMsg("15", "wifi_toolow");
- }
- else if (nWifiLevel <= m_nWifiWarning)
- {
- AddWarnMsg("15", "wifi_low");
- }
- else
- {
- DelErrMsg("15");
- }*/
- //SendWifiValue(nWifiLevel);
- break;
- }
- case EVT_STATUS_BATTERY_VALUE:
- {
- int nBatteryValue = nParam1;
- /*if (nBatteryValue < m_nBatteryLimit)
- {
- AddErrMsg("16", "battery_toolow");
- }
- else if (nBatteryValue <= m_nBatteryWarning)
- {
- AddWarnMsg("16", "battery_low");
- }
- else
- {
- DelErrMsg("16");
- }*/
- //SendBatteryValue(nBatteryValue);
- break;
- }
- default:
- FERROR("Not support this status({$})", nEventID);
- break;
- }
- }
- void nsFPD::FPDDeviceHaoBo::OnEventProcessData(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- switch (nEventID)
- {
- case EVT_DATA_RAW_IMAGE:
- {
- FINFO("EVT_DATA_RAW_IMAGE");
- FINFO("m_nWidth:{$},m_nHeight:{$}", m_nWidth, m_nHeight);
- memcpy(m_pImgBuffer, pParam, (size_t)m_nWidth * (size_t)m_nHeight * sizeof(WORD));
- //暂时先用假值,有需要再改
- SYSTEMTIME stImgCreateTime = { 0 };
- GetLocalTime(&stImgCreateTime);
- ResDataObject objImageHead, objTemp;
- objTemp.add(SM_IMAGE_TYPE, (int)IMAGE_FULL);
- objTemp.add(SM_IMAGE_BIT, m_nImgBits);
- objTemp.add(SM_IMAGE_TAG, 1);
- objTemp.add(SM_IMAGE_INDEX, 1);
- objTemp.add(SM_IMAGE_YEAR, 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");
- objTemp.add(SM_IMAGE_EXI2UGY, m_fFactorEXI2UGY);//此项不添加的话会导致ImageSave计算EXI的值为0
- m_AcqUnit->RotateImage(m_pImgBuffer, m_nHeight, m_nWidth, m_nAngle);
- if (90 == m_nAngle || 270 == m_nAngle)
- {
- objTemp.add(SM_IMAGE_WIDTH, m_nHeight);
- objTemp.add(SM_IMAGE_HEIGHT, m_nWidth);
- objTemp.add(SM_IMAGE_ROTATION, "Yes");
- }
- else
- {
- objTemp.add(SM_IMAGE_WIDTH, m_nWidth);
- objTemp.add(SM_IMAGE_HEIGHT, m_nHeight);
- objTemp.add(SM_IMAGE_ROTATION, "No");
- }
- objImageHead.add(SM_IMAGE_HEAD, objTemp);
- FINFO("Full image head: {$}", objImageHead.encode());
- RET_STATUS ret = RET_STATUS::RET_FAILED;
- ret = m_AcqUnit->AddFrameWithRawHead(IMAGE_FULL, objImageHead.encode(), m_pImgBuffer, m_nWidth * m_nHeight);
- FINFO("Add image over");
- break;
- }
- default:
- FERROR("Not support this data({$})", nEventID);
- break;
- }
- }
- void nsFPD::FPDDeviceHaoBo::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)
- // {
- // AddErrMsg("0", "communication error");
- // SendTemperatureValue(0);
- // SendWifiValue(0);
- // SendBatteryValue(0);
- // }
- // else if (strTemp.find("false") != std::string::npos)
- // {
- // DelErrMsg("0");
- // }
- //}
- break;
- case EVT_ERR_INIT_FAILED:
- //{
- // string strTemp = pszMsg;
- // if (strTemp.find("true") != std::string::npos)
- // {
- // AddErrMsg("6", "initialize error");
- // }
- // else if (strTemp.find("false") != std::string::npos)
- // {
- // //一般不可恢复
- // }
- //}
- break;
- default:
- FERROR("Not support this error({$})", nEventID);
- break;
- }
- }
- void nsFPD::FPDDeviceHaoBo::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel,
- const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
- {
- FERROR("Not support this warn({$})", nEventID);
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::StartOffset(bool isAll)
- {
- FINFO("--Func-- StartOffset isAll:{$}", isAll);
- if (isAll)
- {
- m_CalibUnit->SetOffsetCounts(to_string(1));
- g_pDetector->SetFreshAllOffsetEvent();
- }
- else
- {
- m_CalibUnit->SetOffsetCounts(to_string(1));
- g_pDetector->SetfreshOffsetEvent();
- }
- return RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::AbortOffset()
- {
- FINFO("--Func-- AbortOffset");
- g_pDetector->AbortFreshOffset();
- return RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::UpdateModeInRunning(std::vector<AcqModeInfo>& vAcqModeList)
- {
- FINFO("--Func-- UpdateModeInRunning");
- m_vAcqModeInfoList.assign(vAcqModeList.begin(),vAcqModeList.end());
- for (size_t i = 0; i < m_vAcqModeInfoList.size(); i++)
- {
- if (m_vAcqModeInfoList[i].fFrequency == m_fCurrentPPS)
- {
- g_pDetector->UpdateModeInRunning(m_vAcqModeInfoList[i].nModeID, m_vAcqModeInfoList[i].fFrequency);
- break;
- }
- }
- return RET_SUCCEED;
- }
- /***
- * 客户端获取探测器信息
- ***/
- RET_STATUS nsFPD::FPDDeviceHaoBo::GetDetectorInfo(string& strInfo)
- {
- FINFO("--Func-- GetDetectorInfo");
- ResDataObject strDetectorInfo;
- if (m_stDeviceConfig.strPanelSerial == "")
- {
- FWARN("strPanelSerial is null, Send Default Info");
- strDetectorInfo.add("DetectorName", "Simulator");
- strDetectorInfo.add("DetectorSN", "Simulator");
- 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");
- strInfo = strDetectorInfo.encode();
- return RET_STATUS::RET_SUCCEED;
- }
- strDetectorInfo.add("DetectorName", m_stDeviceConfig.strDeviceName.c_str());
- strDetectorInfo.add("DetectorSN", m_stDeviceConfig.strPanelSerial.c_str());
- //strDetectorInfo.add("Firmware", m_stDeviceConfig.strFirmware.c_str());
- //strDetectorInfo.add("APFirmware", "NULL");
- //strDetectorInfo.add("Software", m_stDeviceConfig.strSoftware.c_str());
- //strDetectorInfo.add("SSID", m_stDeviceConfig.strWifiSSID.c_str());
- //strDetectorInfo.add("LifeTime", m_stDeviceConfig.nLifeTime);
- //strDetectorInfo.add("PowerOn", m_stDeviceConfig.nPowerOn);
- //strDetectorInfo.add("FD_Voltage_List1", m_strVoltage.c_str());
- //strDetectorInfo.add("DateCode", m_stDeviceConfig.strDateCode.c_str());
- //strDetectorInfo.add("PartNumber", m_stDeviceConfig.strPartNumber.c_str());
- //strDetectorInfo.add("WifiDataRate", m_stDeviceConfig.nWifiDataRate);
- //strDetectorInfo.add("WifiChannel", m_stDeviceConfig.nWifiChannel);
- //strDetectorInfo.add("DetectorExist", m_stDeviceConfig.bExisted);
- //strDetectorInfo.add("SystemAS", m_stDeviceConfig.pDetModeInfoStruct[0].nWorkStation);
- strInfo = strDetectorInfo.encode();
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::FaultInjection(string strErrorCode)
- {
- m_WarnAndError->SendError(strErrorCode, "");
- return RET_STATUS::RET_SUCCEED;
- }
- RET_STATUS nsFPD::FPDDeviceHaoBo::EliminateFault(string strErrorCode)
- {
- m_WarnAndError->ClearError(strErrorCode);
- return RET_STATUS::RET_SUCCEED;
- }
|