Main Content

Use the Model Advisor Configuration Editor to Customize the Model Advisor

Overview of the Model Advisor Configuration Editor

The Model Advisor Configuration Editor provides a way for you to specify the checks that you want to use for edit-time checking, as well as the checks included in the Model Advisor. This organizational hierarchy is saved as a configuration file, which is loaded when you initiate the Model Advisor. You can use the Model Advisor Configuration Editor to modify existing configurations, create new Model Advisor configurations, and specify the default configuration.

The Model Advisor Configuration Editor gives you the flexibility to customize the Model Advisor analysis to meet the needs of your organization by allowing you to:

  • Review all available Model Advisor checks.

  • Add, remove, and organize built-in checks and folders in the Model Advisor tree.

  • Integrate custom Model Advisor checks in your verification and validation workflow.

  • Disable and enable checks and folders.

  • Rename checks and folders.

  • Specify whether a check is marked as a warning or failure when it is flagged during a Model Advisor analysis.

  • Suppress the warning about missing checks when loading the Model Advisor configuration.

The Model Advisor Configuration Editor includes:

  • The Library pane — A read-only pane that lists all checks and folders that are available for use in the configuration, delineated by the By Product and By Task tabs. To permanently display the Library tab, click Show Library on the toolstrip.

  • The Model Advisor pane — This pane lists the checks and folders in the current Model Advisor configuration, filtered by:

    • All checks ― Lists all Model Advisor checks included in the current configuration

    • Edit Time supported checks ― Lists only the Model Advisor checks that are supported as edit-time checks

  • Information tab — This tab provides details about the check and folder, such as display name, check title and ID, description, license requirements, subchecks, and input parameters.

Use the search functionality in the Library and Model Advisor panes to locate specific checks and folders.

Model Advisor Configuration Editor

Open the Model Advisor Configuration Editor

Before opening the Model Advisor Configuration Editor, verify that the current folder is writable. If the folder is not writable, you see an error message when you start the Model Advisor Configuration Editor.

When implementing custom checks or Model Advisor customizations by using the Model Advisor API, you must first update the Simulink® environment to include your sl_customization.m file. At the MATLAB® command line, enter

Advisor.Manager.refresh_customizations

Use one of these methods to open the Model Advisor Configuration Editor:

  • Programmatically ― At the MATLAB command line, enter Simulink.ModelAdvisor.openConfigUI.

  • From the Simulink editor ― In the Modeling tab, select Model Advisor > Model Advisor Configuration Editor .

  • From the Model Advisor ― Select Settings > Open Configuration Editor.

The configuration file that is currently being used by the Model Advisor displays when you open the Model Advisor Configuration Editor. The file name for the configuration is displayed at the top of the window. Verify that you are evaluating the correct configuration file. To open a different configuration file, click Open and browse to the file you would like to review.

To create a new configuration, click the New button on the toolstrip. Use Save As to rename the configuration file. Model Advisor configuration files are saved in .json format.

Specify a Default Configuration File

You can use the Model Advisor Configuration Editor to specify a default configuration that loads automatically when the Model Advisor opens. To set the default configuration, open the configuration file in the Model Advisor Configuration Editor and click the Set As Default button on the toolstrip.

Note

If you have previously designated a default configuration, you can use Clear default configuration setting to clear the setting that designates the current default configuration file. Clicking the button does not modify the configuration that is currently displayed in the Model Advisor Configuration Editor. When you do not specify a default configuration, the Model Advisor uses the standard configuration that is defined by your system administrator.

If you do not specify the configuration file as the default, when you save the file, you are prompted as to whether to make the file the default configuration. To make this file the default configuration, click Yes.

Customize the Model Advisor Configuration

You can use the Model Advisor Configuration Editor to customize the Model Advisor configuration tree, including adding and removing checks and folders and specifying the order in which checks are executed. You can also disable the ability for users to select whether to include or exclude a check from an analysis. You can also use the Model Advisor Configuration Editor to define the input parameters for a check.

Note

Checks that are copied from the Library tab retain their default parameter settings. When they are pasted into your custom configuration folder, the box beside each check is not selected.

Checks that are copied or cut from a folder in the Model Advisor tab retain their user-define parameter settings. When a check is included in multiple folders, you can specify different parameters for each check individually.

Organize the Hierarchy

You can customize the layout of the checks and folders in the Model Advisor configuration tree by using:

  • New Folder to create a folder.

  • Copy, Cut, and Paste to add, copy, and move checks and folders.

  • Delete to remove checks and folders.

  • Move Up or Move Down to shift the position of the check or folder in the configuration tree. The folders and checks that are higher in the configuration tree are executed first in the analysis.

