Main Content

Group Tasks with Subprocesses

With the CI/CD Automation for Simulink Check support package, you can define a development and verification process for your team by using a process model. Within a process, you can use subprocesses to group related tasks, create a hierarchy of tasks, and share parts of your overall process. A subprocess is a self-contained sequence of tasks, inside a process or other subprocess, that can run standalone.

Process Advisor UI with mouse pointing to run button for example subprocess

Open Process Model

You can group tasks into subprocesses 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 to Specific Subprocess

To group the tasks in your process:

  1. In the process model, you can add a subprocess by using addSubprocess on your process model object.

    spA = pm.addSubprocess("Subprocess A");

  2. Instead of adding your tasks directly to your process model object, add your tasks to a specific subprocess by using addTask.

    tA1 = spA.addTask("Task A1");
    tA2 = spA.addTask("Task A2");

  3. You can use the dependsOn and runsAfter methods to define the relationships between tasks and subprocesses in your process.

    For example, the following process model defines a process in which Task 1 runs, then Subprocess A, and then Subprocess B.

    function processmodel(pm)
        % Defines the project's processmodel
    
        arguments
            pm padv.ProcessModel
        end
    
        t1 = pm.addTask("Task 1");
    
        spA = pm.addSubprocess("Subprocess A");
            tA1 = spA.addTask("Task A1");
            tA2 = spA.addTask("Task A2");
        spB = pm.addSubprocess("Subprocess B");
            tB1 = spB.addTask("Task B1");
            tB2 = spB.addTask("Task B2");
        
        % Relationships
        spA.dependsOn(t1);
            tA2.dependsOn(tA1);
        spB.dependsOn(spA);
            tB2.dependsOn(tB1);
    
    end
    The build system executes each of the tasks inside a subprocess before existing the subprocess. The following diagram shows a graphical representation of the relationships defined by that process model.

    Diagram showing relationships between Task 1, Subprocess A, and Subprocess B as arrows

Considerations for Subprocess Boundaries

The relationships that you specify in the process model cannot cross any subprocess boundaries. For example, in the previous process model, you cannot directly specify that Task A1 depends on Task 1 because that relationship would enter into Subprocess A, crossing the subprocess boundary.

Diagram showing invalid relationship between Task 1 and Task A1, marked with a red X

In this case, you need to create a relationship between the Task 1 and Subprocess A instead.

Example Process Model with Subprocesses

To access an example process model that groups tasks into subprocesses for Model Verification and Code Verification, enter processAdvisorExampleStart(Subprocess = true) at the command line.

Process Advisor app showing Model Verification and Code Verification tasks in the Tasks column

See Also

Related Topics