Engee documentation

While Iterator

Control unit for the while-iterator subsystem.

while iterator

Description

The While Iterator block placed in the Subsystem block , executes the subsystem during the current time step if the value of the input condition is true (1). Use this block to implement logic equivalent to a while loop in a programming language.

Ports

Input

cond - logical state
scalar

Signal with the result of the evaluation of the logical condition. Since the subsystem is not started externally during the time step, the evaluation of the condition as true (1) or false (0) must reside within the subsystem.

The data type and values of the signal can be:

  • Logical (Boolean) - true (1) or false (0).

  • Numeric - true (any positive or negative number) or false (0).

Data types: Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Bool.

IC (initial logical condition) - initial logical condition
scalar

Signal with initial logical condition. At the beginning of each time step:

  • If IC is false (0), the subsystem is not executed during the time step.

  • If IC is true (value is not equal to 0), the subsystem starts execution and keeps repeating execution as long as the cond signal is true.

Dependencies

To enable the IC port, set the While loop type parameter to `while'.

Data types: Float16, Float32, Float64, Int8, Int16, Int32, Int64, UInt8, UInt16, UInt32, UInt64, Bool.

Output

Iteration number - number of iterations
scalar

Signal with the number of block executions at each time step.

Dependencies

To enable the Iteration number port, set Show iteration number port to `enabled'.

Data types: Float64.

Parameters

Maximum number of iterations (-1 for unlimited) - maximum number of iterations
5 (by default) | -1 | integer

Set the maximum number of iterations allowed during a time step.

  • -1 is any number of iterations as long as the cond signal is true (the value is not equal to 0).
    If you specify -1 and the cond signal never becomes false (0), the simulation runs in an infinite loop. In this case the only way to stop the simulation is to close Engee.

  • ` Integer` is the maximum number of iterations during a time step.

Usage in program code

Block parameter

MaxIters

Type

character vector

Values

5 | -1 | integer

By default

5

While loop type - block type
while (by default) | do-while | do-while

Select the block type.

  • while - While Iterator block has two inputs: cond input (logical condition) and IC input (initial logical condition).
    The source of the IC signal must be external to the While Iterator Subsystem block.
    At the beginning of each time step:
    - If the IC input is true (value is not equal to 0), the blocks in the subsystem repeat execution as long as the cond input is true.
    This process continues for a time step as long as the cond input is true and the number of iterations Maximum number of iterations.
    - if the IC input is false, the While Iterator block does not execute the contents of the subsystem.

  • do-while - the While Iterator block has one input, the cond input (while condition).
    At each time step, the blocks in the subsystem are executed as long as the value on the cond input is true (not equal to 0).
    This process continues as long as the value at the cond input is true and the number of iterations Maximum number of iterations.

Usage in program code

Block parameter

WhileBlockType

Type

character vector

Values

while | do-while

By default

while

Show iteration number port - control output port display
off (By default) | on

Control the output port display for the block execution number signal.
The signal value from this port starts at 1 and increases by 1 for each subsequent iteration.

  • disable - do not display the output port.

  • enabled - display the output port for the signal with iteration number.

Usage in program code

Block parameter

ShowIterationPort

Type

character vector

Values

disabled | enabled

* By default*

off

Additional options

C code generation: Yes