Detector_HaoBoRF.cpp 58 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042
  1. #include "stdafx.h"
  2. #include "Detector_HaoBoRF.h"
  3. #include "CCOS.Dev.FPD.HaoBoRF.h"
  4. extern Log4CPP::Logger* gLogger;
  5. Detector_HaoBoRF* g_pDetector = nullptr;
  6. #define LOAD_PROC_ADDRESS(handle,func) \
  7. if ((func = (API_##func)GetProcAddress(handle, #func)) == NULL) { FERROR("loading entry point {$} error!!!", #func); }\
  8. #define BREAK_UINT32(var, ByteNum) \
  9. (unsigned char)((unsigned int)(((var) >> ((ByteNum)* 8)) & 0x00FF))
  10. #define BUILD_UINT32(Byte0, Byte1, Byte2, Byte3) \
  11. ((unsigned int)((unsigned int)((Byte0)& 0x00FF) \
  12. + ((unsigned int)((Byte1)& 0x00FF) << 8) \
  13. + ((unsigned int)((Byte2)& 0x00FF) << 16) \
  14. + ((unsigned int)((Byte3)& 0x00FF) << 24)))
  15. Detector_HaoBoRF::Detector_HaoBoRF()
  16. {
  17. m_pDPC2PanelID = new map<void*, int>();
  18. m_pPanelID2DPC = new map<int, void*>();
  19. m_nPanelCount = 0;
  20. m_nCurrentPanelID = 0;
  21. m_bConnected = false;
  22. m_nCurrentLogicMode = -1;
  23. m_pRawImgBuffer = nullptr;
  24. m_pFullImgBuffer = nullptr;
  25. m_nSaveRaw = 0;
  26. m_strCtrlWorkPath = "";
  27. m_eCaliType = CCOS_CALIBRATION_TYPE::CCOS_CALIBRATION_TYPE_NONE;
  28. m_eStatus = eDetStatus::DetStatus_NotIni;
  29. m_nMaxImgWidth = 0;
  30. m_nMaxImgHeight = 0;
  31. m_nRawImageWidth = 0;
  32. m_nRawImageHeight = 0;
  33. m_nCropLeft = 0;
  34. m_nCropRight = 0;
  35. m_nCropTop = 0;
  36. m_nCropBottom = 0;
  37. m_nImageWidth = 0;
  38. m_nImageHeight = 0;
  39. m_nFrameID = 0;
  40. m_nDropImgNum = 0;
  41. m_nDropImgCount = 0;
  42. m_nExamMode = APP_STATUS::APP_STATUS_MAX;
  43. m_hFPDScanThread = nullptr;
  44. m_fFrameRate = 10.0f; //缺省值,10帧每秒
  45. m_nDelayTime = 0;
  46. m_nExiThreshold = 200;//新增配置
  47. m_nImageBits = 16;
  48. m_bFirstImage = true;
  49. m_nModeID = 1;
  50. m_nGainLevel = 3;
  51. m_hSDKModule = nullptr;
  52. m_nFpdHandle = nullptr;
  53. m_bLoaded = false;
  54. nPGALevel = 0;
  55. nBinning = 0;
  56. nPrepareTime = 0;
  57. nLiveAcqTime = 0;
  58. m_hStopScanEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
  59. m_hAcqEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
  60. m_hGainEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
  61. m_hDarkEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
  62. m_hProcessImgEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
  63. m_hArrayEvent[0] = m_hStopScanEvent;
  64. m_hArrayEvent[1] = m_hAcqEvent;
  65. m_hArrayEvent[2] = m_hGainEvent;
  66. m_hArrayEvent[3] = m_hDarkEvent;
  67. m_hArrayEvent[4] = m_hProcessImgEvent;
  68. m_hStopOffsetEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
  69. m_hStartAllOffset = CreateEvent(NULL, FALSE, FALSE, NULL);
  70. m_hStartOffset = CreateEvent(NULL, FALSE, FALSE, NULL);
  71. m_hAbortOffset = CreateEvent(NULL, FALSE, FALSE, NULL);
  72. m_hOffsetEvent[0] = m_hStopOffsetEvent;
  73. m_hOffsetEvent[1] = m_hStartAllOffset;
  74. m_hOffsetEvent[2] = m_hStartOffset;
  75. m_hOffsetEvent[3] = m_hAbortOffset;
  76. }
  77. Detector_HaoBoRF::~Detector_HaoBoRF()
  78. {
  79. FINFO("~Detector_HaoBoRF");
  80. if (m_hStopScanEvent)
  81. {
  82. CloseHandle(m_hStopScanEvent);
  83. m_hStopScanEvent = nullptr;
  84. }
  85. if (m_hAcqEvent)
  86. {
  87. CloseHandle(m_hAcqEvent);
  88. m_hAcqEvent = nullptr;
  89. }
  90. if (m_hGainEvent)
  91. {
  92. CloseHandle(m_hGainEvent);
  93. m_hGainEvent = nullptr;
  94. }
  95. if (m_hDarkEvent)
  96. {
  97. CloseHandle(m_hDarkEvent);
  98. m_hDarkEvent = nullptr;
  99. }
  100. if (m_hProcessImgEvent)
  101. {
  102. CloseHandle(m_hProcessImgEvent);
  103. m_hProcessImgEvent = nullptr;
  104. }
  105. if (m_pRawImgBuffer)
  106. {
  107. delete[]m_pRawImgBuffer;
  108. m_pRawImgBuffer = nullptr;
  109. }
  110. if (m_pFullImgBuffer != nullptr)
  111. {
  112. delete[]m_pFullImgBuffer;
  113. m_pFullImgBuffer = nullptr;
  114. }
  115. FINFO("Call HBI_Destroy");
  116. HBI_Destroy(m_nFpdHandle);
  117. }
  118. //参数说明:
  119. // @USER_CALLBACK_HANDLE_ENVENT
  120. // @pContext:参数 1,上位机对象指针,可以为空(NULL)
  121. // @ufpdId:参数 2,例如平板id
  122. // @byteEventid:参数 3,事件 ID,参考HbiType.h 中 enumeCallbackEventCommType
  123. // @PVEventParam1:参数 4,配置指针或图像结构体指针
  124. // @nEventParam2:参数 5,例如datasize 或状态
  125. // @nEventParam3:参数 6,例如帧号 frameid
  126. // @nEventParam4:参数 7,例如帧率 framerate 或状态等
  127. int CallBackFunc(void* _contex, int nDevId, unsigned char byteEventId, void* param1, int param2, int param3, int param4)
  128. {
  129. FINFO("CallBackFunc nDevId:{$},byteEventId:{$},param2:{$},param3:{$},param4:{$}", nDevId, (int)byteEventId, param2, param3, param4);
  130. int ret = 0;
  131. ImageData* imagedata = NULL;
  132. RegCfgInfo* pRegCfg = NULL;
  133. int status = -1;
  134. switch (byteEventId)
  135. {
  136. case ECALLBACK_TYPE_INVALVE:
  137. {
  138. FINFO("Callback Type: ECALLBACK_TYPE_INVALVE");
  139. break;
  140. }
  141. case ECALLBACK_TYPE_COMM_RIGHT:
  142. {
  143. FINFO("Callback Type: ECALLBACK_TYPE_COMM_RIGHT");
  144. break;
  145. }
  146. case ECALLBACK_TYPE_COMM_WRONG:
  147. {
  148. FINFO("Callback Type: ECALLBACK_TYPE_COMM_WRONG");
  149. break;
  150. }
  151. case ECALLBACK_TYPE_DUMMPLING:
  152. {
  153. FINFO("Callback Type: ECALLBACK_TYPE_DUMMPLING");
  154. break;
  155. }
  156. case ECALLBACK_TYPE_ACQ_END:
  157. {
  158. FINFO("Callback Type: ECALLBACK_TYPE_ACQ_END");
  159. break;
  160. }
  161. case ECALLBACK_TYPE_UPDATE_FIRMWARE:
  162. {
  163. FINFO("Callback Type: ECALLBACK_TYPE_UPDATE_FIRMWARE");
  164. break;
  165. }
  166. case ECALLBACK_TYPE_ERASE_FIRMWARE:
  167. {
  168. FINFO("Callback Type: ECALLBACK_TYPE_ERASE_FIRMWARE");
  169. break;
  170. }
  171. case ECALLBACK_TYPE_FPD_STATUS: // detetor status:connect/disconnect/ready/busy and so on
  172. {
  173. FINFO("Callback Type: ECALLBACK_TYPE_FPD_STATUS");
  174. if (param2 <= 0 && param2 >= -11)
  175. {
  176. if (param2 == 0)
  177. FERROR("ECALLBACK_TYPE_FPD_STATUS,Err:Network not connected!");
  178. else if (param2 == -1)
  179. FERROR("ECALLBACK_TYPE_FPD_STATUS,Err:Parameter exception!");
  180. else if (param2 == -2)
  181. FERROR("ECALLBACK_TYPE_FPD_STATUS,Err:Failed to return the number of ready descriptors!");
  182. else if (param2 == -3)
  183. FERROR("ECALLBACK_TYPE_FPD_STATUS,Err:Receive timeout!");
  184. else if (param2 == -4)
  185. FERROR("ECALLBACK_TYPE_FPD_STATUS,Err:Receive failed!");
  186. else if (param2 == -5)
  187. FERROR("ECALLBACK_TYPE_FPD_STATUS,Err:Socket-Port unreadable!");
  188. else if (param2 == -6)
  189. FERROR("ECALLBACK_TYPE_FPD_STATUS,Network card unusual!");
  190. else if (param2 == -7)
  191. FERROR("ECALLBACK_TYPE_FPD_STATUS,Network card ok!");
  192. else if (param2 == -8)
  193. FERROR("ECALLBACK_TYPE_FPD_STATUS:Update Firmware end!");
  194. else if (param2 == -9)
  195. FERROR("ECALLBACK_TYPE_FPD_STATUS:Light Fiber disconnected!");
  196. else if (param2 == -10)
  197. FERROR("ECALLBACK_TYPE_FPD_STATUS:Read ddr failed,try restarting the PCIe driver!");
  198. else /*if (param2 == -11)*/
  199. FERROR("ECALLBACK_TYPE_FPD_STATUS:is not jumb!");
  200. status = (int)FPD_DISCONN_STATUS;
  201. FERROR("Detector not connected!");
  202. g_pDetector->StatusFeedback(EVT_STATUS_PANEL, PANEL_CLOSE);
  203. }
  204. else if (param2 == FPD_CONN_SUCCESS) // connect
  205. {
  206. FINFO("Detector connected!");
  207. status = (int)FPD_CONN_SUCCESS;
  208. g_pDetector->StatusFeedback(EVT_STATUS_PANEL, PANEL_CONNECT);
  209. g_pDetector->GetPanelInfo();
  210. }
  211. else if (param2 == FPD_PREPARE_STATUS) // prepare
  212. {
  213. FINFO("Detector prepare!");
  214. status = (int)FPD_PREPARE_STATUS;
  215. g_pDetector->StatusFeedback(EVT_STATUS_PANEL, PANEL_STANDBY);
  216. }
  217. else if (param2 == FPD_READY_STATUS) // ready
  218. {
  219. FINFO("Detector ready!");
  220. status = (int)FPD_READY_STATUS;
  221. g_pDetector->StatusFeedback(EVT_STATUS_PANEL, PANEL_READY_EXP);
  222. }
  223. else if (param2 == FPD_DOOFFSET_TEMPLATE)// do offset template
  224. {
  225. FINFO("Detector do offset template!");
  226. status = (int)FPD_DOOFFSET_TEMPLATE;
  227. }
  228. else if (param2 == FPD_EXPOSE_STATUS) // busy expose
  229. {
  230. FINFO("Detector Exposing!");
  231. status = FPD_EXPOSE_STATUS;
  232. }
  233. else if (param2 == FPD_CONTINUE_READY) // continue ready
  234. {
  235. FINFO("Detector Continue ready!");
  236. status = FPD_CONTINUE_READY;
  237. g_pDetector->StatusFeedback(EVT_STATUS_PANEL, PANEL_READY_EXP);
  238. }
  239. else if (param2 == FPD_DWONLOAD_GAIN) // download gain template
  240. {
  241. FINFO("Detector Download gain template!");
  242. status = FPD_DWONLOAD_GAIN;
  243. }
  244. else if (param2 == FPD_DWONLOAD_DEFECT) // download defect template
  245. {
  246. FINFO("Detector Download defect template!");
  247. status = FPD_DWONLOAD_DEFECT;
  248. }
  249. else if (param2 == FPD_DWONLOAD_OFFSET)// download offset template
  250. {
  251. FINFO("Detector Download offset template!");
  252. status = FPD_DWONLOAD_OFFSET;
  253. }
  254. else if (param2 == FPD_UPDATE_FIRMARE)// update firmware
  255. {
  256. FINFO("Detector Update firmware!");
  257. status = FPD_UPDATE_FIRMARE;
  258. }
  259. else if (param2 == FPD_RETRANS_MISS)// Retrans mission
  260. {
  261. FINFO("Detector Retrans mission!");
  262. status = FPD_RETRANS_MISS;
  263. }
  264. else
  265. FERROR("Detector Other error:{$}", param2);
  266. if (status != -1)// error, diconnect detector
  267. {
  268. if (param2 <= 0 && param2 >= -10)
  269. {
  270. g_pDetector->HBI_DisConnectDetector(g_pDetector->m_nFpdHandle);
  271. }
  272. }
  273. break;
  274. }
  275. case ECALLBACK_TYPE_ROM_UPLOAD:
  276. {
  277. FINFO("Callback Type: ECALLBACK_TYPE_ROM_UPLOAD");
  278. if (param1 == NULL || param2 == 0)
  279. {
  280. FERROR("Parameter exception!");
  281. return ret;
  282. }
  283. pRegCfg = new RegCfgInfo;
  284. if (pRegCfg != NULL)
  285. {
  286. memset(pRegCfg, 0x00, sizeof(RegCfgInfo));
  287. memcpy(pRegCfg, (unsigned char*)param1, sizeof(RegCfgInfo));
  288. g_pDetector->PrintDetectorCfg(pRegCfg);
  289. }
  290. break;
  291. }
  292. case ECALLBACK_TYPE_RAM_UPLOAD:
  293. {
  294. FINFO("Callback Type: ECALLBACK_TYPE_RAM_UPLOAD");
  295. if (param1 == NULL || param2 == 0)
  296. {
  297. FERROR("Parameter exception!");
  298. return ret;
  299. }
  300. break;
  301. }
  302. case ECALLBACK_TYPE_FACTORY_UPLOAD:
  303. {
  304. FINFO("Callback Type: ECALLBACK_TYPE_FACTORY_UPLOAD");
  305. if (param1 == NULL || param2 == 0)
  306. {
  307. printf("err:Parameter exception!\n");
  308. return ret;
  309. }
  310. break;
  311. }
  312. case ECALLBACK_TYPE_WLAN_BATTERY:
  313. {
  314. FINFO("Callback Type: ECALLBACK_TYPE_WLAN_BATTERY");
  315. break;
  316. }
  317. case ECALLBACK_TYPE_BUFFER_WARNING:
  318. {
  319. FINFO("Callback Type: ECALLBACK_TYPE_BUFFER_WARNING");
  320. break;
  321. }
  322. case ECALLBACK_TYPE_ILLEGAL_PACKAGE_NUM:
  323. {
  324. FINFO("Callback Type: ECALLBACK_TYPE_ILLEGAL_PACKAGE_NUM");
  325. break;
  326. }
  327. case ECALLBACK_TYPE_USER_DDR_UPLOAD:
  328. {
  329. FINFO("Callback Type: ECALLBACK_TYPE_USER_DDR_UPLOAD");
  330. break;
  331. }
  332. case ECALLBACK_TYPE_WIRELESS_NETWORK:
  333. {
  334. FINFO("Callback Type: ECALLBACK_TYPE_WIRELESS_NETWORK");
  335. break;
  336. }
  337. case ECALLBACK_TYPE_WIRELESS_SETKEYOK:
  338. {
  339. FINFO("Callback Type: ECALLBACK_TYPE_WIRELESS_SETKEYOK");
  340. break;
  341. }
  342. case ECALLBACK_FIRMWARE_TEMPLATE_STATUS:
  343. {
  344. FINFO("Callback Type: ECALLBACK_FIRMWARE_TEMPLATE_STATUS");
  345. break;
  346. }
  347. case ECALLBACK_TYPE_SINGLE_IMAGE:
  348. case ECALLBACK_TYPE_MULTIPLE_IMAGE:
  349. FINFO("Callback Type: ECALLBACK_TYPE_SINGLE_IMAGE or ECALLBACK_TYPE_MULTIPLE_IMAGE");
  350. if (param1 == NULL || param2 == 0)
  351. {
  352. FERROR("Parameter exception!");
  353. return ret;
  354. }
  355. imagedata = (ImageData*)param1;
  356. g_pDetector->m_nRawImageWidth = imagedata->uwidth;
  357. g_pDetector->m_nRawImageHeight = imagedata->uheight;
  358. g_pDetector->m_nFrameID = imagedata->uframeid;
  359. FINFO("Callback ImageWidth:{$},ImageHeight:{$},FrameID:{$},datalen:{$}", imagedata->uwidth, imagedata->uheight, imagedata->uframeid, imagedata->datalen);
  360. memcpy(g_pDetector->m_pRawImgBuffer, (unsigned char*)imagedata->databuff, imagedata->datalen);
  361. //获取图像后需要调用停止采集,所以改到子线程处理
  362. SetEvent(g_pDetector->m_hProcessImgEvent);
  363. break;
  364. case ECALLBACK_TYPE_PREVIEW_IMAGE:
  365. {
  366. FINFO("Callback Type: ECALLBACK_TYPE_PREVIEW_IMAGE");
  367. if (param1 == NULL || param2 == 0)
  368. {
  369. FERROR("Parameter exception!");
  370. return ret;
  371. }
  372. imagedata = (ImageData*)param1;
  373. break;
  374. }
  375. case ECALLBACK_TYPE_LIVE_IMAGE:
  376. {
  377. FINFO("Callback Type: ECALLBACK_TYPE_LIVE_IMAGE");
  378. if (param1 == NULL || param2 == 0)
  379. {
  380. FERROR("Parameter exception!");
  381. return ret;
  382. }
  383. imagedata = (ImageData*)param1;
  384. g_pDetector->m_nRawImageWidth = imagedata->uwidth;
  385. g_pDetector->m_nRawImageHeight = imagedata->uheight;
  386. g_pDetector->m_nFrameID = imagedata->uframeid;
  387. FINFO("Callback ImageWidth:{$},ImageHeight:{$},FrameID:{$},datalen:{$}", imagedata->uwidth, imagedata->uheight, imagedata->uframeid, imagedata->datalen);
  388. memcpy(g_pDetector->m_pRawImgBuffer, (unsigned char*)imagedata->databuff, imagedata->datalen);
  389. //获取图像后需要调用停止采集,所以改到子线程处理
  390. SetEvent(g_pDetector->m_hProcessImgEvent);
  391. break;
  392. }
  393. case ECALLBACK_TYPE_PACKET_MISS:
  394. {
  395. FINFO("Callback Type: ECALLBACK_TYPE_PACKET_MISS");
  396. break;
  397. }
  398. case ECALLBACK_TYPE_OFFSET_TMP:
  399. {
  400. FINFO("Callback Type: ECALLBACK_TYPE_OFFSET_TMP");
  401. if (param1 == NULL || param2 == 0)
  402. {
  403. FERROR("Parameter exception!");
  404. return ret;
  405. }
  406. imagedata = (ImageData*)param1;
  407. break;
  408. }
  409. case ECALLBACK_OVERLAY_NUMBER:
  410. {
  411. FINFO("Callback Type: ECALLBACK_OVERLAY_NUMBER");
  412. break;
  413. }
  414. case ECALLBACK_OVERLAY_16BIT_IMAGE:
  415. {
  416. FINFO("Callback Type: ECALLBACK_OVERLAY_16BIT_IMAGE");
  417. if (param1 == NULL || param2 == 0)
  418. {
  419. FERROR("Parameter exception!");
  420. return ret;
  421. }
  422. imagedata = (ImageData*)param1;
  423. break;
  424. }
  425. case ECALLBACK_OVERLAY_32BIT_IMAGE:
  426. {
  427. FINFO("Callback Type: ECALLBACK_OVERLAY_32BIT_IMAGE");
  428. if (param1 == NULL || param2 == 0)
  429. {
  430. FERROR("Parameter exception!");
  431. return ret;
  432. }
  433. imagedata = (ImageData*)param1;
  434. break;
  435. }
  436. case ECALLBACK_TYPE_8BIT_IMAGE:
  437. {
  438. FINFO("Callback Type: ECALLBACK_TYPE_8BIT_IMAGE");
  439. break;
  440. }
  441. case ECALLBACK_TYPE_SENDTO_WIZARD:
  442. {
  443. FINFO("Callback Type: ECALLBACK_TYPE_SENDTO_WIZARD");
  444. break;
  445. }
  446. case ECALLBACK_TYPE_PACKET_MISS_MSG:
  447. {
  448. FINFO("Callback Type: ECALLBACK_TYPE_PACKET_MISS_MSG");
  449. break;
  450. }
  451. case ECALLBACK_TYPE_THREAD_EVENT:
  452. {
  453. FINFO("Callback Type: ECALLBACK_TYPE_THREAD_EVENT");
  454. if (param2 == 100)
  455. FINFO("ECALLBACK_TYPE_THREAD_EVENT,start recv data!");
  456. else if (param2 == 101)
  457. FINFO("ECALLBACK_TYPE_THREAD_EVENT,end recv data!");
  458. else if (param2 == 104)
  459. FINFO("ECALLBACK_TYPE_THREAD_EVENT,Packet Retransmission:start recv data!");
  460. else if (param2 == 105)
  461. FINFO("ECALLBACK_TYPE_THREAD_EVENT,Frame Retransmission:start recv data!");
  462. else if (param2 == 106)
  463. FINFO("ECALLBACK_TYPE_THREAD_EVENT,Frame loss retransmission over,end recv data!");
  464. else if (param2 == 107)
  465. FINFO("ECALLBACK_TYPE_THREAD_EVENT,image buff is null:end recv data!");
  466. else if (param2 == 108)
  467. FINFO("ECALLBACK_TYPE_THREAD_EVENT,Generate Offset Template:start thread!");
  468. else if (param2 == 109)
  469. FINFO("ECALLBACK_TYPE_THREAD_EVENT,Generate Offset Template:end thread!");
  470. else if (param2 == 110)
  471. FINFO("ECALLBACK_TYPE_THREAD_EVENT,Generate Gain Template:start thread!");
  472. else if (param2 == 111)
  473. FINFO("ECALLBACK_TYPE_THREAD_EVENT,Generate Gain Template:end thread!");
  474. else if (param2 == 112)
  475. FINFO("ECALLBACK_TYPE_THREAD_EVENT,offset calibrate:success!");
  476. else if (param2 == 113)
  477. FINFO("ECALLBACK_TYPE_THREAD_EVENT,offset calibrate:failed!");
  478. else if (param2 == 114)
  479. FINFO("ECALLBACK_TYPE_THREAD_EVENT,gain calibrate:success!");
  480. else if (param2 == 115)
  481. FINFO("ECALLBACK_TYPE_THREAD_EVENT,gain calibrate:failed!");
  482. else if (param2 == 116)
  483. FINFO("ECALLBACK_TYPE_THREAD_EVENT,defect calibrate:success!");
  484. else if (param2 == 117)
  485. FINFO("ECALLBACK_TYPE_THREAD_EVENT,defect calibrate:failed!");
  486. else if (param2 == 118)
  487. FINFO("ECALLBACK_TYPE_THREAD_EVENT,InitGainTemplate:failed!");
  488. else if (param2 == 119)
  489. FINFO("ECALLBACK_TYPE_THREAD_EVENT,firmare offset calibrate:success!");
  490. else if (param2 == 120)
  491. FINFO("ECALLBACK_TYPE_THREAD_EVENT,Generate Defect Template:start thread!");
  492. else if (param2 == 121)
  493. FINFO("ECALLBACK_TYPE_THREAD_EVENT,Generate Defect Template:end thread!");
  494. else
  495. FERROR("ECALLBACK_TYPE_THREAD_EVENT,Err:other error [{$}]", param2);
  496. break;
  497. }
  498. case ECALLBACK_TYPE_ACQ_DISCARDDED:
  499. {
  500. FINFO("Callback Type: ECALLBACK_TYPE_ACQ_DISCARDDED");
  501. break;
  502. }
  503. case ECALLBACK_TYPE_OFFSET_ERR_MSG:
  504. {
  505. FINFO("Callback Type: ECALLBACK_TYPE_OFFSET_ERR_MSG");
  506. break;
  507. }
  508. case ECALLBACK_TYPE_GAIN_ERR_MSG:
  509. {
  510. FINFO("Callback Type: ECALLBACK_TYPE_GAIN_ERR_MSG");
  511. break;
  512. }
  513. case ECALLBACK_TYPE_DEFECT_ERR_MSG:
  514. {
  515. FINFO("Callback Type: ECALLBACK_TYPE_DEFECT_ERR_MSG");
  516. break;
  517. }
  518. case ECALLBACK_TYPE_NET_ERR_MSG:
  519. {
  520. FINFO("Callback Type: ECALLBACK_TYPE_NET_ERR_MSG");
  521. break;
  522. }
  523. case ECALLBACK_TYPE_SET_CFG_OK:
  524. {
  525. FINFO("Callback Type: ECALLBACK_TYPE_SET_CFG_OK set rom param succuss!");
  526. break;
  527. }
  528. case ECALLBACK_TYPE_SAVE_SUCCESS:
  529. {
  530. FINFO("Callback Type: ECALLBACK_TYPE_SAVE_SUCCESS");
  531. break;
  532. }
  533. case ECALLBACK_TYPE_GENERATE_TEMPLATE:
  534. {
  535. FINFO("Callback Type: ECALLBACK_TYPE_GENERATE_TEMPLATE");
  536. if (param2 == ECALLBACK_TEMPLATE_BEGIN)
  537. {
  538. FINFO("ECALLBACK_TEMPLATE_BEGIN");
  539. }
  540. else if (param2 == ECALLBACK_TEMPLATE_INVALVE_PARAM)
  541. {
  542. FINFO("ECALLBACK_TEMPLATE_INVALVE_PARAM:{$}", param3);
  543. }
  544. else if (param2 == ECALLBACK_TEMPLATE_MALLOC_FAILED)
  545. {
  546. FINFO("ECALLBACK_TEMPLATE_MALLOC_FAILED:{$}", param3);
  547. }
  548. else if (param2 == ECALLBACK_TEMPLATE_SEND_FAILED)
  549. {
  550. FINFO("ECALLBACK_TEMPLATE_SEND_FAILED:{$}", param3);
  551. }
  552. else if (param2 == ECALLBACK_TEMPLATE_STATUS_ABORMAL)
  553. {
  554. FINFO("ECALLBACK_TEMPLATE_STATUS_ABORMAL:{$}", param3);
  555. }
  556. else if (param2 == ECALLBACK_TEMPLATE_FRAME_NUM)
  557. {
  558. FINFO("ECALLBACK_TEMPLATE_FRAME_NUM:{$}", param3);
  559. }
  560. else if (param2 == ECALLBACK_TEMPLATE_TIMEOUT)
  561. {
  562. FINFO("ECALLBACK_TEMPLATE_TIMEOUT:{$}", param3);
  563. }
  564. else if (param2 == ECALLBACK_TEMPLATE_MEAN)
  565. {
  566. ECALLBACK_RAW_INFO* ptr = (ECALLBACK_RAW_INFO*)param1;
  567. if (ptr != NULL)
  568. {
  569. FINFO("ECALLBACK_TEMPLATE_MEAN:{$},dMean={$.2f}", ptr->szRawName, ptr->dMean);
  570. }
  571. }
  572. else if (param2 == ECALLBACK_TEMPLATE_GENERATE)
  573. {
  574. if (param3 == OFFSET_TMP)
  575. FINFO("ECALLBACK_TEMPLATE_GENERATE:OFFSET_TMP");
  576. else if (param3 == GAIN_TMP)
  577. FINFO("ECALLBACK_TEMPLATE_GENERATE:GAIN_TMP");
  578. else if (param3 == DEFECT_TMP)
  579. FINFO("ECALLBACK_TEMPLATE_GENERATE:DEFECT_TMP,bad point={$}", param2);
  580. else
  581. FINFO("ECALLBACK_TEMPLATE_GENERATE:nid={$}", param3);
  582. }
  583. else if (param2 == ECALLBACK_TEMPLATE_RESULT)
  584. {
  585. FINFO("ECALLBACK_TEMPLATE_RESULT:{$}", param3);
  586. }
  587. else
  588. {
  589. FINFO("other:len={$},nid={$}", param2, param3);
  590. }
  591. break;
  592. }
  593. case ECALLBACK_TYPE_FILE_NOTEXIST:
  594. {
  595. FINFO("Callback Type: ECALLBACK_TYPE_FILE_NOTEXIST");
  596. if (param1 != NULL)
  597. FERROR("err:{$} not exist!", (char*)param1);
  598. break;
  599. }
  600. case ECALLBACK_TYPE_WORK_STATUS:
  601. {
  602. FINFO("Callback Type: ECALLBACK_TYPE_WORK_STATUS");
  603. break;
  604. }
  605. default:
  606. FINFO("default Callback Type[{$}]", (int)byteEventId);
  607. break;
  608. }
  609. if (pRegCfg)
  610. {
  611. delete pRegCfg;
  612. pRegCfg = nullptr;
  613. }
  614. return 0;
  615. }
  616. bool Detector_HaoBoRF::DriverEntry(void* pDrvDPC, ResDataObject& Configuration, const char* szWorkPath)
  617. {
  618. printf("========DriverEntry %p\n", pDrvDPC);
  619. FINFO("========DriverEntry {$}", pDrvDPC);
  620. map<void*, int>::iterator iter = m_pDPC2PanelID->find(pDrvDPC);
  621. if (iter != m_pDPC2PanelID->end())
  622. {
  623. FERROR("This DPC already exist");
  624. return false;
  625. }
  626. m_pDPC2PanelID->insert(pair<void*, int>(pDrvDPC, m_nPanelCount));
  627. m_pPanelID2DPC->insert(pair<int, void*>(m_nPanelCount, pDrvDPC));
  628. m_nPanelCount++;
  629. m_ModeConfig = Configuration; //记录配置 --目前只有一个平板,多板时应该分别存储
  630. FINFO("m_ModeConfig:{$}", m_ModeConfig.encode());
  631. if (nullptr == m_hFPDScanThread)
  632. {
  633. unsigned uThreadId;
  634. _beginthreadex(NULL, 0, onFPDScanThread, this, 0, &uThreadId);
  635. m_hFPDScanThread = OpenThread(THREAD_ALL_ACCESS, TRUE, uThreadId);
  636. }
  637. if (nullptr == m_hOffsetThread)
  638. {
  639. unsigned uThreadId;
  640. _beginthreadex(NULL, 0, RefreshOffsetThread, this, 0, &uThreadId);
  641. m_hOffsetThread = OpenThread(THREAD_ALL_ACCESS, TRUE, uThreadId);
  642. }
  643. m_strCtrlWorkPath = szWorkPath;
  644. if (!LoadDll(szWorkPath))
  645. {
  646. FERROR("Load dll failed!");
  647. return false;
  648. }
  649. if (m_bLoaded)
  650. {
  651. FINFO("Calling HBI_Init");
  652. m_nFpdHandle = HBI_Init(0);
  653. if (!m_nFpdHandle)
  654. {
  655. FERROR("HBI_Init error!");
  656. return false;
  657. }
  658. FINFO("Calling HBI_RegEventCallBackFun");
  659. int nRet = HBI_RegEventCallBackFun(m_nFpdHandle, CallBackFunc, NULL);
  660. if (TestError(nRet, "HBI_RegEventCallBackFun"))
  661. {
  662. FERROR("Register call back fun fail!");
  663. return false;
  664. }
  665. }
  666. return true;
  667. }
  668. bool Detector_HaoBoRF::Connect(void* pDrvDPC)
  669. {
  670. printf("========Connect detector begin \r\n");
  671. FINFO("========Connect detector begin \n");
  672. if ((*m_pDPC2PanelID)[pDrvDPC] != m_nCurrentPanelID)
  673. {
  674. FERROR("Not current DPC, return true");
  675. return true;
  676. }
  677. if (m_bLoaded)
  678. {
  679. if (!ConnectDetector())
  680. {
  681. return false;
  682. }
  683. }
  684. else
  685. {
  686. FERROR("DLL is not loaded!");
  687. return false;
  688. }
  689. FINFO("Connect over");
  690. printf("Connect over \n");
  691. return true;
  692. }
  693. void Detector_HaoBoRF::DisConnect()
  694. {
  695. printf("========DisConnect with detector \n");
  696. FINFO("========DisConnect");
  697. int nRet = HBI_SUCCSS;
  698. }
  699. void Detector_HaoBoRF::EnterExamMode(int nExamMode)
  700. {
  701. switch (nExamMode)
  702. {
  703. case APP_STATUS_WORK_BEGIN:
  704. FINFO("Enter into Exam Windows");
  705. m_nExamMode = APP_STATUS_WORK_BEGIN;
  706. break;
  707. case APP_STATUS_WORK_END:
  708. FINFO("Quit Exam Windows");
  709. m_nExamMode = APP_STATUS_WORK_END;
  710. break;
  711. case APP_STATUS_DETSHARE_BEGIN:
  712. FINFO("Enter into Detector Share Windows");
  713. m_nExamMode = APP_STATUS_DETSHARE_BEGIN;
  714. break;
  715. case APP_STATUS_DETSHAR_END:
  716. m_nExamMode = APP_STATUS_IDLE;
  717. FINFO("Quit Detector Share Windows");
  718. m_nExamMode = APP_STATUS_DETSHAR_END;
  719. break;
  720. case APP_STATUS_CAL_BEGIN:
  721. FINFO("Enter into Calibration Windows");
  722. m_nExamMode = APP_STATUS_CAL_BEGIN;
  723. break;
  724. case APP_STATUS_CAL_END:
  725. FINFO("Quit Calibration Windows");
  726. m_nExamMode = APP_STATUS_CAL_END;
  727. break;
  728. case APP_STATUS_WORK_IN_SENSITIVITY:
  729. FINFO("Enter into sensitivity test interface");
  730. m_nExamMode = APP_STATUS_WORK_IN_SENSITIVITY;
  731. break;
  732. default:
  733. break;
  734. }
  735. if (APP_STATUS_WORK_END == m_nExamMode)
  736. {
  737. if (DetStatus_Acquire == GetDpcStatus())
  738. {
  739. FINFO("quit exam but detector status is acquire,so stop acquire");
  740. StopAcquisition(nullptr);
  741. }
  742. }
  743. }
  744. bool Detector_HaoBoRF::SetAcqMode(int nMode)
  745. {
  746. printf("========SetAcqMode nMode:%d \n", nMode);
  747. FINFO("========SetAcqMode nMode:{$}",nMode);
  748. if (m_nCurrentLogicMode == nMode)
  749. {
  750. FINFO("Same mode, return");
  751. return true;
  752. }
  753. //只有RAD模式读取全部的配置文件,CF和PF不读取全部配置,只读取部分
  754. try
  755. {
  756. int nModeCount = (int)m_ModeConfig["ModeTable"].size();
  757. for (int i = 0; i < nModeCount; i++)
  758. {
  759. int logicMode = (int)m_ModeConfig["ModeTable"][i]["LogicMode"];//SetAcqMode
  760. if (logicMode == nMode)
  761. {
  762. //FINFO("ModeTable22 {$}, {$}", i, m_ModeConfig["ModeTable"][i].encode());
  763. FINFO("find LogicMode == nMode");
  764. if (logicMode == RAD)
  765. {
  766. m_nModeID = (int)m_ModeConfig["ModeTable"][i]["OperationMode"];//RAD 固定用1*1的Binning
  767. }
  768. m_nDelayTime = (int)m_ModeConfig["ModeTable"][i]["DelayTime"];
  769. m_nDropImgCount = (int)m_ModeConfig["ModeTable"][i]["DropImgCount"];
  770. m_nSaveRaw = (int)m_ModeConfig["ModeTable"][i]["IsSaveRaw"];
  771. m_nTriggerMode = (int)m_ModeConfig["ModeTable"][i]["ExamType"];
  772. FINFO("m_nDelayTime:{$}, m_nDropImgCount:{$}, m_nSaveRaw:{$}, m_nModeID:{$}, m_nTriggerMode:{$}",
  773. m_nDelayTime, m_nDropImgCount, m_nSaveRaw, m_nModeID, m_nTriggerMode);
  774. m_nCropLeft = (int)m_ModeConfig["ModeTable"][i]["CropLeft"];
  775. m_nCropRight = (int)m_ModeConfig["ModeTable"][i]["CropRight"];
  776. m_nCropTop = (int)m_ModeConfig["ModeTable"][i]["CropTop"];
  777. m_nCropBottom = (int)m_ModeConfig["ModeTable"][i]["CropBottom"];
  778. FINFO("Crop left:{$}, top:{$}, right:{$}, bottom:{$}", m_nCropLeft, m_nCropTop, m_nCropRight, m_nCropBottom);
  779. m_nImageBits = (int)m_ModeConfig["ModeTable"][i]["PhySizeInfoBit"];
  780. m_nGainLevel = (int)m_ModeConfig["ModeTable"][i]["GainValue"];
  781. FINFO("m_nImageBits:{$}, m_nGainLevel:{$}", m_nImageBits, m_nGainLevel);
  782. break;
  783. }
  784. }
  785. }
  786. catch (ResDataObjectExption& e)
  787. {
  788. FERROR("Read configuration failed, Error code: {$}", e.what());
  789. return false;
  790. }
  791. m_nCurrentLogicMode = nMode;
  792. return true;
  793. }
  794. bool Detector_HaoBoRF::SetExposureTimes(int nTimes)
  795. {
  796. FINFO("========SetExposureTimes({$})", nTimes);
  797. return true;
  798. }
  799. bool Detector_HaoBoRF::PrepareAcquisition(void* pDrvDPC)
  800. {
  801. printf("========PrepareAcquisition \n");
  802. FINFO("========PrepareAcquisition ");
  803. int nRet = HBI_SUCCSS;
  804. if ((*m_pDPC2PanelID)[pDrvDPC] != m_nCurrentPanelID)
  805. {
  806. FERROR("Not current DPC, return");
  807. return false;
  808. }
  809. if (-1 == m_nCurrentLogicMode)
  810. {
  811. FERROR("Illegal exam mode");
  812. return false;
  813. }
  814. eDetStatus detectorStatus = GetDpcStatus();
  815. if (detectorStatus == DetStatus_Acquire)
  816. {
  817. bool ret = StopAcquisition(pDrvDPC);
  818. if (!ret)
  819. {
  820. return false;
  821. }
  822. }
  823. //modeID 1->1*1 2->2*2
  824. FINFO("m_nTriggerMode:{$}, m_nModeID:{$}, acqTime:{$}", m_nTriggerMode, m_nModeID, 1 / (int)m_fFrameRate);
  825. FINFO("Call HBI_TriggerBinningAcqTime");
  826. nRet = HBI_TriggerBinningAcqTime(m_nFpdHandle, m_nTriggerMode, m_nModeID, 1 / (int)m_fFrameRate, 0);
  827. if (TestError(nRet,"HBI_TriggerBinningAcqTime"))
  828. {
  829. FERROR("HBI_TriggerBinningAcqTime fail!");
  830. return false;
  831. }
  832. return true;
  833. }
  834. bool Detector_HaoBoRF::StartAcquisition(void* pDrvDPC)
  835. {
  836. printf("========StartAcquisition \n");
  837. FINFO("========StartAcquisition ");
  838. int nRet = HBI_SUCCSS;
  839. if ((*m_pDPC2PanelID)[pDrvDPC] != m_nCurrentPanelID)
  840. {
  841. FERROR("Not current DPC, return");
  842. return false;
  843. }
  844. if (-1 == m_nCurrentLogicMode)
  845. {
  846. FERROR("Illegal exam mode");
  847. return false;
  848. }
  849. else
  850. {
  851. m_bValidImage = false; //开始采集,恢复初值
  852. m_nDropImgNum = 0; //开始采集,恢复初值
  853. m_bFirstImage = true;
  854. m_dwBeginTime = GetTickCount64();
  855. }
  856. FPD_AQC_MODE aqc_mode;
  857. FINFO("m_nCurrentLogicMode:{$}", m_nCurrentLogicMode);
  858. if (m_nCurrentLogicMode == RAD)
  859. {
  860. aqc_mode.nAcqnumber = 1;
  861. }
  862. else if (m_nCurrentLogicMode == CF || m_nCurrentLogicMode == PF)
  863. {
  864. aqc_mode.eAqccmd = EnumIMAGE_ACQ_CMD::LIVE_ACQ_DEFAULT_TYPE;
  865. aqc_mode.eLivetype = EnumLIVE_ACQUISITION::ONLY_IMAGE;
  866. }
  867. FINFO("Call HBI_LiveAcquisition");
  868. nRet = HBI_LiveAcquisition(m_nFpdHandle, aqc_mode);
  869. if (TestError(nRet,"HBI_LiveAcquisition"))
  870. {
  871. FERROR("HBI_LiveAcquisition fail!");
  872. return false;
  873. }
  874. SetDpcStatus(DetStatus_Acquire); //动态模式激活采集,设置状态
  875. return true;
  876. }
  877. bool Detector_HaoBoRF::StopAcquisition(void* pDrvDPC)
  878. {
  879. printf("========StopAcquisition \n");
  880. FINFO("========StopAcquisition ");
  881. int nRet = HBI_SUCCSS;
  882. if ((*m_pDPC2PanelID)[pDrvDPC] != m_nCurrentPanelID)
  883. {
  884. FERROR("Not current DPC, return");
  885. return false;
  886. }
  887. FINFO("Call HBI_StopAcquisition");
  888. nRet = HBI_StopAcquisition(m_nFpdHandle);
  889. if (TestError(nRet,"HBI_StopAcquisition"))
  890. {
  891. FERROR("Stop Acqusition fail!");
  892. return false;
  893. }
  894. return true;
  895. }
  896. bool Detector_HaoBoRF::ActiveCalibration(void* pDrvDPC, CCOS_CALIBRATION_TYPE eType)
  897. {
  898. printf("========ActiveCalibration \n");
  899. FINFO("========ActiveCalibration ");
  900. if ((*m_pDPC2PanelID)[pDrvDPC] != m_nCurrentPanelID)
  901. {
  902. //printf("Not current DPC, return\n");
  903. FERROR("Not current DPC, return");
  904. return false;
  905. }
  906. if (-1 == m_nCurrentLogicMode)
  907. {
  908. FERROR("Illegal exam mode");
  909. return false;
  910. }
  911. if (CCOS_CALIBRATION_TYPE_XRAY == eType)
  912. {
  913. SetDpcStatus(DetStatus_GainCalibration);
  914. }
  915. m_eCaliType = eType;
  916. return true;
  917. }
  918. bool Detector_HaoBoRF::PrepareCalibration(void* pDrvDPC)
  919. {
  920. printf("========PrepareCalibration \n");
  921. FINFO("========PrepareCalibration ");
  922. bool bRet = false;
  923. if ((*m_pDPC2PanelID)[pDrvDPC] != m_nCurrentPanelID)
  924. {
  925. FERROR("Not current DPC, return");
  926. return bRet;
  927. }
  928. if (GetDpcStatus() != DetStatus_GainCalibration)
  929. {
  930. FINFO("Current status is not XrayCalibration, return succeed");
  931. return true;
  932. }
  933. return bRet;
  934. }
  935. bool Detector_HaoBoRF::StartCalibration(void* pDrvDPC)
  936. {
  937. printf("========StartCalibration \n");
  938. FINFO("========StartCalibration ");
  939. bool bRet = false;
  940. if ((*m_pDPC2PanelID)[pDrvDPC] != m_nCurrentPanelID)
  941. {
  942. FERROR("Not current DPC, return");
  943. return bRet;
  944. }
  945. if (CCOS_CALIBRATION_TYPE_DARK == m_eCaliType)
  946. {
  947. SetEvent(m_hDarkEvent);
  948. bRet = true;
  949. }
  950. else if (CCOS_CALIBRATION_TYPE_XRAY == m_eCaliType)
  951. {
  952. bRet = StartGainCalibration();
  953. }
  954. return bRet;
  955. }
  956. bool Detector_HaoBoRF::StopCalibration(void* pDrvDPC)
  957. {
  958. printf("========StopCalibration \n");
  959. FINFO("========StopCalibration ");
  960. bool bRet = false;
  961. int nRet = HBI_SUCCSS;
  962. if ((*m_pDPC2PanelID)[pDrvDPC] != m_nCurrentPanelID)
  963. {
  964. //printf("Not current DPC, return\n");
  965. FERROR("Not current DPC, return");
  966. return bRet;
  967. }
  968. FINFO("StopCalibration Calling StopCalibration");
  969. return bRet;
  970. }
  971. bool Detector_HaoBoRF::LoadDll(string strWorkPath)
  972. {
  973. printf("========LoadDll \n");
  974. FINFO("========LoadDll start");
  975. string strSDKPath = "";
  976. try
  977. {
  978. strSDKPath = (string)m_ModeConfig["SDKPath"];
  979. }
  980. catch (ResDataObjectExption& e)
  981. {
  982. FERROR("Read configuration failed, Error code: {$}", e.what());
  983. return false;
  984. }
  985. string workpath = strWorkPath + strSDKPath;
  986. FINFO("workpath:{$}", workpath);
  987. string drvpath = workpath + "\\HBISDKApi.dll";
  988. SetDllDirectory(workpath.c_str());
  989. m_hSDKModule = LoadLibrary(drvpath.c_str());
  990. if (m_hSDKModule == nullptr)
  991. {
  992. DWORD dw = GetLastError();
  993. FERROR("Load {$} failed! error code:{$}", drvpath, dw);
  994. return false;
  995. }
  996. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_Init);
  997. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_Destroy);
  998. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_ConnectDetector);
  999. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_DisConnectDetector);
  1000. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_RegEventCallBackFun);
  1001. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_GetSDKVerion);
  1002. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_GetFirmareVerion);
  1003. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_GetError);
  1004. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_GetFpdCfgInfo);
  1005. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_GetImageProperty);
  1006. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_LiveAcquisition);
  1007. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_StopAcquisition);
  1008. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_SetSelfDumpingTime);
  1009. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_TriggerAndCorrectApplay);
  1010. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_UpdateTriggerMode);
  1011. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_UpdateCorrectEnable);
  1012. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_SetBinning);
  1013. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_GenerateTemplate);
  1014. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_TriggerBinningAcqTime);
  1015. LOAD_PROC_ADDRESS(m_hSDKModule, HBI_IsMutilMode);
  1016. m_bLoaded = true;
  1017. FINFO("LoadDll end");
  1018. return true;
  1019. }
  1020. int Detector_HaoBoRF::GetPGA(unsigned short usValue)
  1021. {
  1022. unsigned short gainMode = ((usValue & 0xff) << 8) | ((usValue >> 8) & 0xff);
  1023. int nPGA = (gainMode >> 10) & 0x3f;
  1024. if (nPGA == 0x02) return 1;
  1025. else if (nPGA == 0x04) return 2;
  1026. else if (nPGA == 0x08) return 3;
  1027. else if (nPGA == 0x0c) return 4;
  1028. else if (nPGA == 0x10) return 5;
  1029. else if (nPGA == 0x18) return 6;
  1030. else if (nPGA == 0x3e) return 7;
  1031. else return 0;
  1032. }
  1033. void Detector_HaoBoRF::PrintDetectorCfg(RegCfgInfo* pCfg)
  1034. {
  1035. FINFO("========PrintDetectorCfg");
  1036. if (pCfg == NULL)
  1037. {
  1038. FERROR("pCfg is NULL!");
  1039. return;
  1040. }
  1041. FINFO("Xray sensor type:{$}", (int)pCfg->m_SysBaseInfo.m_byXRaySensorType);
  1042. // detector type,width and hight
  1043. if (pCfg->m_SysBaseInfo.m_byPanelSize == 0x01)
  1044. FINFO("PanelSize:{$},fpd type:4343-140um", (int)pCfg->m_SysBaseInfo.m_byPanelSize);
  1045. else if (pCfg->m_SysBaseInfo.m_byPanelSize == 0x02)
  1046. FINFO("PanelSize:{$},fpd type:3543-140um", (int)pCfg->m_SysBaseInfo.m_byPanelSize);
  1047. else if (pCfg->m_SysBaseInfo.m_byPanelSize == 0x03)
  1048. FINFO("PanelSize:{$},fpd type:1613-125um", (int)pCfg->m_SysBaseInfo.m_byPanelSize);
  1049. else if (pCfg->m_SysBaseInfo.m_byPanelSize == 0x04)
  1050. FINFO("PanelSize:{$},fpd type:3030-140um", (int)pCfg->m_SysBaseInfo.m_byPanelSize);
  1051. else if (pCfg->m_SysBaseInfo.m_byPanelSize == 0x05)
  1052. FINFO("PanelSize:{$},fpd type:2530-85um", (int)pCfg->m_SysBaseInfo.m_byPanelSize);
  1053. else if (pCfg->m_SysBaseInfo.m_byPanelSize == 0x06)
  1054. FINFO("PanelSize:{$},fpd type:3025-140um", (int)pCfg->m_SysBaseInfo.m_byPanelSize);
  1055. else if (pCfg->m_SysBaseInfo.m_byPanelSize == 0x07)
  1056. FINFO("PanelSize:{$},fpd type:4343-100um", (int)pCfg->m_SysBaseInfo.m_byPanelSize);
  1057. else if (pCfg->m_SysBaseInfo.m_byPanelSize == 0x08)
  1058. FINFO("PanelSize:{$},fpd type:2530-75um", (int)pCfg->m_SysBaseInfo.m_byPanelSize);
  1059. else if (pCfg->m_SysBaseInfo.m_byPanelSize == 0x09)
  1060. FINFO("PanelSize:{$},fpd type:2121-200um", (int)pCfg->m_SysBaseInfo.m_byPanelSize);
  1061. else if (pCfg->m_SysBaseInfo.m_byPanelSize == 0x0a)
  1062. FINFO("PanelSize:{$},fpd type:1412-50um", (int)pCfg->m_SysBaseInfo.m_byPanelSize);
  1063. else if (pCfg->m_SysBaseInfo.m_byPanelSize == 0x0b)
  1064. FINFO("PanelSize:{$},fpd type:0606-50um", (int)pCfg->m_SysBaseInfo.m_byPanelSize);
  1065. else
  1066. FERROR("PanelSize:{$},invalid fpd type!", (int)pCfg->m_SysBaseInfo.m_byPanelSize);
  1067. FINFO("PixelPitch:{$}", (int)pCfg->m_SysBaseInfo.m_byPixelPitch);
  1068. m_nMaxImgWidth = pCfg->m_SysBaseInfo.m_sImageWidth;
  1069. m_nMaxImgHeight = pCfg->m_SysBaseInfo.m_sImageHeight;
  1070. FINFO("Detector Width={$},Hight={$}", m_nMaxImgWidth, m_nMaxImgHeight);
  1071. ConfFeedback(EVT_CONF_MAX_IMAGESIZE, m_nCurrentPanelID, "", m_nMaxImgWidth * m_nMaxImgHeight);
  1072. if (m_pRawImgBuffer)
  1073. {
  1074. delete[] m_pRawImgBuffer;
  1075. m_pRawImgBuffer = nullptr;
  1076. }
  1077. m_pRawImgBuffer = new WORD[(size_t)m_nMaxImgWidth * (size_t)m_nMaxImgHeight];
  1078. if (m_pFullImgBuffer)
  1079. {
  1080. delete[] m_pFullImgBuffer;
  1081. m_pFullImgBuffer = nullptr;
  1082. }
  1083. m_pFullImgBuffer = new WORD[(size_t)m_nMaxImgWidth * (size_t)m_nMaxImgHeight];
  1084. FINFO("Serial Number:{$}", pCfg->m_SysBaseInfo.m_cSnNumber);
  1085. FINFO("MaxFPS:{$}", (int)pCfg->m_SysBaseInfo.m_cMaxFps);
  1086. //ip and port
  1087. unsigned short usValue = ((pCfg->m_EtherInfo.m_sDestUDPPort & 0xff) << 8) | ((pCfg->m_EtherInfo.m_sDestUDPPort >> 8) & 0xff);
  1088. FINFO("SourceIP:{$}.{$}.{$}.{$}:{$}",
  1089. pCfg->m_EtherInfo.m_byDestIP[0],
  1090. pCfg->m_EtherInfo.m_byDestIP[1],
  1091. pCfg->m_EtherInfo.m_byDestIP[2],
  1092. pCfg->m_EtherInfo.m_byDestIP[3],
  1093. usValue);
  1094. usValue = ((pCfg->m_EtherInfo.m_sSourceUDPPort & 0xff) << 8) | ((pCfg->m_EtherInfo.m_sSourceUDPPort >> 8) & 0xff);
  1095. FINFO("DestIP:{$}.{$}.{$}.{$}:{$}",
  1096. pCfg->m_EtherInfo.m_bySourceIP[0],
  1097. pCfg->m_EtherInfo.m_bySourceIP[1],
  1098. pCfg->m_EtherInfo.m_bySourceIP[2],
  1099. pCfg->m_EtherInfo.m_bySourceIP[3],
  1100. usValue);
  1101. //trigger mode
  1102. if (pCfg->m_SysCfgInfo.m_byTriggerMode == 0x01)
  1103. FINFO("static software trigger.[0x{$02X}]", pCfg->m_SysCfgInfo.m_byTriggerMode);
  1104. else if (pCfg->m_SysCfgInfo.m_byTriggerMode == 0x03)
  1105. FINFO("static hvg trigger.[0x{$02X}]", pCfg->m_SysCfgInfo.m_byTriggerMode);
  1106. else if (pCfg->m_SysCfgInfo.m_byTriggerMode == 0x04)
  1107. FINFO("Free AED trigger mode.[0x{$02X}]", pCfg->m_SysCfgInfo.m_byTriggerMode);
  1108. else if (pCfg->m_SysCfgInfo.m_byTriggerMode == 0x05)
  1109. FINFO("Dynamic:Hvg Sync mode.[0x{$02X}]", pCfg->m_SysCfgInfo.m_byTriggerMode);
  1110. else if (pCfg->m_SysCfgInfo.m_byTriggerMode == 0x06)
  1111. FINFO("Dynamic:Fpd Sync mode.[0x{$02X}]", pCfg->m_SysCfgInfo.m_byTriggerMode);
  1112. else if (pCfg->m_SysCfgInfo.m_byTriggerMode == 0x07)
  1113. FINFO("Dynamic:Fpd Continue mode.[0x{$02X}]", pCfg->m_SysCfgInfo.m_byTriggerMode);
  1114. else if (pCfg->m_SysCfgInfo.m_byTriggerMode == 0x08)
  1115. FINFO("Static:SAEC mode.[0x{$02X}]", pCfg->m_SysCfgInfo.m_byTriggerMode);
  1116. else
  1117. FINFO("other trigger mode.[0x{$02X}]", pCfg->m_SysCfgInfo.m_byTriggerMode);
  1118. // Binning type
  1119. nBinning = (int)pCfg->m_SysCfgInfo.m_byBinning;
  1120. if (nBinning < 1 || nBinning > 4)
  1121. {
  1122. nBinning = 1;
  1123. }
  1124. FINFO("Binning type:{$}*{$}", nBinning, nBinning);
  1125. // acq delay time
  1126. FINFO("Pre Acquisition Delay Time:{$}ms", pCfg->m_SysCfgInfo.m_unPreAcquisitionDelayTime);
  1127. // prepare delayed
  1128. BYTE byte1 = 0, byte2 = 0, byte3 = 0, byte4 = 0;
  1129. byte1 = BREAK_UINT32(pCfg->m_SysCfgInfo.m_unPreAcquisitionDelayTime, 0);
  1130. byte2 = BREAK_UINT32(pCfg->m_SysCfgInfo.m_unPreAcquisitionDelayTime, 1);
  1131. byte3 = BREAK_UINT32(pCfg->m_SysCfgInfo.m_unPreAcquisitionDelayTime, 2);
  1132. byte4 = BREAK_UINT32(pCfg->m_SysCfgInfo.m_unPreAcquisitionDelayTime, 3);
  1133. nPrepareTime = BUILD_UINT32(byte4, byte3, byte2, byte1);
  1134. FINFO("nPrepareTime:{$}ms", nPrepareTime);
  1135. FINFO("commCfg._type:{$}", (int)commCfg._type);
  1136. // Continuous acquisition time interval and frame rate calculation
  1137. if (commCfg._type == UDP_COMM_TYPE || commCfg._type == WALN_COMM_TYPE)
  1138. {
  1139. byte1 = BREAK_UINT32(pCfg->m_SysCfgInfo.m_unContinuousAcquisitionSpanTime, 0);
  1140. byte2 = BREAK_UINT32(pCfg->m_SysCfgInfo.m_unContinuousAcquisitionSpanTime, 1);
  1141. byte3 = BREAK_UINT32(pCfg->m_SysCfgInfo.m_unContinuousAcquisitionSpanTime, 2);
  1142. byte4 = BREAK_UINT32(pCfg->m_SysCfgInfo.m_unContinuousAcquisitionSpanTime, 3);
  1143. }
  1144. else
  1145. {
  1146. byte1 = BREAK_UINT32(pCfg->m_SysCfgInfo.m_unSelfDumpingSpanTime, 0);
  1147. byte2 = BREAK_UINT32(pCfg->m_SysCfgInfo.m_unSelfDumpingSpanTime, 1);
  1148. byte3 = BREAK_UINT32(pCfg->m_SysCfgInfo.m_unSelfDumpingSpanTime, 2);
  1149. byte4 = BREAK_UINT32(pCfg->m_SysCfgInfo.m_unSelfDumpingSpanTime, 3);
  1150. }
  1151. nLiveAcqTime = BUILD_UINT32(byte4, byte3, byte2, byte1);
  1152. if (nLiveAcqTime <= 0)
  1153. {
  1154. FWARN("live aqc time:{$}ms", nLiveAcqTime);
  1155. nLiveAcqTime = 1000;
  1156. }
  1157. FINFO("nLiveAcqTime:{$}ms", nLiveAcqTime);
  1158. unsigned int nMaxFps = (unsigned int)(1000 / nLiveAcqTime);
  1159. if (nMaxFps <= 0) nMaxFps = 1;
  1160. FINFO("nMaxFps:{$}", nMaxFps);
  1161. //correction enable
  1162. if (pCfg->m_ImgCaliCfg.m_byOffsetCorrection == 0x01)
  1163. FINFO("Firmware offset correction disenable.[0x{$02X}]", pCfg->m_ImgCaliCfg.m_byOffsetCorrection);
  1164. else if (pCfg->m_ImgCaliCfg.m_byOffsetCorrection == 0x02)
  1165. FINFO("Firmware offset correction enable.[0x{$02X}]", pCfg->m_ImgCaliCfg.m_byOffsetCorrection);
  1166. else
  1167. FINFO("Firmware other offset correction enable.[0x{$02X}]", pCfg->m_ImgCaliCfg.m_byOffsetCorrection);
  1168. if (pCfg->m_ImgCaliCfg.m_byGainCorrection == 0x01)
  1169. FINFO("Firmware gain correction disenable.[0x{$02X}]", pCfg->m_ImgCaliCfg.m_byGainCorrection);
  1170. else if (pCfg->m_ImgCaliCfg.m_byGainCorrection == 0x02)
  1171. FINFO("Firmware gain correction enable.[0x{$02X}]", pCfg->m_ImgCaliCfg.m_byGainCorrection);
  1172. else
  1173. FINFO("Firmware gain offset correction enable.[0x{$02X}]", pCfg->m_ImgCaliCfg.m_byGainCorrection);
  1174. if (pCfg->m_ImgCaliCfg.m_byDefectCorrection == 0x01)
  1175. FINFO("Firmware defect correction disenable.[0x{$02X}]", pCfg->m_ImgCaliCfg.m_byDefectCorrection);
  1176. else if (pCfg->m_ImgCaliCfg.m_byDefectCorrection == 0x02)
  1177. FINFO("Firmware defect correction enable.[0x{$02X}]", pCfg->m_ImgCaliCfg.m_byDefectCorrection);
  1178. else
  1179. FINFO("Firmware defect offset correction enable.[0x{$02X}]", pCfg->m_ImgCaliCfg.m_byDefectCorrection);
  1180. if (pCfg->m_ImgCaliCfg.m_byDummyCorrection == 0x01)
  1181. FINFO("Firmware Dummy correction disenable.[0x{$02X}]", pCfg->m_ImgCaliCfg.m_byDummyCorrection);
  1182. else if (pCfg->m_ImgCaliCfg.m_byDummyCorrection == 0x02)
  1183. FINFO("Firmware Dummy correction enable.[0x{$02X}]", pCfg->m_ImgCaliCfg.m_byDummyCorrection);
  1184. else
  1185. FINFO("Firmware Dummy offset correction enable.[0x{$02X}]", pCfg->m_ImgCaliCfg.m_byDummyCorrection);
  1186. // PGA level
  1187. nPGALevel = GetPGA(pCfg->m_TICOFCfg.m_sTICOFRegister[26]);
  1188. FINFO("nPGALevel:{$}", nPGALevel);
  1189. }
  1190. bool Detector_HaoBoRF::ConnectDetector()
  1191. {
  1192. printf("========ConnectDetector \n");
  1193. FINFO("========ConnectDetector ");
  1194. int nRet = HBI_SUCCSS;
  1195. commCfg._type = UDP_JUMBO_COMM_TYPE;//标准网口,支持jumbo类型
  1196. commCfg._loacalPort = 32896;
  1197. commCfg._remotePort = 32897;
  1198. memset(commCfg._localip, 0, sizeof(commCfg._localip));
  1199. memset(commCfg._remoteip,0, sizeof(commCfg._remoteip));
  1200. sprintf(commCfg._localip, "%s", "192.168.10.20");//本机IP
  1201. sprintf(commCfg._remoteip, "%s", "192.168.10.40");//探测器IP
  1202. int dooffsetTemplate = 0;
  1203. FINFO("Calling HBI_ConnectDetector");
  1204. nRet = HBI_ConnectDetector(m_nFpdHandle, commCfg, dooffsetTemplate);
  1205. if (TestError(nRet,"HBI_ConnectDetector"))
  1206. {
  1207. FERROR("Connect detector fail!");
  1208. return false;
  1209. }
  1210. return true;
  1211. }
  1212. //True 有错 false 没错
  1213. bool Detector_HaoBoRF::TestError(int nErrorCode, const char* szFuncName)
  1214. {
  1215. if (nErrorCode)
  1216. {
  1217. string strErrorInfo = HBI_GetError(CrErrStrList, 51, nErrorCode);
  1218. if (strErrorInfo.size() == 0)
  1219. {
  1220. FERROR("HBI_GetError fail! error code:{$}", nErrorCode);
  1221. }
  1222. else
  1223. {
  1224. FERROR("{$} return error {$}, reason: {$}", szFuncName, nErrorCode, strErrorInfo);
  1225. }
  1226. return true;
  1227. }
  1228. else
  1229. {
  1230. FINFO("{$} executed successfully", szFuncName);
  1231. return false;
  1232. }
  1233. }
  1234. bool Detector_HaoBoRF::GetPanelInfo()
  1235. {
  1236. FINFO("======GetPanelInfo");
  1237. int nRet = HBI_SUCCSS;
  1238. char serialNumber[20] = { 0 };
  1239. FINFO("Call HBI_GetFPDSerialNumber");
  1240. nRet = HBI_GetFPDSerialNumber(m_nFpdHandle, serialNumber);
  1241. if (TestError(nRet,"HBI_GetFPDSerialNumber"))
  1242. {
  1243. return false;
  1244. }
  1245. FINFO("Detector SN:{$}",serialNumber);
  1246. char sdkVersion[100] = { 0 };
  1247. FINFO("Call HBI_GetSDKVerion");
  1248. nRet = HBI_GetSDKVerion(m_nFpdHandle, sdkVersion);
  1249. if (TestError(nRet, "HBI_GetSDKVerion"))
  1250. {
  1251. return false;
  1252. }
  1253. FINFO("Detector sdk version:{$}", sdkVersion);
  1254. char firmwareVersion[100] = { 0 };
  1255. FINFO("Call HBI_GetFirmareVerion");
  1256. nRet = HBI_GetFirmareVerion(m_nFpdHandle, firmwareVersion);
  1257. if (TestError(nRet, "HBI_GetFirmareVerion"))
  1258. {
  1259. return false;
  1260. }
  1261. FINFO("Detector firmware version:{$}", firmwareVersion);
  1262. RegCfgInfo* pCfgInfo = new RegCfgInfo;
  1263. memset(pCfgInfo, 0x00, sizeof(RegCfgInfo));
  1264. FINFO("Call HBI_GetFirmareVerion");
  1265. nRet = HBI_GetFpdCfgInfo(m_nFpdHandle, pCfgInfo);
  1266. if (TestError(nRet, "HBI_GetFirmareVerion"))
  1267. {
  1268. return false;
  1269. }
  1270. PrintDetectorCfg(pCfgInfo);
  1271. if (pCfgInfo)
  1272. {
  1273. delete pCfgInfo;
  1274. pCfgInfo = nullptr;
  1275. }
  1276. IMAGE_PROPERTY* imageProperty = new ImageProperty();
  1277. FINFO("Call HBI_GetImageProperty");
  1278. nRet = HBI_GetImageProperty(m_nFpdHandle, imageProperty);
  1279. if (TestError(nRet, "HBI_GetImageProperty"))
  1280. {
  1281. return false;
  1282. }
  1283. FINFO("FPD num:{$}, ImageWidth:{$}, ImageHeight:{$}, DataType:{$}, ImageBit:{$}, Endian:{$}, PacketSize:{$}, \
  1284. FrameSize:{$}, TailPacketSize:{$}, CapacitySize:{$}",
  1285. imageProperty->nFpdNum, imageProperty->nwidth, imageProperty->nheight, imageProperty->datatype, imageProperty->ndatabit,
  1286. imageProperty->nendian, imageProperty->packet_size, imageProperty->frame_size, imageProperty->tailPacketSize, imageProperty->frame_number);
  1287. if (imageProperty)
  1288. {
  1289. delete imageProperty;
  1290. imageProperty = nullptr;
  1291. }
  1292. FINFO("Call HBI_IsMutilMode");
  1293. bool bRet = HBI_IsMutilMode(m_nFpdHandle);
  1294. if (bRet)
  1295. {
  1296. FINFO("Detector support multi mode!");
  1297. }
  1298. else
  1299. {
  1300. FINFO("Detector doesn't support multi mode!");
  1301. }
  1302. return true;
  1303. }
  1304. bool Detector_HaoBoRF::CalculateEXI(WORD* pImgData, int nImgWidth, int nImgHeight, int nImageBit, int nThreshold)
  1305. {
  1306. int nROIXL = static_cast<int>(0.3 * nImgWidth);
  1307. int nROIXR = static_cast<int>(0.7 * nImgWidth);
  1308. int nROIYL = static_cast<int>(0.3 * nImgHeight);
  1309. int nROIYR = static_cast<int>(0.7 * nImgHeight);
  1310. WORD* pSrc = NULL;
  1311. long nCount = 0;
  1312. DWORD64 nSum = 0;
  1313. int nEXI = 0;
  1314. try
  1315. {
  1316. for (int i = nROIYL; i < nROIYR; i++)
  1317. {
  1318. pSrc = pImgData + (i * nImgWidth);
  1319. for (int j = nROIXL; j < nROIXR; j++)
  1320. {
  1321. nSum += *(pSrc + j);
  1322. nCount++;
  1323. }
  1324. }
  1325. nEXI = (int)(nSum / nCount);
  1326. }
  1327. catch (...)
  1328. {
  1329. return false;
  1330. }
  1331. FINFO("Image EXI:{$}, Threshold:{$}", nEXI, nThreshold);
  1332. if (nEXI >= nThreshold)
  1333. {
  1334. FINFO("Image has xray!");
  1335. return true;//有x射线
  1336. }
  1337. return false;
  1338. }
  1339. bool Detector_HaoBoRF::CheckImageExi(WORD* pImgData, int nImgWidth, int nImgHeight, WORD dwExiThrethold)
  1340. {
  1341. if (dwExiThrethold <= 0)
  1342. {
  1343. return true;
  1344. }
  1345. FINFO("Check image exi...");
  1346. bool bResult = CalculateEXI(pImgData, nImgWidth, nImgHeight, 16, dwExiThrethold);
  1347. if (bResult)
  1348. {
  1349. return true;
  1350. }
  1351. FINFO("Check image exi---black Image");
  1352. return false;
  1353. }
  1354. //nIndex 缺省-1
  1355. void Detector_HaoBoRF::OnProcessImage(int nWidth, int nHeight, int nFrameID)
  1356. {
  1357. printf("========OnProcessImage \n");
  1358. FINFO("========OnProcessImage nWidth:{$},nHeight:{$},nIndex:{$}", nWidth, nHeight, nFrameID);
  1359. int ret = 0;
  1360. bool bImageCrop = false;
  1361. if (m_nCropLeft != 0 || m_nCropTop != 0 || m_nCropRight != 0 || m_nCropBottom != 0)
  1362. {
  1363. ret = CropImageMargin(m_pFullImgBuffer, m_nImageWidth, m_nImageHeight,
  1364. m_pRawImgBuffer, m_nRawImageWidth, m_nRawImageHeight, m_nImageBits,
  1365. m_nCropLeft, m_nCropTop, m_nCropRight, m_nCropBottom);
  1366. if (ret)
  1367. {
  1368. FERROR("CropImageMargin fail!!");
  1369. }
  1370. else
  1371. {
  1372. FINFO("CropImageMargin success!");
  1373. bImageCrop = true;
  1374. }
  1375. }
  1376. //上图之前回调图像的宽高,使得上层在拷贝内存时是正确的图像大小
  1377. if (bImageCrop)
  1378. {
  1379. ConfFeedback(EVT_CONF_RAW_WIDTH, m_nCurrentPanelID, "", m_nImageWidth);
  1380. ConfFeedback(EVT_CONF_RAW_HIGHT, m_nCurrentPanelID, "", m_nImageHeight);
  1381. }
  1382. else
  1383. {
  1384. ConfFeedback(EVT_CONF_RAW_WIDTH, m_nCurrentPanelID, "", m_nRawImageWidth);
  1385. ConfFeedback(EVT_CONF_RAW_HIGHT, m_nCurrentPanelID, "", m_nRawImageHeight);
  1386. }
  1387. if (!m_bValidImage && m_nDelayTime > 0)
  1388. {
  1389. m_dwEndTime = GetTickCount64();
  1390. }
  1391. FINFO("OnProcessImage m_nDropImgNum:{$} m_nDropImgCount:{$}", m_nDropImgNum, m_nDropImgCount);
  1392. if (m_nDropImgNum < m_nDropImgCount)//配置为0时表示不丢图
  1393. {
  1394. m_nDropImgNum++;
  1395. FINFO("Drop {$} image", m_nDropImgNum);
  1396. }
  1397. else if (!CheckTimeLimit(m_dwBeginTime, m_dwEndTime))//m_nDelayTime 配置为0时表示不延时
  1398. {
  1399. m_nDropImgNum++;
  1400. FERROR("CheckTimeLimit Drop {$} image", m_nDropImgNum);
  1401. }
  1402. else
  1403. {
  1404. if (m_bFirstImage)
  1405. {
  1406. FINFO("m_bFirstImage is true");
  1407. StatusFeedback(EVT_STATUS_PANEL, PANEL_XWINDOW_ON);
  1408. m_bFirstImage = false;
  1409. }
  1410. FINFO("OnProcessImage m_nCurrentLogicMode:{$}", m_nCurrentLogicMode);
  1411. //560RF动态模式做点片
  1412. if (m_nCurrentLogicMode == AcqMode::RAD)
  1413. {
  1414. FINFO("RAD mode");
  1415. if (m_bValidImage)
  1416. {
  1417. //RAD模式已经推过图了就不在推图了
  1418. FINFO("RAD has send one image! return");
  1419. return;
  1420. }
  1421. if (bImageCrop)
  1422. {
  1423. //计算图像EXI 不满足的不往上推
  1424. if (!CheckImageExi(m_pFullImgBuffer, m_nImageWidth, m_nImageHeight, m_nExiThreshold)) //true 有射线 false 没射线
  1425. {
  1426. return;
  1427. }
  1428. }
  1429. else
  1430. {
  1431. //计算图像EXI 不满足的不往上推
  1432. if (!CheckImageExi(m_pRawImgBuffer, m_nRawImageWidth, m_nRawImageHeight, m_nExiThreshold)) //true 有射线 false 没射线
  1433. {
  1434. return;
  1435. }
  1436. }
  1437. }
  1438. if (bImageCrop)
  1439. {
  1440. DataFeedback(EVT_DATA_RAW_IMAGE, m_pFullImgBuffer);
  1441. }
  1442. else
  1443. {
  1444. DataFeedback(EVT_DATA_RAW_IMAGE, m_pRawImgBuffer);
  1445. }
  1446. m_bValidImage = true; //合法图像,不再判断时间间隔
  1447. }
  1448. if (m_nSaveRaw)
  1449. {
  1450. SaveImage(nFrameID, bImageCrop);
  1451. }
  1452. }
  1453. void Detector_HaoBoRF::SaveImage(int nIndex, bool bImageCrop)
  1454. {
  1455. FINFO("========Begin save image");
  1456. char szTemp[30] = { 0 };
  1457. FILE* fp;
  1458. string strFileName = m_strCtrlWorkPath + "\\rawdata";
  1459. if (-1 == nIndex)
  1460. {
  1461. strFileName += "\\Image_Rad.raw";
  1462. }
  1463. else
  1464. {
  1465. sprintf_s(szTemp, "\\Image_%d.raw", nIndex);
  1466. strFileName += szTemp;
  1467. }
  1468. if ((fp = fopen(strFileName.c_str(), "wb+")) == NULL)
  1469. {
  1470. DWORD dw = GetLastError();
  1471. FERROR("fopen {$} failed, {$}", strFileName, dw);
  1472. return;
  1473. }
  1474. if (bImageCrop)
  1475. {
  1476. fwrite(m_pFullImgBuffer, sizeof(WORD), (ULONGLONG)m_nImageWidth * m_nImageHeight, fp);
  1477. }
  1478. else
  1479. {
  1480. fwrite(m_pRawImgBuffer, sizeof(WORD), (ULONGLONG)m_nRawImageWidth * m_nRawImageHeight, fp);
  1481. }
  1482. fclose(fp);
  1483. FINFO("Save {$} image over", strFileName);
  1484. }
  1485. // 说明:调用SDK接口,执行offset校正流程 dark校正、闲时offset刷新都会调用这个函数
  1486. bool Detector_HaoBoRF::StartDarkCalibration()
  1487. {
  1488. printf("========StartDarkCalibration \n");
  1489. FINFO("========StartDarkCalibration");
  1490. FINFO("Call HBI_GenerateTemplate");
  1491. int ret = HBI_GenerateTemplate(m_nFpdHandle, OFFSET_TEMPLATE_TYPE, 0);
  1492. if (TestError(ret,"HBI_GenerateTemplate"))
  1493. {
  1494. return false;
  1495. }
  1496. return true;
  1497. }
  1498. bool Detector_HaoBoRF::StartGainCalibration()
  1499. {
  1500. printf("========StartGainCalibration \n");
  1501. FINFO("========StartGainCalibration ");
  1502. if (-1 == m_nCurrentLogicMode)
  1503. {
  1504. FERROR("Illegal exam mode");
  1505. return false;
  1506. }
  1507. return true;
  1508. }
  1509. unsigned __stdcall Detector_HaoBoRF::onFPDScanThread(PVOID pvoid)
  1510. {
  1511. Detector_HaoBoRF* pOpr = (Detector_HaoBoRF*)pvoid;
  1512. FINFO("Enter scan thread");
  1513. bool bExit = false;
  1514. while (!bExit)
  1515. {
  1516. DWORD dwRet = WaitForMultipleObjects(SCAN_EVENT_COUNT, pOpr->m_hArrayEvent, FALSE, INFINITE);
  1517. if (WAIT_OBJECT_0 == dwRet) //m_hStopScanEvent
  1518. {
  1519. bExit = true;
  1520. }
  1521. else if (WAIT_OBJECT_0 + 1 == dwRet) //m_hAcqEvent
  1522. {
  1523. pOpr->OnAcquireImage();
  1524. }
  1525. else if (WAIT_OBJECT_0 + 2 == dwRet) //m_hGainEvent
  1526. {
  1527. pOpr->OnAcquireGainImage();
  1528. }
  1529. else if (WAIT_OBJECT_0 + 3 == dwRet) //m_hDarkEvent
  1530. {
  1531. pOpr->OnStartDarkCalibration();
  1532. }
  1533. else if (WAIT_OBJECT_0 + 4 == dwRet) //m_hProcessImgEvent
  1534. {
  1535. pOpr->OnProcessImage(pOpr->m_nRawImageWidth, pOpr->m_nRawImageHeight, pOpr->m_nFrameID);
  1536. }
  1537. }
  1538. FINFO("Level scan thread");
  1539. return 0;
  1540. }
  1541. unsigned __stdcall Detector_HaoBoRF::RefreshOffsetThread(PVOID pvoid)
  1542. {
  1543. Detector_HaoBoRF* pOpr = (Detector_HaoBoRF*)pvoid;
  1544. FINFO("========Enter fresh offset thread");
  1545. bool bExit = false;
  1546. while (!bExit)
  1547. {
  1548. DWORD dwRet = WaitForMultipleObjects(OFFSET_EVENT_COUNT, pOpr->m_hOffsetEvent, FALSE, INFINITE);
  1549. if (WAIT_OBJECT_0 == dwRet) //m_hStopOffsetEvent
  1550. {
  1551. bExit = true;
  1552. }
  1553. else if (WAIT_OBJECT_0 + 1 == dwRet) //m_hStartAllOffset
  1554. {
  1555. pOpr->RefreshAllOffset();
  1556. }
  1557. else if (WAIT_OBJECT_0 + 2 == dwRet) //m_hStartOffset
  1558. {
  1559. pOpr->OnRefreshOffset();
  1560. }
  1561. else if (WAIT_OBJECT_0 + 3 == dwRet) //m_hAbortOffset
  1562. {
  1563. pOpr->AbortFreshOffset();
  1564. }
  1565. }
  1566. FINFO("Level fresh offset thread");
  1567. return 0;
  1568. }
  1569. //1800RF支持单独的RAD模式
  1570. void Detector_HaoBoRF::OnAcquireImage()
  1571. {
  1572. printf("========OnAcquireImage \n");
  1573. FINFO("========OnAcquireImage ");
  1574. SetDpcStatus(DetStatus_Acquire); //动态模式激活采集,设置状态
  1575. SetDpcStatus(DetStatus_Standby); //rad采集失败,设置状态
  1576. }
  1577. //SDK Rad模式增益校正流程
  1578. void Detector_HaoBoRF::OnAcquireGainImage()
  1579. {
  1580. printf("========OnAcquireGainImage \n");
  1581. FINFO("========OnAcquireGainImage ");
  1582. SetDpcStatus(DetStatus_Standby);
  1583. StatusFeedback(EVT_STATUS_CALIBRATIOIN, PANEL_EVENT_END_OK);
  1584. }
  1585. //说明:开始暗场校正
  1586. void Detector_HaoBoRF::OnStartDarkCalibration()
  1587. {
  1588. printf("========OnStartDarkCalibration \n");
  1589. FINFO("========OnStartDarkCalibration ");
  1590. SetDpcStatus(DetStatus_OffsetCalibration); //开始offset校正
  1591. if (StartDarkCalibration())
  1592. {
  1593. StatusFeedback(EVT_STATUS_CALIBRATIOIN, PANEL_EVENT_END_OK);
  1594. }
  1595. else
  1596. {
  1597. StatusFeedback(EVT_STATUS_CALIBRATIOIN, PANEL_EVENT_END_ERROR);
  1598. }
  1599. SetDpcStatus(DetStatus_Standby); //offset校正完成,置回Standby
  1600. }
  1601. //获取只用于本DPC记录的探测器状态
  1602. eDetStatus Detector_HaoBoRF::GetDpcStatus()
  1603. {
  1604. string strStatus = "Unknown";
  1605. switch (m_eStatus)
  1606. {
  1607. case DetStatus_NotIni:
  1608. strStatus = "NotIni";
  1609. break;
  1610. case DetStatus_NotConn:
  1611. strStatus = "NotConn";
  1612. break;
  1613. case DetStatus_Sleep:
  1614. strStatus = "Sleep";
  1615. break;
  1616. case DetStatus_Standby:
  1617. strStatus = "Standby";
  1618. break;
  1619. case DetStatus_Acquire:
  1620. strStatus = "Acquire";
  1621. break;
  1622. case DetStatus_OffsetCalibration:
  1623. strStatus = "OffsetCalibration";
  1624. break;
  1625. case DetStatus_GainCalibration:
  1626. strStatus = "GainCalibration";
  1627. break;
  1628. default:
  1629. break;
  1630. }
  1631. FINFO("Driver status: {$}", strStatus.c_str());
  1632. return m_eStatus;
  1633. }
  1634. //设置只用于本DPC的探测器状态
  1635. bool Detector_HaoBoRF::SetDpcStatus(eDetStatus status)
  1636. {
  1637. string strStatus = "Unknown";
  1638. bool bSetStatus = true;
  1639. switch (status)
  1640. {
  1641. case DetStatus_NotIni:
  1642. strStatus = "NotIni";
  1643. break;
  1644. case DetStatus_NotConn:
  1645. strStatus = "NotConn";
  1646. break;
  1647. case DetStatus_Sleep:
  1648. strStatus = "Sleep";
  1649. break;
  1650. case DetStatus_Standby:
  1651. strStatus = "Standby";
  1652. break;
  1653. case DetStatus_Acquire:
  1654. strStatus = "Acquire";
  1655. break;
  1656. case DetStatus_OffsetCalibration:
  1657. strStatus = "OffsetCalibration";
  1658. break;
  1659. case DetStatus_GainCalibration:
  1660. strStatus = "GainCalibration";
  1661. break;
  1662. default:
  1663. bSetStatus = false;
  1664. break;
  1665. }
  1666. if (bSetStatus)
  1667. {
  1668. m_eStatus = status;
  1669. FINFO("Set driver status: {$}", strStatus.c_str());
  1670. }
  1671. else
  1672. {
  1673. FERROR("{$} {$} is a illegal status", strStatus.c_str(), (int)status);
  1674. }
  1675. return bSetStatus;
  1676. }
  1677. bool Detector_HaoBoRF::LoadCalibrationFiles()
  1678. {
  1679. FINFO("========LoadCalibrationFiles");
  1680. return true;
  1681. }
  1682. //参照RFOC康众动态代码整理的图像裁剪功能
  1683. int Detector_HaoBoRF::CropImageMargin(LPVOID pDstData, int& nDstWidth, int& nDstHeight,
  1684. LPVOID pScrData, int nSrcWidth, int nSrcHeight, int nBits,
  1685. int nLeftMargin, int nTopMargin, int nRightMargin, int nBottomMargin)
  1686. {
  1687. printf("========CropImageMargin \n");
  1688. FINFO("========CropImageMargin ");
  1689. if ((pDstData == NULL) || (pScrData == NULL) || (nSrcWidth <= 0) || (nSrcHeight <= 0) || (nBits <= 0))
  1690. return -1;
  1691. if ((nLeftMargin >= nSrcWidth) || (nTopMargin >= nSrcHeight))
  1692. return -1;
  1693. int nBitsToBYTE = (int)((nBits + 7) * 0.125);
  1694. if (nBitsToBYTE < 1)
  1695. return -1;
  1696. int nXL, nXR, nYL, nYR;
  1697. nXL = nLeftMargin;//32
  1698. nYL = nTopMargin;
  1699. if (nSrcWidth - nRightMargin < 0)
  1700. return -1;
  1701. nXR = nSrcWidth - nRightMargin - 1; //2783
  1702. if (nXR < nXL)
  1703. return -1;
  1704. if (nSrcHeight - nBottomMargin < 0)
  1705. return -1;
  1706. nYR = nSrcHeight - nBottomMargin - 1;
  1707. if (nYR < nYL)
  1708. return -1;
  1709. nDstWidth = nXR - nXL + 1;
  1710. nDstHeight = nYR - nYL + 1;
  1711. FINFO("TopCrop:{$};Bottom:{$},nDstWidth:{$},nDstHeight:{$},Bits:{$}", nYL, nYR, nDstWidth, nDstHeight, nBitsToBYTE);
  1712. int i = 0;
  1713. #pragma omp parallel private(i)
  1714. {
  1715. #pragma omp for
  1716. for (i = nYL; i <= nYR; i++)
  1717. {
  1718. ::memcpy((WORD*)pDstData + (i - nYL) * nDstWidth, (WORD*)pScrData + (i * nSrcWidth + nXL), nDstWidth * nBitsToBYTE);
  1719. }
  1720. }
  1721. return 0;
  1722. }
  1723. //说明:初始化时刷新所有模式的offset 配置文件的OffsetInterval配置为0时则不会运行此段代码
  1724. bool Detector_HaoBoRF::RefreshAllOffset()
  1725. {
  1726. printf("========Refresh all mode offset begin \n");
  1727. FINFO("========Refresh all mode offset begin");
  1728. bool bRet = false;
  1729. SetDpcStatus(DetStatus_OffsetCalibration); //开始全模式offset刷新
  1730. StatusFeedback(EVT_STATUS_OFFSET, PANEL_EVENT_START);
  1731. StatusFeedback(EVT_STATUS_OFFSET_PROGRESS, 0);
  1732. bRet = StartDarkCalibration(); //当前mode失败,仍可以进行下一个mode的刷新
  1733. if (!bRet)
  1734. {
  1735. FERROR("RefreshAllOffset StartDarkCalibration failed!");
  1736. StatusFeedback(EVT_STATUS_OFFSET, PANEL_EVENT_END_ERROR);
  1737. }
  1738. StatusFeedback(EVT_STATUS_OFFSET_PROGRESS, 1);
  1739. SetDpcStatus(DetStatus_Standby); //全模式offset刷新结束,置回Standby
  1740. StatusFeedback(EVT_STATUS_OFFSET, PANEL_EVENT_END_OK);
  1741. FINFO("Refresh all mode offset over");
  1742. return bRet;
  1743. }
  1744. //说明:刷当前模式的offset,什么时候刷由前端控制
  1745. void Detector_HaoBoRF::OnRefreshOffset()
  1746. {
  1747. FINFO("========OnRefreshOffset begin");
  1748. bool bRet = false;
  1749. SetDpcStatus(DetStatus_OffsetCalibration);
  1750. StatusFeedback(EVT_STATUS_OFFSET_PROGRESS, 0);
  1751. StatusFeedback(EVT_STATUS_OFFSET, PANEL_EVENT_START);
  1752. bRet = StartDarkCalibration();
  1753. if (bRet)
  1754. {
  1755. StatusFeedback(EVT_STATUS_OFFSET_PROGRESS, 1);
  1756. }
  1757. else
  1758. {
  1759. FERROR("OnRefreshOffset StartDarkCalibration failed!");
  1760. StatusFeedback(EVT_STATUS_OFFSET, PANEL_EVENT_END_ERROR);
  1761. }
  1762. SetDpcStatus(DetStatus_Standby);
  1763. StatusFeedback(EVT_STATUS_OFFSET, PANEL_EVENT_END_OK);
  1764. FINFO("OnRefreshOffset over");
  1765. }
  1766. bool Detector_HaoBoRF::CheckTimeLimit(ULONGLONG dwBeginTime, ULONGLONG dwEndTime)
  1767. {
  1768. if (m_bValidImage) //合法图像,不再判断时间间隔,直接返回true
  1769. {
  1770. FINFO("CheckTimeLimit m_bValidImage is true!");
  1771. return true;
  1772. }
  1773. if (m_nDelayTime == 0) //没有开启延时机制
  1774. {
  1775. FINFO("The delay time is invalid, return");
  1776. return true;
  1777. }
  1778. if ((int)(dwEndTime - dwBeginTime) > m_nDelayTime)
  1779. {
  1780. FINFO("The interval({$}) is ok", dwEndTime - dwBeginTime);
  1781. return true;
  1782. }
  1783. FERROR("The interval({$}) is shorter than the delay({$})",dwEndTime - dwBeginTime, m_nDelayTime);
  1784. return false;
  1785. }
  1786. void Detector_HaoBoRF::ConfFeedback(int nEventID, int nDetectorID, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1787. {
  1788. if (-1 == nDetectorID)
  1789. {
  1790. nDetectorID = m_nCurrentPanelID;
  1791. }
  1792. ((FPDDeviceHaoBo*)(*m_pPanelID2DPC)[nDetectorID])->OnFPDCallback(nDetectorID,
  1793. nEventID, EVT_LEVEL_CONFIGURATION, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1794. }
  1795. void Detector_HaoBoRF::InfoFeedback(int nEventID, int nDetectorID, int nParam1, float fParam2, const char* pszMsg, int nPtrParamLen, void* pParam)
  1796. {
  1797. if (-1 == nDetectorID)
  1798. {
  1799. nDetectorID = m_nCurrentPanelID;
  1800. }
  1801. ((FPDDeviceHaoBo*)(*m_pPanelID2DPC)[nDetectorID])->OnFPDCallback(nDetectorID,
  1802. nEventID, EVT_LEVEL_INFORMATOION, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1803. }
  1804. void Detector_HaoBoRF::StatusFeedback(int nEventID, int nParam1, const char* pszMsg, int nDetectorID, float fParam2, int nPtrParamLen, void* pParam)
  1805. {
  1806. if (-1 == nDetectorID)
  1807. {
  1808. nDetectorID = m_nCurrentPanelID;
  1809. }
  1810. ((FPDDeviceHaoBo*)(*m_pPanelID2DPC)[nDetectorID])->OnFPDCallback(nDetectorID,
  1811. nEventID, EVT_LEVEL_STATUS, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1812. }
  1813. void Detector_HaoBoRF::DataFeedback(int nEventID, void* pParam, int nParam1, float fParam2, const char* pszMsg, int nPtrParamLen, int nDetectorID)
  1814. {
  1815. if (-1 == nDetectorID)
  1816. {
  1817. nDetectorID = m_nCurrentPanelID;
  1818. }
  1819. ((FPDDeviceHaoBo*)(*m_pPanelID2DPC)[nDetectorID])->OnFPDCallback(nDetectorID,
  1820. nEventID, EVT_LEVEL_DATA, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1821. }
  1822. void Detector_HaoBoRF::WarnFeedback(int nEventID, const char* pszMsg, int nParam1, float fParam2, int nPtrParamLen, void* pParam, int nDetectorID)
  1823. {
  1824. if (-1 == nDetectorID)
  1825. {
  1826. nDetectorID = m_nCurrentPanelID;
  1827. }
  1828. ((FPDDeviceHaoBo*)(*m_pPanelID2DPC)[nDetectorID])->OnFPDCallback(nDetectorID,
  1829. nEventID, EVT_LEVEL_WARNING, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1830. }
  1831. void Detector_HaoBoRF::ErrorFeedback(int nEventID, const char* pszMsg, int nDetectorID, int nParam1, float fParam2, int nPtrParamLen, void* pParam)
  1832. {
  1833. if (-1 == nDetectorID)
  1834. {
  1835. nDetectorID = m_nCurrentPanelID;
  1836. }
  1837. ((FPDDeviceHaoBo*)(*m_pPanelID2DPC)[nDetectorID])->OnFPDCallback(nDetectorID,
  1838. nEventID, EVT_LEVEL_ERROR, pszMsg, nParam1, fParam2, nPtrParamLen, pParam);
  1839. }
  1840. float Detector_HaoBoRF::SetFluPPS(float fPPS)
  1841. {
  1842. FINFO("========SetFluPPS {$}", fPPS);
  1843. m_fFrameRate = fPPS;
  1844. return m_fFrameRate;
  1845. }
  1846. void Detector_HaoBoRF::GetFluPPS(float& fFluPPS)
  1847. {
  1848. fFluPPS = m_fFrameRate;
  1849. FINFO("========GetFluPPS {$}", fFluPPS);
  1850. }
  1851. void Detector_HaoBoRF::AbortFreshOffset()
  1852. {
  1853. FINFO("========AbortFreshOffset");
  1854. }
  1855. void Detector_HaoBoRF::SetAbortOffsetEvent()
  1856. {
  1857. FINFO("========SetAbortOffsetEvent");
  1858. SetEvent(m_hAbortOffset);
  1859. }
  1860. void Detector_HaoBoRF::SetFreshAllOffsetEvent()
  1861. {
  1862. FINFO("========SetFreshAllOffsetEvent");
  1863. SetEvent(m_hStartAllOffset);
  1864. }
  1865. void Detector_HaoBoRF::SetfreshOffsetEvent()
  1866. {
  1867. FINFO("========SetfreshOffsetEvent");
  1868. SetEvent(m_hStartOffset);
  1869. }
  1870. void Detector_HaoBoRF::UpdateModeInRunning(int nMode, float fFrequency)
  1871. {
  1872. FINFO("========UpdateModeInRunning ModeID:{$},Frequency:{$}", nMode, fFrequency);
  1873. m_nModeID = nMode;
  1874. m_fFrameRate = fFrequency;
  1875. }