Main Content

Define Task Relationships

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.

Typically, you have dependencies between your tasks or you want your tasks to run in a specific order. In your process model, you can specify the relationship between tasks by using either the dependsOn method or the runsAfter method.

  • dependsOn specifies that a task depends on inputs or results from another task to run successfully. When you run the downstream task, the build system automatically runs the upstream task first.

  • runsAfter specifies a preferred task execution order for tasks that do not depend on each other. When both tasks are in the queue of tasks for the build system to run, the build system runs those tasks in your preferred task execution order when possible.

Open Process Model

You can specify the relationships between tasks 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.

  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.

Specify Relationships

Suppose you want to perform these tasks in the following order:

  1. Check modeling standards with the built-in task RunModelStandards.

  2. Generate code with the built-in task GenerateCode.

  3. Inspect the generated code with the built-in task RunCodeInspection.

The following process model adds those tasks to the process model and specifies the relationships between those tasks by using the runsAfter and dependsOn methods.

function processmodel(pm)

    arguments
        pm padv.ProcessModel
    end

    % Add Tasks
    modelAdvisorTask = pm.addTask(padv.builtin.task.RunModelStandards);
    generateCodeTask = pm.addTask(padv.builtin.task.GenerateCode);
    inspectCodeTask = pm.addTask(padv.builtin.task.RunCodeInspection);

    % Define Task Relationships
    generateCodeTask.runsAfter(modelAdvisorTask);
    inspectCodeTask.dependsOn(generateCodeTask);

end
The code generation task should run after the Model Advisor task because code generation does not depend on the results or outputs from Model Advisor. The code inspection task depends on the generated code to have code to inspect and cannot run successfully without the outputs from code generation. In Process Advisor, if you point to the run button for a task that depends on another task, Process Advisor highlights that dependency. If you run a downstream task, like Inspect Code, the upstream dependencies, like Generate Code, run automatically.

Process Advisor highlighting Generate Code task as dependency for the Inspect Code task

See Also

| | | | |

Related Topics