#include "stdafx.h"
#include "MPosControllerLabelPrinter.h"

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

CMPosControllerLabelPrinter::CMPosControllerLabelPrinter()
: CMPosControllerDevices(_T("MPosControllerLabelPrinter.dll"))
{
	LoadDll();
}

CMPosControllerLabelPrinter::~CMPosControllerLabelPrinter()
{
}

bool CMPosControllerLabelPrinter::LoadDll()
{ 	
	if(m_hDll == 0)
		return FALSE;
	//()GetProcAddress(m_hDll, (""));
	fCheckPrinterStatus		= (pCheckPrinterStatus)GetProcAddress(m_hDll, ("checkPrinterStatus"));
	fPrintBuffer			= (pPrintBuffer)GetProcAddress(m_hDll, ("printBuffer"));
	fPrintRawData			= (pPrintRawData)GetProcAddress(m_hDll, ("printRawData"));
	fDrawTextDeviceFont		= (pDrawTextDeviceFont)GetProcAddress(m_hDll, ("drawTextDeviceFont"));
	fDrawTextVectorFont		= (pDrawTextVectorFont)GetProcAddress(m_hDll, ("drawTextVectorFont"));
	
	fDrawBarcode1D			= (pDrawBarcode1D)GetProcAddress(m_hDll, ("drawBarcode1D"));
	fDrawBarcodeMaxiCode	= (pDrawBarcodeMaxiCode)GetProcAddress(m_hDll, ("drawBarcodeMaxiCode"));
	fDrawBarcodePDF417		= (pDrawBarcodePDF417)GetProcAddress(m_hDll, ("drawBarcodePDF417"));
	fDrawBarcodeQRCode		= (pDrawBarcodeQRCode)GetProcAddress(m_hDll, ("drawBarcodeQRCode"));
	fDrawBarcodeDataMatrix	= (pDrawBarcodeDataMatrix)GetProcAddress(m_hDll, ("drawBarcodeDataMatrix"));
	fDrawBarcodeAztec		= (pDrawBarcodeAztec)GetProcAddress(m_hDll, ("drawBarcodeAztec"));
	fDrawBarcodeCode49		= (pDrawBarcodeCode49)GetProcAddress(m_hDll, ("drawBarcodeCode49"));
	fDrawBarcodeCodaBlock	= (pDrawBarcodeCodaBlock)GetProcAddress(m_hDll, ("drawBarcodeCodaBlock"));
	fDrawBarcodeMicroPDF	= (pDrawBarcodeMicroPDF)GetProcAddress(m_hDll, ("drawBarcodeMicroPDF"));
	fDrawBarcodeIMB			= (pDrawBarcodeIMB)GetProcAddress(m_hDll, ("drawBarcodeIMB"));
	fDrawBarcodeMSI			= (pDrawBarcodeMSI)GetProcAddress(m_hDll, ("drawBarcodeMSI"));
	fDrawBarcodePlessey		= (pDrawBarcodePlessey)GetProcAddress(m_hDll, ("drawBarcodePlessey"));
	fDrawBarcodeTLC39		= (pDrawBarcodeTLC39)GetProcAddress(m_hDll, ("drawBarcodeTLC39"));
	fDrawBarcodeRSS			= (pDrawBarcodeRSS)GetProcAddress(m_hDll, ("drawBarcodeRSS"));

	fDrawBlock				= (pDrawBlock)GetProcAddress(m_hDll, ("drawBlock"));
	fDrawCircle				= (pDrawCircle)GetProcAddress(m_hDll, ("drawCircle"));
	fDrawImageFile			= (pDrawImageFile)GetProcAddress(m_hDll, ("drawImageFile"));
	fDrawBase64Image		= (pDrawBase64Image)GetProcAddress(m_hDll, ("drawBase64Image"));

	fSetCharacterset		= (pSetCharacterset)GetProcAddress(m_hDll, ("setCharacterset"));
	fSetPrintingType		= (pSetPrintingType)GetProcAddress(m_hDll, ("setPrintingType"));
	fSetMargin				= (pSetMargin)GetProcAddress(m_hDll, ("setMargin"));
	fSetLength				= (pSetLength)GetProcAddress(m_hDll, ("setLength"));
	fSetWidth				= (pSetWidth)GetProcAddress(m_hDll, ("setWidth"));
	fSetSpeed				= (pSetSpeed)GetProcAddress(m_hDll, ("setSpeed"));
	fSetDensity				= (pSetDensity)GetProcAddress(m_hDll, ("setDensity"));
	fSetOrientation			= (pSetOrientation)GetProcAddress(m_hDll, ("setOrientation"));
	fSetOffset				= (pSetOffset)GetProcAddress(m_hDll, ("setOffset"));
	fSetCuttingPosition		= (pSetCuttingPosition)GetProcAddress(m_hDll, ("setCuttingPosition"));
	fSetAutoCutter			= (pSetAutoCutter)GetProcAddress(m_hDll, ("setAutoCutter"));
	
	fSetRewinder			= (pSetRewinder)GetProcAddress(m_hDll, ("setRewinder"));
	fSetupRFID				= (pSetupRFID)GetProcAddress(m_hDll, ("setupRFID"));
	fSetEPCDataStructure	= (pSetEPCDataStructure)GetProcAddress(m_hDll, ("setEPCDataStructure"));
	fSetRFIDPosition		= (pSetRFIDPosition)GetProcAddress(m_hDll, ("setRFIDPosition"));
	fCalibrateRFID			= (pCalibrateRFID)GetProcAddress(m_hDll, ("calibrateRFID"));
	fWriteRFID				= (pWriteRFID)GetProcAddress(m_hDll, ("writeRFID"));
	fSetRFIDPassword		= (pSetRFIDPassword)GetProcAddress(m_hDll, ("setRFIDPassword"));
	fLockRFID				= (pLockRFID)GetProcAddress(m_hDll, ("lockRFID"));

	fGetModelName			= (pGetModelName)GetProcAddress(m_hDll, ("getModelName"));
	fGetFirmwareVersion		= (pGetFirmwareVersion)GetProcAddress(m_hDll, ("getFirmwareVersion"));
	fGetPrinterDPI			= (pGetPrinterDPI)GetProcAddress(m_hDll, ("getPrinterDPI"));
	fGetMaxWidth			= (pGetMaxWidth)GetProcAddress(m_hDll, ("getMaxWidth"));
	fGetSupportedSpeeds		= (pGetSupportedSpeeds)GetProcAddress(m_hDll, ("getSupportedSpeeds"));
	fGetStatisticsData		= (pGetStatisticsData)GetProcAddress(m_hDll, ("getStatisticsData"));
	return TRUE;
}
int CMPosControllerLabelPrinter::checkPrinterStatus()
{
	return fCheckPrinterStatus(m_nBgtId);
}

