Engee documentation

Switch Case

Selects a subsystem for execution using logic similar to the switch operator.

switch case

Description

The Switch Case block with Switch Case Action Subsystem blocks containing Action Port blocks implements switching logic to control the execution of the subsystem.

switch case subsystem example

A Switch Case block has one input. To select a variation, relate it to the input signal value using the Case conditions parameter. The options are evaluated from top to bottom, starting with the first option.

Each variant is associated with an output port that is attached to the Switch Case Action Subsystem block. When an option is selected, the associated output port sends an action signal to execute the subsystem.

The default option is selected after all other conditions are evaluated as false. The presence of the `default' option is optional, even if the other conditions do not exhaust all possible input values.

The options for the Switch Case block already contain an analogue of the break operator after the Switch Case Action Subsystem block is executed. Therefore, for the Switch Case block it is not necessary to specify it explicitly, as in the standard switch operators of the C language.

Ports

Input

u1 (logical operator) - value for selecting a variant
scalar

Input signal for variant selection

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

Output

case - action signal for the Switch Case Action Subsystem unit
scalar

Output from Case and By default ports are action signals associated with Switch Case Action Subsystem blocks.

Data types: Float64.

Parameters

Edit output ports - number and names of output ports
12 (By default)

The number of output ports of the block is equal to the number of characters in this line. The characters become the names of these ports.

Case conditions (e.g., {1,[2,3]}) - variant values
[1] (by default).

Sets the values corresponding to the variants.

[1]

Indicates that the output port marked as case[1] outputs an action signal when the value of the input port is 1.

You can use an entry with a colon to specify a range of integer register conditions. For example, the value {[1:5]} indicates that the output port option [1 2 3 4 5] is executed when the input value is 1, 2, 3, 4, or 5.

Depending on the block size, variants from the long list of variant states are displayed in shortened form on the face of the Switch Case block as a multipoint (…​).

Usage in program code

Block parameter

CaseConditions

Values

[1] | <list of cases>

By default

[1]

Show default case - output port display control
enabled (by default) | disabled

Output port display control by default.

on

The By default output port is displayed as the last option in the Switch Case block. This allows you to specify the option by default that is executed when the input value does not match any of the other values.

off

The output port is hidden by default.

Usage in program code

Block parameter

ShowDefaultCase

Values

on | off

By default

enabled

Additional options

C code generation: Yes

Examples