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.
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 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.
Some projects use the same, detailed component in multiple places, and require the design of such a component to be tightly managed. You can create a reference architecture to reuse the architectural definition of a component in the same architecture model or across several architecture models. Create such a reference architecture using this procedure:
Sensor component and select Save as
Provide a name for the model. By default, the reference architecture is saved in the same folder as the architecture model. Browse for or type the full path if you want to save it in a different folder.
System Composer 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
All architecture models can reference this new architecture model through linked components.
You can use a reference architecture, 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
Provide the full path to the reference architecture. If the linked component has its own ports and components, this content is deleted during linking and replaced by that of the reference architecture. The ports of the linked component become the architecture ports in the reference architecture.
Any change made in a reference architecture is immediately reflected in the models that link to it. If you move or rename the reference architecture, the link becomes invalid and the linked component displays an error. Link the component to a valid reference architecture.
In some cases, you have to deviate from the reference architecture 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 reference architecture is removed, you can start making changes without affecting other architectures. However, you cannot propagate local changes to the reference architecture. If you link to the reference architecture again, local changes are lost.
To remove a Stateflow® Chart behavior, see Remove Stateflow Chart Behavior from Component.
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 to programmatically 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 to a Variant Component 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.
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 object 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.
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 Create Software Architecture from Architecture Model Component.