This block sorts an array of type LReal
with any number of elements (max. 1000) in ascending or descending order and returns the sorted version of the array in the same variable.
LGF_ShellSort_LReal (FB) | ||||||||
---|---|---|---|---|---|---|---|---|
Bool | sortDirection | error | Bool | |||||
status | Word | |||||||
Array[*] of LReal | array | Array[*] of LReal | ||||||
Identifier | Data type | Default value | Description |
---|---|---|---|
sortDirection | Bool | FALSE | FALSE: Sort ascending; TRUE: Sort descending |
Identifier | Data type | Description |
---|---|---|
error | Bool | FALSE: No error TRUE: An error occurred during the execution of the FB |
status | Word | 16#0000-16#7FFF: Status of the FB 16#8000-16#FFFF: Error identification (see following Table) |
Identifier | Data type | Description |
---|---|---|
array | Array[*] of LReal | Array to be sorted |
Code / Value | Identifier / Description |
---|---|
16#0000 | STATUS_NO_ERROR Status: Execution finished without errors |
16#8200 | ERR_NO_ARRAY Error: Actual parameter at the `array` input has only one element. |
16#8201 | ERR_TOO_MANY_ELEMENTS Error: Actual parameter at the `array` input has too many elements (maximum is 1000). |
The block sorts according to the shell sort procedure. Note that the execution time of the block depends significantly on how many elements the array to be sorted has. The overview below shows several measured values of the block depending on the number of array elements.
Average steps needed for execution: \mathcal{O}( n \cdot \log (n)^2 )
Table: Execution times of the block LGF_ShellSort…
Number of array elements | S7-1212C DC/DC/DC | S7-1516-3 PN/DP |
---|---|---|
100 | approx. 11-16 ms | approx. 1-2 ms |
1000 | approx. 185-205 ms | approx. 10-12 ms |
Version & Date | Change description | |
---|---|---|
01.00.00 | Siemens Industry Online Support | |
19.08.2015 | First released version | |
01.01.00 | Siemens Industry Online Support | |
19.05.2016 | New function: reverse sort | |
01.01.01 | Siemens Industry Online Support | |
02.01.2017 | Upgrade: TIA Portal V14 Update 1 | |
01.01.02 | Siemens Industry Online Support | |
17.08.2018 | Upgrade: TIA V15 Update 2 | |
01.01.03 | Siemens Industry Online Support | |
23.11.2018 | Upgrade: TIA V15.1 | |
02.00.00 | Siemens Industry Online Support | |
29.01.2019 | Output "done" removed (not necessary, because only one cycle) | |
02.00.01 | Simatic Systems Support | |
15.10.2019 | Code refactoring, comments added, change data type from Real to LReal | |
03.00.00 | Simatic Systems Support | |
23.04.2020 | Set version to V3.0.0, harmonize the version of the whole library | |
03.00.01 | Simatic Systems Support | |
15.02.2021 | Insert documentation |