int CMPosControllerLabelPrinter::printRawData(char* rawData, int rawDataLength)
{
	return fPrintRawData(m_nBgtId, rawData,	rawDataLength);
}

int CMPosControllerLabelPrinter::printBuffer(int numberOfcopies)
{
	return fPrintBuffer(m_nBgtId, numberOfcopies);
}

int CMPosControllerLabelPrinter::drawTextDeviceFont(LPCTSTR data, int xPos, int yPos, char fontSelection, int fontWidth,
													int fontHeight, int rightSpace, int rotation, BOOL reverse, BOOL bold, BOOL rightToLeft, int alignment)
{
	return fDrawTextDeviceFont(m_nBgtId, data, xPos, yPos, fontSelection, fontWidth, fontHeight, rightSpace, rotation, reverse, bold, rightToLeft, alignment);
}

int CMPosControllerLabelPrinter::drawTextVectorFont(LPCTSTR data, int xPos, int yPos, char fontSelection, int fontWidth,
													int fontHeight, int rightSpace, int rotation, BOOL reverse, BOOL bold, BOOL italic, BOOL rightToLeft, int alignment)
{
	return fDrawTextVectorFont(m_nBgtId, data, xPos, yPos, fontSelection, fontWidth, fontHeight, rightSpace, rotation, reverse, bold, italic, rightToLeft, alignment);
}

int CMPosControllerLabelPrinter::drawBarcode1D(LPCTSTR data, int xPos, int yPos, int barcodeType,
											   int widthNarrow, int widthWide, int height, int hri, int quietZoneWidth, int rotation)
{
	return fDrawBarcode1D(m_nBgtId, data, xPos, yPos, barcodeType, widthNarrow, widthWide, height, hri, quietZoneWidth, rotation);
}

int CMPosControllerLabelPrinter::drawBarcodeMaxiCode(LPCTSTR data, int xPos, int yPos, int mode)
{
	return fDrawBarcodeMaxiCode(m_nBgtId, data, xPos, yPos, mode);
}

int CMPosControllerLabelPrinter::drawBarcodePDF417(LPCTSTR data, int xPos, int yPos, int rowCount, int columnCount, int eccLevel, int dataCompressionMethod, BOOL hri, int startPosition, int moduleWidth, int barHeight, int rotation)
{
	return fDrawBarcodePDF417(m_nBgtId, data, xPos, yPos, rowCount, columnCount, eccLevel, dataCompressionMethod, hri, startPosition, moduleWidth, barHeight, rotation);
}