Enable or Disable Checks

You can use the Model Advisor Configuration Editor to disable the check box control for checks and folders in the Model Advisor. By doing so, the check is still listed in the Model Advisor configuration tree, but it is dimmed and you do not have the ability to add or remove the check from the analysis.

In the Model Advisor pane, right-click on a folder or check and select Disable. Depending on the check box selection in the Model Advisor Configuration Editor, the following results occur in the Model Advisor:

  • If the box beside check is selected in the Model Advisor Configuration Editor, then in the Model Advisor, the check is automatically selected. Because you selected Disable, the check is dimmed and you cannot choose to remove the check from the analysis.

    If the box beside the check is not selected and the Disable option is applied in the Model Advisor Configuration Editor, then in the Model Advisor, the check is not selected and you cannot included it in the analysis.

  • If the box beside folder is selected in the Model Advisor Configuration Editor, then in the Model Advisor, the checks within the folder are automatically selected. Because you selected Disable, the folder and its checks are dimmed and you cannot choose to remove the checks from the analysis.

    If the box beside the folder is not selected and the Disable option is applied in the Model Advisor Configuration Editor, then in the Model Advisor, none of the checks within the folder are selected and you cannot include it in the analysis.

When a check or folder is disabled, you can use the Enable option to allow users to determine whether to include the check(s) in an analysis.

Note

Enable and Disable affects the execution of checks in the analysis for both the Model Advisor user interface and edit-time checking.

Specify Parameters for Check Customization

You can use the Model Advisor Configuration Editor to customize a Model Advisor check, such as the display name and input parameters for the check.

In the Information tab, review the content that you can customize for the check:

  • Display Name — Provide a new name for the check, which is displayed in the Model Advisor. Note that changing the display name does not change the check title.

  • Check result when issues are flagged — Specify whether you want the check to be marked as a warning or failure in the results when the check flags an issue in your model. The default value is Warning. Select Fail to mark a flagged check as failed in the results.

  • Input Parameters — Specify additional characteristics and functionality for the check. The Model Advisor uses these parameters to further define the emphasis of the analysis. For example, you can choose to include only subcheck jc_0736_b and specify the acceptable number of single-byte spaces in the analysis for Model Advisor check Check indentation of code in Stateflow states.

Suppress Warning Message for Missing Checks

The Model Advisor automatically warns you of checks that are missing when loading a Model Advisor configuration. You can use the Model Advisor Configuration Editor to suppress this message. Select the Model Advisor Configuration Editor root node and, in the Information tab, select Suppress warning message for missing checks when loading configuration.

Alternatively, you can programmatically suppress the Model Advisor warning by entering this command at the MATLAB command line:

warning('off','Simulink:tools:MALoadConfigMissCorrespondCheck')

Use the Model Advisor Configuration Editor to Create a Custom Model Advisor Configuration

You can use the Model Advisor Configuration Editor to organize the hierarchy of the Model Advisor and specify checks that are included in check analyses. This example shows how to create a new configuration file, specify checks for the Model Advisor and edit-time checking, define check parameters, and load the configuration to the Model Advisor.

Copy the Model to Your Current Directory

Copy model AdvisorCustomizationExample.slx and its supporting files, including the custom Model Advisor configuration file demoConfiguration.json, to your writeable directory.

1. In MATLAB, set your current folder to a writeable directory.

2. Enter this command in the MATLAB command prompt. MATLAB copies the example files to your writeable directory.

copyfile(fullfile(matlabroot,'examples','slcheck','main','prepare_cust_chk_code.m'),...
    'prepare_cust_chk_code.m','f');
run('prepare_cust_chk_code.m');

Open the Model and Review the Model Advisor Configuration

In this example, you will refresh the Model Advisor check information cache, open the model, and review the Model Advisor configuration. Specifically, you will review the effect that the configuration has on the Model Advisor user interface and edit-time checking.

1. To refresh the Model Advisor check information cache, at the MATLAB command prompt, type:

Advisor.Manager.refresh_customizations();

2. Open the example model.

open_system('AdvisorCustomizationExample.slx');

3. On the Modeling tab, open the Model Advisor. You can also open the Model Advisor by typing this command at the MATLAB command prompt:

modeladvisor('AdvisorCustomizationExample.slx');
Updating Model Advisor cache...
Model Advisor cache updated. For new customizations, to update the cache, use the Advisor.Manager.refresh_customizations method.

