KonicaObject.cpp 57 KB

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