Main Content

Add Tasks to Process

With the CI/CD Automation for Simulink Check support package, you can define a development and verification process for your team by creating a process model and adding tasks for the steps that you want to perform as part of your process. In the process model, you add the tasks that you want to perform as part of your process. A task represents an individual step in the process. Tasks can take artifacts as inputs, perform specific actions, generates assessments, and return artifacts as outputs.

Flow diagram for a task accepting input artifacts and returning output artifacts and assessments

Open Process Model

You can add tasks to your process by editing the process model file for your project. If you do not have a project or process model, see Automate and Run Tasks with Process Advisor to get started.

  1. Open the project that contains your files.

  2. Open Process Advisor. On the Project tab, in the Tools section, click Process Advisor.

  3. Edit the process model by clicking the Edit button in the toolstrip.

Add Tasks

You add tasks to your process model by using the addTask object function on the padv.ProcessModel object. You can add:

  • Built-In Tasks for common activities like checking modeling standards, generating code, and running tests.

  • Custom Tasks for your own customized task behavior.

For example, the following process model adds the built-in task padv.builtin.task.RunModelStandards to the default process.

function processmodel(pm)
    arguments
        pm padv.ProcessModel
    end

     % Adding a built-in task
     modelAdvisorTask = pm.addTask(padv.builtin.task.RunModelStandards);

end

You can add multiple tasks to your process model, including multiple instances of the same task. However, each task object in your process must have a unique name specified by the Name property.

By default, tasks perform an action with a default behavior, but you can reconfigure the task behavior from inside the process model to change configuration files the task uses, output report file types, and other behaviors. For more information, see Reconfigure Task Behavior.

In Process Advisor, the Tasks column shows the task and the artifacts that the task iterates over.

Tasks column showing built-in task for Check Modeling Standards

Built-In Tasks

The support package has built-in tasks for common activities like checking modeling standards, generating code, and running tests. The classes that define the built-in tasks are in the padv.builtin.task namespace. To view the source code for a built-in task, use the open function.

GoalTask TitleBuilt-In TaskRequired ProductRequires Display
Model ReportsGenerate SDD Reportpadv.builtin.task.GenerateSDDReportSimulink® Report Generator™Yes. For more information, see Set Up Virtual Display Machines Without Displays.
Generate Simulink Web Viewpadv.builtin.task.GenerateSimulinkWebView
Generate Model Comparisonpadv.builtin.task.GenerateModelComparisonSimulink
Requirements ReportsGenerate Requirements Reportpadv.builtin.task.GenerateRequirementsReportRequirements Toolbox™No
Model AnalysisCheck Modeling Standardspadv.builtin.task.RunModelStandardsSimulink Check™
Detect Design Errorspadv.builtin.task.DetectDesignErrorsSimulink Design Verifier™
Testing and CoverageMerge Test Resultspadv.builtin.task.MergeTestResultsSimulink Test™
Run Testspadv.builtin.task.RunTestsPerModel
Run Testspadv.builtin.task.RunTestsPerTestCase
Model Design and Testing MetricsCollect Metricspadv.builtin.task.CollectMetrics

Simulink Check

Code GenerationGenerate Codepadv.builtin.task.GenerateCodeEmbedded Coder®
Code AnalysisCheck Coding Standards or Prove Code Qualitypadv.builtin.task.AnalyzeModelCodePolyspace® Bug Finder™ or Polyspace Code Prover™
Inspect Codepadv.builtin.task.RunCodeInspectionSimulink Code Inspector™
Build AutomationRun MATLAB Build Tool Taskspadv.builtin.task.RunBuildToolMATLAB®

Custom Tasks

If you need to perform steps that are not covered by the built-in tasks, you can create and add custom tasks to your process model.

For example, consider the following process model that adds a custom task named "RunMyScript" to run a script, myScript.m, and generate a result for Process Advisor. You define the action that the custom task performs by using the Action argument for the addTask method.

function processmodel(pm)

    arguments
        pm padv.ProcessModel
    end

    % Add custom task
    pm.addTask("RunMyScript", Action = @runMyScript);

end

% Define action that custom task performs
function taskResult = runMyScript(~)
    run("myScript.m");
    taskResult = padv.TaskResult;
end

However, for more complex tasks, you want to define your custom task in a separate class that inherits from one of the built-in task classes or from the padv.Task superclass. For more information, see Create Custom Tasks.

See Also

Related Topics