| ioPAC RTU Controllers C/C++ Sample Code Programming Guide

- Main Page
- Modules
- Data Structures
- Files

Macros | Functions
FAST_AI
Library » IO

## Macros
#define | FAST_AI_BATCH_DATA_SIZE 60*1000

## Functions
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Raw_Value_Get (UINT8 slot, UINT8 start, UINT8 count, UINT32 *buf, struct Timestamp *time)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Eng_Value_Get (UINT8 slot, UINT8 start, UINT8 count, float *buf, struct Timestamp *time)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Range_Get (UINT8 slot, UINT8 start, UINT8 count, UINT8 *buf)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Min_Raw_Get (UINT8 slot, UINT8 start, UINT8 count, UINT32 *buf)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Max_Raw_Get (UINT8 slot, UINT8 start, UINT8 count, UINT32 *buf)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Min_Eng_Get (UINT8 slot, UINT8 start, UINT8 count, float *buf)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Max_Eng_Get (UINT8 slot, UINT8 start, UINT8 count, float *buf)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Burnout_Value_Get (UINT8 slot, UINT8 start, UINT8 count, float *buf)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Status_Get (UINT8 slot, UINT8 start, UINT8 count, UINT8 *buf)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Enable_Mode_Get (UINT8 slot, UINT32 *mode)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Range_Set (UINT8 slot, UINT8 start, UINT8 count, UINT8 *buf)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Min_Raw_Reset (UINT8 slot, UINT32 channel)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Max_Raw_Reset (UINT8 slot, UINT32 channel)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Min_Eng_Reset (UINT8 slot, UINT32 channel)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Max_Eng_Reset (UINT8 slot, UINT32 channel)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Burnout_Value_Set (UINT8 slot, UINT8 start, UINT8 count, float *buf)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Sampling_Rate_Get (UINT8 slot, UINT32 *rate)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Buf_Overflow_Get (UINT8 slot, UINT32 *overflow)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Batch_Data_Get (UINT8 slot, UINT32 channel, UINT32 fore_interval, UINT32 back_interval, UINT8 *buf, struct Timestamp *time)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Batch_Data_Check (UINT8 slot, UINT32 channel, UINT32 *count)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Sampling_Rate_Set (UINT8 slot, UINT32 rate)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Buf_Overflow_Reset (UINT8 slot, UINT32 overflow)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Buf_Reset (UINT8 slot)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Trigger_Set (UINT8 slot, UINT32 channel_trigger, UINT32 fore_interval, UINT32 back_interval, UINT32 *required_buf_size)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Trigger_Stop_Set (UINT8 slot, UINT32 channel_trigger, struct Timestamp *time)
MODULE_RW_ERR_CODE | MX_RTU_Module_Fast_AI_Enable_Mode_Set (UINT8 slot, UINT32 mode)

## Detailed Description

Sample Code:
fast_ai.c
fast_ai_stop.c

## Macro Definition Documentation

#define FAST_AI_BATCH_DATA_SIZE 60*1000