4. In the By Task tab, make sure that the box beside these checks is selected:

  • Modeling Standards for MAB > Naming Conventions > Content > Check character usage in block names

  • Modeling Standards for MAB > Simulink > Diagram Appearance > Check whether block names appear below blocks

5. Right-click on the Modeling Standards for MAB folder and select Run Selected Checks. In the results, notice that both checks are marked with a warning. See Run Model Advisor Checks and Review Results for more information about using the Model Advisor.

6. Return to the Simulink model editor.

7. On the Modeling tab, verify that the Model Advisor > Edit-Time Checks option is selected. Observe that the Logical Operator blocks is highlighted. Click on the warning icon above the block to view edit-time check violations. For more information, see Check Your Model by Using Edit Time Checks.

Load a Model Advisor Configuration

In this example, you will load the Model Advisor configuration file that was shipped with example AdvisorCustomizationExample.slx. The Model Advisor configuration file can be in .json (as of R2020a) or .mat (R2019b and earlier) format.

1. To load a custom configuration file, select Settings > Load Configuration and select the configuration you would like to use. For this example, select demoConfiguration.json from the writeable directory you specified previously. The Model Advisor updates to reflect the new configuration and displays the configuration file name at the top of the window.

2. Explore the Model Advisor and observe that only three checks are available in this configuration.

3. To specify configuration file demoConfiguration.json as the default Model Advisor configuration, select Settings > Set Current Configuration as Default.

To clear the default configuration setting, select Settings > Clear default configuration settings. When you do not specify a default configuration, the Model Advisor uses the standard configuration that is defined by your system administrator.

Create a New Model Advisor Configuration

In this example, you will create a custom configuration file named demo_Configuration_ISO26262_MAB.json. You will use this configuration file to define the MathWorks Advisory Board (MAB) modeling guidelines checks that you want to execute by using the Model Advisor user interface.

1. In model AdvisorCustomizationExample.slx, open the Model Advisor and check that demoConfiguration.json is the current configuration.

2. Select Settings > Open configuration editor to open the Model Advisor Configuration Editor.

Note: The file that is currently loaded in the Model Advisor cache automatically displays when you open the Model Advisor Configuration Editor.

3. Click New. In the Model Advisor pane, select All checks. This specifies that the configuration you are viewing is for all of the checks in the Model Advisor user interface.

4. Highlight the Model Advisor Configuration Editor root folder and click New Folder. Select the new folder and in the Information tab, change the display name to ISO 26262 Standard Checks. Click Apply.

5. In the toolstrip, select Show Library to display the Library pane. In the By Product tab search field, enter ISO 26262.

6. Right-click on the Simulink Check > Modeling Standards > IEC 61508, IEC 62304, ISO 26262, EN 50128, and ISO 25119 Checks folder and select Copy. Right-click on your custom ISO 26262 Standard Checks folder and click Paste. Verify that the folder and checks have been copied to your custom configuration folder.

Note: Checks that are copied from the Library pane retain their default parameter settings. When they are pasted into your custom configuration folder, the box beside each check is not selected.

7. In the By Task folder on the Model Advisor pane, right-click on the Modeling Standards for MAB folder and select Cut. Click on the Model Advisor Configuration Editor root folder and click Paste. The folder is removed from the By Task folder and is added as a new subfolder in the Model Advisor Configuration Editor root folder.

Note: Checks that are copied or cut from a folder in the Model Advisor pane retain their user-defined parameter settings. When a check is included in multiple folders, you can specify different parameters for each check individually.

8. Select the ISO 26262 Standard Checks folder and use the Move Down button to change the position this folder in the hierarchy. The Model Advisor will execute the checks in the Modeling Standards for MAB folder first.

9. Select the By Product and By Task folders and select Delete.

10. Click Save As and rename the configuration file to demo_Configuration_ISO26262_MAB. Select Yes at the prompt to save the configuration as the default configuration. The file automatically saves in .json format.

Note: If you have previously designated a default configuration, you can use Clear default configuration setting to clear the flag that specifies the current default configuration file. Clicking the button does not modify the configuration that is currently displayed in the Model Advisor Configuration Editor.

11. Close the Model Advisor Configuration Editor and the AdvisorCustomizationExample.slx model.

12. Refresh the Model Advisor cache and open model AdvisorCustomizationExample.slx by entering the following in the MATLAB command line:

Advisor.Manager.refresh_customizations();
open_system('AdvisorCustomizationExample.slx');

