//======================================================================
//	API-CAP(W32)
//	CCAPAIO.H					CONTEC.CO.,LTD.
//======================================================================
//======================================================================

//======================================================================
// Range
//======================================================================
#define	PM10						0	//+-10V
#define	PM5							1	//+-5V
#define	P10							50	//0~10V
#define	P5							51	//0~5V
#define	P20MA						100	//0~20mA

//======================================================================
// Error Code
//======================================================================
#define	AIO_ERR_SUCCESS					0			//Successed
#define	AIO_ERR_INI_MEMORY				3			//Cannot allocate memory
#define	AIO_ERR_INI_REGISTRY			4			//Cannot access setting file
#define	AIO_ERR_DLL_DEVICE_NAME			10000		//Used DeviceName unwritten in setting file
#define	AIO_ERR_DLL_INVALID_ID			10001		//Invalid Id
#define	AIO_ERR_DLL_CREATE_FILE			10003		//Cannot open
#define	AIO_ERR_DLL_CLOSE_FILE			10004		//Close error
#define	AIO_ERR_INFO_NOT_FIND_DEVICE	10006		//Not find device
#define	AIO_ERR_PTR_DEVICE_NAME			10007		//DeviceName is NULL
#define	AIO_ERR_PTR_DEVICE				10008		//Device is NULL
#define	AIO_ERR_UNKNOWN_DEVICE			10013		//Unknown device
#define	AIO_ERR_PTR_DEVICE_TYPE			10015		//DeviceType is NULL
#define	AIO_ERR_INFO_INVALID_DEVICE		10050		//Invalid device
#define	AIO_ERR_NULL_DEVICE				10100		//DeviceName is NULL string
#define	AIO_ERR_PTR_ID					10101		//Id is NULL
#define	AIO_ERR_PTR_ERR_STR				10180		//ErrorString is NULL
#define	AIO_ERR_PTR_AI_RANGE			11051		//AiRange is NULL
#define	AIO_ERR_AI_RANGE				11060		//AiRange is out of range
#define	AIO_ERR_AI_CHANNEL				11420		//AiChannel is out of range
#define	AIO_ERR_PTR_AI_DATA				11421		//AiData is NULL
#define	AIO_ERR_PTR_AI_MAX_CHANNELS		11720		//AiMaxChannels is NULL
#define	AIO_ERR_PTR_AI_RESOLUTION		11740		//AiResolution is NULL
#define	AIO_ERR_AO_CHANNEL				13000		//AoChannel is out of range
#define	AIO_ERR_AO_CHANNELS				13020		//AoChannels is out of range
#define	AIO_ERR_PTR_AO_DATA				13021		//AoData is NULL
#define	AIO_ERR_PTR_AO_RESOLUTION		13040		//AoResolution is NULL
#define	AIO_ERR_PTR_AO_MAX_CHANNELS		13080		//AoMaxChannels is NULL
#define	AIO_ERR_PTR_AO_RANGE			13111		//AoRange is NULL
#define	AIO_ERR_AO_RANGE				13120		//AoRange is out of range
#define	AIO_ERR_SYS_NOT_SUPPORTED		20001		//Function is not supported
#define	AIO_ERR_DEVICE_BUSY				20002		//Device is busy
#define	AIO_ERR_AI_DEVICE_RANGE			21060		//AiRange is out of range
#define	AIO_ERR_AI_SET_RANGE			21063		//Range setting error
#define	AIO_ERR_AI_DEVICE_CHANNEL		21420		//AiChannel is out of range
#define	AIO_ERR_AD_ERROR				21421		//AD transter error
#define	AIO_ERR_AI_CHANNEL_NUM_OVER		21441		//Number of Channels is over
#define	AIO_ERR_AO_DEVICE_CHANNEL		23000		//AoChannel is out of range
#define	AIO_ERR_DA_ERROR				23001		//DA transfer error
#define	AIO_ERR_AO_DATA_RANGE1			23002		//AoData must be from 0 to 4095
#define	AIO_ERR_AO_DATA_RANGE2			23003		//AoData must be from 0 to 605535
#define	AIO_ERR_AO_CHANNEL_NUM_OVER		23021		//Number of Channels is over
#define	AIO_ERR_AO_DEVICE_RANGE			23120		//AoRange is out of range
#define	AIO_ERR_AO_SET_RANGE			23121		//Range setting error
#define	AIO_ERR_START_ERROR				28001		//Module start error
#define	AIO_ERR_NOT_START				28002		//Device is not started
#define	AIO_ERR_ACCESS_RIGHT			28003		//Access rights error
#define	AIO_ERR_DLL_TIMEOUT				28004		//Timeout
#define	AIO_ERR_COMPOSITION				28005		//Unknown error

//======================================================================
// Function Prototype
//======================================================================
#ifdef __cplusplus
extern"C"{
#endif
long WINAPI AioInit(char *Devicename, short *Id);
long WINAPI AioExit(short Id);
long WINAPI AioGetErrorString(long Err, char *szMsg);
long WINAPI AioQueryDeviceName(short Index, short *GroupID, short *UnitID, short *DeviceID, char *DeviceName, char *Device);
long WINAPI AioGetDeviceType(char * Device, short * DeviceType);

long WINAPI AioSetAccessRight(BYTE *AccsRight);
long WINAPI AioSetDirectMode(short Id, short DirectMode);
long WINAPI AioSetIOInterval(long Interval);
long WINAPI AioStartIO(short Id, short Start);
long WINAPI AioGetRemoteStatus(short Id, BYTE *Start, BYTE *Status);

long WINAPI AioSingleAi(short Id, short AiChannel, long * AiData);
long WINAPI AioSingleAiEx(short Id, short AiChannel, float * AiData);
long WINAPI AioMultiAi(short Id, short AiChannels, long * AiData);
long WINAPI AioMultiAiEx(short Id, short AiChannels, float * AiData);
long WINAPI AioGetAiResolution(short Id, short * AiResolution);
long WINAPI AioGetAiMaxChannels(short Id, short * AiMaxChannels);
long WINAPI AioSetAiRangeAll(short Id, short AiRange);
long WINAPI AioGetAiRange(short Id, short AiChannel, short * AiRange);

long WINAPI AioSingleAo(short Id, short AoChannel, long AoData);
long WINAPI AioSingleAoEx(short Id, short AoChannel, float AoData);
long WINAPI AioSingleAoEcho(short Id, short AoChannel, long *AoData);
long WINAPI AioMultiAo(short Id, short AoChannels, long * AoData);
long WINAPI AioMultiAoEx(short Id, short AoChannels, float * AoData);
long WINAPI AioMultiAoEcho(short Id, short AoChannels, long * AoData);
long WINAPI AioGetAoResolution(short Id, short * AoResolution);
long WINAPI AioGetAoMaxChannels(short Id, short * AoMaxChannels);
long WINAPI AioSetAoRangeAll(short Id, short AoRange);
long WINAPI AioGetAoRange(short Id, short AoChannel, short * AoRange);


#ifdef __cplusplus
}
#endif