// The following ifdef block is the standard way of creating macros which make exporting 
// from a DLL simpler. All files within this DLL are compiled with the DCON_FUN_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see 
// DCON_FUN_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
//==========================================================================



//check ERR number winson
//HART General ErrCode
#define		_NOERR			0
#define		impossible_er		-99
#define		para_mismatch_er	-98
#define		response_er		-8
#define		check_sum_er		-7
#define		rece_cmd_er		-6
#define		addr_burst_er		-5
#define		addr_master_er		-4
#define		delimiter_er		-3
#define		rdata_tooshort_er	-2
#define		timeout_er		-1
#define		_CheckSumError		7
#define		_ResultStrCheckError    12
#define		_CmdError		13
#define		_UnderInputRange        19
#define		_ExceedInputRange	20
#define		_FORMATERROR            50
#define		RECEIVEING		51
#define		_FORMATNOTMATCH		52
//PC UART ErrCode
#define		_ComPortNotOpen         8
#define		_TimeOut                15
#define		ComInUse_Err		25
#define		COMInUseOrInvalid_Err	65533
//PAC UART ErrCode
#define		_PAC_ERR_UART_BASE			0x14000
#define		_PAC_ERR_UART_CHECKSUM			(_PAC_ERR_UART_BASE+1)
#define		_PAC_ERR_UART_READ_TIMEOUT		(_PAC_ERR_UART_BASE+2)
#define		_PAC_ERR_UART_RESPONSE			(_PAC_ERR_UART_BASE+3)
#define		_PAC_ERR_UART_UNDER_INPUT_RANGE		(_PAC_ERR_UART_BASE+4)
#define		_PAC_ERR_UART_EXCEED_INPUT_RANGE	(_PAC_ERR_UART_BASE+5)
#define		_PAC_ERR_UART_OPEN_FAILED		(_PAC_ERR_UART_BASE+6)
#define		_PAC_ERR_UART_GET_COMM_STATUS_ERROR	(_PAC_ERR_UART_BASE+7)
#define		_PAC_ERR_UART_INVALID_VALUE		(_PAC_ERR_UART_BASE+8)

/*
//SLOT Number
#define SLOT0						256
#define SLOT1						257
#define SLOT2						258
#define SLOT3						259
#define SLOT4						260
#define SLOT5						261
#define SLOT6						262
#define SLOT7						263
*/

#define DEBUG 1

typedef struct{
	BYTE preamble;
	BYTE delimeter;
	BYTE addr[5];
	BYTE cmd;
	BYTE data[255];
	WORD SdataLen;
}HTSendFrame;

typedef struct{
	BYTE preamble;
	BYTE delimeter;
	BYTE addr[5];
	BYTE cmd;
	BYTE data[255];
	WORD Rdatalen;
	WORD response_code;
}HTRcvFrame;

#ifdef	__cplusplus  // for C++ compile use
extern "C" {
#endif	/*	__cplusplus	*/

//[1] Module Info
	long hart_GetModuleName(char *InBuf, short iCheckSum, WORD wTimeout);
	long hart_GetFwVersion(char *InBuf, short iCheckSum, WORD wTimeout);
	long hart_GetModRstSta(BYTE *status, short iCheckSum, WORD wTimeout);
	long hart_GetModDBSta(BYTE *status, short iCheckSum, WORD wTimeout);
	long hart_SetConfiguration(char *FF, short iCheckSum, WORD wTimeout);
	long hart_GetConfiguration(char *InBuf, short iCheckSum, WORD wTimeout);
//[2] HART Comm.
	long hart_Send(HTSendFrame *HTFrame, BYTE ch, short iCheckSum, WORD wTimeout);
	long hart_Recv(HTRcvFrame *HTFrame, BYTE ch, short iCheckSum, WORD wTimeout);
//[3] Host WDT
	long hart_GetWDTStatus(WORD *status, short iCheckSum, WORD wTimeout);
	long hart_RstWDTStatus(short iCheckSum, WORD wTimeout);
	long hart_GetWDTConfig(BYTE *Enwdt, BYTE *times, short iCheckSum, WORD wTimeout);
	long hart_SetWDTConfig(BYTE Enwdt, BYTE times, short iCheckSum, WORD wTimeout);
//[4] Calibration
	long hart_EnableCal(short iCheckSum, WORD wTimeout);
	long hart_DisableCal(short iCheckSum, WORD wTimeout);
	long hart_SetZeroCal(BYTE ch, short iCheckSum, WORD wTimeout);
	long hart_SetFullCal(BYTE ch, short iCheckSum, WORD wTimeout);
//[5] Limit Value	
	long hart_ClrAllChHLVal(BYTE HLState, short iCheckSum, WORD wTimeout);
	long hart_ClrChHLVal(BYTE HLState, BYTE ch, short iCheckSum, WORD wTimeout);
	long hart_ReadChHLfVal(BYTE HLState, BYTE ch, float *fVal, short iCheckSum, WORD wTimeout);
	long hart_ReadChHLhVal(BYTE HLState, BYTE ch, WORD *hVal, short iCheckSum, WORD wTimeout);
	long hart_ReadAllChHLfVal(BYTE HLState, float fVal[], short iCheckSum, WORD wTimeout);
	long hart_ReadAllChHLhVal(BYTE HLState, WORD hVal[], short iCheckSum, WORD wTimeout);
//[6] Analog Value
	long hart_ReadChfVal(BYTE ch, float *fVal, short iCheckSum, WORD wTimeout);
	long hart_ReadChhVal(BYTE ch, WORD *hVal, short iCheckSum, WORD wTimeout);
	long hart_ReadAllfVal(float fVal[], short iCheckSum, WORD wTimeout);
	long hart_ReadAllhVal(WORD hVal[], short iCheckSum, WORD wTimeout);

#ifdef	__cplusplus
}
#endif	/*	__cplusplus	*/

