/** * File: IFpdAttachment.h * * Purpose: Access interface of iRay flat panel Attachment SDK. * * @author Haitao.Ning * @version 1.0 2019/03/07 * * Copyright (C) 2009, 2019, iRay Technology (Shanghai) Ltd. * * @code: sample code for demostrating IFpdAttach.DLL interface only, * --------------------------------------------------------------------------------------------------------- #include "stdafx.h" #include "IFpdAttachment.h" #include "IRayErrDef.h" FnGetAttachmentSDKVersion g_fpGetAttachmentSDKVersion; FnRegisterDeviceStateNotify g_fpRegisterDeviceStateNotify; FnInitLibrary g_fpInitLibrary; FnUnInitLibrary g_fpUnInitLibrary; FnGetFDInfo g_fpGetFDInfo; FnSetFDIpWifiInfo g_fpSetFDIpWifiInfo; FnSetFDIpInfo g_fpSetFDIpInfo; FnSetFDWifiInfo g_fpSetFDWifiInfo; void OnFpdAttachModuleNotify(int nEventID, int nParam1, int nParam2, int nPtrParamLen, void* pParam); int _tmain(int argc, _TCHAR* argv[]) { HMODULE hModule = LoadLibraryA("FpdAttach.dll"); if (NULL == hModule) { printf("\r\n----Load Attach SDK DLL failed!----"); return 0; } g_fpGetAttachmentSDKVersion = (FnGetAttachmentSDKVersion)GetProcAddress(hModule, IRAY_ATTACHMENT_PROC_NAME_GETAttachmentSDKVERSION); g_fpRegisterDeviceStateNotify = (FnRegisterDeviceStateNotify)GetProcAddress(hModule, IRAY_ATTACHMENT_PROC_NAME_REGISTERDEVICESTATENOTIFY);; g_fpInitLibrary = (FnInitLibrary)GetProcAddress(hModule, IRAY_ATTACHMENT_PROC_NAME_INITLIBRARY);; g_fpUnInitLibrary = (FnUnInitLibrary)GetProcAddress(hModule, IRAY_ATTACHMENT_PROC_NAME_UNINITLIBRARY);; g_fpGetFDInfo = (FnGetFDInfo)GetProcAddress(hModule, IRAY_ATTACHMENT_PROC_NAME_GETFDINFO);; g_fpSetFDIpWifiInfo = (FnSetFDIpWifiInfo)GetProcAddress(hModule, IRAY_ATTACHMENT_PROC_NAME_SETFDIPWIFIINFO);; g_fpSetFDIpInfo = (FnSetFDIpInfo)GetProcAddress(hModule, IRAY_ATTACHMENT_PROC_NAME_SETFDIPINFO);; g_fpSetFDWifiInfo = (FnSetFDWifiInfo)GetProcAddress(hModule, IRAY_ATTACHMENT_PROC_NAME_SETFDWIFIINFO);; if (NULL == g_fpGetAttachmentSDKVersion || NULL == g_fpRegisterDeviceStateNotify || NULL == g_fpInitLibrary || NULL == g_fpUnInitLibrary || NULL == g_fpGetFDInfo || NULL == g_fpSetFDIpWifiInfo || NULL == g_fpSetFDIpInfo || NULL == g_fpSetFDWifiInfo) { printf("\r\n----Get exported function failed!----"); FreeLibrary(hModule); return 0; } int nResult = 0; char szVersion[32] = {0}; nResult = g_fpGetAttachmentSDKVersion(szVersion); if (Err_OK != nResult) { printf("\r\n----Get Attachment SDK Version failed!----"); } nResult = g_fpRegisterDeviceStateNotify(&OnFpdAttachModuleNotify); if (Err_OK != nResult) { printf("\r\n----Register Notify Callback function failed!----"); } nResult = g_fpInitLibrary(); if (Err_OK != nResult) { printf("\r\n----InitLibrary failed!----"); FreeLibrary(hModule); return 0; } FDInfo info; memset(&info, 0, sizeof(info)); nResult = g_fpGetFDInfo(&info); if (Err_OK != nResult) { printf("\r\n----Get FD Info failed!----"); } FDSettings setting; memset(&setting, 0, sizeof(setting)); // initial setting here // ...TBD nResult = g_fpSetFDIpWifiInfo(&setting); if (Err_OK != nResult) { printf("\r\n----Set FD Ip Wifi Info failed!----"); } nResult = g_fpSetFDIpInfo(&setting); if (Err_OK != nResult) { printf("\r\n----Set FD Ip Info failed!----"); } nResult = g_fpSetFDWifiInfo(&setting); if (Err_OK != nResult) { printf("\r\n----Set FD Wifi Info failed!----"); } g_fpUnInitLibrary(); FreeLibrary(hModule); getchar(); return 0; } void OnFpdAttachModuleNotify(int nEventID, int nParam1, int nParam2, int nPtrParamLen, void* pParam) { switch (nEventID) { case Evt_DevOnline: printf("\r\n----FD online notice----"); break; case Evt_DevOffline: printf("\r\n----FD offline notice----"); break; default: break; } } * ---------------------------------------------------------------------------------------------------------/ * @endcode * */ #ifndef _IRAY_ATTACHMENT_INTERFACE_H_ #define _IRAY_ATTACHMENT_INTERFACE_H_ #define IRAY_ATTACHMENT_PROC_NAME_GETAttachmentSDKVERSION "GetAttachmentSDKVersion" #define IRAY_ATTACHMENT_PROC_NAME_REGISTERDEVICESTATENOTIFY "RegisterDeviceStateNotify" #define IRAY_ATTACHMENT_PROC_NAME_INITLIBRARY "InitLibrary" #define IRAY_ATTACHMENT_PROC_NAME_UNINITLIBRARY "UnInitLibrary" #define IRAY_ATTACHMENT_PROC_NAME_GETFDINFO "GetFDInfo" #define IRAY_ATTACHMENT_PROC_NAME_SETFDIPWIFIINFO "SetFDIpWifiInfo" #define IRAY_ATTACHMENT_PROC_NAME_SETFDIPINFO "SetFDIpInfo" #define IRAY_ATTACHMENT_PROC_NAME_SETFDWIFIINFO "SetFDWifiInfo" #define Evt_DevOnline 3001 // Device Online #define Evt_DevOffline 3002 // Device Offline //#define Err_OK 0 // errors has been defined in IRayErrDef.h //#define Err_StateErr 5 //#define Err_NotImplemented 7 //#define Err_InvalidParamValue 20 //#define Err_DetectorRespTimeout 24 //#define Err_CommDeviceNotFound 34 /** * FDInfo: Define a data struct for result of GetFDInfo functions, total 256 bytes */ #pragma pack(1) typedef struct _tagFDInfo { int nProdNo; char szSN[64]; char szIP[64]; char szWifiSSID[32]; char szWifiPwd[32]; char szWifiCountryCode[2]; char szReserved[32]; }FDInfo; /** * FDSettings: Define a data struct for config detector network settings */ typedef struct _tagFDWifiSettings { char szIP[64]; char szWifiSSID[32]; char szWifiPwd[32]; char szReserved[126]; }FDSettings; #pragma pack() /** * FnGetAttachmentSDKVersion: Define a function type for DLL export function "GetAttachmentSDKVersion" * * GetAttachmentSDKVersion: Get IRay Attachment SDK software version * * @param pszVersion [out] buffer to receive the version infomation * * @return 0: succeed, Non-Zero: error code */ typedef int(*FnGetAttachmentSDKVersion)(char pszVersion[32]); /** * FnDeviceStateChangeCallback: Define a function type for device online/offline state change callback * * @param nEventID [in] event ID * @param nParam1 [in] parameter with the event, defined for a certain event * @param nParam2 [in] parameter with the event, defined for a certain event * @param nPtrParamLen [in] bytes count for pointer typed parameter, defined for a certain event * @param pParam [in] pointer typed parameter, defined for a certain event * * @return void */ typedef void(*FnDeviceStateChangeCallback)(int nEventID, int nParam1, int nParam2, int nPtrParamLen, void* pParam); /** * FnRegisterDeviceStateNotify: Define a function type for DLL export function "RegisterDeviceStateNotify" * * RegisterDeviceStateNotify: register the FD state change event callback function * * @param pCallback [in] callback function pointer, return the FD online or offline state change event * * @return 0: succeed, Non-Zero: error code */ typedef int(*FnRegisterDeviceStateNotify)(FnDeviceStateChangeCallback pCallback); /** * FnInitLibrary: Define a function type for DLL export function "InitLibrary" * * InitLibrary: Initialize the attachment library * * @param None * * @return 0: succeed, Non-Zero: error code */ typedef int(*FnInitLibrary)(void); /** * FnUnInitLibrary: Define a function type for Dll export function "UnInitLibrary" * * UnInitLibrary: Destory the attachment library * * @param None * * @return void */ typedef void(*FnUnInitLibrary)(void); /** * FnGetFDInfo: Define a function type for DLL export function "GetFDInfo" * * GetFDInfo: Read detector info * * @param pOut [out] Detector Info and Network Settings * * @return 0: succeed, Non-Zero: error code */ typedef int(*FnGetFDInfo)(FDInfo* pInfo); /** * FnSetFDIpWifiInfo: Define a function type for DLL export function "SetFDIpWifiInfo" * * SetFDIpWifiInfo: Setting the Network parameters of IP/SSID/PWD/CountryCode. * * @param pIn [in] The parameters structure * * @return 0: succeed, Non-Zero: error code */ typedef int(*FnSetFDIpWifiInfo)(FDSettings* pIn); /** * FnSetFDIpInfo: Define a function type for DLL export function "SetFDIpInfo" * * SetFDIpInfo: Just Setting the Network parameter of IP. * * @param pIn [in] The parameters structure * * @return 0: succeed, Non-Zero: error code */ typedef int(*FnSetFDIpInfo)(FDSettings* pIn); /** * FnSetFDWifiInfo: Define a function type for DLL export function "SetFDWifiInfo" * * SetFDWifiInfo: Setting the Network parameters of SSID/PWD/CountryCode. * * @param pIn [in] The parameters structure * * @return 0: succeed, Non-Zero: error code */ typedef int(*FnSetFDWifiInfo)(FDSettings* pIn); #endif