|
|
|
| R2012a Documentation → Simulink Verification and Validation | |
Learn more about Simulink Verification and Validation |
|
| Contents | Index |
| On this page… |
|---|
Note While you can organize checks and folders within a customization file, use the Model Advisor Configuration Editor. For more information, see Using the Model Advisor Configuration Editor Versus Customization File. |
The sl_customization.m file contains a set of functions for registering and defining custom checks, tasks, and groups. To set up the sl_customization.m file, follow the guidelines in this table.
| Function | Description | Required or Optional |
|---|---|---|
| sl_customization() | Registers custom checks, tasks, folders, and callbacks with the Simulink customization manager at startup (see Registering Checks and Process Callbacks). | Required for all customizations to the Model Advisor. |
| One or more check definitions | Defines all custom checks (see Defining Custom Checks). | Required for custom checks and to add custom checks to the By Product folder. |
| One or more task definitions | Defines all custom tasks (see Defining Custom Tasks). | Required to add custom checks to the Model Advisor, except when adding the checks to the By Product folder. Write one task for each check that you add to the Model Advisor. |
| One or more groups | Defines all custom groups (see Defining Custom Tasks). | Required to add custom tasks to new folders in the Model Advisor, except when adding a new subfolder to the By Product folder. Write one group definition for each new folder. |
| One process callback function | Specifies actions that Simulink performs at startup and post-execution time (see Defining Startup and Post-Execution Actions Using Process Callback Functions). | Optional. |
To add tasks and folders to the Model Advisor, create the sl_customization.m file on your MATLAB path. Then create the sl_customization() function in the sl_customization.m file on your MATLAB path.
Tip
|
The sl_customization function accepts one argument, a customization manager object, as in this example:
function sl_customization(cm)
The customization manager object includes methods for registering custom checks, tasks, folders, and process callbacks. Use these methods to register customizations specific to your application, as described in the sections that follow.
The customization manager provides the following methods for registering custom tasks and folders:
addModelAdvisorTaskFcn (@factorygroupDefinitionFcn)
Registers the tasks that you define in factorygroupDefinitionFcn to the By Task folder of the Model Advisor.
The factorygroupDefinitionFcn argument is a handle to the function that defines the checks to add to the Model Advisor as instances of the ModelAdvisor.FactoryGroup class (see Defining Custom Tasks).
addModelAdvisorTaskAdvisorFcn (@taskDefinitionFcn)
Registers the tasks and folders that you define in taskDefinitionFcn to the folder in the Model Advisor that you specify using the ModelAdvisor.Root.publish method or the ModelAdvisor.Group class.
The taskDefinitionFcn argument is a handle to the function that defines all custom tasks and folders. Simulink adds the checks and folders to the Model Advisor as instances of the ModelAdvisor.Task or ModelAdvisor.Group classes (see Defining Custom Tasks).
Note The @ sign defines a function handle that MATLAB calls. For more information, see At — @ in the MATLAB documentation. |
Model Advisor Code Example: Registering Custom Tasks and Folders. The following code example registers custom tasks and folders:
function sl_customization(cm) % register custom factory group cm.addModelAdvisorTaskFcn(@defineModelAdvisorTasks); % register custom tasks. cm.addModelAdvisorTaskAdvisorFcn(@defineTaskAdvisor);
Note If you add custom checks and process callbacks within the sl_customization.m file, include methods for registering the checks and process callbacks in the sl_customization function. For more information, see Registering Checks and Process Callbacks. |
You can use custom tasks for adding checks to the Model Advisor, either in multiple folders or in a single, custom folder. You define custom tasks in one or more functions that specify the properties of each instance of the ModelAdvisor.Task class. Define one instance of this class for each custom task that you want to add to the Model Advisor. Then register the custom task, as described in Register Tasks and Folders. The following sections describe how to define custom tasks.
To add a check to multiple folders or a single, custom folder:
Create a check using the ModelAdvisor.Check class, as described in Defining Custom Checks.
Register a task wrapper for the check, as described in Register Tasks and Folders.
If you want to add the check to folders that are not already present, register and create the folders using the ModelAdvisor.Group class.
Add a check to the task using the ModelAdvisor.Task.setCheck method.
Add the task to each folder using the ModelAdvisor.Group.addTask method and the task ID.
You can add MathWorks checks to your custom folders by defining the checks as custom tasks. When you add the checks as custom tasks, you identify checks by the check ID.
To find MathWorks check IDs:
In the Model Advisor, select View > Source Tab.
Navigate to the folder that contains the MathWorks check.
In the right pane, click Source. The Model Advisor displays the Title, TitleID, and Source information for each check in the folder.
Select and copy the TitleID of the check that you want to add as a task.
The Visible, Enable, and Value properties interact the same way for tasks as they do for checks (see Displaying and Enabling Checks).
You can specify where the Model Advisor places tasks within the Model Advisor using the following guidelines:
To place a task in a new folder in the Model Advisor Task Manager, use the ModelAdvisor.Group class. See Defining Custom Folders.
To place a task in a new folder in the By Task folder, use the ModelAdvisor.FactoryGroup class. See Defining Custom Folders.
The following is an example of a task definition function. This function defines three tasks. The tasks are derived from the checks defined in Model Advisor Code Example: Check Definition Function.
For an example of placing these tasks into a custom group, see Model Advisor Code Example: Group Definition.
% Defines Model Advisor tasks and a custom folder % Add checks to a custom folder using task definitions function defineTaskAdvisor mdladvRoot = ModelAdvisor.Root; % Define task that uses Sample Check 1: Informational check MAT1 = ModelAdvisor.Task('mathworks.example.task.configManagement'); MAT1.DisplayName = 'Informational check for model configuration management'; MAT1.Description = 'Display model configuration and checksum information.'; setCheck(MAT1, 'mathworks.example.configManagement'); mdladvRoot.register(MAT1); % Define task that uses Sample Check 2: Basic Check with Pass/Fail Status MAT2 = ModelAdvisor.Task('mathworks.example.task.unconnectedObjects'); MAT2.DisplayName = 'Check for unconnected objects'; setCheck(MAT2, 'mathworks.example.unconnectedObjects'); MAT2.Description = ['Identify unconnected lines, input ports, and output ' ... 'ports in the model or subsystem.']; mdladvRoot.register(MAT2); % Define task that uses Sample Check 3: Check with Subresults and Actions MAT3 = ModelAdvisor.Task('mathworks.example.task.optimizationSettings'); MAT3.DisplayName = 'Check safety-related optimization settings'; MAT3.Description = ['Check model configuration for optimization ' ... 'settings that can impact safety.']; MAT3.setCheck('mathworks.example.optimizationSettings'); mdladvRoot.register(MAT3); % Custom folder definition MAG = ModelAdvisor.Group('mathworks.example.ExampleGroup'); MAG.DisplayName = 'My Group'; % Add tasks to My Group folder addTask(MAG, MAT1); addTask(MAG, MAT2); addTask(MAG, MAT3); % Add My Group folder to the Model Advisor under 'Model Advisor' (root) mdladvRoot.publish(MAG);
Use folders to group checks in the Model Advisor by functionality or usage. You define custom folders in:
A factory group definition function that specifies the properties of each instance of the ModelAdvisor.FactoryGroup class.
A task definition function that specifies the properties of each instance of the ModelAdvisor.Group class. For more information about task definition functions, see Adding a Check to Custom or Multiple Folders Using Tasks.
Define one instance of the group classes for each folder that you want to add to the Model Advisor. Then register the custom folder, as described in Register Tasks and Folders. The following sections describe how to define custom groups.
To add a custom folder:
Create the folder using the ModelAdvisor.Group or ModelAdvisor.FactoryGroup classes.
Add the folder to the Model Advisor, as described in Defining Custom Folders.
You can specify the location of custom folders within the Model Advisor using the following guidelines:
To define a new folder in the Model Advisor Task Manager, use the ModelAdvisor.Group class.
To define a new folder in the By Task folder, use the ModelAdvisor.FactoryGroup class.
Note To define a new folder in the By Product folder, use the ModelAdvisor.Root.publish method within a custom check. For more information, see Defining Where Custom Checks Appear. |
The following is an example of a group definition. The definition places the tasks defined in Model Advisor Code Example: Task Definition Function inside a folder called My Group under the Model Advisor root. The task definition function includes this group definition.
% Custom folder definition MAG = ModelAdvisor.Group('mathworks.example.ExampleGroup'); MAG.DisplayName='My Group'; % Add tasks to My Group folder MAG.addTask(MAT1); MAG.addTask(MAT2); MAG.addTask(MAT3); % Add My Group folder to the Model Advisor under 'Model Advisor' (root) mdladvRoot.publish(MAG);
The following is an example of a factory group definition function. The definition places the checks defined in Model Advisor Code Example: Check Definition Function into a folder called Demo Factory Group inside of the By Task folder.
function defineModelAdvisorTasks mdladvRoot = ModelAdvisor.Root; % --- sample factory group rec = ModelAdvisor.FactoryGroup('com.mathworks.sample.factorygroup'); rec.DisplayName='Demo Factory Group'; rec.Description='Demo Factory Group'; rec.addCheck('mathworks.example.configManagement'); rec.addCheck('mathworks.example.unconnectedObjects'); rec.addCheck('mathworks.example.optimizationSettings'); mdladvRoot.publish(rec); % publish inside By Task
The Simulink Verification and Validation software provides a demo that shows how to customize the Model Advisor by adding:
Custom checks
Check input parameters
Check actions
Check list views to call the Model Advisor Result Explorer
Custom tasks to include the custom checks in the Model Advisor
Custom folders for grouping the checks
Custom procedures
A process callback function
The demo also provides the source code of the sl_customization.m file that executes the customizations.
To run the demo:
At the MATLAB command line, type slvnvdemo_mdladv.
Follow the instructions in the model.
![]() | Organizing Checks and Folders Using the Model Advisor Configuration Editor | Verifying and Using Custom Configurations | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |