////////////////////////////////////////////////////////////////////////////////
//
//              Copyright (c) 1993,1994,1995,2005, 2006 X-Rite, Incorporated
//                          3100 44th St. S.W.
//                          Grandville MI 49418
//                          (616) 534-7663
//                          
//                          ALL RIGHTS RESERVED
//
////////////////////////////////////////////////////////////////////////////////
//
//  Module:     XdsIII.H
//
//  Purpose:    This module is the main header file for XdsIII.DLL.
//
////////////////////////////////////////////////////////////////////////////////


#if !defined( _XDSIII_H_ )
#define _XDSIII_H_

////////////////////////////////////////////////////////////////////////////////
// PRE-PROCESSOR DEFINITIONS
#if defined( WIN32 )
	typedef __int64 CONNECTION_HANDLE;
	typedef unsigned short wchar_t;

	#if defined ( NODLL )
		#define DLL 
	#else
		#define DLL             __stdcall
	#endif
#else
	#define DLL
	typedef long long CONNECTION_HANDLE;
#endif
////////////////////////////////////////////////////////////////////////////////
#ifdef __cplusplus
	typedef bool xds_bool;
#else
	typedef unsigned char xds_bool;
#endif

#ifndef NULL
#ifdef __cplusplus
#define NULL    0
#else
#define NULL    ((void *)0)
#endif
#endif

#define XDS_VERSION 3

#if defined( WIN32 )
	#pragma pack(push)
	#pragma pack(1)
#endif


typedef struct _tagEventstruct
{
	unsigned long		ulVersion;
	CONNECTION_HANDLE	hConnection;
	unsigned long		ulListener; 
	unsigned long		ulType;
	unsigned long		ulId;
	unsigned long		ulSubClass;
	unsigned long		ulTimeStampSec;
	unsigned long		ulTimeStampMicroSec;
	unsigned char*		puchData;
	unsigned long		ulDataLength;
	wchar_t*			pwszDesc;
	wchar_t				wszModuleName[128];
	unsigned long		ulModuleLineNumber;
#ifndef SWIG
	void**				ppData;
#else
	unsigned long		ppData;
#endif
}XdsEvent;

#if defined( WIN32 )
	#pragma pack(pop)
#endif

#ifdef __cplusplus
enum EXdsProtocol
#else
enum
#endif
{
	PROTOCOL_NONE = 0,
	PROTOCOL_RCI,
	PROTOCOL_ICP,
	PROTOCOL_BCP,
	
	MAX_PROTOCOL
};

//return "true" to continue through the listener chain
typedef xds_bool (DLL *PFN_LISTENER)( const XdsEvent* pXdsEvent, unsigned long ulListenerData );

#ifdef __cplusplus
enum EXdsEvent
#else
enum
#endif
{
	XDSEVENT_ERROR = 1,
	XDSEVENT_MESSAGE_RECEIVED,
	XDSEVENT_FRAMEWORK,
	XDSEVENT_USER,
	XDSEVENT_RESERVED_DEBUG,
	XDSEVENT_RESERVED_INTERNAL,

	MAX_XDSEVENT
};

typedef enum  
{
	STATUS_CODE_TERMINATOR=1,
	STATUS_CODE_WITH_ONE_WHITESPACE_TERMINATOR,
	STATUS_CODE_WITH_TWO_WHITESPACES_TERMINATOR,
	CR_TERMINATOR,
	LF_TERMINATOR,
	CRLF_TERMINATOR,
	NONE_TERMINATOR,
	ACK_TERMINATOR,
	TIMEOUT_TERMINATOR,
	ASTERISK_TERMINATOR,

	INVALID_TERMINATOR
}MESSAGE_TERMINATOR;

#ifdef __cplusplus
enum EXdsErrorId
#else
enum
#endif 
{
	ERROR_ADD_LISTENER = 1,								//1		//Error while trying to add a listener.
	ERROR_REMOVE_LISTENER,								//2		//Error while trying to remove a listener.
	ERROR_CONNECT_FAILED,								//3		//Connection failed.
	ERROR_UNABLE_TO_DISCONNECT,							//4		//Unable to disconnect.     
	ERROR_SEND_FAILED,									//5		//Send failed.               
	ERROR_SEND_AND_RECEIVE_FAILED,						//6		//Send and receive failed.   
	ERROR_PROCESS_DATA_FAILED,							//7		//Process data failed.                         
	ERROR_UNABLE_TO_SET_MSG_TIMEOUT,					//8		//Unable to set message timout.  
	ERROR_UNABLE_TO_SET_MSG_TERMINATOR,					//9		//Unable to set message terminator.
	ERROR_UNABLE_TO_GET_MSG_TERMINATOR,					//10	//Unable to get message terminator.
	ERROR_UNABLE_TO_FLUSH_INPUT_BUFFER,					//11	//Unable to flush input buffer.
	ERROR_UNABLE_TO_CREATE_DIRECTORY,					//12	//Unable to create directory.
	ERRROR_UNABLE_TO_DESTROY_CONNECTION,				//13	//Unable to destroy connection.
	ERROR_CONNECTION_DISCONNECTED,						//14	//Connection disconnected.
	ERROR_FUNCTION_NOT_SUPPORTED,						//15	//Function not supported.
	MAX_ERROR_TYPE_API,

	ERROR_ADDIN	= 1000,
	ERROR_DRIVER = 2000,
	ERROR_DRIVER_CRITICAL,
	ERROR_DRIVER_INSTRUMENT,
	
	JNI_ERROR_ARRAY_INDEX_OUT_OF_BOUNDS_EXCEPTION=0x00010000,
	JNI_ERROR_NULL_POINTER,

	MAX_ERROR_TYPE=0x80000000	
		
	// User errors of type EVENT_USER should be greater than MAX_ERROR_TYPE 	
};

