CogniPilot

MODELICA LIBRARY · ENGINEERING REFERENCE

function

Vehicles.Interfaces.activeScheduleRow

Locate the last schedule row whose activation time has passed

A zero-order hold over a time-indexed table. Scanning the whole table makes the result a function of time alone, so it does not depend on when sampling started or on a retained row index.

Public declarations

Explicit source declarations; dimensions, modifications and defaults are shown as written, without evaluation.

RoleNameTypeDimensions / attributes / defaultDescription
inputnow_sReal(unit = "s")
inputactivationTime_sReal[:](each unit = "s")Strictly ascending activation times
outputrowInteger(min = 1, max = size(activationTime_s, 1))

Modelica declarations and implementation

Show parameters, interfaces and source

Parameters, inputs, outputs, defaults and equations from the source file.

function activeScheduleRow
  "Locate the last schedule row whose activation time has passed"
  input Real now_s(unit = "s");
  input Real activationTime_s[:](each unit = "s")
    "Strictly ascending activation times";
  output Integer row(min = 1, max = size(activationTime_s, 1));
algorithm
  row := 1;
  for index in 1:size(activationTime_s, 1) loop
    if now_s >= activationTime_s[index] then
      row := index;
    end if;
  end for;
  annotation(Documentation(info = "<html>
    <p>A zero-order hold over a time-indexed table. Scanning the whole table
    makes the result a function of time alone, so it does not depend on when
    sampling started or on a retained row index.</p>
  </html>"));
end activeScheduleRow;