DIOS.Dev.FPD.HaoBoRF.cpp 59 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796
  1. #include "stdafx.h"
  2. #include "FileVersion.hpp"
  3. #include "CCOS.Dev.FPD.HaoBoRF.h"
  4. #include "common_api.h"
  5. #include "DICOMImageHeadKey.h"
  6. #include "Detector_HaoBoRF.h"
  7. #include <sys/stat.h>
  8. namespace nsFPD = CCOS::Dev::Detail::Detector;
  9. static nsFPD::HaoBoDriver gIODriver;
  10. Log4CPP::Logger* gLogger = nullptr;
  11. extern Detector_HaoBoRF* g_pDetector;
  12. extern const char* g_szMouldPath;
  13. HaoBoDriver* gDriver = nullptr;
  14. extern "C" CCOS::Dev::IODriver * __cdecl GetIODriver() // 返回静态对象的引用, 调用者不能删除 !
  15. {
  16. return &gIODriver;
  17. }
  18. extern "C" CCOS::Dev::IODriver * __cdecl CreateIODriver() // 返回新对象, 调用者必须自行删除此对象 !
  19. {
  20. gDriver = new nsFPD::HaoBoDriver();
  21. return gDriver;
  22. }
  23. nsFPD::HaoBoDriver::HaoBoDriver()
  24. {
  25. pObjDev = nullptr;
  26. m_bDriverConnect = false; //缺省为false
  27. m_pAttribute.reset(new ResDataObject());
  28. m_pDescription.reset(new ResDataObject());
  29. }
  30. nsFPD::HaoBoDriver::~HaoBoDriver()
  31. {
  32. if (pObjDev != nullptr)
  33. {
  34. delete pObjDev;
  35. pObjDev = nullptr;
  36. }
  37. Close();
  38. Log4CPP::ThreadContext::Map::Clear();
  39. gLogger = nullptr;
  40. }
  41. auto nsFPD::HaoBoDriver::CreateDevice(int index)->std::unique_ptr <IODevice>
  42. {
  43. printf("--Driver-- createdevice \r\n");
  44. FINFO("--Driver-- createdevice \n");
  45. pObjDev = new FPDDeviceHaoBo(EventCenter, m_ConfigFileName);
  46. auto Device = std::unique_ptr<IODevice>(new IODevice(pObjDev));
  47. pObjDev->CreateDevice();
  48. pObjDev->Register();
  49. return Device;
  50. }
  51. bool nsFPD::HaoBoDriver::Connect()
  52. {
  53. printf("--Driver-- connect \r\n");
  54. FINFO("--Driver-- connect");
  55. if (pObjDev && g_pDetector && !m_bDriverConnect)
  56. {
  57. pObjDev->Connect();
  58. }
  59. return m_bDriverConnect;
  60. }
  61. void nsFPD::HaoBoDriver::Disconnect()
  62. {
  63. printf("--Driver-- disconnect \r\n");
  64. FINFO("--Driver-- disconnect");
  65. if (pObjDev != nullptr)
  66. {
  67. delete pObjDev;
  68. pObjDev = nullptr;
  69. }
  70. m_bDriverConnect = false;
  71. }
  72. bool nsFPD::HaoBoDriver::isConnected() const
  73. {
  74. return m_bDriverConnect;
  75. }
  76. void nsFPD::HaoBoDriver::Prepare()
  77. {
  78. printf("--Driver-- prepare \r\n");
  79. string strLogPath = GetProcessDirectory() + R"(\Conf\Log4CPP.Config.xml)";
  80. auto rc = Log4CPP::LogManager::LoadConfigFile(strLogPath.c_str());
  81. gLogger = Log4CPP::LogManager::GetLogger("Module");
  82. FINFO("Code Build datetime [{$} {$}]", __DATE__, __TIME__);
  83. #ifdef _WIN64
  84. FINFO("=============================Version: {$} (64-bit)==================================", FileVersion(g_szMouldPath).GetVersionString());
  85. #else
  86. FINFO("=============================Version: {$} (32-bit)==================================", FileVersion(g_szMouldPath).GetVersionString());
  87. #endif
  88. FINFO("--Driver-- Prepare get logger");
  89. }
  90. std::string nsFPD::HaoBoDriver::DriverProbe()
  91. {
  92. printf("--Driver-- DriverProbe \r\n");
  93. FINFO("--Driver-- DriverProbe");
  94. ResDataObject r_config, HardwareInfo;
  95. if (r_config.loadFile(m_ConfigFileName.c_str()))
  96. {
  97. HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
  98. HardwareInfo.add("MinorID", r_config["CONFIGURATION"]["MinorID"]);
  99. HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
  100. HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
  101. HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
  102. }
  103. else
  104. {
  105. HardwareInfo.add("MajorID", "Detector");
  106. HardwareInfo.add("MinorID", "RF");
  107. HardwareInfo.add("VendorID", "HaoBo");
  108. HardwareInfo.add("ProductID", "HaoBo");
  109. HardwareInfo.add("SerialID", "Driver");
  110. }
  111. string str = HardwareInfo.encode();
  112. return str;
  113. }
  114. /***
  115. ** 获取ID和配置
  116. ***/
  117. std::string nsFPD::HaoBoDriver::GetResource()
  118. {
  119. printf("--Driver-- GetResource \r\n");
  120. FINFO("--Driver-- GetResource");
  121. ResDataObject r_config, temp;
  122. if (!temp.loadFile(m_ConfigFileName.c_str()))
  123. {
  124. FERROR("load file error! file name:{$}",m_ConfigFileName.c_str());
  125. return "";
  126. }
  127. m_ConfigAll = temp;
  128. r_config = temp["CONFIGURATION"];
  129. m_Configurations = r_config;
  130. ResDataObject DescriptionTemp;
  131. ResDataObject ListTemp;
  132. string strTemp = ""; //用于读取字符串配置信息
  133. string strIndex = ""; //用于读取配置信息中的List项
  134. int nTemp = -1; //用于读取整型配置信息
  135. char sstream[10] = { 0 }; //用于转换值
  136. string strValue = ""; //用于存储配置的值
  137. string strType = ""; //用于存储配置的类型 int/float/string...
  138. /***
  139. * 1. 通过循环,将所有配置项写到pDeviceConfig
  140. * 2. 记录配置项的内部key以及配置类型,类型对应了不同配置文件路径,用于读写真实值
  141. ***/
  142. try
  143. {
  144. int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
  145. //FINFO(g_pFPDCtrlLog, "ConfigInfo Count: {$}", nConfigInfoCount);
  146. m_pAttribute->clear();
  147. m_pDescription->clear();
  148. for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
  149. {
  150. DescriptionTemp.clear();
  151. ListTemp.clear();
  152. //AttributeType
  153. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Type"];
  154. DescriptionTemp.add(AttributeType, strTemp.c_str());
  155. //FINFO(g_pFPDCtrlLog, "--> {$}: {$}", AttributeType, strTemp.c_str());
  156. strType = strTemp; //记录配置项的类型
  157. //AttributeKey
  158. //1. 根据AttributeType,内部key和配置路径,拿到当前的真实值
  159. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
  160. nTemp = (int)m_Configurations["ConfigToolInfo"][nInfoIndex]["PathID"];
  161. GetDeviceConfigValue(r_config, strTemp.c_str(), nTemp, strValue);
  162. //2. 赋值
  163. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  164. if ("int" == strType)
  165. {
  166. (*m_pAttribute).add(strTemp.c_str(), atoi(strValue.c_str()));
  167. //FINFO(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), atoi(strValue.c_str()));
  168. }
  169. else if ("float" == strType)
  170. {
  171. (*m_pAttribute).add(strTemp.c_str(), atof(strValue.c_str()));
  172. //FINFO(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), atof(strValue.c_str()));
  173. }
  174. else //其它先按string类型处理
  175. {
  176. (*m_pAttribute).add(strTemp.c_str(), strValue.c_str());
  177. //FINFO(g_pFPDCtrlLog, "Key {$}: {$}", strTemp.c_str(), strValue.c_str());
  178. }
  179. //AttributeAccess
  180. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Access"];
  181. DescriptionTemp.add(AttributeAccess, strTemp.c_str());
  182. //FINFO(g_pFPDCtrlLog, "{$}: {$}", AttributeAccess, strTemp.c_str());
  183. //AttributeRangeMin
  184. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMin"];
  185. if (strTemp != "") //不需要的配置项为空
  186. {
  187. DescriptionTemp.add(AttributeRangeMin, strTemp.c_str());
  188. //FINFO(g_pFPDCtrlLog, "{$}: {$}", AttributeRangeMin, strTemp.c_str());
  189. }
  190. //AttributeRangeMax
  191. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["RangeMax"];
  192. if (strTemp != "") //不需要的配置项为空
  193. {
  194. DescriptionTemp.add(AttributeRangeMax, strTemp.c_str());
  195. //FINFO(g_pFPDCtrlLog, "{$}: {$}", AttributeRangeMax, strTemp.c_str());
  196. }
  197. //AttributeList
  198. nTemp = m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListNum"];
  199. if (nTemp > 0) //ListNum不大于0时说明不需要list配置
  200. {
  201. for (int nListIndex = 0; nListIndex < nTemp; nListIndex++)
  202. {
  203. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["ListInfo"][nListIndex];
  204. //sprintf_s(sstream, "{$}", nListIndex);
  205. auto temKey = std::to_string(nListIndex);
  206. ListTemp.add(temKey.c_str(), strTemp.c_str());
  207. //FINFO(g_pFPDCtrlLog, "list {$}: {$}", nListIndex, strTemp.c_str());
  208. }
  209. DescriptionTemp.add(AttributeList, ListTemp);
  210. }
  211. //AttributeRequired
  212. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["Required"];
  213. DescriptionTemp.add(AttributeRequired, strTemp.c_str());
  214. //FINFO(g_pFPDCtrlLog, "{$}: {$}", AttributeRequired, strTemp.c_str());
  215. //AttributeDefaultValue
  216. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeDescripition"]["DefaultValue"];
  217. if (strTemp != "") //不需要的配置项为空
  218. {
  219. DescriptionTemp.add(AttributeDefaultValue, strTemp.c_str());
  220. //FINFO(g_pFPDCtrlLog, "{$}: {$}", AttributeDefaultValue, strTemp.c_str());
  221. }
  222. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  223. (*m_pDescription).add(strTemp.c_str(), DescriptionTemp);
  224. }
  225. }
  226. catch (exception e)
  227. {
  228. FERROR("Get config error: {$}", e.what());
  229. return "";
  230. }
  231. ResDataObject resDeviceResource;
  232. resDeviceResource.add(ConfKey::CcosDetectorAttribute, (*m_pAttribute));
  233. resDeviceResource.add(ConfKey::CcosDetectorDescription, (*m_pDescription));
  234. ResDataObject DescriptionTempEx;
  235. DescriptionTempEx.add(ConfKey::CcosDetectorConfig, resDeviceResource);
  236. m_DeviceConfig = DescriptionTempEx;
  237. string res = DescriptionTempEx.encode();
  238. printf("HaoBoRF driver module: get resource over \r\n");
  239. //FINFO("get resource over {$}", res.c_str());//此处在调试读取配置的时候再放开,不然打印很长查日志不方便
  240. FINFO("get resource over!");
  241. return res;
  242. }
  243. std::string nsFPD::HaoBoDriver::DeviceProbe()
  244. {
  245. printf("--Driver-- DeviceProbe \r\n");
  246. FINFO("--Driver-- DeviceProbe");
  247. ResDataObject r_config, HardwareInfo;
  248. if (r_config.loadFile(m_ConfigFileName.c_str()))
  249. {
  250. HardwareInfo.add("MajorID", r_config["CONFIGURATION"]["MajorID"]);
  251. HardwareInfo.add("MinorID", "Device");
  252. HardwareInfo.add("VendorID", r_config["CONFIGURATION"]["VendorID"]);
  253. HardwareInfo.add("ProductID", r_config["CONFIGURATION"]["ProductID"]);
  254. HardwareInfo.add("SerialID", r_config["CONFIGURATION"]["SerialID"]);
  255. }
  256. else
  257. {
  258. HardwareInfo.add("MajorID", "Detector");
  259. HardwareInfo.add("MinorID", "Device");
  260. HardwareInfo.add("VendorID", "HaoBo");
  261. HardwareInfo.add("ProductID", "HaoBo");
  262. HardwareInfo.add("SerialID", "1234");
  263. }
  264. string str = HardwareInfo.encode();
  265. return str;
  266. }
  267. bool nsFPD::HaoBoDriver::GetDeviceConfig(std::string& Cfg)
  268. {
  269. printf("--Driver-- GetDeviceConfig \r\n");
  270. FINFO("--Driver-- GetDeviceConfig");
  271. Cfg = m_DeviceConfig.encode();
  272. FINFO("GetDeviceConfig over");
  273. return true;
  274. }
  275. bool nsFPD::HaoBoDriver::SetDeviceConfig(std::string Cfg)
  276. {
  277. printf("--Driver-- SetDeviceConfig \r\n");
  278. FINFO("--Driver-- SetDeviceConfig {$}", Cfg.c_str());
  279. ResDataObject DeviceConfig;
  280. DeviceConfig.decode(Cfg.c_str());
  281. ResDataObject DescriptionTempEx;
  282. DescriptionTempEx = DeviceConfig["DeviceConfig"];
  283. bool bSaveFile = false; //true:重新保存配置文件
  284. string strAccess = "";
  285. for (int i = 0; i < DescriptionTempEx.size(); i++)
  286. {
  287. ResDataObject temp = DescriptionTempEx[i];
  288. FINFO("{$}", temp.encode());
  289. for (int j = 0; j < temp.size(); j++)
  290. {
  291. string strKey = temp.GetKey(j);
  292. FINFO("{$}", strKey.c_str());
  293. try
  294. {
  295. if (m_pAttribute->GetFirstOf(strKey.c_str()) >= 0)
  296. {
  297. strAccess = (string)(*m_pDescription)[strKey.c_str()]["Access"];
  298. if ("RW" == strAccess || "rw" == strAccess)
  299. {
  300. //修改对应配置,在其他单元的配置项要同时调用其修改函数修改真实值
  301. //1. 修改内存中的值,用于给上层发消息
  302. (*m_pAttribute)[strKey.c_str()] = temp[j];
  303. //2. 拿到Innerkey
  304. int nConfigInfoCount = (int)m_Configurations["ConfigToolInfo"].GetKeyCount("AttributeInfo");
  305. FINFO("ConfigInfo Count: {$}", nConfigInfoCount);
  306. string strTemp = ""; //存储AttributeKey
  307. for (int nInfoIndex = 0; nInfoIndex < nConfigInfoCount; nInfoIndex++)
  308. {
  309. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["AttributeKey"];
  310. if (strTemp == strKey)
  311. {
  312. strTemp = (string)m_Configurations["ConfigToolInfo"][nInfoIndex]["InnerKey"];
  313. break;
  314. }
  315. }
  316. //3. 修改配置文件中的值
  317. if (SetDeviceConfigValue(m_Configurations, strTemp.c_str(), 1, temp[j]))
  318. {
  319. bSaveFile = true;
  320. }
  321. }
  322. else
  323. {
  324. FINFO("{$} is not a RW configuration item", strKey.c_str());
  325. }
  326. }
  327. }
  328. catch (ResDataObjectExption& e)
  329. {
  330. FERROR("SetDriverConfig crashed: {$}", e.what());
  331. return false;
  332. }
  333. }
  334. }
  335. if (bSaveFile)
  336. {
  337. //3. 重新保存配置文件
  338. SaveConfigFile(true);
  339. }
  340. return true;
  341. }
  342. bool nsFPD::HaoBoDriver::SaveConfigFile(bool bSendNotify)
  343. {
  344. FINFO("--Driver-- SaveConfigFile start m_ConfigFileName:{$}", m_ConfigFileName);
  345. m_ConfigAll["CONFIGURATION"] = m_Configurations;
  346. m_ConfigAll.SaveFile(m_ConfigFileName.c_str());
  347. FINFO("SaveConfigFile over");
  348. return true;
  349. }
  350. bool nsFPD::HaoBoDriver::GetDeviceConfigValue(ResDataObject config, const char* pInnerKey, int nPathID, string& strValue)
  351. {
  352. //strValue = "";
  353. //string strTemp = pInnerKey;
  354. //if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
  355. //{
  356. // if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp)
  357. // {
  358. // strValue = (string)config["connections"][pInnerKey];
  359. // }
  360. // else if (DetectorVender == strTemp || DetectorModel == strTemp ||
  361. // DetectorDescription == strTemp || DetectorSerialNumber == strTemp)
  362. // {
  363. // strValue = (string)config[pInnerKey];
  364. // }
  365. // else if (SyncType == strTemp || FPDWorkStation == strTemp || OperationMode == strTemp || ExamType == strTemp || ExiThreshold == strTemp ||
  366. // ImageWidth == strTemp || ImageHeight == strTemp || RawImgWidth == strTemp || RawImgHeight == strTemp)
  367. // {
  368. // strValue = (string)config["ModeTable"]["DetectorMode"][pInnerKey];
  369. // }
  370. // else if (TempMaxLimit == strTemp || ReConnect == strTemp ||
  371. // TempUpperLimit == strTemp || TempLowerLimit == strTemp || TempMinLimit == strTemp ||
  372. // BatLowerLimit == strTemp || BatMiniLimit == strTemp ||
  373. // BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp ||
  374. // WifiMiniLimit == strTemp || HighPowerTimeout == strTemp ||
  375. // ShowTemperature == strTemp || ShowWifi == strTemp ||
  376. // ShowBattery == strTemp || ShowBluetooth == strTemp ||
  377. // FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp || CcosDetectorAttachedFlag == strTemp)
  378. // {
  379. // strValue = (string)config[pInnerKey];
  380. // }
  381. // else
  382. // {
  383. // strValue = "";
  384. // FERROR("Error Configuration item: {$}", pInnerKey);
  385. // }
  386. //}
  387. return true;
  388. }
  389. bool nsFPD::HaoBoDriver::SetDeviceConfigValue(ResDataObject& config, const char* pInnerKey,
  390. int nPathID, const char* szValue)
  391. {
  392. //string strTemp = pInnerKey;
  393. //FINFO("Begin to change {$} item value to {$}", pInnerKey, szValue);
  394. //if (1 == nPathID) //从DriverConfig路径下每个DPC自己的配置文件读取
  395. //{
  396. // if (WiredIP == strTemp || WirelessIP == strTemp || LocalIP == strTemp)
  397. // {
  398. // config["connections"][pInnerKey] = szValue;
  399. // }
  400. // else if (DetectorVender == strTemp || DetectorModel == strTemp ||
  401. // DetectorDescription == strTemp || DetectorSerialNumber == strTemp)
  402. // {
  403. // config[pInnerKey] = szValue;
  404. // }
  405. // else if (SyncType == strTemp || FPDWorkStation == strTemp || OperationMode == strTemp || ExamType == strTemp || ExiThreshold == strTemp ||
  406. // ImageWidth == strTemp || ImageHeight == strTemp || RawImgWidth == strTemp || RawImgHeight == strTemp)
  407. // {
  408. // config["ModeTable"]["DetectorMode"][pInnerKey] = szValue;
  409. // }
  410. // else if (TempMaxLimit == strTemp || ReConnect == strTemp ||
  411. // TempUpperLimit == strTemp || TempLowerLimit == strTemp ||
  412. // BatLowerLimit == strTemp || BatMiniLimit == strTemp ||
  413. // BatLowerLimitInCali == strTemp || WifiLowerLimit == strTemp ||
  414. // WifiMiniLimit == strTemp || HighPowerTimeout == strTemp ||
  415. // ShowTemperature == strTemp || ShowWifi == strTemp ||
  416. // ShowBattery == strTemp || ShowBluetooth == strTemp ||
  417. // FPDExamMode == strTemp || FPDAcqMode == strTemp || FPDModeMatch == strTemp || CcosDetectorAttachedFlag == strTemp)
  418. // {
  419. // config[pInnerKey] = szValue;
  420. // }
  421. // else
  422. // {
  423. // FERROR("Error Configuration item: {$}", pInnerKey);
  424. // return false;
  425. // }
  426. //}
  427. return true;
  428. }
  429. nsFPD::FPDDeviceHaoBo::FPDDeviceHaoBo(std::shared_ptr<IOEventCenter> center,std::string strConfigPath)
  430. {
  431. m_strWorkPath = GetProcessDirectory();
  432. m_nWidth = 0;
  433. m_nHeight = 0;
  434. m_nImgBits = 0;
  435. m_nAngle = 0;
  436. m_nPixelSpacing = 0;
  437. m_nSensitivity = 0;
  438. m_fDose = 0.0f;
  439. m_pImgBuffer = nullptr;
  440. m_eAppStatus = APP_STATUS::APP_STATUS_IDLE;
  441. m_bDeviceConnect = false;
  442. m_nCurrentAcqMode = 0;
  443. m_fCurrentPPS = 15.0f;
  444. m_vAcqModeInfoList.clear();
  445. m_fFactorEXI2UGY = 0.0f;
  446. m_DetectorCtrlUnit.reset(new OemCtrl(center, this));
  447. m_AcqUnit.reset(new OemAcq(center, this));
  448. m_SyncUnit.reset(new OemSync(center, this));
  449. m_CalibUnit.reset(new OemCalib(center, this));
  450. m_DetectorConfiguration.reset(new DetectorConfiguration(strConfigPath));
  451. m_WarnAndError.reset(new FPDErrorWarning(center, DetectorUnitType, m_strWorkPath));
  452. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_INIT));
  453. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  454. EventCenter = center;
  455. }
  456. nsFPD::FPDDeviceHaoBo::~FPDDeviceHaoBo()
  457. {
  458. FINFO("~FPDDeviceHaoBo");
  459. if (g_pDetector)
  460. {
  461. delete g_pDetector;
  462. g_pDetector = nullptr;
  463. }
  464. if (m_pImgBuffer)
  465. {
  466. delete m_pImgBuffer;
  467. m_pImgBuffer = nullptr;
  468. }
  469. m_vAcqModeInfoList.clear();
  470. }
  471. std::string nsFPD::FPDDeviceHaoBo::GetGUID() const
  472. {
  473. return DetectorUnitType;
  474. }
  475. bool nsFPD::FPDDeviceHaoBo::CreateDevice()
  476. {
  477. printf("--Func-- device CreateDevice \r\n");
  478. FINFO("--Func-- device CreateDevice \n");
  479. if (!LoadConfig())
  480. {
  481. return false;
  482. }
  483. if (nullptr == g_pDetector)
  484. {
  485. g_pDetector = new Detector_HaoBoRF();
  486. }
  487. g_pDetector->DriverEntry(this, m_DetectorConfiguration->m_Configurations, m_strWorkPath.c_str());
  488. m_DetectorCtrlUnit->SetAttachStatus("1"); //没有attach功能,直接上发1,使客户端显示探测器状态
  489. m_DetectorCtrlUnit->SetDetectorWidth(to_string(m_stDeviceConfig.nDetectorWidth));
  490. m_DetectorCtrlUnit->SetDetectorHeight(to_string(m_stDeviceConfig.nDetectorHeight));
  491. m_DetectorCtrlUnit->SetSupportDDR(to_string(m_stDeviceConfig.nSupportDDR));
  492. m_DetectorCtrlUnit->SetTargetEXI("5000");
  493. m_CalibUnit->SetOffsetInterval(to_string(m_stDeviceConfig.nOffsetInterval));
  494. return true;
  495. }
  496. RET_STATUS nsFPD::FPDDeviceHaoBo::Connect()
  497. {
  498. printf("--Func-- device Connect \r\n");
  499. FINFO("--Func-- device Connect");
  500. if (!g_pDetector->Connect(this))
  501. {
  502. FERROR("Connect Detector fail!");
  503. return RET_STATUS::RET_FAILED;
  504. }
  505. return RET_STATUS::RET_SUCCEED;
  506. }
  507. bool nsFPD::FPDDeviceHaoBo::Prepare()
  508. {
  509. printf("--Func-- device Prepare \r\n");
  510. FINFO("--Func-- device prepare nDetectorWidth:{$},nDetectorHeight:{$}", m_stDeviceConfig.nDetectorWidth, m_stDeviceConfig.nDetectorHeight);
  511. //blockname, fullimage blocksize, blockcount,previewimage blocksize,blockcount
  512. EventCenter->OnMaxBlockSize("HaoBoRfQue", 4000 * 4000 * 2, 10, 1500 * 1500 * 2, 1);
  513. return true;
  514. }
  515. bool nsFPD::FPDDeviceHaoBo::LoadConfig()
  516. {
  517. printf("--Func-- device LoadConfig \r\n");
  518. FINFO("--Func-- device LoadConfig start");
  519. //LoadConfigurations必须比下边俩函数先调用,否则会有问题
  520. if (!m_DetectorConfiguration->LoadConfigurations(m_stDeviceConfig, m_vAcqModeInfoList))
  521. {
  522. FERROR("Load configuration file failed!!!");
  523. return false;
  524. }
  525. //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
  526. m_Battery.reset(new DeviceBatteryMould("DetectorBattery", 0,
  527. m_stDeviceConfig.nBatteryLimit,
  528. m_stDeviceConfig.nBatteryWarning,
  529. 90, 20, 90, 100, 0, EventCenter));
  530. //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
  531. m_Temperature.reset(new DeviceTemperatureMould("DetectorTemperature", 0.0f,
  532. m_stDeviceConfig.fTemperatureErrorMin,
  533. m_stDeviceConfig.fTemperatureWarnMin,
  534. m_stDeviceConfig.fTemperatureWarnMax,
  535. 20.0f, 100.0f,
  536. m_stDeviceConfig.fTemperatureErrorMax,
  537. 0.0f, EventCenter));
  538. //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
  539. m_Wifi.reset(new DeviceWifiMould("DetectorWifi", 0,
  540. m_stDeviceConfig.nWifiLimit,
  541. m_stDeviceConfig.nWifiWarning,
  542. 100, 10, 100, 100, 0, EventCenter));
  543. FINFO("--Func-- device LoadConfig end");
  544. return true;
  545. }
  546. void nsFPD::FPDDeviceHaoBo::Register()
  547. {
  548. FINFO("--Func-- device Register \n");
  549. auto Disp = &Dispatch;
  550. RegisterCtrl(Disp);
  551. RegisterAcq(Disp);
  552. RegisterSync(Disp);
  553. RegisterCalib(Disp);
  554. RegisterOthers(Disp);
  555. }
  556. RET_STATUS nsFPD::FPDDeviceHaoBo::EnterExam(int nExamMode)
  557. {
  558. FINFO("--Func-- EnterExam {$}", nExamMode);
  559. switch (nExamMode)
  560. {
  561. case APP_STATUS_WORK_BEGIN:
  562. FINFO("Enter into Exam Windows");
  563. m_eAppStatus = APP_STATUS_WORK_BEGIN;
  564. break;
  565. case APP_STATUS_WORK_END:
  566. FINFO("Quit Exam Windows");
  567. m_eAppStatus = APP_STATUS_WORK_END;
  568. break;
  569. case APP_STATUS_DETSHARE_BEGIN:
  570. FINFO("Enter into Detector Share Windows");
  571. m_eAppStatus = APP_STATUS_DETSHARE_BEGIN;
  572. break;
  573. case APP_STATUS_DETSHAR_END:
  574. m_eAppStatus = APP_STATUS_IDLE;
  575. FINFO("Quit Detector Share Windows");
  576. m_eAppStatus = APP_STATUS_DETSHAR_END;
  577. break;
  578. case APP_STATUS_CAL_BEGIN:
  579. FINFO("Enter into Calibration Windows");
  580. m_eAppStatus = APP_STATUS_CAL_BEGIN;
  581. break;
  582. case APP_STATUS_CAL_END:
  583. FINFO("Quit Calibration Windows");
  584. m_eAppStatus = APP_STATUS_CAL_END;
  585. break;
  586. case APP_STATUS_WORK_IN_SENSITIVITY:
  587. FINFO("Enter into sensitivity test interface");
  588. m_eAppStatus = APP_STATUS_WORK_IN_SENSITIVITY;
  589. break;
  590. default:
  591. break;
  592. }
  593. g_pDetector->EnterExamMode(nExamMode);
  594. return RET_STATUS::RET_SUCCEED;
  595. }
  596. bool nsFPD::FPDDeviceHaoBo::GetLogicMode(string& strAcqMode, int& nLogicMode)
  597. {
  598. if (strAcqMode == "RAD")
  599. {
  600. nLogicMode = RAD;
  601. }
  602. else if (strAcqMode == "CF")
  603. {
  604. nLogicMode = CF;
  605. }
  606. else if (strAcqMode == "PF")
  607. {
  608. nLogicMode = PF;
  609. }
  610. else if (strAcqMode == "1")
  611. {
  612. nLogicMode = RAD;
  613. }
  614. else if (strAcqMode == "2")
  615. {
  616. nLogicMode = CF;
  617. }
  618. else if (strAcqMode == "3")
  619. {
  620. nLogicMode = PF;
  621. }
  622. else
  623. {
  624. FERROR("Not support mode!");
  625. return false;
  626. }
  627. return true;
  628. }
  629. RET_STATUS nsFPD::FPDDeviceHaoBo::SetAcqMode(string strAcqMode)
  630. {
  631. printf("--Func-- SetAcqMode(%s) \r\n", strAcqMode.c_str());
  632. FINFO("--Func-- SetAcqMode strAcqMode:{$}", strAcqMode);
  633. RET_STATUS ret = RET_STATUS::RET_FAILED;
  634. //如果没连接,不执行
  635. if (!m_bDeviceConnect)
  636. {
  637. FERROR("Detector not connected, return");
  638. return ret;
  639. }
  640. //由于动态需要ready快,故通知探测器ready状态在这里通知
  641. if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus() || DETECTOR_STATUS_CALIB == m_DetectorCtrlUnit->GetDetectorStatus())
  642. {
  643. FINFO("Detector is not standby! neet to stop");
  644. ret = StopAcquisition();
  645. if (ret != RET_STATUS::RET_SUCCEED)
  646. {
  647. FERROR("SetAcqMode StopAcquisition fail!!!");
  648. return ret;
  649. }
  650. else
  651. {
  652. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  653. }
  654. }
  655. else
  656. {
  657. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  658. }
  659. int nMode = RAD;
  660. bool bRet = GetLogicMode(strAcqMode, nMode);
  661. if (!bRet)
  662. {
  663. return RET_STATUS::RET_FAILED;
  664. }
  665. try
  666. {
  667. ResDataObject objModeConfig = m_DetectorConfiguration->m_Configurations;
  668. int nModeCount = (int)objModeConfig["ModeTable"].size();
  669. for (int i = 0; i < nModeCount; i++)
  670. {
  671. //FINFO("ModeTable {$}, {$}",i, objModeConfig["ModeTable"][i].encode());
  672. int nAppModeID = (int)objModeConfig["ModeTable"][i]["LogicMode"];
  673. if (nAppModeID == nMode)
  674. {
  675. m_nAngle = (int)objModeConfig["ModeTable"][i]["RotateAngle"];
  676. m_nPixelSpacing = (int)objModeConfig["ModeTable"][i]["PixelPitch"];
  677. m_nImgBits = (int)objModeConfig["ModeTable"][i]["PhySizeInfoBit"];
  678. m_nSensitivity = (int)objModeConfig["ModeTable"][i]["Sensitivity"];
  679. FINFO("m_nAngle:{$}, m_nPixelSpacing:{$}, m_nImgBits:{$}, m_nSensitivity:{$}", m_nAngle, m_nPixelSpacing, m_nImgBits, m_nSensitivity);
  680. string strDoseOfExi = std::to_string(m_nSensitivity);
  681. m_fFactorEXI2UGY = 100.0f / stof(strDoseOfExi) * 1.0f;//统一使用IEC标准 呈现四角信息,无单位 ugy * 100 -ugy。所有Zskk探测器的FactorEXI2UGY均需*100
  682. FINFO("m_fFactorEXI2UGY = {$} ", m_fFactorEXI2UGY);
  683. m_DetectorCtrlUnit->SetFPDSensitivity(std::to_string(m_fFactorEXI2UGY));
  684. break;
  685. }
  686. }
  687. }
  688. catch (ResDataObjectExption& e)
  689. {
  690. FERROR("Read configuration failed, Error code: {$}", e.what());
  691. ret = RET_STATUS::RET_FAILED;
  692. return ret;
  693. }
  694. m_nCurrentAcqMode = nMode;
  695. if (g_pDetector->SetAcqMode(nMode))
  696. {
  697. ret = RET_STATUS::RET_SUCCEED;
  698. m_AcqUnit->AcqModeNotify(strAcqMode);
  699. }
  700. else
  701. {
  702. ret = RET_STATUS::RET_FAILED;
  703. }
  704. return ret;
  705. }
  706. RET_STATUS nsFPD::FPDDeviceHaoBo::PrepareAcquisition()
  707. {
  708. printf("--Func-- PrepareAcquisition \r\n");
  709. FINFO("--Func-- PrepareAcquisition");
  710. RET_STATUS ret = RET_STATUS::RET_FAILED;
  711. if (!m_bDeviceConnect)
  712. {
  713. FERROR("Detector not connected, return");
  714. return ret;
  715. }
  716. if ((m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING) ||
  717. (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_ACTIVE))
  718. {
  719. FERROR("PrepareAcquisition failed! Detector at Calibration status!");
  720. return ret;
  721. }
  722. if (g_pDetector->PrepareAcquisition(this))
  723. {
  724. ret = RET_STATUS::RET_SUCCEED;
  725. }
  726. FINFO("PrepareAcquisition over");
  727. return ret;
  728. }
  729. RET_STATUS nsFPD::FPDDeviceHaoBo::StartAcquisition(string in)
  730. {
  731. printf("--Func-- StartAcquisition \r\n");
  732. FINFO("--Func-- StartAcquisition");
  733. FINFO("StartAcquisition param in:{$}", in);
  734. RET_STATUS ret = RET_STATUS::RET_FAILED;
  735. if (!m_bDeviceConnect)
  736. {
  737. FERROR("Detector not connected, return");
  738. return ret;
  739. }
  740. FINFO("StartAcquisition m_nCurrentAcqMode:{$}", m_nCurrentAcqMode);
  741. if (in == "RAD" || in == "CF" || in == "PF")
  742. {
  743. ret = SetAcqMode(in);
  744. if (ret != RET_STATUS::RET_SUCCEED)
  745. {
  746. FERROR("StartAcquisition SetAcqMode fail!");
  747. return ret;
  748. }
  749. }
  750. else
  751. {
  752. FERROR("Not support this mode, mode name:{$}",in);
  753. return ret;
  754. }
  755. ret = PrepareAcquisition();
  756. if (ret != RET_STATUS::RET_SUCCEED)
  757. {
  758. FERROR("StartAcquisition PrepareAcquisition fail!");
  759. return ret;
  760. }
  761. if (g_pDetector->StartAcquisition(this))
  762. {
  763. ret = RET_STATUS::RET_SUCCEED;
  764. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
  765. }
  766. else
  767. {
  768. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  769. }
  770. FINFO("StartAcquisition over");
  771. return ret;
  772. }
  773. RET_STATUS nsFPD::FPDDeviceHaoBo::StopAcquisition()
  774. {
  775. printf("--Func-- StopAcquisition \r\n");
  776. FINFO("--Func-- StopAcquisition");
  777. RET_STATUS ret = RET_STATUS::RET_FAILED;
  778. if (!m_bDeviceConnect)
  779. {
  780. FERROR("Detector not connected, return");
  781. return ret;
  782. }
  783. if (DETECTOR_STATUS_STANDBY == m_DetectorCtrlUnit->GetDetectorStatus())
  784. {
  785. //printf(("Detector already at stanby status.\n");
  786. FINFO("Detector already at stanby status.");
  787. ret = RET_STATUS::RET_SUCCEED;
  788. }
  789. else
  790. {
  791. if (g_pDetector->StopAcquisition(this))
  792. {
  793. ret = RET_STATUS::RET_SUCCEED;
  794. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  795. }
  796. }
  797. FINFO("StopAcquisition over");
  798. return ret;
  799. }
  800. RET_STATUS nsFPD::FPDDeviceHaoBo::SetFluPPS(float fFluPPS)
  801. {
  802. FINFO("--Func-- SetFluPPS:{$}", fFluPPS);
  803. m_fCurrentPPS = fFluPPS;
  804. bool bFind = false;
  805. //更新m_fFrameRate值
  806. for (size_t i = 0; i < m_vAcqModeInfoList.size(); i++)
  807. {
  808. if (m_vAcqModeInfoList[i].fFrequency == fFluPPS)
  809. {
  810. FINFO("find config pps");
  811. bFind = true;
  812. g_pDetector->UpdateModeInRunning(m_vAcqModeInfoList[i].nModeID,fFluPPS);
  813. m_AcqUnit->FluPPSNotify(fFluPPS);
  814. break;
  815. }
  816. }
  817. if (!bFind)
  818. {
  819. FINFO("not find config pps");
  820. float fRealFps = g_pDetector->SetFluPPS(fFluPPS);
  821. if (fRealFps > 0.0f)
  822. {
  823. m_AcqUnit->FluPPSNotify(fRealFps);
  824. }
  825. }
  826. return RET_STATUS::RET_SUCCEED;
  827. }
  828. RET_STATUS nsFPD::FPDDeviceHaoBo::GetFluPPS(float& fFluPPS)
  829. {
  830. g_pDetector->GetFluPPS(fFluPPS);
  831. return RET_STATUS::RET_SUCCEED;
  832. }
  833. RET_STATUS nsFPD::FPDDeviceHaoBo::SetXrayOnNum()
  834. {
  835. FINFO("--Func-- SetXrayOnNum");
  836. return RET_STATUS::RET_FAILED;
  837. }
  838. RET_STATUS nsFPD::FPDDeviceHaoBo::SetExposureTimes(int nTimes)
  839. {
  840. FINFO("--Func-- SetExposureTimes({$})", nTimes);
  841. if (g_pDetector->SetExposureTimes(nTimes))
  842. {
  843. return RET_STATUS::RET_SUCCEED;
  844. }
  845. return RET_STATUS::RET_FAILED;
  846. }
  847. RET_STATUS nsFPD::FPDDeviceHaoBo::ActiveCalibration(CCOS_CALIBRATION_TYPE eType)
  848. {
  849. printf("--Func-- ActiveCalibration eType:%d \r\n", eType);
  850. FINFO("--Func-- ActiveCalibration {$}", (int)eType);
  851. RET_STATUS ret = RET_STATUS::RET_FAILED;
  852. if (!m_bDeviceConnect)
  853. {
  854. FERROR("Detector not connected, return");
  855. return ret;
  856. }
  857. if (eType == CCOS_CALIBRATION_TYPE_NONE || eType == CCOS_CALIBRATION_TYPE_MAX)
  858. {
  859. return RET_STATUS::RET_INVALID;
  860. }
  861. if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus())
  862. {
  863. if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
  864. {
  865. //printf(("ActiveCalibration failed. Detector at Acq status\r\n");
  866. FERROR("ActiveCalibration failed. Detector at Acq status");
  867. }
  868. return RET_STATUS::RET_FAILED;
  869. }
  870. if (g_pDetector->ActiveCalibration(this, eType))
  871. {
  872. ret = RET_STATUS::RET_SUCCEED;
  873. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_ACTIVE));
  874. m_CalibUnit->SetCalibrationProgress("0");
  875. }
  876. else
  877. {
  878. FERROR("Active calibration failed");
  879. }
  880. FINFO("ActiveCalibration over");
  881. return ret;
  882. }
  883. RET_STATUS nsFPD::FPDDeviceHaoBo::PrepareCalibration()
  884. {
  885. printf("--Func-- PrepareCalibration \r\n");
  886. FINFO("--Func-- PrepareCalibration");
  887. RET_STATUS ret = RET_STATUS::RET_FAILED;
  888. if (!m_bDeviceConnect)
  889. {
  890. FERROR("Detector not connected, return");
  891. return ret;
  892. }
  893. if (g_pDetector->PrepareCalibration(this))
  894. {
  895. ret = RET_STATUS::RET_SUCCEED;
  896. }
  897. else
  898. {
  899. FERROR("Prepare calibration failed");
  900. }
  901. FINFO("PrepareCalibration over");
  902. return ret;
  903. }
  904. RET_STATUS nsFPD::FPDDeviceHaoBo::GetRequestedDose(std::string& strDose)
  905. {
  906. printf("--Func-- GetRequestedDose \r\n");
  907. FINFO("--Func-- GetRequestedDose");
  908. RET_STATUS Ret = RET_STATUS::RET_SUCCEED;
  909. bool bGetDoseInfo = false;
  910. ResDataObject out;
  911. CCOS_CALIBRATION_TYPE nCalibrationType = m_CalibUnit->GetCalibrationType();
  912. if (CCOS_CALIBRATION_TYPE_DARK == nCalibrationType)
  913. {
  914. out.add("Dose", 0.0f);
  915. out.add("kV", 0.0f);
  916. out.add("mA", 0.0f);
  917. out.add("ms", 0.0f);
  918. out.add("mAs", 0.0f);
  919. bGetDoseInfo = true;
  920. }
  921. else if (CCOS_CALIBRATION_TYPE_XRAY == nCalibrationType)
  922. {
  923. for (int i = 0; i < m_CalibDoseList.size(); i++)
  924. {
  925. ResDataObject temp = m_CalibDoseList[i];
  926. int nDose = temp["Dose"];
  927. int nDoseParem = (int)(m_fDose * 1000);
  928. if (nDoseParem == nDose)
  929. {
  930. out.add("Dose", nDoseParem);
  931. out.add("kV", temp["kV"]);
  932. out.add("mA", temp["mA"]);
  933. out.add("ms", temp["ms"]);
  934. out.add("mAs", temp["mAs"]);
  935. bGetDoseInfo = true;
  936. break;
  937. }
  938. }
  939. }
  940. else
  941. {
  942. Ret = RET_STATUS::RET_FAILED;
  943. }
  944. if (bGetDoseInfo)
  945. {
  946. strDose = out.encode();
  947. FINFO("GetRequestedDose {$} over", strDose.c_str());
  948. }
  949. else
  950. {
  951. FERROR("GetRequestedDose failed");
  952. }
  953. return Ret;
  954. }
  955. RET_STATUS nsFPD::FPDDeviceHaoBo::StartCalibration()
  956. {
  957. printf("--Func-- StartCalibration \r\n");
  958. FINFO("--Func-- StartCalibration");
  959. RET_STATUS ret = RET_STATUS::RET_FAILED;
  960. if (!m_bDeviceConnect)
  961. {
  962. FERROR("Detector not connected, return");
  963. return ret;
  964. }
  965. if ((m_CalibUnit->GetCalibrationStatus() != CCOS_CALIBRATION_STATUS_PAUSE) && (m_CalibUnit->GetCalibrationStatus() != CCOS_CALIBRATION_STATUS_ACTIVE))
  966. {
  967. FERROR("Start calibration failed, in {$} status", (int)m_CalibUnit->GetCalibrationStatus());
  968. return ret;
  969. }
  970. if (DETECTOR_STATUS_STANDBY != m_DetectorCtrlUnit->GetDetectorStatus())
  971. {
  972. if (DETECTOR_STATUS_ACQ == m_DetectorCtrlUnit->GetDetectorStatus())
  973. {
  974. FERROR("Start calibration failed. Detector already at Acq status");
  975. }
  976. return ret;
  977. }
  978. if (m_CalibUnit->GetCalibrationStatus() == CCOS_CALIBRATION_STATUS_RUNNING)
  979. {
  980. FERROR("Detector already at calib status");
  981. return ret;
  982. }
  983. if (g_pDetector->StartCalibration(this))
  984. {
  985. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));
  986. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_RUNNING));
  987. ret = RET_STATUS::RET_SUCCEED;
  988. }
  989. else
  990. {
  991. FERROR("Start calibration failed");
  992. return ret;
  993. }
  994. FINFO("StartCalibration over");
  995. return ret;
  996. }
  997. RET_STATUS nsFPD::FPDDeviceHaoBo::StopCalibration()
  998. {
  999. printf("--Func-- StopCalibration \r\n");
  1000. FINFO("--Func-- StopCalibration");
  1001. RET_STATUS ret = RET_STATUS::RET_FAILED;
  1002. if (!m_bDeviceConnect)
  1003. {
  1004. FERROR("Detector not connected, return");
  1005. return ret;
  1006. }
  1007. if (g_pDetector->StopCalibration(this))
  1008. {
  1009. ret = RET_STATUS::RET_SUCCEED;
  1010. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  1011. m_CalibUnit->SetCalibrationProgress("100");
  1012. }
  1013. else
  1014. {
  1015. FERROR("Start calibration failed");
  1016. }
  1017. FINFO("StopCalibration over");
  1018. return ret;
  1019. }
  1020. bool nsFPD::FPDDeviceHaoBo::Support_DarkCalib()
  1021. {
  1022. return true;
  1023. }
  1024. bool nsFPD::FPDDeviceHaoBo::Support_XrayCalib()
  1025. {
  1026. return true;
  1027. }
  1028. //理论上定义的Action和Attr的名称要在CCOS.Dev.FPDDeviceMould.hpp中定义,之前由于不清楚导致有的名称在Detector_Model_Def.h中定义的 以后要规范
  1029. void nsFPD::FPDDeviceHaoBo::RegisterCtrl(nsDetail::Dispatch* Dispatch)
  1030. {
  1031. Dispatch->Action.Push(ActionKey::GetFPDinformation, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorInfo);
  1032. Dispatch->Action.Push(ActionKey::ActiveDetector, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSActiveDetector);
  1033. Dispatch->Action.Push(ActionKey::EnterExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSEnterExam);
  1034. Dispatch->Action.Push(ActionKey::ExitExam, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSExitExam);
  1035. Dispatch->Action.Push(ActionKey::SetXrayOnNum, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetXrayOnNum);
  1036. Dispatch->Action.Push(ActionKey::SetExposureTimes, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSSetExposureTimes);
  1037. Dispatch->Action.Push(ActionKey::FaultInjection, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSFaultInjection);
  1038. Dispatch->Action.Push(ActionKey::EliminateFault, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSEliminateFault);
  1039. Dispatch->Get.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDStatus);
  1040. Dispatch->Get.Push(AttrKey::Description, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDescription);
  1041. Dispatch->Get.Push(AttrKey::FPDSensitivity, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetFPDSensitivity);
  1042. Dispatch->Get.Push(AttrKey::TargetEXI, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetTargetEXI);
  1043. Dispatch->Get.Push(SupportDDR, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetSupportDDR);
  1044. Dispatch->Get.Push(AttrKey::DetectorID, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorID);
  1045. Dispatch->Get.Push(AttrKey::DetectorType, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorType);
  1046. Dispatch->Get.Push(AttrKey::PixelData, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetPixelData);
  1047. Dispatch->Get.Push(AttrKey::DetectorWidth, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorWidth);
  1048. Dispatch->Get.Push(AttrKey::DetectorHeight, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::JSGetDetectorHeight);
  1049. Dispatch->Set.Push(AttrKey::DetectorStatus, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorStatus);
  1050. Dispatch->Set.Push(AttrKey::Description, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDescription);
  1051. Dispatch->Set.Push(AttrKey::FPDSensitivity, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetFPDSensitivity);
  1052. Dispatch->Set.Push(AttrKey::TargetEXI, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetTargetEXI);
  1053. Dispatch->Set.Push(SupportDDR, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetSupportDDR);
  1054. Dispatch->Set.Push(AttrKey::DetectorID, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorID);
  1055. Dispatch->Set.Push(AttrKey::DetectorType, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetDetectorType);
  1056. Dispatch->Set.Push(AttrKey::PixelData, m_DetectorCtrlUnit.get(), &DetectorCtrlUnit::SetPixelData);
  1057. }
  1058. void nsFPD::FPDDeviceHaoBo::RegisterAcq(nsDetail::Dispatch* Dispatch)
  1059. {
  1060. Dispatch->Action.Push(ActionKey::SetAcqMode, m_AcqUnit.get(), &AcqUnit::JSSetAcqMode);
  1061. Dispatch->Action.Push(ActionKey::SetValue_PPS, m_AcqUnit.get(), &AcqUnit::JSSetFluPPS);
  1062. Dispatch->Get.Push(AttrKey::AcqMode, m_AcqUnit.get(), &AcqUnit::JSGetAcqMode);
  1063. Dispatch->Get.Push(AttrKey::ZskkFPDState, m_AcqUnit.get(), &AcqUnit::JSGetZskkFPDState);
  1064. Dispatch->Get.Push(AttrKey::NoNeedWaitImage, m_AcqUnit.get(), &AcqUnit::JSGetNoNeedWaitImage);
  1065. Dispatch->Get.Push(AttrKey::ImgDataInfo, m_AcqUnit.get(), &AcqUnit::JSGetLastImage);
  1066. Dispatch->Get.Push(AttrKey::MaxFrameRate, m_AcqUnit.get(), &AcqUnit::JSGetMaxFrameRate);
  1067. Dispatch->Get.Push(AttrKey::FluPPS, m_AcqUnit.get(), &AcqUnit::JSGetFluPPS);
  1068. Dispatch->Set.Push(AttrKey::ZskkFPDState, m_AcqUnit.get(), &AcqUnit::SetZskkFPDState);
  1069. Dispatch->Set.Push(AttrKey::NoNeedWaitImage, m_AcqUnit.get(), &AcqUnit::JSSetNoNeedWaitImage);
  1070. Dispatch->Update.Push(AttrKey::ModeInRunning, m_AcqUnit.get(), &AcqUnit::JSUpdateModeInRunning);
  1071. }
  1072. void nsFPD::FPDDeviceHaoBo::RegisterSync(nsDetail::Dispatch* Dispatch)
  1073. {
  1074. Dispatch->Action.Push(ActionKey::PrepareAcquisition, m_SyncUnit.get(), &SyncUnit::JSPrepareAcquisition);
  1075. Dispatch->Action.Push(ActionKey::StartAcquisition, m_SyncUnit.get(), &SyncUnit::JSStartAcquisition);
  1076. Dispatch->Action.Push(ActionKey::StopAcquisition, m_SyncUnit.get(), &SyncUnit::JSStopAcquisition);
  1077. Dispatch->Get.Push(AttrKey::FPDReadyStatus, m_SyncUnit.get(), &SyncUnit::JSGetFPDReady);
  1078. Dispatch->Get.Push(AttrKey::XwindowStatus, m_SyncUnit.get(), &SyncUnit::JSGetXWindowStatus);
  1079. Dispatch->Get.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSGetImageReadingStatus);
  1080. Dispatch->Set.Push(AttrKey::FPDReadyStatus, m_SyncUnit.get(), &SyncUnit::JSSetFPDReady);
  1081. Dispatch->Set.Push(AttrKey::XwindowStatus, m_SyncUnit.get(), &SyncUnit::JSSetXWindowStatus);
  1082. Dispatch->Set.Push(AttrKey::ImageReadingStatus, m_SyncUnit.get(), &SyncUnit::JSSetImageReadingStatus);
  1083. }
  1084. void nsFPD::FPDDeviceHaoBo::RegisterCalib(nsDetail::Dispatch* Dispatch)
  1085. {
  1086. Dispatch->Action.Push(ActionKey::ActiveCalibration, m_CalibUnit.get(), &CalibUnit::JSActiveCalibration);
  1087. Dispatch->Action.Push(ActionKey::GetRequestedDose, m_CalibUnit.get(), &CalibUnit::JSGetRequestedDose);
  1088. Dispatch->Action.Push(ActionKey::PrepareCalibration, m_CalibUnit.get(), &CalibUnit::JSPrepareCalibration);
  1089. Dispatch->Action.Push(ActionKey::StartCalibration, m_CalibUnit.get(), &CalibUnit::JSStartCalibration);
  1090. Dispatch->Action.Push(ActionKey::StopCalibration, m_CalibUnit.get(), &CalibUnit::JSStopCalibration);
  1091. Dispatch->Action.Push(ActionKey::SetCorrectionType, m_CalibUnit.get(), &CalibUnit::JSSetCorrectionType);
  1092. Dispatch->Action.Push(ActionKey::StartOffset, m_CalibUnit.get(), &CalibUnit::JSStartOffset);
  1093. Dispatch->Action.Push(ActionKey::AbortOffset, m_CalibUnit.get(), &CalibUnit::JSAbortOffset);
  1094. Dispatch->Get.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::JSGetCalibStatus);
  1095. Dispatch->Get.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::JSGetCalibProgress);
  1096. Dispatch->Get.Push(AttrKey::UploadCalibrationFilesResult, m_CalibUnit.get(), &CalibUnit::JSGetUploadCalibrationFilesResult);
  1097. Dispatch->Get.Push(AttrKey::OffsetStatus, m_CalibUnit.get(), &CalibUnit::JSGetOffsetStatus);
  1098. Dispatch->Get.Push(AttrKey::OffsetCounts, m_CalibUnit.get(), &CalibUnit::JSGetOffsetCounts);
  1099. Dispatch->Get.Push(AttrKey::OffsetProgress, m_CalibUnit.get(), &CalibUnit::JSGetOffsetProgress);
  1100. Dispatch->Get.Push(AttrKey::OffsetInterval, m_CalibUnit.get(), &CalibUnit::JSGetOffsetInterval);
  1101. Dispatch->Set.Push(AttrKey::CalibrationStatus, m_CalibUnit.get(), &CalibUnit::SetCalibrationStatus);
  1102. Dispatch->Set.Push(AttrKey::CalibrationProgress, m_CalibUnit.get(), &CalibUnit::SetCalibrationProgress);
  1103. Dispatch->Set.Push(AttrKey::UploadCalibrationFilesResult, m_CalibUnit.get(), &CalibUnit::SetUploadCalibrationFilesResult);
  1104. Dispatch->Set.Push(AttrKey::OffsetStatus, m_CalibUnit.get(), &CalibUnit::SetOffsetStatus);
  1105. Dispatch->Set.Push(AttrKey::OffsetCounts, m_CalibUnit.get(), &CalibUnit::SetOffsetCounts);
  1106. Dispatch->Set.Push(AttrKey::OffsetProgress, m_CalibUnit.get(), &CalibUnit::SetOffsetProgress);
  1107. Dispatch->Set.Push(AttrKey::OffsetInterval, m_CalibUnit.get(), &CalibUnit::SetOffsetInterval);
  1108. Dispatch->Update.Push(AttrKey::OffsetInterval, m_CalibUnit.get(), &CalibUnit::JSUpdateOffsetInterval);
  1109. }
  1110. void nsFPD::FPDDeviceHaoBo::RegisterOthers(nsDetail::Dispatch* Dispatch)
  1111. {
  1112. Dispatch->Get.Push(AttrKey::Temperature_Value, m_Temperature.get(), &DeviceTemperatureMould::JSGetCurrentTemperatureValue);
  1113. Dispatch->Get.Push(AttrKey::Remain_Power_Value, m_Battery.get(), &DeviceBatteryMould::JSGetCurrentBatteryValue);
  1114. Dispatch->Get.Push(AttrKey::Wifi_Strength_Value, m_Wifi.get(), &DeviceWifiMould::JSGetCurrentSignalValue);
  1115. Dispatch->Get.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMax);
  1116. Dispatch->Get.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureWarningMin);
  1117. Dispatch->Get.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMax);
  1118. Dispatch->Get.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureErrorMin);
  1119. Dispatch->Get.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureCalibWarningMax);
  1120. Dispatch->Get.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::JSGetTemperatureCalibWarningMin);
  1121. Dispatch->Get.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryWarningMin);
  1122. Dispatch->Get.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSGetBatteryErrorMin);
  1123. Dispatch->Get.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalWarningMin);
  1124. Dispatch->Get.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSGetSignalErrorMin);
  1125. //ErrorList
  1126. Dispatch->Get.Push(nDetail::AttrKey::ErrorList, m_WarnAndError.get(), &FPDErrorWarning::JSGetErrorList);
  1127. Dispatch->Set.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMax);
  1128. Dispatch->Set.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureWarningMin);
  1129. Dispatch->Set.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMax);
  1130. Dispatch->Set.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureErrorMin);
  1131. Dispatch->Set.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureCalibWarningMax);
  1132. Dispatch->Set.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::SetTemperatureCalibWarningMin);
  1133. Dispatch->Set.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryWarningMin);
  1134. Dispatch->Set.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::SetBatteryErrorMin);
  1135. Dispatch->Set.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalWarningMin);
  1136. Dispatch->Set.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::SetSignalErrorMin);
  1137. Dispatch->Update.Push(TempUpperLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMax);
  1138. Dispatch->Update.Push(TempLowerLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureWarningMin);
  1139. Dispatch->Update.Push(TempMaxLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMax);
  1140. Dispatch->Update.Push(TempMinLimit, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureErrorMin);
  1141. Dispatch->Update.Push(TemperatureCalibUpWarn, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureCalibWarningMax);
  1142. Dispatch->Update.Push(TemperatureCalibLowWarn, m_Temperature.get(), &DeviceTemperatureMould::JSUpdateTemperatureCalibWarningMin);
  1143. Dispatch->Update.Push(BatLowerLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryWarningMin);
  1144. Dispatch->Update.Push(BatMiniLimit, m_Battery.get(), &DeviceBatteryMould::JSUpdateBatteryErrorMin);
  1145. Dispatch->Update.Push(WifiLowerLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalWarningMin);
  1146. Dispatch->Update.Push(WifiMiniLimit, m_Wifi.get(), &DeviceWifiMould::JSUpdateSignalErrorMin);
  1147. }
  1148. void nsFPD::FPDDeviceHaoBo::OnFPDCallback(int nDetectorID, int nEventID, int nEventLevel,
  1149. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1150. {
  1151. switch (nEventLevel)
  1152. {
  1153. case EVT_LEVEL_CONFIGURATION:
  1154. {
  1155. OnEventProcessConf(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1156. break;
  1157. }
  1158. case EVT_LEVEL_INFORMATOION:
  1159. {
  1160. OnEventProcessInfo(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1161. break;
  1162. }
  1163. case EVT_LEVEL_STATUS:
  1164. {
  1165. OnEventProcessStatus(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1166. break;
  1167. }
  1168. case EVT_LEVEL_DATA:
  1169. {
  1170. OnEventProcessData(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1171. break;
  1172. }
  1173. case EVT_LEVEL_WARNING:
  1174. {
  1175. OnEventProcessWarning(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1176. break;
  1177. }
  1178. case EVT_LEVEL_ERROR:
  1179. {
  1180. OnEventProcessError(nDetectorID, nEventID, nEventLevel, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1181. break;
  1182. }
  1183. default:
  1184. break;
  1185. }
  1186. }
  1187. void nsFPD::FPDDeviceHaoBo::OnEventProcessConf(int nDetectorID, int nEventID, int nEventLevel,
  1188. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1189. {
  1190. switch (nEventID)
  1191. {
  1192. case EVT_CONF_PANEL_SERIAL:
  1193. {
  1194. m_stDeviceConfig.strPanelSerial = pszMsg;
  1195. FINFO("Receive Panel {$} SN {$}", nDetectorID, pszMsg);
  1196. m_DetectorCtrlUnit->SetDetectorID(m_stDeviceConfig.strPanelSerial);
  1197. break;
  1198. }
  1199. case EVT_CONF_RAW_WIDTH:
  1200. {
  1201. if (m_stDeviceConfig.nFullImageWidth != nParam1)
  1202. {
  1203. m_stDeviceConfig.nFullImageWidth = nParam1;
  1204. }
  1205. if (m_nWidth != nParam1)
  1206. {
  1207. m_nWidth = nParam1;
  1208. }
  1209. FINFO("Ratate angle: {$}", m_nAngle);
  1210. if (m_nAngle == 90 || m_nAngle == 270)
  1211. {
  1212. m_AcqUnit->SetFulImageInfo(m_nWidth, m_nHeight, m_nImgBits, false);
  1213. }
  1214. else
  1215. {
  1216. m_AcqUnit->SetFulImageInfo(m_nHeight, m_nWidth, m_nImgBits, false);
  1217. }
  1218. FINFO("Panel {$} m_nWidth:{$}", nDetectorID, m_nWidth);
  1219. break;
  1220. }
  1221. case EVT_CONF_RAW_HIGHT:
  1222. {
  1223. if (m_stDeviceConfig.nFullImageHeight != nParam1)
  1224. {
  1225. m_stDeviceConfig.nFullImageHeight = nParam1;
  1226. }
  1227. if (m_nHeight != nParam1)
  1228. {
  1229. m_nHeight = nParam1;
  1230. }
  1231. FINFO("Ratate angle: {$}", m_nAngle);
  1232. if (m_nAngle == 90 || m_nAngle == 270)
  1233. {
  1234. m_AcqUnit->SetFulImageInfo(m_nWidth, m_nHeight, m_nImgBits, false);
  1235. }
  1236. else
  1237. {
  1238. m_AcqUnit->SetFulImageInfo(m_nHeight, m_nWidth, m_nImgBits, false);
  1239. }
  1240. FINFO("Panel {$} m_nHeight:{$}", nDetectorID, m_nHeight);
  1241. break;
  1242. }
  1243. case EVT_CONF_MAX_IMAGESIZE:
  1244. {
  1245. int nImageSize = nParam1;
  1246. FINFO("Receive image size:{$}", nImageSize);
  1247. if (m_pImgBuffer)
  1248. {
  1249. delete m_pImgBuffer;
  1250. m_pImgBuffer = nullptr;
  1251. }
  1252. m_pImgBuffer = new WORD[nImageSize];
  1253. }
  1254. }
  1255. }
  1256. void nsFPD::FPDDeviceHaoBo::OnEventProcessInfo(int nDetectorID, int nEventID, int nEventLevel,
  1257. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1258. {
  1259. FERROR("Not support this info({$})", nEventID);
  1260. }
  1261. void nsFPD::FPDDeviceHaoBo::OnEventProcessStatus(int nDetectorID, int nEventID, int nEventLevel,
  1262. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1263. {
  1264. switch (nEventID)
  1265. {
  1266. case EVT_STATUS_PANEL:
  1267. {
  1268. ENUM_PANEL_STATUS ePanelStatus = (ENUM_PANEL_STATUS)nParam1;
  1269. if (PANEL_CLOSE == nParam1)
  1270. {
  1271. FINFO("EVT_STATUS_PANEL PANEL_CLOSE");
  1272. m_bDeviceConnect = false;
  1273. gDriver->m_bDriverConnect = false;
  1274. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_SHUTDOWN));
  1275. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_DISCONNECT_SUCCESS));
  1276. m_WarnAndError->SendError(ERR_FPD_DISCONNECT, "");
  1277. }
  1278. else if (PANEL_CONNECT == nParam1)
  1279. {
  1280. FINFO("EVT_STATUS_PANEL PANEL_CONNECT");
  1281. gDriver->m_bDriverConnect = true;
  1282. m_bDeviceConnect = true;
  1283. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_WAKEUP));
  1284. m_DetectorCtrlUnit->SetConnectStatus(to_string(PANEL_CONNECT_OK));
  1285. m_WarnAndError->ClearError(ERR_FPD_DISCONNECT);
  1286. }
  1287. else if (PANEL_STANDBY == nParam1)
  1288. {
  1289. FINFO("EVT_STATUS_PANEL PANEL_STANDBY");
  1290. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_WAKEUP));
  1291. }
  1292. else if (PANEL_READY_EXP == nParam1)
  1293. {
  1294. FINFO("EVT_STATUS_PANEL PANEL_READY_EXP");
  1295. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1296. m_AcqUnit->SetZskkFPDState(to_string(ZSKK_FPD_STATE_READY));
  1297. }
  1298. else if (PANEL_XWINDOW_ON == nParam1) //Xwindow On
  1299. {
  1300. FINFO("EVT_STATUS_PANEL PANEL_XWINDOW_ON");
  1301. m_SyncUnit->XWindowOnNotify();
  1302. }
  1303. else if (PANEL_XWINDOW_OFF == nParam1) // Xwindow Off
  1304. {
  1305. FINFO("EVT_STATUS_PANEL PANEL_XWINDOW_OFF");
  1306. m_SyncUnit->XWindowOffNotify();
  1307. }
  1308. else if (PANEL_START_ACQ == nParam1)
  1309. {
  1310. FINFO("EVT_STATUS_PANEL PANEL_START_ACQ");
  1311. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_ACQ));//PANEL_START_ACQ
  1312. }
  1313. break;
  1314. }
  1315. case EVT_STATUS_CALIBRATIOIN:
  1316. {
  1317. ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
  1318. switch (eStatus)
  1319. {
  1320. case PANEL_EVENT_START:
  1321. break;
  1322. case PANEL_EVENT_END_OK:
  1323. case PANEL_EVENT_END_ERROR:
  1324. m_DetectorCtrlUnit->SetDetectorStatus(to_string(DETECTOR_STATUS_STANDBY));
  1325. m_CalibUnit->SetCalibrationStatus(to_string(CCOS_CALIBRATION_STATUS_STANDBY));
  1326. m_CalibUnit->SetCalibrationProgress("100");//make progress
  1327. break;
  1328. case PANEL_EVENT_TIMEOUT:
  1329. break;
  1330. default:
  1331. break;
  1332. }
  1333. break;
  1334. }
  1335. case EVT_STATUS_OFFSET:
  1336. {
  1337. ENUM_PANEL_EVENT_STATE eStatus = (ENUM_PANEL_EVENT_STATE)nParam1;
  1338. switch (eStatus)
  1339. {
  1340. case PANEL_EVENT_END_OK:
  1341. m_CalibUnit->SetOffsetStatus("Idle");
  1342. break;
  1343. case PANEL_EVENT_END_ERROR:
  1344. m_CalibUnit->SetOffsetStatus("Error");
  1345. break;
  1346. case PANEL_EVENT_START:
  1347. m_CalibUnit->SetOffsetStatus("Running");
  1348. break;
  1349. default:
  1350. break;
  1351. }
  1352. break;
  1353. }
  1354. case EVT_STATUS_OFFSET_PROGRESS:
  1355. {
  1356. FINFO("EVT_STATUS_OFFSET_PROGRESS param:{$}", nParam1);
  1357. int nOffsetProgress = nParam1;
  1358. m_CalibUnit->SetOffsetProgress(to_string(nOffsetProgress));
  1359. break;
  1360. }
  1361. case EVT_STATUS_TEMPERATURE:
  1362. {
  1363. float fTemperature = fParam2;
  1364. /*if (fTemperature > m_fTemperMaxLimit)
  1365. {
  1366. AddErrMsg("14", "temperature_toohigh");
  1367. }
  1368. else if (fTemperature >= m_fTemperWarning)
  1369. {
  1370. AddWarnMsg("14", "temperature_high");
  1371. }
  1372. else if (fTemperature < m_fTemperMinLimit)
  1373. {
  1374. AddErrMsg("14", "temperature_toolow");
  1375. }
  1376. else if (fTemperature <= m_fTemperLowLimit)
  1377. {
  1378. AddWarnMsg("14", "temperature_low");
  1379. }
  1380. else
  1381. {
  1382. DelErrMsg("14");
  1383. }*/
  1384. //SendTemperatureValue(fTemperature);
  1385. break;
  1386. }
  1387. case EVT_STATUS_WIFI:
  1388. {
  1389. int nWifiLevel = nParam1;
  1390. /*if (nWifiLevel < m_nWifiLimit)
  1391. {
  1392. AddErrMsg("15", "wifi_toolow");
  1393. }
  1394. else if (nWifiLevel <= m_nWifiWarning)
  1395. {
  1396. AddWarnMsg("15", "wifi_low");
  1397. }
  1398. else
  1399. {
  1400. DelErrMsg("15");
  1401. }*/
  1402. //SendWifiValue(nWifiLevel);
  1403. break;
  1404. }
  1405. case EVT_STATUS_BATTERY_VALUE:
  1406. {
  1407. int nBatteryValue = nParam1;
  1408. /*if (nBatteryValue < m_nBatteryLimit)
  1409. {
  1410. AddErrMsg("16", "battery_toolow");
  1411. }
  1412. else if (nBatteryValue <= m_nBatteryWarning)
  1413. {
  1414. AddWarnMsg("16", "battery_low");
  1415. }
  1416. else
  1417. {
  1418. DelErrMsg("16");
  1419. }*/
  1420. //SendBatteryValue(nBatteryValue);
  1421. break;
  1422. }
  1423. default:
  1424. FERROR("Not support this status({$})", nEventID);
  1425. break;
  1426. }
  1427. }
  1428. void nsFPD::FPDDeviceHaoBo::OnEventProcessData(int nDetectorID, int nEventID, int nEventLevel,
  1429. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1430. {
  1431. switch (nEventID)
  1432. {
  1433. case EVT_DATA_RAW_IMAGE:
  1434. {
  1435. FINFO("EVT_DATA_RAW_IMAGE");
  1436. FINFO("m_nWidth:{$},m_nHeight:{$}", m_nWidth, m_nHeight);
  1437. memcpy(m_pImgBuffer, pParam, (size_t)m_nWidth * (size_t)m_nHeight * sizeof(WORD));
  1438. //暂时先用假值,有需要再改
  1439. SYSTEMTIME stImgCreateTime = { 0 };
  1440. GetLocalTime(&stImgCreateTime);
  1441. ResDataObject objImageHead, objTemp;
  1442. objTemp.add(SM_IMAGE_TYPE, (int)IMAGE_FULL);
  1443. objTemp.add(SM_IMAGE_BIT, m_nImgBits);
  1444. objTemp.add(SM_IMAGE_TAG, 1);
  1445. objTemp.add(SM_IMAGE_INDEX, 1);
  1446. objTemp.add(SM_IMAGE_YEAR, stImgCreateTime.wYear);
  1447. objTemp.add(SM_IMAGE_MONTH, stImgCreateTime.wMonth);
  1448. objTemp.add(SM_IMAGE_DAY, stImgCreateTime.wDay);
  1449. objTemp.add(SM_IMAGE_HOUR, stImgCreateTime.wHour);
  1450. objTemp.add(SM_IMAGE_MINUTE, stImgCreateTime.wMinute);
  1451. objTemp.add(SM_IMAGE_SEC, stImgCreateTime.wSecond);
  1452. objTemp.add(SM_IMAGE_MILLSEC, stImgCreateTime.wMilliseconds);
  1453. objTemp.add(SM_IMAGE_LSB, "5000");
  1454. objTemp.add(SM_IMAGE_DOSE, m_nSensitivity);
  1455. objTemp.add(SM_IMAGE_PIXELSPACING, m_nPixelSpacing);
  1456. objTemp.add(SM_IMAGE_PIXELREPRESENTATION, "1");
  1457. objTemp.add(SM_IMAGE_FLIP, "No");
  1458. objTemp.add(SM_IMAGE_ORIGINX, "0");
  1459. objTemp.add(SM_IMAGE_ORIGINY, "0");
  1460. objTemp.add(SM_IMAGE_EXI2UGY, m_fFactorEXI2UGY);//此项不添加的话会导致ImageSave计算EXI的值为0
  1461. m_AcqUnit->RotateImage(m_pImgBuffer, m_nHeight, m_nWidth, m_nAngle);
  1462. if (90 == m_nAngle || 270 == m_nAngle)
  1463. {
  1464. objTemp.add(SM_IMAGE_WIDTH, m_nHeight);
  1465. objTemp.add(SM_IMAGE_HEIGHT, m_nWidth);
  1466. objTemp.add(SM_IMAGE_ROTATION, "Yes");
  1467. }
  1468. else
  1469. {
  1470. objTemp.add(SM_IMAGE_WIDTH, m_nWidth);
  1471. objTemp.add(SM_IMAGE_HEIGHT, m_nHeight);
  1472. objTemp.add(SM_IMAGE_ROTATION, "No");
  1473. }
  1474. objImageHead.add(SM_IMAGE_HEAD, objTemp);
  1475. FINFO("Full image head: {$}", objImageHead.encode());
  1476. RET_STATUS ret = RET_STATUS::RET_FAILED;
  1477. ret = m_AcqUnit->AddFrameWithRawHead(IMAGE_FULL, objImageHead.encode(), m_pImgBuffer, m_nWidth * m_nHeight);
  1478. FINFO("Add image over");
  1479. break;
  1480. }
  1481. default:
  1482. FERROR("Not support this data({$})", nEventID);
  1483. break;
  1484. }
  1485. }
  1486. void nsFPD::FPDDeviceHaoBo::OnEventProcessError(int nDetectorID, int nEventID, int nEventLevel,
  1487. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1488. {
  1489. switch (nEventID)
  1490. {
  1491. case EVT_ERR_COMMUNICATE:
  1492. //{
  1493. // string strTemp = pszMsg;
  1494. // if (strTemp.find("true") != std::string::npos)
  1495. // {
  1496. // AddErrMsg("0", "communication error");
  1497. // SendTemperatureValue(0);
  1498. // SendWifiValue(0);
  1499. // SendBatteryValue(0);
  1500. // }
  1501. // else if (strTemp.find("false") != std::string::npos)
  1502. // {
  1503. // DelErrMsg("0");
  1504. // }
  1505. //}
  1506. break;
  1507. case EVT_ERR_INIT_FAILED:
  1508. //{
  1509. // string strTemp = pszMsg;
  1510. // if (strTemp.find("true") != std::string::npos)
  1511. // {
  1512. // AddErrMsg("6", "initialize error");
  1513. // }
  1514. // else if (strTemp.find("false") != std::string::npos)
  1515. // {
  1516. // //一般不可恢复
  1517. // }
  1518. //}
  1519. break;
  1520. default:
  1521. FERROR("Not support this error({$})", nEventID);
  1522. break;
  1523. }
  1524. }
  1525. void nsFPD::FPDDeviceHaoBo::OnEventProcessWarning(int nDetectorID, int nEventID, int nEventLevel,
  1526. const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1527. {
  1528. FERROR("Not support this warn({$})", nEventID);
  1529. }
  1530. RET_STATUS nsFPD::FPDDeviceHaoBo::StartOffset(bool isAll)
  1531. {
  1532. FINFO("--Func-- StartOffset isAll:{$}", isAll);
  1533. if (isAll)
  1534. {
  1535. m_CalibUnit->SetOffsetCounts(to_string(1));
  1536. g_pDetector->SetFreshAllOffsetEvent();
  1537. }
  1538. else
  1539. {
  1540. m_CalibUnit->SetOffsetCounts(to_string(1));
  1541. g_pDetector->SetfreshOffsetEvent();
  1542. }
  1543. return RET_SUCCEED;
  1544. }
  1545. RET_STATUS nsFPD::FPDDeviceHaoBo::AbortOffset()
  1546. {
  1547. FINFO("--Func-- AbortOffset");
  1548. g_pDetector->AbortFreshOffset();
  1549. return RET_SUCCEED;
  1550. }
  1551. RET_STATUS nsFPD::FPDDeviceHaoBo::UpdateModeInRunning(std::vector<AcqModeInfo>& vAcqModeList)
  1552. {
  1553. FINFO("--Func-- UpdateModeInRunning");
  1554. m_vAcqModeInfoList.assign(vAcqModeList.begin(),vAcqModeList.end());
  1555. for (size_t i = 0; i < m_vAcqModeInfoList.size(); i++)
  1556. {
  1557. if (m_vAcqModeInfoList[i].fFrequency == m_fCurrentPPS)
  1558. {
  1559. g_pDetector->UpdateModeInRunning(m_vAcqModeInfoList[i].nModeID, m_vAcqModeInfoList[i].fFrequency);
  1560. break;
  1561. }
  1562. }
  1563. return RET_SUCCEED;
  1564. }
  1565. /***
  1566. * 客户端获取探测器信息
  1567. ***/
  1568. RET_STATUS nsFPD::FPDDeviceHaoBo::GetDetectorInfo(string& strInfo)
  1569. {
  1570. FINFO("--Func-- GetDetectorInfo");
  1571. ResDataObject strDetectorInfo;
  1572. if (m_stDeviceConfig.strPanelSerial == "")
  1573. {
  1574. FWARN("strPanelSerial is null, Send Default Info");
  1575. strDetectorInfo.add("DetectorName", "Simulator");
  1576. strDetectorInfo.add("DetectorSN", "Simulator");
  1577. strDetectorInfo.add("SSID", " ");
  1578. strDetectorInfo.add("LifeTime", "0");
  1579. strDetectorInfo.add("PowerOn", "0");
  1580. strDetectorInfo.add("DateCode", " ");
  1581. strDetectorInfo.add("PartNumber", " ");
  1582. strDetectorInfo.add("WifiDataRate", " ");
  1583. strDetectorInfo.add("WifiChannel", "0");
  1584. strDetectorInfo.add("DetectorExist", "0");
  1585. strDetectorInfo.add("SystemAS", "0");
  1586. strDetectorInfo.add("CalibrationDate", "0");
  1587. strDetectorInfo.add("CalibrationDue", "0");
  1588. strDetectorInfo.add("CalibrationExist", "0");
  1589. strDetectorInfo.add("CommunicationStatus", "0");
  1590. strDetectorInfo.add("DetectorTemperature", "0");
  1591. strDetectorInfo.add("FDCalibrationTemperature", "0");
  1592. strDetectorInfo.add("TemperatureStatus", "0");
  1593. strDetectorInfo.add("WaitTime", "0");
  1594. strDetectorInfo.add("DetectorWifiSignal", "0");
  1595. strDetectorInfo.add("DetectorBattery", "0");
  1596. strDetectorInfo.add("ShockSensor", "NULL");
  1597. strDetectorInfo.add("FirmwareUpdate", "0");
  1598. strInfo = strDetectorInfo.encode();
  1599. return RET_STATUS::RET_SUCCEED;
  1600. }
  1601. strDetectorInfo.add("DetectorName", m_stDeviceConfig.strDeviceName.c_str());
  1602. strDetectorInfo.add("DetectorSN", m_stDeviceConfig.strPanelSerial.c_str());
  1603. //strDetectorInfo.add("Firmware", m_stDeviceConfig.strFirmware.c_str());
  1604. //strDetectorInfo.add("APFirmware", "NULL");
  1605. //strDetectorInfo.add("Software", m_stDeviceConfig.strSoftware.c_str());
  1606. //strDetectorInfo.add("SSID", m_stDeviceConfig.strWifiSSID.c_str());
  1607. //strDetectorInfo.add("LifeTime", m_stDeviceConfig.nLifeTime);
  1608. //strDetectorInfo.add("PowerOn", m_stDeviceConfig.nPowerOn);
  1609. //strDetectorInfo.add("FD_Voltage_List1", m_strVoltage.c_str());
  1610. //strDetectorInfo.add("DateCode", m_stDeviceConfig.strDateCode.c_str());
  1611. //strDetectorInfo.add("PartNumber", m_stDeviceConfig.strPartNumber.c_str());
  1612. //strDetectorInfo.add("WifiDataRate", m_stDeviceConfig.nWifiDataRate);
  1613. //strDetectorInfo.add("WifiChannel", m_stDeviceConfig.nWifiChannel);
  1614. //strDetectorInfo.add("DetectorExist", m_stDeviceConfig.bExisted);
  1615. //strDetectorInfo.add("SystemAS", m_stDeviceConfig.pDetModeInfoStruct[0].nWorkStation);
  1616. strInfo = strDetectorInfo.encode();
  1617. return RET_STATUS::RET_SUCCEED;
  1618. }
  1619. RET_STATUS nsFPD::FPDDeviceHaoBo::FaultInjection(string strErrorCode)
  1620. {
  1621. m_WarnAndError->SendError(strErrorCode, "");
  1622. return RET_STATUS::RET_SUCCEED;
  1623. }
  1624. RET_STATUS nsFPD::FPDDeviceHaoBo::EliminateFault(string strErrorCode)
  1625. {
  1626. m_WarnAndError->ClearError(strErrorCode);
  1627. return RET_STATUS::RET_SUCCEED;
  1628. }