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.
Enter:
apax add @simatic-ax/collections
Simatic.Ax.Collections;
to install this package you need to login into the GitHub registry. You'll find more information here
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
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 |
Represents a first-in, first-out (FIFO) collection of IListItem.
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 |
METHOD Dequeue : IListItem
END_METHOD
Parameter | Type | Description |
---|---|---|
Return Value | IListItem | Return and remove the oldest element in the list |
METHOD PUBLIC Count : INT
END_METHOD
Parameter | Type | Description |
---|---|---|
Return Value | INT | Count of elements in the FIFO |
Represents a simple last-in-first-out (LIFO) collection of IListItem.
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 |
METHOD Pop : IListItem
END_METHOD
Parameter | Type | Description |
---|---|---|
Return Value | IListItem | Return and remove the newest element in the list |
METHOD Peek : IListItem
END_METHOD
Parameter | Type | Description |
---|---|---|
Return Value | IListItem | Return the newest element in the list (without removing) |
METHOD PUBLIC Count : INT
END_METHOD
Parameter | Type | Description |
---|---|---|
Return Value | INT | Count of elements in the LIFO |
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.
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
Please read the Legal information