KonicaObject2.cpp 55 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526
  1. // KonicaObject2.cpp: CKonicaObject2 的实现
  2. #include "pch.h"
  3. #include "KonicaObject2.h"
  4. #include <comutil.h>
  5. #pragma comment(lib, "comsuppw.lib")
  6. #define IMAGE_START_ADDRESS 500
  7. CKonicaObject2* g_pKonicaObject = nullptr;
  8. void _stdcall AeroSDKCallBack(int nType, unsigned int uintParam, char* pstrPanelId, int nXgboxNo)
  9. {
  10. if (nullptr != g_pKonicaObject)
  11. {
  12. g_pKonicaObject->CallBackEvent(nType, uintParam, pstrPanelId, nXgboxNo);
  13. }
  14. }
  15. // CKonicaObject2
  16. CKonicaObject2::CKonicaObject2()
  17. {
  18. m_pDataBuffer = nullptr;
  19. m_pDataBuffer = new CShareMem("KonicaDetectorBuffer2");
  20. OutputDebugString("Create share memory----------------------");
  21. m_pDataBuffer->CreateShareMem(20 * 1024 * 1024 * sizeof(WORD));//40MB 2张预览图+1张正式图
  22. g_pKonicaObject = this;
  23. m_strSdkPath = "";
  24. m_strPanelType = "";
  25. m_nXgboxNo = 1;
  26. m_nSyncMode = SYNC_AED;
  27. m_bOpenSdk = false;
  28. m_bConnect = false;
  29. m_nDetectorStatus = AEROSDK_PANEL_STATUS_UNKNOWN;
  30. m_bConnectXgbox = false;
  31. m_nImageNo = 0;
  32. m_nPreImgWidth = 0;
  33. m_nPreImgHeight = 0;
  34. m_nRawImgWidth = 0;
  35. m_nRawImgHeight = 0;
  36. m_pPreImgBuffer1 = nullptr;
  37. m_pPreImgBuffer2 = nullptr;
  38. m_pRawImgBuffer = nullptr;
  39. m_hRespond = CreateEvent(NULL, FALSE, FALSE, NULL);
  40. m_nResolution = AEROSDK_RESOLUTION_NORMAL;
  41. m_bHaveImageInDetector = false;
  42. OutputDebugString("Init KonicaCom End----------------------");
  43. }
  44. CKonicaObject2::~CKonicaObject2()
  45. {
  46. OutputDebugString("destruction----------------------");
  47. m_pDataBuffer->CloseShareMemMap();
  48. if (m_pPreImgBuffer1 != nullptr)
  49. {
  50. delete[]m_pPreImgBuffer1;
  51. m_pPreImgBuffer1 = nullptr;
  52. }
  53. if (m_pPreImgBuffer2 != nullptr)
  54. {
  55. delete[]m_pPreImgBuffer2;
  56. m_pPreImgBuffer2 = nullptr;
  57. }
  58. if (m_pRawImgBuffer != nullptr)
  59. {
  60. delete[]m_pRawImgBuffer;
  61. m_pRawImgBuffer = nullptr;
  62. }
  63. if (m_hRespond)
  64. {
  65. CloseHandle(m_hRespond);
  66. m_hRespond = nullptr;
  67. }
  68. }
  69. /***
  70. ** 等待探测器操作执行完毕
  71. ***/
  72. bool CKonicaObject2::WaitRespond(int nTimeOut, const char* szAction)
  73. {
  74. char temp[512] = { 0 };
  75. sprintf(temp, "--- WaitRespond({%s}), {%d}ms----------------------", szAction, nTimeOut);
  76. OutputDebugString(temp);
  77. DWORD dwRet = WaitForSingleObject(m_hRespond, nTimeOut);
  78. if (dwRet == WAIT_TIMEOUT)
  79. {
  80. sprintf(temp, "time out in wait response, action:{%s}----------------------", szAction);
  81. OutputDebugString(temp);
  82. return false;
  83. }
  84. return true;
  85. }
  86. void CKonicaObject2::StopWaiting(const char* szAction)
  87. {
  88. char temp[512] = { 0 };
  89. sprintf("--- Stop waiting respond, {%s}----------------------", szAction);
  90. OutputDebugString(temp);
  91. SetEvent(m_hRespond);
  92. }
  93. STDMETHODIMP CKonicaObject2::LoadDLL(BSTR strSdkPath)
  94. {
  95. OutputDebugString("LoadDLL start----------------------");
  96. char* pSdkPath = _com_util::ConvertBSTRToString(strSdkPath);//需要手动释放内存
  97. string strWorkPath = pSdkPath;
  98. m_strSdkPath = strWorkPath;//D:\SVNDownload\CCOS_DROC_TRUNK\Device\OEMDrivers\Detector\Konica\KonicaHDDetector\SDK
  99. SetDllDirectory(strWorkPath.c_str());
  100. /*strWorkPath = strWorkPath + "\\Aerosdk.dll";
  101. HMODULE m_hSDKModule = LoadLibraryEx(strWorkPath.c_str(), nullptr, LOAD_WITH_ALTERED_SEARCH_PATH);
  102. OutputDebugString("LoadLibrary----------------------");
  103. if (m_hSDKModule == nullptr)
  104. {
  105. DWORD dw = GetLastError();
  106. char temp[1024] = { 0 };
  107. sOutputDebugString("Load %s fail! error code:%ld----------------------", strWorkPath.c_str(), dw);
  108. OutputDebugString(temp);
  109. return S_FALSE;
  110. }*/
  111. delete[] pSdkPath;
  112. Initialize();
  113. OutputDebugString("LoadDLL end----------------------");
  114. return S_OK;
  115. }
  116. void CKonicaObject2::Initialize()
  117. {
  118. ZeroMemory(&m_stLogInfo, sizeof(StAerosdkLogInfo));
  119. m_stLogInfo.intLogLevel = AEROSDK_LOG_DEBUG;
  120. sprintf_s(m_stLogInfo.strSdkLog, sizeof(m_stLogInfo.strSdkLog), "%s%s", m_strSdkPath.c_str(), "\\Log\\AeroSDK.log");
  121. sprintf_s(m_stLogInfo.strKmfLog, sizeof(m_stLogInfo.strKmfLog), "%s%s", m_strSdkPath.c_str(), "\\Log\\KmfLog.log");
  122. std::string temp;
  123. if (strAeroSDKini)
  124. {
  125. sprintf_s(strAeroSDKini, MAX_PATH, "%s%s", m_strSdkPath.c_str(), "\\Conf\\AerosdkSetting.ini");
  126. temp = "strAeroSDKini:";
  127. temp = temp + strAeroSDKini;
  128. temp = temp + "----------------------";
  129. OutputDebugString(temp.c_str());
  130. }
  131. if (strPanelLog)
  132. {
  133. sprintf_s(strPanelLog, MAX_PATH, "%s%s", m_strSdkPath.c_str(), "\\Log\\Panel.log");
  134. temp = "strPanelLog:";
  135. temp = temp + strPanelLog;
  136. temp = temp + "----------------------";
  137. OutputDebugString(temp.c_str());
  138. }
  139. if (strXGBOXLog)
  140. {
  141. sprintf_s(strXGBOXLog, MAX_PATH, "%s%s", m_strSdkPath.c_str(), "\\Log\\XGBOX.log");
  142. temp = "strXGBOXLog:";
  143. temp = temp + strXGBOXLog;
  144. temp = temp + "----------------------";
  145. OutputDebugString(temp.c_str());
  146. }
  147. if (strECBLog)
  148. {
  149. sprintf_s(strECBLog, MAX_PATH, "%s%s", m_strSdkPath.c_str(), "\\Log\\ECB.log");
  150. temp = "strECBLog:";
  151. temp = temp + strECBLog;
  152. temp = temp + "----------------------";
  153. OutputDebugString(temp.c_str());
  154. }
  155. }
  156. STDMETHODIMP CKonicaObject2::SetPanelType(BSTR strPanelType)
  157. {
  158. OutputDebugString("SetPanelType----------------------");
  159. char* pPanelType = _com_util::ConvertBSTRToString(strPanelType);//需要手动释放内存
  160. m_strPanelType = pPanelType;
  161. std::string temp = "m_strPanelType:";
  162. temp = temp + m_strPanelType;
  163. temp = temp + "----------------------";
  164. OutputDebugString(temp.c_str());
  165. delete[] pPanelType;
  166. return S_OK;
  167. }
  168. string CKonicaObject2::GetStrEventType(int nEventType)
  169. {
  170. string temp = "";
  171. switch (nEventType)
  172. {
  173. case AEROSDK_CBTYPE_PANEL_CONNECTTED_WIRE:
  174. temp = "AEROSDK_CBTYPE_PANEL_CONNECTTED_WIRE";
  175. break;
  176. case AEROSDK_CBTYPE_PANEL_CONNECTTED_WIRELESS:
  177. temp = "AEROSDK_CBTYPE_PANEL_CONNECTTED_WIRELESS";
  178. break;
  179. case AEROSDK_CBTYPE_PANEL_DISCONNECT:
  180. temp = "AEROSDK_CBTYPE_PANEL_DISCONNECT";
  181. break;
  182. case AEROSDK_CBTYPE_PANEL_STATUS:
  183. temp = "AEROSDK_CBTYPE_PANEL_STATUS";
  184. break;
  185. case AEROSDK_CBTYPE_PANEL_BATTERY_STATUS:
  186. temp = "AEROSDK_CBTYPE_PANEL_BATTERY_STATUS";
  187. break;
  188. case AEROSDK_CBTYPE_PANEL_SIGNAL_STATUS:
  189. temp = "AEROSDK_CBTYPE_PANEL_SIGNAL_STATUS";
  190. break;
  191. case AEROSDK_CBTYPE_PANEL_MOUNTED:
  192. temp = "AEROSDK_CBTYPE_PANEL_MOUNTED";
  193. break;
  194. case AEROSDK_CBTYPE_PANEL_SWITCH_PUSHED:
  195. temp = "AEROSDK_CBTYPE_PANEL_SWITCH_PUSHED";
  196. break;
  197. case AEROSDK_CBTYPE_PANEL_PULSESYNC_STATUS:
  198. temp = "AEROSDK_CBTYPE_PANEL_PULSESYNC_STATUS";
  199. break;
  200. case AEROSDK_CBTYPE_PANEL_ALIGNMENT_STATUS:
  201. temp = "AEROSDK_CBTYPE_PANEL_ALIGNMENT_STATUS";
  202. break;
  203. case AEROSDK_CBTYPE_PANEL_READY_TIMEOUT:
  204. temp = "AEROSDK_CBTYPE_PANEL_READY_TIMEOUT";
  205. break;
  206. case AEROSDK_CBTYPE_PANEL_START_IMAGE:
  207. temp = "AEROSDK_CBTYPE_PANEL_START_IMAGE";
  208. break;
  209. case AEROSDK_CBTYPE_PANEL_DONE_PREVIEW1:
  210. temp = "AEROSDK_CBTYPE_PANEL_DONE_PREVIEW1";
  211. break;
  212. case AEROSDK_CBTYPE_PANEL_DONE_PREVIEW2:
  213. temp = "AEROSDK_CBTYPE_PANEL_DONE_PREVIEW2";
  214. break;
  215. case AEROSDK_CBTYPE_PANEL_DONE_IMAGE:
  216. temp = "AEROSDK_CBTYPE_PANEL_DONE_IMAGE";
  217. break;
  218. case AEROSDK_CBTYPE_PANEL_ERROR_IMAGETRANSFER:
  219. temp = "AEROSDK_CBTYPE_PANEL_ERROR_IMAGETRANSFER";
  220. break;
  221. case AEROSDK_CBTYPE_PANEL_DONE_RETRANSFER:
  222. temp = "AEROSDK_CBTYPE_PANEL_DONE_RETRANSFER";
  223. break;
  224. case AEROSDK_CBTYPE_PANEL_UPDATE_STATUS:
  225. temp = "AEROSDK_CBTYPE_PANEL_UPDATE_STATUS";
  226. break;
  227. case AEROSDK_CBTYPE_PANEL_DONE_UPDATE:
  228. temp = "AEROSDK_CBTYPE_PANEL_DONE_UPDATE";
  229. break;
  230. case AEROSDK_CBTYPE_PANEL_UPDATE_ERROR:
  231. temp = "AEROSDK_CBTYPE_PANEL_UPDATE_ERROR";
  232. break;
  233. case AEROSDK_CBTYPE_PANEL_GAINCALIB_RESULT:
  234. temp = "AEROSDK_CBTYPE_PANEL_GAINCALIB_RESULT";
  235. break;
  236. case AEROSDK_CBTYPE_PANEL_DARKCALIB_PASSAGE:
  237. temp = "AEROSDK_CBTYPE_PANEL_DARKCALIB_PASSAGE";
  238. break;
  239. case AEROSDK_CBTYPE_PANEL_DARKCALIB_RESULT:
  240. temp = "AEROSDK_CBTYPE_PANEL_DARKCALIB_RESULT";
  241. break;
  242. case AEROSDK_CBTYPE_PANEL_OPEN_ERROR:
  243. temp = "AEROSDK_CBTYPE_PANEL_OPEN_ERROR";
  244. break;
  245. case AEROSDK_CBTYPE_PANEL_DETECT_ERROR:
  246. temp = "AEROSDK_CBTYPE_PANEL_DETECT_ERROR";
  247. break;
  248. case AEROSDK_CBTYPE_PANEL_ERROR_CANCELED:
  249. temp = "AEROSDK_CBTYPE_PANEL_ERROR_CANCELED";
  250. break;
  251. case AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_IMAGE:
  252. temp = "AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_IMAGE";
  253. break;
  254. case AEROSDK_CBTYPE_PANEL_DYNAMIC_IMAGE_FRAMECOUNT:
  255. temp = "AEROSDK_CBTYPE_PANEL_DYNAMIC_IMAGE_FRAMECOUNT";
  256. break;
  257. case AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_RETRANSFER:
  258. temp = "AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_RETRANSFER";
  259. break;
  260. case AEROSDK_CBTYPE_XGBOX_CONNECTTED:
  261. temp = "AEROSDK_CBTYPE_XGBOX_CONNECTTED";
  262. break;
  263. case AEROSDK_CBTYPE_XGBOX_DISCONNECT:
  264. temp = "AEROSDK_CBTYPE_XGBOX_DISCONNECT";
  265. break;
  266. case AEROSDK_CBTYPE_XGBOX_PREPARE_ON:
  267. temp = "AEROSDK_CBTYPE_XGBOX_PREPARE_ON";
  268. break;
  269. case AEROSDK_CBTYPE_XGBOX_EXPOSURE_ON:
  270. temp = "AEROSDK_CBTYPE_XGBOX_EXPOSURE_ON";
  271. break;
  272. case AEROSDK_CBTYPE_XGBOX_KMREADY_ON:
  273. temp = "AEROSDK_CBTYPE_XGBOX_KMREADY_ON";
  274. break;
  275. case AEROSDK_CBTYPE_XGBOX_KMREADY_OFF:
  276. temp = "AEROSDK_CBTYPE_XGBOX_KMREADY_OFF";
  277. break;
  278. case AEROSDK_CBTYPE_XGBOX_EXPOSURE_OFF:
  279. temp = "AEROSDK_CBTYPE_XGBOX_EXPOSURE_OFF";
  280. break;
  281. case AEROSDK_CBTYPE_XGBOX_PREPARE_OFF:
  282. temp = "AEROSDK_CBTYPE_XGBOX_PREPARE_OFF";
  283. break;
  284. case AEROSDK_CBTYPE_XGBOX_EXPOSUREON_TIMEOUT:
  285. temp = "AEROSDK_CBTYPE_XGBOX_EXPOSUREON_TIMEOUT";
  286. break;
  287. case AEROSDK_CBTYPE_XGBOX_ILLEGAL_SWITCH_SEQUENCE:
  288. temp = "AEROSDK_CBTYPE_XGBOX_ILLEGAL_SWITCH_SEQUENCE";
  289. break;
  290. case AEROSDK_CBTYPE_XGBOX_UPDATE_STATUS:
  291. temp = "AEROSDK_CBTYPE_XGBOX_UPDATE_STATUS";
  292. break;
  293. case AEROSDK_CBTYPE_XGBOX_DONE_UPDATE:
  294. temp = "AEROSDK_CBTYPE_XGBOX_DONE_UPDATE";
  295. break;
  296. case AEROSDK_CBTYPE_XGBOX_UPDATE_ERROR:
  297. temp = "AEROSDK_CBTYPE_XGBOX_UPDATE_ERROR";
  298. break;
  299. case AEROSDK_CBTYPE_XGBOX_OPEN_ERROR:
  300. temp = "AEROSDK_CBTYPE_XGBOX_OPEN_ERROR";
  301. break;
  302. case AEROSDK_CBTYPE_XGBOX_DETECT_ERROR:
  303. temp = "AEROSDK_CBTYPE_XGBOX_DETECT_ERROR";
  304. break;
  305. case AEROSDK_CBTYPE_XGBOX_ERROR_CANCELED:
  306. temp = "AEROSDK_CBTYPE_XGBOX_ERROR_CANCELED";
  307. break;
  308. case AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRE:
  309. temp = "AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRE";
  310. break;
  311. case AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRELESS:
  312. temp = "AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRELESS";
  313. break;
  314. case AEROSDK_CBTYPE_PANEL_XGBOX_DISCONNECT:
  315. temp = "AEROSDK_CBTYPE_PANEL_XGBOX_DISCONNECT";
  316. break;
  317. case AEROSDK_CBTYPE_PANEL_WARNING_DO_CALIBRATION:
  318. temp = "AEROSDK_CBTYPE_PANEL_WARNING_DO_CALIBRATION";
  319. break;
  320. case AEROSDK_CBTYPE_END_EXPOSURE_SEQUENCE:
  321. temp = "AEROSDK_CBTYPE_END_EXPOSURE_SEQUENCE";
  322. break;
  323. case AEROSDK_CBTYPE_END_IMAGERESENDING_SEQUENCE:
  324. temp = "AEROSDK_CBTYPE_END_IMAGERESENDING_SEQUENCE";
  325. break;
  326. case AEROSDK_CBTYPE_END_DELETEIMAGE_SEQUENCE:
  327. temp = "AEROSDK_CBTYPE_END_DELETEIMAGE_SEQUENCE";
  328. break;
  329. case AEROSDK_CBTYPE_END_PANEL_UPDATE_SEQUENCE:
  330. temp = "AEROSDK_CBTYPE_END_PANEL_UPDATE_SEQUENCE";
  331. break;
  332. case AEROSDK_CBTYPE_END_XGBOX_UPDATE_SEQUENCE:
  333. temp = "AEROSDK_CBTYPE_END_XGBOX_UPDATE_SEQUENCE";
  334. break;
  335. case AEROSDK_CBTYPE_END_PANEL_GAINCALIB_SEQUENCE:
  336. temp = "AEROSDK_CBTYPE_END_PANEL_GAINCALIB_SEQUENCE";
  337. break;
  338. case AEROSDK_CBTYPE_END_PANEL_DARKCALIB_SEQUENCE:
  339. temp = "AEROSDK_CBTYPE_END_PANEL_DARKCALIB_SEQUENCE";
  340. break;
  341. case AEROSDK_CBTYPE_END_UNSHOTIMAGE_SEQUENCE:
  342. temp = "AEROSDK_CBTYPE_END_UNSHOTIMAGE_SEQUENCE";
  343. break;
  344. case AEROSDK_CBTYPE_END_DYNAMIC_EXPOSURE_SEQUENCE:
  345. temp = "AEROSDK_CBTYPE_END_DYNAMIC_EXPOSURE_SEQUENCE";
  346. break;
  347. case AEROSDK_CBTYPE_END_DYNAMIC_IMAGERESENDING_SEQUENCE:
  348. temp = "AEROSDK_CBTYPE_END_DYNAMIC_IMAGERESENDING_SEQUENCE";
  349. break;
  350. }
  351. return temp;
  352. }
  353. bool CKonicaObject2::WriteNotifyMessageToShareMemory(int nEventType, long nStartPosition, int nParam, WORD* pImageBuffer, int nBufferSize)
  354. {
  355. std::string strResult = GetStrEventType(nEventType);
  356. std::string strtemp = "WriteNotifyMessageToShareMemory nEventType:";
  357. strtemp = strtemp + strResult;
  358. strtemp = strtemp + "----------------------";
  359. OutputDebugString(strtemp.c_str());
  360. int temp = 0;
  361. bool bRet = false;
  362. if (nEventType == AEROSDK_CBTYPE_PANEL_STATUS || nEventType == AEROSDK_CBTYPE_PANEL_BATTERY_STATUS || nEventType == AEROSDK_CBTYPE_PANEL_SIGNAL_STATUS)
  363. {
  364. temp = nParam;
  365. bRet = m_pDataBuffer->WriteShareMemEx(nStartPosition, &temp, sizeof(int));
  366. if (!bRet)
  367. {
  368. return false;
  369. }
  370. }
  371. else if (nEventType == AEROSDK_CBTYPE_PANEL_DONE_PREVIEW1 || nEventType == AEROSDK_CBTYPE_PANEL_DONE_PREVIEW2 || nEventType == AEROSDK_CBTYPE_PANEL_DONE_IMAGE)
  372. {
  373. bRet = m_pDataBuffer->WriteShareMemEx(nStartPosition, pImageBuffer, nBufferSize);
  374. if (!bRet)
  375. {
  376. return false;
  377. }
  378. }
  379. else
  380. {
  381. temp = nEventType;
  382. bRet = m_pDataBuffer->WriteShareMemEx(nStartPosition, &temp, sizeof(int));
  383. if (!bRet)
  384. {
  385. return false;
  386. }
  387. }
  388. return true;
  389. }
  390. void CKonicaObject2::CallBackEvent(int nType, unsigned int uintParam, char* pstrPanelId, int nXgboxNo)
  391. {
  392. int nRet = AEROSDK_OK;
  393. std::lock_guard<std::mutex> lock(mtx);
  394. m_queue.push(nType);
  395. std::string temp;
  396. switch (nType)
  397. {
  398. case AEROSDK_CBTYPE_PANEL_CONNECTTED_WIRE:
  399. // AeroSDK-Panel connection detection [wired]
  400. if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
  401. {
  402. m_bConnect = true;
  403. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_CONNECTTED_WIRE, 0, uintParam, nullptr, 0);
  404. }
  405. break;
  406. case AEROSDK_CBTYPE_PANEL_CONNECTTED_WIRELESS:
  407. // AeroSDK-Panel connection detection [wireless]
  408. if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
  409. {
  410. m_bConnect = true;
  411. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_CONNECTTED_WIRELESS, 4, uintParam, nullptr, 0);
  412. }
  413. break;
  414. case AEROSDK_CBTYPE_PANEL_DISCONNECT:
  415. // AeroSDK-Panel disconnection detection
  416. if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
  417. {
  418. m_bConnect = false;
  419. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DISCONNECT, 8, uintParam, nullptr, 0);
  420. }
  421. break;
  422. case AEROSDK_CBTYPE_PANEL_STATUS:
  423. // Panel status notification
  424. if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
  425. {
  426. m_nDetectorStatus = uintParam;
  427. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_STATUS, 12, m_nDetectorStatus, nullptr, 0);
  428. // In order to know the change of Panel status and show on GUI (outside of AeroSDKCallBack), the event should be set as follows.
  429. // Especially, when AerosdkStartExposureSequenceIt () is used, this code is needed in order to handle "Wait Ready" or "Read Out" event at outside of AeroSDKCallBack.
  430. switch (m_nDetectorStatus)
  431. {
  432. case AEROSDK_PANEL_STATUS_UNKNOWN:
  433. OutputDebugString("Detector status: UNKNOWN----------------------");
  434. break;
  435. case AEROSDK_PANEL_STATUS_INITIALIZE:
  436. OutputDebugString("Detector status: INITIALIZE----------------------");
  437. break;
  438. case AEROSDK_PANEL_STATUS_SLEEP:
  439. OutputDebugString("Detector status: SLEEP----------------------");
  440. break;
  441. case AEROSDK_PANEL_STATUS_STANDBY:
  442. OutputDebugString("Detector status: STANDBY----------------------");
  443. break;
  444. case AEROSDK_PANEL_STATUS_READY:
  445. OutputDebugString("Detector status: READY----------------------");
  446. break;
  447. case AEROSDK_PANEL_STATUS_EXPOSURE:
  448. OutputDebugString("Detector status: EXPOSURE----------------------");
  449. break;
  450. case AEROSDK_PANEL_STATUS_SHUTDOWN:
  451. OutputDebugString("Detector status: SHUTDOWN----------------------");
  452. break;
  453. case AEROSDK_PANEL_STATUS_UPDATE:
  454. OutputDebugString("Detector status: UPDATE----------------------");
  455. break;
  456. case AEROSDK_PANEL_STATUS_MAINTENANCE:
  457. OutputDebugString("Detector status: MAINTENANCE----------------------");
  458. break;
  459. case AEROSDK_PANEL_STATUS_WAIT_READY:
  460. OutputDebugString("Detector status: WAIT_READY----------------------");
  461. if (m_nSyncMode == SYNC_AED)
  462. {
  463. // When AeroSync Button is pushed, User Program has to make the Panel Ready status.
  464. temp = "Call API_AerosdkSetPanelReady m_strPanelType:";
  465. temp = temp + m_strPanelType;
  466. temp = temp + "----------------------";
  467. OutputDebugString(temp.c_str());
  468. //调完接口后很快就ready,但是目前没有回调,就认为ready了
  469. nRet = AerosdkSetPanelReady((char*)m_strPanelType.c_str());
  470. if (TestError(nRet, "API_AerosdkSetPanelReady"))
  471. {
  472. OutputDebugString("AerosdkSetPanelReady Failure!----------------------");
  473. }
  474. else
  475. {
  476. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_STATUS, 12, AEROSDK_PANEL_STATUS_READY, nullptr, 0);
  477. }
  478. }
  479. break;
  480. case AEROSDK_PANEL_STATUS_READOUT:
  481. OutputDebugString("Detector status: READOUT----------------------");
  482. break;
  483. case AEROSDK_PANEL_STATUS_ERROR:
  484. OutputDebugString("Detector status: ERROR----------------------");
  485. break;
  486. default:
  487. break;
  488. }
  489. }
  490. break;
  491. case AEROSDK_CBTYPE_PANEL_BATTERY_STATUS:
  492. // Panel battery status notification
  493. // Panel wireless signal strength notification
  494. OutputDebugString("Detector battery status notification----------------------");
  495. if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
  496. {
  497. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_BATTERY_STATUS, 16, uintParam, nullptr, 0);
  498. }
  499. break;
  500. case AEROSDK_CBTYPE_PANEL_SIGNAL_STATUS:
  501. // Panel mounted notification
  502. OutputDebugString("Detector signal status notification----------------------");
  503. if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
  504. {
  505. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_SIGNAL_STATUS, 20, uintParam, nullptr, 0);
  506. }
  507. break;
  508. case AEROSDK_CBTYPE_PANEL_MOUNTED:
  509. // Panel switch pressed-down notification
  510. OutputDebugString("Detector mounted notification----------------------");
  511. if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
  512. {
  513. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_MOUNTED, 24, uintParam, nullptr, 0);
  514. }
  515. break;
  516. case AEROSDK_CBTYPE_PANEL_SWITCH_PUSHED:
  517. OutputDebugString("Switch pushed notification----------------------");
  518. if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
  519. {
  520. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_SWITCH_PUSHED, 28, uintParam, nullptr, 0);
  521. }
  522. break;
  523. case AEROSDK_CBTYPE_PANEL_PULSESYNC_STATUS:
  524. OutputDebugString("AEROSDK_CBTYPE_PANEL_PULSESYNC_STATUS----------------------");
  525. if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
  526. {
  527. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_PULSESYNC_STATUS, 32, uintParam, nullptr, 0);
  528. }
  529. break;
  530. case AEROSDK_CBTYPE_PANEL_ALIGNMENT_STATUS:
  531. OutputDebugString("AEROSDK_CBTYPE_PANEL_ALIGNMENT_STATUS----------------------");
  532. if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
  533. {
  534. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_ALIGNMENT_STATUS, 36, uintParam, nullptr, 0);
  535. }
  536. break;
  537. case AEROSDK_CBTYPE_PANEL_READY_TIMEOUT:
  538. // Ready timeout notification
  539. // After several minutes has passed, the Wiress Panel will enter into Standby mode.
  540. temp = m_strPanelType;
  541. temp = temp + " Ready timeout notification----------------------";
  542. OutputDebugString(temp.c_str());
  543. if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
  544. {
  545. //set ready timeout error
  546. // Difference from AeroSDKSampleIt.cpp <ADD COMMENT>
  547. // If you want to know when this timeout happens (at READY or WAIT READY), you have to check the "uintParam";
  548. // If you want to enter into exposure sequence, call AerosdkStartExposureSequenceIt function again.
  549. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_READY_TIMEOUT, 40, uintParam, nullptr, 0);
  550. }
  551. break;
  552. case AEROSDK_CBTYPE_PANEL_START_IMAGE:
  553. // Image transfer start notification
  554. OutputDebugString("Image transfer start notnotificationify----------------------");
  555. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_START_IMAGE, 44, uintParam, nullptr, 0);
  556. break;
  557. case AEROSDK_CBTYPE_PANEL_DONE_PREVIEW1:
  558. // Preview1 image receiving completion notification
  559. OutputDebugString("Preview1 image arrived----------------------");
  560. if (m_pPreImgBuffer1 != nullptr)
  561. {
  562. delete[]m_pPreImgBuffer1;
  563. m_pPreImgBuffer1 = nullptr;
  564. OutputDebugString("delete m_pPreImgBuffer1!----------------------");
  565. }
  566. OutputDebugString("m_pPreImgBuffer1 new space----------------------");
  567. m_pPreImgBuffer1 = new WORD[m_nPreImgWidth * m_nPreImgHeight];
  568. // Receiving Preview1 image from SDK (refer Section 4.4.1 and 8.9.3 of AeroSDK Library Manual)
  569. OutputDebugString("Call AerosdkGetPreviewImage----------------------");
  570. nRet = AerosdkGetPreviewImage((char*)m_strPanelType.c_str(), m_nImageNo, AEROSDK_IMAGE_PREVIEW1, m_nPreImgWidth, m_nPreImgHeight, m_pPreImgBuffer1);
  571. if (TestError(nRet, "AerosdkGetPreviewImage"))
  572. {
  573. OutputDebugString("AerosdkGetPreviewImage PREVIEW1 Failure!----------------------");
  574. break;
  575. }
  576. //把图保存到本地
  577. SaveRawFunc(m_pPreImgBuffer1,"C:\\Konica\\Image\\preview1.raw", m_nPreImgWidth, m_nPreImgHeight);
  578. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DONE_PREVIEW1, 300, uintParam, m_pPreImgBuffer1, m_nPreImgWidth * m_nPreImgHeight *2);
  579. break;
  580. case AEROSDK_CBTYPE_PANEL_DONE_PREVIEW2:
  581. // Preview2 image receiving completion notification
  582. OutputDebugString("Preview2 image arrived----------------------");
  583. if (m_pPreImgBuffer2 != nullptr)
  584. {
  585. delete[]m_pPreImgBuffer2;
  586. m_pPreImgBuffer2 = nullptr;
  587. OutputDebugString("delete m_pPreImgBuffer2!----------------------");
  588. }
  589. OutputDebugString("m_pPreImgBuffer2 new space----------------------");
  590. m_pPreImgBuffer2 = new WORD[m_nPreImgWidth * m_nPreImgHeight];
  591. OutputDebugString("Call AerosdkGetPreviewImage----------------------");
  592. nRet = AerosdkGetPreviewImage((char*)m_strPanelType.c_str(), m_nImageNo, AEROSDK_IMAGE_PREVIEW2, m_nPreImgWidth, m_nPreImgHeight, m_pPreImgBuffer2);
  593. if (TestError(nRet, "AerosdkGetPreviewImage"))
  594. {
  595. OutputDebugString("AerosdkGetPreviewImage PREVIEW2 Failure!----------------------");
  596. break;
  597. }
  598. //SaveRawFunc(m_pPreImgBuffer2, "C:\\Konica\\Image\\preview2.raw", m_nPreImgWidth, m_nPreImgHeight);
  599. //WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DONE_PREVIEW2, 300 + 2 * 1024 * 1024, uintParam, m_pPreImgBuffer2, m_nPreImgWidth * m_nPreImgHeight * 2);
  600. break;
  601. case AEROSDK_CBTYPE_PANEL_DONE_IMAGE:
  602. // Final image receiving completion notification
  603. OutputDebugString("Final image arrived----------------------");
  604. if (m_pRawImgBuffer != nullptr)
  605. {
  606. delete[]m_pRawImgBuffer;
  607. m_pRawImgBuffer = nullptr;
  608. OutputDebugString("delete m_pRawImgBuffer!----------------------");
  609. }
  610. m_pRawImgBuffer = new WORD[m_nRawImgWidth * m_nRawImgHeight];
  611. OutputDebugString("m_pRawImgBuffer new space----------------------");
  612. // Receiving final image from SDK (refer Section 4.4.1 and 8.9.4 of AeroSDK Library Manual)
  613. OutputDebugString("Call API_AerosdkGetImage----------------------");
  614. nRet = AerosdkGetImage((char*)m_strPanelType.c_str(), m_nImageNo, m_nRawImgWidth, m_nRawImgHeight, m_pRawImgBuffer);
  615. if (TestError(nRet, "API_AerosdkGetImage"))
  616. {
  617. OutputDebugString("Get final image Failure!----------------------");
  618. break;
  619. }
  620. SaveRawFunc(m_pRawImgBuffer, "C:\\Konica\\Image\\FinalImage.raw", m_nRawImgWidth, m_nRawImgHeight);
  621. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DONE_IMAGE, 300 + 4 * 1024 * 1024, uintParam, m_pRawImgBuffer, m_nRawImgWidth * m_nRawImgHeight * 2);
  622. break;
  623. case AEROSDK_CBTYPE_PANEL_ERROR_IMAGETRANSFER:
  624. // Image transfer error
  625. OutputDebugString("Image transfer error notification----------------------");
  626. if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
  627. {
  628. // set image transfer error
  629. //g_intImageTransferError = uintParam;
  630. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_ERROR_IMAGETRANSFER, 48, uintParam, nullptr, 0);
  631. }
  632. break;
  633. case AEROSDK_CBTYPE_PANEL_DONE_RETRANSFER:
  634. // Image resending completion notification
  635. OutputDebugString("Image resending completion notification----------------------");
  636. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DONE_RETRANSFER, 52, uintParam, nullptr, 0);
  637. break;
  638. case AEROSDK_CBTYPE_PANEL_UPDATE_STATUS:
  639. // Panel firmware update status notification
  640. OutputDebugString("Panel firmware update status notification----------------------");
  641. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_UPDATE_STATUS, 56, uintParam, nullptr, 0);
  642. break;
  643. case AEROSDK_CBTYPE_PANEL_DONE_UPDATE:
  644. OutputDebugString("Panel firmware update success----------------------");
  645. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DONE_UPDATE, 60, uintParam, nullptr, 0);
  646. break;
  647. case AEROSDK_CBTYPE_PANEL_UPDATE_ERROR:
  648. // Panel firmware update error notification
  649. OutputDebugString("Panel firmware update error notification----------------------");
  650. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_UPDATE_ERROR, 64, uintParam, nullptr, 0);
  651. break;
  652. case AEROSDK_CBTYPE_PANEL_GAINCALIB_RESULT:
  653. // Gain calibration result notification
  654. OutputDebugString("Gain calibration result notification----------------------");
  655. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_GAINCALIB_RESULT, 68, uintParam, nullptr, 0);
  656. break;
  657. case AEROSDK_CBTYPE_PANEL_DARKCALIB_PASSAGE:
  658. // Dark calibration progress notification
  659. OutputDebugString("Dark calibration progress notification----------------------");
  660. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DARKCALIB_PASSAGE, 72, uintParam, nullptr, 0);
  661. break;
  662. case AEROSDK_CBTYPE_PANEL_DARKCALIB_RESULT:
  663. // Dark calibration result notification
  664. OutputDebugString("Dark calibration result notification----------------------");
  665. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DARKCALIB_RESULT, 76, uintParam, nullptr, 0);
  666. break;
  667. case AEROSDK_CBTYPE_PANEL_OPEN_ERROR:
  668. // Panel open error after retry
  669. OutputDebugString("Panel open fail!----------------------");
  670. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_OPEN_ERROR, 80, uintParam, nullptr, 0);
  671. break;
  672. case AEROSDK_CBTYPE_PANEL_DETECT_ERROR:
  673. // Panel error detection
  674. OutputDebugString("Panel error detection----------------------");
  675. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DETECT_ERROR, 84, uintParam, nullptr, 0);
  676. break;
  677. case AEROSDK_CBTYPE_PANEL_ERROR_CANCELED:
  678. // Panel error cancellation
  679. OutputDebugString("Panel error cancellation----------------------");
  680. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_ERROR_CANCELED, 88, uintParam, nullptr, 0);
  681. break;
  682. case AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_IMAGE:
  683. OutputDebugString("AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_IMAGE----------------------");
  684. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_IMAGE, 92, uintParam, nullptr, 0);
  685. break;
  686. case AEROSDK_CBTYPE_PANEL_DYNAMIC_IMAGE_FRAMECOUNT:
  687. OutputDebugString("AEROSDK_CBTYPE_PANEL_DYNAMIC_IMAGE_FRAMECOUNT----------------------");
  688. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DYNAMIC_IMAGE_FRAMECOUNT, 96, uintParam, nullptr, 0);
  689. break;
  690. case AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_RETRANSFER:
  691. OutputDebugString("AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_RETRANSFER----------------------");
  692. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_DONE_DYNAMIC_RETRANSFER, 100, uintParam, nullptr, 0);
  693. break;
  694. case AEROSDK_CBTYPE_XGBOX_CONNECTTED:
  695. // AeroSDK - XG-IFBOX connection detection; In AeroSync Mode, this callback does not happen.
  696. OutputDebugString("XgBox connect notification----------------------");
  697. if (m_nXgboxNo == nXgboxNo)
  698. {
  699. m_bConnectXgbox = true;
  700. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_CONNECTTED, 104, m_nXgboxNo, nullptr, 0);
  701. }
  702. break;
  703. case AEROSDK_CBTYPE_XGBOX_DISCONNECT:
  704. // AeroSDK - XG-IFBOX disconnection detection; In AeroSync Mode, this callback does not happen.
  705. OutputDebugString("XgBox disconnect notification----------------------");
  706. if (m_nXgboxNo == nXgboxNo)
  707. {
  708. m_bConnectXgbox = false;
  709. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_DISCONNECT, 108, m_nXgboxNo, nullptr, 0);
  710. }
  711. break;
  712. case AEROSDK_CBTYPE_XGBOX_PREPARE_ON:
  713. // Prepare Signal On Detection; In AeroSync Mode, this callback does not happen.
  714. OutputDebugString("AEROSDK_CBTYPE_XGBOX_PREPARE_ON----------------------");
  715. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_PREPARE_ON, 112, nXgboxNo, nullptr, 0);
  716. temp = "";
  717. temp = temp + "nXgboxNo:";
  718. temp = temp + std::to_string(nXgboxNo);
  719. temp = temp + "----------------------";
  720. OutputDebugString(temp.c_str());
  721. if (m_nSyncMode == SYNC_HARDWARE
  722. && m_nXgboxNo == nXgboxNo
  723. && m_nDetectorStatus == AEROSDK_PANEL_STATUS_READY
  724. && m_bConnect == true
  725. && m_bConnectXgbox == true)
  726. {
  727. OutputDebugString("Call AerosdkSetReadyBusy AEROSDK_READY----------------------");
  728. nRet = AerosdkSetReadyBusy(nXgboxNo, uintParam, m_nImageNo, AEROSDK_READY);
  729. if (TestError(nRet, "AerosdkSetReadyBusy"))
  730. {
  731. OutputDebugString("AerosdkSetReadyBusy Failure!----------------------");
  732. }
  733. }
  734. else
  735. {
  736. // This means your User Program blocks (does not allow) XG-IFBOX and generator to turn on Exposure signal.
  737. // Please refer Section 3.4.1 and 8.4.3 of AeroSDK Library Manual.
  738. OutputDebugString("Call AerosdkSetReadyBusy AEROSDK_BUSY----------------------");
  739. nRet = AerosdkSetReadyBusy(nXgboxNo, uintParam, 0, AEROSDK_BUSY);
  740. if (TestError(nRet, "AerosdkSetReadyBusy"))
  741. {
  742. OutputDebugString("AerosdkSetReadyBusy Failure!----------------------");
  743. }
  744. }
  745. break;
  746. case AEROSDK_CBTYPE_XGBOX_EXPOSURE_ON:
  747. // Exposure Signal On Detection; In AeroSync Mode, this callback does not happen.
  748. OutputDebugString("AEROSDK_CBTYPE_XGBOX_EXPOSURE_ON----------------------");
  749. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_EXPOSURE_ON, 116, nXgboxNo, nullptr, 0);
  750. break;
  751. case AEROSDK_CBTYPE_XGBOX_KMREADY_ON:
  752. // KM_Ready Signal On Detection; In AeroSync Mode, this callback does not happen.
  753. OutputDebugString("AEROSDK_CBTYPE_XGBOX_KMREADY_ON----------------------");
  754. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_KMREADY_ON, 120, nXgboxNo, nullptr, 0);
  755. break;
  756. case AEROSDK_CBTYPE_XGBOX_KMREADY_OFF:
  757. // KM_Ready Signal Off Detection; In AeroSync Mode, this callback does not happen.
  758. OutputDebugString("AEROSDK_CBTYPE_XGBOX_KMREADY_OFF----------------------");
  759. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_KMREADY_OFF, 124, nXgboxNo, nullptr, 0);
  760. break;
  761. case AEROSDK_CBTYPE_XGBOX_EXPOSURE_OFF:
  762. // Exposure Signal Off Detection; In AeroSync Mode, this callback does not happen.
  763. OutputDebugString("AEROSDK_CBTYPE_XGBOX_EXPOSURE_OFF----------------------");
  764. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_EXPOSURE_OFF, 128, nXgboxNo, nullptr, 0);
  765. break;
  766. case AEROSDK_CBTYPE_XGBOX_PREPARE_OFF:
  767. // Prepare Signal Off Detection; In AeroSync Mode, this callback does not happen.
  768. OutputDebugString("AEROSDK_CBTYPE_XGBOX_PREPARE_OFF----------------------");
  769. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_PREPARE_OFF, 132, nXgboxNo, nullptr, 0);
  770. break;
  771. case AEROSDK_CBTYPE_XGBOX_EXPOSUREON_TIMEOUT:
  772. // Exposure switch pressed down timeout; In AeroSync Mode, this callback does not happen.
  773. OutputDebugString("AEROSDK_CBTYPE_XGBOX_EXPOSUREON_TIMEOUT----------------------");
  774. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_EXPOSUREON_TIMEOUT, 136, nXgboxNo, nullptr, 0);
  775. break;
  776. case AEROSDK_CBTYPE_XGBOX_ILLEGAL_SWITCH_SEQUENCE:
  777. // Switch sequence interruption; In AeroSync Mode, this callback does not happen.
  778. OutputDebugString("AEROSDK_CBTYPE_XGBOX_ILLEGAL_SWITCH_SEQUENCE----------------------");
  779. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_ILLEGAL_SWITCH_SEQUENCE, 140, nXgboxNo, nullptr, 0);
  780. break;
  781. case AEROSDK_CBTYPE_XGBOX_UPDATE_STATUS:
  782. // XG-IFBOX firmware update status notification; In AeroSync Mode, this callback does not happen.
  783. OutputDebugString("AEROSDK_CBTYPE_XGBOX_UPDATE_STATUS----------------------");
  784. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_UPDATE_STATUS, 144, nXgboxNo, nullptr, 0);
  785. break;
  786. case AEROSDK_CBTYPE_XGBOX_DONE_UPDATE:
  787. // XG-IFBOX firmware update completion notification; In AeroSync Mode, this callback does not happen.
  788. OutputDebugString("AEROSDK_CBTYPE_XGBOX_DONE_UPDATE----------------------");
  789. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_DONE_UPDATE, 148, nXgboxNo, nullptr, 0);
  790. break;
  791. case AEROSDK_CBTYPE_XGBOX_UPDATE_ERROR:
  792. // XG-IFBOX firmware update error notification; In AeroSync Mode, this callback does not happen.
  793. OutputDebugString("AEROSDK_CBTYPE_XGBOX_UPDATE_ERROR----------------------");
  794. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_UPDATE_ERROR, 152, nXgboxNo, nullptr, 0);
  795. break;
  796. case AEROSDK_CBTYPE_XGBOX_OPEN_ERROR:
  797. // XG-IFBOX open error; In AeroSync Mode, this callback does not happen.
  798. OutputDebugString("AEROSDK_CBTYPE_XGBOX_OPEN_ERROR----------------------");
  799. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_OPEN_ERROR, 156, nXgboxNo, nullptr, 0);
  800. break;
  801. case AEROSDK_CBTYPE_XGBOX_DETECT_ERROR:
  802. // XG-IFBOX error detection; In AeroSync Mode, this callback does not happen.
  803. OutputDebugString("AEROSDK_CBTYPE_XGBOX_DETECT_ERROR----------------------");
  804. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_DETECT_ERROR, 160, nXgboxNo, nullptr, 0);
  805. break;
  806. case AEROSDK_CBTYPE_XGBOX_ERROR_CANCELED:
  807. // XG-IFBOX error cancellation; In AeroSync Mode, this callback does not happen.
  808. OutputDebugString("AEROSDK_CBTYPE_XGBOX_ERROR_CANCELED----------------------");
  809. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_XGBOX_ERROR_CANCELED, 164, nXgboxNo, nullptr, 0);
  810. break;
  811. case AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRE:
  812. // Panel -- XG-IFBOX connection is detected (in wired mode) after it was disconnected.
  813. OutputDebugString("AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRE----------------------");
  814. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRE, 168, nXgboxNo, nullptr, 0);
  815. break;
  816. case AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRELESS:
  817. // Panel -- XG-IFBOX connection is detected (in wireless mode) after it was disconnected.
  818. OutputDebugString("AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRELESS----------------------");
  819. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_XGBOX_CONNECTED_WIRELESS, 172, nXgboxNo, nullptr, 0);
  820. break;
  821. case AEROSDK_CBTYPE_PANEL_XGBOX_DISCONNECT:
  822. // Panel -- XG-IFBOX is disconnected.
  823. OutputDebugString("AEROSDK_CBTYPE_PANEL_XGBOX_DISCONNECT----------------------");
  824. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_XGBOX_DISCONNECT, 176, nXgboxNo, nullptr, 0);
  825. break;
  826. case AEROSDK_CBTYPE_PANEL_WARNING_DO_CALIBRATION:
  827. // Warning to let User Program prompt end-users to make calibration of Panel
  828. OutputDebugString("AEROSDK_CBTYPE_PANEL_WARNING_DO_CALIBRATION----------------------");
  829. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_PANEL_WARNING_DO_CALIBRATION, 180, uintParam, nullptr, 0);
  830. break;
  831. case AEROSDK_CBTYPE_END_EXPOSURE_SEQUENCE:
  832. // Exposure sequence end notification
  833. OutputDebugString("Exposure sequence end notification----------------------");
  834. if (strcmp(m_strPanelType.c_str(), pstrPanelId) == 0)
  835. {
  836. // Append callback queue
  837. // These need much processing time, so the code should be written at outside of AeroSDKCallBack().
  838. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_EXPOSURE_SEQUENCE, 184, uintParam, nullptr, 0);
  839. }
  840. break;
  841. case AEROSDK_CBTYPE_END_IMAGERESENDING_SEQUENCE:
  842. // Image resending sequence end notification
  843. OutputDebugString("Image resending sequence end notification----------------------");
  844. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_IMAGERESENDING_SEQUENCE, 188, uintParam, nullptr, 0);
  845. if (m_bHaveImageInDetector)
  846. {
  847. m_bHaveImageInDetector = false;
  848. StopWaiting("ImageResendingSequence");
  849. }
  850. break;
  851. case AEROSDK_CBTYPE_END_DELETEIMAGE_SEQUENCE:
  852. // Image discarding sequence end notification
  853. OutputDebugString("Image discarding sequence end notification----------------------");
  854. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_DELETEIMAGE_SEQUENCE, 192, uintParam, nullptr, 0);
  855. if (m_bHaveImageInDetector)
  856. {
  857. m_bHaveImageInDetector = false;
  858. StopWaiting("ImageDeleteSequence");
  859. }
  860. break;
  861. case AEROSDK_CBTYPE_END_PANEL_UPDATE_SEQUENCE:
  862. // Panel firmware update sequence end notification
  863. OutputDebugString("Panel firmware update sequence end notification----------------------");
  864. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_PANEL_UPDATE_SEQUENCE, 196, uintParam, nullptr, 0);
  865. break;
  866. case AEROSDK_CBTYPE_END_XGBOX_UPDATE_SEQUENCE:
  867. // XG-IFBOX firmware update sequence end notification; In AeroSync Mode, this callback does not happen.
  868. OutputDebugString("AEROSDK_CBTYPE_END_XGBOX_UPDATE_SEQUENCE----------------------");
  869. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_XGBOX_UPDATE_SEQUENCE, 200, nXgboxNo, nullptr, 0);
  870. break;
  871. case AEROSDK_CBTYPE_END_PANEL_GAINCALIB_SEQUENCE:
  872. // Gain calibration sequence end notification
  873. OutputDebugString("Gain calibration sequence end notification----------------------");
  874. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_PANEL_GAINCALIB_SEQUENCE, 204, uintParam, nullptr, 0);
  875. break;
  876. case AEROSDK_CBTYPE_END_PANEL_DARKCALIB_SEQUENCE:
  877. // Dark calibration sequence end notification
  878. OutputDebugString("Dark calibration sequence end notification----------------------");
  879. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_PANEL_DARKCALIB_SEQUENCE, 208, uintParam, nullptr, 0);
  880. break;
  881. case AEROSDK_CBTYPE_END_UNSHOTIMAGE_SEQUENCE:
  882. OutputDebugString("AEROSDK_CBTYPE_END_UNSHOTIMAGE_SEQUENCE----------------------");
  883. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_UNSHOTIMAGE_SEQUENCE, 212, uintParam, nullptr, 0);
  884. break;
  885. case AEROSDK_CBTYPE_END_DYNAMIC_EXPOSURE_SEQUENCE:
  886. OutputDebugString("AEROSDK_CBTYPE_END_DYNAMIC_EXPOSURE_SEQUENCE----------------------");
  887. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_DYNAMIC_EXPOSURE_SEQUENCE, 216, uintParam, nullptr, 0);
  888. break;
  889. case AEROSDK_CBTYPE_END_DYNAMIC_IMAGERESENDING_SEQUENCE:
  890. OutputDebugString("AEROSDK_CBTYPE_END_DYNAMIC_IMAGERESENDING_SEQUENCE----------------------");
  891. WriteNotifyMessageToShareMemory(AEROSDK_CBTYPE_END_DYNAMIC_IMAGERESENDING_SEQUENCE, 220, uintParam, nullptr, 0);
  892. break;
  893. default:
  894. temp = "CallBackEvent default type:";
  895. temp = temp + std::to_string(nType);
  896. temp = temp + "----------------------";
  897. OutputDebugString(temp.c_str());
  898. WriteNotifyMessageToShareMemory(nType, 224, uintParam, nullptr, 0);
  899. break;
  900. }
  901. }
  902. /***
  903. ** 检测接口是否有错误,true:有错;false:没错
  904. ***/
  905. bool CKonicaObject2::TestError(int nRet, const char* szFuncName, bool bShowTrue)
  906. {
  907. char temp[1024] = { 0 };
  908. if (nRet == AEROSDK_OK)
  909. {
  910. if (bShowTrue)
  911. {
  912. sprintf(temp, "%s executed successfully----------------------", szFuncName);
  913. OutputDebugString(temp);
  914. }
  915. return false;
  916. }
  917. else
  918. {
  919. char strPanelErrorInfo[16] = { 0 };
  920. char strXgboxErrorInfo[16] = { 0 };
  921. AerosdkGetPanelLastError((char*)m_strPanelType.c_str(), strPanelErrorInfo);
  922. AerosdkGetXgboxLastError(m_nXgboxNo, strXgboxErrorInfo);
  923. sprintf(temp,"{%s} return error, error code:{%d}, panel error info:{%s}, xgbox error info:{%s}----------------------",
  924. szFuncName, nRet, strPanelErrorInfo, strXgboxErrorInfo);
  925. OutputDebugString(temp);
  926. return true;
  927. }
  928. }
  929. STDMETHODIMP CKonicaObject2::OpenSdk()
  930. {
  931. OutputDebugString("OpenSdk----------------------");
  932. if (!m_bOpenSdk)
  933. {
  934. int nRet = AerosdkOpen(AeroSDKCallBack, strAeroSDKini, AEROSDK_ON, &m_stLogInfo);
  935. if (nRet == AEROSDK_ERROR_OPEN_ALREADY)
  936. {
  937. m_bOpenSdk = true;
  938. return S_OK;
  939. }
  940. if (TestError(nRet, "API_AerosdkOpen"))
  941. {
  942. return S_FALSE;
  943. }
  944. else
  945. {
  946. m_bOpenSdk = true;
  947. }
  948. }
  949. return S_OK;
  950. }
  951. STDMETHODIMP CKonicaObject2::OpenPanel()
  952. {
  953. OutputDebugString("OpenPanel----------------------");
  954. if (!m_bConnect)
  955. {
  956. int nRet = AerosdkOpenPanel((char*)m_strPanelType.c_str(), NULL, NULL, strPanelLog, NULL);
  957. if (nRet == AEROSDK_ERROR_PANEL_OPEN_ALREADY)
  958. {
  959. m_bConnect = true;
  960. return S_OK;
  961. }
  962. if (TestError(nRet, "API_AerosdkOpenPanel"))
  963. {
  964. return S_FALSE;
  965. }
  966. }
  967. return S_OK;
  968. }
  969. STDMETHODIMP CKonicaObject2::OpenXgBox(int nXgBoxNo)
  970. {
  971. OutputDebugString("OpenXgBox----------------------");
  972. m_nXgboxNo = nXgBoxNo;
  973. /*if (!m_bConnectXgbox)
  974. {*/
  975. int nRet = AerosdkOpenXgbox(m_nXgboxNo, NULL, strECBLog, strXGBOXLog, NULL);
  976. if (nRet == AEROSDK_ERROR_XGBOX_DOUBLE_OPEN)
  977. {
  978. OutputDebugString("Xgbox double open----------------------");
  979. m_bConnectXgbox = true;
  980. return S_OK;
  981. }
  982. else if (nRet == AEROSDK_WARN_RETRY)
  983. {
  984. //SDK retrying connection
  985. OutputDebugString("SDK Retrying Open Xgbox----------------------");
  986. }
  987. else
  988. {
  989. if (TestError(nRet, "API_AerosdkOpenXgbox"))
  990. {
  991. return S_FALSE;
  992. }
  993. }
  994. //}
  995. return S_OK;
  996. }
  997. STDMETHODIMP CKonicaObject2::CloseSdk()
  998. {
  999. OutputDebugString("CloseSdk----------------------");
  1000. int nRet = AerosdkClose(AEROSDK_OFF, AEROSDK_OFF);
  1001. if (TestError(nRet, "API_AerosdkClose"))
  1002. {
  1003. return S_FALSE;
  1004. }
  1005. return S_OK;
  1006. }
  1007. STDMETHODIMP CKonicaObject2::ClosePanel()
  1008. {
  1009. OutputDebugString("ClosePanel----------------------");
  1010. int nRet = AerosdkClosePanel((char*)m_strPanelType.c_str());
  1011. if (TestError(nRet, "API_AerosdkClosePanel"))
  1012. {
  1013. return S_FALSE;
  1014. }
  1015. return S_OK;
  1016. }
  1017. STDMETHODIMP CKonicaObject2::CloseXgBox()
  1018. {
  1019. OutputDebugString("CloseXgBox----------------------");
  1020. int nRet = AerosdkCloseXgbox(m_nXgboxNo);
  1021. if (TestError(nRet, "API_AerosdkCloseXgbox"))
  1022. {
  1023. return S_FALSE;
  1024. }
  1025. return S_OK;
  1026. }
  1027. //设置当前探测器使用的分辨率
  1028. STDMETHODIMP CKonicaObject2::SetPanelResolution(int nResolution)
  1029. {
  1030. m_nResolution = nResolution;
  1031. char temp[512] = { 0 };
  1032. sprintf(temp, "SetPanelResolution nResolution:%d----------------------", nResolution);
  1033. OutputDebugString(temp);
  1034. /*int nRet = AerosdkSetPanelResolution((char*)m_strPanelType.c_str(), m_nResolution);
  1035. if (TestError(nRet, "AerosdkSetPanelResolution"))
  1036. {
  1037. return S_FALSE;
  1038. }*/
  1039. return S_OK;
  1040. }
  1041. //主要用于区分是否支持正常分辨率和高分辨率,并不是当前探测器使用的分辨率
  1042. STDMETHODIMP CKonicaObject2::GetPanelResolution(int* pResolution)
  1043. {
  1044. OutputDebugString("GetPanelResolution----------------------");
  1045. int nRet = AerosdkGetPanelResolutionInfo((char*)m_strPanelType.c_str(), pResolution);
  1046. if (TestError(nRet, "AerosdkGetPanelResolutionInfo"))
  1047. {
  1048. return S_FALSE;
  1049. }
  1050. char temp[512] = { 0 };
  1051. sprintf(temp,"GetPanelResolution resolution:%d----------------------",*pResolution);
  1052. OutputDebugString(temp);
  1053. return S_OK;
  1054. }
  1055. STDMETHODIMP CKonicaObject2::GetImageSize(int nSizeMode, int nResolution, int* pWidth, int* pHeight)
  1056. {
  1057. OutputDebugString("GetImageSize----------------------");
  1058. char temp[512] = { 0 };
  1059. int nRet = AerosdkGetImageSizeEx((char*)m_strPanelType.c_str(), nSizeMode, nResolution, pWidth, pHeight);
  1060. if (TestError(nRet, "API_AerosdkGetImageSizeEx"))
  1061. {
  1062. return S_FALSE;
  1063. }
  1064. if (AEROSDK_IMAGE_PREVIEW == nSizeMode)
  1065. {
  1066. m_nPreImgWidth = *pWidth;
  1067. m_nPreImgHeight = *pHeight;
  1068. sprintf(temp, "m_nPreImgWidth:%d,m_nPreImgHeight:%d----------------------", m_nPreImgWidth, m_nPreImgHeight);
  1069. OutputDebugString(temp);
  1070. }
  1071. else if (AEROSDK_IMAGE_EXPOSURE == nSizeMode)
  1072. {
  1073. m_nRawImgWidth = *pWidth;
  1074. m_nRawImgHeight = *pHeight;
  1075. sprintf(temp, "m_nRawImgWidth:%d,m_nRawImgHeight:%d----------------------", m_nRawImgWidth, m_nRawImgHeight);
  1076. OutputDebugString(temp);
  1077. }
  1078. else
  1079. {
  1080. return S_FALSE;
  1081. }
  1082. return S_OK;
  1083. }
  1084. STDMETHODIMP CKonicaObject2::GetPanelSettingInfo(CHAR* strPanelID, int* nPanelSize)
  1085. {
  1086. OutputDebugString("GetPanelSettingInfo----------------------");
  1087. StAerosdkPanelSettingInfo settingInfo;
  1088. int nRet = AerosdkGetPanelSettingInfo((char*)m_strPanelType.c_str(), &settingInfo);
  1089. if (TestError(nRet, "API_AerosdkGetPanelSettingInfo"))
  1090. {
  1091. return S_FALSE;
  1092. }
  1093. memcpy(strPanelID, settingInfo.strPanelId, sizeof(settingInfo.strPanelId));
  1094. *nPanelSize = settingInfo.intPanelSize;
  1095. char temp[512] = { 0 };
  1096. sprintf(temp, "strPanelID:%s,nPanelSize:%d----------------------", strPanelID, *nPanelSize);
  1097. OutputDebugString(temp);
  1098. return S_OK;
  1099. }
  1100. STDMETHODIMP CKonicaObject2::GetPanelVersionInfo(unsigned char* pDllVersion, unsigned char* pAllVersion, unsigned char* pFwComnBootVersion, unsigned char* pFwComnVersion, unsigned char* pFwPowerBootVersion, unsigned char* pFwPowerVersion, unsigned char* pFpgaVersion)
  1101. {
  1102. OutputDebugString("GetPanelVersionInfo----------------------");
  1103. StAerosdkPanelVersionInfo versionInfo;
  1104. int nRet = AerosdkGetPanelVersionInfo((char*)m_strPanelType.c_str(), &versionInfo);
  1105. if (TestError(nRet, "API_AerosdkGetPanelVersionInfo"))
  1106. {
  1107. return S_FALSE;
  1108. }
  1109. memcpy(pDllVersion, versionInfo.ucharDllVersion, sizeof(versionInfo.ucharDllVersion));
  1110. memcpy(pAllVersion, versionInfo.ucharAllVersion, sizeof(versionInfo.ucharAllVersion));
  1111. memcpy(pFwComnBootVersion, versionInfo.ucharFwComnBootVersion, sizeof(versionInfo.ucharFwComnBootVersion));
  1112. memcpy(pFwComnVersion, versionInfo.ucharFwComnVersion, sizeof(versionInfo.ucharFwComnVersion));
  1113. memcpy(pFwPowerBootVersion, versionInfo.ucharFwPowerBootVersion, sizeof(versionInfo.ucharFwPowerBootVersion));
  1114. memcpy(pFwPowerVersion, versionInfo.ucharFwPowerVersion, sizeof(versionInfo.ucharFwPowerVersion));
  1115. memcpy(pFpgaVersion, versionInfo.ucharFpgaVersion, sizeof(versionInfo.ucharFpgaVersion));
  1116. return S_OK;
  1117. }
  1118. STDMETHODIMP CKonicaObject2::GetPanelConservationInfo(unsigned int* pShootCount)
  1119. {
  1120. OutputDebugString("GetPanelConservationInfo----------------------");
  1121. int nRet = AerosdkGetPanelConservationInfo((char*)m_strPanelType.c_str(), pShootCount);
  1122. if (TestError(nRet, "API_AerosdkGetPanelConservationInfo"))
  1123. {
  1124. return S_FALSE;
  1125. }
  1126. char temp[512] = { 0 };
  1127. sprintf(temp, "nShootCount:%d----------------------", *pShootCount);
  1128. OutputDebugString(temp);
  1129. return S_OK;
  1130. }
  1131. STDMETHODIMP CKonicaObject2::GetCradleConservationInfo(int* pConnectCount)
  1132. {
  1133. OutputDebugString("GetCradleConservationInfo----------------------");
  1134. int nRet = AerosdkGetCradleConservationInfo((char*)m_strPanelType.c_str(), pConnectCount);
  1135. if (TestError(nRet, "API_AerosdkGetCradleConservationInfo"))
  1136. {
  1137. return S_FALSE;
  1138. }
  1139. char temp[512] = { 0 };
  1140. sprintf(temp, "nConnectCount:%d----------------------", *pConnectCount);
  1141. OutputDebugString(temp);
  1142. return S_OK;
  1143. }
  1144. STDMETHODIMP CKonicaObject2::StartExposureSequenceIt(int nXgBoxNo, int nImageNo, int nSyncMode, int nIntegrationTime)
  1145. {
  1146. OutputDebugString("StartExposureSequenceIt----------------------");
  1147. m_nImageNo = nImageNo;
  1148. char temp[512] = { 0 };
  1149. sprintf(temp, "StartExposureSequenceIt nXgBoxNo:%d,nImageNo:%d,nSyncMode:%d,nIntegrationTime:%d----------------------", nXgBoxNo, nImageNo, nSyncMode, nIntegrationTime);
  1150. OutputDebugString(temp);
  1151. int nRet = AEROSDK_OK;
  1152. memset(temp, 0, sizeof(temp));
  1153. sprintf(temp, "StartExposureSequenceIt m_nResolution:%d----------------------", m_nResolution);
  1154. OutputDebugString(temp);
  1155. //开始采集前设置分辨率
  1156. OutputDebugString("Call AerosdkSetPanelResolution----------------------");
  1157. nRet = AerosdkSetPanelResolution((char*)m_strPanelType.c_str(), m_nResolution);
  1158. if (TestError(nRet, "AerosdkSetPanelResolution"))
  1159. {
  1160. return S_FALSE;
  1161. }
  1162. if (nSyncMode == AEROSDK_COOPERATION_SRM)//硬同步
  1163. {
  1164. StAerosdkXgboxStatusInfo xgboxStatusInfo;
  1165. nRet = AerosdkGetXgboxStatusInfo(nXgBoxNo,1,&xgboxStatusInfo);
  1166. if (TestError(nRet, "AerosdkGetXgboxStatusInfo"))
  1167. {
  1168. memset(temp, 0, sizeof(temp));
  1169. sprintf(temp, "GetXgboxStatusInfo return error code:%d----------------------", nRet);
  1170. OutputDebugString(temp);
  1171. }
  1172. else
  1173. {
  1174. if (xgboxStatusInfo.intCrMode == AEROSDK_ON)
  1175. {
  1176. OutputDebugString("Xgbox is CR mode----------------------");
  1177. }
  1178. else
  1179. {
  1180. OutputDebugString("Xgbox is DR mode----------------------");
  1181. }
  1182. }
  1183. }
  1184. nRet = AerosdkStartExposureSequenceIt((char*)m_strPanelType.c_str(), nXgBoxNo, nImageNo, nSyncMode, nIntegrationTime, AEROSDK_MOVEMODE_NORMAL);
  1185. if (TestError(nRet, "AerosdkStartExposureSequenceIt"))
  1186. {
  1187. memset(temp, 0, sizeof(temp));
  1188. sprintf(temp,"StartExposureSequenceIt return error code:%d----------------------",nRet);
  1189. OutputDebugString(temp);
  1190. return S_FALSE;
  1191. }
  1192. return S_OK;
  1193. }
  1194. string CKonicaObject2::GetStrPanelStatus(int nPanelStatus)
  1195. {
  1196. string temp = "";
  1197. switch (nPanelStatus)
  1198. {
  1199. case AEROSDK_PANEL_STATUS_INITIALIZE:
  1200. temp = "AEROSDK_PANEL_STATUS_INITIALIZE";
  1201. break;
  1202. case AEROSDK_PANEL_STATUS_SLEEP:
  1203. temp = "AEROSDK_PANEL_STATUS_SLEEP";
  1204. break;
  1205. case AEROSDK_PANEL_STATUS_STANDBY:
  1206. temp = "AEROSDK_PANEL_STATUS_STANDBY";
  1207. break;
  1208. case AEROSDK_PANEL_STATUS_READY:
  1209. temp = "AEROSDK_PANEL_STATUS_READY";
  1210. break;
  1211. case AEROSDK_PANEL_STATUS_EXPOSURE:
  1212. temp = "AEROSDK_PANEL_STATUS_EXPOSURE";
  1213. break;
  1214. case AEROSDK_PANEL_STATUS_SHUTDOWN:
  1215. temp = "AEROSDK_PANEL_STATUS_SHUTDOWN";
  1216. break;
  1217. case AEROSDK_PANEL_STATUS_UPDATE:
  1218. temp = "AEROSDK_PANEL_STATUS_UPDATE";
  1219. break;
  1220. case AEROSDK_PANEL_STATUS_MAINTENANCE:
  1221. temp = "AEROSDK_PANEL_STATUS_MAINTENANCE";
  1222. break;
  1223. case AEROSDK_PANEL_STATUS_WAIT_READY:
  1224. temp = "AEROSDK_PANEL_STATUS_WAIT_READY";
  1225. break;
  1226. case AEROSDK_PANEL_STATUS_READOUT:
  1227. temp = "AEROSDK_PANEL_STATUS_READOUT";
  1228. break;
  1229. case AEROSDK_PANEL_STATUS_ERROR:
  1230. temp = "AEROSDK_PANEL_STATUS_ERROR";
  1231. break;
  1232. case AEROSDK_PANEL_STATUS_UNKNOWN:
  1233. temp = "AEROSDK_PANEL_STATUS_UNKNOWN";
  1234. break;
  1235. }
  1236. return temp;
  1237. }
  1238. STDMETHODIMP CKonicaObject2::GetPanelStatusInfo(int* pPanelStatus)
  1239. {
  1240. OutputDebugString("GetPanelStatusInfo----------------------");
  1241. int nRet = AerosdkGetPanelStatusInfo((char*)m_strPanelType.c_str(), pPanelStatus);
  1242. if (TestError(nRet, "AerosdkGetPanelStatusInfo"))
  1243. {
  1244. return S_FALSE;
  1245. }
  1246. int nPanelStatus = *pPanelStatus;
  1247. string strPanelStatus = GetStrPanelStatus(nPanelStatus);
  1248. char temp[512] = { 0 };
  1249. sprintf(temp, "PanelStatus:%s----------------------", strPanelStatus.c_str());
  1250. OutputDebugString(temp);
  1251. return S_OK;
  1252. }
  1253. STDMETHODIMP CKonicaObject2::CancelExposureSequence(int nImageNo)
  1254. {
  1255. OutputDebugString("CancelExposureSequence----------------------");
  1256. char temp[512] = { 0 };
  1257. sprintf(temp, "nImageNo:%d----------------------", nImageNo);
  1258. OutputDebugString(temp);
  1259. int nRet = AerosdkCancelExposureSequence((char*)m_strPanelType.c_str(), nImageNo);
  1260. if (TestError(nRet, "API_AerosdkCancelExposureSequence"))
  1261. {
  1262. return S_FALSE;
  1263. }
  1264. return S_OK;
  1265. }
  1266. STDMETHODIMP CKonicaObject2::SetSyncMode(int nSyncMode)
  1267. {
  1268. OutputDebugString("SetSyncMode----------------------");
  1269. m_nSyncMode = nSyncMode;
  1270. char temp[512] = { 0 };
  1271. sprintf(temp, "m_nSyncMode:%d----------------------", m_nSyncMode);
  1272. OutputDebugString(temp);
  1273. return S_OK;
  1274. }
  1275. STDMETHODIMP CKonicaObject2::GetPanelBatteryInfo(int* pBatteryValue, int* pBatteryStatus)
  1276. {
  1277. OutputDebugString("GetPanelBatteryInfo----------------------");
  1278. int nRet = AerosdkGetPanelBatteryInfo((char*)m_strPanelType.c_str(), pBatteryValue, pBatteryStatus);
  1279. if (TestError(nRet, "API_AerosdkGetPanelBatteryInfo"))
  1280. {
  1281. return S_FALSE;
  1282. }
  1283. char temp[512] = { 0 };
  1284. sprintf(temp, "BatteryValue:%d,BatteryStatus:%d----------------------", *pBatteryValue, *pBatteryStatus);
  1285. OutputDebugString(temp);
  1286. return S_OK;
  1287. }
  1288. STDMETHODIMP CKonicaObject2::GetPanelSignalInfo(int* pSignalStrength)
  1289. {
  1290. OutputDebugString("GetPanelSignalInfo----------------------");
  1291. int nRet = AerosdkGetPanelSignalInfo((char*)m_strPanelType.c_str(), pSignalStrength);
  1292. if (TestError(nRet, "API_AerosdkGetPanelSignalInfo"))
  1293. {
  1294. return S_FALSE;
  1295. }
  1296. char temp[512] = { 0 };
  1297. sprintf(temp, "SignalStrength:%d----------------------", *pSignalStrength);
  1298. OutputDebugString(temp);
  1299. return S_OK;
  1300. }
  1301. STDMETHODIMP CKonicaObject2::GetQueueData(int* pMessageType)
  1302. {
  1303. std::lock_guard<std::mutex> lock(mtx);
  1304. if (!m_queue.empty())
  1305. {
  1306. int type = m_queue.front();
  1307. *pMessageType = type;
  1308. m_queue.pop();
  1309. return S_OK;
  1310. }
  1311. else
  1312. {
  1313. return S_FALSE;
  1314. }
  1315. }
  1316. void CKonicaObject2::SaveRawFunc(WORD* pInImg, char* strFileName, int nImgWidth, int nImgHeight)
  1317. {
  1318. FILE* fp;
  1319. std::string fileName = strFileName;
  1320. fileName = fileName + "----------------------";
  1321. OutputDebugString(fileName.c_str());
  1322. if ((fp = fopen(strFileName, "wb")) == NULL)
  1323. {
  1324. DWORD dw = GetLastError();
  1325. char temp[512] = { 0 };
  1326. sprintf(temp, "fopen {%s} failed, error code:{%ld}", strFileName, dw);
  1327. OutputDebugString(temp);
  1328. return;
  1329. }
  1330. fwrite(pInImg, sizeof(WORD), (size_t)nImgWidth * (size_t)nImgHeight, fp);
  1331. fclose(fp);
  1332. OutputDebugString("Save image over----------------------");
  1333. }
  1334. STDMETHODIMP CKonicaObject2::CheckImageEx(int* pImageNo, int* pResolution)
  1335. {
  1336. unsigned int nInputImageNo = 0;
  1337. int nResolution = 0;//AEROSDK_RESOLUTION_NORMAL AEROSDK_RESOLUTION_HIGH
  1338. int nRet = 0;
  1339. char temp[256] = { 0 };
  1340. OutputDebugString("CheckImageEx----------------------");
  1341. nRet = AerosdkCheckImageEx((char*)m_strPanelType.c_str(), &nInputImageNo, &nResolution);
  1342. if (TestError(nRet, "AerosdkCheckImageEx"))
  1343. {
  1344. memset(temp, 0, sizeof(temp));
  1345. sprintf(temp, "CheckImageEx return error code:%d----------------------", nRet);
  1346. OutputDebugString(temp);
  1347. return S_FALSE;
  1348. }
  1349. else
  1350. {
  1351. memset(temp, 0, sizeof(temp));
  1352. sprintf(temp, "CheckImageEx nInputImageNo:%d,nResolution:%d----------------------", nInputImageNo, nResolution);
  1353. OutputDebugString(temp);
  1354. *pImageNo = nInputImageNo;
  1355. if (nInputImageNo)
  1356. {
  1357. *pResolution = nResolution;
  1358. OutputDebugString("Have image in detector!----------------------");
  1359. m_bHaveImageInDetector = true;
  1360. /*if (ImageResend(nInputImageNo))
  1361. {
  1362. OutputDebugString("ImageResend Success!----------------------");
  1363. }
  1364. else
  1365. {
  1366. OutputDebugString("ImageResend Fail!----------------------");
  1367. return S_FALSE;
  1368. }*/
  1369. if (ImageDelete(nInputImageNo))
  1370. {
  1371. OutputDebugString("ImageDelete Success!----------------------");
  1372. }
  1373. else
  1374. {
  1375. OutputDebugString("ImageDelete Fail!----------------------");
  1376. return S_FALSE;
  1377. }
  1378. }
  1379. else
  1380. {
  1381. OutputDebugString("NO image in detector!----------------------");
  1382. }
  1383. return S_OK;
  1384. }
  1385. }
  1386. bool CKonicaObject2::ImageResend(int nImageNo)
  1387. {
  1388. char temp[256] = { 0 };
  1389. sprintf(temp, "ImageResend nImageNo:%d----------------------", nImageNo);
  1390. OutputDebugString(temp);
  1391. int nRet = 0;
  1392. if (m_nSyncMode == SYNC_HARDWARE)
  1393. {
  1394. nRet = AerosdkStartImageResendingSequenceWithMode((char*)m_strPanelType.c_str(), nImageNo, AEROSDK_COOPERATION_SRM);// Triggered
  1395. }
  1396. else if (m_nSyncMode == SYNC_AED)
  1397. {
  1398. nRet = AerosdkStartImageResendingSequenceWithMode((char*)m_strPanelType.c_str(), nImageNo, AEROSDK_COOPERATION_AEROSYNC);// AeroSync
  1399. }
  1400. else
  1401. {
  1402. OutputDebugString("Wrong sync mode!----------------------");
  1403. return false;
  1404. }
  1405. if (TestError(nRet, "AerosdkStartImageResendingSequenceWithMode"))
  1406. {
  1407. memset(temp, 0, sizeof(temp));
  1408. sprintf(temp, "ImageResendingSequence return error code:%d----------------------", nRet);
  1409. OutputDebugString(temp);
  1410. return false;
  1411. }
  1412. bool bRet = WaitRespond(20000, "ImageResendingSequence");
  1413. if (!bRet)
  1414. {
  1415. return false;
  1416. }
  1417. return true;
  1418. }
  1419. bool CKonicaObject2::ImageDelete(int nImageNo)
  1420. {
  1421. char temp[256] = { 0 };
  1422. sprintf(temp, "ImageDelete nImageNo:%d----------------------", nImageNo);
  1423. OutputDebugString(temp);
  1424. int nRet = 0;
  1425. nRet = AerosdkStartImageDeleteSequence((char*)m_strPanelType.c_str(), nImageNo);
  1426. if (TestError(nRet, "AerosdkStartImageDeleteSequence"))
  1427. {
  1428. memset(temp, 0, sizeof(temp));
  1429. sprintf(temp, "ImageDeleteSequence return error code:%d----------------------", nRet);
  1430. OutputDebugString(temp);
  1431. return false;
  1432. }
  1433. bool bRet = WaitRespond(10000, "ImageDeleteSequence");
  1434. if (!bRet)
  1435. {
  1436. return false;
  1437. }
  1438. return true;
  1439. }