Propagate Variant Conditions from Variant Source Blocks to Conditionally Executed Subsystems
Aconditionally executed subsystemis a nonvirtual subsystem that allows you to control its execution with an external signal. Enabled, Triggered, and Function-Call Subsystems are examples of conditional subsystems. The external signal that controls a conditional subsystem is called thecontrol signaland the port through which the signal enters the block is called thecontrol port。For more information on conditional subsystems, seeConditionally Executed Subsystems Overview。
You can use a single-input/single-output or a multi-inputVariant Sourceblock to control the execution of conditional subsystems based on the active variant conditions at the inports of theVariant Sourceblock.
Use Variant Source Block to Control Execution of Conditional Subsystem Blocks
This example shows how to use a single-input/single-output Variant Source block to control the execution of a conditional subsystem block.
Explore the Model
Open the modelslexVariantControlPorts
。
The model contains a single-input/single-output Variant Source block,变体Source1
, with variant condition set asV==1
。The output from变体Source1
block is connected to the control port of the Enabled SubsystemSubsystem
。
TheAllow zero active variant controlsparameter on the变体Source1
block is set toon
。When this option is selected and there is no active variant choice, Simulink® disables all the blocks connected to the input and output stream of the Variant Source block.
When you simulate the model after settingV=1
,conditionV==1
propagates to the outport of变体Source1
and then to the control port ofSubsystem
。The condition assigned to the subsystem block then propagates to the blocks namedSine2
andOut1
connected to its input and output ports. If you setV
to a value other than1
, Simulink disables all the blocks connected to the inport and outport of变体Source1
。
Propagate Variant Conditions to Function-Call Subsystems
A Function-Call Subsystem block is a subsystem that another block can invoke directly during simulation. The Function-Call Subsystem block is analogous to a function in procedural programming language. For more information, seeUsing Function-Call Subsystems。
You can use a Variant Source block to make the Function-Call Subsystem block conditional.
The Variant Source block has conditionV==1
, whereV
is aSimulink.Parameter
。
TheOutput function callparameter on the Variant Source block is set toon
。这使得块输出函数call signals.
TheAllow zero active variant controlsparameter on the Variant Source block is set toon
。
When you simulate this model, the variant condition from the Variant Source block propagates to the control port of theSubA
subsystem block and further propagates to the blocks connected to its inports and outports.
When
V=1
,SubA
block is active and the variant condition propagates backward and forward to the blocks connected to the input (三机一体
) and output (Out1
) ports.
When
V~=1
(for example,V=0
),SubA
becomes inactive, which makesOut1
inactive.In2
remains active because it is connected toSubB
, which is active.
If
In2
is not connected toSubB
,In2
变得不活跃的时候V~=1
。
Note: If the Function-Call Subsystem is placed inside a virtual grouped subsystem, the variant condition triggering the Function-Call Subsystem must match the corresponding condition on the input of the higher level subsystem block.