Apis Scenario

This module is used for sequential execute mathematical and condition based expressions.

The scenario file is parsed run-time at start up and any changes made to this file will be detected and the scenario will restarted.

NOTE: A scenario script consists of only one START condition and a number of user defined action condition. Supported actions are WHEN, WHILE and END.

The first condition that always must be fulfilled before the different actions conditions are executed is the START condition. A condition is an expression that can be evaluated to true or false. When the start condition is true, the script engine runs through the init sections to initialize the variables before it start to evaluate the different actions in that order it is written. To stop an execution of a script, you use the END action. You can allow the script engine to restart after the END condition is fulfilled by setting the module property AllowScenarioRestart. The figure below shows how to construct an scenario file.


To add comments in a scenario file this can be done by use of '//'

Scenario variable

  • All variables can be initialized in 'Init section'.

  • All variables are global within the same script engine executing the scenario file

  • You can access items in Apis namespace by using syntax '#<ModuleName>.<ItemName>#'. However, this requires that the AssignmentMode is set to UserDefined.

  • Types of variables

    • Internal scenario variables
      • Should be initialized (default value is ’0.0’)
      • Created when used the first time
    • Mapped scenario variables
      • MAP scnItem = #Worker.Variable#. However, this requires that the AssignmentMode is set to UserDefined.
        • The 'scnItem' is an internal scenario variable name which is accessible only the executing script engine
      • Through global attributes '<ModuleName>.Out' and '<ModuleName>.In'

Predefined variable names

NameDescription
ErrorThe numbers of errors
ErrorTextThe last error description
SimTimeExternal reference or PC clock (numbers of seconds since start)

Condition based actions

OperatorDescriptionExample
STARTCondition to start the scriptSTART <condition>
WHILE

Action done each time criterion is met

Note: For RAMP and PULSE the execution of a period will be restarted after the running period is completed as long as the WHILE condition remains true.

WHILE <condition>
WHEN

Action done first time criterion is met.

Note: For RAMP and PULSE the execution of a period will pause if the WHEN condition becomes false in the running period.

WHEN <condition>
ENDCondition to stop the script executionEND <condition>

Expressions supported

In addition to the expressions support in ApisCalculateBee, these functions are supported

FunctionDescriptionSyntax
RAMPThe RAMP function will generate a ramp signal between start and stop at the defined period. In each calculation interval the result will be written to the variable name.RAMP<variable name> <start value> <stop value> <period>
PULSEThe PULSE function will generate a pulse signal between low and high value and stop at the defined period. In each calculation interval the result will be written to the variable name.PULSE <variable name> <low value> <high value> <period>

Provider: Prediktor

Properties