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 modelsldemo_fuelsys
. This model is an air-fuel ratio control system designed with Simulink®and Stateflow®.
The figures show portions of thesldemo_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 theModelingtab, selectModel Advisor>Edit-Time Checks. The Configuration Parameters dialog box opens and you select the check box forEdit-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 clickSuppress.
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 namesandCheck 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 theModelingtab, selectModel Advisor.
Select the top-level model
sldemo_fuelsys
from the System Hierarchy and clickOK.In the left pane, in theBy Product>Simulink Check>Model Standards>DO-178C/DO-331folder, 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-clickDO-178C/DO-331 Checksnode, and then selectRun Selected Checks.
To review the configuration parameters that are not set to the recommended values, clickCheck safety-related diagnostic settings for solvers.
更新parameters to the recommended values, in the toolstrip, clickFix.
Action Reportwindow displays the Model Advisor updates the parameters to the recommended values and details the result.
Repeat step 6 for theCheck safety-related diagnostic settings for sample timecheck.
To verify that your model now passes, rerun the checks.
To generate a results report of theSimulink Check™checks, select theDO-178C/DO-331 Checksnode, and then, in the toolstrip, clickReport.
Close the Model Advisor.
Next, collect metric data on the model and fix other compliance issues by using the Metrics Dashboard.