//-------------------------------------------------------------------------//
// ReaderDll  v2.51 head file
//-------------------------------------------------------------------------//
#include <windows.h>

#define  EXPORT  extern "C" __declspec (dllexport)

//-------------------------------------------------------------------------//
#define    ID_MOD_1D                    1   // SE950,CCD 1D 
#define    ID_MOD_1D_ELR                2   // 1D Long Laser
#define    ID_MOD_2D                    4   // SE4407 2D
#define    ID_MOD_TI_RFID              16   // Texas Instrument RFID
#define    ID_MOD_RFID                 32   // RFID
#define    ID_MOD_2D_4507              64   // SE4507 2D
#define    ID_MOD_1D_955              128   // SE955  1D
#define    ID_MOD_MP_RFID             256   // Microprogram RFID

//-------------------------------------------------------------------------//
#define    NO_ACTIVE_DEVICE            0    // none
#define    DC_READER_BC                7    // barcode reader
#define    DC_READER_RFID              32   // RFID reader
#define    ALL_DEVICE                  255  // all device

//-------------------------------------------------------------------------//
#define    CMD_MAXLEN                  1024
#define    DATA_MAXLEN                 4096

//-------------------------------------------------------------------------//
#define    READ_UID                    1
#define    READ_DATA                   2

//-------------------------------------------------------------------------//
// error code
#define ERROR_PARAMETER               0x00000004

#define    W_READER_ALREADY_INIT       -51 

#define    E_READER_UNKNOWN_ERROR         0
#define    E_READER_NOT_INIT           -101
#define    E_READER_INIT_FAILED        -102
#define    E_NO_READER_INSTALLED       -103
#define    E_READER_BC_RESET_FAILED    -111
#define    E_READER_RFID_RESET_FAILED  -112
#define    E_READER_RESET_FAILED       -113
#define    E_READER_GET_PARAM_FAILED   -121
#define    E_READER_SET_PARAM_FAILED   -122
#define    E_READER_NO_SPEC_DC_BC      -131
#define    E_READER_NO_SPEC_DC_RFID    -132
#define    E_READER_NO_SPEC_DC         -133
#define    E_SOUND_INVALID_INDEX       -241
#define    E_SOUND_INVALID_PATH        -242
#define    E_SOUND_PALY_FAILED         -243
#define    E_VIBRATOR_INVALID_MODE     -251
#define    E_VIBRATOR_INVALID_DURATION -252
#define    E_WRONG_READER_TYPE         -253

#define    E_TAG_READ_FAILED           -272
#define    E_TAG_VALUE_OVER_RANGE      -273
#define    E_TAG_INVALID_LENGTH        -274
#define    E_TAG_GET_DATA_FAILED       -275
#define    E_TAG_WRITE_FAILED          -276
#define    E_TAG_CANNOT_WRITE          -277
#define    E_TAG_NO_TAG                -278
#define    E_TAG_WRITE_TIMEOUT         -279
#define    E_TAG_CANNOT_READ           -280
#define    E_TAG_READ_TIMEOUT          -281

#define    E_BUFF_IS_TOO_SMALL         -300

//-------------------------------------------------------------------------//
#define    DECODE_BC                   TEXT("DecodeEventBC")
#define    DECODE_MSG                  TEXT("WM_DECODEDATA")



typedef  INT (CALLBACK *INITREADER)(VOID); //InitReader
typedef  INT (CALLBACK *GETREADERTYPE)(VOID); //GetReaderType
typedef  INT (CALLBACK *GETACTIVEDEVICE)(VOID); //GetActiveDevice
typedef  INT (CALLBACK *SETACTIVEDEVICE)(INT actDC); //SetActiveDevice
typedef  INT (CALLBACK *GETDECODEDATA)(BYTE *buf, INT bufSize); //GetDecodeData
typedef  INT (CALLBACK *GETDECODETYPE)(VOID); //GetDecodeType
typedef  INT (CALLBACK *RESETREADERTODEFAULT)(INT readerType); //ResetReaderToDefault
typedef  INT (CALLBACK *READBARCODEDATA)(INT *codeType, CHAR *outBuf, INT bufSize, INT timeout); //ReadBarcodeData
typedef  INT (CALLBACK *BEEPER)(INT mode, BYTE *path); //Beeper
typedef  INT (CALLBACK *GETDLLVER)(CHAR *buf, INT bufSize); //GetDllVer
typedef  INT (CALLBACK *GETOUTPUTRECORD)(INT target, CHAR *buf, INT bufSize); //GetOutputRecord
typedef  INT (CALLBACK *GETDECODERVERSION)(INT target, CHAR *buf, INT bufSize); //GetDecoderVersion 
typedef  INT (CALLBACK *CONVERTBYTETOWIDECHAR)(CHAR *inBuf, INT inBufLen, WCHAR *outBuf, INT outBufLen);
typedef  INT (CALLBACK *INITREADERFORNET)(VOID);