int CMPosControllerLabelPrinter::drawBarcodeQRCode(LPCTSTR data, int xPos, int yPos, int size, int model, int eccLevel, int rotation)
{
	return fDrawBarcodeQRCode(m_nBgtId, data, xPos, yPos, size, model, eccLevel, rotation);
}

int CMPosControllerLabelPrinter::drawBarcodeDataMatrix(LPCTSTR data, int xPos, int yPos, int size, BOOL reverse, int rotation)
{
	return fDrawBarcodeDataMatrix(m_nBgtId, data, xPos, yPos, size, reverse, rotation);
}

int CMPosControllerLabelPrinter::drawBarcodeAztec(LPCTSTR data, int xPos, int yPos, int size, BOOL extendedChannel, int eccLevel, BOOL menuSymbol, int numberOfSymbols, LPCTSTR optionalID, int rotation)
{
	return fDrawBarcodeAztec(m_nBgtId, data, xPos, yPos, size, extendedChannel, eccLevel, menuSymbol, numberOfSymbols, optionalID, rotation);
}

int CMPosControllerLabelPrinter::drawBarcodeCode49(LPCTSTR data, int xPos, int yPos, int widthNarrow, int widthWide, int height, int hri, int startingMode, int rotation)
{
	return fDrawBarcodeCode49(m_nBgtId, data, xPos, yPos, widthNarrow, widthWide, height, hri, startingMode, rotation);
}

int CMPosControllerLabelPrinter::drawBarcodeCodaBlock(LPCTSTR data, int xPos, int yPos, int widthNarrow, int widthWide, int height, BOOL securityLevel, int dataColumns, char mode, int encode)
{
	return fDrawBarcodeCodaBlock(m_nBgtId, data, xPos, yPos, widthNarrow, widthWide, height, securityLevel, dataColumns, mode, encode);
}

int CMPosControllerLabelPrinter::drawBarcodeMicroPDF(LPCTSTR data, int xPos, int yPos, int moduleWidth, int height, int mode, int rotation)
{
	return fDrawBarcodeMicroPDF(m_nBgtId, data, xPos, yPos, moduleWidth, height, mode, rotation);
}

int CMPosControllerLabelPrinter::drawBarcodeIMB(LPCTSTR data, int xPos, int yPos, BOOL hri, int rotation)
{
	return fDrawBarcodeIMB(m_nBgtId, data, xPos, yPos, hri, rotation);
}

int CMPosControllerLabelPrinter::drawBarcodeMSI(LPCTSTR data, int xPos, int yPos, int widthNarrow, int widthWide, int height, int checkDigit, BOOL printCheckDigit, int hri, int rotation)
{
	return fDrawBarcodeMSI(m_nBgtId, data, xPos, yPos, widthNarrow, widthWide, height, checkDigit, printCheckDigit, hri, rotation);
}

int CMPosControllerLabelPrinter::drawBarcodePlessey(LPCTSTR data, int xPos, int yPos, int widthNarrow, int widthWide, int height, BOOL printCheckDigit, int hri, int rotation)
{
	return fDrawBarcodePlessey(m_nBgtId, data, xPos, yPos, widthNarrow, widthWide, height, printCheckDigit, hri, rotation);
}

int CMPosControllerLabelPrinter::drawBarcodeTLC39(LPCTSTR data, int xPos, int yPos, int widthNarrow, int widthWide, int height, int rowHeightOfMicroPDF417, int narrowWidthOfMicroPDF417, int rotation)
{
	return fDrawBarcodeTLC39(m_nBgtId, data, xPos, yPos, widthNarrow, widthWide, height, rowHeightOfMicroPDF417, narrowWidthOfMicroPDF417, rotation);
}

int CMPosControllerLabelPrinter::drawBarcodeRSS(LPCTSTR data, int xPos, int yPos, int barcodeType, int magnification, int separatorHeight, int height, int segmentWidth, int rotation)
{
	return fDrawBarcodeRSS(m_nBgtId, data, xPos, yPos, barcodeType, magnification, separatorHeight, height, segmentWidth, rotation);
}

int CMPosControllerLabelPrinter::drawBlock(int startPosX, int startPosY, int endPosX, int endPosY, LPCTSTR option, int thickness)
{
	return fDrawBlock(m_nBgtId, startPosX, startPosY, endPosX, endPosY, option, thickness);
}

int CMPosControllerLabelPrinter::drawCircle(int startPosX, int startPosY, int size, int multiplier)
{
	return fDrawCircle(m_nBgtId, startPosX, startPosY, size, multiplier);
}

