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.
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.
Open the project that contains your files.
Open Process Advisor. On the Project tab, in the Tools section, click Process Advisor.
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.
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.
Goal | Task Title | Built-In Task | Required Product | Requires Display |
---|---|---|---|---|
Model Reports | Generate SDD Report | padv.builtin.task.GenerateSDDReport | Simulink® Report Generator™ | Yes. For more information, see Set Up Virtual Display Machines Without Displays. |
Generate Simulink Web View | padv.builtin.task.GenerateSimulinkWebView | |||
Generate Model Comparison | padv.builtin.task.GenerateModelComparison | Simulink | ||
Requirements Reports | Generate Requirements Report | padv.builtin.task.GenerateRequirementsReport | Requirements Toolbox™ | No |
Model Analysis | Check Modeling Standards | padv.builtin.task.RunModelStandards | Simulink Check™ | |
Detect Design Errors | padv.builtin.task.DetectDesignErrors | Simulink Design Verifier™ | ||
Testing and Coverage | Merge Test Results | padv.builtin.task.MergeTestResults | Simulink Test™ | |
Run Tests | padv.builtin.task.RunTestsPerModel | |||
Run Tests | padv.builtin.task.RunTestsPerTestCase | |||
Model Design and Testing Metrics | Collect Metrics | padv.builtin.task.CollectMetrics | Simulink Check | |
Code Generation | Generate Code | padv.builtin.task.GenerateCode | Embedded Coder® | |
Code Analysis | Check Coding Standards or Prove Code Quality | padv.builtin.task.AnalyzeModelCode | Polyspace® Bug Finder™ or Polyspace Code Prover™ | |
Inspect Code | padv.builtin.task.RunCodeInspection | Simulink Code Inspector™ | ||
Build Automation | Run MATLAB Build Tool Tasks | padv.builtin.task.RunBuildTool | MATLAB® |
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.