//================= 2D SE4507 engine ========================================================================
typedef INT (CALLBACK *UPC_2D_4507)(INT rw, INT *enableUpcA, INT *enableUpcE, INT *enableUpcE1, INT *enableAddons, INT *addonsRedundancy, INT *transmitUpcACheckDigit, INT *transmitUpcECheckDigit, INT *transmitUpcE1CheckDigit, INT *preambleUpcA, INT *preambleUpcE, INT *preambleUpcE1, INT *convertUpcEToA, INT *convertUpcE1ToA, INT *uccCouponExtendedCode);
typedef INT (CALLBACK *EANJAN_2D_4507)(INT rw, INT *enableEanJan8, INT *enableEanJan13, INT *enableBooklandEan, INT *enableAddons, INT *addonsRedundancy, INT *enableEanJan8Extended, INT *uccCouponExtendedCode);
typedef INT (CALLBACK *CODE39_2D_4507)(INT rw, INT *enable, INT *enableTrioptic, INT *convertToCode32, INT *prefixCode32, INT *checkDigitVerification, INT *transmitCheckDigit, INT *fullASCII, INT *length1, INT *length2);
typedef INT (CALLBACK *CODE128_2D_4507)(INT rw, INT *enable, INT *enableGS1_128, INT *enableISBT128, INT *enableIsbtConcatenation, INT *isbtConcatenationRedundancy);
typedef INT (CALLBACK *CODE93_2D_4507)(INT rw, INT *enable, INT *length1, INT *length2);
typedef INT (CALLBACK *CODE11_2D_4507)(INT rw, INT *enable, INT *numberOfCheckDigits, INT *transmitCheckDigit, INT *length1, INT *length2);
typedef INT (CALLBACK *INTERLEAVED2OF5_2D_4507)(INT rw, INT *enable, INT *length1, INT *length2, INT *checkDigitVerification, INT *transmitCheckDigit, INT *convertToEan13);                       
typedef INT (CALLBACK *INDUSTRIAL2OF5_2D_4507)(INT rw, INT *enable, INT *length1, INT *length2);
typedef INT (CALLBACK *CODABAR_2D_4507)(INT rw, INT *enable, INT *length1, INT *length2, INT *enableCLSIEditing, INT *enableNOTISEditing);
typedef INT (CALLBACK *MSI_2D_4507)(INT rw, INT *enable, INT *length1, INT *length2, INT *checkDigitVerification, INT *transmitCheckDigit, INT *checkDigitAlgorithm);                           
typedef INT (CALLBACK *POSTALCODE_2D_4507)(INT rw, INT *enableUSPostnet, INT *enableUSPlanet, INT *enableUKPostal, INT *transmitUKCheckDigit, INT *enableJapanPostal, INT *enableAustralianPostal, INT *enableDutchPostal, INT *transmitUSCheckDigit);
typedef INT (CALLBACK *GS1_DATABAR_2D_4507)(INT rw, INT *enableDataBarOmndirectional, INT *enableGS1_DataBarLimited, INT *transmitGS1_DataBarExpanded, INT *convertToUpcEan);
typedef INT (CALLBACK *COMPOSITE_2D_4507)(INT rw, INT *enableCC_C, INT *enableCC_AB, INT *enableTLC39, INT *enableUpcMode, INT *enableBeepMode, INT *enableEmulationMode);                       
typedef INT (CALLBACK *SYMBOLOGIES_2D_4507)(INT rw, INT *enablePDF417, INT *enableMicroPDF417, INT *enableCode128Emulation, INT *enableDataMatrix, INT *enableDataMatrixInverse, INT *decodeMirrorImage, INT *enableMaxiCode, INT *enableQRCode, INT *enableQRCodeInverse, INT *enableMicroQR, INT *enableAztec, INT *enableAztecInverse);
typedef INT (CALLBACK *MATRIX2OF5_2D_4507)(INT rw, INT *enable, INT *length1, INT *length2, INT *redundancy, INT *checkDigitVerification, INT *transmitCheckDigit);
typedef INT (CALLBACK *CHINESE2OF5_2D_4507)(INT rw, INT *enable);
typedef INT (CALLBACK *MACROPDF_2D_4507)(INT rw, INT *modeTransmitDecode, INT *transmitControlHeader, INT *enableEscapeChar);
typedef INT (CALLBACK *MISCELLANEOUSOPTION_2D_4507)(INT rw, INT *transmitCodeIdChar, INT *sendNoReadMessage);
typedef INT (CALLBACK *USERPREFERENCES_2D_4507)(INT rw, INT *laserOnTime, INT *timeoutBetweenSameBarcode, INT *triggerMode);
typedef INT (CALLBACK *SYMBOLOGYSECURITYLEVEL_2D_4507)(INT rw, INT *redundancyLevel, INT *securityLevel, INT *interCharGapSize);