#ifdef __cplusplus
enum EXdsErrorSubclass
#else
enum
#endif 
{
	ERROR_SUBCLASS_DEVICE_IO_CONTROL_FAILED = 1,						//1		//Device IO control failed.
	ERROR_SUBCLASS_CREATE_FILE_FAILED,									//2		//Create file failed.
	ERROR_SUBCLASS_READ_FILE_FAILED,									//3		//Read file failed.
	ERROR_SUBCLASS_INVALID_LISTENER_PROC,								//4		//Invalid listener proc.
	ERROR_SUBCLASS_INVALID_EVENT_TYPE,									//5		//Invalid event type.
	ERROR_SUBCLASS_INVALID_LISTENER_HANDLE,								//6		//Invalid listener handle.
	ERROR_SUBCLASS_BAD_PORT,											//7		//Invalid port.
	ERROR_SUBCLASS_BAD_BAUDRATE,										//8		//Invalid baud rate.
	ERROR_SUBCLASS_BAD_PARITY,											//9		//Invalid parity.
	ERROR_SUBCLASS_BAD_STOPBITS,										//10	//Invalid stopbits.
	ERROR_SUBCLASS_BAD_BITS,											//11	//Invalid bits.
	ERROR_SUBCLASS_INVALID_TRANSPORT_HANDLE,							//12	//Invalid transport handle.
	ERROR_SUBCLASS_CLOSE_HANDLE_FAILED,									//13	//Failed to close handle.
	ERROR_SUBCLASS_WRITE_FILE_FAILED,									//14	//Failed to write file.
    ERROR_SUBCLASS_COULD_NOT_CREATE_THREAD,								//15	//Failed to create thread.
    ERROR_SUBCLASS_ALREADY_CONNECTED_TO_DEVICE,							//16	//Device already connected.
	ERROR_SUBCLASS_FAILED_TO_CREATE_USB_PORT,							//17	//Failed to create usb port.
	ERROR_SUBCLASS_FAILED_TO_OPEN_PORT,									//18	//Failed to open port.
	ERROR_SUBCLASS_TIMEOUT,												//19	//Timeout.
	ERROR_SUBCLASS_BUFFER_TOO_SMALL,									//20	//Buffer is too small.
	ERROR_SUBCLASS_NO_DATA_TO_RETRIEVE,									//21	//No data to retrieve.
	ERROR_SUBCLASS_INVALID_PROTOCOL,									//22	//Invalid protocol.
	ERROR_SUBCLASS_NOT_CONNECTED_TO_DEVICE,								//23	//Not connected to device.
	ERROR_SUBCLASS_INVALID_PARAMETER_NULL_SENDBUFFER,					//24	//Invalid parameter send buffer.
	ERROR_SUBCLASS_INVALID_PARAMETER_INVALID_DATA_MODE,					//25	//Invalid paramater data mode.
	ERROR_SUBCLASS_INVALID_PARAMETER_NULL_RECV_BUFFER,					//26	//Invalid parameter receive buffer.
	ERROR_SUBCLASS_INVALID_PARAMETER_ZERO_RECV_BUFFER_LEN,				//27	//Invalid parameter receive buffer length.
	ERROR_SUBCLASS_INVALID_PARAMETER_MESSAGE_TERMINATOR,				//28	//Invalid parameter message terminator.
	ERROR_SUBCLASS_INVALID_PARAMETER_NULL_NUM_BYTES_RECVD,				//29	//Invalid parameter number of bytes received.
	ERROR_SUBCLASS_INVALID_PARAMETER_NULL_STATUS_CODE,					//30	//Invalid parameter status code.
	ERROR_SUBCLASS_NULL_TRANSPORT,										//31	//Invalid transport.
	ERROR_SUBCLASS_INVALID_PARAMETER_NULL_EVENT_MANAGER,				//32	//Invalid parameter event manager.
	ERROR_SUBCLASS_INVALID_PARAMETER_NULL_TRANSPORT,					//33	//Invalid parameter transport.
	ERROR_SUBCLASS_INVALID_PARAMETER_INVALID_PROTOCOL,					//34	//Invalid parameter protocol.
	ERROR_SUBCLASS_PROTOCOL_CANT_SEND_DATA,								//35	//Protocol can not send data.
	ERROR_SUBCLASS_TRANSPORT_CANT_RESET,								//36	//Transport can not reset.
	ERROR_SUBCLASS_PROTOCOL_CANCELLED,									//37	//Protocol cancelled.
	ERROR_SUBCLASS_TRANSPORT_DATA_NOT_AVAILABLE,						//38	//Transport data not available.
	ERROR_SUBCLASS_PROTOCOL_CANT_RECV_DATA,								//39	//Protocol can not receive data.
	ERROR_SUBCLASS_PARITY_NOT_SUPPORTED,								//40	//Parity not supported.
	ERROR_SUBCLASS_STOPBITS_NOT_SUPPORTED,								//41	//Stopbits not supported.
    ERROR_SUBCLASS_INSUFFICIENT_PERMISSIONS_TO_CREATE_DIRECTORY,		//42	//Insufficient permissions to create directory.
	ERROR_SUBCLASS_COMMUNICATION_FAILURE_NEED_TO_RESET_AND_RECONNECT,	//43	//Communication failure. Instrument needs to be reset and reconnected.
	ERROR_SUBCLASS_INVALID_EVENTMANAGER,								//44	//Invalid event manager.
	ERROR_SUBCLASS_INVALID_INTERFACE,									//45	//Invalid interface.
	ERROR_SUBCLASS_UNABLE_TO_WRITE_TO_PIPE,								//46	//Unable to write into the pipe.
	ERROR_SUBCLASS_CANNOT_CREATE_DEVICE,								//47	//Can not create device.
	ERROR_SUBCLASS_INVALID_USB_DEVICE_INTERFACE,						//48	//Invalid USB interface.
	ERROR_SUBCLASS_CANNOT_OPEN_DEVICE,									//49	//Can not open device.
	ERROR_SUBCLASS_CANNOT_SET_CONFIGURATION,							//50	//Can not set configuration.
	ERROR_SUBCLASS_DEVICE_IS_NOT_OPEN,									//51	//Device is not open.
	ERROR_SUBCLASS_CANNOT_GET_INTERFACE_FOR_CONFIGURATION,				//52	//Can not get interface for configuration.
	ERROR_SUBCLASS_CANNOT_OPEN_INTERFACE,								//53	//Can not open interface.
	ERROR_SUBCLASS_CANNOT_FIND_INOUT_PIPE,								//54	//Can not find InOut pipe.
	ERROR_SUBCLASS_DEVICE_DISCONNECTED,									//55	//Device disconnected.
	ERROR_SUBCLASS_DEVICE_INTERFACE_ALREADY_CLOSED,						//56	//Device interface is already closed.
	ERROR_SUBCLASS_COULD_NOT_SET_THREAD_PRIORITY,						//57	//Could not set thread priority.
	ERROR_SUBCLASS_FAILED_TO_ADD_DATA_TO_INTERNAL_BUFFER,				//58	//Failed to add data to the internal buffer.
    ERROR_SUBCLASS_USB_DEVICE_NEEDS_TOBE_UNPLUGED_REPLUGED,				//59	//USB device needs to be removed and reinserted.
	ERROR_SUBCLASS_RESET_PIPES_FAILED,									//60	//Failed to reset pipe.
	ERROR_SUBCLASS_METHOD_NOT_SUPPORTED_IN_ADDIN,						//61	//Method not supported in the addin.
	ERROR_SUBCLASS_INVALID_IPADDRESS,									//62	//Invalid IP address.
	ERROR_SUBCLASS_INVALID_PORT_NUMBER,									//63	//Invalid port number.
	ERROR_SUBCLASS_UNABLE_TO_REGISTER_WITH_REACTOR,						//64	//Unable to register with the reactor.
	ERROR_SUBCLASS_UNABLE_TO_CONNECT_TO_DEVICE,							//65	//Unable to connect to the device.
	ERROR_SUBCLASS_FAILED_TO_HANDLE_SOCKET_EVENTS,						//66	//Failed to handle socket events.
	ERROR_SUBCLASS_FAILED_TO_START_REACTOR_THREAD,						//67	//Failed to start reactor thread.
	ERROR_SUBCLASS_UNABLE_TO_SEND_TO_SOCKET,							//68	//Unable to send to socket.
	ERROR_SUBCLASS_UNABLE_TO_READ_FROM_SOCKET,							//69	//Unable to read from socket.
	ERROR_SUBCLASS_FAILED_TO_START_READ_QUEUE_THREAD,					//70	//Failed to start the read queue thread.
	ERROR_SUBCLASS_ETHERNET_NOT_SUPPORTED,								//71	//Ethernet not supported.
	ERROR_SUBCLASS_UNREGISTER_LISTENER_FAILED_HANDLE_NOT_FOUND,			//72	//Unregister listener failed because the handle was not found.
	ERROR_SUBCLASS_INVALID_PARAMETER_INVALID_DATA_LENGTH,				//73	//Invalid parameter data length.

	ERROR_SUBCLASS_INSTRUMENT_STATUS_CODE = 2000,						//2000	//Status code.
	ERROR_SUBCLASS_QUERY_INSTRUMENT_PERSONALITY,						//2001	//An error occurred while attempting to query the instrument's personality configuration.
	ERROR_SUBCLASS_QUERY_INSTRUMENT_PERSONALITY_TIMEOUT,				//2002	//A timeout error occurred while attempting to query the instrument's personality configuration.
	ERROR_SUBCLASS_QUERY_INSTRUMENT_ILLUMOBS,							//2003	//An error occurred while attempting to query the instrument's illuminant observer configuration.
	ERROR_SUBCLASS_QUERY_INSTRUMENT_ILLUMOBS_TIMEOUT,					//2004	//A timeout error occurred while attempting to query the instrument's illuminant observer configuration.
	ERROR_SUBCLASS_SET_INSTRUMENT_BAUDRATE,								//2005	//An error occurred while attempting to set the instrument's baud rate.
	ERROR_SUBCLASS_SET_INSTRUMENT_BAUDRATE_TIMEOUT,						//2006	//A timeout error occurred while attempting to set the instrument's baud rate.
	ERROR_SUBCLASS_SET_INSTRUMENT_BAUDRATE_NUMBERFORMAT,				//2007	//A number format exception error occurred while attempting to set the instrument's baud rate.				
	ERROR_SUBCLASS_SET_INSTRUMENT_BAUDRATE_DATAFORMATTING,				//2008	//A data formatting error occurred while attempting to set the instrument's baud rate.
	ERROR_SUBCLASS_RECONNECT_SERIAL,									//2009	//An error occurred while attempting to reconnect the serial connection.
	ERROR_SUBCLASS_RECONNECT_SERIAL_TIMEOUT,							//2010	//A timeout error occurred while attempting to reconnect the serial connection.
	ERROR_SUBCLASS_RECONNECT_SERIAL_DATAFORMATTING,						//2011	//A data formatting error occurred while attempting to reconnect the serial connection.
	ERROR_SUBCLASS_GET_INSTRUMENT_BOOTVERSION,							//2012	//An error occurred while attempting to get the instrument's boot version.
	ERROR_SUBCLASS_GET_INSTRUMENT_BOOTVERSION_TIMEOUT,					//2013	//A timeout error occurred while attempting to get the instrument's boot version.
	ERROR_SUBCLASS_CHANGE_TO_BOOTMODE,									//2014	//An error occurred while attempting to put the instrument into boot mode.
	ERROR_SUBCLASS_CHANGE_TO_BOOTMODE_TIMEOUT,							//2015	//A timeout error occurred while attempting to put the instrument into boot mode.
	ERROR_SUBCLASS_RESTORE_SERIAL_BOOTMODE_TIMEOUT,						//2016	//A timeout error occurred while attempting to restore the instrument's connection in boot mode.
	ERROR_SUBCLASS_RESTORE_SERIAL_BOOTMODE,								//2017	//An error occurred while attempting to restore the instrument's connection in boot mode.
	ERROR_SUBCLASS_RESTORE_SERIAL_BOOTMODE_DATAFORMATTING,				//2018	//A data formatting error occurred while attempting to restore the instrument's connection in boot mode.
	ERROR_SUBCLASS_CHANGE_TO_HIGHEST_MAIN_BAUD,							//2019	//A connection error occurred while attempting to change to the instrument's highest baud rate.
	ERROR_SUBCLASS_CHANGE_TO_HIGHEST_MAIN_BAUD_TIMEOUT,					//2020	//A timeout error occurred while attempting to change to the instrument's highest baud rate.
	ERROR_SUBCLASS_CHANGE_TO_HIGHEST_MAIN_BAUD_DATAFORMATTING,			//2021	//A data formatting error occurred while attempting to change to the instrument's highest baud rate.
	ERROR_SUBCLASS_FAILED_TO_SENDANDRECEIVE,							//2022	//Failed to send and receive.
	ERROR_SUBCLASS_VERIFY_INSTRUMENT_MODEL,								//2023	//An error occurred while attempting to verify the instrument model.
	ERROR_SUBCLASS_VERIFY_INSTRUMENT_MODEL_TIMEOUT,						//2024	//A timeout error occurred while attempting to verify the instrument model.
	ERROR_SUBCLASS_VERIFY_INSTRUMENT_MODEL_STATUSCODE,					//2025	//A status code exception occurred while attempting to verify the instrument model.
	ERROR_SUBCLASS_QUERY_INSTRUMENT_SERIALNUMBER,						//2026	//An error occurred while attempting to get the instrument's serial number.
	ERROR_SUBCLASS_QUERY_INSTRUMENT_SERIALNUMBER_TIMEOUT,				//2027	//A timeout error occurred while attempting to get the instrument's serial number.
	ERROR_SUBCLASS_QUERY_INSTRUMENT_FIRMWAREVERSION,					//2028	//An error occurred while attempting to get the instrument's firmware version.
	ERROR_SUBCLASS_QUERY_INSTRUMENT_FIRMWAREVERSION_TIMEOUT,			//2029	//A timeout error occurred while attempting to get the instrument's firmware version.
	ERROR_SUBCLASS_FAILED_TO_RECONNECT_FROM_BOOT,						//2030	//Unable to reconnect after resetting the instrument while in boot mode.
	ERROR_SUBCLASS_FAILED_TO_RECONNECT_AFTER_RESET,						//2031	//Unable to reconnect after resetting the instrument.
	ERROR_SUBCLASS_FAILED_TO_RECONNECT_AFTER_FACTORYRESET,				//2032	//Unable to reconnect after restoring the instrument's factory defaults.
	ERROR_SUBCLASS_FAILED_TO_GET_MEASUREMENTDATA,						//2033	//An error occurred while attempting to get the current measurement data.
	ERROR_SUBCLASS_FAILED_TO_GET_MEASUREMENTDATA_TIMEOUT,				//2034	//A timeout error occurred while attempting to get the current measurement data.
	ERROR_SUBCLASS_QUERY_INSTRUMENT_INFO,								//2035	//An error occurred while attempting to query instrument information.
	ERROR_SUBCLASS_QUERY_INSTRUMENT_INFO_TIMEOUT,						//2036	//A timeout error occurred while attempting to query instrument information.
	ERROR_SUBCLASS_QUERY_INSTRUMENT_INFO_DATAFORMATTING,				//2037	//A data formatting error occurred while attempting to query instrument information.
	ERROR_SUBCLASS_SETUP_SPECTRAL_MEASUREMENT,							//2038	//An error occurred while attempting to configure the instrument for spectral measurements.
	ERROR_SUBCLASS_SEND_CURRENT_MEASUREMENT,							//2039	//A failure occurred while asking the instrument to send its current measurement data.
	ERROR_SUBCLASS_SEND_CURRENT_MEASUREMENT_ILLEGAL_ARGUMENT,			//2040	//An illegal argument exception occurred while attempting to get the instrument's measurement data.
	ERROR_SUBCLASS_SEND_CURRENT_MEASUREMENT_TIMEOUT,					//2041	//A timeout error occurred while attempting to get the instrument's password.
	ERROR_SUBCLASS_QUERY_MESSAGE_TERMINATOR,							//2042	//An error occurred while attempting to get the instrument's message terminator.
	ERROR_SUBCLASS_QUERY_DEFAULT_DATA_GROUP,							//2043	//An error occurred while attempting to query the instrument's default data group configuration.
	ERROR_SUBCLASS_QUERY_DEFAULT_DATA_GROUP_TIMEOUT,					//2044	//A timeout error occurred while attempting to query the instrument's default data group configuration.
	ERROR_SUBCLASS_ENABLE_DISABLE_MANUAL_MEASUREMENTS,					//2045	//An error occurred while attempting to enable/disable manual measurements.
	ERROR_SUBCLASS_ENABLE_DISABLE_MANUAL_MEASUREMENTS_TIMEOUT,			//2046	//A timeout error occurred while attempting to enable/disable manual measurements.
	ERROR_SUBCLASS_GET_INSTRUMENT_PASSWORD,								//2047	//An error occurred while attempting to get the instrument's password.
	ERROR_SUBCLASS_GET_INSTRUMENT_PASSWORD_TIMEOUT,						//2048	//A timeout error occurred while attempting to get the instrument's password.
	ERROR_SUBCLASS_UNRECOGNIZED_INSTRUMENT_TYPE,						//2049	//An error occurred while attempting to get the current measurement data because the instrument type is not recognized.
	ERROR_SUBCLASS_VERIFY_INSTRUMENT_PASSWORD,							//2050	//An error occurred while attempting to verify the instrument's password.
	ERROR_SUBCLASS_VERIFY_INSTRUMENT_PASSWORD_TIMEOUT,					//2051	//A timeout error occurred while attempting to verify the instrument's password.
	ERROR_SUBCLASS_VERIFY_INSTRUMENT_PASSWORD_FAILED,					//2052	//Verification of the instrument's password failed.
	ERROR_SUBCLASS_INVALID_INSTRUMENT_PASSWORD,							//2053	//An error occurred while attempting to get the current measurement data. The instrument returned an invalid response.
	ERROR_SUBCLASS_MEASURE,												//2054	//An error occurred while attempting to measure.
	ERROR_SUBCLASS_QUERY_CALSTRIP_SERIALNUMBER,							//2055	//An error occurred while attempting to get the calibration strip's serial number.
	ERROR_SUBCLASS_QUERY_CALSTRIP_SERIALNUMBER_TIMEOUT,					//2056	//A timeout error occurred while attempting to get the calibration strip's serial number.
	ERROR_SUBCLASS_QUERY_RESPONSE_DELIMITER,							//2057	//An error occurred while attempting to query the instrument's response delimiter configuration.
	ERROR_SUBCLASS_WHITE_CALIBRATION_NOTSUPPORTED,						//2058	//White calibration is not supported.
	ERROR_SUBCLASS_BLACK_CALIBRATION_NOTSUPPORTED,						//2059	//Black calibration is not supported.
	ERROR_SUBCLASS_GRAY_CALIBRATION_NOTSUPPORTED,						//2060  //Gray calibration is not supported.
	ERROR_SUBCLASS_CALIBRATION_FAILED,									//2061	//An error occurred while attempting to calibrate.
	ERROR_SUBCLASS_CALIBRATION_TIMEOUT,									//2062	//A timeout error occurred while attempting to calibrate.
	ERROR_SUBCLASS_FAILED_TO_GET_WHITE_CALIBRATIONDATA,					//2063  //
	ERROR_SUBCLASS_FAILED_TO_GET_WHITE_CALIBRATIONDATA_TIMEOUT,			//2064  //
	ERROR_SUBCLASS_FAILED_TO_GET_BLACK_CALIBRATIONDATA,					//2065  //
	ERROR_SUBCLASS_FAILED_TO_GET_BLACK_CALIBRATIONDATA_TIMEOUT			//2066  //
};	