## Function Documentation

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Raw_Value_Get | ( | UINT8 | slot,
|  | UINT8 | start,
|  | UINT8 | count,
|  | UINT32 * | buf,
|  | struct Timestamp * | time
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | start | The first channel to get.
  [in] | count | The number of channels to get.
  [out] | buf | The AI raw data for the corresponding channels.
  [out] | time | Timestamp of AI data.

Returns
  MODULE_RW_ERR_CODE

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Eng_Value_Get | ( | UINT8 | slot,
|  | UINT8 | start,
|  | UINT8 | count,
|  | float * | buf,
|  | struct Timestamp * | time
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | start | The first channel to get.
  [in] | count | The number of channels to get.
  [out] | buf | The AI engineering data for the corresponding channels.
  [out] | time | Timestamp of AI data.

Returns
  MODULE_RW_ERR_CODE

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Range_Get | ( | UINT8 | slot,
|  | UINT8 | start,
|  | UINT8 | count,
|  | UINT8 * | buf
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | start | The first channel to get.
  [in] | count | The number of channels to get.
  [out] | buf | The AI range for the corresponding channels.

Returns
  MODULE_RW_ERR_CODE

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Min_Raw_Get | ( | UINT8 | slot,
|  | UINT8 | start,
|  | UINT8 | count,
|  | UINT32 * | buf
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | start | The first channel to get.
  [in] | count | The number of channels to get.
  [out] | buf | The AI range for the corresponding channels.

Returns
  MODULE_RW_ERR_CODE

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Max_Raw_Get | ( | UINT8 | slot,
|  | UINT8 | start,
|  | UINT8 | count,
|  | UINT32 * | buf
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | start | The first channel to get.
  [in] | count | The number of channels to get.
  [out] | buf | The maximum AI raw data for the corresponding channels.

Returns
  MODULE_RW_ERR_CODE

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Min_Eng_Get | ( | UINT8 | slot,
|  | UINT8 | start,
|  | UINT8 | count,
|  | float * | buf
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | start | The first channel to get.
  [in] | count | The number of channels to get.
  [out] | buf | The minimum AI engineering data for the corresponding channels.

Returns
  MODULE_RW_ERR_CODE

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Max_Eng_Get | ( | UINT8 | slot,
|  | UINT8 | start,
|  | UINT8 | count,
|  | float * | buf
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | start | The first channel to get.
  [in] | count | The number of channels to get.
  [out] | buf | The maximum AI engineering data for the corresponding channels.

Returns
  MODULE_RW_ERR_CODE

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Burnout_Value_Get | ( | UINT8 | slot,
|  | UINT8 | start,
|  | UINT8 | count,
|  | float * | buf
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | start | The first channel to get.
  [in] | count | The number of channels to get.
  [out] | buf | The burnout value for the corresponding channels.

Returns
  MODULE_RW_ERR_CODE

Note
  These values are valid only when the AI range is 4-20 mA.

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Status_Get | ( | UINT8 | slot,
|  | UINT8 | start,
|  | UINT8 | count,
|  | UINT8 * | buf
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | start | The first channel to get.
  [in] | count | The number of channels to get.
  [out] | buf | The AI status for the corresponding channels.

Returns
  MODULE_RW_ERR_CODE

Note
  These values are valid only when the AI range is 4-20 mA.

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Enable_Mode_Get | ( | UINT8 | slot,
|  | UINT32 * | mode
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [out] | mode | The AI enable mode for the AI module.

Returns
  MODULE_RW_ERR_CODE

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Range_Set | ( | UINT8 | slot,
|  | UINT8 | start,
|  | UINT8 | count,
|  | UINT8 * | buf
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | start | The first channel to set.
  [in] | count | The number of channels to set.
  [in] | buf | The AI range for the corresponding channels.

Returns
  MODULE_RW_ERR_CODE

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Min_Raw_Reset | ( | UINT8 | slot,
|  | UINT32 | channel
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | channel | Reset the minimum AI raw data for the specified channel. The bit 0 represents channel 0 will be reset and so on.

Returns
  MODULE_RW_ERR_CODE

Note
  This API only reset the RAW value, reset is setting the Min value to be current value.

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Max_Raw_Reset | ( | UINT8 | slot,
|  | UINT32 | channel
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | channel | Reset the maximum AI raw data for the specified channel. The bit 0 represents channel 0 will be reset and so on.

Returns
  MODULE_RW_ERR_CODE

Note
  This API only reset the RAW value, reset is setting the Max value to be current value.

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Min_Eng_Reset | ( | UINT8 | slot,
|  | UINT32 | channel
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | channel | Reset the minimum AI engineering data for the specified channel. The bit 0 represents channel 0 will be reset and so on.

Returns
  MODULE_RW_ERR_CODE

Note
  This API only reset the ENG value, reset is setting the Min value to be current value.

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Max_Eng_Reset | ( | UINT8 | slot,
|  | UINT32 | channel
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | channel | Reset the maximum AI engineering data for the specified channel. The bit 0 represents channel 0 will be reset and so on.

Returns
  MODULE_RW_ERR_CODE

Note
  This API only reset the ENG value, reset is setting the Max value to be current value.

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Burnout_Value_Set | ( | UINT8 | slot,
|  | UINT8 | start,
|  | UINT8 | count,
|  | float * | buf
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | start | The first channel to set.
  [in] | count | The number of channels to set.
  [in] | buf | The burnout value for the corresponding channels.

Returns
  MODULE_RW_ERR_CODE

Note
  These values are valid only when the AI range is 4-20 mA.

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Sampling_Rate_Get | ( | UINT8 | slot,
|  | UINT32 * | rate
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [out] | rate | The sampling rate of the fast AI channel.

Returns
  MODULE_RW_ERR_CODE

Note
  The range of sampling rates is [1-5000] Hz.

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Buf_Overflow_Get | ( | UINT8 | slot,
|  | UINT32 * | overflow
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [out] | overflow | A bitwise value to indicate all channels' overflow status. The value for bit 0 indicates whether or not channel 0's buffer is overflowed (0: OK, 1: overflow).

Returns
  MODULE_RW_ERR_CODE

Note
  If the buffer is overflowed, the fast AI will not work.

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Batch_Data_Get | ( | UINT8 | slot,
|  | UINT32 | channel,
|  | UINT32 | fore_interval,
|  | UINT32 | back_interval,
|  | UINT8 * | buf,
|  | struct Timestamp * | time
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | channel | The channel to get.
  [in] | fore_interval | The pre-recording time before the trigger time (one unit = 1sec).
  [in] | back_interval | The recording time after the trigger time (one unit = 1sec).
  [out] | buf | The batch of AI raw data.
  [out] | time | Timestamp of the first AI data.

Returns
  MODULE_RW_ERR_CODE

Note
  Before executing this API, the channel must be triggered by MX_RTU_Module_Fast_AI_Trigger_Set . The maximum buffer size refers to FAST_AI_BATCH_DATA_SIZE .

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Batch_Data_Check | ( | UINT8 | slot,
|  | UINT32 | channel,
|  | UINT32 * | count
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | channel | The channel to get.
  [out] | count | The batch data count in the buffer.

Returns
  MODULE_RW_ERR_CODE

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Sampling_Rate_Set | ( | UINT8 | slot,
|  | UINT32 | rate
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | rate | The sampling rate of the fast AI channel.

Returns
  MODULE_RW_ERR_CODE

Note
  The range of sampling rates is [1-5000] Hz.

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Buf_Overflow_Reset | ( | UINT8 | slot,
|  | UINT32 | overflow
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | overflow | A bitwise value to specify that the channel's buffer and overflow flag to be reset. If bit 0's value is 1, then channel 0's buffer and buffer overflow flag will be reset, and so on.

Returns
  MODULE_RW_ERR_CODE

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Buf_Reset | ( | UINT8 | slot | ) |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.

Returns
  MODULE_RW_ERR_CODE

Note
  Using this API will clear all data in the buffer.

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Trigger_Set | ( | UINT8 | slot,
|  | UINT32 | channel_trigger,
|  | UINT32 | fore_interval,
|  | UINT32 | back_interval,
|  | UINT32 * | required_buf_size
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | channel_trigger | A bitwise value to specify that the channel to be trigger. If bit 0's value is 1, then channel 0 will be triggered, and so on.
  [in] | fore_interval | The pre-recording time before the trigger time (one unit = 1 second).
  [in] | back_interval | The recording time after the trigger time (one unit = 1 second).
  [out] | required_buf_size | The required buffer size of the batch of AI raw data.

Returns
  MODULE_RW_ERR_CODE

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Trigger_Stop_Set | ( | UINT8 | slot,
|  | UINT32 | channel_trigger,
|  | struct Timestamp * | time
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | channel_trigger | A bitwise value to specify that the channel to be stopped. If bit 0's value is 1, then channel 0 will be stopped, and so on.
  [out] | time | Timestamp of the trigger stopping.

Returns
  MODULE_RW_ERR_CODE

MODULE_RW_ERR_CODE MX_RTU_Module_Fast_AI_Enable_Mode_Set | ( | UINT8 | slot,
|  | UINT32 | mode
| ) |  |

Parameters

  [in] | slot | Slot 0: Built-in IO Ports, Slots 1 ~ 12: Expansion IO Ports.
  [in] | mode | The AI enable mode for the AI module.

Returns
  MODULE_RW_ERR_CODE