#ifdef _8172W_EXPORTS #define I8172WAPI __declspec(dllexport) #else #define I8172WAPI __declspec(dllimport) #endif #ifdef __cplusplus // for C++ compile use extern "C" { #endif /* __cplusplus */ #define pac_i8172W_WriteDOGroupInDIO pac_i8172W_DIO_WriteDOGroup #define pac_i8172W_WriteDOBitInDIO pac_i8172W_DIO_WriteDOBit #define pac_i8172W_ReadDIGroupInDIO pac_i8172W_DIO_ReadDIGroup #define pac_i8172W_ReadDIBitInDIO pac_i8172W_DIO_ReadDIBit #define pac_i8172W_ReadAI pac_i8172W_ReadAI_Ch #define pac_i8172W_ReadAIAll pac_i8172W_ReadAI_All // function for I-8172 I/O I8172WAPI int pac_i8172W_GetLibVersion(); /********************************************************* User use this function to read the version of lib. *********************************************************/ I8172WAPI void pac_i8172W_GetLibDate(char *LibDate); /******************************************************** Reading the date of lib lately. *********************************************************/ I8172WAPI int pac_i8172W_Init(int iSlot); /*************************************************************** Read hardware ID iSlot: 0 ~ 7 return: 0 OK -1 error ****************************************************************/ // function for I-8172 to FR-2057 I8172WAPI void pac_i8172W_WriteDOGroup(int iSlot,int iPort, int iGroup,unsigned int iData); /*************************************************************** User use this function to write Hex value to DO (for FR-2057) module, iSlot: 0 ~ 7 iPort: 0 or 1 iGroup: 0 ~ 7 Every group has 16 channels. iData 0 ~ 0xffff ****************************************************************/ I8172WAPI void pac_i8172W_WriteDOBit(int iSlot,int iPort,int iGroup,int iChannel,int iStatus); /**************************************************************** User use this function to write single channel to DO (for FR-2057) module, iSlot: 0 ~ 7 iPort: 0 or 1 iGroup: 0 ~ 7 Every group has 16 channels. iBit: 0~15 iStatus: 0 off 1 on ****************************************************************/ // function for I-8172 to FR-2053 I8172WAPI unsigned int pac_i8172W_ReadDIGroup(int iSlot,int iPort,int iGroup); /*************************************************************** User use this function to read value from DI (for FR-2053 ) module, iSlot: 0 ~ 7 iPort: 0 or 1 iGroup: 0 ~ 7 Every group has 16 channels. return: DI Value (0 ~ 0xffff) ****************************************************************/ I8172WAPI unsigned int pac_i8172W_ReadDIBit(int iSlot,int iPort,int iGroup,int iChannel); /*************************************************************** User use this function to read single channel from DI (for FR-2053 ) module, iSlot: 0 ~ 7 iPort: 0 or 1 iGroup: 0 ~ 7 Every group has 16 channels. iChannel: 0 ~ 15 return: 0 or 1 ************************************************************/ I8172WAPI int pac_i8172W_ReadDIGroupStatus(int iSlot,int iPort, int iGroup); //FR-2053, FR-2054, FR-2017 function I8172WAPI int pac_i8172W_ReadInputGroupStatus(int iSlot,int iPort, int iGroup); /************************************************************** Read status of DI Group Communication Status iSlot: 0 ~ 7 iPort: 0 or 1 iGroup: 0~7 return 0 offline, 1 online ***************************************************************/ // function used for FR-2054 I8172WAPI void pac_i8172W_DIO_WriteDOGroup(int iSlot,int iPort, int iGroup,unsigned int iData); /*************************************************************** User use this function to input Hex value to DO module, iSlot: 0 ~ 7 iPort: 0 or 1 iGroup: 0 ~ 7 iData: 0 ~ 0xff ****************************************************************/ //FR-2054 function I8172WAPI void pac_i8172W_DIO_WriteDOBit(int iSlot,int iPort,int iGroup,int iChannel, int iStatus); /**************************************************************** User use this function to input write channel to DO (for FR-2054 ) module, iSlot: 0 ~ 7 iPort: 0 or 1 iGroup: 0 ~ 7 iBitIndex: 0~7 iStatus: 0 off 1 on ****************************************************************/ //FR-2054 function I8172WAPI unsigned int pac_i8172W_DIO_ReadDIGroup(int iSlot,int iPort,int iGroup); /*************************************************************** User use this function to read value from DI (for FR-2054 ) module, iSlot: 0 ~ 7 iPort: 0 or 1 iGroup: 8 ~ 15 return: DI Value 0 ~ 0xff ****************************************************************/ //FR-2054 function I8172WAPI unsigned int pac_i8172W_DIO_ReadDIBit(int iSlot,int iPort,int iGroup,int iChannel); /*************************************************************** User use this function to read single channel from DI(for FR-2054 ) module, iSlot: 0 ~ 7 iPort: 0 or 1 iGroup: 8 ~ 15 iChannel: 0 ~ 7 return: 0 or 1 ************************************************************/ //FR-2017 function I8172WAPI short pac_i8172W_ReadAIHex(int iSlot,int iPort,int iGroup,short bitMode,short *iChannel, short* aiHex); /*************************************************************** User use this function to read channel index and analog input data get from FR-2017, iSlot: 0 ~ 7 iPort: 0 or 1 iGroup: 8 ~ 15 bitMode: 12 means 12-bit mode, 16 means 16-bit mode. *iChannel: requested channel index get from FR-2017 *aiHex: requested hex format analog input data from FR-2017 return: if return < 0 means Read AI Hex failed else means Read AI Hex successfully. Note: For FRnet, FR-2017 update 16-bit data coutinuous every 2.8 ms, if 16-bit mode, *iChannel always be 0, and aiHex will be the only analog input data. if 12-bit mode, the data format defined as MSB LSB bit15 bit14 bit13 bit12 bit11 bit10 Bit9 Bit8 Bit7 Bit6 Bit5 Bit4 Bit3 Bit2 Bit1 Bit0 |<------------------------------12-bits AD data------------------------------------------->| |<----- Channel Index ---->| if 12-bit mode, we have to use i8172_ReadAIHex function to get which channel and data get from FR-2017, if use i8172_ReadAIHex to get hex data from FR-2017, we have to use i8172_AIHexToFloat with typeCode and bitMode to convert the hex data to float. ****************************************************************/ I8172WAPI void pac_i8172W_AIHexToFloat(short hexData, short typeCode, short bitMode, float* fData); /*************************************************************** User use this function to convert hex format analog input data to float format, hexData: hex format analog input data get from FR-2017 with function i8172_ReadAIHex typeCode: the input range of FR-2017 bitMode: 12 means 12-bit mode, 16 means 16-bit mode. fData: converted float format data. FR_2017 type code 0x1a 0 ~ 20 mA 0x7 4 ~ 20 mA 0x8 +/-10 V 0x9 +/-5 V 0xa +/-1 V 0xb +/-500 mV 0xc +/-150 mV 0xd +/-20 mA ****************************************************************/ I8172WAPI short pac_i8172W_ReadAI_Ch(int iSlot,int iPort, int iGroup, short bitMode,short typeCode, short iChannel, float* aiFloat); /*************************************************************** User use this function to read channel index and analog input data get from FR-2017, iSlot: 0 ~ 7 iPort: 0 or 1 iGroup: 8 ~ 15 bitMode: 12 means 12-bit mode, 16 means 16-bit mode. typeCode: the input range of FR-2017 iChannel: requested channel index of FR-2017 *aiFloat: requested float format analog input data from FR-2017 return: the sampling time needs for i8172_ReadAI_Ch to get the iChannel index data from FR-2017. Note: for most users, it is not convenient to use i8172_ReadAIHex to get the analog input data from FR-2017 By using i8172_ReadAI_Ch, program will blocked for about 0 to 45 ms to get certain channel index data. FR_2017 type code 0x1a 0 ~ 20 mA 0x7 4 ~ 20 mA 0x8 +/-10 V 0x9 +/-5 V 0xa +/-1 V 0xb +/-500 mV 0xc +/-150 mV 0xd +/-20 mA ****************************************************************/ I8172WAPI short pac_i8172W_ReadAI_All(int iSlot,int iPort, int iGroup, short bitMode,short isSingleEnded,short typeCode[], float aiFloat[]); /*************************************************************** User use this function to read all analog input data get from FR-2017, iSlot: 0 ~ 7 iPort: 0 or 1 iGroup: 8 ~ 15 bitMode: 12 means 12-bit mode, 16 means 16-bit mode. isSingleEnded: 0 differential mode , 1 single-ended mode , typeCode[]: the input range array of FR-2017 aiFloat[]: requested float format analog input data array. return: the sampling time needs for i8172_ReadAI_ALL to get the all analog input data from FR-2017. Note: for most users, it is not convenient to use i8172_ReadAIHex to get the analog input data from FR-2017 By using i8172_ReadAI_ALL, program will blocked for about 0 to 45 ms to get all channels' data. FR_2017 type code 0x7 4 ~ 20 mA 0x8 +/-10 V 0x9 +/-5 V 0xa +/-1 V 0xb +/-500 mV 0xc +/-150 mV 0xd +/-20 mA 0x1a 0 ~ 20 mA ****************************************************************/ I8172WAPI short pac_i8172W_WriteAOHex(int iSlot,int iPort,int iGroup,short bitMode,short iChannel, short aoHexData, short ifDelay); /*************************************************************** User use this function to write analog output data by FR-2024, iSlot: 0 ~ 7 iPort: 0 or 1 iGroup: 0 ~ 7 bitMode: 12 means 12-bit mode, at present only support 12-bit mode, reserved this parameter for future I/O with different bit mode. iChannel: channel index of FR-2024 aoHexData: analog output data. delayTime: the delay time after FR-2024 write analog output data. return: 0. Note: for some application,program may use a for loop to write analog output by using i8172_WriteAOHex, but for FRnet protocol, each command will have 3 ms delay for 250K setting and 1 ms delay for 1M setting. if there is no need to write analog output continuously, the delayTime may set as 0 ****************************************************************/ I8172WAPI short pac_i8172W_WriteAOFloat(int iSlot,int iPort,int iGroup,short bitMode,short iChannel, short typeCode, float aoFloat, short ifDelay); /*************************************************************** User use this function to write analog output data by FR-2024, iSlot: 0 ~ 7 iPort: 0 or 1 iGroup: 0 ~ 7 bitMode: 12 means 12-bit mode, at present only support 12-bit mode, reserved this parameter for future I/O with different bit mode. typeCode: the input range of FR-2024 iChannel: channel index of FR-2024 aoHexData: analog output data. delayTime: the delay time after FR-2024 write analog output data. return: 0. Note: for some application,program may use a for loop to write analog output by using i8172_WriteAOFloat, but for FRnet protocol, each command will have 3 ms delay for 250K setting and 1 ms delay for 1M setting. if there is no need to write analog output continuously, the delayTime may set as 0 typeCode for FR-2024 0 ~ 20mA 0x30 4 ~ 20mA 0x31 0V ~ +10V 0x32 -10V ~ +10V 0x33 0V ~ +5V 0x34 -5V ~ +5V 0x35 ****************************************************************/ #ifdef __cplusplus } #endif /* __cplusplus */