//EVENT_FRAMEWORK subtypes
#ifdef __cplusplus
enum EXdsFrameworkSubclass
#else
enum
#endif 
{
	FWN_SEND_STARTED = 1,
	FWN_SEND_ENDED,
	FWN_SEND_RECV_STARTED,
	FWN_SEND_RECV_ENDED,
	FWN_CONNECT_STARTING,
	FWN_CONNECT_COMPLETE,
	FWN_DISCONNECT_STARTING,
	FWN_DISCONNECT_COMPLETE,
	FWN_REGISTER_LISTENER,
	FWN_UNREGISTER_LISTENER,
	FWN_USB_COMMUNICATION_FAILURE,
	FWN_RAW_DATA_SENT,
	FWN_RAW_DATA_RECEIVED,
	FWN_SEND_AND_RECEIVE_TIMEOUT,
	MAX_FRAMEWORK_TYPE_API,

	FWN_ADDIN = 1000,
	MAX_FRAMEWORK_TYPE=0x80000000
};

#ifdef __cplusplus
enum EXdsMessageSubcode
#else
enum //MESSAGE_SUBCODE
#endif 
{
	TERMINATOR_NOT_RECEIVED = 1
};

#ifdef __cplusplus
enum EXdsParity
#else
enum
#endif 
{
	NO_PARITY = 0,
	ODD_PARITY,
	EVEN_PARITY,
	MARK_PARITY,			//not supported on Macintosh
	SPACE_PARITY,			//not supported on Macintosh

	MAX_PARITY
};

