Decompose and Reuse Components
Every component in an architecture model can have its own design, or even several design alternatives. These designs can be architectures modeled in System Composer™ or behaviors modeled in Simulink®. Engineering systems often use the same component design in multiple places. A common component, such as power switch, can be part of all electrical components. You can reuse a component in System Composer within the same model as well as across architecture models.
Architecture Reference | How to Use | More Information |
---|---|---|
System Composer model reference | Define component hierarchy with a linked architecture model to easily reuse these definitions across architectural components. | Create Architecture Model Reference |
System Composer subsystem reference | Define component hierarchy with a linked architecture subsystem to easily reuse these definitions across architectural components. Subsystems support root-level physical ports to use with Simscape™ physical behaviors. | Create Architecture Subsystem Reference |
Tip
To learn more about how System Composer concepts apply to systems engineering design, see System Composer Concepts.
Decompose Component
A component can have its own architecture. Double-click a component to view or edit its architecture. When you view the component at this level, its ports appear as architecture ports. Use the Model Browser to view component hierarchy.
You can add components, ports, and connections at this level to define the architecture.
You can also make a new Component block from a group of components.
Select the components. Either click and drag a rectangle, or select multiple components by holding the Shift button down.
Create a component from the selected elements by right-clicking and selecting
Create Component from Selection
.
As a result, the new component has the selected components, their ports, and connections as part of its architecture. Any unconnected ports and connections to components outside of the selection become ports on the new component.
Any component that has its own architecture displays a preview of its contents.
Create Architecture Reference
An architecture reference provides a structure to create a hierarchical architectural system and further define subsystems using the component, port, connector paradigm in System Composer. Some projects use the same, detailed component in multiple places. The design of such a component must be tightly managed. You can create an architecture reference to reuse the architectural definition of a component in the same architecture model or across several architecture models.
Create Architecture Model Reference
Create an architecture reference model using this procedure:
Right-click the
Sensor
component and select Save as Architecture Model. Then, from the Type list, selectModel Reference
.Provide a name for the model. By default, the referenced architecture model is saved in the same folder as the architecture model. Browse for or enter the full path if you want to save the referenced model in a different folder.
The software creates an architecture model with the provided name, and links the component to the new model. The linked model is indicated in the name of the component between the
<>
signs.All architecture models can reference this new architecture model through linked components.
Create Architecture Subsystem Reference
You can link architecture subsystem references to components. Unlike a model reference, a subsystem reference supports top-level physical ports. Subsystems improve top-down editing workflows because inherited ports are flexible. An architecture subsystem reference contains sharable architecture models with optional Simscape behaviors. For more information about implementing Simscape behaviors, see Implement Component Behavior Using Simscape.
Note
To type ports on architecture subsystems with interfaces, you must link an external interface data dictionary. Architecture subsystems do not contain a model workspace. For more information, see Manage Interfaces with Data Dictionaries.
Create an architecture subsystem reference by linking an existing System Composer architecture subsystem file to a component or saving a new architecture subsystem from the converted component. The subsystem reference is saved in a separate file from the parent System Composer architecture model. Save a new architecture subsystem from the converted component using this procedure:
Right-click the
Motor
component and select Save as Architecture Model. Then, from the Type list, selectSubsystem Reference
.Provide a name for the subsystem. By default, the referenced architecture subsystem is saved in the same folder as the architecture model. Browse for or type the full path if you want to save the referenced subsystem in a different folder.
System Composer creates an architecture subsystem with the provided name, and links the component to the new model. The linked subsystem is indicated in the name of the component between the
<>
signs, and the component has a icon on the upper right.All architecture models can reference this new architecture subsystem through linked components.
An architecture subsystem reference component can be implemented as a reference to a separate System Composer subsystem file and reused multiple times in the architecture model. Each component linked to an architecture subsystem is unique, so when a physical port is set to inherited, each instance of a physical port can use a different physical domain.
Architecture subsystem references support physical ports with physical interfaces. You can add Simscape behaviors to child components that become Simulink subsystem references or Simulink subsystem components. For more information, see Implement Component Behavior Using Simscape.
Drag to Add Reference Components to Architecture Models
You can drag to add a reference component linked to a model or subsystem into a System Composer model. Drag a model or subsystem file from the file explorer to add a reference component to the architecture model canvas.
For example, dragging a model SLX file into the architecture model canvas adds a Reference Component block that references the model in the SLX file.
Files that you drag to add must be on the MATLAB® path. Creating reference components by dragging files from the MATLAB Editor into the model canvas is not supported.
Use Architecture Reference
You can use an architecture model reference, saved in a separate file, by linking to it from a component. Right-click the component and select Link to Model. You can also use the Create Reference option in the element palette directly to create a component that uses a reference architecture.
To link a selected component to an existing architecture model, right-click the Trajectory Planning
component and select Link to Model.
Provide the full path to the referenced architecture model. If the linked component has its own ports and components, this content is deleted during linking and is replaced by that of the referenced architecture. The ports of the linked component become the architecture ports in the referenced architecture.
Any change made in an architecture model reference is immediately reflected in the models that link to it. If you move or rename the referenced architecture, the link becomes invalid and the linked component displays an error. Link the component to a valid architecture model reference.
Remove Architecture Reference
In some cases, you have to deviate from the architecture model reference for a single component. For example, a comprehensive sensor model, referenced from a local component, may include too many features for the motion control architecture at hand and require simplification for that architecture only. In this case, you can remove the reference architecture to make local changes possible. Right-click a linked component and select Inline Model.
This operation provides two options:
Interface and subcomponents — Ports, interfaces, and subcomponents of the reference architecture are copied to the component.
Interface only — The ports and designated interfaces of the reference architecture are reflected on the component, but the composition is blank.
Once the architecture model reference is removed, you can make changes without affecting other architectures. However, you cannot propagate local changes to the architecture model reference. If you link to the referenced architecture again, local changes are lost.
Create Variants
A component can have multiple design alternatives, or variants.
A variant is one of many structural or behavioral choices in a variant component.
Use variants to quickly swap different architectural designs for a component while performing analysis.
A variant control is a string that controls the active variant choice.
Set the variant control programmatically to control which variant is active.
You can model variations for any component in a single architecture model. You can define a mix of behaviors (defined in a Simulink model) and architectures (defined in a System Composer architecture model) as variant choices. For example, a component may have two variant options that represent two alternate structural decompositions.
Convert a Component block to a Variant Component block by adding variant choices to the component. Right-click the Sensor
component and select Add Variant Choice.
The badge on the component indicates that it is a variant, and a variant choice is added to the existing composition. Double-click the component to see variant choices.
Add Variant Choices
You can add more variant choices to a variant component using the Add Variant Choice option.
Open and edit the variant by right-clicking and selecting Variant > Open > Variant Name from the component context menu.
You can also designate a component as a variant upon creation using the button in the toolstrip. This creates two variant choices by default.
Activate a specific variant choice using the context menu of the block. Right-click and select Variant > Label Mode Active Choice > Choice (Component). The active choice is displayed in the header of the block.
Convert Variant Component to Variant Assembly Component
A Variant Assembly Component block enables you to add or remove its variant choices from external sources without modifying the model. The Variant Assembly Component block can contain Model blocks, Subsystem Reference blocks, or both as its variant choices. The choices are maintained in corresponding model or subsystem files that are on the MATLAB path. The conversion from Variant Component to Variant Assembly Component is not supported for software architecture and AUTOSAR architecture.
Convert Variant Component to Variant Assembly Component Interactively
Consider a Variant Component block in an architecture model canvas with model
reference or subsystem reference or Simulink models as its variant choices and in label
or
expression
mode that is to be converted to a Variant Assembly
Component block. For more information on the steps to convert a Variant
Component to a Variant Assembly Component interactively,
see Convert Variant Subsystem Block with Expressions to Variant Assembly Subsystem Block Interactively and Convert Variant Subsystem Block with Labels to Variant Assembly Subsystem Block Interactively.
Convert Variant Component to Variant Assembly Component Programmatically
To convert a Variant Component block using the makeVariantAssembly
function of the systemcomposer.arch.VariantComponent
object to programmatically convert to a Variant Assembly Component block, see makeVariantAssembly
.
Create Software Architecture from Component
You can create a software architecture model from a component in a System Composer architecture model and reference the software architecture model from the component. You can use software architectures to link Simulink export-function, rate-based, or JMAAB models to components in your architecture model to simulate and generate code. For more information, see Export Architecture to Software Architecture.
Create AUTOSAR Architecture from Component
You can create an AUTOSAR architecture model from a component in a System Composer architecture or software architecture model and reference the AUTOSAR architecture model from the component. For more information, see Create AUTOSAR Architecture from System Composer Model (AUTOSAR Blockset).
See Also
Functions
createArchitectureModel
|createArchitectureSubsystem
|linkToModel
|inlineComponent
|addVariantComponent
|makeVariant
|makeVariantAssembly
|addChoice
|setActiveChoice