
#ifdef _I8012W_EXPORTS
	#define I8012WAPI __declspec(dllexport)
#else
	#define I8012WAPI __declspec(dllimport)
#endif

// This class is exported from the pac_i8012.dll
#define NoError 		 0
#define ID_ERROR		-1
#define FIFO_FULL		-2
#define FIFO_EMPTY	-3

#ifdef __cplusplus
extern "C" {
#endif

#define i9012_Init                      i8012W_Init
#define i9012_GetLibVersion             i8012W_GetLibVersion
#define i9012_GetFirmwareVersion        i8012W_GetFirmwareVersion
#define i9012_Read_AI                   i8012W_Read_AI
#define i9012_Read_AIHex                i8012W_Read_AIHex
#define i9012_ConfigMagicScan           i8012W_ConfigMagicScan
#define i9012_StartMagicScan            i8012W_StartMagicScan
#define i9012_StopMagicScan             i8012W_StopMagicScan
#define i9012_Read_FIFO_Block           i8012W_Read_FIFO_Block
#define i9012_Read_FIFO_NonBlock        i8012W_Read_FIFO_NonBlock
#define i9012_ReadFIFO_ISR              i8012W_ReadFIFO_ISR
#define i9012_InstallMagicScanISR       i8012W_InstallMagicScanISR
#define i9012_UnInstallMagicScanISR     i8012W_UnInstallMagicScanISR
#define i9012_ClearINT                  i8012W_ClearINT
#define i9012_ConfigTrigOut             i8012W_ConfigTrigOut
#define i9012_Enable_TrigOut            i8012W_Enable_TrigOut
#define i9012_Disable_TrigOut           i8012W_Disable_TrigOut
#define i9012_ReadGainOffset            i8012W_ReadGainOffset
#define i9012_CalibrationHEX            i8012W_CalibrationHEX 
#define i9012_CalibrationFloat          i8012W_CalibrationFloat 


short i8012W_Init(int slot);
//	function to initialize i-9012 at specific slot
//	slot: 0 ~ 7
//	return: Error Code. 


short i8012W_GetLibVersion(void);
//	function to get the library version of 8012.lib
//	return: version number. 
//	for example: 0x106; = Rev:1.0.6


//void i8012W_GetLibDate(char libDate[]);
//	function to get the library built date
//	libDate: library built date 
//	return: None


short i8012W_GetFirmwareVersion(int slot);
//	function to get the FPGA firmware version
//	slot: 1 ~ 8
//	return: firmware version


int i8012W_Read_AI(int slot,int ch,int gain,float* fval);
//	function to read calibrated AI data
//	slot: 1 ~ 8
//	ch: 1 ~ 8
//	gain: 0 : +/- 5V ; 1 : +/- 10V
//	val[]: float format Ai data array
//	return: refer to error code


int i8012W_Read_AIHex(int slot,int ch,int gain,short* hval);
//	function to read calibrated AI data
//	slot: 1 ~ 8
//	ch: 1 ~ 8
//	gain: 0 : +/- 5V ; 1 : +/- 10V
//	val[]: hexadecimal format Ai data array
//	return: refer to error code


int i8012W_ConfigMagicScan(int slot,int gain,int chcnt,int type,unsigned long samplerate,unsigned long* realrate);
//	function to configure Magic Scan function, need to be called before start
//	slot: 1 ~ 8
//	gain: 0 : +/- 5V ; 1 : +/- 10V
//	chcnt: 1 ~ 8
//        E.g. Config magic scan Ch0, chcnt =1 
//             Config magic scan Ch5, chcnt =6
//             Config magic scan Ch3~Ch7, chcnt=8
//	type: 0 : Internal clock trig	1 : External clock trig
//	sampleRate: 20~200Khz
//	*realrate: the real sample rate
//	return: refer to error code


int i8012W_StartMagicScan(int slot);
//	function to start Magic scan, after this function has been called, all the AI data will be save to FIFO 
//	slot: 1 ~ 8
//	return: refer to error code


int i8012W_StopMagicScan(int slot);
//	function to stop Magic scan
//	slot: 1 ~ 8
//	return: refer to error code


int i8012W_Read_FIFO_Block(int slot,short FIFOData[],unsigned long cnt,unsigned long* readFIFOcnt);
//	function to read data from FIFO in block mode
//	slot: 1 ~ 8
//	FIFOData[]: data array
//	cnt: amount of data required
//	*readFIFOcnt: reading counts of data in this process
//	return: refer to error code


int i8012W_Read_FIFO_NonBlock(int slot,short FIFOData[],unsigned long cnt,short* readFIFOcnt);
//	function to read data from FIFO in nonblock mode
//	slot: 1 ~ 8
//	FIFOData[]: data array
//	cnt: amount of data required
//	*readFIFOcnt: reading counts of data in this process
//	return: refer to error code


short i8012W_ReadFIFO_ISR(int slot, short FIFOData[],short* readFIFOcnt);
//	function to read data from FIFO while using ISR function
//	slot: 1 ~ 8
//	hexData[]: data array
//	*readFIFOcnt: reading counts of data in this process
//	return: refer to error code


#ifdef WIN32
	short i8012W_InstallMagicScanISR(int slot,void (__stdcall *isr)(int slot),short leveltype);
	//	function to install ISR function for XP-9000 based on WES system
	//	slot: 1 ~ 8
	//	void(__stdcall *isr)(int slot): function pointer for ISR 
	//	leveltype: 
	//				1 : 10
	//				2 : 2048
	//	return: refer to error code
#else
	short i8012W_InstallMagicScanISR(int slot,void (*isr)(int),short leveltype); 
	//	function to install ISR function for WP-9000 based on WES system
	//	slot: 1 ~ 8
	//	void(__stdcall *isr)(int slot): function pointer for ISR 
	//	leveltype: 
	//				1 : 10
	//				2 : 2048
	//	return: refer to error code
#endif


short i8012W_UnInstallMagicScanISR(int slot);
//	function to uninstall ISR function 
//	slot: 1 ~ 8
//	return: refer to error code

short i8012W_ClearINT(int slot);
//	function to clear the signal of interrupt, should be called in ISR function
//	slot: 1 ~ 8
//	return: None

int i8012W_ConfigTrigOut(int slot,unsigned long samplerate,unsigned long* realrate);
//	function to congifure trig out function
//	slot: 1 ~ 8
//	sampleRate: 20~200Khz
//	*realrate: the real sample rate
//	return: refer to error code

short i8012W_Enable_TrigOut(int slot);
//	function to enable trig out function 
//	slot: 1 ~ 8
//	return: refer to error code

short i8012W_Disable_TrigOut(int slot);
//	function to disable trig out function 
//	slot: 1 ~ 8
//	return: refer to error code

short i8012W_ReadGainOffset(int slot,int ch,int Gain,unsigned short* GainValue, short* offsetValue);
//	function to read gain value and offset value for each range of I-9012
//	slot: 1 ~ 8
//	ch: 1 ~ 8
//	Gain: 0 : +/- 5V  1 : +/- 10V
//	*GainValue: gain value
//	*offsetValue: offset value
//	return: refer to error code


int i8012W_CalibrationHEX(int slot,int ch,int gain,short raw,short* hval);
//	function to calibrate raw data that read from FIFO
//	slot: 1 ~ 7
//	ch: 1~8
//	gain: 0 : +/- 5V  1 : +/- 10V
//	raw: raw data
//	val: calibrated hexadecimal data

int i8012W_CalibrationFloat(int slot,int ch,int gain,short raw,float* fval);
//	function to calibrate raw data that read from FIFO
//	slot: 1 ~ 7
//	ch: 1~8
//	gain: 0 : +/- 5V  1 : +/- 10V
//	raw: raw data
//	val: calibrated flaot data

#ifdef __cplusplus
}
#endif
