FB_BA_RingIterator

FB_BA_RingIterator 1:

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:

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

FB_BA_RingIterator 2: 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.

FB_BA_RingIterator 3: Methods

Name

Definition location

Description

AddEntry

Local

Adds one or more entries to the ring buffer and updates the index of the last entry.

Initialize

Local

Initializes the ring buffer with a specific last entry and fill status.

Iterate

Local

Starts an inactive iteration or resumes an active iteration (with ring buffer wrapping).

Stop

Local

Ends the current iteration and resets the virtual index.

Reset

Local

Completely resets the ring buffer (number of entries and last entry).

FB_BA_RingIterator 4: 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.