FB_BA_StaticArray

FB_BA_StaticArray 1:

The function block is an extension of the function block FB_BA_DynamicArray.

The aim of this extension is to avoid using router memory and use static memory instead. This is declared in the application, where its size can be flexibly adjusted.

FB_BA_StaticArray 2:

The static memory must be provided by the application, but it must never be changed outside of the array! The management should take place in all cases via the array itself.

Using a static array is recommended when the expected memory requirements can be reliably estimated.

For efficiency reasons, the memory area should be sized so that only as much memory as necessary is reserved. Global constants and parameter lists are suitable for defining memory limits.

Inherits from: FB_BA_DynamicArray

Application

The use cases are essentially the same as those for dynamic arrays. There are only minor differences in the declaration, since the external memory area and its size must be passed as parameters.

Further information

See examples of initialization during variable declaration.

Examples

Example declaration of the array, its static memory, and corresponding constants.

VAR_GLOBAL  CONSTANT
  uiObjectCount    :  UINT := 100;
  uiArrayMemSize   :  UINT := TO_UINT(uiObjectCount  *  SIZEOF(FB_OBJECT));
END_VAR
VAR
  bArrayMemory   : ARRAY[0.. uiArrayMemSize] OF BYTE;
  fbArray        : FB_StaticArray := (uiEntrySize:=SIZEOF(FB_Object), pExtMemory:=ADR(bArrayMemory), uiExtMemorySize:=uiArrayMemSize);)
END_VAR

Further information

Since the static array is to be used in exactly the same way as the Dynamic array, appropriate application examples are documented there.

FB_BA_StaticArray 3: Methods

Name

Definition location

Description

AddEntry

Local

Creates a new data set at the end of the array and copies the content of the specified entry to the internal memory.

Reset

Local

Resets the complete content of the array.

AddEntry

Local

Creates a new data set at the end of the array and copies the content of the specified entry to the internal memory.

FindEntry

FB_BA_DynamicArray

Determines the position of the specified entry in the array by comparing its content with the data sets of the array.

GetEntry

FB_BA_DynamicArray

Copies the contents of the data set to a certain position in the specified memory area.

GetEntryEx

FB_BA_DynamicArray

Determines a pointer to the internal memory of the specified data set.

RemoveEntry

FB_BA_DynamicArray

Removes the data set at the specified index position from the array.

RemoveEntryEx

FB_BA_DynamicArray

Determines the position of the specified entry and deletes it from the array.

Reset

FB_BA_DynamicArray

Resets the complete content of the array.

SetEntry

FB_BA_DynamicArray

Replaces the existing data set with a new one by overwriting the internal memory area of the existing data set with the value of the new entry.

AddEntryPtr

FB_BA_DynamicArray

Creates a new entry at the end of the array and copies its memory address (i.e., the address to which the pointer pEntry points) to the internal memory.

FindEntryPtr

FB_BA_DynamicArray

Determines the position of an entry in the array by comparing its address with the addresses stored in the array.

GetEntryExPtr

FB_BA_DynamicArray

Outputs a pointer to the memory address of the requested entry.

RemoveEntryExPtr

FB_BA_DynamicArray

Determines the position of the specified entry and deletes it from the array.

SetEntryPtr

FB_BA_DynamicArray

Replaces an existing entry with a new one.