Reconfigure Task Behavior
With the CI/CD Automation for Simulink Check support package, you can define a development and verification process for your team by adding tasks to your process model and reconfiguring the task behavior to meet the needs of your specific process.
You can modify the behavior of a task by overriding the values of the task properties in the process model. You can use the task properties to control the:
If you do not have a process model for your team, you can get started by using the default process model as shown in Modify Default Process Model to Fit Your Process.
Open Process Model
You can reconfigure task behavior for your project and process by editing the process model file for the 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.
Alternatively, for custom tasks, you can specify the task property values directly in your class definition file. For more information, see Create Custom Tasks.
Task Inputs
The InputQueries
property of a task defines the task inputs. If you want to provide additional inputs to a task, you can add queries to the InputQueries
property of the task by using the addInputQueries
method on the task object in the process model. For each task in the process, Process Advisor runs the InputQueries
property of the task to find the input artifacts. For each input artifact, Process Advisor also runs the InputDependencyQuery
property of the task to find additional dependencies that can impact whether task results are up-to-date. Queries find artifacts in your project based on search criteria like the artifact type, project label, file path, and other characteristics. For more information, see Find Artifacts with Queries.
For example, if you want the Check Modeling Standards task to run the Model Advisor checks specified by a Model Advisor configuration file, sampleChecks.json
, you can add this file as an input to the task. This allows the task to use the file as an input, recognize changes to the file, and update the task status if the file changes. The task automatically becomes outdated if you make a change to any of the task inputs or input dependencies.
maTask = pm.addTask(padv.builtin.task.RunModelStandards()); % Specify which Model Advisor configuration file to run maTask.addInputQueries(padv.builtin.query.FindFileWithAddress( ... Type = 'ma_config_file',... Path = fullfile('tools','sampleChecks.json')));
When you run the task in Process Advisor and point to the task results in the I/O column, you can see the task Inputs and the additional input Dependencies.
Using Task Outputs as Task Inputs
If you want a task to use the outputs from a previous task:
Specify a
dependsOn
relationship between the two tasksUpdate the
InputQueries
property of the downstream task to use the querypadv.builtin.query.GetOutputsOfDependentTask
as one of the input queries
For example, the built-in task MergeTestResults
requires outputs from the built-in task RunTestsPerTestCase
. In the process model, you must specify a dependency between these tasks by using the dependsOn
function. For example:
mergeTestTask.dependsOn(milTask, "WhenStatus",{'Pass','Fail'});
MergeTestResults
, you can see that the task uses the built-in query GetOutputsOfDependentTask
as an input query to find the outputs from the RunTestsPerTestCase
task.... options.InputQueries = [padv.builtin.query.GetIterationArtifact,... padv.builtin.query.GetOutputsOfDependentTask(... Task="padv.builtin.task.RunTestsPerTestCase")]; ...
Task Action
Tasks have various properties that determine how they perform their task actions. For example, the Check Modeling Standards task has properties such as CheckIDList
, DisplayResults
, and ExtensiveAnalysis
. When you run the RunModelStandards
task, these properties specify the input arguments for the function ModelAdvisor.run
. For information on the built-in task classes and their properties, see Built-In Tasks.
You can reconfigure how a task runs by specifying different values for these properties in the
process model. For example, for the Check Modeling Standards
task, you can specify a list of Model Advisor checks to run and the report format by
setting the CheckIDList
and ReportFormat
properties.
maTask = pm.addTask(padv.builtin.task.RunModelStandards()); % Specify which Model Advisor checks to run maTask.CheckIDList = {'mathworks.jmaab.db_0032','mathworks.jmaab.jc_0281'}; % Specify report format maTask.ReportFormat = 'docx';
When you run the task in Process Advisor, the task runs the specified Model Advisor checks and generates the Model Advisor report as a Microsoft® Word document instead of an HTML file.
Task Iterations
The IterationQuery
property of a task defines which artifacts a task iterates over and therefore how often the task runs. For example, by default, the Check Modeling Standards task uses the iteration query padv.builtin.query.FindModels
to run one time for each model in the project. Although tasks iterate over artifacts, tasks do not automatically use those artifacts as inputs unless those artifacts are specified by the task input queries. Queries find artifacts in your project based on search criteria like the artifact type, project label, file path, and other characteristics. For more information, see Find Artifacts with Queries.
To change which artifacts a task iterates over, you can specify a different value for the IterationQuery
property. For example, to have the Check Modeling Standards task only iterate over models that have Voter
in their file path, you can modify the iteration query for the task.
maTask = pm.addTask(padv.builtin.task.RunModelStandards()); % Specify which set of artifacts to run for maTask.IterationQuery = ... padv.builtin.query.FindModels(IncludePath = 'Voter');
The task iterations appear below the task title in the Tasks column in Process Advisor. If the iteration query does not return results, the task no longer appears in Process Advisor.
See Also
addInputQueries
| addTask
| padv.Task
| Process Advisor | runprocess