addDependsOnRelationship
Class: padv.Process
Namespace: padv
Create dependency between two tasks or subprocesses
Syntax
addDependsOnRelationship(process,Source=dependentTaskOrSubprocess,Dependency=prerequisiteTaskOrSubprocess)
addDependsOnRelationship(___,Name=Value)
Description
addDependsOnRelationship(
specifies that in the process
,Source=dependentTaskOrSubprocess
,Dependency=prerequisiteTaskOrSubprocess
)process
, the source depends on the dependency. The
source does not run until after the dependency runs completely and has a status.
addDependsOnRelationship(___,
specifies additional characteristics of the relationship by using one or more
Name=Value
)Name=Value
arguments. For example,
addDependsOnRelationship(p1,Source=t2,Dependency=t1,WhenStatus=["Pass","Fail"])
specifies that in process p1
, task t2
depends on task
t1
and that task t2
can only run after
t1
runs completely and has a passing or failing task status.
Input Arguments
process
— Process
padv.Process
object
Process, specified as a padv.Process
object.
Example: padv.Process("p1")
dependentTaskOrSubprocess
— Task or subprocess that depends on completion of prerequisite task or subprocess
string | padv.Task
object | padv.Subprocess
Task or subprocess that depends on the completion of a prerequisite task or subprocess, specified as either:
Task name, specified as a string
Task instance, specified as a
padv.Task
objectSubprocess name, specified as a string
Subprocess instance, specified as a
padv.Subprocess
object
Example: "TaskB"
Example: padv.Task("TaskB")
Example: padv.builtin.task.AnalyzeModelCode()
prerequisiteTaskOrSubprocess
— Task or subprocess that must run before dependent task or subprocess
string | padv.Task
object | padv.Subprocess
Task or subprocess that must run before a dependent task or subprocess, specified as either:
Task name, specified as a string
Task instance, specified as a
padv.Task
objectSubprocess name, specified as a string
Subprocess instance, specified as a
padv.Subprocess
object
Example: "TaskA"
Example: padv.Task("TaskA")
Example: padv.builtin.task.GenerateCode()
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: addDependsOnRelationship(p1,Source=t2,Dependency=t1,WhenStatus=["Pass","Fail"])
IterationArtifactMatching
— Option to control which prerequisite task iterations run
true
or 1
(default) | false
or 0
Option to control which prerequisite task iterations run, specified as a numeric
or logical 1
(true
) or 0
(false
):
true
— When the build system runs the dependencies, the build system runs only the task iterations that the tasks have in common.false
— When the build system runs the dependencies of a task, 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 depends on all project artifacts generated by the first task.
For example, suppose you have two tasks: TaskA
and
TaskB
:
TaskA
runs onModelA
andModelB
.TaskB
runs only onModelB
and depends onTaskA
.
If you run TaskB
and:
IterationArtifactMatching
istrue
,TaskA
runs only onModelB
.IterationArtifactMatching
isfalse
,TaskA
runs on bothModelA
andModelB
.
Data Types: logical
Override
— Replace existing relationship
false
or 0
(default) | true
or 1
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
relationship between the tasks or subprocesses.
Data Types: logical
WhenStatus
— Option to control when dependencies run
"Pass"
(default) | ["Pass","Fail"]
| ["Pass","Fail","Error"]
Option to control when dependencies run, specified as either:
"Pass"
— Only run the task or subprocess if the dependencies pass. For example, ifTaskB
depends onTaskA
,TaskA
needs to pass beforeTaskB
runs. IfTaskA
fails or errors,TaskB
does not run.["Pass","Fail"]
— Only run the task or subprocess if the dependencies either pass or fail. For example, ifTaskB
depends onTaskA
,TaskA
needs to either pass or fail beforeTaskB
runs. IfTaskA
errors,TaskB
does not run.["Pass","Fail","Error"]
— The task or subprocess runs, even if the dependencies fail or error. For example, ifTaskB
depends onTaskA
,TaskA
can pass, fail, or error andTaskB
still runs.
Examples
Add Tasks and Subprocesses Inside Process
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
andprocessB
Adds example tasks and subprocess to the processes by using the
addTask
andaddSubprocess
methodsDefines task relationships inside a specific process by using the
addDependsOnRelationship
andaddRunsAfterRelationship
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
.
See Also
Functions
Classes
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: United States.
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)