//================= 1D, SE955  ========================================================================
typedef INT (CALLBACK *USERPREFERENCES_1D_SE955)(INT rw, INT *laserOnTime, INT *scanAngle, INT *timeoutBetweenSameBarcode, INT *redundancyLevel, INT *bidirectionalRedundancy, INT *aimDuration, INT *triggerMode);
typedef INT (CALLBACK *UPC_1D_SE955)(INT rw, INT *enableUpcA, INT *enableUpcE, INT *enableUpcE1, INT *enableAddons, INT *addonsRedundancy, INT *transmitUpcACheckDigit, INT *transmitUpcECheckDigit, INT *transmitUpcE1CheckDigit, INT *preambleUpcA, INT *preambleUpcE, INT *preambleUpcE1, INT *convertUpcEToA, INT *convertUpcE1ToA, INT *uccCouponExtendedCode, INT *upcEanSecurityLevel);
typedef INT (CALLBACK *EANJAN_1D_SE955)(INT rw, INT *enableEanJan8, INT *enableEanJan13, INT *enableBooklandEan, INT *enableAddons, INT *addonsRedundancy, INT *enableEanJan8Extended, INT *uccCouponExtendedCode, INT *upcEanSecurityLevel);
typedef INT (CALLBACK *CODE39_1D_SE955)(INT rw, INT *enable, INT *enableTrioptic, INT *convertToCode32, INT *prefixCode32, INT *checkDigitVerification, INT *transmitCheckDigit, INT *fullASCII, INT *length1, INT *length2);
typedef INT (CALLBACK *CODE93_1D_SE955)(INT rw, INT *enable, INT *length1, INT *length2);                                   
typedef INT (CALLBACK *INTERLEAVED2OF5_1D_SE955)(INT rw, INT *enable, INT *length1, INT *length2, INT *checkDigitVerification, INT *transmitCheckDigit, INT *convertToEan13);
typedef INT (CALLBACK *INDUSTRIAL2OF5_1D_SE955)(INT rw, INT *enable, INT *length1, INT *length2);                                        
typedef INT (CALLBACK *CODABAR_1D_SE955)(INT rw, INT *enable, INT *length1, INT *length2, INT *enableCLSIEditing, INT *enableNOTISEditing);
typedef INT (CALLBACK *MSI_1D_SE955)(INT rw, INT *enable, INT *length1, INT *length2, INT *checkDigitVerification, INT *transmitCheckDigit, INT *checkDigitAlgorithm);                                
typedef INT (CALLBACK *GS1_DATABAR_1D_SE955)(INT rw, INT *enableDataBarOmndirectional, INT *enableGS1_DataBarLimited, INT *transmitGS1_DataBarExpanded, INT *convertToUpcEan);
typedef INT (CALLBACK *CODE128_1D_SE955)(INT rw, INT *enable, INT *enableGS1_128, INT *enableISBT128);
typedef INT (CALLBACK *MISCELLANEOUSOPTION_1D_SE955)(INT rw, INT *transmitCodeIdChar, INT *sendNoReadMessage);
typedef INT (CALLBACK *CHINESE2OF5_1D_SE955)(INT rw, INT *enable);
typedef INT (CALLBACK *CODE11_1D_SE955)(INT rw, INT *enable, INT *numberOfCheckDigits, INT *transmitCheckDigit, INT *length1, INT *length2);

//================= Others  ========================================================================
typedef INT (CALLBACK *NOTIFICATIONSETTINGS)(INT rw, INT *goodRead, INT *enableVibrator, INT *vibrationTime, INT *ledDuration);                    
typedef INT (CALLBACK *DATAOUTPUTSETTINGS)(INT rw, INT *enableKeyboardEmulation, INT *autoEnterWay, INT *autoEnterChar, INT *showCodeType, INT *showCodeLen, CHAR *prefixCode, INT prefixCodeLen, CHAR *suffixCode, INT suffixCodeLen);



