公关opagate Variant Conditions from Variant Source Blocks to Subsystem Blocks
A Subsystem block can represent a virtual subsystem or a nonvirtual subsystem. A virtual subsystem provides graphical hierarchy in a model and does not impact the execution of a model. A nonvirtual subsystem executes as a single unit within a model. Simulink propagates variant conditions differently to these subsystems. This example shows the propagation of variant conditions from a Variant Source block to Subsystem blocks.
Explore the Model
Open the model,slexVariantCondPropToSubsystems
.
ClickSimulation>Runto simulate this model and see the variant conditions being propagated from the Variant Source blocks to the blocks connected to it.
The variant condition annotation helps you visualize the propagated conditions. To be able to view the variant condition annotation, clickDisplay>Blocks>Variant Condition Legend.
The model contains three Variant Source blocks:Variant Source1
,Variant Source2
, andVariant Source3
, respectively.
Variant Source1
contains conditionsV = 1
andV = 2
at inport. The variant conditionV = 1
propagates toGainA1
whileV = 2
propagates toSine2
. TheSine1
block does not get any propagated variant conditions because it is connected to a block, which is always consumed irrespective of the variant condition. If theTo Workspace block1
did not exist or was commented-out before simulating the model, variant conditionV = 1
propagates toSine1
.
Variant Source2
is connected to virtual subsystemsSubsystem1
andSubsystem2
that have identical contents, aSine Wave
block connected to aTo Workspace
and anOutput
blocks.Subsystem1
is a grouped virtual subsystem (Treat as grouped when propagating variant conditionsis selected) while Subsystem2 (Treat as grouped when propagating variant conditionsis clear) is an ungrouped virtual subsystem.
A Subsystem block becomes a grouped virtual subsystem when you select theTreat as grouped when propagating variant conditionscheck box in the block parameters dialog box. When theTreat as grouped when propagating variant conditionscheck box is clear, the subsystem is an ungrouped virtual subsystem.
A grouped subsystem represents a system of equation and hence the propagated conditions also apply to the blocks within this system. A grouped subsystem has a continuous boundary line. An ungrouped subsystem does not represent a system of equation and the blocks within it have ungrouped semantics. An ungrouped subsystem has a dotted boundary line and the conditions are propagated into the subsystem.
The variant conditionV = 1
propagates toSubsystem1
and further to the blocks within it asSubsystem1
is a grouped virtual subsystem (represents a system of equation). Since Subsystem1 is a system, the condition also applies the blocks within the system.
Subsystem2
that is an ungrouped virtual subsystem (does not represent a system of equation) also receivesV = 1
as the propagated condition, and the propagated variant conditionV = 1
propagates intoSubsystem 2
as if the subsystem were expanded. The dotted lines on the Subsystem 2 icon indicates that it is flattened during Simulink compilation and hence you can see variant condition for those blocks inside it.
Variant Source3
is connected to a nonvirtual (atomic) subsystem withV = 1
as the propagated variant condition. A nonvirtual (atomic) subsystem always represents a system of equations. An atomic subsystem has a continuous solid boundary line. The variant condition does not propagate inside the nonvirtual subsystem. Instead, it stays on the boundary. However, all blocks inside that subsystem get same variant condition as the Subsystem. The nonvirtual subsystem behaves as an entity.
Virtual subsystems by default works like a grouped collection of blocks where all the blocks contained inside the subsystem have the same variant condition. This is true when theTreat as grouped when propagating variant conditionsparameter is selected. Virtual subsystems behave like an ungrouped collection of blocks when theTreat as grouped when propagating variant conditionsparameter is cleared. In this example, the behavior of the Subsystem2 (Ungrouped) may not be as expected as the block never becomes conditional. Nonvirtual subsystems always behave like an entity and the contents only execute when the condition assigned to the subsystem is satisfied. Nonvirtual subsystems, Model blocks, and grouped virtual subsystems behave the same.
Virtual Subsystems with Treat as Grouped when Propagating Variant Conditions
Treat as grouped when propagating variant conditionsoption is On: Consider an example with Variant Source block:Variant Source5
and a virtual subsystemSubsystem4
. TheVariant Source5
has a conditionV = 1
.Subsystem4
has a Sine Wave connected to aTo Workspace1
andOutport
blocks.
Subsystem4 gets conditionV = 1
asV = 1
is propagated fromVariant Source5
. The blocks insideSubsystem4
间接继承的条件Subsystem4
.Subsystem4
is conditional as its inports/outports are conditional. To make theSubsystem4
as unconditional, add a new outport or clear theTreat as grouped when propagating variant conditionsoption.
Treat as grouped when propagating variant conditionsoption is Off: Consider an example with a Variant Source block:Variant Source4
and a virtual subsystemSubsystem3
. TheVariant Source4
has conditionV = 1
.Subsystem3
has a Sine Wave connected to aTo Workspace
andOutport
blocks.
Subsystem3
gets the conditionV = 1
asV = 1
propagates fromVariant Source4
. However due to unconditional blockTo Workspace1
, the propagation stops and the conditionV = 1
is set only to theOut1
port. Now theSubsystem3
is also unconditional due to presence of unconditional blocks within.