主要内容

addSubprocess

Class: padv.Process
Namespace: padv

Add subprocess to process

Syntax

subprocessObj = addSubprocess(process,subprocess)
subprocessObj = addSubprocess(___,Name=Value)

Description

subprocessObj = addSubprocess(process,subprocess) adds the subprocess specified by subprocess to the process. A subprocess represents a group of tasks. You can access the subprocess by using the subprocess object subprocessObj.

subprocessObj = addSubprocess(___,Name=Value) specifies the properties of the subprocess using one or more Name=Value arguments. For example, addSubprocess(p1,s1,Title="My Subprocess") adds the subprocess s1 to the process p1 and specifies that the subprocess appear with the title My Subprocess in the Process Advisor app. padv.Subprocess objects have other properties, but you cannot set those properties by using the name-value arguments.

Input Arguments

expand all

Process, specified as a padv.Process object.

Example: padv.Process("p1")

Subprocess, specified as either the:

  • Subprocess name, specified as a string

  • Subprocess instance, specified as a padv.Subprocess object

Example: "MySubprocessName"

Example: padv.Subprocess("MySubprocess")

Name-Value Arguments

expand all

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: addSubprocess(p1,s1,Title="My Subprocess")

Parameterization

expand all

Type of artifact, specified as one or more of the values listed in this table. To specify multiple values, use an array.

CategoryArtifact TypeDescription

MATLAB®

"m_class"MATLAB class
"m_file"MATLAB file
"m_func"MATLAB function
"m_method"MATLAB class method
"m_property"MATLAB class property

Model Advisor

"ma_config_file"Model Advisor configuration file
"ma_justification_file"Model Advisor justification file

Model Finder

"mf_database"Model Finder database file

Process Advisor

"padv_dep_artifacts"

Related artifacts that current artifact depends on

"padv_output_file"

Process Advisor output file

Project

"project"Current project file

Requirements

"mwreq_file"Requirement file (since R2024b)
"mwreq_item"Requirement (since R2024b)

"sl_req"

Requirement (for R2024a and earlier)
"sl_req_file"Requirement file (for R2024a and earlier)
"sl_req_table"Requirements Table

Stateflow®

"sf_chart"Stateflow chart
"sf_graphical_fcn"Stateflow graphical function
"sf_group"Stateflow group
"sf_state"Stateflow state
"sf_state_transition_chart"Stateflow state transition chart
"sf_truth_table"Stateflow truth table

Simulink®

"sl_block_diagram"Block diagram
"sl_data_dictionary_file"Data dictionary file
"sl_embedded_matlab_fcn"MATLAB function
"sl_block_diagram"Block diagram
"sl_library_file"Library file
"sl_model_file"Simulink model file
"sl_protected_model_file"Protected Simulink model file
"sl_subsystem"Subsystem
"sl_subsystem_file"Subsystem file

System Composer™

"zc_block_diagram"System Composer architecture
"zc_component"System Composer architecture component
"zc_file"System Composer architecture file
Tests"harness_info_file"Harness info file
"sl_harness_block_diagram"Harness block diagram
"sl_harness_file"Test harness file
"sl_test_case"Simulink Test™ case
"sl_test_case_result"Simulink Test case result
"sl_test_file"Simulink Test file
"sl_test_iteration"Simulink Test iteration
"sl_test_iteration_result"Simulink Test iteration result
"sl_test_report_file"Simulink Test result report
"sl_test_result_file"Simulink Test result file
"sl_test_resultset"Simulink Test result set
"sl_test_seq"Test Sequence
"sl_test_suite"Simulink Test suite
"sl_test_suite_result"Simulink Test suite result

Description

expand all

Human readable name that appears in the Tasks column of the Process Advisor app, specified as a string. By default, the Process Advisor app uses the Name property of the subprocess as the Title.

Data Types: string

Subprocess description, specified as a string.

Data Types: string

Path to subprocess documentation, specified as a string.

Data Types: string

Tools

expand all

Function that launches a tool, specified as the function handle or a cell array of function_handle objects. For each action that you specify in LaunchToolAction, you must have corresponding text specified in LaunchToolText.

When the property LaunchToolAction is specified, you can point to the subprocess in the Process Advisor app and click the ellipsis (...) and then Open Tool Name to open the tool associated with the subprocess.

Example: @openTool

Example: {@openToolA,@openToolB}

Data Types: cell | function_handle

Description of the action that the LaunchToolAction property performs, specified as a string. For each action that you specify in LaunchToolAction, you must have corresponding text specified in LaunchToolText.

Example: "Open Tool"

Example: ["Open Tool A","Open Tool B"]

Data Types: string

Output Arguments

expand all

Subprocess instance in process, returned as a padv.Subprocess object.

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