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 be applicable to a specific element type, such as components. When a model element has a stereotype, you can specify property values as part of its architectural definition. Stereotypes and properties also make analysis of an architecture possible.
Each profile contains a set of stereotypes, and each stereotype comes with a set of properties.
The goal of this example is to compute the total cost of the system given the cost of its parts. The example profile is limited to this goal.
Load a profile to make stereotypes available for model elements.
On the Model tab and in the Profiles section, select Manage and then from the drop-down, select Import .
Browse to the examples folder.
This profile contains 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 an
helps identify the element throughout the design and implementation process, and a
Note that project members can use to track any issues with the
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. These properties help compute the
total weight and cost of the design in this particular example.
Add custom properties to a model element by applying a stereotype from a loaded profile. This procedure uses the model ex_RobotArch.slx.
Open the example robot model with the MATALB command open_system('ex_RobotArch_props.slx').
Open the Sensors component.
On the Modeling tab and in the Profiles section, 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
simpleProfile.sysGeneral. The stereotype
sysGeneral is useful for tracking.
In the Sensors component, select the GPS component. Right-click and select Apply Stereotype > simpleProfile.sysComponent.
sysComponent is useful for physical properties
sysGeneral was selected in a previous step.
Navigate to top of the model. Apply the
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 >
sysConnector stereotype to all connectors in the
Sensors layer, the Trajectory Planning layer and the top
Set the property values to enable cost analysis. Follow this example for the GPS module.
In the Sensors component, select GPS component.
Open the Property Inspector. On the Modeling tab and in the Design section, select Property Editor.
Expand the sysComponent stereotype to see the properties.
Set unitPrice to
5 and press Enter.
Similarly, for the
GPSData connector properties, set the
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.
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 unitPrice = child.getValue("sysConnector.unitPrice"); length = child.getValue("sysConnector.length"); sysComponent_unitPrice = unitPrice*length + sysComponent_unitPrice; end instance.setValue("sysComponent.unitPrice",sysComponent_unitPrice) end
Return to the Analysis screen and click Instantiate. The analysis viewer shows the properties of each model element.
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.