monitor the complexity of your design using the model maintainability dashboard -凯发k8网页登录
the model maintainability dashboard collects metric data from the model design artifacts in a project to help you assess the size, architecture, and complexity of your design.
the dashboard analyzes different aspects of model maintainability from model design artifacts like simulink® models, stateflow® charts, and matlab® code. the model maintainability metrics help you determine if parts of a design are too complex and need to be refactored. a less complex design is easier to read, maintain, and test.
this example shows how to collect and explore the maintainability metric data for a project. as you update and development your design artifacts, use the dashboard to assess the impact on complexity and maintainability.
open the model maintainability dashboard for a project
1. open a project that contains design artifacts. for this example, in the matlab command window, enter:
dashboardccprojectstart("incomplete")
the dashboardccprojectstart
command creates a new instance of an example project for a cruise control system. the project includes several models, tests, and requirements files.
2. the model maintainability dashboard is a model design dashboard that displays maintainability metrics. to open the model maintainability dashboard, use one of these approaches:
on the project tab, click model design dashboard.
open a model in the project and, in the apps gallery, click model design dashboard.
in the command window, enter:
modeldesigndashboard
the dashboard app launches and opens a new model maintainability tab for the software component cc_cruisecontrol
.
explore the project architecture
on the left side of the dashboard app is the project panel which displays the architecture of the units and components in the current project. software components use the component icon and software units use the unit icon .
3. in the project panel, expand the component cc_cruisecontrol. the component cc_cruisecontrol
contains 4 software units: cc_controlmode
, cc_driverswreqest
, cc_lightcontrol
, and cc_throttlecontroller
.
4. select the unit cc_controlmode to open a model maintainability dashboard for that software unit. if a dashboard is not available for a specific unit or component, the name of the unit or component appears dimmed.
use the project panel to open the dashboard for the different units and components in your project architecture.
explore the design artifacts
on the bottom left of the dashboard app is the artifacts panel which displays the artifacts inside the selected unit or component. the functional requirements, design, tests, and test results folders contain the artifacts the dashboard traced to the current unit or component.
for example, when cc_controlmode is selected in the project panel, the artifacts panel displays the artifacts associated with the unit cc_controlmode
.
5. in the artifacts panel, expand the design folder. for the unit cc_controlmode
, the design folder shows the associated data dictionary, model, and subsystem references.
in the toolstrip for the dashboard app, you can click the legend button to view a list of the icons for artifacts that the dashboard traces.
explore the maintainability metrics
when you open a model maintainability dashboard, the dashboard automatically collects the metric data and displays the results in the six main sections of the dashboard:
component structure
component interface
design cyclomatic complexity breakdown
simulink architecture
stateflow architecture
matlab architecture
each section of the dashboard contains widgets that help you interact with the metric data.
6. in the component structure section of the dashboard, point to the complexity widget. three dots appears in the top-right corner of the widget.
point to the three dots and click the help icon to view more information about the metric and how the dashboard calculates the metric value.
7. in the simulink architecture section, in the signal lines row and distribution column, the metric results show an outlier in the signal line distribution.
the dashboard sorted most of the metric data into the three distribution bins on the left. the rightmost distribution bin contains metric data that is outside of that range.
8. point to the rightmost distribution bin. the tooltip indicates that there is one layer in the model hierarchy containing between 60 and 69 simulink signals.
the other layers of the model contain fewer signal lines. for example, the leftmost distribution bin shows nine model layers containing fewer than 10 simulink signals.
9. click the rightmost distribution bin to explore the metric data in more detail.
the dashboard opens the metric details for the widget with a table of metric values and hyperlinks to each related artifact. the table shows that the artifact control_mode_statemachine contains 60 signal lines.
note that there is a breadcrumb trail from the metric details back to the main model maintainability results for cc_controlmode.
10. in the artifact column, click on control_mode_statemachine to open the artifact in simulink.
in this example, the artifact control_mode_statemachine
is a subsystem in the model cc_controlmode
. if the 60 signal lines at the top layer of the subsystem make the design hard to read, refactor the model layer to improve readability.