IRayFpdSys_MAM.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  1. /**
  2. * File: IRayFpdSys.h
  3. *
  4. * Purpose: Main access interface of iRay flat panel SDK.
  5. *
  6. * @author Haitao.Ning
  7. * @version 1.0 2015/02/02
  8. *
  9. * Copyright (C) 2009, 2015, iRay Technology (Shanghai) Ltd.
  10. *
  11. * @code: sample code for demostrating IRayFpdSys_MAM.DLL interface only,
  12. * more error-handling shall be performed in user's program, detail see "Programming Guide" document.
  13. * ---------------------------------------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "IRayFpdSys_MAM.h"
  16. #define TEST_WORKDIR_1 "D:\\MyDR\\MyDetector1"
  17. #define TEST_WORKDIR_2 "D:\\MyDR\\MyDetector2"
  18. void MyCallback(int nDetectorID, int nEventID, int nEventLevel,
  19. const char* pszMsg, int nParam1, int nParam2, int nPtrParamLen, void* pParam);
  20. FnCreate g_fpCreate;
  21. FnDestroy g_fpDestroy;
  22. FnGetAttr g_fpGetAttr;
  23. FnSetAttr g_fpSetAttr;
  24. FnInvoke g_fpInvoke;
  25. int _tmain(int argc, _TCHAR* argv[])
  26. {
  27. HMODULE hModule = LoadLibraryA("FpdSys_MAM.DLL");
  28. if (NULL == hModule)
  29. {
  30. printf("\r\n----Load SDK DLL failed!----");
  31. return 0;
  32. }
  33. g_fpCreate = (FnCreate)GetProcAddress(hModule, IRAY_FPD_PROC_NAME_CREATE);
  34. g_fpDestroy = (FnDestroy)GetProcAddress(hModule, IRAY_FPD_PROC_NAME_DESTROY);
  35. g_fpGetAttr = (FnGetAttr)GetProcAddress(hModule, IRAY_FPD_PROC_NAME_GETATTR);
  36. g_fpSetAttr = (FnSetAttr)GetProcAddress(hModule, IRAY_FPD_PROC_NAME_SETATTR);
  37. g_fpInvoke = (FnInvoke)GetProcAddress(hModule, IRAY_FPD_PROC_NAME_INVOKE);
  38. if (NULL == g_fpCreate || NULL == g_fpDestroy || NULL == g_fpGetAttr ||
  39. NULL == g_fpSetAttr || NULL == g_fpInvoke)
  40. {
  41. printf("\r\n----Get exported function failed!----");
  42. FreeLibrary(hModule);
  43. return 0;
  44. }
  45. FPDRESULT result;
  46. int nDetectorID1;
  47. result = g_fpCreate(TEST_WORKDIR_1, &MyCallback, &nDetectorID1);
  48. if (Err_OK == result)
  49. {
  50. IRayVariant var;
  51. var.vt = IVT_INT;
  52. var.val.nVal = 1;
  53. result = g_fpSetAttr(nDetectorID1, Cfg_ComPort, &var);
  54. if (Err_OK != result)
  55. {
  56. printf("\r\n----Test set attribute data failed!----");
  57. }
  58. else
  59. {
  60. printf("\r\n----Test set attribute data succeed----");
  61. }
  62. result = g_fpGetAttr(nDetectorID1, Attr_State, &var);
  63. if (Err_OK != result)
  64. {
  65. printf("\r\n----Test get attribute data failed!----");
  66. }
  67. else
  68. {
  69. printf("\r\n----Test get attribute data succeed, value = %d----", var.val.nVal);
  70. }
  71. }
  72. else
  73. {
  74. printf("\r\n----Create detector object failed!----");
  75. FreeLibrary(hModule);
  76. return 0;
  77. }
  78. int nDetectorID2;
  79. result = g_fpCreate(TEST_WORKDIR_2, &MyCallback, &nDetectorID2);
  80. if (Err_OK == result)
  81. {
  82. result = g_fpInvoke(nDetectorID2, Cmd_Connect, NULL, 0);
  83. if (Err_TaskPending == result)
  84. {
  85. printf("\r\n----Test command invoke is pending, please wait task result event.----");
  86. }
  87. if (Err_OK == result)
  88. {
  89. printf("\r\n----Test command invoke succeed!----");
  90. }
  91. else
  92. {
  93. printf("\r\n----Test command invoke failed! ErrCode = %d----", result);
  94. }
  95. }
  96. else
  97. {
  98. printf("\r\n----Create detector object failed!----");
  99. g_fpDestroy(nDetectorID1);
  100. FreeLibrary(hModule);
  101. return 0;
  102. }
  103. while (getchar() != 'q')
  104. {
  105. Sleep(10);
  106. }
  107. g_fpDestroy(nDetectorID1);
  108. g_fpDestroy(nDetectorID2);
  109. FreeLibrary(hModule);
  110. return 0;
  111. }
  112. void MyCallback(int nDetectorID, int nEventID, int nEventLevel,
  113. const char* pszMsg, int nParam1, int nParam2, int nPtrParamLen, void* pParam)
  114. {
  115. switch (nEventID)
  116. {
  117. case Evt_TaskResult_Succeed:
  118. if (Cmd_Connect == nParam1)
  119. {
  120. printf("\r\n----Test event callback succeed, Detector connected: ID = %d----", nDetectorID);
  121. }
  122. break;
  123. default:
  124. break;
  125. }
  126. }
  127. * ---------------------------------------------------------------------------------------------------------
  128. * @endcode
  129. *
  130. */
  131. #ifndef _IRAY_FPD_SYSTEM_INTERFACE_H_
  132. #define _IRAY_FPD_SYSTEM_INTERFACE_H_
  133. #include "IRayVariant_MAM.h"
  134. #include "IRayImage_MAM.h"
  135. #include "IRayErrDef_MAM.h"
  136. #include "IRayCmdDef_MAM.h"
  137. #include "IRayAttrDef_MAM.h"
  138. #include "IRayEnumDef_MAM.h"
  139. #include "IRayEventDef_MAM.h"
  140. #define IRAY_FPD_PROC_NAME_VERSION "GetSDKVersion"
  141. #define IRAY_FPD_PROC_SET_USERCODE "SetUserCode"
  142. #define IRAY_FPD_PROC_NAME_REGISTER_SCANNotify "RegisterScanNotify"
  143. #define IRAY_FPD_PROC_NAME_SCAN "ScanOnce"
  144. #define IRAY_FPD_PROC_NAME_CREATE "Create"
  145. #define IRAY_FPD_PROC_NAME_DESTROY "Destroy"
  146. #define IRAY_FPD_PROC_NAME_GETATTR "GetAttr"
  147. #define IRAY_FPD_PROC_NAME_SETATTR "SetAttr"
  148. #define IRAY_FPD_PROC_NAME_INVOKE "Invoke"
  149. #define IRAY_FPD_PROC_NAME_ABORT "Abort"
  150. #define IRAY_FPD_PROC_NAME_DEFECT_OPEN "OpenDefectTemplateFile"
  151. #define IRAY_FPD_PROC_NAME_DEFECT_SAVE "SaveDefectTemplateFile"
  152. #define IRAY_FPD_PROC_NAME_DEFECT_CLOSE "CloseDefectTemplateFile"
  153. #define IRAY_FPD_PROC_NAME_EXPLINE_CORRECT "DoExpLineCorrect"
  154. #define IRAY_FPD_PROC_NAME_SYNC_CREATE "SyncBoxCreate"
  155. #define IRAY_FPD_PROC_NAME_SYNC_DESTROY "SyncBoxDestroy"
  156. #define IRAY_FPD_PROC_NAME_SYNC_BIND "SyncBoxBind"
  157. #define IRAY_FPD_PROC_NAME_SYNC_GET_BIND "SyncBoxGetBind"
  158. #define IRAY_FPD_PROC_NAME_SYNC_GET_TUBEREADYTIME "SyncBoxGetTubeReadyTime"
  159. #define IRAY_FPD_PROC_NAME_SYNC_SET_TUBEREADYTIME "SyncBoxSetTubeReadyTime"
  160. #define IRAY_FPD_PROC_NAME_SYNC_GET_STATE "SyncBoxGetState"
  161. /**
  162. * FnGetSDKVersion: Define a function type for DLL export function "GetSDKVersion"
  163. *
  164. * GetSDKVersion: Get IRay FPD SDK software version
  165. *
  166. * @param pszVersion [out] buffer to receive the version infomation
  167. * for example "4.0.1.33" (MainVer.Function.Fixing.Build)
  168. *
  169. * @return 0: succeed, Non-Zero: error code
  170. */
  171. typedef int(*FnGetSDKVersion)(char pszVersion[32]);
  172. /**
  173. * FnSetUserCode: Define a function type for DLL export function "SetUserCode"
  174. *
  175. * SetUserCode: Set user code to obtain the authority specified by the license
  176. *
  177. * @param pszUserCode [in] User code to match the license
  178. *
  179. * @return 0: succeed, Non-Zero: error code
  180. */
  181. typedef int(*FnSetUserCode)(char* pszUserCode);
  182. /**
  183. * DetectorProfile: Define a data struct for scan and profile functions
  184. */
  185. #pragma pack(1)
  186. typedef struct _tagDetectorProfile
  187. {
  188. int nProdNo;
  189. int nSubProdNo;
  190. char szSN[64];
  191. char szIP[64];
  192. char szDetConfig[512];
  193. int bDetState; // 0:not busy, 1:busy
  194. }DetectorProfile;
  195. #pragma pack()
  196. /**
  197. * FnNotifyScanResult: Define a function type for broadcast scanning callback,
  198. * Note that: the data is only avaliable within the calling
  199. *
  200. * @param pDetectorProfile [in] scan result data struct
  201. *
  202. * @return void
  203. */
  204. typedef void(*FnNotifyScanResult)(DetectorProfile* pDetectorProfile);
  205. /**
  206. * FnRegisterScanNotify: Define a function type for DLL export function "RegisterScanNotify"
  207. *
  208. * RegisterScanNotify: register the scanning result callback function
  209. *
  210. * @param pCallback [in] callback function pointer, return the scan result from operation "Scan once" or
  211. * firmware pushed online notification.
  212. *
  213. * @return 0: succeed, Non-Zero: error code
  214. */
  215. typedef int(*FnRegisterScanNotify)(FnNotifyScanResult pCallback);
  216. /**
  217. * FnScanOnce: Define a function type for DLL export function "ScanOnce"
  218. *
  219. * ScanOnce: Start a broadcast scan to find reachable detectors, the result notification will be
  220. * returned with registered callback.
  221. *
  222. * @param pszIP [in] IP address of selected local network card, NULL or "0.0.0.0" means broadcast all network cards
  223. *
  224. * @return 0: succeed, Non-Zero: error code
  225. */
  226. typedef int(*FnScanOnce)(char* pszSourceIP);
  227. /**
  228. * FnCallback: Define a function type for SDK callback,
  229. * this definition will be used as an function argument while creating a detector object.
  230. *
  231. * @param nDetectorID [in] the detector which fired the event
  232. * @param nEventID [in] event ID
  233. * @param nEventLevel [in] event level
  234. * @param pszMsg [in] string description for the event
  235. * @param nParam1 [in] parameter with the event, defined for a certain event
  236. * @param nParam2 [in] parameter with the event, defined for a certain event
  237. * @param nPtrParamLen [in] bytes count for pointer typed parameter, defined for a certain event
  238. * @param pParam [in] pointer typed parameter, defined for a certain event
  239. *
  240. * @return void
  241. */
  242. typedef void(*FnCallback)(int nDetectorID, int nEventID, int nEventLevel,
  243. const char* pszMsg, int nParam1, int nParam2, int nPtrParamLen, void* pParam);
  244. /**
  245. * FnCreate: Define a function type for DLL export function "Create"
  246. *
  247. * Create: Create memory detector object,
  248. * if work dir has been used, function call will return error, together with the occuppied detector ID.
  249. *
  250. * @param pszWorkDir [in] set the working directory for a certain flat panel device
  251. * @param fpCallback [in] set the function pointer for SDK event callback
  252. * @param pDetectorID [out] buffer to receive the created object ID
  253. *
  254. * @return 0: succeed, Non-Zero: error code
  255. */
  256. typedef int(*FnCreate)(const char* pszWorkDir, FnCallback fpCallback, int* pDetectorID);
  257. /**
  258. * FnDestroy: Define a function type for DLL export function "Destroy"
  259. *
  260. * Destroy: Close the connection of specified detector, release the corresponding memory object
  261. *
  262. * @param nDetectorID [in] the ID of memory detector object
  263. *
  264. * @return 0: succeed, Non-Zero: error code
  265. */
  266. typedef int(*FnDestroy)(int nDetectorID);
  267. /**
  268. * FnGetAttr: Define a function type for DLL export function "GetAttr"
  269. *
  270. * GetAttr: Get attribute value
  271. *
  272. * @param nDetectorID [in] specify a detector
  273. * @param nAttrID [in] specify an attribute for getting
  274. * @param pVar [out] buffer to receive the value
  275. *
  276. * @return 0: succeed, Non-Zero: error code
  277. */
  278. typedef int(*FnGetAttr)(int nDetectorID, int nAttrID, IRayVariant* pVar);
  279. /**
  280. * FnSetAttr: Define a function type for DLL export function "SetAttr"
  281. *
  282. * SetAttr: Set attribute value
  283. *
  284. * @param nDetectorID [in] specify a detector
  285. * @param nAttrID [in] specify an attribute for setting
  286. * @param pVar [in] variant to set
  287. *
  288. * @return 0: succeed, Non-Zero: error code
  289. */
  290. typedef int(*FnSetAttr)(int nDetectorID, int nAttrID, const IRayVariant* pVar);
  291. /**
  292. * FnInvoke: Define a function type for DLL export function "Invoke"
  293. *
  294. * Invoke: Call SDK method using a pre-defined command ID,
  295. * if "pending" returned, it means an asynchronous task is started and the result will be callback later.
  296. *
  297. * @param nDetectorID [in] specify a detector
  298. * @param nCommandID [in] specify an command for calling
  299. * @param pars [in] parameter list for a certain command
  300. * @param nParCount [in] the count of parameters
  301. *
  302. * @return 0: succeed, Non-Zero: "pending state" or error code
  303. */
  304. typedef int(*FnInvoke)(int nDetectorID, int nCommandID, IRayCmdParam pars[], int nParCount);
  305. /**
  306. * FnAbort: Define a function type for DLL export function "Abort"
  307. *
  308. * Abort: Abort the current transation processing flow
  309. *
  310. * @param nDetectorID [in] specify a detector
  311. *
  312. * @return 0: succeed, Non-Zero: error code
  313. */
  314. typedef int(*FnAbort)(int nDetectorID);
  315. /**
  316. * FnOpenDefectTemplateFile: Define a function type for DLL export function "OpenDefectTemplateFile"
  317. *
  318. * OpenDefectTemplateFile: Load the specified defect template file for editing
  319. *
  320. * @param pszFilePath [in] file path
  321. * @param ppHandler [out] return the handler of the opened file
  322. * @param pWidth [out] return width of the image
  323. * @param pHeight [out] return height of the image
  324. * @param ppPoints [out] return defect point map of the detector, for each element 0 means normal, 1 means defect
  325. * @param ppRows [out] return defect row map of the detector, for each element 0 means normal, 1 means defect
  326. * @param ppCols [out] return defect column map of the detector, for each element 0 means normal, 1 means defect
  327. * , if ppDualReadCols2 not NULL, ppCols means defect column map of the upper part
  328. * @param ppDualReadCols2 [out] only for the 'Dual-Read' detector, return defect column map of the bottom part
  329. * , NULL means not Dual-Read
  330. *
  331. *
  332. * @return 0: succeed, Non-Zero: error code
  333. */
  334. typedef int(*FnOpenDefectTemplateFile)(
  335. const char* pszFilePath,
  336. void** ppHandler,
  337. unsigned short* pWidth,
  338. unsigned short* pHeight,
  339. char** ppPoints, // arrayLen = width * height
  340. char** ppRows, // arrayLen = height
  341. char** ppCols, // arrayLen = width
  342. char** ppDualReadCols2 // arrayLen = width
  343. );
  344. /**
  345. * FnSaveDefectTemplateFile: Define a function type for DLL export function "SaveDefectTemplateFile"
  346. *
  347. * SaveDefectTemplateFile: Save the opened defect template file after editing
  348. *
  349. * @param pHandler [in] the handler of the opened file
  350. *
  351. * @return 0: succeed, Non-Zero: error code
  352. */
  353. typedef int(*FnSaveDefectTemplateFile)(void* pHandler);
  354. /**
  355. * FnCloseDefectTemplateFile: Define a function type for DLL export function "CloseDefectTemplateFile"
  356. *
  357. * CloseDefectTemplateFile: Close the opened defect template file
  358. *
  359. * @param pHandler [in] the handler of the opened file
  360. *
  361. * @return 0: succeed, Non-Zero: error code
  362. */
  363. typedef int(*FnCloseDefectTemplateFile)(void* pHandler);
  364. /**
  365. * FnDoExpLineCorrect: Define a function type for DLL export function "DoExpLineCorrect"
  366. *
  367. * DoExpLineCorrect: Do exposure line correction after grid removing process, for FreeSync mode only
  368. *
  369. * @param pData [in,out] image data pointer
  370. * @param usWidth [in] image width
  371. * @param usHeight [in] image height
  372. * @param usExpLine [in] exposure line number
  373. *
  374. * @return 0: succeed, Non-Zero: error code
  375. */
  376. typedef int(*FnDoExpLineCorrect)(unsigned short* pData, unsigned short usWidth, unsigned short usHeight, unsigned short usExpLine);
  377. /**
  378. * FnSyncBoxCreate: Define a function type for DLL export function "SyncBoxCreate"
  379. *
  380. * SyncBoxCreate: Create a memory object of syncbox
  381. *
  382. * @param nComPort [in] specify the serial COM port which the device connected,
  383. * is Zero is specified, the function should scan all the ports to find the device
  384. * @param pSyncboxID [in,out] buffer to receive the value of created syncbox ID
  385. *
  386. * @return 0: succeed, Non-Zero: error code
  387. */
  388. typedef int(*FnSyncBoxCreate)(int nComPort, int *pSyncboxID);
  389. /**
  390. * FnSyncBoxDestroy: Define a function type for DLL export function "SyncBoxDestroy"
  391. *
  392. * SyncBoxDestroy: Close the syncbox device and release the corresponding memory object
  393. *
  394. * @param nSyncBoxID [in] the ID of memory syncbox object
  395. *
  396. * @return 0: succeed, Non-Zero: error code
  397. */
  398. typedef int(*FnSyncBoxDestroy)(int nSyncBoxID);
  399. /**
  400. * FnSyncBoxBind: Define a function type for DLL export function "SyncBoxBind"
  401. *
  402. * SyncBoxBind: Bind a detector object to the syncbox.
  403. * Note that if the detector object destroyed, binding may be changed.
  404. *
  405. * @param nSyncboxID [in] specify the syncbox
  406. * @param nDetectorID [in] specify a detector which is going to bind to the syncbox
  407. *
  408. * @return 0: succeed, Non-Zero: error code
  409. */
  410. typedef int(*FnSyncBoxBind)(int nSyncboxID, int nDetectorID);
  411. /**
  412. * FnSyncBoxGetBind: Define a function type for DLL export function "SyncBoxGetBind"
  413. *
  414. * SyncBoxGetBind: Get the current bound detector of syncbox
  415. *
  416. * @param nSyncboxID [in] specify the syncbox
  417. * @param pDetectorID [in, out] buffer to receive the value.
  418. *
  419. * @return 0: succeed, Non-Zero: error code
  420. */
  421. typedef int(*FnSyncBoxGetBind)(int nSyncboxID, int *pDetectorID);
  422. /**
  423. * FnSyncBoxGetTubeReadyTime: Define a function type for DLL export function "SyncBoxGetTubeReadyTime"
  424. *
  425. * SyncBoxGetTubeReadyTime: Get the parameter value of "TubeReadyTime", syncbox will wait the specified time
  426. * after hand switch phase I is pressed and before the detector clear action start
  427. *
  428. * @param nSyncboxID [in] specify the syncbox
  429. * @param pTimeInMS [in,out] buffer to receive the value
  430. *
  431. * @return 0: succeed, Non-Zero: error code
  432. */
  433. typedef int(*FnSyncBoxGetTubeReadyTime)(int nSyncboxID, int *pTimeInMS);
  434. /**
  435. * FnSyncBoxSetTubeReadyTime: Define a function type for DLL export function "SyncBoxSetTubeReadyTime"
  436. *
  437. * SyncBoxSetTubeReadyTime: Set the parameter value of "TubeReadyTime" to device
  438. *
  439. * @param nSyncboxID [in] specify the syncbox
  440. * @param nTimeInMS [in] specify the time value, in MS
  441. *
  442. * @return 0: succeed, Non-Zero: error code
  443. */
  444. typedef int(*FnSyncBoxSetTubeReadyTime)(int nSyncboxID, int nTimeInMS);
  445. /**
  446. * FnSyncBoxGetState: Define a function type for DLL export function "SyncBoxGetState"
  447. *
  448. * SyncBoxGetState: Get the current state of syncbox
  449. *
  450. * @param nSyncboxID [in] specify the syncbox
  451. * @param pState [in, out] buffer to receive the value. 0 - Unknown, 1 - Ready, 2 - Busy
  452. *
  453. * @return 0: succeed, Non-Zero: error code
  454. */
  455. typedef int(*FnSyncBoxGetState)(int nSyncboxID, int *pState);
  456. #endif