Defining a Process Callback Function

About Process Callback Functions

The process callback function is an optional function that lets you modify the appearance of checks and tasks in the Model Advisor, and process check results at run time. The process callback function specifies actions to be performed at different stages of Model Advisor execution:

If you create a process callback function, you must register it as described in Registering Custom Checks, Tasks, and Groups. The sections that follow provide mode information about defining your own process callback functions.

Process Callback Function Arguments

The process callback function takes the following arguments:

ArgumentI/O TypeData TypeDescription
stageInputEnumerationSpecifies the stages at which process callback actions are executed. Use this argument in a switch statement to specify actions for the stages configure and process_results.
systemInputPathModel or subsystem to be analyzed by Model Advisor.
checkCellArrayInput/OutputCell arrayAs input, the array of checks constructed in the check definition function.

As output, the array of checks modified by actions in the configure stage.
taskCellArrayInput/OutputCell arrayAs input, the array of tasks constructed in the task definition function.

As output, the array of tasks modified by actions in the configure stage.

Code Example: Process Callback Function

Here is an example of a process callback function that specifies actions in the configure stage to enable only the custom checks assigned to the Demo group in Code Example: Check Definition Function. In the process_results stage, this function displays an informative dialog box for checks that do not pass.

function [checkCellArray taskCellArray] = ...
    ModelAdvisorProcessFunction(stage, system, checkCellArray, taskCellArray)
switch stage
    case 'configure'
        for i=1:length(checkCellArray)
            % hidden all checks that do not belong to Demo group
            if ~(strcmp(checkCellArray{i}.Group, 'Demo'))
                checkCellArray{i}.Visible = false;
                checkCellArray{i}.Value = false;
            end
        end
    case 'process_results'
        for i=1:length(checkCellArray)
            % print message if check does not pass
            if checkCellArray{i}.Selected && ...
                    (strcmp(checkCellArray{i}.Title, ...
                    'Check Simulink window screen color'))
                if isempty(strfind(checkCellArray{i}.Result, 'Passed'))
                    disp('Example message from Model Advisor Process callback.');
                end
            end
        end
end
  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS