// WoosimPrinterLib.h : header file for the WoosimPrinter DLL

#pragma once

#define MSG_RECEIVE_CHECK		_T("WOOSIM_PRT_OK")

#define DATA					0x44		// Response data from printer (ex. card data , model name, etc)
#define STATUS_ANSWER			0x53		// Response of printer status request

// Common return value
#define SUCCESS									1
#define ALREADY_OPENED							-1
#define TIMEOUT									-7
#define NOT_OPEN_THE_PORT						-11

// Serial and Bluetooth connection error return value
#define UNABLE_TO_OPEN_THE_PORT					-2
#define UNABLE_TO_CONFIGURE_THE_SERIAL_PORT		-3 
#define UNABLE_TO_SET_THE_TIMEOUT_PARAMETERS	-4

// Wireless network connection error return value
#undef SOCKET_ERROR
#define SOCKET_ERROR							-2
#define CONNECT_FAIL							-3

// USB connection error return value
#define UNABLE_TO_MAKE_CONNECTION				-2
#define UNABLE_TO_GET_INFOMATION				-3 
#define NOT_WOOSIM_PRINTER						-4
#define NO_TARGET_PRINTER						-5

// Barcode type
#define UPCA				65
#define UPCE				66
#define EAN13				67
#define EAN8				68
#define CODE39				69
#define ITF					70
#define CODABAR				71
#define CODE93				72
#define CODE128				73

// Printer dots for each width
#define _1INCH				192
#define _2INCH				384
#define _3INCH				576
#define _4INCH				832

// MCU type
#define MCU_M16C			0
#define MCU_ARM				1
#define MCU_RX				2


/******************************************************************************************
	DLL export/import functions
******************************************************************************************/
#ifdef DLL_EXPORT
#define DLL_API __declspec(dllexport)
#else
#define DLL_API __declspec(dllimport)
#endif

// Device communication API
extern "C" DLL_API int  __stdcall ConnectSerialPrinter(char *pPortName, int baudRate = 57600, int timeoutMsec = 1000, BOOL bProtocol = FALSE);
extern "C" DLL_API int  __stdcall ConnectUSBPrinter(int timeoutMsec = 1000, BOOL bProtocol = FALSE);
extern "C" DLL_API int  __stdcall ConnectWirelessPrinter(char *pIPAddress, int port, int timeoutMsec = 5000, BOOL bProtocol = FALSE);
extern "C" DLL_API BOOL __stdcall ClosePrinterConnection();
// Send directly command to device without using printing data buffer
extern "C" DLL_API void __stdcall EnterMSRMode(int n);
extern "C" DLL_API void __stdcall CancelMSRMode();
extern "C" DLL_API void __stdcall EnterSCRMode();
extern "C" DLL_API void __stdcall CancelSCRMode();
// Require information from device without using printing data buffer
extern "C" DLL_API void __stdcall GetPrinterModelName();
extern "C" DLL_API void __stdcall GetFirmwareVersion();
extern "C" DLL_API int  __stdcall GetPrinterStatus(int timeoutMsec);
extern "C" DLL_API int  __stdcall GetPrinterStatusEx(int timeoutMsec);

// Printing data buffer handling
extern "C" DLL_API int  __stdcall PrintSpool(BOOL bDelete = TRUE);
extern "C" DLL_API void __stdcall ClearSpool();
extern "C" DLL_API int  __stdcall GetSpoolSize();
extern "C" DLL_API BYTE* __stdcall GetSpoolBuffer();

// Append command & data to the printing data buffer
extern "C" DLL_API int  __stdcall ControlCommand(BYTE *data, int length);
extern "C" DLL_API void __stdcall TextSaveSpool(char *text);
extern "C" DLL_API void __stdcall InitPrinterStatus();
extern "C" DLL_API void __stdcall PrintData();
extern "C" DLL_API void __stdcall PrintDotFeed(int dots);
extern "C" DLL_API void __stdcall PrintLineFeed(int lines);
extern "C" DLL_API void __stdcall SetCharCodeTable(int n, int mcu);
extern "C" DLL_API void __stdcall SetFontSize(int n);
extern "C" DLL_API void __stdcall SetTextAlignment(int n);
extern "C" DLL_API void __stdcall SetTextStyle(int underline, BOOL bold, int width, int height, BOOL reverse);
extern "C" DLL_API void __stdcall InitLineSpace();
extern "C" DLL_API void __stdcall SetLineSpace(int n);
extern "C" DLL_API void __stdcall SetAbsPosition(int distance);
extern "C" DLL_API void __stdcall SetCharSpace(int n);
extern "C" DLL_API void __stdcall SetUpsideDown(BOOL set);
extern "C" DLL_API void __stdcall SetFontForTTF(char *ttfFile);
extern "C" DLL_API int  __stdcall PrintSpoolForTTF(char* data, BYTE fontWidth, BYTE fontHeight);
extern "C" DLL_API void __stdcall SetPositionFromMark(int distance);
extern "C" DLL_API void __stdcall FeedToMark();
extern "C" DLL_API void __stdcall CutPaper(int mode);
// Page mode
extern "C" DLL_API void __stdcall SetPageMode();
extern "C" DLL_API void __stdcall InitPageMode(int x, int y, int width, int height);
extern "C" DLL_API void __stdcall Page_DrawLine(int x1, int y1, int x2, int y2, int thickness);
extern "C" DLL_API void __stdcall Page_DrawBox(int x, int y, int width, int height, int thickness);
extern "C" DLL_API void __stdcall Page_DrawEllipse(int x, int y, int radiusW, int radiusH, int thickness);
extern "C" DLL_API void __stdcall Page_DotFeed(int dots);
extern "C" DLL_API void __stdcall Page_LineFeed(int lines);
extern "C" DLL_API void __stdcall Page_Newline();
extern "C" DLL_API void __stdcall Page_ClearCurrentData();
extern "C" DLL_API void __stdcall Page_SetArea(int x, int y, int width, int height);
extern "C" DLL_API void __stdcall Page_SetDirection(int n);
extern "C" DLL_API void __stdcall Page_SetPosition(int x, int y);
extern "C" DLL_API void __stdcall Page_Print();
extern "C" DLL_API void __stdcall Page_SetStandardMode();
extern "C" DLL_API void __stdcall Page_Print_StandardMode();
// Image
extern "C" DLL_API void __stdcall NormalBmpSaveSpool(char* bmpFilePath);
extern "C" DLL_API void __stdcall NormalAdjustBmpSaveSpool(char* bmpFilePath, int contrast, int brightness);
extern "C" DLL_API void __stdcall CompressedBmpSaveSpool(char *bmpFilePath);
extern "C" DLL_API void __stdcall CompressedAdjustBmpSaveSpool(char *bmpFilePath, int contrast, int brightness);
extern "C" DLL_API void __stdcall LoadLogoSaveSpool(int n);
// Barcode 
extern "C" DLL_API void __stdcall OneDimensionBarcodeSaveSpool(BYTE barcodeType, int width, int height, BOOL bHri, char *barcodeData);
extern "C" DLL_API void __stdcall PDF417SaveSpool(int width, int column, int level, int ratio, char *barcodeData, BOOL bHri);
extern "C" DLL_API void __stdcall DataMatrixSaveSpool(int height, int width, int module, char *barcodeData);
extern "C" DLL_API void __stdcall QRCodeSaveSpool(int version, char level, int module, char *barcodeData);
extern "C" DLL_API void __stdcall MicroPDF417SaveSpool(int width, int column, int row, int ratio, char *barcodeData, BOOL bHri);
extern "C" DLL_API void __stdcall TruncatedPDF417SaveSpool(int width, int column, int level, int ratio, char *barcodeData, BOOL bHri);
extern "C" DLL_API void __stdcall MaxicodeSaveSpool(int mode, char *barcodeData);
extern "C" DLL_API void __stdcall GS1DatabarSaveSpool(int type, int n, char *barcodeData);
