A profile contains a set of model element stereotypes with custom properties. A stereotype can be applicable to components, ports, connections, and architectures, or it can made applicable only to a specific element type, such as components. When a model element has a stereotype applied to it, you can specify property values as part of its architectural definition. In addition to allowing you to manage properties relevant to the system specification within the architecture model, stereotypes and associated properties also facilitate analysis of an architecture model.
Each profile contains a set of stereotypes, and each stereotype contains a set of properties.
The goal of this example is to compute the total cost of the system given the cost of its constituent parts. The example profile is limited to this goal.
Load a profile to make stereotypes available for model elements.
Start System Composer. Enter
systemcomposer at the MATLAB command
In the Modeling tab, select Import and then from the drop-down, select Import .
Browse to the examples folder.
From the toolstrip, click Import and select Edit to open the Profile Editor.
In the profile, observe these stereotypes.
|sysGeneral||components, ports, connectors|
Importing the profile makes stereotypes available to their applicable elements.
sysGeneral is a general stereotype, applicable to all element
types, that enables adding generic properties such as a
project members can use to track any issues with the element.
sysComponent applies only to components, and includes properties
such as weight and cost that contribute to the total weight and cost specifications of
the robot system.
sysConnector stereotype applies to connectors, and includes price
and weight properties defined per meter of length (assuming a physical connector like a
wire). These properties help compute the total weight and cost of the design in this
You can add a stereotype icon to all component-level stereotypes. These are your choices:
Add custom properties to a model element by applying a stereotype from a loaded profile.
This procedure uses the model
Open the Sensors component.
On the Modeling tab, select Apply Stereotypes.
In the Apply Stereotypes dialog box and from the Apply to list,
All elements. From the in list,
In the list of available stereotypes, select
Click Apply and close the window to exit the dialog box.
Select the GPS component. Right-click and select
Apply Stereotype. Check that
simpleProfile.sysComponent is selected.
sysComponent stereotype is used for managing physical
properties and cost.
Navigate to top of the model. Check that the
stereotype is applied to the Sensors and Trajectory
Planning components, and the top-level architecture model. Right-click each
component or a space in the top-level, and select Apply Stereotype
simpleProfile.sysComponent is selected.
Check that the
sysConnector stereotype is applied to all
connectors in the Sensors layer, the Trajectory Planning layer, and the top model layer.
Press and hold Shift to select multiple connectors. Right-click the
selection, click Apply Stereotype, and check that the stereotype is
Set the property values to enable cost analysis. Follow this example for the GPS module.
In the Sensors component, select the GPS component.
Open the Property Inspector. Click the drop-down in the Design section of the toolstrip and select Property Inspector.
Expand the sysComponent stereotype to see the properties.
5 and press
Select the GPSData port connector. Check that
length is set to
Complete the model using the values in this table. If a property is not in the table, you can leave it blank as it has no effect on the analysis. Pin the Property Inspector to the editor to make it permanently visible during this operation.
|Top layer||Encoder connector||length||0.5|
|Trajectory Planning component||unitPrice||500|
|Sensors layer||GyroData component||unitPrice||50|
Save the model as
Analyze the total cost for all components in the robot model.
On the Modeling tab and in the Views section, select Analysis Model, and then from the drop-down list select Analysis Model.
Add an analysis function. In the Analysis function box, enter the function name
ex_RobotArch_analysis without an extension, and then click . A MATLAB function file is created and saved with the
The analysis function includes constructs that get properties from model elements, given as a template. Modify this template to add the cost of individual elements to obtain total cost for their parent architecture. This function computes the cost for one model element as a total of its own cost and the cost of all of its child components.
function ex_RobotArch_analysis(instance,varargin) if instance.isComponent() sysComponent_unitPrice = instance.getValue("sysComponent.unitPrice"); for child = instance.Components comp_price = child.getValue("sysComponent.unitPrice"); sysComponent_unitPrice = sysComponent_unitPrice + comp_price; end for child = instance.Connectors if (child.hasValue('sysConnector.unitPrice')) unitPrice = child.getValue("sysConnector.unitPrice"); length = child.getValue("sysConnector.length"); sysComponent_unitPrice = unitPrice*length + sysComponent_unitPrice; end end instance.setValue("sysComponent.unitPrice",sysComponent_unitPrice) end
Return to the Instantiate Architecture Model screen and click Instantiate. The Analysis Viewer shows the properties of each model element. The default values for the start of the Analysis are taken from the property values you entered when you attached the stereotype to the model and edited their values.
In the Analysis section, select
BottomUp as the iteration method and click
The cost of each element is added in a bottom-up manner to find the cost of the system. The result is written to the analysis instance and is visible in the Analysis Viewer.