Detect and Fix Model Advisor Check Violations
The Model Advisor checks your model or subsystem for modeling conditions and configuration settings that cause inaccurate or inefficient simulation and inefficient generated code and code that is unsuitable for safety-critical applications. The Model Advisor checks can help you verify compliance with industry standards and guidelines. By using the Model Advisor, you can implement consistent modeling guidelines across projects and development teams.
A subset of Model Advisor checks support edit-time checking. With edit-time checking, you can check for model conditions while you develop a model. Highlighted blocks in the model editor window alert you to issues in the model.
This tutorial uses the example model sldemo_fuelsys
. This model is
an air-fuel ratio control system designed with Simulink® and Stateflow®.
The figures show portions of the sldemo_fuelsys
model. The
top-level model is a closed-loop system that consists of a plant (Engine Gas Dynamics)
and a controller (the Fuel Rate Control subsystem). The plant allows engineers to
validate the controller through simulation early in the design cycle. The control logic
is a Stateflow chart that specifies the different modes of operation.
Detect and Fix Model Advisor Check Violations While You Edit
Set your current folder to a writeable directory.
Open the model
sldemo_fuelsys
by typing this command:openExample('sldemo_fuelsys')
To use edit-time checking, on the Modeling tab, select Model Advisor > Edit-Time Checks. The Configuration Parameters dialog box opens and you select the check box for Edit-Time Checks.
The highlighted blocks and subsystems indicate compliance issues.
Pause over a highlighted block and click the warning icon. A dialog box provides a description of the warning. For detailed documentation on the check that detected the issue, click the question mark. These blocks contain edit-time warnings because of incorrect block names.
To exclude a block from a selected check, you can click Suppress.
Open the
Engine Gas Dynamics
subsystem by double-clicking it. Pause over theair/fuel ratio
output port and click the warning icon.This output port returns warnings because its name violates two checks: Check for unsupported block names and Check port block names.
Address the warnings by replacing the
/
symbol and the space in the block name with underscores. The block is no longer highlighted.Address the warnings for the other highlighted blocks in the
Engine Gas Dynamics
subsystem.
Detect and Fix Model Advisor Check Violations Interactively
On the Modeling tab, select Model Advisor.
Select the top-level model
sldemo_fuelsys
from the System Hierarchy and click OK.In the left pane, in the By Product > Simulink Check > Modeling Standards > DO-178C/DO-331 folder, select:
Check safety-related diagnostic settings for solvers
Check safety-related diagnostic settings for sample time
Check safety-related optimization settings for logic signals
Right-click DO-178C/DO-331 Checks node, and then select Run Selected Checks.
To review the configuration parameters that are not set to the recommended values, click Check safety-related diagnostic settings for solvers.
To update the parameters to the recommended values, in the toolstrip, click Fix.
Action Report window displays the Model Advisor updates the parameters to the recommended values and details the result.
Repeat step 6 for the Check safety-related diagnostic settings for sample time check.
To verify that your model now passes, rerun the checks.
To generate a results report of the Simulink Check™ checks, select the DO-178C/DO-331 Checks node, and then, in the toolstrip, click Report.
Close the Model Advisor.
Next, collect metric data on the model and fix other compliance issues by using the Metrics Dashboard.