McePosTableRemainingEntries

0.3.0

Count the number of valid remaining entries in a PosTable from a given Index.

Version history

0.3.0

  Rioual

Changes

Changed:
  • conditions are passed as an input instead of in_out
  • Use conditiondOK instead of hasCondition for 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

kindnametypedefaultcomment
inputindexINTindex of actual PosTable entry
inputloadIndexINTindex for loading next motion(s)
inputposTableSizeINTnumber of entries
inputrollOverBOOLcontinue from start after reaching end of table
inputconditionsARRAY [0..GVL.CONDITIONS_UBOUND] OF BOOLbits used as start conditions for a PosTable entry
in_outposTableMcePosTableDatatrajectory to be processed by PosTable

Details

index

INT

Index to start the search from.

loadIndex

INT

Index of the last loaded motion.

posTableSize

INT

Number of entries of the PosTable.

rollOver

BOOL

Continue from the top of the PosTable after reaching the end.

conditions

ARRAY [0..GVL.CONDITIONS_UBOUND] OF BOOL

Bits 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 TRUE state
  • If you need a condition to be checked for the FALSE state, you need to invert the connected signal outside of PosTable

Trajectory 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 := );

Pages built with Hugo - 17 Dec 2025 17:25 CET