sl_customization.m file contains a set
of functions for registering and defining custom checks, tasks, and
groups. To set up the
follow the guidelines in this table.
|Function||Description||Required or Optional|
|Registers custom checks and tasks, folders with the Simulink® customization manager at startup. See Register Checks.||Required for customizations to the Model Advisor.|
|One or more check definitions||Defines custom checks. See Define Custom Checks.||Required for custom checks and to add custom checks to the By Product folder.|
|One or more task definitions||Defines custom tasks. See Define 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 custom groups. See Define 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.|
If the By Product folder is not displayed in the Model Advisor window, select Show By Product Folder from the Settings > Preferences dialog box.
To add tasks and folders to the Model Advisor, create the
on your MATLAB® path. Then create the
sl_customization.m file on your MATLAB path.
You can have more than one
on your MATLAB path.
Do not place an
that customizes the Model Advisor in your root MATLAB folder
or its subfolders, except for the
Otherwise, the Model Advisor ignores the customizations that the file
sl_customization function accepts one
argument, a customization manager object, as in this example:
The customization manager object includes methods for registering custom checks, tasks, and folders. 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:
Registers the tasks that you define in
the By Task folder of the Model Advisor.
is a handle to the function that defines the checks to add to the
Model Advisor as instances of the
Registers the tasks and folders that you define in
the folder in the Model Advisor that you specify using the
is a handle to the function that defines custom tasks and folders. Simulink adds
the checks and folders to the Model Advisor as instances of the
The following example shows how to register custom tasks and folders:
function sl_customization(cm) % register custom factory group cm.addModelAdvisorTaskFcn(@defineModelAdvisorTasks); % register custom tasks. cm.addModelAdvisorTaskAdvisorFcn(@defineTaskAdvisor);
If you add custom checks within the
include methods for registering the checks in the
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
Define one instance of this class for each custom task that you want
to add to the Model Advisor. Then register the custom task. 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
Register a task wrapper for the check.
If you want to add the check to folders that are not
already present, register and create the folders using the
Add a check to the task using the
Add the task to each folder using the
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.
interact the same way for tasks as they do for 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
To place a task in a new folder in the By
Task folder, use the
The following example shows a task definition function. This function defines three tasks.
% 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 0: Check whose Results are Viewed as Detailed Result Collections MAT8 = ModelAdvisor.Task('com.mathworks.sample.TaskSample8'); MAT8.DisplayName='Example task using new check style (recommended style)'; MAT8.setCheck('com.mathworks.sample.Check0'); mdladvRoot.register(MAT8); % 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 MAG.addTask(MAT8); 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
A task definition function that specifies the properties
of each instance of the
Define one instance of the group classes for each folder that you want to add to the Model Advisor.
To add a custom folder:
Create the folder using the
Register the folder.
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
To define a new folder in the By Task folder,
To define a new folder in the By Product folder,
ModelAdvisor.Root.publish method within
a custom check. If the By Product folder is
not displayed in the Model Advisor window, select Show By
Product Folder from the Settings > Preferences dialog box.
The following examples shows a group definition. The definition places the tasks 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(MAT8); 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 example shows a factory group definition function. The definition places the checks 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('com.mathworks.sample.Check0'); rec.addCheck('mathworks.example.configManagement'); rec.addCheck('mathworks.example.unconnectedObjects'); rec.addCheck('mathworks.example.optimizationSettings'); mdladvRoot.publish(rec); % publish inside By Task
The Simulink Check™ software provides an example that shows how to customize the Model Advisor by adding:
Check input parameters
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
The example also provides the source code of the
that executes the customizations.
To run the example:
At the MATLAB command line,
Follow the instructions in the model.