FB_BA_RingIterator

The function block extends the FB_BA_Iterator and implements an iteration mechanism for ring-shaped (circular) data sources. It supports the management of entries in a ring buffer with automatic wrapping when the upper limit is reached.
The iterator iterates with the following properties:
- nIndex: Physical index of the ring buffer position
- nVirtualIndex: Virtual index for logical iteration over actual entries
- nEntryCount: Number of entries currently stored (may exceed the buffer size)
Inherits from: FB_BA_Iterator
Syntax
FUNCTION_BLOCK FB_BA_RingIterator EXTENDS FB_BA_Iterator
VAR_OUTPUT
nEntryCount : DINT;
nLastEntry : DINT;
nVirtualIndex: DINT;
END_VAR
Outputs
Name | Type | Description |
|---|---|---|
bIsActive | BOOL | Iteration status: TRUE if iteration is active, FALSE if stopped. |
nIndex | DINT | Current physical index in the ring buffer. |
nEntryCount | DINT | Number of stored entries (may exceed the buffer size). |
nLastEntry | DINT | Index position of the last entry in the ring buffer. |
nVirtualIndex | DINT | Virtual index of actual entries. |
Methods
Name | Definition location | Description |
|---|---|---|
Local | Adds one or more entries to the ring buffer and updates the index of the last entry. | |
Local | Initializes the ring buffer with a specific last entry and fill status. | |
Local | Starts an inactive iteration or resumes an active iteration (with ring buffer wrapping). | |
Local | Ends the current iteration and resets the virtual index. | |
Local | Completely resets the ring buffer (number of entries and last entry). |
Properties
Name | Type | Access | Definition location | Description |
|---|---|---|---|---|
IsMaxLimit | BOOL | Get | Local | Indicates whether the current index has reached the upper limit (when active). |
IsMinLimit | BOOL | Get | Local | Indicates whether the current index has reached the lower limit (when active). |
IsExceeded | BOOL | Get | Local | Indicates whether the number of entries has exceeded the buffer size. |
IsFull | BOOL | Get | Local | Indicates whether the ring buffer is completely full. |
MaxVBound | DINT | Get | Local | Maximum virtual limit (depends on actual entries). |
Size | DINT | Get | Local | Size of the ring buffer (nMaxBound - nMinBound + 1). |
Valid | BOOL | Get | Local | Indicates whether the iterator has been initialized correctly. |