int CMPosControllerLabelPrinter::drawImageFile(LPCTSTR fileName, int startPosX, int startPosY, int width, int threshold, int ditheringType, int compressType)
{
	return fDrawImageFile(m_nBgtId, fileName, startPosX, startPosY, width, threshold, ditheringType, compressType);
}

int CMPosControllerLabelPrinter::drawBase64Image(LPCTSTR base64String, int startPosX, int startPosY, int width, int threshold, int dithering, int compressType)
{
	return fDrawBase64Image(m_nBgtId, base64String, startPosX, startPosY, width, threshold, dithering, compressType);
}

int CMPosControllerLabelPrinter::setCharacterset(int characterset, int internationalCharset)
{
	return fSetCharacterset(m_nBgtId, characterset, internationalCharset);
}

int CMPosControllerLabelPrinter::setPrintingType(char printingType)
{
	return fSetPrintingType(m_nBgtId, printingType);
}

int CMPosControllerLabelPrinter::setMargin(int horizontalMargin, int verticalMargin)
{
	return fSetMargin(m_nBgtId, horizontalMargin, verticalMargin);
}

int CMPosControllerLabelPrinter::setLength(int labelLength, int gapLength, LPCTSTR mediaType, int offsetLength)
{
	return fSetLength(m_nBgtId, labelLength, gapLength, mediaType, offsetLength);
}

int CMPosControllerLabelPrinter::setWidth(int labelWidth)
{
	return fSetWidth(m_nBgtId, labelWidth);
}

int CMPosControllerLabelPrinter::setSpeed(int speed)
{
	return fSetSpeed(m_nBgtId, speed);
}

int CMPosControllerLabelPrinter::setDensity(int density)
{
	return fSetDensity(m_nBgtId, density);
}

int CMPosControllerLabelPrinter::setOrientation(char orientaion)
{
	return fSetOrientation(m_nBgtId, orientaion);
}

int CMPosControllerLabelPrinter::setAutoCutter(BOOL enableAutoCutter, int cuttingPeriod)
{
	return fSetAutoCutter(m_nBgtId, enableAutoCutter, cuttingPeriod);
}

int CMPosControllerLabelPrinter::setRewinder(BOOL enable)
{
	return fSetRewinder(m_nBgtId, enable);
}

int CMPosControllerLabelPrinter::setupRFID(int rfidType, int numberOfRetries, int numberOfLabel, int radioPower)
{
	return fSetupRFID(m_nBgtId, rfidType, numberOfRetries, numberOfLabel, radioPower);
}

int CMPosControllerLabelPrinter::setEPCDataStructure(int totalSize, LPCTSTR fieldSizes)
{
	return fSetEPCDataStructure(m_nBgtId, totalSize, fieldSizes);
}

int CMPosControllerLabelPrinter::setRFIDPosition(int transPosition)
{
	return fSetRFIDPosition(m_nBgtId, transPosition);
}

int CMPosControllerLabelPrinter::calibrateRFID()
{
	return fCalibrateRFID(m_nBgtId);
}

int CMPosControllerLabelPrinter::writeRFID(int dataType, int startingBlockNumber, int dataLength, LPCTSTR data)
{
	return fWriteRFID(m_nBgtId, dataType, startingBlockNumber, dataLength, data);
}

int CMPosControllerLabelPrinter::setRFIDPassword(LPCTSTR oldAccessPwd, LPCTSTR oldKillPwd, LPCTSTR newAccessPwd, LPCTSTR newKillPwd)
{
	return fSetRFIDPassword(m_nBgtId, oldAccessPwd, oldKillPwd, newAccessPwd, newKillPwd);
}

int CMPosControllerLabelPrinter::lockRFID()
{
	return fLockRFID(m_nBgtId);
}

LPCTSTR CMPosControllerLabelPrinter::getStatisticsData(int Info)
{
	return fGetStatisticsData(m_nBgtId, Info);
}

LPCTSTR CMPosControllerLabelPrinter::getSupportedSpeeds()
{
	return fGetSupportedSpeeds(m_nBgtId);
}

int CMPosControllerLabelPrinter::getPrinterDPI()
{
	return fGetPrinterDPI(m_nBgtId);
}

int CMPosControllerLabelPrinter::getMaxWidth()
{
	return fGetMaxWidth(m_nBgtId);
}

LPCTSTR CMPosControllerLabelPrinter::getModelName()
{
	return fGetModelName(m_nBgtId);
}

LPCTSTR CMPosControllerLabelPrinter::getFirmwareVersion()
{
	return fGetFirmwareVersion(m_nBgtId);
}