EXPORT int CALLBACK InitReaderForNet(void);
EXPORT int CALLBACK InitReader(void);
EXPORT int CALLBACK GetReaderType(void);
EXPORT int CALLBACK GetActiveDevice(void);
EXPORT int CALLBACK SetActiveDevice(int target);
EXPORT int CALLBACK GetDecodeData(char *buf, int bufSize);
EXPORT int CALLBACK GetDecodeTagType(void);  //RFID
EXPORT int CALLBACK ResetReaderToDefault(int target);
EXPORT int CALLBACK GetOutputRecord(int target, char *buf, int bufSize);
EXPORT int CALLBACK ReadBarcodeData(int *codeType, char *outBuf, int bufSize, int timeout);
EXPORT int CALLBACK Beeper(int mode, char *path);
EXPORT int CALLBACK SetVibrator(int mode, int duration);
EXPORT int CALLBACK GetDecodeType(void);
EXPORT int CALLBACK GetDllVer(char *buf, int bufSize);
EXPORT int CALLBACK GetDecoderVersion(int target, char *buf, int bufSize);
EXPORT int CALLBACK UpdateSE4507Decoder(char *fileName, HWND progressBar);
EXPORT int CALLBACK ConvertByteToWideChar(char *inBuf, int inBufLen, wchar_t *outBuf, int outBufLen);
EXPORT int CALLBACK GetOutputRecordWideChar(int target, short *buf, int bufSize);

//================= 2D SE4507 engine ========================================================================
EXPORT int CALLBACK Upc_2D_4507(int rw, int *enableUPC_A, int *enableUPC_E, int *enableUPC_E1, int *UPC_EAN_JAN_decodeSupplementals, int *UPC_EAN_JAN_supplementalsRedundancy, int *transmitUPC_AcheckDigit, int *transmitUPC_EcheckDigit, int *transmitUPC_E1checkDigit, int *preambleUPC_A, int *preambleUPC_E, int *preambleUPC_E1, int *convertUPC_EtoA, int *convertUPC_E1ToA, int *uccCouponExtendedCode);
EXPORT int CALLBACK EanJan_2D_4507(int rw, int *enableEAN8_JAN8, int *enableEAN13_JAN13, int *enableBooklandEAN, int *UPC_EAN_JAN_decodeSupplementals, int *UPC_EAN_JAN_supplementalsRedundancy, int *EAN8_JAN8_extend, int *uccCouponExtendedCode);
EXPORT int CALLBACK Code39_2D_4507(int rw, int *enable, int *trioptic, int *code39ToCode32, int *code32Prefix, int *checkDigitVerification, int *transmitCheckDigit, int *fullASCII, int *length1, int *length2);
EXPORT int CALLBACK Code128_2D_4507(int rw, int *enable, int *enableGS1_128, int *isbt128, int *enableIsbtConcatenation, int *isbtConcatenationRedundancy);
EXPORT int CALLBACK Code93_2D_4507(int rw, int *enable, int *length1, int *length2);
EXPORT int CALLBACK Code11_2D_4507(int rw, int *enable, int *numberOfCheckDigits, int *transmitCheckDigit, int *length1, int *length2);
EXPORT int CALLBACK Interleaved2Of5_2D_4507(int rw, int *enable, int *length1, int *length2, int *checkDigitVerification, int *transmitCheckDigit, int *convertToEAN13);
EXPORT int CALLBACK Industrial2Of5_2D_4507(int rw, int *enable, int *length1, int *length2);
EXPORT int CALLBACK Codabar_2D_4507(int rw, int *enable, int *length1, int *length2, int *clsiEditing, int *notisEditing);
EXPORT int CALLBACK Msi_2D_4507(int rw, int *enable, int *length1, int *length2, int *checkDigitVerification, int *transmitCheckDigit, int *checkDigitAlgorithm);                           
EXPORT int CALLBACK PostalCode_2D_4507(int rw, int *usPostnet, int *usPlanet, int *ukPostal, int *transmitUKcheckDigit, int *japanPostal, int *australianPostal, int *dutchPostal, int *transmitUScheckDigit);
EXPORT int CALLBACK GS1_DataBar_2D_4507(int rw, int *enableDataBarOmndirectional, int *enableGS1_DataBarLimited, int *transmitGS1_DataBarExpanded, int *convertToUpcEan);
EXPORT int CALLBACK Rss_2D_4507(int rw, int *rss14, int *rssUmited, int *rssExpanded, int *convertToUPC_EAN);
EXPORT int CALLBACK Composite_2D_4507(int rw, int *cc_c, int *cc_ab, int *tlc39, int *upcMode, int *beepMode, int *uccEAN128EmulationMode);
EXPORT int CALLBACK Symbologies_2D_4507(int rw, int *pdf417, int *microPDF417, int *code128Emulation, int *dataMatrix, int *dataMatrixInverse, int *decodeMirrorImage, int *maxiCode, int *qrCode, int *qrCodeInverse, int *microQR, int *azTech, int *azTechInverse);
EXPORT int CALLBACK SymbologySecurityLevel_2D_4507(int rw, int *redundancy, int *securityLevel, int *interCharGapSize);
EXPORT int CALLBACK MacroPDF_2D_4507(int rw, int *macroPDFTransmit, int *controlHeader, int *escapeChar);
EXPORT int CALLBACK MiscellaneousOption_2D_4507(int rw, int *transmitCodeIdChar, int *sendNoReadMessage);
EXPORT int CALLBACK UserPreferences_2D_4507(int rw, int *laserOnTime, int *timeoutBetweenSameSymbol, int *triggerMode);
EXPORT int CALLBACK Chinese2Of5_2D_4507(int rw, int *enable);
EXPORT int CALLBACK Matrix2Of5_2D_4507(int rw, int *enable, int *length1, int *length2, int *redundancy, int *checkDigitVerification, int *transmitCheckDigit);                                       

