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:

VAR_IN_OUT

VAR_IN_OUT
    hList  : T_HLINKEDLIST;
END_VAR

hList: Linked List Handle (type: T_HLINKEDLIST). 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

VAR_INPUT

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

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

putPosPtr: Address of the node element (input parameter, type: T_LinkedListEntry).

VAR_OUTPUT

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

bOk: 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 node element that was searched for could not be found, the list is empty, or has overflowed (no more free node elements).

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

getPosPtr: Address of the node element (output parameter, type: T_LinkedListEntry).

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)