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
line.
In the Modeling tab, select Import and
then from the drop-down, select Import
.
Browse to the examples folder.
<matlabroot>\toolbox\systemcomposer\examples
.
Select simpleProfile
.
From the toolstrip, click Import and select Edit to open the Profile Editor.
In the profile, observe these stereotypes.
Stereotype | Application | Properties |
---|---|---|
sysGeneral | components, ports, connectors |
|
| ||
sysComponent | components |
|
| ||
sysConnector | 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 Note
, which
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
particular example.
Note
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
ex_RobotArch
.
Open the Sensors component.
On the Modeling tab, select Apply Stereotypes.
In the Apply Stereotypes dialog box and from the Apply to list,
select All elements
. From the in list,
select This layer
.
In the list of available stereotypes, select
simpleProfile.sysGeneral
.
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.
Note
The sysComponent
stereotype is used for managing physical
properties and cost.
Navigate to top of the model. Check that the sysComponent
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
to ensure 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
selected.
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.
Set unitPrice
to 5
and press
Enter.
Select the GPSData port connector. Check that
length
is set to 0.05
and
unitPrice
to 0.1
.
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.
Layer | Element | Property | Value |
---|---|---|---|
Top layer | Encoder connector | length | 0.5 |
unitPrice | 0.1 | ||
SensorData connector | length | 0.6 | |
unitPrice | 0.2 | ||
MotionCommand connector | length | 0.5 | |
unitPrice | 0.2 | ||
Sensors component | unitPrice | 5 | |
Trajectory Planning component | unitPrice | 500 | |
Motion component | unitPrice | 750 | |
Sensors layer | GyroData component | unitPrice | 50 |
DataProcessing component | unitPrice | 500 | |
GPS component | unitPrice | 100 | |
GPSData connector | length | 0.05 | |
unitPrice | 0.1 | ||
MotionData connector | length | 0.05 | |
unitPrice | 0.1 | ||
RawData connector | length | 0.05 | |
unitPrice | 0.1 |
Save the model as ex_RobotArch_props.slx
.
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 the button. A MATLAB function file is created and saved
with the name
ex_RobotArch_analysis.m
.
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
Analyze.
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.