Main Content

addRunsAfterRelationship

Class: padv.Process
Namespace: padv

Specify predecessor for task or subprocess

Syntax

addRunsAfterRelationship(process,Source=sourceTaskOrSubprocess,Predecessor=predecessorTaskOrSubprocess)
addRunsAfterRelationship(___,Name=Value)

Description

addRunsAfterRelationship(process,Source=sourceTaskOrSubprocess,Predecessor=predecessorTaskOrSubprocess) specifies that in the process, the source should run after the predecessor.

addRunsAfterRelationship(___,Name=Value) specifies additional characteristics of the relationship by using one or more Name=Value arguments. For example, addRunsAfterRelationship(p1,Source=t2,Predecessor=t1,Override=true) specifies that in process p1, task t2 should run after task t1 and that this relationship overrides any other relationships defined between tasks t1 and t2 in the process.

Input Arguments

expand all

Process, specified as a padv.Process object.

Example: padv.Process("p1")

Task or subprocess that should run after completion of predecessor task or subprocess, specified as either:

  • Task name, specified as a string

  • Task instance, specified as a padv.Task object

  • Subprocess name, specified as a string

  • Subprocess instance, specified as a padv.Subprocess object

Example: "TaskB"

Example: padv.Task("TaskB")

Example: padv.builtin.task.GenerateCode()

Task or subprocess that should run before source task or subprocess, specified as either:

  • Task name, specified as a string

  • Task instance, specified as a padv.Task object

  • Subprocess name, specified as a string

  • Subprocess instance, specified as a padv.Subprocess object

Example: "TaskA"

Example: padv.Task("TaskA")

Example: padv.builtin.task.RunModelStandards()

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Example: addRunsAfterRelationship(p1,Source=t2,Predecessor=t1,Override=true)

Option to control which predecessor task iterations run, specified as a numeric or logical 1 (true) or 0 (false):

  • true — When the build system runs the predecessors, the build system runs only the task iterations that the tasks or subprocesses have in common.

  • false — When the build system runs the predecessors, the build system runs all task iterations. This behavior is useful when you have a task that creates new project artifacts and a task that runs on each artifact in the project. The second task should run after all project artifacts are generated by the first task.

For example, suppose you have two tasks: FirstTask and SecondTask:

  • FirstTask runs on ModelA and ModelB.

  • SecondTask runs only on ModelB and should run after on FirstTask.

If you run SecondTask and:

  • IterationArtifactMatching is true, FirstTask runs only on ModelB.

  • IterationArtifactMatching is false, FirstTask runs on both ModelA and ModelB.

Data Types: logical

Replace existing relationship, specified as a numeric or logical 0 (false) or 1 (true).

By default, if you define multiple relationships between the same tasks or subprocesses, the build system only uses the most recent relationship and ignores previous relationships. Setting the Override argument as 1 (true) makes sure that the current relationship replaces any existing relationships.

Data Types: logical

Option to control whether the build system ignores circular relationships between tasks or subprocesses, specified as a numeric or logical 0 (false) or 1 (true).

By default, if you specify a circular relationship between tasks or subprocesses, the build system ignores the relationship. For example, if you specify both addRunsAfterRelationship(p1,SecondTask,FirstTask) and addRunsAfterRelationship(p1,FirstTask,SecondTask), the build system ignores the addRunsAfterRelationship relationship.

If you specify StrictOrdering as true, the build system generates an error when you try to run tasks or subprocesses that have a circular relationship.

Data Types: logical

Examples

expand all

In your process model, you can define multiple processes for different workflows and environments. A process consists of the tasks and subprocesses that you add to your padv.Process process by using the addTask and addSubprocess methods. To specify the relationships between tasks inside a specific process, use the addDependsOnRelationship and addRunsAfterRelationship methods.

Open the Process Advisor example project.

processAdvisorExampleStart

The model AHRS_Voter opens with the Process Advisor pane to the left of the Simulink® canvas.

In the Process Advisor pane, click the Edit process model button to open the processmodel.m file for the project.

Replace the contents of the processmodel.m file with the following example code. The code:

  • Defines two processes, processA and processB

  • Adds example tasks and subprocess to the processes by using the addTask and addSubprocess methods

  • Defines task relationships inside a specific process by using the addDependsOnRelationship and addRunsAfterRelationship methods

function processmodel(pm)
    % This function defines a process model for a project by setting up processes,
    % subprocesses, and tasks within those processes.

    arguments
        pm padv.ProcessModel
    end

    % --- Processes ---
    % Add processes to process model
    processA = pm.addProcess("A");
    processB = pm.addProcess("B");

    % --- Tasks ---
    % Create example tasks
    task1 = padv.Task("task1");
    task2 = padv.Task("task2");
    task3 = padv.Task("task3");
    taskA1 = padv.Task("taskA1");
    taskA2 = padv.Task("taskA2");
    taskB1 = padv.Task("taskB1");
    taskB2 = padv.Task("taskB2");

    % --- Subprocesses ---
    % Add subprocesses to parent process
    subprocessA = processA.addSubprocess("subprocessA"); % Add to process A
    subprocessB = processB.addSubprocess("subprocessB"); % Add to process B

    % --- Add Tasks to Processes ---
    processA.addTask(task1); % Add task1 to process A
    processA.addTask(task2); % Add task2 to process A
    processB.addTask(task1); % Reuse task1 in process B
    processB.addTask(task3); % Add task3 to process B

    % --- Add Tasks to Subprocesses ---
    subprocessA.addTask(taskA1); % Add taskA1 to subprocessA under process A
    subprocessA.addTask(taskA2); % Add taskA2 to subprocessA under process A
    subprocessB.addTask(taskB1); % Add taskB1 to subprocessB under process B
    subprocessB.addTask(taskB2); % Add taskB2 to subprocessB under process B

    % --- Add Relationships Between Tasks ---
    % In processA, task2 should run after task1
    processA.addRunsAfterRelationship(...
        Source = task2,...
        Predecessor = task1);
    % In processA, taskA2 depends on taskA1
    processA.addDependsOnRelationship(...
        Source = taskA2,...
        Dependency = taskA1);

end

In Process Advisor, refresh by clicking Refresh Tasks.

You can select which process you want to use from the Process gallery in the toolstrip. By default, processes appear in the order that you define them in the process model.

If you point to the run button for taskA2 in process A, Process Advisor highlights the dependency between taskA2 and taskA1.

Process Advisor Tasks column showing mouse pointing to taskA2

Go to top of page