Search the next valid entry in a PosTable from a given Index.
Version history
0.1.0
Rioual
Changes
Added:
- initial version
Overview
| kind | name | type | default | comment |
|---|---|---|---|---|
| input | index | INT | index of actual PosTable entry | |
| input | offset | INT | 0=first result, 1=second result, 2=third result | |
| input | posTableSize | INT | number of entries | |
| input | rollOver | BOOL | continue from start after reaching end of table | |
| in_out | posTable | McePosTableData | trajectory to be processed by PosTable |
Details
index
INTIndex to start the search from.
offset
INTNumber of skipped result.
| value | explanation |
|---|---|
| 0 | first result |
| 1 | second result |
| 2 | third result |
posTableSize
INTNumber of entries of the PosTable.
rollOver
BOOLContinue from the top of the PosTable after reaching the end.
posTable
McePosTableDataTrajectory to be processed by PosTable.
Source code
Declarations
(*Index of found PosTable entry (-1=no valid result found)*)
FUNCTION McePosTableFindEntry : INT
(*
* -----------------------------------------------------------------------------
* Name : McePosTableFindEntry
* Version : 0.1.0
* Date : 2024-02-29
* Author : Rioual
* Family : YaskawaMce
* Organisation : github.com/YaskawaEurope/mlx-examples
*
* -----------------------------------------------------------------------------
* Index of found PosTable entry (-1=no valid result found)
* -----------------------------------------------------------------------------
*)
VAR_INPUT
index : INT; (*index of actual PosTable entry*)
offset : INT; (*0=first result, 1=second result, 2=third result*)
posTableSize : INT; (*number of entries*)
rollOver : BOOL; (*continue from start after reaching end of table*)
END_VAR
VAR_IN_OUT
posTable : McePosTableData; (*trajectory to be processed by PosTable*)
END_VAR
VAR
nEntriesFound : INT;
i : INT;
END_VAR
Logic
nEntriesFound := 0;
// -------------------------------------
// forward direction
// -------------------------------------
// search through the remaining part of the array
FOR i := index TO (posTableSize - 1) DO
IF NOT posTable.stEntry[i].bSkipEntry THEN
nEntriesFound := nEntriesFound + 1;
IF (nEntriesFound > offset) THEN
McePosTableFindEntry := i;
RETURN;
END_IF;
END_IF;
IF posTable.stEntry[i].bLastEntry THEN
EXIT;
END_IF;
END_FOR;
// search through the first part of the array
IF rollOver THEN
FOR i := 0 TO index DO
IF NOT posTable.stEntry[i].bSkipEntry THEN
nEntriesFound := nEntriesFound + 1;
IF (nEntriesFound > offset) THEN
McePosTableFindEntry := i;
RETURN;
END_IF;
END_IF;
IF posTable.stEntry[i].bLastEntry THEN
EXIT;
END_IF;
END_FOR;
END_IF;
// no valid result found
McePosTableFindEntry := - 1;
Implementation
Snippet of the function call:
dummy := McePosTableFindEntry(
index := ,
offset := ,
posTableSize := ,
rollOver := ,
posTable := );