Define Stereotypes and Perform Analysis
Stereotypes add an additional layer of metadata to components, ports, and connectors in System Composer™. A stereotype is a custom extension of the modeling language. Stereotypes provide a mechanism to extend the architectural language elements by adding domain-specific metadata. The hardware architecture model provides a basis to understand the applied stereotypes, create filtered views based on the stereotypes, and perform an analysis on the model.
To access the models and supporting files used in this example, see Simulate Mobile Robot with System Composer Workflow.
Hardware Architecture Model for Mobile Robot
The hardware architecture model describes the hardware components — the sensor, actuators, and embedded processor — and their connections. The colors and icons indicate the stereotypes used for each element. To open the hardware architecture model, double-click the file or enter this command in the MATLAB® Command Window.
% Open the hardware architecture model for the mobile robot systemcomposer.openModel('scMobileRobotHardwareArchitecture');
View Stereotypes and Properties in Profile Editor
In this example, the
HardwareBaseStereotype stereotype is defined as
an abstract stereotype and is extended to connector and component stereotypes. For example,
DataConnector stereotype is a connector stereotype that inherits the
HardwareBaseStereotype. In addition to properties like name and mass,
DataConnector stereotype has a property,
TypeOfConnection, that describes which of the three connection types it
uses: RS232, Ethernet, or USB.
To focus on expected time before first maintenance, define properties such as
Life. Setting these properties allows you to analyze each hardware
component to make sure the mobile robot will last until first expected year of maintenance.
To open the Profile Editor, navigate to Modeling > Profiles > Profile Editor.
Apply Stereotypes to Elements in Model
Once you define stereotypes in the Profile Editor, you can apply them to components, ports, and connectors. Apply stereotypes using the Property Inspector. To open the Property Inspector, navigate to Modeling > Design > Property Inspector.
To add stereotypes to elements, select the element in the diagram. In the Property
Inspector, select Main > Stereotype. You can apply multiple stereotypes to the same element. Apply the
MobileRobotProfile.Sensor stereotype to the
Sensor component to add properties.
Some components remain in use for longer periods of time than others. The
Sensor component is used for obstacle avoidance in this scenario, so it is
always in use except when it is charging. The
RGB Camera only aligns the
robot to the charging station, so it is in use for a shorter period per day. You can change
values for the
Life properties to determine the expected maintenance time for
components that are each used with different frequency.
ExceedExpectedMaintenance is set to
false by default. This property will update when you run your
Architecture Views for Hardware Architecture Model
Use the Architecture Views Gallery to review changes you make in the architecture model. Architecture views allow you to create filtered views and thereby focus on few elements of the model, which enables you to navigate a complex model more easily.
For example, an electrical engineer might be interested only in the electrical components of the hardware architecture. The engineer could apply a filter to show only components with electrical stereotypes.
To open the Architecture Views Gallery, navigate to Modeling > Architecture Views.
Select New > View to create a new view.
Name the view in the View Properties pane on the right.
In the bottom pane, under View Configurations > Filter, select from the list Add Component Filter > Select All Components to show all components in the view.
Select Apply .
Select the Component Hierarchy view. The hierarchy of the components is flattened to show all subcomponents in one view.
You can apply a filter to view components with the Life Expectancy requirement. Select New > View and name the view in the View Properties pane on the right.
In the bottom pane under View Configurations > Filter, select Add Component Filter.
Select Apply .
Observe the components with the
The components with the
Lifeproperty defined are components for which expected time before first maintenance is a concern.
Analyze Hardware Components for Life Expectancy
Analyze the system to check if the components and connectors will last longer than the expected time before first maintenance. This value is set to two years in the analysis function. Navigate to Modeling > Views > Analysis Model to open the Instantiate Architecture Model dialog box.
Select all stereotypes to make them available on the instance model. Select
scMobileRobotAnalysis.m as the analysis function. The iteration order
determines in what order the component hierarchy is analyzed. However, since each component
is analyzed separately, the order does not matter. Select the default
Click Instantiate to instantiate the model. Relevant components and connectors with stereotypes are shown. Since all stereotypes are selected, all elements with stereotypes are shown in the instance model. Model analysis will calculate which components and connectors will last longer than the expected two years. Click Analyze to perform the calculation.
The components for which usage is not defined are components that last significantly
longer than the expected time and are therefore excluded from analysis. The analysis
function calculates whether the time before first maintenance for each component and
connector will exceed
Life, which is set to two years. The unchecked
boxes indicate that components and connectors will need maintenance within two years.
To refresh the instance model in the Analysis Viewer, select
Overwrite, then click Refresh. This
action will retrieve the values back from the source model, in this case, the hardware
architecture model. Since
ExceedExpectedMaintenance was the only property
changed, it reverts back to its default value. Conversely, when you click
Update the property values in the hardware architecture source
update according to the instance model.