IFpdAttachment.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. /**
  2. * File: IFpdAttachment.h
  3. *
  4. * Purpose: Access interface of iRay flat panel Attachment SDK.
  5. *
  6. * @author Haitao.Ning
  7. * @version 1.0 2019/03/07
  8. *
  9. * Copyright (C) 2009, 2019, iRay Technology (Shanghai) Ltd.
  10. *
  11. * @code: sample code for demostrating IFpdAttach.DLL interface only,
  12. * ---------------------------------------------------------------------------------------------------------
  13. #include "stdafx.h"
  14. #include "IFpdAttachment.h"
  15. #include "IRayErrDef.h"
  16. FnGetAttachmentSDKVersion g_fpGetAttachmentSDKVersion;
  17. FnRegisterDeviceStateNotify g_fpRegisterDeviceStateNotify;
  18. FnInitLibrary g_fpInitLibrary;
  19. FnUnInitLibrary g_fpUnInitLibrary;
  20. FnGetFDInfo g_fpGetFDInfo;
  21. FnSetFDIpWifiInfo g_fpSetFDIpWifiInfo;
  22. FnSetFDIpInfo g_fpSetFDIpInfo;
  23. FnSetFDWifiInfo g_fpSetFDWifiInfo;
  24. void OnFpdAttachModuleNotify(int nEventID,
  25. int nParam1, int nParam2, int nPtrParamLen, void* pParam);
  26. int _tmain(int argc, _TCHAR* argv[])
  27. {
  28. HMODULE hModule = LoadLibraryA("FpdAttach.dll");
  29. if (NULL == hModule)
  30. {
  31. printf("\r\n----Load Attach SDK DLL failed!----");
  32. return 0;
  33. }
  34. g_fpGetAttachmentSDKVersion = (FnGetAttachmentSDKVersion)GetProcAddress(hModule, IRAY_ATTACHMENT_PROC_NAME_GETAttachmentSDKVERSION);
  35. g_fpRegisterDeviceStateNotify = (FnRegisterDeviceStateNotify)GetProcAddress(hModule, IRAY_ATTACHMENT_PROC_NAME_REGISTERDEVICESTATENOTIFY);;
  36. g_fpInitLibrary = (FnInitLibrary)GetProcAddress(hModule, IRAY_ATTACHMENT_PROC_NAME_INITLIBRARY);;
  37. g_fpUnInitLibrary = (FnUnInitLibrary)GetProcAddress(hModule, IRAY_ATTACHMENT_PROC_NAME_UNINITLIBRARY);;
  38. g_fpGetFDInfo = (FnGetFDInfo)GetProcAddress(hModule, IRAY_ATTACHMENT_PROC_NAME_GETFDINFO);;
  39. g_fpSetFDIpWifiInfo = (FnSetFDIpWifiInfo)GetProcAddress(hModule, IRAY_ATTACHMENT_PROC_NAME_SETFDIPWIFIINFO);;
  40. g_fpSetFDIpInfo = (FnSetFDIpInfo)GetProcAddress(hModule, IRAY_ATTACHMENT_PROC_NAME_SETFDIPINFO);;
  41. g_fpSetFDWifiInfo = (FnSetFDWifiInfo)GetProcAddress(hModule, IRAY_ATTACHMENT_PROC_NAME_SETFDWIFIINFO);;
  42. if (NULL == g_fpGetAttachmentSDKVersion || NULL == g_fpRegisterDeviceStateNotify || NULL == g_fpInitLibrary ||
  43. NULL == g_fpUnInitLibrary || NULL == g_fpGetFDInfo ||
  44. NULL == g_fpSetFDIpWifiInfo || NULL == g_fpSetFDIpInfo || NULL == g_fpSetFDWifiInfo)
  45. {
  46. printf("\r\n----Get exported function failed!----");
  47. FreeLibrary(hModule);
  48. return 0;
  49. }
  50. int nResult = 0;
  51. char szVersion[32] = {0};
  52. nResult = g_fpGetAttachmentSDKVersion(szVersion);
  53. if (Err_OK != nResult)
  54. {
  55. printf("\r\n----Get Attachment SDK Version failed!----");
  56. }
  57. nResult = g_fpRegisterDeviceStateNotify(&OnFpdAttachModuleNotify);
  58. if (Err_OK != nResult)
  59. {
  60. printf("\r\n----Register Notify Callback function failed!----");
  61. }
  62. nResult = g_fpInitLibrary();
  63. if (Err_OK != nResult)
  64. {
  65. printf("\r\n----InitLibrary failed!----");
  66. FreeLibrary(hModule);
  67. return 0;
  68. }
  69. FDInfo info;
  70. memset(&info, 0, sizeof(info));
  71. nResult = g_fpGetFDInfo(&info);
  72. if (Err_OK != nResult)
  73. {
  74. printf("\r\n----Get FD Info failed!----");
  75. }
  76. FDSettings setting;
  77. memset(&setting, 0, sizeof(setting));
  78. // initial setting here
  79. // ...TBD
  80. nResult = g_fpSetFDIpWifiInfo(&setting);
  81. if (Err_OK != nResult)
  82. {
  83. printf("\r\n----Set FD Ip Wifi Info failed!----");
  84. }
  85. nResult = g_fpSetFDIpInfo(&setting);
  86. if (Err_OK != nResult)
  87. {
  88. printf("\r\n----Set FD Ip Info failed!----");
  89. }
  90. nResult = g_fpSetFDWifiInfo(&setting);
  91. if (Err_OK != nResult)
  92. {
  93. printf("\r\n----Set FD Wifi Info failed!----");
  94. }
  95. g_fpUnInitLibrary();
  96. FreeLibrary(hModule);
  97. getchar();
  98. return 0;
  99. }
  100. void OnFpdAttachModuleNotify(int nEventID, int nParam1, int nParam2, int nPtrParamLen, void* pParam)
  101. {
  102. switch (nEventID)
  103. {
  104. case Evt_DevOnline:
  105. printf("\r\n----FD online notice----");
  106. break;
  107. case Evt_DevOffline:
  108. printf("\r\n----FD offline notice----");
  109. break;
  110. default:
  111. break;
  112. }
  113. }
  114. * ---------------------------------------------------------------------------------------------------------/
  115. * @endcode
  116. *
  117. */
  118. #ifndef _IRAY_ATTACHMENT_INTERFACE_H_
  119. #define _IRAY_ATTACHMENT_INTERFACE_H_
  120. #define IRAY_ATTACHMENT_PROC_NAME_GETAttachmentSDKVERSION "GetAttachmentSDKVersion"
  121. #define IRAY_ATTACHMENT_PROC_NAME_REGISTERDEVICESTATENOTIFY "RegisterDeviceStateNotify"
  122. #define IRAY_ATTACHMENT_PROC_NAME_INITLIBRARY "InitLibrary"
  123. #define IRAY_ATTACHMENT_PROC_NAME_UNINITLIBRARY "UnInitLibrary"
  124. #define IRAY_ATTACHMENT_PROC_NAME_GETFDINFO "GetFDInfo"
  125. #define IRAY_ATTACHMENT_PROC_NAME_SETFDIPWIFIINFO "SetFDIpWifiInfo"
  126. #define IRAY_ATTACHMENT_PROC_NAME_SETFDIPINFO "SetFDIpInfo"
  127. #define IRAY_ATTACHMENT_PROC_NAME_SETFDWIFIINFO "SetFDWifiInfo"
  128. #define Evt_DevOnline 3001 // Device Online
  129. #define Evt_DevOffline 3002 // Device Offline
  130. //#define Err_OK 0 // errors has been defined in IRayErrDef.h
  131. //#define Err_StateErr 5
  132. //#define Err_NotImplemented 7
  133. //#define Err_InvalidParamValue 20
  134. //#define Err_DetectorRespTimeout 24
  135. //#define Err_CommDeviceNotFound 34
  136. /**
  137. * FDInfo: Define a data struct for result of GetFDInfo functions, total 256 bytes
  138. */
  139. #pragma pack(1)
  140. typedef struct _tagFDInfo
  141. {
  142. int nProdNo;
  143. char szSN[64];
  144. char szIP[64];
  145. char szWifiSSID[32];
  146. char szWifiPwd[32];
  147. char szWifiCountryCode[2];
  148. char szReserved[32];
  149. }FDInfo;
  150. /**
  151. * FDSettings: Define a data struct for config detector network settings
  152. */
  153. typedef struct _tagFDWifiSettings
  154. {
  155. char szIP[64];
  156. char szWifiSSID[32];
  157. char szWifiPwd[32];
  158. char szReserved[126];
  159. }FDSettings;
  160. #pragma pack()
  161. /**
  162. * FnGetAttachmentSDKVersion: Define a function type for DLL export function "GetAttachmentSDKVersion"
  163. *
  164. * GetAttachmentSDKVersion: Get IRay Attachment SDK software version
  165. *
  166. * @param pszVersion [out] buffer to receive the version infomation
  167. *
  168. * @return 0: succeed, Non-Zero: error code
  169. */
  170. typedef int(*FnGetAttachmentSDKVersion)(char pszVersion[32]);
  171. /**
  172. * FnDeviceStateChangeCallback: Define a function type for device online/offline state change callback
  173. *
  174. * @param nEventID [in] event ID
  175. * @param nParam1 [in] parameter with the event, defined for a certain event
  176. * @param nParam2 [in] parameter with the event, defined for a certain event
  177. * @param nPtrParamLen [in] bytes count for pointer typed parameter, defined for a certain event
  178. * @param pParam [in] pointer typed parameter, defined for a certain event
  179. *
  180. * @return void
  181. */
  182. typedef void(*FnDeviceStateChangeCallback)(int nEventID, int nParam1, int nParam2, int nPtrParamLen, void* pParam);
  183. /**
  184. * FnRegisterDeviceStateNotify: Define a function type for DLL export function "RegisterDeviceStateNotify"
  185. *
  186. * RegisterDeviceStateNotify: register the FD state change event callback function
  187. *
  188. * @param pCallback [in] callback function pointer, return the FD online or offline state change event
  189. *
  190. * @return 0: succeed, Non-Zero: error code
  191. */
  192. typedef int(*FnRegisterDeviceStateNotify)(FnDeviceStateChangeCallback pCallback);
  193. /**
  194. * FnInitLibrary: Define a function type for DLL export function "InitLibrary"
  195. *
  196. * InitLibrary: Initialize the attachment library
  197. *
  198. * @param None
  199. *
  200. * @return 0: succeed, Non-Zero: error code
  201. */
  202. typedef int(*FnInitLibrary)(void);
  203. /**
  204. * FnUnInitLibrary: Define a function type for Dll export function "UnInitLibrary"
  205. *
  206. * UnInitLibrary: Destory the attachment library
  207. *
  208. * @param None
  209. *
  210. * @return void
  211. */
  212. typedef void(*FnUnInitLibrary)(void);
  213. /**
  214. * FnGetFDInfo: Define a function type for DLL export function "GetFDInfo"
  215. *
  216. * GetFDInfo: Read detector info
  217. *
  218. * @param pOut [out] Detector Info and Network Settings
  219. *
  220. * @return 0: succeed, Non-Zero: error code
  221. */
  222. typedef int(*FnGetFDInfo)(FDInfo* pInfo);
  223. /**
  224. * FnSetFDIpWifiInfo: Define a function type for DLL export function "SetFDIpWifiInfo"
  225. *
  226. * SetFDIpWifiInfo: Setting the Network parameters of IP/SSID/PWD/CountryCode.
  227. *
  228. * @param pIn [in] The parameters structure
  229. *
  230. * @return 0: succeed, Non-Zero: error code
  231. */
  232. typedef int(*FnSetFDIpWifiInfo)(FDSettings* pIn);
  233. /**
  234. * FnSetFDIpInfo: Define a function type for DLL export function "SetFDIpInfo"
  235. *
  236. * SetFDIpInfo: Just Setting the Network parameter of IP.
  237. *
  238. * @param pIn [in] The parameters structure
  239. *
  240. * @return 0: succeed, Non-Zero: error code
  241. */
  242. typedef int(*FnSetFDIpInfo)(FDSettings* pIn);
  243. /**
  244. * FnSetFDWifiInfo: Define a function type for DLL export function "SetFDWifiInfo"
  245. *
  246. * SetFDWifiInfo: Setting the Network parameters of SSID/PWD/CountryCode.
  247. *
  248. * @param pIn [in] The parameters structure
  249. *
  250. * @return 0: succeed, Non-Zero: error code
  251. */
  252. typedef int(*FnSetFDWifiInfo)(FDSettings* pIn);
  253. #endif