Main Content

Advisor.authoring.createBlockConstraintCheck

Create Model Advisor check for registering block constraints

Description

check_obj = Advisor.authoring.createBlockConstraintCheck(check_ID) creates a ModelAdvisor.check object, check_obj, and assigns it a unique identifier, check_ID. Specify the block constraints data file as an input parameter to this object. Use the Advisor.authoring.generateBlockConstraintsDataFile function to create the block constraints data file.

Examples

collapse all

This code shows how to specify and register a Model Advisor constraint check in the sl_customization file. Just below the %check comment, the Advisor.authoring.createBlockConstraintCheck function creates the ModelAdvisor.check object rec. The inputParam1.value is the name of the data file that contains the block constraints. In this example, that data file is myDataFile.xml. For an example of how to create this data file, see Advisor.authoring.generateBlockConstraintsDataFile.

function sl_customization(cm)

% register custom checks.
cm.addModelAdvisorCheckFcn(@defineModelAdvisorChecks);

% register items to factory group.
cm.addModelAdvisorTaskFcn(@defineModelAdvisorGroups);


% defineModelAdvisorChecks
function defineModelAdvisorChecks

% check
rec = Advisor.authoring.createBlockConstraintCheck('com.mathworks.sample.Check1');
rec.Title = 'Example: Check block parameter constraints';
rec.setCallbackFcn(@(system)(Advisor.authoring.CustomCheck.checkCallback...
    (system)), 'None', 'StyleOne');
rec.TitleTips = 'Example check block parameter constraints';

% --- data file input parameters
rec.setInputParametersLayoutGrid([1 1]);
inputParam1 = ModelAdvisor.InputParameter;
inputParam1.Name = 'Data File';
inputParam1.Value = 'myDataFile.xml';
inputParam1.Type = 'String';
inputParam1.Description = 'Name or full path of XML data file.';
inputParam1.setRowSpan([1 1]);
inputParam1.setColSpan([1 1]);
rec.setInputParameters({inputParam1});
rec.SupportExclusion = false;
rec.SupportLibrary = true;

mdladvRoot = ModelAdvisor.Root;
mdladvRoot.register(rec);

% defineModelAdvisorGroups
function defineModelAdvisorGroups
mdladvRoot = ModelAdvisor.Root;

% --- sample factory group 1
rec = ModelAdvisor.FactoryGroup('com.mathworks.Test.factoryGroup');
rec.DisplayName='Example: My Group';
rec.addCheck('com.mathworks.sample.Check1');

mdladvRoot.publish(rec);

Input Arguments

collapse all

Name of model advisor check, specified as a character vector

Example: 'com.mathworks.sample.Check1'

Output Arguments

collapse all

New ModelAdvisor.check object with default property values.

Note

The ModelAdvisor.Check object that you create using the Advisor.authoring.createBlockConstraintCheck function does not support setting exclusions.

Introduced in R2018a