FB_LinkedListCtrl

FB_LinkedListCtrl 1:

The function block FB_LinkedListCtrl can be used to implement a linked list in the PLC project. A double-linked list is created. A linked list allows values (known as nodes) to be stored. It is possible to iterate the list from the back to the front or the other way. Nodes can quickly be added or deleted.

It is not possible to change the maximum number of nodes at runtime; it must be specified before compiling. An array of type: T_LinkedListEntry is used as a "node pool". Adding/removing/finding of nodes is controlled through action calls. The function block features the following tasks:

FB_LinkedListCtrl 2: Inputs

VAR_INPUT
    putValue   : PVOID := 0;
    putPosPtr  : POINTER TO T_LinkedListEntry := 0;
END_VAR

Name

Type

Description

putValue

PVOID

Value/data element (input parameter, 32/64 bit, unsigned number or pointer).

putPosPtr

T_LinkedListEntry

Address of the node element (input parameter).

FB_LinkedListCtrl 3: Inputs/outputs

VAR_IN_OUT
    hList  : T_HLINKEDLIST;
END_VAR

Name

Type

Description

hList

T_HLINKEDLIST

Linked List Handle. The handle must be initialized once with the function: F_CreateLinkedListHnd before being used. An associated instance of the handle variable must be created and initialized for each linked list.

FB_LinkedListCtrl 4: Outputs

VAR_OUTPUT
    bOk       : BOOL := FALSE;
    getValue  : PVOID := 0;
    getPosPtr : POINTER TO T_LinkedListEntry := 0;
END_VAR

Name

Type

Description

bOk

BOOL

Result of the last action called. Returns TRUE if a new node element could be added, removed, or found in the list. FALSE is returned if the searched node element could not be found, the list is empty, or has overflowed (no more free node elements).

getValue

PVOID

Value/data element (output parameter, 32/64 bit, unsigned number or pointer).

getPosPtr

T_LinkedListEntry

The address of the node element (output parameter)

Example:

See: Example: Linked list (FB_LinkedListCtrl).

Requirements

Development environment

Target platform

PLC libraries to be integrated (category group)

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_Utilities (System)