#ifdef __cplusplus
enum EXdsStopBits
#else
enum
#endif 
{
	ONE_STOPBIT = 0,
	ONE5_STOPBIT,			//not supported on Macintosh
	TWO_STOPBIT,

	MAX_STOPBITS	
};

#ifdef __cplusplus
enum EXdsIcpMsgType
#else
enum
#endif 
{
	XDS_COMMAND	= 1,
	XDS_DATA,
};

#ifdef __cplusplus
extern "C"
{
#endif

	CONNECTION_HANDLE DLL	CreateEthernetConnection(   const char*  szIPAddress,
														unsigned long ulPortNumber,
														unsigned long ulProtocol);
															
	CONNECTION_HANDLE DLL	CreateEthernetConnectionEx(   const char* szIPAddress,
														unsigned long ulPortNumber,
														unsigned long ulProtocol,
														const char* szPluginName,
														int* piReturnCode );

	CONNECTION_HANDLE DLL	CreateUSBConnection( unsigned long ulDeviceId,
								const char* szSerialNumber,
								unsigned long ulProtocol );

	CONNECTION_HANDLE DLL	CreateUSBConnectionEx( unsigned long ulDeviceId,
								const char* szSerialNumber,
								unsigned long ulProtocol,
								const char* szPluginName,
								int* piReturnCode );


	CONNECTION_HANDLE DLL	CreateSerialConnection( const char* szPort,
								unsigned long ulBaudRate, 
								unsigned long ulParity,
								unsigned long ulBits,
								unsigned long ulStopBit,
								xds_bool bUseCTS,
								unsigned long ulProtocol );
	
	CONNECTION_HANDLE DLL	CreateSerialConnectionEx( const char* szPort,
								unsigned long ulBaudRate, 
								unsigned long ulParity,
								unsigned long ulBits,
								unsigned long ulStopBit,
								xds_bool bUseCTS,
								unsigned long ulProtocol,
								const char* szPluginName,
								int* piReturnCode );

	
	xds_bool DLL			ReconnectSerial( CONNECTION_HANDLE hConnection,
								const char* szPort,
								unsigned long ulBaudRate, 
								unsigned long ulParity,
								unsigned long ulBits,
								unsigned long ulStopBit,
								xds_bool bUseCTS,
								unsigned long ulProtocol );

	xds_bool DLL			ReconnectUSB( CONNECTION_HANDLE hConnection,
								unsigned long ulDeviceId,
								const char* szSerialNumber,
								unsigned long ulProtocol );

	xds_bool DLL			ReconnectEthernet( CONNECTION_HANDLE hConnection,
								const char* szIPAddress,
								unsigned long ulPortNumber,
								unsigned long ulProtocol );

	void DLL				DestroyConnection( CONNECTION_HANDLE hConnection );

	xds_bool DLL			Connect( CONNECTION_HANDLE hConnection );
						
	xds_bool DLL			SendAsync( CONNECTION_HANDLE hConnection,
								const char* pchSendBuffer,
								unsigned long ulSendBufferLen,
								unsigned char uchDeviceID,
								int iCmdDataMode );
						
	xds_bool DLL			SendAndReceive(	CONNECTION_HANDLE hConnection, 
								const char* pchSendBuffer,  
								unsigned long ulSendBufferLen,
								unsigned char uchDeviceID,
								int iCmdDataMode,
								unsigned char* pchRcvBuffer,  
								unsigned long ulRcvBufferSize,
								unsigned long ulTimeout,
								unsigned long* pulNumBytesRcved,
								unsigned long* pulStatusCode );
											
	xds_bool DLL			Disconnect( CONNECTION_HANDLE hConnection );	
	
	unsigned long DLL		RegisterListener( CONNECTION_HANDLE hConnection,
								unsigned long ulEventType,
								PFN_LISTENER pfnListenerProc,
								unsigned long ulListenerData,
								xds_bool bRegisterLast );
	
	xds_bool DLL			UnregisterListener(	CONNECTION_HANDLE hConnection,
								unsigned long ulListenerHandle );	
		
	xds_bool DLL			BroadcastError( CONNECTION_HANDLE hConnection,
								unsigned long ulId,
								unsigned long ulSubClass,
								const char* pszDesc,
								const wchar_t* pwszDesc,
								const wchar_t* pwszModuleName,
								unsigned long ulModuleLineNumber );

	xds_bool DLL			BroadcastMessageReceived( CONNECTION_HANDLE hConnection,
								const unsigned char* pData,
								unsigned long ulDataLength,
								unsigned long ulStatusCode,
								const wchar_t* pwszDesc,
								const wchar_t* pwszModuleName,
								unsigned long ulModuleLineNumber );

	xds_bool DLL			BroadcastMessageReceivedEx( CONNECTION_HANDLE hConnection,
								unsigned long ulId,
								const unsigned char* pData,
								unsigned long ulDataLength,
								unsigned long ulStatusCode,
								const wchar_t* pwszDesc,
								const wchar_t* pwszModuleName,
								unsigned long ulModuleLineNumber );
									
	xds_bool DLL			BroadcastFramework( CONNECTION_HANDLE hConnection,
								unsigned long ulId,
								unsigned long ulSubClass,
								const unsigned char* pData,
								unsigned long ulDataLength,
								const wchar_t* pwszDesc,
								const wchar_t* pwszModuleName,
								unsigned long ulModuleLineNumber );
						
	xds_bool DLL			BroadcastUser( CONNECTION_HANDLE hConnection,
								unsigned long ulId,
								unsigned long ulSubClass,
								const unsigned char* puchData,
								unsigned long ulDataLength,
								const wchar_t* pwszDesc,
								const wchar_t* pwszModuleName,
								unsigned long ulModuleLineNumber);

	xds_bool DLL			GetLastXdsError( CONNECTION_HANDLE hConnection,
								unsigned long* pulId,
								unsigned long* pulSubClass );

	MESSAGE_TERMINATOR DLL	SetMsgTerminator( CONNECTION_HANDLE hConnection,
								MESSAGE_TERMINATOR MsgTerminator );

	long DLL				SetMsgTimeout( CONNECTION_HANDLE hConnection,
								long lMsgTimeout);

	unsigned long	DLL		GetListenerDataPtrFromIndex(CONNECTION_HANDLE hConnection,
														unsigned long ulEventType,										
														unsigned long ulIndex );

	unsigned long	DLL		GetNumberOfListeners(	CONNECTION_HANDLE hConnection,
													unsigned long ulEventType );

#ifdef __cplusplus
}   // extern "C"
#endif

#endif  // _XDSIII_H_


