Variant Source
Variable routing between multiple inputs.
Description
The Variant Source block allows multiple implementations of a signal source component to be included in a single layer.
A Variant Source block has one or more input ports and only one output port. Alternatives are connected to the input port of the block so that a maximum of one alternative is active during model execution.
The Variant control mode parameter defines the variant control mode. During simulation Engee connects the active variant directly to the output port of the Variant Source block and ignores inactive variants.
Using the Variant Source block allows:
-
Extend the conditions for selecting alternatives to the entire model.
-
Improve model performance at runtime because Engee does not consider inactive blocks. If all choices are inactive, Engee completely disregards the variant region of the model.
-
Use variant component interfaces for fast modelling of variant selection.
Ports
Input
Port_1 - input signal for the first variant
scalar
| vector
| matrix
Input signal for the first variant.
Data types: Float16
, Float32
, Float64
, Int8
, Int16
, Int32
, Int64
, Int128
, UInt8
, UInt16
, UInt32
, UInt64
, UInt128
, Fixed-point
, Bool
.
Port_N - input signal for the N-th variant
scalar
| vector
| matrix
Input signal for the N-th variant.
Data types: Float16
, Float32
, Float64
, Int8
, Int16
, Int32
, Int64
, Int128
, UInt8
, UInt16
, UInt32
, UInt64
, UInt128
, Fixed-point
, Bool
.
Parameters
Variant control mode - variant control mode
expression (by default)
| label
| sim codegen switching
The variant control that determines the selection of the active variant can be of any of these types:
-
expression
- in this mode, Engee selects the active option based on the evaluation of the option’s conditions. When the condition expression evaluates totrue
, the corresponding option becomes active. When the condition expression evaluates tofalse
, the corresponding option becomes inactive. -
label
- In this mode, Engee selects the active variant based on the variant name. The variant control is a string and does not require the creation of variables in workspaces. -
sim codegen switching
- in this mode it is possible to automatically switch between variants for simulation and code generation workflows without creating variables in the workspace. When simulating a model, Engee automatically selects the sim branch as the active option. When generating code in Engee automatically selects the codegen branch.
Block parameter |
|
Values |
|
By default |
|
Number of choices - number of choices
2 (by default)
| positive integer
Number of choices as a positive integer. The maximum number of choices is `32.
Port N Variant control expression - expression defining the activity of the N-th output port
An expression that defines the activity of the Nth input port. The default
string can be specified instead of the expression to select the active By default, which will be used if all other expressions are false.
Only one default option must be specified or an error will occur.
Port N Variant control label - Nth port label
All data entered in this field will be considered as a string. The active variant should be selected in the Label mode active choice field, where the label of the active variant should be entered.
Port N Variant control switch - label of the N-th port for the sim codegen switching
mode
These fields are displayed if Variant control mode
is equal to im codegen switching
. In this mode two configurable ports are always available: one of them must be set to (sim)
and the other to (codegen)
.
Label mode active choice - name of the active choice in label
mode
none (By default)
Name of the active choice in label mode. The entered name will become the active label.
Dependencies
To use this parameter, set the Variant control mode parameter to label
.
Allow zero active variant controls - modelling without selecting an active variant
off (By default)
| `on
Select this checkbox to allow the possibility that none of the variants will be active.
If the checkbox is not selected, Engee generates an error if no active option is selected.
Dependencies
To use this option, set the Variant control mode parameter to expression
.
Block parameter |
|
Values |
|
By default |
|