#ifdef __cplusplus
extern "C" {
#endif

#define NoError 					0
#define ID_ERROR					-1
#define SLOT_ERROR					-2
#define CHANNEL_ERROR				-3
#define GAIN_ERROR					-4
#define INT_MODE_ERROR  			-5
#define NOT_SUPPORT_ERROR			-6



short i8026W_Init(int slot);

short i8026W_GetLibVersion(void);
void i8026W_GetLibDate(char libDate[]);


short i8026W_GetFirmwareVer(int slot);


// DIO API
void i8026W_WriteDO(int slot, short doVal);
void i8026W_WriteDOBit(int slot,int chIndex, short bitVal);
short i8026W_ReadDIO(int slot, short* diVal, short* doVal,unsigned char diBitArr[], unsigned char doBitArr[]);



// 8026W AO Related API
/*
AO Gain
0=+/-10V 
1=+/-5V    
2=0 ~10V    
3=0 ~5V   
4=0 ~ 20mA 

if want to operate AO output in Timer or other Interrupt service, 
Don't use i8026W_WriteAO/i8026W_ReadbackAO, 
for i-8000 and iP-8000 can not operate float format data in Interrupt service

please use following API

for 2' complement format (Hex format)
1. i8026W_WriteAOHex
2. i8026W_ReadbackAOHex
for example 
	if gain 0=+/-10V , ao hex data 0x7fff will be output 10V and 0x8000 output -10V
	if gain 2=0 ~ 10V , ao hex data 0xffff will be output 10V and 0 output 0V

for engineering format (decimal format)
1. i8026W_WriteAO_x1000 
2. i8026W_ReadbackAO_x1000
for example 
	if gain 0=+/-10V , ao engineering format data 10000 will be output 10V and -10000 output -10V
	if gain 2=0 ~ 10V , ao engineering format data 10000 will be output 10V and 0 output 0V
*/
void i8026W_ReadAO_GainOffset(int slot,int chIndex,short gain,unsigned short *gainValue, short *offsetValue);
// Performance in iP-8000 (writeAOHex 10000 times needs 694 ms )
short i8026W_WriteAOHex (int slot ,int chIndex,short gain,short hexData);
short i8026W_ReadbackAOHex (int slot ,int chIndex, short* hVal);
// Performance in iP-8000 (writeAO 10000 times needs 3134 ms )
short i8026W_WriteAO (int slot ,int chIndex,short gain,float aoData);
short i8026W_ReadbackAO (int slot ,int chIndex, float* fVal);
// Performance in iP-8000 (writeAO_x1000 10000 times needs 1050 ms )
short i8026W_WriteAO_x1000 (int slot ,int chIndex,short gain,short aoData);
short i8026W_ReadbackAO_x1000 (int slot ,int chIndex, short* aoData);





// AI API
/*
Gain
0=+/-10V
1=+/-5V
2=+10V
3=+5V
4=0~20mA

if want to operate AI input in Timer or other Interrupt service, 
Don't use i8026W_ReadAI 
for i-8000 and iP-8000 can not operate float format data in Interrupt service

please use following API
for 2' complement format (Hex format)
1. i8026W_ReadAIHex
for example 
	if gain 0=+/-10V , ai hex data 0x7fff will be 10V and 0x8000 be -10V

for engineering format (decimal format)
1. i8026W_ReadAI_x1000 
for example 
	if gain 0=+/-10V , ai engineering format data 10000 will be 10V and -10000 be -10V

*/
short i8026W_ReadAIGainOffset(int slot,int ch, int gain,unsigned short *gainValue,short *offsetValue) ;

// Performance in iP-8000 (ReadAIHex 10000 times needs 2521 ms )
short i8026W_ReadAIHex(int slot, int chIndex, short gain, short* hVal);
// Performance in iP-8000 (ReadAI 10000 times needs 3092 ms )
short i8026W_ReadAI(int slot, int chIndex, short gain, float* aiVal);

// To help to filter the noise and i8026W_Set_AVGCnt will reduce the sample rate 
void i8026W_Set_AVGCnt(int slot, unsigned short cnt);



#ifdef __cplusplus
 }
#endif


