#include "StdAfx.h"
#include "MPosControllerConfig.h"

//////////////////////////////////////////////////////////////////////////

CMPosControllerConfig::CMPosControllerConfig()
: CMPosControllerDevices(_T("MPosControllerConfig.dll"))
{
	LoadDll();
}

CMPosControllerConfig::~CMPosControllerConfig()
{
}

bool CMPosControllerConfig::LoadDll()
{ 	
	if(m_hDll == 0)
		return FALSE;

	fsearchDevices			= (pSearchDevices)GetProcAddress(m_hDll, "searchDevices");
	fgetBgateSerialNumber	= (pGetBgateSerialNumber)GetProcAddress(m_hDll, "getBgateSerialNumber");
	fgetUSBDevice			= (pGetUSBDevice)GetProcAddress(m_hDll, "getUSBDevice");
	fgetSerialConfiguration = (pGetSerialConfiguration)GetProcAddress(m_hDll, "getSerialConfiguration");
	fsetSerialConfiguration = (pSetSerialConfiguration)GetProcAddress(m_hDll, "setSerialConfiguration");
	fgetCustomDevices		= (pGetCustomDevices)GetProcAddress(m_hDll, "getCustomDevices");
	faddCustomDevice		= (pAddCustomDevice)GetProcAddress(m_hDll, "addCustomDevice");	
	fdeleteCustomDevice		= (pDeleteCustomDevice)GetProcAddress(m_hDll, "deleteCustomDevice");
	freInitCustomDeviceType = (pReInitCustomDeviceType)GetProcAddress(m_hDll, "reInitCustomDeviceType");

	return TRUE;
}

LPCTSTR CMPosControllerConfig::searchDevices()
{
	return fsearchDevices(m_nBgtId);
}

LPCTSTR CMPosControllerConfig::getBgateSerialNumber()
{
	return fgetBgateSerialNumber(m_nBgtId);
}

LPCTSTR CMPosControllerConfig::getUSBDevice(int deviceId)
{
	return fgetUSBDevice(m_nBgtId, deviceId);
}

LPCTSTR CMPosControllerConfig::getSerialConfiguration(int deviceId)
{
	return fgetSerialConfiguration(m_nBgtId, deviceId);
}

int CMPosControllerConfig::setSerialConfiguration(int deviceId, int baudrate, int dataBit, int stopBit, int parityBit, int flowControl)
{
	return fsetSerialConfiguration(m_nBgtId, deviceId, baudrate, dataBit, stopBit, parityBit, flowControl);
}

LPCTSTR CMPosControllerConfig::getCustomDevices(int deviceType)
{
	return fgetCustomDevices(m_nBgtId, deviceType);
}

int CMPosControllerConfig::addCustomDevice(int deviceType, LPCTSTR vid, LPCTSTR pid)
{
	return faddCustomDevice(m_nBgtId, deviceType, vid, pid);
}

int CMPosControllerConfig::deleteCustomDevice(int deviceType, LPCTSTR vid, LPCTSTR pid)
{
	return fdeleteCustomDevice(m_nBgtId, deviceType, vid, pid);
}

int CMPosControllerConfig::reInitCustomDeviceType(int deviceType)
{
	return freInitCustomDeviceType(m_nBgtId, deviceType);
}
