Switch Case
Selects a subsystem for execution using logic similar to the switch operator.
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.
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
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 is1
.
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 (…)
.
Block parameter |
|
Values |
|
By default |
|
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.
Block parameter |
|
Values |
|
By default |
|