McePosTableRemainingEntries

0.1.0

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

Version history

0.1.0

  Rioual

Changes

Added:
  • initial version

Overview

kindnametypedefaultcomment
inputindexINTindex of actual PosTable entry
inputposTableSizeINTnumber of entries
inputrollOverBOOLcontinue from start after reaching end of table
in_outposTableMcePosTableDatatrajectory to be processed by PosTable

Details

index

INT

Index to start the search from.

posTableSize

INT

Number of entries of the PosTable.

rollOver

BOOL

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

Trajectory to be processed by PosTable.

Source code

Declarations

(*remaining (valid) PosTable entries*)
FUNCTION McePosTableRemainingEntries : INT

(*
 * -----------------------------------------------------------------------------
 * Name               : McePosTableRemainingEntries
 * Version            : 0.1.0
 * Date               : 2024-02-29
 * Author             : Rioual
 * Family             : YaskawaMce
 * Organisation       : github.com/YaskawaEurope/mlx-examples
 * 
 * -----------------------------------------------------------------------------
 * remaining (valid) PosTable entries
 * -----------------------------------------------------------------------------
 *)

VAR_INPUT
  index : INT; (*index of actual PosTable entry*)
  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
  i : INT;
  nCount : INT;
END_VAR

Logic

IF (index < 0) OR (index > (posTableSize - 1)) THEN
  McePosTableRemainingEntries := 0;
  RETURN;
END_IF;

nCount := - 1;

// -------------------------------------
// 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;

    // entry with standstill action, stop searching
    IF (posTable.stEntry[i].nActionID > 0) 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;

      // entry with standstill action, stop searching
      IF (posTable.stEntry[i].nActionID > 0) 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 := , 
           posTableSize := , 
           rollOver := , 
           posTable := );

Pages built with Hugo - 23 Apr 2024 11:54 CEST