//================= 1D, SE955 =========================================================================================
EXPORT int CALLBACK UserPreferences_1D_SE955(int rw, int *laserOnTime, int *scanAngle, int *timeoutBetweenSameSymbol, int *linearCodeTypeSecurityLevels, int *bidirectionalRedundancy, int *aimDuration, int *triggerMode);
EXPORT int CALLBACK Upc_1D_SE955(int rw, int *enableUPC_A, int *enableUPC_E, int *enableUPC_E1, int *UPC_EAN_JAN_decodeSupplementals, int *UPC_EAN_JAN_supplementalsRedundancy, int *transmitUPC_AcheckDigit, int *transmitUPC_EcheckDigit, int *transmitUPC_E1checkDigit, int *preambleUPC_A, int *preambleUPC_E, int *preambleUPC_E1, int *convertUPC_EtoA, int *convertUPC_E1ToA, int *uccCouponExtendedCode, int *upcEanSecurityLevel);
EXPORT int CALLBACK EanJan_1D_SE955(int rw, int *enableEAN8_JAN8, int *enableEAN13_JAN13, int *enableBooklandEAN, int *UPC_EAN_JAN_decodeSupplementals, int *UPC_EAN_JAN_supplementalsRedundancy, int *EAN8_JAN8_extend, int *uccCouponExtendedCode, int *upcEanSecurityLevel);
EXPORT int CALLBACK Code39_1D_SE955(int rw, int *enable, int *trioptic, int *code39ToCode32, int *code32Prefix, int *checkDigitVerification, int *transmitCheckDigit, int *fullASCII, int *length1, int *length2);
EXPORT int CALLBACK Code93_1D_SE955(int rw, int *enable, int *length1, int *length2);                                   
EXPORT int CALLBACK Interleaved2Of5_1D_SE955(int rw, int *enable, int *length1, int *length2, int *checkDigitVerification, int *transmitCheckDigit, int *convertToEAN13);
EXPORT int CALLBACK Industrial2Of5_1D_SE955(int rw, int *enable, int *length1, int *length2);                                        
EXPORT int CALLBACK Codabar_1D_SE955(int rw, int *enable, int *length1, int *length2, int *clsiEditing, int *notisEditing);
EXPORT int CALLBACK Msi_1D_SE955(int rw, int *enable, int *length1, int *length2, int *checkDigitVerification, int *transmitCheckDigit, int *checkDigitAlgorithm);                                
EXPORT int CALLBACK GS1_DataBar_1D_SE955(int rw, int *enableDataBarOmndirectional, int *enableGS1_DataBarLimited, int *transmitGS1_DataBarExpanded, int *convertToUpcEan);
EXPORT int CALLBACK Code128_1D_SE955(int rw, int *enable, int *enableGS1_128, int *isbt128);
EXPORT int CALLBACK MiscellaneousOption_1D_SE955(int rw, int *transmitCodeIdChar, int *sendNoReadMessage);
EXPORT int CALLBACK Chinese2Of5_1D_SE955(int rw, int *enable);
EXPORT int CALLBACK Code11_1D_SE955(int rw, int *enable, int *numberOfCheckDigits, int *transmitCheckDigit, int *length1, int *length2);



      