Nonvirtual Buses at Model Interfaces
A model reference boundary is the boundary between a model that contains aModelblock and the referenced model. If bus data passes to aModelblock, then that data crosses the boundary to the referenced model. Bus data input for theModelblock must be consistent with the bus data that the referenced model requires.
For bus data that crosses model reference boundaries, decide whether to use a virtual or nonvirtual bus. Using a virtual bus can be simpler than using a nonvirtual bus. However, using a nonvirtual bus provides a well-defined data interface for code generation. To learn the differences between virtual and nonvirtual buses, seeTypes of Composite Signals.
Tip
For virtual buses at interfaces, useIn Bus ElementandOut Bus Elementblocks. These blocks support multirate virtual buses and do not requireSimulink.Bus
objects.
For nonvirtual buses at interfaces, useInportandOutportblocks.
Model Reference Requirements for Nonvirtual Buses
If you use a bus as an input to or an output from a referenced model:
Only a nonvirtual bus can contain variable-size signal elements.
For code generation, you can only configure the
I/O arguments step method
style of C++ class interface for the referenced model when using a nonvirtual bus or when using theDefault
style of C++ class interface.For code generation, you can only configure function prototype control for the referenced model when using a nonvirtual bus.
Nonvirtual公交车与根级InportBlocks
To pass a bus from a root-levelInportblock into a referenced model, in the Block Parameters dialog box of theInportblock:
Set theData typeparameter to
Bus:
Replace
with the name of the
Bus
object that defines the bus theInportblock produces.
To output a nonvirtual bus from the root-levelInportblock, select输出作为nonvirtual busin the Block Parameters dialog box of theInportblock.
All signals in a nonvirtual bus must have the same sample time. For details, seeModify Sample Times for Nonvirtual Buses.
For information about importing data to root-levelInportblocks, seeLoad Bus Data to Root-Level Input Ports.
Nonvirtual公交车与根级OutportBlocks
To pass a bus through a root-levelOutportblock of a referenced model, in the Block Parameters dialog box of theOutportblock:
SetData typeto
Bus:
.Replace
with the name of the
Bus
object that defines the bus theOutportblock produces.
To output a nonvirtual bus from the port that corresponds to the root-levelOutportblock, select输出作为nonvirtual bus in parent modelin the Block Parameters dialog box of theOutportblock.
All signals in a nonvirtual bus must have the same sample time. For details, seeModify Sample Times for Nonvirtual Buses.
Rate Transitions for Nonvirtual Buses
To pass a multirate bus as a nonvirtual bus into a referenced model, use anInportblock. Add blocks in the parent and referenced model as follows:
In the parent model, convert the multirate bus to a single-rate bus by inserting aRate Transitionblock.Inportblocks can only pass single-rate nonvirtual buses into referenced models. TheRate Transition块必须指定a rate in itsBlock Parameters>Output port sample timefield unless one of the following is true:
TheConfiguration Parameters>Solverpane specifies a rate with these settings:
ThePeriodic sample time constraintparameter is set to
Specified
.TheSample time propertiesparameter contains the specified rate.
TheInportblock that accepts the nonvirtual bus in the referenced model specifies a rate in itsBlock Properties>Signal Attributes>Sample timefield.
In the referenced model, use aBus Selectorblock to pick out signals of interest, and useRate Transitionblocks to convert the signals to the desired rates.
See Also
Blocks
- Bus Creator|Bus Selector|In Bus Element|Inport|Out Bus Element|Outport|Rate Transition|Signal Conversion