//////////////////////////////////////////////////////////////////////////
//Export Function
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000

#include "mPOSConst.h"

typedef int	 (__stdcall *pSelectInterface)(int interfaceType, LPCWSTR address);
typedef int  (__stdcall *pSelectCommandMode)(int bgtId, int commandMode);
typedef int  (__stdcall *pOpenService)(int bgtId);
typedef int  (__stdcall *pOpenServiceById)(int bgtId, int openDeviceId, int timeout);
typedef int  (__stdcall *pCloseService)(int bgtId, int timeout);
typedef bool (__stdcall *pIsOpen)(int bgtId);
typedef int  (__stdcall *pGetDeviceId)(int bgtId);
typedef int  (__stdcall *pDirectIO)(int bgtId, char* data, int dataLength);
typedef int  (__stdcall *pSendFile)(int bgtId, LPCWSTR fileName);
typedef int  (__stdcall *pSetTransaction)(int bgtId, int transactionMode);

class CMPosControllerDevices
{
public:
	CMPosControllerDevices();
	CMPosControllerDevices(const CString& strFileName);
	virtual ~CMPosControllerDevices();
	
	int		selectInterface(int interfaceType, LPCWSTR address);
	int		selectCommandMode(int commandMode);
	int		openService();
	int		openServiceById(int openDeviceId, int timeout);
	int		closeService(int closeTimeout);
	bool	isOpen();
	int		getDeviceId();
	int		directIO(char* data, int dataLength);
	int		sendFile(LPCWSTR);
	int		setTransaction(int transactionMode);
	int		setReadMode(int mode);
	int		setKeepNetworkConnection(int enable);
	LPCWSTR	getSDKVersion();
	int		setDataEvent(pfnDataEvent fnDataEventCallback);
	int		setStatusUpdateEvent(pfnStatusUpdateEvent fnStatusCallback);
	int		setOutputCompletedEvent(pfnOutputCompletedEvent fnOutputCompletedEvent);

protected:
	HMODULE	m_hDll;
	int 	m_nBgtId;
	int 	m_nDeviceId;
	bool LoadDll(const CString& strFileName);

private:
	void UnloadDll();
	

	pSelectInterface				fselectInterface;
	pSelectCommandMode				fselectCommandMode;
	pOpenService					fopenService;
	pOpenServiceById				fopenServiceById;
	pCloseService					fcloseService;
	pIsOpen							fisOpen;
	pGetDeviceId					fgetDeviceId;
	pDirectIO						fdirectIO;
	pSendFile						fsendFile;
	pSetTransaction					fsetTransaction;
};

