Simatic.AX.Collections

This collection library contains some classes for list handling of types of IListItem. Unfortunately the ST implementation does not support any generic data types and also no dynamic memory allocation. Therefore this example library has much space for improvement and it is open for discussion with other users.

The actual implementation is based on a linked list item (IListItem) where you need to create for each item a instance (which also can be stored in an array) The Advantage of the concept is, that you don't need to use arrays with fixed size and you can mix the types as long as they're of type IListItem.

Important: By inserting, adding, writing some items NO copy of the object will be created. You need to manage the list items by yourself.

Install this package

Enter:

apax add @simatic-ax/collections

Namespace

Simatic.Ax.Collections;

to install this package you need to login into the GitHub registry. You'll find more information here

Linked List

LinkedList.Add() : IListItem Method

Add a new object IListItem to the end of the list

Parameter Type Description
Return Value IListItem Reference to the inserted item
item IListItem Item to be inserted
join BOOL Create a ring list. First and last element will be linked. It works only once with the latest item which is added.
METHOD PUBLIC FINAL Add : IListItem
    VAR_INPUT
        item : IListItem;
        join : BOOL := FALSE;
    END_VAR
END_METHOD

LinkedList.Remove() : BOOL Method

Remove a IListItem from the list.

METHOD PUBLIC Remove : BOOL
    VAR_INPUT
        item : IListItem;
    END_VAR
END_METHOD
Parameter Type Description
Return Value Bool Removing item was successful
item IListItem Reference to item to be removed

Fifo

Represents a first-in, first-out (FIFO) collection of IListItem.

Fifo.Enqueue(item : IListItem) : IListItem Method

METHOD Enqueue : IListItem
    VAR_INPUT
        item : IListItem;
    END_VAR
END_METHOD
Parameter Type Description
Return Value IListItem Reference to the enqueued item
item IListItem Item to be inserted

Fifo.Dequeue() : IListItem Method

METHOD Dequeue : IListItem
END_METHOD
Parameter Type Description
Return Value IListItem Return and remove the oldest element in the list

Fifo.Count() INT

    METHOD PUBLIC Count : INT
    END_METHOD
Parameter Type Description
Return Value INT Count of elements in the FIFO

Stack

Represents a simple last-in-first-out (LIFO) collection of IListItem.

Stack.Push(item : IListItem) : IListItem Method

METHOD Push : IListItem
    VAR_INPUT
        item : IListItem;
    END_VAR
END_METHOD
Parameter Type Description
Return Value IListItem Reference to the pushed item
item IListItem Item to be inserted

Stack.Pop() : IListItem Method

METHOD Pop : IListItem
END_METHOD
Parameter Type Description
Return Value IListItem Return and remove the newest element in the list

Stack.Peek() : IListItem Method

METHOD Peek : IListItem
END_METHOD
Parameter Type Description
Return Value IListItem Return the newest element in the list (without removing)

Stack.Count() : INT

    METHOD PUBLIC Count : INT
    END_METHOD
Parameter Type Description
Return Value INT Count of elements in the LIFO

Contribution

Thanks for your interest in contributing. Anybody is free to report bugs, unclear documentation, and other problems regarding this repository in the Issues section or, even better, is free to propose any changes to this repository using Merge Requests.

Markdownlint-cli

This workspace will be checked by the markdownlint-cli (there is also documented ho to install the tool) tool in the CI workflow automatically.
To avoid, that the CI workflow fails because of the markdown linter, you can check all markdown files locally by running the markdownlint with:

markdownlint **/*.md --fix

License and Legal information

Please read the Legal information