13. Open the Model Advisor and check that configuration file demo_Configuration_ISO26262_MAB.json is being used. The Model Advisor displays the folders Modeling Standards for MAB and ISO 26262 Standard Checks.

Specify Model Advisor Checks

In this example, you will customize the checks in your custom configuration file, demo_Configuration_ISO26262_MAB.json, and review the effect that your customizations have on the Model Advisor analysis of the AdvisorCustomizationExample.slx model.

1. On the Modeling tab, click Model Advisor > Model Advisor Configuration Editor and, if necessary, open demo_Configuration_ISO26262_MAB.json.

2. In the Model Advisor pane, verify that the configuration focus is set to the All checks option.

3. Clear the check box the box beside the Model Advisor Configuration Editor root node folder. (This step is optional. However, deselecting the checks allows you to more easily view the results of using the Model Advisor Configuration Editor to specify checks for display in the Model Advisor.)

4. To allow you to use the Model Advisor user interface to specify which checks to include in the Model Advisor analysis, right-click on the Model Advisor Configuration Editor root folder and click Enable. (Note: Enable is the default setting. This option is dimmed when none of the checks are disabled.)

5. Check the box beside the Modeling Standards for MAB > Naming Conventions >Content > Check character usage in block name check.

6. Right-click on each of these checks and select Disable:

  • Modeling Standards for MAB > Naming Conventions > Content > Check character usage in block names

  • Modeling Standards for MAB > Naming Conventions > Content > Check length of subsystem name

7. Click the Modeling Standards for MAB > Simulink > Diagram Appearance > Check whether block names appear below blocks check and, in the Information tab, select Fail for the Check result when issues are flagged option. Click Apply.

Note: The default for the Check result when issues are flagged option is Warning.

8. Click Save to save the configuration. Close the Model Advisor Configuration Editor and the model.

9. Refresh the Model Advisor cache and open model AdvisorCustomizationExample.slx by entering the following in the MATLAB command line:

Advisor.Manager.refresh_customizations();
open_system('AdvisorCustomizationExample.slx');

10. Open the Model Advisor and verify that configuration file demo_Configuration_ISO26262_MAB.json is being used.

Observe these checks, which reflect the settings that you chose in the Model Advisor Configuration Editor:

  • The Modeling Standards for MAB > Naming Conventions > Content > Check character usage in block names check is dimmed and the check box is selected. This check will always execute in a Model Advisor analysis and, because it is dimmed, you cannot choose to exclude it from the analysis.

  • The Modeling Standards for MAB > Naming Conventions > Content > Check length of subsystem names check is dimmed and the check box is not selected. This check will not be included in the analysis and, because it is dimmed, you cannot select it for inclusion in the analysis.

11. Check the box beside the Modeling Standards for MAB > Simulink > Diagram Appearance > Check whether block names appear below blocks check.

12. To run the Model Advisor analysis, right-click on the Model Advisor Standards for MAB root node and select Run Selected Checks.

13. Click on the following checks and review the Model Advisor analysis results:

  • The Modeling Standards for MAB > Naming Conventions > Content > Check character usage in block names check is marked with a warning icon and the results specify the check violation is in the Gain block.

  • There are no results for the Modeling Standards for MAB > Naming Conventions > Content > Check length of subsystem check because it could not be selected for the analysis.

  • The Modeling Standards for MAB > Simulink > Diagram Appearance > Check whether block names appear below blocks check is marked with a fail icon. This behavior is intended; you specified this check settings by using the Model Advisor Configuration Editor.

Specify Checks for Edit-Time Checking

In this example, you will specify the checks that are available in the demo_Configuration_ISO26262_MAB.json configuration file for execution during edit-time checking.

1. In model AdvisorCustomizationExample.slx, on the Modeling tab, make sure that the Model Advisor > Edit-Time Checks option is selected.

2. On the Modeling tab, click Customize Edit-Time Checks. The Model Advisor Configuration Editor opens with the configuration focus option set to Edit-Time supported checks. Only a subset of Model Advisor checks are supported for edit-time checking; the Edit-Time supported checks option displays only checks that support edit-time checking.

3. In the Model Advisor pane, check the box beside the Modeling Standards for MAB > Simulink > Operation Blocks > Check icon shape of Logical Operator blocks check.

4. Click Save to save the configuration. Close the Model Advisor Configuration Editor. Return to the AdvisorCustomizationExample.slx model.

5. In the Simulink editor, notice that the Logical Operator block is now highlighted. Open the violation and click Fix. The Model Advisor changes the block to a rectangular shape and the highlighted edit-time check warning clears.

See Also

|

Related Topics