Count the number of valid remaining entries in a PosTable from a given Index.
Version history
0.3.0
Rioual
Changes
Changed:
conditionsare passed as an input instead of in_out- Use
conditiondOKinstead ofhasConditionfor waiting at the next entry
show full history
0.2.0
Rioual
Changes
Added:
- If the next valid entry has conditions, the current entry is a standstill
0.1.0
Rioual
Changes
Added:
- initial version
Overview
| kind | name | type | default | comment |
|---|---|---|---|---|
| input | index | INT | index of actual PosTable entry | |
| input | loadIndex | INT | index for loading next motion(s) | |
| input | posTableSize | INT | number of entries | |
| input | rollOver | BOOL | continue from start after reaching end of table | |
| input | conditions | ARRAY [0..GVL.CONDITIONS_UBOUND] OF BOOL | bits used as start conditions for a PosTable entry | |
| in_out | posTable | McePosTableData | trajectory to be processed by PosTable |
Details
index
INTIndex to start the search from.
loadIndex
INTIndex of the last loaded motion.
posTableSize
INTNumber of entries of the PosTable.
rollOver
BOOLContinue from the top of the PosTable after reaching the end.
conditions
ARRAY [0..GVL.CONDITIONS_UBOUND] OF BOOLBits used as start conditions for a PosTable entry.
If a PosTable entry has one or more bits in startConditions set to TRUE
then the motion for that entry will not be started until the start conditions
are satisfied.
- Conditions are only checked for the
TRUEstate - If you need a condition to be checked for the
FALSEstate, you need to invert the connected signal outside of PosTable
posTable
McePosTableDataTrajectory to be processed by PosTable.
Source code
Declarations
(*remaining (valid) PosTable entries*)
FUNCTION McePosTableRemainingEntries : INT
(*
* -----------------------------------------------------------------------------
* Name : McePosTableRemainingEntries
* Version : 0.3.0
* Date : 2024-05-15
* Author : Rioual
* Family : YaskawaMce
* Organisation : github.com/YaskawaEurope/mlx-examples
*
* -----------------------------------------------------------------------------
* remaining (valid) PosTable entries
* -----------------------------------------------------------------------------
*)
VAR_INPUT
index : INT; (*index of actual PosTable entry*)
loadIndex : INT; (*index for loading next motion(s)*)
posTableSize : INT; (*number of entries*)
rollOver : BOOL; (*continue from start after reaching end of table*)
conditions : ARRAY [0..GVL.CONDITIONS_UBOUND] OF BOOL; (*bits used as start conditions for a PosTable entry*)
END_VAR
VAR_IN_OUT
posTable : McePosTableData; (*trajectory to be processed by PosTable*)
END_VAR
VAR
i : INT;
nCount : INT;
stConditionResult : McePosTableConditions; (*state if the next motion condition are satisfied*)
nNextIndex : INT; (*next valid entry*)
nNextLoadIndex : INT;
bWaitForConditions : BOOL;
END_VAR
Logic
IF (index < 0) OR (index > (posTableSize - 1)) THEN
McePosTableRemainingEntries := 0;
RETURN;
END_IF;
nCount := - 1;
MEMUtils.MemSet(pbyBuffer := ADR(stConditionResult), byValue := 0, dwSize := SIZEOF(stConditionResult));
nNextLoadIndex := McePosTableFindEntry(loadIndex, 1, posTableSize, rollOver, posTable);
bWaitForConditions := index = nNextLoadIndex;
// -------------------------------------
// forward direction
// -------------------------------------
// search through the remaining part of the array
FOR i := index TO (posTableSize - 1) DO
IF NOT posTable.stEntry[i].bSkipEntry THEN
nCount := nCount + 1;
// check conditions for the next valid position
nNextIndex := McePosTableFindEntry(i, 1, posTableSize, rollOver, posTable);
IF nNextIndex >= 0 AND NOT ((index <= nNextIndex AND nNextIndex <= loadIndex) OR (loadIndex < index AND index < nNextIndex AND NOT bWaitForConditions)) THEN
stConditionResult := McePosTableCheckConditions(
index := nNextIndex,
posTableSize := posTableSize,
conditions := conditions,
posTable := posTable);
ELSE
stConditionResult.bConditionsOk := TRUE;
END_IF;
// entry with standstill action or next entry with conditions, stop searching
IF (posTable.stEntry[i].nActionID > 0) OR NOT stConditionResult.bConditionsOk THEN
McePosTableRemainingEntries := nCount;
RETURN;
// last move, ignore further entries
ELSIF posTable.stEntry[i].bLastEntry THEN
EXIT;
END_IF;
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
nCount := nCount + 1;
// check conditions for the next valid position
nNextIndex := McePosTableFindEntry(i, 1, posTableSize, FALSE, posTable);
IF nNextIndex >= 0 AND NOT ((index <= nNextIndex AND nNextIndex <= loadIndex) OR (loadIndex < index AND index < nNextIndex AND NOT bWaitForConditions)) THEN
stConditionResult := McePosTableCheckConditions(
index := nNextIndex,
posTableSize := posTableSize,
conditions := conditions,
posTable := posTable);
END_IF;
// entry with standstill action or next entry with conditions, stop searching
IF (posTable.stEntry[i].nActionID > 0) OR NOT stConditionResult.bConditionsOk THEN
McePosTableRemainingEntries := nCount;
RETURN;
// last move, ignore further entries
ELSIF posTable.stEntry[i].bLastEntry THEN
EXIT;
END_IF;
END_IF;
END_FOR;
// unlimited entries to go
nCount := 9999;
END_IF;
McePosTableRemainingEntries := nCount;
Implementation
Snippet of the function call:
dummy := McePosTableRemainingEntries(
index := ,
loadIndex := ,
posTableSize := ,
rollOver := ,
conditions := ,
posTable := );