Process Advisor Reference
Process Advisor Reference
Support Package
Reference Book
R2022a — R2023b
How to Contact MathWorks
Phone: 508-647-7000
iii
Reference Book
1
Utilities
6
Artifact Types
8
Tokens
9
iv Contents
Built-In Task Library
10
Check Coding Standards or Prove Code Quality . . . . . . . . . . . . . . . . . . . . 10-3
Prerequisites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-3
Add Task to Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-3
Reconfigure Task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-4
Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-10
v
Run Tests (per model) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-37
Add Task to Process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-37
Reconfigure Task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-37
Source Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-39
padv.builtin.query.FindFilesWithLabel . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-5
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-5
Input Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-5
Use in Process Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-5
padv.builtin.query.FindFileWithAddress . . . . . . . . . . . . . . . . . . . . . . . . . . 11-7
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-7
Input Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-7
Use in Process Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-7
Test Outside Process Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-8
padv.builtin.query.FindModels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-9
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-9
Input Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-9
Use in Process Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-9
Test Outside Process Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-10
padv.builtin.query.FindModelsWithLabel . . . . . . . . . . . . . . . . . . . . . . . . 11-12
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-12
Input Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-12
Use in Process Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-12
padv.builtin.query.FindModelsWithTestCases . . . . . . . . . . . . . . . . . . . . . 11-14
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-14
Input Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-14
Use in Process Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-14
padv.builtin.query.FindProjectFile . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-16
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-16
Use in Process Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-16
padv.builtin.query.FindRefModels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-17
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-17
vi Contents
Input Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-14
Use in Process Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-17
padv.builtin.query.FindRequirements . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-18
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-18
Input Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-18
Use in Process Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-18
padv.builtin.query.FindRequirementsForModel . . . . . . . . . . . . . . . . . . . 11-20
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-20
Input Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-20
padv.builtin.query.FindTestCasesForModel . . . . . . . . . . . . . . . . . . . . . . . 11-21
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-21
Input Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-21
Use in Process Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-21
padv.builtin.query.FindTopModels . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-23
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-23
Input Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-14
Use in Process Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-23
padv.builtin.query.GetDependentArtifacts . . . . . . . . . . . . . . . . . . . . . . . 11-25
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-25
Use in Task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-25
padv.builtin.query.GetIterationArtifact . . . . . . . . . . . . . . . . . . . . . . . . . . 11-26
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-26
Use in Task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-26
padv.builtin.query.GetOutputsOfDependentTask . . . . . . . . . . . . . . . . . . 11-27
Syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-27
Input Arguments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-27
Use in Task . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-27
vii
1
Reference Book
This PDF is a Reference Book with information on the API, artifact types, built-in tasks, and built-in
queries.
For examples and general information, see the User's Guide PDF. You can access the PDFs from
either:
• https://www.mathworks.com/matlabcentral/fileexchange/115220-ci-cd-automation-for-simulink-
check
• The question mark icon in the Process Advisor app
2
The support package provides a customizable process modeling system that you can use to define
your build and verification process. You define your pipeline of tasks in the process model. The
process model is a file (processmodel.p or processmodel.m) that specifies the tasks in the
process, the queries that determine which artifacts to use for each task, the artifacts associated with
each task, and the dependencies between tasks. Open the Process Advisor app or use the function
createprocess to create a process model for your project. Inside the process model file, you can
add, remove, and reconfigure tasks and the dependencies between tasks.
For examples of how to create a process model, see the "Author Your Process Model" chapter in the
User's Guide PDF.
Classes
Class Description
padv.Artifact Store artifact information
padv.ProcessModel Define tasks and process for project
padv.Query Select set of artifacts from project
padv.Subprocess Group tasks
padv.Task Define single step in process
padv.TaskResult Create and access results from task
Functions
Function Description
createprocess Create a process model
getprocess Get process model object for process model in
project
2 Process Modeling System API
createprocess
Create process model
Syntax
processModelPath = createprocess()
processModelPath = createprocess(Name=Value)
Description
processModelPath = createprocess() creates a process model at the project root and returns
the path to the created process model. The process model is saved as processmodel.m.
By default, the process model is a default process model that can create a model-based design
pipeline. You can only call createprocess if you have a project open.
Examples
Open a project that does not have a process model and use createprocess to create a copy of the
default process into the project.
Open an example project, for example matlab.project.example.timesTable, that does not have
a process model.
processModelPath = createprocess
createprocess copies the default process model into the project root and saves the path to the
process model to processModelPath.
myProject = currentProject;
addFile(myProject,processModelPath)
Open the Process Advisor app in a standalone window to view the tasks associated with the project
and project artifacts.
processAdvisorWindow
2-2
createprocess
Open a project and overwrite the process model with an empty process model.
Open the Process Advisor example project, which contains an example process model.
processAdvisorExampleStart
Use createprocess to overwrite the existing process model with an empty process model.
processModelPath = createprocess(Template="empty",Overwrite=true)
Open the created process model to view the commented-out example code.
open(processModelPath)
Input Arguments
Name-Value Pair Arguments
Example: "empty"
Data Types: char | string
Setting to overwrite existing process model, specified as a numeric or logical 0 (false) or 1 (true).
Example: true
Data Types: logical
Output Arguments
processModelPath — Path to created process model
character vector
2-3
2 Process Modeling System API
Alternative Functionality
App
If a project does not have a process model, you can use the Process Advisor app to create the default
process model. To open the Process Advisor app for a project, in the MATLAB® Command Window,
enter:
processAdvisorWindow
When you open the Process Advisor app on a project that does not have a process model, the app
automatically creates a copy of the default process model at the root of the project.
Version History
Introduced in R2022a
2-4
getprocess
getprocess
Get process model object for process model in project
Syntax
processModelObject = getprocess()
Description
processModelObject = getprocess() returns a process model object, processModelObject,
for the process model in the project. You can use the process model object to view the properties of
the process model in the project. For more information, see the documentation for
"padv.ProcessModel" in this PDF.
If the current project does not have a process model, the function getprocess automatically creates
a new process model at the root of the project.
Examples
Use getprocess to find the default query that the current process model uses. If you have a task
that does not specify an iteration query, the default query defines which artifacts the process iterates
over. By default, custom tasks run once per project because the default query is
"padv.builtin.query.FindProjectFile".
Open the Process Advisor example project, which contains an example process model.
processAdvisorExampleStart
currentProcessModel = getprocess()
defaultQuery = currentProcessModel.DefaultQueryName
defaultQuery =
"padv.builtin.query.FindProjectFile"
You can use the findTask and findQuery functions on the loaded process model to find specific
tasks and queries in the process.
2-5
2 Process Modeling System API
findTask(currentProcessModel,"padv.builtin.task.RunModelStandards")
Output Arguments
processModelObject — Properties of process model
padv.ProcessModel object
The padv.ProcessModel object returns the names of the tasks, queries, default query, and root
process model file for the process.
Version History
Introduced in R2022a
2-6
padv.Artifact
padv.Artifact
Store artifact information
Description
A padv.Artifact object represents an artifact that you can run a task on in the process defined in
your process model. For example, you can use a padv.Artifact object as the input to functions like
runprocess and generateProcessTasks when you only want to run or generate tasks associated
with a specific artifact.
Creation
Syntax
artifactObject = padv.Artifact(artifactType,artifactAddress)
artifactObject = padv.Artifact( ___ ,Name=Value)
Description
artifactObject = padv.Artifact( ___ ,Name=Value) specifies the artifact using one or more
Name=Value arguments.
Input Arguments
For a list of valid artifact types, see the chapter "Artifact Types" in this PDF.
Example: "sl_model_file"
Example: "m_file"
Example: "sl_test_case"
Data Types: string
2-7
2 Process Modeling System API
Properties
Type — Type of artifact
string
For a list of valid artifact types, see the chapter "Artifact Types" in this PDF.
Example: "sl_model_file"
Example: "sl_test_case"
Example: "m_file"
Data Types: string
Object Functions
Object Function Description
getAlias Get human-readable name for subfile artifact. A
subfile is a part of a larger file. For example, a
subsystem is a subfile of a model file.
ALIAS = getAlias(artifactObj)
getTypes Get artifact type.
TYPES = getTypes(artifactObj)
getKey Get unique key for artifact. A key is a unique
address for a file.
KEY = getKey(artifactObj)
2-8
padv.Artifact
TYPE = hasType(artifactObj)
Examples
Suppose you have a process model with several tasks, but right now you only want to run test cases
associated with a single model. You can use a padv.Artifact object to specify the model and use
the runprocess function to run the test cases for that model.
Open the Process Advisor example project, which contains an example process model.
processAdvisorExampleStart
Create a padv.Artifact object that represents the model that you want to run. For this example,
the artifact type is "sl_model_file" because the artifact is a Simulink model and the address is the
path to model AHRS_Voter.slx, relative to the project root.
model = padv.Artifact(...
"sl_model_file",...
fullfile("02_Models","AHRS_Voter","specification","AHRS_Voter.slx"));
Run the Run Tests task on the test cases associated with the model AHRS_Voter.slx by specifying
the name-value arguments of the runprocess function.
runprocess(...
Tasks = "padv.builtin.task.RunTestsPerTestCase",...
FilterArtifact = model)
The build system only runs the test cases associated with the specified model.
Version History
Introduced in R2022a
2-9
2 Process Modeling System API
padv.ProcessModel
Define tasks and process for project
Description
A padv.ProcessModel object represents the process model that defines the tasks and process for a
project. A task performs an action and is a single step in your process. A process is a series of tasks
that run in a specific order. The process model defines the tasks that you can perform on the project,
and the order and relationships between tasks in the process. You can use tasks and queries to
dynamically perform actions and find artifacts in the project. Use the addTask object function to add
tasks to the process model. You can use the function runprocess to run the tasks defined in the
process model.
Creation
Syntax
pm = padv.ProcessModel()
Description
Properties
TaskNames — Tasks added to process model object
string array
Use the object function addTask to add a task instance to a process model.
Example: ["padv.builtin.task.GenerateSimulinkWebView"
"padv.builtin.task.RunModelStandards"]
Data Types: string
Use the object function addQuery to add a query instance to a process model.
Example: ["padv.builtin.query.FindModels" "padv.builtin.query.FindProjectFile"]
Data Types: string
2-10
padv.ProcessModel
Default query for tasks added to process model, specified as the name of a padv.Query query.
Example: "padv.builtin.query.FindModels"
Data Types: string
By default, Process Advisor and the build system output results in a folder PA_Results in the project
root.
Example: fullfile("$PROJECTROOT$","Process_Results")
Data Types: string
By default, the generated JUnit report for a task has the format
taskName_iterationArtifact_JUnit.xml.
Example: "$TASKNAME$_$ITERATIONARTIFACT$_JUnitReport.xml"
Data Types: string
2-11
2 Process Modeling System API
RootFileName uses processmodel.m as the name of the process model file, unless a
processmodel.p file exists. If you have both a P-code file and a .m file, the P-code file takes
precedence over the corresponding .m file for execution, even after modifications to the .m file.
Object Functions
reset Removes tasks and queries from process model
pm = padv.ProcessModel();
reset(pm);
reload Load process model by executing process model
file for project
pm = padv.ProcessModel();
reload(pm);
addSubprocess Add subprocess instance to process model
addSubprocess(pm,"MySubprocess");
addTask Add task instance to process model
addTask(pm,"MyCustomTask",Action=@SayHello,...
IterationQuery=padv.builtin.query.FindModels);
addQuery(pm,"MyCustomQuery")
pm = padv.ProcessModel();
QUERY = findQuery(pm,...
"padv.builtin.query.FindModels")
findTask Find task instance by name
pm = padv.ProcessModel();
TASK = findTask(pm,...
"padv.builtin.task.RunModelStandards");
exists Check if process model exists for project
Examples
You can use the object function addTask to add the tasks to a padv.ProcessModel object.
2-12
padv.ProcessModel
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.
function processmodel(pm)
arguments
pm padv.ProcessModel
end
addTask(pm,"taskA");
addTask(pm,"taskB");
end
The function addTask adds the task objects to the padv.ProcessModel object.
Use the function getprocess to get the process model object for the project.
pm = getprocess;
Get the task object for "taskA" defined in the current process model.
taskAObj is a padv.Task object that you can use to view the properties of the task "taskA".
Version History
Introduced in R2022a
2-13
2 Process Modeling System API
addQuery
Package: padv
Syntax
queryObj = addQuery(pm,queryNameOrInstance)
queryObj = addQuery( ___ ,Name=Value)
Description
queryObj = addQuery(pm,queryNameOrInstance) adds the query specified by
queryNameOrInstance to the process model. You can access the query using the query object
queryObj.
queryObj = addQuery( ___ ,Name=Value) specifies the properties of the query using one or
more Name=Value arguments.
Input Arguments
pm — Process for project
padv.ProcessModel object (default) |
Artifact type returned by the query, specified as a valid value for the Type property of a
padv.Artifact object.
Example: DefaultArtifactType = "sl_model_file"
2-14
addQuery
Human readable name for the query, specified as a string. By default, the Title property of the
query is the same as the Name.
Example: Title = "My Query"
Data Types: string
FunctionHandle — Handle to function that runs when you run query object
function_handle
Handle to function that runs when you run query object, specified as a function_handle.
When you call the run function on a query object, run runs the function specified by the
function_handle.
Example: FunctionHandle = @FunctionForQuery
Data Types: function_handle
Initial query run before iteration query, specified as either a padv.Query object or the Name of a
padv.Query object. When you specify a padv.Query object as the iteration query for a task, the
Parent query is the initial query that the build system runs before running the specified iteration
query.
The build system ignores the Parent query when you specify a query as an input query or
dependency query for a task.
Example: Parent = "padv.builtin.query.FindModels"
Setting for automatically sorting artifacts by address, specified as a numeric or logical 1 (true) or 0
(false). When a query returns artifacts, the artifacts should be in a consistent order. By default, the
build system sorts artifacts by the artifact address.
Alternatively, you can sort artifacts in a different order by overriding the internal sortArtifacts
method in a subclass that defines a custom sort behavior. The build system automatically calls the
sortArtifacts method when using the process model. The sortArtifacts method expects two
input arguments: a padv.Query object and a list of padv.Artifact objects returned by the run
function. The sortArtifacts method should return a list of sorted padv.Artifact objects.
Example: SortArtifacts = false
2-15
2 Process Modeling System API
Output Arguments
queryObj — Query object
padv.Query object
For more information, see the documentation for "padv.Query" in this PDF.
Version History
Introduced in R2022a
2-16
addTask
addTask
Package: padv
Syntax
taskObj = addTask(pm,taskNameOrInstance)
taskObj = addTask( ___ ,Name=Value)
Description
taskObj = addTask(pm,taskNameOrInstance) adds the task specified by
taskNameOrInstance to the process model. You can access the task using the task object taskObj.
taskObj = addTask( ___ ,Name=Value) specifies the properties of the task using one or more
Name=Value arguments.
Examples
You can use the addTask function to create function-based tasks directly in the process model.
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.
function processmodel(pm)
arguments
pm padv.ProcessModel
end
addTask(pm,"MyCustomTask",Action=@SayHello,...
IterationQuery=padv.builtin.query.FindModels);
end
2-17
2 Process Modeling System API
This code adds a task, MyCustomTask to the process model while specifying that the task runs the
function SayHello one time for each model found in the project. The function SayHello also
specifies the results returned by the task.
Input Arguments
pm — Process for project
padv.ProcessModel object (default)
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 task as the Title.
Example: "My Task"
Data Types: string
Artifacts that task iterates over, specified as a padv.Query object or the name of a padv.Query
object. By default, task objects run one time and are associated with the project. When you specify
IterationQuery, the task runs one time for each artifact specified by the padv.Query. In the
Process Advisor app, the artifacts specified by IterationQuery appear under task title.
For example, if the IterationQuery for a task finds three models, Model_A, Model_B, and
Model_C, the build system creates three task iterations under the title of the task in the Tasks
column.
2-18
addTask
Each of the artifacts under the task title represents a task iteration.
• a padv.Query object
• the name of padv.Query object
• an array of padv.Query objects
• an array of names of padv.Query objects
2-19
2 Process Modeling System API
By default, the task does not specify any artifacts as inputs. When you specify InputQueries, the
task tasks the artifacts specified by the specified query or queries as an input.
Suppose a task runs once for each model in the project and you want to provide the models as inputs
to the task. If you specify InputQueries as the built-in query
padv.builtin.query.GetIterationArtifact, the query returns each artifact that the tasks
iterates over, which in this example is each of the models in the project.
Example: InputQueries = padv.builtin.query.GetIterationArtifact
Artifact dependencies for task inputs, specified as a padv.Query object or the name of a
padv.Query object.
Function that the task runs, specified as the function handle. When you run the task, the task runs
the function specified by the function handle.
For example, if you want the task to run the function myFunction, specify Action as @myFunction.
Example: Action = @myFunction
Data Types: function_handle
Artifact type that the task can run on, specified by a string. The required iteration artifact type must
be the artifact type supported by the IterationQuery property of the task.
For a list of valid artifact types, see the chapter "Artifact Types" in this PDF.
Example: RequiredIterationArtifactType = "sl_model_file"
Data Types: string
Setting to require all licenses for task, specified as a numeric or logical 1 (true) or 0 (false). By
default, all licenses in the Licenses property of the task are required for the task to run. Specify 0
(false) if the task can run without all licenses listed in the Licenses property.
Example: Licenses = ["matlab_report_gen" "simulink_report_gen"]
Data Types: logical
2-20
addTask
Output Arguments
taskObj — Task object
padv.Task object
For more information, see the documentation for "padv.Task" in this PDF.
Version History
Introduced in R2022a
2-21
2 Process Modeling System API
padv.Query
Select set of artifacts from project
Description
A padv.Query object represents a query that you can use to select a set of artifacts from a project.
Use the input arguments to define the set of artifacts that the query selects. Queries can either be
function-based or class-based. Use FunctionHandle to specify a function for a function-based query
or use inheritance for a class-based query.
Creation
Syntax
Q = padv.Query(Name)
Q = padv.Query( ___ ,Name = Value)
Description
Q = padv.Query( ___ ,Name = Value) specifies query properties using one or more name-value
arguments. For example, DefaultArtifactType = "sl_model_file" changes the default
artifact type for the query from a generic output file, "padv_output_file", to a model file,
"sl_model_file".
Input Arguments
Unique identifier for query, specified as character vector or string. You can only specify a query name
when you create a query object. You cannot change the query name after you create the query object.
2-22
padv.Query
Expected artifact type, specified as a valid value for the Type property of a padv.Artifact object.
padv.Task objects use the DefaultArtifactType to confirm that the artifacts output by the query
are the types of artifacts required by the padv.Task object.
When you use the run function on a query object, the DefaultArtifactType is the default value
for artifacts returned by the function.
Example: DefaultArtifactType = "sl_model_file"
Initial query run before iteration query, specified as either a padv.Query object or the Name of a
padv.Query object. When you specify a padv.Query object as the iteration query for a task, the
Parent query is the initial query that the build system runs before running the specified iteration
query.
The build system ignores the Parent query when you specify a query as an input query or
dependency query for a task.
Example: "padv.builtin.query.FindModels"
Setting for automatically sorting artifacts by address, specified as a numeric or logical 1 (true) or 0
(false). When a query returns artifacts, the artifacts should be in a consistent order. By default, the
build system sorts artifacts by the artifact address.
Alternatively, you can sort artifacts in a different order by overriding the internal sortArtifacts
method in a subclass that defines a custom sort behavior. The build system automatically calls the
sortArtifacts method when using the process model. The sortArtifacts method expects two
input arguments: a padv.Query object and a list of padv.Artifact objects returned by the run
function. The sortArtifacts method should return a list of sorted padv.Artifact objects.
Example: SortArtifacts = false
Data Types: logical
FunctionHandle — Handle to function that runs when you run query object
function_handle
2-23
2 Process Modeling System API
Handle to function that runs when you run query object, specified as a function_handle.
When you call the run function on a query object, run runs the function specified by the
function_handle.
Example: FunctionHandle = @FunctionForQuery
Data Types: function_handle
Version History
Introduced in R2022a
2-24
padv.Subprocess
padv.Subprocess
Group tasks
Description
Creation
A padv.Subprocess object represents a group of tasks in a padv.ProcessModel process. In your
process model, use the object functions addTask and addSubprocess to group tasks and
subprocesses inside your subprocess. You can use the object functions dependsOn and runsAfter to
specify the dependencies and desired execution order for a subprocess.
Properties
Title — Human readable name that appears in Process Advisor app
string
Human readable name that appears in the Tasks column of the Process Advisor app, returned as a
string. By default, the Process Advisor app uses the Name property of the task as the Title.
Example: padv.Task("myTask",Title = "My Task")
Data Types: string
Artifact type that the subprocess can run on, returned as a string. The required iteration artifact type
must be the artifact type supported by the IterationQuery property of the subprocess. For a list of
valid artifact types, see the chapter "Artifact Types" in this PDF.
2-25
2 Process Modeling System API
When the property LaunchToolAction is specified, you can point to the task in the Process Advisor
app and click the ellipsis (...) and then Open Tool Name to open the tool associated with the task.
For tasks that are not built-in tasks, the task options show the ellipsis (...) and then Launch Tool.
Example: padv.Task("myTask",LaunchToolAction = @openTool)
Data Types: function_handle
Description of the action that the LaunchToolAction property performs, returned as a string scalar.
Example: padv.Task("myTask",LaunchToolAction = @openTool, LaunchToolText =
"Open tool.")
Data Types: string
Controls if the padv.Task is enabled in the process model, returned as a numeric or logical 1 (true)
or 0 (false).
Example: padv.Task("myTask",Enabled = false)
Data Types: logical
Location for standard outputs that tasks in the subprocess produce, specified as a string.
Example: fullfile("folder", "subfolder")
Data Types: string
CacheDirectory — Location for additional cache files that tasks in subprocess produce
string
Location for additional cache files that tasks in the subprocess produce, specified as a string. The
cache directory can contain temporary files that do not need to be either saved in the task results or
archived by a CI system.
Example: fullfile("folder", "subfolder")
Data Types: string
2-26
padv.Subprocess
Object Functions
• addTask(subprocessObject, taskNameOrInstance, NAME, VALUE, ...)
• addSubprocess(subprocessObject, subprocessNameOrInstance, NAME, VALUE, ...)
• dependsOn(subprocessObject, DEPENDENCIES, NAME, VALUE, ...)
• runsAfter(subprocessObject, PREDECESSORS, NAME, VALUE, ...)
Examples
Group Tasks Inside Subprocess
You can use a subprocess to group related tasks, create a hierarchy of tasks, and share parts of a
process. A subprocess is a self-contained sequence of tasks, inside a process or other subprocess, that
can run standalone.
1 In the process model, add a subprocess by using addSubprocess on your process model object.
spA = pm.addSubprocess("Subprocess A");
2 Add your tasks directly to the subprocess by using addTask.
tA1 = spA.addTask("Task A1");
tA2 = spA.addTask("Task A2");
Note You do not need to add the task to both the subprocess and process model.
3 Specify the relationship between the tasks and subprocesses in your process.
You can use the dependsOn and runsAfter functions to define the relationships.
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
2-27
2 Process Modeling System API
pm padv.ProcessModel
end
t1 = pm.addTask("Task 1");
% 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.
Note Relationships cannot cross any subprocess boundaries. For example, in this 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.
2-28
padv.Subprocess
Version History
Introduced in R2022a
2-29
2 Process Modeling System API
padv.Task Class
Package: padv
Description
A padv.Task object represents a single step in a padv.ProcessModel process. For example, a
padv.Task object could represent a step like checking modeling standards, running tests,
generating code, or performing a custom action. padv.Task objects can accept project artifacts as
inputs, perform actions, generate assessments, and return project artifacts as outputs. In your
process model, use the object functions addInputQueries, dependsOn, and runsAfter to specify
the inputs, dependencies, and desired execution order for a task. You can execute tasks as part of a
pipeline. Use the runprocess function to generate and run a pipeline of tasks.
Creation
Syntax
taskObject = padv.Task(Name)
taskObject = padv.Task( ___ ,Name=Value)
Description
taskObject = padv.Task( ___ ,Name=Value) sets properties using one or more name-value
arguments. For example,
padv.Task("myTask",IterationQuery=padv.builtin.query.FindModels) creates a task
object named myTask that runs once for each model.
Properties
Public Properties
Unique identifier for task in process, returned as a string. When you specify the Name, you specify the
Name property of the task object.
Each task in the process model must have a unique Name. After you specify a Name for a padv.Task
object, you cannot change the Name.
2-30
padv.Task Class
Human readable name that appears in the Tasks column of the Process Advisor app, returned as a
string. By default, the Process Advisor app uses the Name property of the task as the Title.
Example: padv.Task("myTask",Title = "My Task")
Data Types: string
Function that the task runs, returned as the function handle. When you run the task, the task runs the
function specified by the function handle.
For example, if you want the task to run the function myFunction, specify Action as @myFunction.
Example: padv.Task("myTask",Action = @myFunction)
Data Types: function_handle
Artifact type that the task can run on, returned by a string. The required iteration artifact type must
be the artifact type supported by the IterationQuery property of the task.
For a list of valid artifact types, see the chapter "Artifact Types" in this PDF.
Example: padv.Task("myTask",RequiredIterationArtifactType = "sl_model_file")
Data Types: string
2-31
2 Process Modeling System API
Artifacts that task iterates over, returned as a padv.Query object or the name of a padv.Query
object. By default, task objects run one time and are associated with the project. When you specify
IterationQuery, the task runs one time for each artifact returned by the padv.Query. In the
Process Advisor app, the artifacts returned by IterationQuery appear under task title.
For example, if the IterationQuery for a task finds three models, Model_A, Model_B, and
Model_C, the build system creates three task iterations under the title of the task in the Tasks
column.
Each of the artifacts under the task title represents a task iteration.
2-32
padv.Task Class
Artifact dependencies for task inputs, returned as a padv.Query object or the name of a
padv.Query object.
Automatically include the number of MATLAB warning messages in the padv.TaskResult, returned
as a numeric or logical 0 (false) or 1 (true).
Example:
Data Types: logical
List of products that must be installed to run the task, returned as a string array.
Data Types: string
Setting to require all licenses for task, returned as a numeric or logical 1 (true) or 0 (false). By
default, all licenses in the Licenses property of the task are required for the task to run. Specify 0
(false) if the task can run without all licenses listed in the Licenses property.
Example: padv.Task("myTask",AllLicenseRequired = false)
Data Types: logical
When the property LaunchToolAction is specified, you can point to the task in the Process Advisor
app and click the ellipsis (...) and then Open Tool Name to open the tool associated with the task.
For tasks that are not built-in tasks, the task options show the ellipsis (...) and then Launch Tool.
Example: padv.Task("myTask",LaunchToolAction = @openTool)
Data Types: function_handle
2-33
2 Process Modeling System API
Description of the action that the LaunchToolAction property performs, returned as a string scalar.
Example: padv.Task("myTask",LaunchToolAction = @openTool, LaunchToolText =
"Open tool.")
Data Types: string
Controls if the padv.Task is enabled in the process model, returned as a numeric or logical 1 (true)
or 0 (false).
Example: padv.Task("myTask",Enabled = false)
Data Types: logical
AlwaysRun — Always force task to run, even if the task results are already up to date
false or 0 (default) | true or 1
Always force task to run, even if the task results are already up to date, returned as a numeric or
logical 0 (false) or 1 (true).
Example: padv.Task("myTask",AlwaysRun = true)
Data Types: logical
• a padv.Query object
• the name of padv.Query object
• an array of padv.Query objects
• an array of names of padv.Query objects
By default, the task does not specify any artifacts as inputs. When you specify InputQueries, the
task tasks the artifacts returned by the specified query or queries as an input.
Suppose a task runs once for each model in the project and you want to provide the models as inputs
to the task. If you specify InputQueries as the built-in query
padv.builtin.query.GetIterationArtifact, the query returns each artifact that the tasks
iterates over, which in this example is each of the models in the project.
Example: padv.Task("myTask",InputQueries =
padv.builtin.query.GetIterationArtifact)
Location for standard outputs that the task produces, specified as a string.
Built-in tasks automatically specify OutputDirectory. If you do not specify OutputDirectory for
a custom task, the build system stores task outputs in the DefaultOutputDirectory specified by
padv.ProcessModel.
Data Types: string
2-34
padv.Task Class
CacheDirectory — Location for any additional cache files that the task generates
string array
Location for any additional cache files that the task generates, specified as a string. The cache
directory can contain temporary files that do not need to be either saved in the task results or
archived by a CI system.
Data Types: string
List of CI aware result file types to be generated for task, specified as a string array.
Data Types: string
List of CI aware result file types generated by task, specified as a string array.
Data Types: string
Methods
Object Functions
addInputQueries(taskObj,inputQueries)
dependsOn Create a dependency between a task, taskObj,
and dependencies, dependencies.
dependsOn(taskObj,dependencies)
run Run task represented by taskObj.
taskResult = run(taskObj)
taskResult = run(taskObj,inputArtifacts)
runsAfter Specify the preferred execution order for tasks by
specifying the tasks, predecessors, that a task,
taskObj, should run after.
runsAfter(taskObj,predecessors)
See the next sections for more information on these object functions.
2-35
2 Process Modeling System API
Static Methods
Method Description
close_model Close the model or models specified by
modelNames.
close_model(modelNames)
load_model(modelNames)
Examples
You can use padv.Task to create task objects and then use the addTask function to add the task
objects to the padv.ProcessModel object.
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.
function processmodel(pm)
arguments
pm padv.ProcessModel
end
taskA = padv.Task("taskA");
taskB = padv.Task("taskB");
runsAfter(taskB,taskA);
addTask(pm,taskA);
2-36
padv.Task Class
addTask(pm,taskB);
end
This code uses padv.Task to create two task objects: taskA and taskB.
The object function runsAfter specifies that taskB should run after taskA.
The function addTask adds the task objects to the padv.ProcessModel object.
Version History
Introduced in R2022a
2-37
2 Process Modeling System API
addInputQueries
Package: padv
Syntax
addInputQueries(taskObj,inputQueries)
Description
addInputQueries(taskObj,inputQueries) adds the input artifacts returned by inputQueries
as inputs to the task represented by taskObj.
If the task already has input queries specified, addInputQueries adds inputQueries to the list of
input queries in the InputQueries property.
Examples
Create a new padv.Task object myTaskObj that represents a task named runForEachModel.
myTaskObj = padv.Task("runForEachModel");
addInputQueries(myTaskObj,padv.builtin.query.FindModels);
When you run the task defined by myTaskObj, the query padv.builtin.query.FindModels finds
each model in the project and provides the models as the input artifacts for the task.
Input Arguments
taskObj — Task object that represents task
padv.Task object
2-38
addInputQueries
A query or queries that get the input artifacts for a task, specified as a padv.Query object or an
array of padv.Query objects. Each artifact that the query or queries return becomes an input to the
task.
For example, if you specify the InputQueries property for a task as the query
padv.builtin.query.FindModels, the query returns each model and the models become input
artifacts for the task.
Note You can only specify the following queries for the inputQueries argument:
• padv.builtin.query.FindArtifacts
• padv.builtin.query.FindFileWithAddress
• padv.builtin.query.FindModels
• padv.builtin.query.FindProjectFile
• padv.builtin.query.FindRequirements
• padv.builtin.query.FindRequirementsForModel
• padv.builtin.query.FindTestCasesForModel
• padv.builtin.query.FindTopModels
• padv.builtin.query.GetDependentArtifacts
• padv.builtin.query.GetIterationArtifact
• padv.builtin.query.GetOutputsOfDependentTask
• padv.builtin.query.FindFilesWithLabel
• padv.builtin.query.FindModelsWithLabel
• padv.builtin.query.FindModelsWithTestCases
• padv.builtin.query.FindRefModels
Example: addInputQueries(myTaskObj,padv.builtin.query.FindModels)
Example: addInputQueries(myTaskObj,
[padv.builtin.query.GetIterationArtifact,padv.builtin.query.GetDependentArtif
acts])
2-39
2 Process Modeling System API
Version History
Introduced in R2022a
2-40
padv.Task.close_model
padv.Task.close_model
Class: padv.Task
Package: padv
Close model
Syntax
padv.Task.close_model(modelNames)
Description
padv.Task.close_model(modelNames) closes the models specified by modelNames. If the
property EnableModelCaching in padv.Preferences is true, then the build system also removes
the models from the model cache at the end of the build.
The built-in tasks load and close models using the methods padv.Task.load_model and
padv.Task.close_model. If you have custom tasks, you can improve the efficiency of model
loading in your builds by using the methods padv.Task.load_model and
padv.Task.close_model inside your custom tasks. These methods allow the build system to cache
a model, instead of reloading the same model multiple times within a build.
If you do not want the build system to cache models, specify the property EnableModelCaching as
false in the padv.Preferences object.
Input Arguments
modelNames — Names of models
string array | character vector | cell array of character vectors
Name of model or models, specified as a string array, character vector, or cell array of character
vectors.
Example: padv.Task.close_model("vdp")
Example: padv.Task.close_model(["modelA","modelB"])
Data Types: char | string | cell
Version History
Introduced in R2022a
2-41
2 Process Modeling System API
dependsOn
Package: padv
Syntax
dependsOn(taskObj,dependencies)
dependsOn( ___ ,Name=Value)
Description
dependsOn(taskObj,dependencies) creates a dependency between taskObj and
dependencies. taskObj runs only after the tasks specified by dependencies run and return a task
status.
dependsOn( ___ ,Name=Value) specifies how the build system handles dependencies using one or
more Name=Value arguments.
Examples
Use the dependsOn function to create a dependency between two tasks in a process model.
Open the processmodel.m file. The file is at the root of the project.
Replace the contents of the processmodel.m file with the following code:
function processmodel(pm)
arguments
pm padv.ProcessModel
end
TaskA = padv.Task("TaskA");
TaskB = padv.Task("TaskB");
dependsOn(TaskB,TaskA);
addTask(pm,TaskA);
addTask(pm,TaskB);
end
This code uses padv.Task to create two task objects: TaskA and TaskB.
2-42
dependsOn
The function addTask adds the task objects to the padv.ProcessModel object.
Open the Process Advisor app. In the MATLAB Command Window, enter:
processAdvisorWindow
In the Tasks column, point to the run button for TaskB. The Process Advisor app automatically
highlights both tasks since TaskA is a dependent task. If you click the run button for TaskB, TaskA
will run before TaskB.
Input Arguments
taskObj — Task object that represents task
padv.Task object
Example: dependsOn(TaskB,"TaskA")
Example: dependsOn(TaskB,TaskA)
Data Types: char | string
2-43
2 Process Modeling System API
Setting that controls which dependent task iterations run, specified as a numeric or logical 1 (true)
or 0 (false):
• true — When the build system runs the dependencies of a task, 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:
Example: dependsOn(TaskB,TaskA,IterationArtifactMatching=false)
Data Types: logical
2-44
dependsOn
• "Pass" — Only run the task if the dependencies pass. For example, if TaskB depends on TaskA,
TaskA needs to pass before TaskB runs. If TaskA fails or errors, TaskB does not run.
• ["Pass","Fail"] — Only run the task if the dependencies either pass or fail. For example, if
TaskB depends on TaskA, TaskA needs to either pass or fail before TaskB runs. If TaskA errors,
TaskB does not run.
• ["Pass","Fail","Error"] — The task runs, even if the dependencies fail or error. For
example, if TaskB depends on TaskA, TaskA can pass, fail, or error and TaskB still runs.
Example: dependsOn(TaskB,TaskA,WhenStatus=["Pass","Fail"])
Data Types: string
Version History
Introduced in R2022a
2-45
2 Process Modeling System API
padv.Task.load_model
Class: padv.Task
Package: padv
Load model
Syntax
padv.Task.load_model(modelNames)
Description
padv.Task.load_model(modelNames) loads the models specified by modelNames into memory. If
the property EnableModelCaching in padv.Preferences is true, then the build system also adds
the models to the model cache for the current build.
The built-in tasks load models using the methods padv.Task.load_model and
padv.Task.close_model. If you have custom tasks, you can improve the efficiency of model
loading in your builds by using the methods padv.Task.load_model and
padv.Task.close_model inside your custom tasks. These methods allow the build system to cache
a model, instead of reloading the same model multiple times within a build.
If you do not want the build system to cache models, specify the property EnableModelCaching as
false in the padv.Preferences object.
Input Arguments
modelNames — Names of models
string array | character vector | cell array of character vectors
Name of model or models, specified as a string array, character vector, or cell array of character
vectors.
Example: padv.Task.load_model("vdp")
Example: padv.Task.load_model(["modelA","modelB"])
Data Types: char | string | cell
Version History
Introduced in R2022a
2-46
run
run
Package: padv
Run task
Syntax
taskResult = run(taskObj)
taskResult = run(taskObj,inputArtifacts)
Description
taskResult = run(taskObj) runs the task represented by taskObj and returns the result from
the task.
How a task runs depends on how the you define the task. You can define tasks using a function or a
class:
• Function-based tasks — Runs the function specified by the Action property of the task.
• Class-based task — Runs the run function implemented inside the class definition.
By default, when you create a padv.Task object, the task is a function-based task, even if you do not
specify an Action property for the task.
Examples
Run Task
Create a new padv.Task object myTaskObj that represents a task named myTask.
myTaskObj = padv.Task("myTask");
Use the run object function to run the task. Save the results to the variable taskResults.
taskResults = run(myTaskObj)
taskResults =
Status: Pass
OutputArtifacts: [0×0 padv.Artifact]
Details: [1×1 struct]
ResultValues: [1×1 struct]
2-47
2 Process Modeling System API
In this example, there is no Action associated with the task and the task returns a
padv.TaskResult with a Status of Pass.
Input Arguments
taskObj — Task object that represents task
padv.Task object
Artifacts that are inputs to the task, specified as a cell array of padv.Artifact objects.
If you specified the InputQueries property for a task, the InputQueries automatically passes a
cell array of padv.Artifact objects to inputArtifacts when you run the task.
Output Arguments
taskResult — Result from task
TaskResult object
Version History
Introduced in R2022a
2-48
runsAfter
runsAfter
Package: padv
Syntax
runsAfter(taskObj,predecessors)
runsAfter( ___ ,Name=Value)
Description
runsAfter(taskObj,predecessors) specifies a preferred execution order for tasks. If possible,
the build system runs the predecessor tasks, specified by predecessors, before the task
represented by taskObj.
runsAfter( ___ ,Name=Value) specifies how the build system handles the preferred execution
order using one or more Name=Value arguments.
Examples
Use the runsAfter function to specify that one task should run after another task.
Open the processmodel.m file. The file is at the root of the project.
Replace the contents of the processmodel.m file with the following code:
function processmodel(pm)
arguments
pm padv.ProcessModel
end
FirstTask = padv.Task("FirstTask");
SecondTask = padv.Task("SecondTask");
runsAfter(SecondTask,FirstTask);
addTask(pm,FirstTask);
addTask(pm,SecondTask);
end
This code uses padv.Task to create two task objects: FirstTask and SecondTask.
The object function runsAfter specifies that SecondTask should run after FirstTask.
2-49
2 Process Modeling System API
The function addTask adds the task objects to the padv.ProcessModel object.
Open the Process Advisor app. In the MATLAB Command Window, enter:
processAdvisorWindow
In the toolstrip, click the Run All button. You can see that SecondTask runs after FirstTask.
Input Arguments
taskObj — Task object that represents task
padv.Task object
Example: runsAfter(SecondTask,"FirstTask")
Example: runsAfter(SecondTask,FirstTask)
Setting that controls which predecessor task iterations run, specified as a numeric or logical 1 (true)
or 0 (false):
• true — When the build system runs the predecessors of a task, the build system runs only the
task iterations that the tasks have in common.
• false — When the build system runs the predecessor 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 should run after all project artifacts
are generated by the first task.
For example, suppose you have two tasks: FirstTask and SecondTask:
2-50
runsAfter
Example: runsAfter(SecondTask,FirstTask,IterationArtifactMatching=false)
Data Types: logical
Setting that controls whether the build system ignores circular relationships between tasks, specified
as a numeric or logical 0 (false) or 1 (true). By default, if you specify a circular relationship
between tasks, the build system ignores the relationship. For example, if you specify both
runsAfter(SecondTask,FirstTask) and runsAfter(FirstTask,SecondTask), the build
system ignores the runsAfter relationship.
If you specify StrictOrdering as true, the build system generates an error when you try to run
tasks that have a circular relationship.
Example: runsAfter(SecondTask,FirstTask,StrictOrdering=true)
Data Types: string
Version History
Introduced in R2022a
2-51
2 Process Modeling System API
padv.TaskResult
Create and access results from task
Description
A padv.TaskResult object represents the results from a task. The run function of a padv.Task
creates a padv.TaskResult object that you can use to access the results from the task. When you
create a custom task, you can specify the results from your custom task. You can also use the function
getProcessTaskResults to view a list of the last task results for a project. The Process Advisor
app uses task results to determine the task statuses, output artifacts, and detailed task results that
appear in the Tasks, Out, and Details columns of the app.
Creation
Syntax
resultObj = padv.TaskResult()
Description
resultObj = padv.TaskResult() creates a result object resultObj that represents the results
from a task.
Properties
Status — Task result status
Pass (default) | Fail | Error
• Pass — A passing task status. The task completed successfully without any issues.
• Fail — A failing task status. The task completed, but the results were not successful.
• Error — An error task status. The task generated an error and did not complete.
The Status property determines the task status shown in the Tasks column in the Process Advisor
app.
For custom tasks, you can specify the task result status as either:
2-52
padv.TaskResult
The OutputArtifacts property determines the output artifacts shown in the Out column in the
Process Advisor app.
The build system only manages output artifacts specified by the task result. For custom tasks, use the
OutputPaths argument to define the output artifacts for the task result.
Temporary storage for task-specific data, returned as a struct. The build system uses Details to
store task-specific data that other build steps can use.
Note that Details are temporary. The build system does not save Details with the task results
after the build finishes.
Data Types: struct
Number of passing, warning, and failing conditions, returned as a struct with fields:
The ResultValues property determines the detailed results shown in the Details column in the
Process Advisor app.
ans =
Pass: 1
Warn: 2
Fail: 3
2-53
2 Process Modeling System API
The build system adds each path specified by OutputArtifacts to the OutputArtifacts
argument as a padv.Artifact object with type padv_output_file.
Example: taskResultObj.OutputPaths = string(fullfile(pwd,filename))
Example: taskResultObj.OutputPaths = [string(fullfile(pwd,filename1)),
string(fullfile(pwd,filename2))]
Data Types: char | string
Object Functions
• applyStatus
Examples
Create a padv.TaskResult object for a custom task that has a failing task status, outputs a
single .json file, and 1 passing condition, 2 warning conditions, and 3 failing conditions.
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 this example process model code:
function processmodel(pm)
% Defines the project's processmodel
arguments
pm padv.ProcessModel
end
addTask(pm,"ExampleTask",Action=@ExampleAction);
end
2-54
padv.TaskResult
taskResult.OutputPaths = string(outputFile);
end
Go back to the Process Advisor app and click Refresh Tasks to update the list of tasks shown in the
app.
In the top-left corner of the Process Advisor pane, switch the filter from Model to Project.
In the top-right corner of the Process Advisor pane, click Run All.
• The Tasks column shows a failing task status to the left of ExampleTask. This code from the
example process model specifies the task status shown in the Tasks column:
taskResult.Status = padv.TaskStatus.Fail;
• The Out column shows an output artifact associated with the task. This code from the example
process model specifies the output artifact shown in the Out column:
taskResult.OutputPaths = string(fullfile(pwd,outputFile));
• The Details column shows 1 passing condition, 2 warning conditions, and 3 failing conditions.
This code from the example process model specifies the detailed task results shown in the Details
column:
taskResult.ResultValues.Pass = 1;
taskResult.ResultValues.Warn = 2;
taskResult.ResultValues.Fail = 3;
Version History
Introduced in R2022a
2-55
2 Process Modeling System API
applyStatus
Package: padv
Syntax
applyStatus(resultObj,taskStatus)
Description
applyStatus(resultObj,taskStatus) applies a new task status taskStatus to the task result
object resultObj if the priority level of taskStatus is higher than the current Status property of
the task result object.
• padv.TaskStatus.Pass
• padv.TaskStatus.Fail
• padv.TaskStatus.Error
Note The function applyStatus can only change the Status to a higher priority status. For
example, if you apply a failing status and then apply a passing status, the status remains a failing
status because the priority of padv.TaskStatus.Fail is higher than the priority of
padv.TaskStatus.Pass.
taskResult =
Status: Fail
OutputArtifacts: [0×0 padv.Artifact]
Details: [1×1 struct]
ResultValues: [1×1 struct]
To set the Status property of a task result object to a specific value, manually set the property to
either padv.TaskStatus.Pass, padv.TaskStatus.Fail, or padv.TaskStatus.Error. For
example, to set the Status of a task result object taskResult to Pass, use taskResult.Status
= padv.TaskStatus.Pass.
Examples
2-56
applyStatus
Use applyStatus to update the Status property of a task result object. If the status is a higher
priority status, applyStatus updates the Status property of the task result object.
Create a task result object. By default, the Status property of the task result object is specified as
Pass.
taskResult = padv.TaskResult();
Suppose the task needs to generate an error. Use applyStatus to apply an error task status,
specified by padv.TaskStatus.Error.
applyStatus(taskResult,padv.TaskStatus.Error);
Apply a passing task status to the task result object. A passing task status is specified by
padv.TaskStatus.Pass.
applyStatus(taskResult,padv.TaskStatus.Pass);
padv.TaskStatus.Pass does not have a higher priority than an error task status, so applyStatus
does not change the Status of the task result object.
taskResult
Suppose you want to reset the status of the task result object to a passing task status. Manually
specify the Status property as padv.TaskStatus.Pass.
taskResult.Status = padv.TaskStatus.Pass
taskResult =
Status: Pass
OutputArtifacts: [0×0 padv.Artifact]
Details: [1×1 struct]
ResultValues: [1×1 struct]
Input Arguments
resultObj — Task result object
padv.TaskResult object
2-57
2 Process Modeling System API
Version History
Introduced in R2022a
2-58
3
The support package provides a build system that you can use to orchestrate and automate the steps
in your model-based design (MBD) pipeline. The build system is software that can orchestrate tasks,
efficiently execute tasks in the pipeline, and perform other actions related to the pipeline. You can
call the build system either through the Process Advisor app or by using the runprocess function.
When you call the build system, the build system loads the process model, analyzes the project, and
orchestrates the create of a pipeline of tasks.
For examples of how to use the build system, see the "Control Builds" and "Integrate into CI"
chapters in the user's guide.
Classes
Class Description
padv.BuildResult Result from build system build
padv.Preferences Set runprocess function settings
Functions
Run Tasks
Function Description
runprocess Run task iterations defined by the process model
Function Description
createProcessTaskID Generate an ID for a specific task iteration
defined by the process model
generateProcessTasks Generate a list of the IDs for the task iterations
defined by the process model
getProcessTaskResults Get available results and result details for task
iterations defined by the process model
3 Build System API
runprocess
Generate and run model-based design (MBD) pipeline using build system
Syntax
[buildResult,exitCode] = runprocess()
[buildResult,exitCode] = runprocess(Name=Value)
Description
[buildResult,exitCode] = runprocess() generate a model-based design (MBD) pipeline and
run the pipeline using the build system. The process model (processmodel.p or processmodel.m)
in the project defines the tasks for the pipeline.
Examples
Open a project and use runprocess to generate and run the MBD pipeline using the build system.
Open the Process Advisor example project, which contains an example process model. The process
model defines the tasks for the pipeline.
processAdvisorExampleStart
Generate and run the MBD pipeline and store the results in the variable results.
results = runprocess()
Open a project and use runprocess. To only run a specific set of tasks, provide the task names to
the Tasks argument.
Open the Process Advisor example project, which contains an example process model. The process
model defines the tasks for the pipeline.
processAdvisorExampleStart
3-2
runprocess
runprocess(...
Tasks = ["padv.builtin.task.GenerateSimulinkWebView",...
"padv.builtin.task.RunModelStandards"])
Open a project and use runprocess. To only run the tasks associated with a specific artifact, provide
a full path, relative path, or a padv.Artifact object to the FilterArtifact argument.
Open the Process Advisor example project, which contains an example process model. The process
model defines the tasks for the pipeline.
processAdvisorExampleStart
Run tasks for the AHRS_Voter model by specifying the relative path to the model.
% run only the AHRS_Voter tasks
runprocess(...
FilterArtifact = fullfile(...
"02_Models","AHRS_Voter","specification","AHRS_Voter.slx"))
Run Specific Task Iteration, Clean Task Results, and Delete Task Outputs
Open a project and run one specific task iteration in the pipeline.
Open the Process Advisor example project, which contains an example process model.
processAdvisorExampleStart
Force runprocess to run one of the task iterations by specifying Force as true and Tasks as one
of the tasks in tasks.
runprocess(Force=true,Tasks=tasks(1))
When Force is true, runprocess runs the pipeline, even if the pipeline already had results that
were marked as up to date.
When you clean task results and delete task outputs, it is as if the tasks were not run.
Input Arguments
Name-Value Pair Arguments
3-3
3 Build System API
Names of tasks that you want to run, specified as a character vector, cell array of character vectors,
string, or string array. The task name is defined by the Name property of the task.
Alternatively, you can specify the task iteration IDs for individual task iterations that you want to run.
See "generateProcessTasks" and "createProcessTaskID" in this PDF for information.
Note You can only run tasks that are defined in the process model.
Example: "padv.builtin.task.GenerateSimulinkWebView"
Example: ["padv.builtin.task.GenerateSimulinkWebView",...
"padv.builtin.task.RunModelStandards"]
Data Types: char | string
Name of process that you want to run, specified by a character vector or string.
Example: "CIPipeline"
Data Types: char | string
Names of subprocesses that you want to run, specified as a character vector, cell array of character
vectors, string, or string array. The subprocess name is defined by the Name property of the
subprocess.
Example: "SubprocessA"
Example: ["SubprocessA",SubprocessB"]
Data Types: char | string
Artifact or artifacts that you want to run tasks for, specified as either the full path to an artifact,
relative path to an artifact, a padv.Artifact object that represents an artifact, or an array of
padv.Artifact objects.
Example: fullfile("C:\","User","projectA","myModel.slx")
Example: fullfile("02_Models","AHRS_Voter","specification","AHRS_Voter.slx")
Example:
padv.Artifact("sl_model_file",fullfile("02_Models","AHRS_Voter","specificatio
n","AHRS_Voter.slx"))
Data Types: string
3-4
runprocess
Skip or run up-to-date tasks, specified as a numeric or logical 0 (false) or 1 (true). By default,
runprocess does not run task iterations that have up to date results.
Example: true
Data Types: logical
By default, runprocess includes task dependencies when running a task. Specify Isolation as
true if you want to run a task in isolation, without running any task dependencies.
Note that you define task dependencies in the process model by using the function dependsOn.
Example: true
Data Types: logical
Clear task results and delete task outputs, specified as a numeric or logical 0 (false) or 1 (true).
• The runprocess functions ignores other name-value arguments, cleans the task results, and
deletes task outputs.
• The OutputDirectory of the task might still contain files. The runprocess function only
deletes the task outputs, specified by the OutputPaths property of the padv.TaskResult object
for the task.
• You cannot specify MarkStale as true. The arguments are mutually exclusive.
Example: true
Data Types: logical
Note To delete task outputs with DeleteOutputs, you must specify Clean as true.
Example: true
Data Types: logical
3-5
3 Build System API
Mark task as outdated, specified as a numeric or logical 0 (false) or 1 (true). When you mark a
task as stale, the results appear outdated in the Process Advisor app.
Note If you specify MarkStale as true, then you cannot specify Clean as true. The arguments are
mutually exclusive.
Example: true
Data Types: logical
Exit MATLAB when running in batch mode, specified as a numeric or logical 1 (true) or 0 (false).
By default, if you are running MATLAB in batch mode and runprocess finishes running,
runprocess exits MATLAB.
Example: false
Data Types: logical
Automatically generate report after runprocess runs tasks, specified as a numeric or logical 1
(true) or 0 (false).
Example: runprocess(GenerateReport = true)
Data Types: logical
File format for the generated report, specified as one of these values:
Note that for the runprocess function to generate a report, you must also specify the argument
GenerateReport as true.
Example: runprocess(GenerateReport = true,ReportFormat = "html-file")
3-6
runprocess
Note that for the runprocess function to generate a report, you must also specify the argument
GenerateReport as true.
Example: runprocess(GenerateReport = true,ReportPath =
fullfile(pwd,"folderName","reportName"))
Data Types: string
Automatically refresh before running tasks, specified as a numeric or logical 1 (true) or 0 (false).
By default, runprocess refreshes before running tasks so that the run uses the current state of the
process model and project. If you specify RefreshProcessModel as false, runprocess does not
refresh before running, but the run might not include the latest changes to tasks in the process model
or artifacts in the project.
Example: false
Data Types: logical
Automatically reanalyze project analysis issues that have a severity level of error, specified as a
numeric or logical 1 (true) or 0 (false).
If you are using R2022b Update 1 or later, you can specify ReanalyzeProjectAnalysisIssues as
false to prevent the build system from reanalyzing project analysis issues that have a severity level
of error. This might reduce the execution time for runprocess, but the build system might not
generate the expected task iterations or detect outdated results.
Fix the issues listed in the Project Analysis Issues pane of the Process Advisor app to make sure the
build system can fully analyze the project, generate the expected task iterations, and detect outdated
results.
3-7
3 Build System API
Example: false
Data Types: logical
Generate JUnit-style XML report for each task in process, specified as a numeric or logical 0 (false)
or 1 (true).
Example: true
Data Types: logical
Output Arguments
buildResult — Results of run
padv.BuildResult
Exit code from run, returned as a double representing the process error code.
Alternative Functionality
App
You can also use the Process Advisor app to run each task or individual task iterations in the process.
To open the Process Advisor app for a project, in the MATLAB Command Window, enter:
processAdvisorWindow
Version History
Introduced in R2022a
3-8
createProcessTaskID
createProcessTaskID
Generate ID for specific task iteration defined by process model
Syntax
ID = createProcessTaskID(task,artifact)
Description
ID = createProcessTaskID(task,artifact) generates the identifier, ID, for an individual task
iteration defined by the process model. A task iteration is the pairing of a task, task, to a specific
project artifact, artifact.
Examples
Suppose you have a process model with several tasks, but right now you only want to run the task
padv.builtin.task.RunModelStandards on the model AHRS_Voter.slx. Use the function
createProcessTaskID to generate the ID for a specific task iteration, then use the function
runprocess to run only that specific task iteration.
Open the Process Advisor example project, which contains an example process model.
processAdvisorExampleStart
Specify a task that exists in the process model. For this example, specify the built-in task for running
Model Advisor checks, padv.builtin.task.RunModelStandards.
task = padv.builtin.task.RunModelStandards;
Use padv.Artifact to specify the project artifact that you want the task to run on. For this
example, the artifact type is sl_model_file because the artifact is a Simulink model and the
address is the path to AHRS_Voter.slx, relative to the project root.
artifactType = "sl_model_file";
address = fullfile("02_Models","AHRS_Voter","specification","AHRS_Voter.slx");
artifact = padv.Artifact(artifactType,address);
Use the task instance and artifact to generate the ID for the specific task iteration.
runModelStandards_for_AHRS_Voter = createProcessTaskID(task,artifact)
runModelStandards_for_AHRS_Voter =
"padv.builtin.task.RunModelStandards|sl_model_file|02_Models/AHRS_Voter/specification/AHRS_Voter.
runprocess(Tasks = runModelStandards_for_AHRS_Voter)
3-9
3 Build System API
When you specify the Tasks value as the ID for a single task iteration, the function runprocess runs
only the specified task iteration. For this example, runprocess runs only the task iteration
associated with the task padv.builtin.task.RunModelStandards and the artifact
AHRS_Voter.slx.
Note Alternatively, instead of creating and then running the task iterations, you can directly specify
the Task and FilterArtifact arguments of the runprocess function to run the task on a specific
artifact:
runprocess(...
Tasks = "padv.builtin.task.RunModelStandards",...
FilterArtifact = fullfile("02_Models","AHRS_Voter","specification","AHRS_Voter.slx"))
But note that you can only run the tasks if the tasks are defined in the process model and the artifacts
exist in the project.
Input Arguments
task — Task name or subclass of padv.Task
string | character vector | padv.Task object
Either:
• Name of task, specified as a string or character vector. The name of a task is stored in the Name
property of the task. For example, "name_of_my_custom_task".
• Subclass of padv.Task, specified as a padv.Task object. Built-in tasks are subclasses of
padv.Task. For example, you can specify the padv.Task object
padv.builtin.task.RunModelStandards for the task argument.
Example: "name_of_my_custom_task"
Example: "padv.builtin.task.RunModelStandards"
Example: padv.builtin.task.RunModelStandards
Data Types: char | string
Output Arguments
ID — Identifier for task iteration defined by process model
string
Identifier for task iteration defined by the process model, returned as a string.
3-10
createProcessTaskID
Example IDs:
• "myCustomProjectTask|project|ProcessAdvisorExample.prj"
• "padv.builtin.task.RunModelStandards|sl_model_file|02_Models/AHRS_Voter/
specification/AHRS_Voter.slx"
• "padv.builtin.task.RunTestsPerTestCase|sl_test_case|ced877ff-
cfb8-4fa8-9bbf-aaa29b1d926b"
Alternative Functionality
App
You can also use the Process Advisor app to run individual task iterations in the process. To open the
Process Advisor app for a project, in the MATLAB Command Window, enter:
processAdvisorWindow
Version History
Introduced in R2022a
3-11
3 Build System API
generateProcessTasks
Get list of IDs for task iterations in MBD pipeline
Syntax
IDs = generateProcessTasks()
IDs = generateProcessTasks(Name=Value)
Description
IDs = generateProcessTasks() returns identifiers, IDs, for each of the task iterations in the
model-based design (MBD) pipeline.
Examples
Suppose you have a process model that adds several tasks to the process. Use the function
generateProcessTasks to list the IDs for each task iteration in the MBD pipeline.
Open the Process Advisor example project, which contains an example process model.
processAdvisorExampleStart
List the IDs for each task iteration in the MBD pipeline.
IDs = generateProcessTasks()
Suppose you have a process model that adds several tasks to the process, but right now you only
want to run the tasks associated with one specific artifact. You can use the function
generateProcessTasks, but filter the list of IDs to only include task iterations associated with a
specific model in the project, AHRS_Voter.slx.
Open the Process Advisor example project, which contains an example process model.
processAdvisorExampleStart
Use padv.Artifact to specify the project artifact that you want the task to run on. For this
example, the artifact type is sl_model_file because the artifact is a Simulink model and the
address is the path to AHRS_Voter.slx, relative to the project root.
3-12
generateProcessTasks
artifactType = "sl_model_file";
address = fullfile("02_Models","AHRS_Voter","specification","AHRS_Voter.slx");
artifact = padv.Artifact(artifactType,address);
Get a list of the IDs for the task iterations in the MBD pipeline, but filter the list to include only task
iterations associated with the artifact AHRS_Voter.slx.
IDs_AHRS_Voter = generateProcessTasks(FilterArtifact=artifact);
Use the function runprocess to run only the task iterations associated with the artifact
AHRS_Voter.slx.
runprocess(Tasks=IDs_AHRS_Voter)
When you specify the Tasks value as a list of IDs for task iterations, the function runprocess runs
only the specified task iterations. For this example, runprocess runs only the task iterations
associated with the artifact AHRS_Voter.slx.
Note Alternatively, instead of generating and then running the task iterations, you can directly
specify the FilterArtifact argument of the runprocess function to run the tasks associated with
the artifact:
runprocess(FilterArtifact = fullfile("02_Models","AHRS_Voter","specification","AHRS_Voter.slx"))
But note that you can only run the tasks if the tasks are defined in the process model and the artifacts
exist in the project.
Input Arguments
Name-Value Pair Arguments
Artifact or artifacts that you want to generate IDs for, specified as either the full path to an artifact,
relative path to an artifact, a padv.Artifact object that represents an artifact, or an array of
padv.Artifact objects.
Example: fullfile("C:\","User","projectA","myModel.slx")
Example: fullfile("02_Models","AHRS_Voter","specification","AHRS_Voter.slx")
Example:
padv.Artifact("sl_model_file",fullfile("02_Models","AHRS_Voter","specificatio
n","AHRS_Voter.slx"))
Data Types: string
3-13
3 Build System API
Name of process that you want to generate IDs for, specified by a character vector or string.
Example: "CIPipeline"
Data Types: char | string
Names of subprocesses that you want to generate IDs for, specified as a character vector, cell array of
character vectors, string, or string array. The subprocess name is defined by the Name property of the
subprocess.
Example: "SubprocessA"
Example: ["SubprocessA",SubprocessB"]
Data Types: char | string
Names of tasks that you want to generate IDs for, specified as a character vector, cell array of
character vectors, string, or string array. The task name is defined by the Name property of the task.
Example: "padv.builtin.task.GenerateSimulinkWebView"
Example: ["padv.builtin.task.GenerateSimulinkWebView",...
"padv.builtin.task.RunModelStandards"]
Data Types: char | string
Output Arguments
IDs — Identifiers for task iterations defined by process model
string
Example IDs:
• "myCustomProjectTask|project|ProcessAdvisorExample.prj"
• "padv.builtin.task.RunModelStandards|sl_model_file|02_Models/AHRS_Voter/
specification/AHRS_Voter.slx"
• "padv.builtin.task.RunTestsPerTestCase|sl_test_case|ced877ff-
cfb8-4fa8-9bbf-aaa29b1d926b"
3-14
generateProcessTasks
Alternative Functionality
App
You can also use the Process Advisor app to run individual task iterations in the process or to view
task iterations for a specific model.
• To open the Process Advisor app for a project, in the MATLAB Command Window, enter:
processAdvisorWindow
• To open the Process Advisor app for a specific model, provide the name of the model, modelName,
to the function processadvisor:
processadvisor(modelName)
Version History
Introduced in R2022a
3-15
3 Build System API
getProcessTaskResults
Get available task results and result details for task iterations in MBD pipeline
Syntax
[IDsWithTaskResults,taskResults,taskResultsOutdated] =
getProcessTaskResults()
[IDsWithTaskResults,taskResults,taskResultsOutdated] = getProcessTaskResults(
Name=Value)
Description
[IDsWithTaskResults,taskResults,taskResultsOutdated] =
getProcessTaskResults() returns available task results and result details for the task iterations
in the MBD pipeline. The function returns the identifiers for task iterations that have task results,
IDsWithTaskResults, the current task results, taskResults, and a logical value that indicates if
the task results are outdated, taskResultsOutdated.
If you do not have task results, use the function runprocess to run tasks and generate results. The
function getProcessTaskResults only returns information related to task iterations that are
defined in the process model. If you have task results from a task iteration that is not in the process
model, the function does not return information related to those task results.
[IDsWithTaskResults,taskResults,taskResultsOutdated] = getProcessTaskResults(
Name=Value) specifies options using one or more name-value arguments.
Examples
Get the available task results for a task iteration and use the result details to find information about
the output artifacts of the task iteration.
Open the Process Advisor example project, which contains an example process model.
processAdvisorExampleStart
List the IDs for each task iteration in the MBD pipeline.
IDs = generateProcessTasks();
runprocess(Tasks=IDs(1))
3-16
getProcessTaskResults
[IDsWithResults,results,outdated] = getProcessTaskResults()
IDsWithResults =
"padv.builtin.task.GenerateSimulinkWebView|sl_model_file|02_Models/AHRS_Voter/specification/A
results =
Status: Pass
OutputArtifacts: [1×1 padv.Artifact]
Details: [1×1 struct]
ResultValues: [1×1 struct]
outdated =
logical
Get the output artifacts from the result. For this example, the result is a Simulink Web View for the
model AHRS_Voter.slx.
webView = results.OutputArtifacts
webView =
Type: "padv_output_file"
Parent: [0×0 padv.Artifact]
Address: "04_Results/AHRS_Voter/webview/AHRS_Voter_webview/AHRS_Voter_webview.html"
UUID: "6b37eb48-d694-4daf-a5dd-024a4bf2348c"
Label: [0×0 string]
StorageAddress: [0×0 string]
Open the Process Advisor example project, which contains an example process model.
processAdvisorExampleStart
Check modeling standards for the model AHRS_Voter.slx by using the built-in task
padv.builtin.task.RunModelStandards. The task uses Model Advisor to run checks on the
model.
runprocess(...
Tasks = "padv.builtin.task.RunModelStandards",...
FilterArtifact = fullfile("02_Models","AHRS_Voter","specification","AHRS_Voter.slx"));
3-17
3 Build System API
[IDsWithResults,results,outdated] = getProcessTaskResults(...
Tasks = "padv.builtin.task.RunModelStandards",...
FilterArtifact = fullfile("02_Models","AHRS_Voter","specification","AHRS_Voter.slx"))
IDsWithResults =
"padv.builtin.task.RunModelStandards|sl_model_file|ProcessAdvisorExample|02_Models/AHRS_Voter
results =
Status: Pass
OutputArtifacts: [1×1 padv.Artifact]
Details: [1×1 struct]
ResultValues: [1×1 struct]
outdated =
logical
Input Arguments
Name-Value Pair Arguments
Names of tasks that you want to run, specified as a character vector, cell array of character vectors,
string, or string array. The task name is defined by the Name property of the task.
Alternatively, you can specify the task iteration IDs for individual task iterations that you want to run.
See "generateProcessTasks" and "createProcessTaskID" in this PDF for information.
Note You can only run tasks that are defined in the process model.
Example: "padv.builtin.task.GenerateSimulinkWebView"
Example: ["padv.builtin.task.GenerateSimulinkWebView",...
"padv.builtin.task.RunModelStandards"]
Data Types: char | string
3-18
getProcessTaskResults
Name of process that you want to run, specified by a character vector or string.
Example: "CIPipeline"
Data Types: char | string
Names of subprocesses that you want to run, specified as a character vector, cell array of character
vectors, string, or string array. The subprocess name is defined by the Name property of the
subprocess.
Example: "SubprocessA"
Example: ["SubprocessA",SubprocessB"]
Data Types: char | string
Artifact or artifacts that you want to run tasks for, specified as either the full path to an artifact,
relative path to an artifact, a padv.Artifact object that represents an artifact, or an array of
padv.Artifact objects.
Example: fullfile("C:\","User","projectA","myModel.slx")
Example: fullfile("02_Models","AHRS_Voter","specification","AHRS_Voter.slx")
Example:
padv.Artifact("sl_model_file",fullfile("02_Models","AHRS_Voter","specificatio
n","AHRS_Voter.slx"))
Data Types: string
Output Arguments
IDsWithTaskResults — Identifiers for task iterations that have task results and are
defined in process model
string | string array
Identifiers for task iterations that have task results and are defined in the process model, returned as
a string or string array.
• If you do not have task results for task iterations in your process model, IDsWithTaskResults
returns an empty array, []. You can use the function runprocess to run tasks and generate
results.
• If you have task results for task iterations that are not in your process model,
IDsWithTaskResults returns an empty array, [].
• If you have task results for task iterations that are in your process model, IDsWithTaskResults
returns the IDs for the task iterations that have task results.
Example IDs:
3-19
3 Build System API
• "myCustomProjectTask|project|ProcessAdvisorExample.prj"
• "padv.builtin.task.RunModelStandards|sl_model_file|02_Models/AHRS_Voter/
specification/AHRS_Voter.slx"
• "padv.builtin.task.RunTestsPerTestCase|sl_test_case|ced877ff-
cfb8-4fa8-9bbf-aaa29b1d926b"
• If you do not have task results for task iterations in your process model, taskResults returns an
empty array, [].
• If you have task results for task iterations that are not in your process model, taskResults
returns an empty array, [].
• If you have task results for task iterations that are in your process model, taskResults returns a
padv.TaskResult or padv.TaskResult array.
padv.TaskResult objects contain properties for the result status, output artifacts, details, and
result values for the number of passing, warning, and failing results for task iterations.
Status of task results, returned as a logical value or logical array. Values of 1 indicate that the results
for the task iteration are outdated and might not reflect the current state of the project or task.
Values of 0 indicate that the results for the task iteration are up-to-date. The result is an empty array,
[], when there are not task results.
Version History
Introduced in R2022a
3-20
padv.BuildResult
padv.BuildResult
Result from build system build
Description
Use the build result, padv.BuildResult, to find the properties of the build system build, including a
list of the tasks that the build system ran and the settings the build system used.
Creation
Syntax
Description
Properties
StartTime — Start time of build
datetime
Example: Pass
3-21
3 Build System API
• Pass
• Warn
• Fail
For example, if the build runs one task iteration and the task iteration returns one passing result and
five warning results, the structure array contains:
struct with fields:
Pass: 1
Warn: 5
Fail: 0
PassTasks — IDs for task iterations that passed during the build
cell array
IDs for task iterations that passed during the build, returned as a cell array.
If the build system runs one task iteration and the task iteration passes, PassTasks returns a one-
dimensional cell array. For example, if the build system only ran the task
padv.builtin.task.GenerateCode on the model AHRS_Voter.slx and the task iteration
passed, PassTasks returns:
{'padv.builtin.task.GenerateCode|sl_model_file|02_Models/AHRS_Voter/specification/AHRS_Voter.slx'
If multiple task iterations pass, PassTasks returns one cell for each task iteration that passed. For
example:
{'padv.builtin.task.GenerateCode|sl_model_file|02_Models/AHRS_Voter/specification/AHRS_Voter.slx'
{'padv.builtin.task.GenerateCode|sl_model_file|02_Models/Actuator_Control/specification/Actuator_
{'padv.builtin.task.GenerateCode|sl_model_file|02_Models/Flight_Control/specification/Flight_Cont
{'padv.builtin.task.GenerateCode|sl_model_file|02_Models/InnerLoop_Control/specification/InnerLoo
{'padv.builtin.task.GenerateCode|sl_model_file|02_Models/OuterLoop_Control/specification/OuterLoo
ErrorTasks — IDs for task iterations that returned an error during the build
cell array
IDs for task iterations that returned an error during the build, returned as a cell array.
If the build system runs one task iteration and the task iteration returns an error, ErrorTasks
returns a one-dimensional cell array. For example, if the build system tried to run a custom task,
customTask, on the model AHRS_Voter.slx, but the task iteration returned an error, ErrorTasks
returns:
{'customTask|sl_model_file|02_Models/AHRS_Voter/specification/AHRS_Voter.slx'}
If multiple task iterations error, ErrorTasks returns one cell for each task iteration that returned an
error. For example:
{'customTask|sl_model_file|02_Models/AHRS_Voter/specification/AHRS_Voter.slx' }
{'customTask|sl_model_file|02_Models/Actuator_Control/specification/Actuator_Control.slx' }
3-22
padv.BuildResult
{'customTask|sl_model_file|02_Models/Flight_Control/specification/Flight_Control.slx' }
{'customTask|sl_model_file|02_Models/InnerLoop_Control/specification/InnerLoop_Control.slx'}
{'customTask|sl_model_file|02_Models/OuterLoop_Control/specification/OuterLoop_Control.slx'}
SkippedTasks — IDs for task iterations that the build system skipped
cell array
IDs for task iterations that the build system skipped, returned as a cell array. The build system skips
task iterations that already have up-to-date results, unless you specify Force as true when you call
the function runprocess.
If the build system skips one task iteration, SkippedTasks returns a one-dimensional cell array. For
example, if you instructed the build system to run the task padv.builtin.task.GenerateCode on
the model AHRS_Voter.slx, but the task iteration already had up-to-date results, SkippedTasks
returns:
{'padv.builtin.task.GenerateCode|sl_model_file|02_Models/AHRS_Voter/specification/AHRS_Voter.slx'
If the build system skips multiple task iterations, SkippedTasks returns one cell for each task
iteration that the build system skipped. For example:
{'padv.builtin.task.GenerateCode|sl_model_file|02_Models/AHRS_Voter/specification/AHRS_Voter.slx'
{'padv.builtin.task.GenerateCode|sl_model_file|02_Models/Actuator_Control/specification/Actuator_
{'padv.builtin.task.GenerateCode|sl_model_file|02_Models/Flight_Control/specification/Flight_Cont
{'padv.builtin.task.GenerateCode|sl_model_file|02_Models/InnerLoop_Control/specification/InnerLoo
{'padv.builtin.task.GenerateCode|sl_model_file|02_Models/OuterLoop_Control/specification/OuterLoo
FailedTasks — IDs for task iterations that failed during the build
cell array
IDs for task iterations that failed during the build, returned as a cell array.
If the build system runs only one task iteration and the task iteration fails, FailedTasks returns a
one-dimensional cell array. For example, if the build system ran the task
padv.builtin.task.GenerateCode on the model AHRS_Voter.slx and the task iteration failed,
FailedTasks returns:
{'padv.builtin.task.GenerateCode|sl_model_file|02_Models/AHRS_Voter/specification/AHRS_Voter.slx'
If multiple task iterations fail, FailedTasks returns one cell for each task iteration that failed. For
example:
{'padv.builtin.task.GenerateCode|sl_model_file|02_Models/AHRS_Voter/specification/AHRS_Voter.slx'
{'padv.builtin.task.GenerateCode|sl_model_file|02_Models/Actuator_Control/specification/Actuator_
{'padv.builtin.task.GenerateCode|sl_model_file|02_Models/Flight_Control/specification/Flight_Cont
{'padv.builtin.task.GenerateCode|sl_model_file|02_Models/InnerLoop_Control/specification/InnerLoo
{'padv.builtin.task.GenerateCode|sl_model_file|02_Models/OuterLoop_Control/specification/OuterLoo
InputArgs — Input arguments that defined how the build system ran the build
[1×1 struct] (default) | structure array
3-23
3 Build System API
Input arguments that defined how the build system ran the build, returned as a structure array with
fields:
• TasksToBuild — List of task iteration IDs that you want the build system to run
• Isolation — Setting to include or ignore task dependencies
• Force — Setting to skip or run up-to-date task iterations
• RerunFailedTasks — Setting to ignore or rerun failed task iterations
• RerunErroredTasks — Setting to ignore or rerun task iterations that returned an error
Examples
Open a project, run a build, and use the build result, padv.BuildResult, to get a list of the passed
task iterations and the settings that the build system used when running the build.
Open the Process Advisor example project, which contains an example process model.
processAdvisorExampleStart
tasks = generateProcessTasks;
Run the first five task iterations in tasks and specify Force as true.
buildResult = runprocess(Force=true,Tasks=tasks(1:5))
Use the build result, buildResult, to get a list of the task iterations that passed.
passed = buildResult.PassTasks'
passed =
{'padv.builtin.task.GenerateSimulinkWebView|sl_model_file|02_Models/AHRS_Voter/specification/
{'padv.builtin.task.GenerateSimulinkWebView|sl_model_file|02_Models/Actuator_Control/specific
{'padv.builtin.task.GenerateSimulinkWebView|sl_model_file|02_Models/Flight_Control/specificat
{'padv.builtin.task.GenerateSimulinkWebView|sl_model_file|02_Models/InnerLoop_Control/specifi
{'padv.builtin.task.GenerateSimulinkWebView|sl_model_file|02_Models/OuterLoop_Control/specifi
3-24
padv.BuildResult
When you used the function runprocess, you specified Force as true. You can see that information
in the InputArgs property of the build result, buildResult.
runprocessInputs = buildResult.InputArgs
runprocessInputs =
TasksToBuild: ["padv.builtin.task.GenerateSimulinkWebView|sl_model_file|02_Models/AHRS_V
Isolation: 0
Force: 1
RerunFailedTasks: 0
RerunErroredTasks: 0
The build result shows that the Force setting was 1 (true) when the build system ran.
Version History
Introduced in R2022a
3-25
3 Build System API
padv.Preferences
Specify settings for Process Advisor and runprocess builds
Description
Use the preferences, padv.Preferences, to specify settings for the Process Advisor app and
settings for how the runprocess function runs builds.
Creation
Syntax
Description
P = padv.Preferences() gets the handle to the global preferences object, P. There is only one set
of preference properties.
Note Certain properties, called run-time settings, only apply to the current MATLAB session. If you
want those preferences to persist between MATLAB sessions, specify the preference values in a
project startup script.
Properties
Project Settings
These settings are stored in the project and are shared with everyone using this project.
Automatically detect changes and mark task results as outdated, specified as a numeric or logical 1
(true) or 0 (false).
When IncrementalBuild is true and you make a change to an artifact in your project, the build
system marks any related task results as outdated.
Example: true
Data Types: logical
Allow the build system to cache models during a build, specified as a numeric or logical 1 (true) or 0
(false).
3-26
padv.Preferences
Example:
Data Types: logical
Run-Time Settings
These settings only apply to the current MATLAB session. If you restart MATLAB or call clear
classes, the preference properties reset to the default values.
To create preferences that the Process Advisor app and build system will use each time they run on
your project, create a project startup script that specifies the properties for padv.Preferences.
Setting that controls whether the build system generates an error message when multiple tasks
attempt to write to the same output file, specified as a numeric or logical 1 (true) or 0 (false).
By default, the build system generates an error if multiple tasks attempt to write to the same output
file.
Example: false
Data Types: logical
Setting for automatically cleaning task results for tasks and artifacts that do not match current
process model or project, specified as a numeric or logical 1 (true) or 0 (false).
By default, when you use the build system, the build system cleans task results that are no longer
relevant for the current process model or project. For example, if you had task results from a specific
task and then you remove that task from the process model, the build system automatically deletes
the task results associated with the task. If you had task results associated with a specific project
artifact and then you removed that artifact from the project, the build system automatically deletes
the task results associated with the artifact. Note that the build system does not delete generated
artifacts like generated code.
If you specify GarbageCollectTaskOutputs as false, the build system does not automatically
clean task results associated with tasks and artifacts that are not in the current process model or
project.
Example: false
Data Types: logical
By default, Process Advisor and the build system do not display certain messages from the digital
thread. You can add or remove messages in the list, or reset the list of filtered messages, by using the
3-27
3 Build System API
padv.Preferences object functions. For information, see the Object Functions for
padv.Preferences.
Data Types: string
Setting to show more information in error messages, specified as a numeric or logical 0 (false) or 1
(true).
By default, error messages from the build system are not verbose.
If you specify ShowDetailedErrorMessages as true, the build system shows full stack traces in
error messages. You might want to see full stack traces when you are debugging a process model.
Example: true
Data Types: logical
Setting for tracking changes to process model, specified as a numeric or logical 1 (true) or 0
(false).
By default, if you make a change to the process model file, the build system marks each task status
and task result as outdated because the tasks in the updated process model might not match the
tasks that generated the task results from the previous version of the process model. For example, if
you ran the built-in task padv.builtin.task.RunModelStandards with the default Model Advisor
configuration, updated the process model to specify a different Model Advisor configuration file for
the task, and then ran the task again, the task results are now outdated because they are the task
results from the default configuration.
If you specify TrackProcessModel as false and make a change to the process model, the build
system will not mark the task statuses and task results as outdated.
Example: false
Data Types: logical
Object Functions
• addFilteredDigitalThreadMessages(obj, IssueId) adds the message, specified by the
issue ID IssueId, to the list of filtered messages in the property
FilteredDigitalThreadMessages.
To get a list of issue messages and issue IDs, use the function getArtifactIssues:
metric_engine = metric.Engine();
issues = getArtifactIssues(metric_engine)
issuesMessages = issues.IssueMessage
issueIDs = issues.IssueId
Suppose that you want to filter out the issue message associated with the issue ID
"alm:artifact_service:CannotResolveElement". You can use the function
3-28
padv.Preferences
p = padv.Preferences;
addFilteredDigitalThreadMessages(p,...
"alm:artifact_service:CannotResolveElement")
• removeFilteredDigitalThreadMessages(obj, IssueId) removes the message, specified
by messageID, to the list of filtered messages in the property
FilteredDigitalThreadMessages.
For example:
p = padv.Preferences;
removeFilteredDigitalThreadMessages(p,...
"alm:simulink_handlers:ModelCallbacksDeactivated")
• resetFilteredDigitalThreadMessages(obj) resets the list of filtered messages in the
property FilteredDigitalThreadMessages.
For example:
p = padv.Preferences;
resetFilteredDigitalThreadMessages(p)
Examples
Use padv.Preferences to specify preferences for the Process Advisor app and build system.
PREF = padv.Preferences
Specify IncrementalBuild as 0.
PREF.IncrementalBuild = 0;
Now, when you run tasks, incremental builds are disabled and the build system forces tasks to run,
even if the tasks have up to date results.
Version History
Introduced in R2022a
3-29
4
The support package provides example pipeline configuration files that you can add to your project to
automatically execute your pipeline on a continuous integration (CI) platform, like GitHub® Actions,
GitLab®, and Jenkins®. The example pipeline configuration files use the pipeline generator API to
automatically generate and execute pipelines for your specific project and process so that you do not
need to manually update any pipeline files when you make changes to your project.
For examples of how to integrate into a specific CI platform, see the "Integrate into CI" chapter in the
user's guide.
Classes
CI Platform Options
Class Description
padv.pipeline.GitHubOptions Settings that control how a generated GitHub
pipeline runs
padv.pipeline.GitLabOptions Settings that control how a generated GitLab
pipeline runs
padv.pipeline.JenkinsOptions Settings that control how a generated Jenkins
pipeline runs
Functions
Function Description
padv.pipeline.generatePipeline Generate pipeline configuration file for CI
platform
4 Pipeline Generator API
padv.pipeline.generatePipeline
Package: padv.pipeline
Syntax
generatorResults = padv.pipeline.generatePipeline(platformOptions)
Description
generatorResults = padv.pipeline.generatePipeline(platformOptions) generates a
pipeline file for the CI platform and options specified by platformOptions. The function
padv.pipeline.generatePipeline is a pipeline generator that can automatically generate a
pipeline file. The generated pipeline file can configure a pipeline that runs your process in CI.
Examples
padv.pipeline.generatePipeline(padv.pipeline.GitLabOptions)
For information on how to use the pipeline generator to integrate into GitLab, see "Integrate into
GitLab".
padv.pipeline.generatePipeline(padv.pipeline.JenkinsOptions)
For information on how to use the pipeline generator to integrate into Jenkins, see "Integrate into
Jenkins".
Input Arguments
platformOptions — Options for generating CI pipeline
padv.pipeline.GitLabOptions object | padv.pipeline.JenkinsOptions object
4-2
padv.pipeline.generatePipeline
• A padv.pipeline.GitLabOptions object to generate a YML file that you can use to run the
generated pipeline in a GitLab CI system.
• A padv.pipeline.JenkinsOptions object to generate a Jenkinsfile that you can use to run the
generated pipeline in Jenkins CI system.
Example: padv.pipeline.generatePipeline(padv.pipeline.GitLabOptions)
Example: padv.pipeline.generatePipeline(padv.pipeline.JenkinsOptions)
Output Arguments
generatorResults — Results from pipeline generator
padv.pipeline.GeneratorResults object
Version History
Introduced in R2022a
4-3
4 Pipeline Generator API
padv.pipeline.GitHubOptions
Options for generating GitHub pipeline configuration file
Description
Use the padv.pipeline.GitHubOptions object to represent the desired options for generating a
GitHub pipeline configuration file. To generate a GitHub pipeline configuration file, use
padv.pipeline.GitHubOptions as an input argument to the
padv.pipeline.generatePipeline function.
Note For information on how to use the pipeline generator to integrate into a GitHub CI system, see
"Integrate into GitHub".
Note If you run MATLAB using the -nodisplay option or you use a machine that does not have a
display (like many CI runners and Docker® containers), you should set up a virtual display server
before you include the following built-in tasks in your process model:
For information, see "Set Up Virtual Display for No-Display Machine" in the User's Guide.
Creation
Description
Properties
RunnerLabels — GitHub runner labels
"self-hosted" (default) | string
The labels determine which GitHub runner can execute the job. For more information, see https://
docs.github.com/en/actions/using-jobs/choosing-the-runner-for-a-job#targeting-runners-in-a-group.
Example: padv.pipeline.GitHubOptions(RunnerLabels = "Linux")
4-4
padv.pipeline.GitHubOptions
How many days GitHub stores workflow artifacts, specified as a string. This property corresponds to
the job keyword "retention-days" in GitHub. After the specified number of retention days, the
artifacts expire and GitHub deletes the artifacts.
Example: padv.pipeline.GitHubOptions(RetentionDays = "90")
Data Types: string
By default, the generated pipeline generates into the subfolder derived > pipeline, relative to the
project root. To change where the pipeline file generates, specify GeneratedPipelineDirectory.
Example: padv.pipeline.GitHubOptions(GeneratedYMLFileName =
"padv_generated_pipeline_file")
Data Types: string
Make sure the path that you specify uses the correct MATLAB root folder location and file separators
for the operating system of your GitHub runner.
Example: "C:\Program Files\MATLAB\R2023a\bin"
Example: "/usr/local/MATLAB/R2023a/bin"
Example: "/Applications/MATLAB_R2023a.app/bin"
Data Types: string
4-5
4 Pipeline Generator API
If the pipeline collects artifacts, the child pipeline contains a job, Collect_Artifacts, that
compresses the build artifacts into a ZIP file and attaches the file to the job.
Example: padv.pipeline.GitHubOptions(EnableArtifactCollection=false)
Data Types: logical | string
Shell environment GitHub uses to launch MATLAB, specified as one of these values:
For example, a pipeline with one stage that runs each of the tasks in the process:
1 Runprocess
4-6
padv.pipeline.GitHubOptions
4-7
4 Pipeline Generator API
Example: padv.pipeline.GitHubOptions(PipelineArchitecture =
padv.pipeline.Architecture.SerialStages)
Pipeline runs both up to date and outdated tasks, specified as a numeric or logical 1 (true) or 0
(false).
The property defines the Force argument for the runprocess function in the generated pipeline
file.
4-8
padv.pipeline.GitHubOptions
ExitInBatchMode — Exits MATLAB if MATLAB was run with -batch startup option
1 (true) (default) | 0 (false)
Exits MATLAB if MATLAB was run with the -batch startup option, specified as a numeric or logical 0
(false) or 1 (true).
This property defines the ExitInBatchMode argument for the runprocess function in the
generated pipeline file.
Example: padv.pipeline.GitHubOptions(ExitInBatchMode=false)
Data Types: logical
Treats all tasks which previously failed as being outdated, specified as a numeric or logical 1 (true)
or 0 (false).
This property defines the RerunFailedTasks argument for the runprocess function in the
generated pipeline file.
Example: padv.pipeline.GitHubOptions(RerunFailedTasks=true)
Data Types: logical
Treats all tasks which previously generated errors as outdated, specified as a numeric or logical 1
(true) or 0 (false).
This property defines the RerunErroredTasks argument for the runprocess function in the
generated pipeline file.
Example: padv.pipeline.GitHubOptions(RerunErroredTasks=true)
Data Types: logical
Use this property to specify how the pipeline starts the MATLAB program. This property defines how
the script in the generated pipeline file launches MATLAB.
Example: padv.pipeline.GitHubOptions(MatlabLaunchCmd = "matlab")
Data Types: string
Use this property to specify the command-line startup options that the pipeline uses when starting
the MATLAB program. This property defines the command-line startup options that appear next to
4-9
4 Pipeline Generator API
the -batch option and MatlabLaunchCmd value in the"script" section of the generated pipeline
file. The pipeline starts MATLAB with the specified startup options.
By default, the support package launches MATLAB using the -batch option. If you need to run
MATLAB without the -batch option, specify the property AddBatchStartupOption as false.
Note If you run MATLAB using the -nodisplay option or you use a machine that does not have a
display (like many CI runners and Docker containers), you should set up a virtual display server
before you include the following built-in tasks in your process model:
For information, see "Set Up Virtual Display for No-Display Machine" in the User's Guide.
Specify whether to open MATLAB using -batch startup option, specified as a numeric or logical 0
(false) or 1 (true).
By default, the support package launches MATLAB in CI using the -batch startup option.
If you need to launch MATLAB with options that are not compatible with -batch, specify
AddBatchStartupOption as false.
Example: padv.pipeline.GitHubOptions(AddBatchStartupOption = false)
Data Types: logical
This property defines the directory where the generated pipeline file generates.
By default, the generated pipeline file is named "simulink_pipeline.yml". To change the name of
the generated pipeline file, specify GeneratedYMLFileName.
Example: padv.pipeline.GitHubOptions(GeneratedPipelineDirectory =
fullfile("derived","pipeline","test"))
Data Types: string
Generate Process Advisor build report, specified as a numeric or logical 1 (true) or 0 (false).
4-10
padv.pipeline.GitHubOptions
File format for the generated report, specified as one of these values:
By default, the report generates in the current working folder with the name
"ProcessAdvisorReport".
Example: padv.pipeline.GitHubOptions(ReportPath = "myReport")
Data Types: string
Stop running pipeline after stage fails, specified as a numeric or logical 0 (false) or 1 (true).
By default, the pipeline continues to run, even if a stage in the pipeline fails.
Example: padv.pipeline.GitHubOptions(StopOnStageFailure = true)
Data Types: logical
4-11
4 Pipeline Generator API
padv.pipeline.GitLabOptions
Options for generating GitLab pipeline configuration file
Description
Use the padv.pipeline.GitLabOptions object to represent the desired options for generating a
GitLab pipeline configuration file. To generate a GitLab pipeline configuration file, use
padv.pipeline.GitLabOptions as an input argument to the
padv.pipeline.generatePipeline function.
Note For information on how to use the pipeline generator to integrate into a GitLab CI system, see
"Integrate into GitLab".
Note If you run MATLAB using the -nodisplay option or you use a machine that does not have a
display (like many CI runners and Docker containers), you should set up a virtual display server
before you include the following built-in tasks in your process model:
For information, see "Set Up Virtual Display for No-Display Machine" in the User's Guide.
Creation
Syntax
options = padv.pipeline.GitLabOptions
options = padv.pipeline.GitLabOptions(Name=Value)
Description
Properties
Tags — GitLab CI/CD tags
string | string array
4-12
padv.pipeline.GitLabOptions
GitLab CI/CD tags, specified as a string or string array. Use this property to specify the tags that
appear next to the tags keyword in a generated GitLab pipeline configuration file.
The GitLab CI/CD tags select a GitLab Runner for a job. The property Tags specifies which CI/CD
tags appear next to the tags keyword in a generated pipeline configuration file.
If the pipeline collects artifacts, the child pipeline contains a job, Collect_Artifacts, that
compresses the build artifacts into a ZIP file and attaches the file to the job.
This property creates an "artifacts" section in the generated pipeline file. For more information,
see the GitLab documentation: https://docs.gitlab.com/ee/ci/yaml/#artifacts.
Example: padv.pipeline.GitLabOptions(EnableArtifactCollection="on_failure")
Data Types: logical | string
This property specifies the file name that appears next to the "name" keyword in the generated
pipeline file. For more information, see the GitLab documentation for "artifacts:name": https://
docs.gitlab.com/ee/ci/yaml/#artifactsname.
Example: padv.pipeline.GitLabOptions(ArtifactZipFileName =
"my_job_artifacts.zip")
Data Types: string
ArtifactsExpireIn — How long GitLab stores job artifacts before the artifacts expire
"30 days" (default) |
How long GitLab stores job artifacts before the artifacts expire, specified as a string.
Use this property to specify how long GitLab stores job artifacts before the artifacts expire and
GitLab deletes the artifacts. This property specifies the expiry time that appears next to the
"expire_in" keyword in the generated pipeline file. For a list of valid possible inputs, see the
GitLab documentation for "artifacts:expire_in": https://docs.gitlab.com/ee/ci/yaml/
#artifactsexpire_in.
4-13
4 Pipeline Generator API
Warning This property will be removed in a future release. Use the property
EnableArtifactCollection instead.
• "on_success"
• "on_failure"
• "always"
Use this property to specify when GitLab uploads job artifacts. This property specifies the input that
appears next to the "when" keyword in the generated pipeline file. For more information, see the
GitLab documentation for "artifacts:when": https://docs.gitlab.com/ee/ci/yaml/#artifactswhen.
Example: padv.pipeline.GitLabOptions(ArtifactsWhen = "on_success")
By default, the generated pipeline generates into the subfolder derived > pipeline, relative to the
project root. To change where the pipeline file generates, specify GeneratedPipelineDirectory.
Example: padv.pipeline.GitLabOptions(GeneratedYMLFileName =
"padv_generated_pipeline_file")
Data Types: string
For example, a pipeline with one stage that runs each of the tasks in the process:
1 Runprocess
4-14
padv.pipeline.GitLabOptions
4-15
4 Pipeline Generator API
4-16
padv.pipeline.GitLabOptions
For more information on pipeline architectures, see the "Customize Pipeline Architecture" section in
"Integrate into GitLab".
Example: padv.pipeline.GitLabOptions(PipelineArchitecture =
padv.pipeline.Architecture.SerialStages)
Pipeline runs both up to date and outdated tasks, specified as a numeric or logical 1 (true) or 0
(false).
The property defines the Force argument for the runprocess function in the generated pipeline
file.
4-17
4 Pipeline Generator API
ExitInBatchMode — Exits MATLAB if MATLAB was run with the -batch startup option
1 (true) (default) | 0 (false)
Exits MATLAB if MATLAB was run with the -batch startup option, specified as a numeric or logical 0
(false) or 1 (true).
This property defines the ExitInBatchMode argument for the runprocess function in the
generated pipeline file.
Example: padv.pipeline.GitLabOptions(ExitInBatchMode=false)
Data Types: logical
Treats all tasks which previously failed as being outdated, specified as a numeric or logical 1 (true)
or 0 (false).
This property defines the RerunFailedTasks argument for the runprocess function in the
generated pipeline file.
Example: padv.pipeline.GitLabOptions(RerunFailedTasks=true)
Data Types: logical
Treats all tasks which previously generated errors as outdated, specified as a numeric or logical 1
(true) or 0 (false).
This property defines the RerunErroredTasks argument for the runprocess function in the
generated pipeline file.
Example: padv.pipeline.GitLabOptions(RerunErroredTasks=true)
Data Types: logical
Use this property to specify how the pipeline starts the MATLAB program. This property defines how
the script in the generated pipeline file launches MATLAB.
Example: padv.pipeline.GitLabOptions(MatlabLaunchCmd = "matlab")
Data Types: string
Use this property to specify the command-line startup options that the pipeline uses when starting
the MATLAB program. This property defines the command-line startup options that appear next to
4-18
padv.pipeline.GitLabOptions
the -batch option and MatlabLaunchCmd value in the"script" section of the generated pipeline
file. The pipeline starts MATLAB with the specified startup options.
By default, the support package launches MATLAB using the -batch option. If you need to run
MATLAB without the -batch option, specify the property AddBatchStartupOption as false.
Note If you run MATLAB using the -nodisplay option, you should set up a virtual display server
before you include the following built-in tasks in your process model:
For information, see "Set Up Virtual Display for No-Display Machine" in the User's Guide.
Specify whether to open MATLAB using -batch startup option, specified as a numeric or logical 0
(false) or 1 (true).
By default, the support package launches MATLAB in CI using the -batch startup option.
If you need to launch MATLAB with options that are not compatible with -batch, specify
AddBatchStartupOption as false.
Example: padv.pipeline.GitLabOptions(AddBatchStartupOption = false)
Data Types: logical
This property defines the directory where the generated pipeline file generates.
By default, the generated pipeline file is named "simulink_pipeline.yml". To change the name of
the generated pipeline file, specify GeneratedYMLFileName.
Example: padv.pipeline.GitLabOptions(GeneratedPipelineDirectory =
fullfile("derived","pipeline","test"))
Data Types: string
Generate JUnit-style XML reports for each task in the process, specified as a numeric or logical 1
(true) or 0 (false).
4-19
4 Pipeline Generator API
JUnit reports allow you see which tests failed in CI without having to examine the job logs.
If you generate JUnit reports, GitLab shows any test failures directly in the merge request and
pipeline detail view. For more information on how GitLab displays JUnit results, see the GitLab
documentation: https://docs.gitlab.com/ee/ci/testing/unit_test_reports.html#view-unit-test-reports-on-
gitlab.
Example: padv.pipeline.GitLabOptions(GenerateJUnitForProcess = false)
Data Types: logical
Generate Process Advisor build report, specified as a numeric or logical 1 (true) or 0 (false).
Example: padv.pipeline.GitLabOptions(GenerateReport = false)
Data Types: logical
File format for the generated report, specified as one of these values:
By default, the report generates in the current working folder with the name
"ProcessAdvisorReport".
Example: padv.pipeline.GitLabOptions(ReportPath = "myReport")
Data Types: string
Stop running pipeline after stage fails, specified as a numeric or logical 0 (false) or 1 (true).
By default, the pipeline continues to run, even if a stage in the pipeline fails.
Example: padv.pipeline.GitLabOptions(StopOnStageFailure = true)
Data Types: logical
4-20
padv.pipeline.GitLabOptions
Examples
Create a padv.pipeline.GitLabOptions object and change the options. When you generate a
pipeline configuration file, the file uses the specified options.
This example shows how to use the pipeline generator API. For information on how to use the
pipeline generator to integrate into a GitLab CI system, see "Integrate into GitLab".
Load a project. For this example, you can load a Process Advisor example project. In the MATLAB
Command Window, enter:
processAdvisorExampleStart
GitLabOptions = padv.pipeline.GitLabOptions(...
Tags = "high_memory",...
ExitInBatchMode = 0,...
PipelineArchitecture = padv.pipeline.Architecture.SingleStage);
padv.pipeline.generatePipeline(GitLabOptions);
By default, the generated pipeline file is named simulink_pipeline.yml and is saved in the
derived > pipeline folder, relative to the project root. To change the name of the generated pipeline
file, specify the argument GeneratedYMLFileName for padv.pipeline.GitLabOptions. To
change where the pipeline file generates, specify the argument GeneratedPipelineDirectory.
For information on how to use the pipeline generator to integrate into a GitLab CI system, see
"Integrate into GitLab" in the User's Guide.
4-21
4 Pipeline Generator API
padv.pipeline.JenkinsOptions
Options for generating Jenkins pipeline configuration file
Description
Use the padv.pipeline.JenkinsOptions object to represent the desired options for generating a
Jenkins pipeline configuration file. To generate a Jenkins pipeline configuration file, use
padv.pipeline.JenkinsOptions as an input argument to the
padv.pipeline.generatePipeline function.
Note For information on how to use the pipeline generator to integrate into a Jenkins CI system, see
"Integrate into Jenkins".
Note If you run MATLAB using the -nodisplay option or you use a machine that does not have a
display (like many CI runners and Docker containers), you should set up a virtual display server
before you include the following built-in tasks in your process model:
For information, see "Set Up Virtual Display for No-Display Machine" in the User's Guide.
Creation
Syntax
options = padv.pipeline.JenkinsOptions
options = padv.pipeline.JenkinsOptions(Name=Value)
Description
Properties
AgentLabel — Which Jenkins agent executes pipeline tasks in Jenkins environment
"any" (default) | string | string array
4-22
padv.pipeline.JenkinsOptions
Which Jenkins agent executes pipeline tasks in the Jenkins environment, specified as a string or
string array.
Use this property to specify the Jenkins agent that executes all stages in the pipeline. Jenkins agents
are typically either a machine or a container. For more information, see the "Glossary" in the Jenkins
documentation: https://www.jenkins.io/doc/book/glossary/#agent.
Example: options = padv.pipeline.JenkinsOptions(AgentLabel="high_memory")
Data Types: string
If you choose to collect artifacts, the child pipeline contains a job, Collect_Artifacts, that collects
the build artifacts and attaches the artifacts to the Collect_Artifacts job.
This property uses the Jenkins Core Plugin to add an "archiveArtifacts" step in the generated
Jenkinsfile that defines the Jenkins pipeline. Install the Jenkins Core Plugin before you specify
EnableArtifactCollection. For more information, see the Jenkins documentation for
"archiveArtifacts": https://www.jenkins.io/doc/pipeline/steps/core/#archiveartifacts-archive-the-
artifacts.
Example: padv.pipeline.JenkinsOptions(EnableArtifactCollection="on_failure")
Data Types: logical | string
This property specifies the file name that appears next to the "artifacts" for the
"archiveArtifacts" step in the generated Jenkinsfile that defines the Jenkins pipeline.
For more information, see the Jenkins documentation for "archiveArtifacts": https://
www.jenkins.io/doc/pipeline/steps/core/#archiveartifacts-archive-the-artifacts.
Example: padv.pipeline.JenkinsOptions(ArtifactZipFileName =
"my_job_artifacts.zip")
Data Types: string
Warning This property will be removed in a future release. Use the property
EnableArtifactCollection instead.
4-23
4 Pipeline Generator API
Setting to only archive artifacts for successful builds, specified as a numeric or logical 0 (false) or 1
(true).
Use this property to specify whether Jenkins only saves build artifacts for successful builds. This
property corresponds to the argument "onlyIfSuccessful" for the "artifacts" in the
"archiveArtifacts" step in the Jenkinsfile that defines the pipeline.
For more information, see the Jenkins documentation for "archiveArtifacts": https://
www.jenkins.io/doc/pipeline/steps/core/#archiveartifacts-archive-the-artifacts.
Example: padv.pipeline.JenkinsOptions(SaveArtifactsOnSuccess = false)
Data Types: logical
By default, the generated pipeline generates into the subfolder derived > pipeline, relative to the
project root. To change where the pipeline file generates, specify GeneratedPipelineDirectory.
Example: padv.pipeline.JenkinsOptions(GeneratedJenkinsFileName =
"padv_generated_pipeline_file")
Data Types: string
Specify whether Jenkins uses MATLAB Plugin to launch MATLAB, specified as a numeric or logical 0
(false) or 1 (true).
If the property UseMatlabPlugin is true, Jenkins uses the "runMATLABCommand" step to launch
MATLAB and the pipeline generator ignores the properties MatlabLaunchCmd and
MatlabStartupOptions. For more information, see the Jenkins documentation for
"runMATLABCommand": https://www.jenkins.io/doc/pipeline/steps/matlab/#runmatlabcommand-run-
matlab-commands-scripts-or-functions
Using the MATLAB Plugin for Jenkins is recommended. For more information, see https://
plugins.jenkins.io/matlab/.
Example: padv.pipeline.JenkinsOptions(UseMatlabPlugin = false)
Data Types: logical
Shell environment Jenkins uses to launch MATLAB, specified as one of these values:
4-24
padv.pipeline.JenkinsOptions
If the property UseMatlabPlugin is true, Jenkins uses the "runMATLABCommand" step to launch
MATLAB and the pipeline generator ignores the properties MatlabLaunchCmd and
MatlabStartupOptions. For more information, see the Jenkins documentation for
"runMATLABCommand": https://www.jenkins.io/doc/pipeline/steps/matlab/#runmatlabcommand-run-
matlab-commands-scripts-or-functions
For example, a pipeline with one stage that runs each of the tasks in the process:
1 Runprocess
4-25
4 Pipeline Generator API
4-26
padv.pipeline.JenkinsOptions
For more information on pipeline architectures, see the "Customize Pipeline Architecture" section in
"Integrate into Jenkins".
Example: padv.pipeline.JenkinsOptions(PipelineArchitecture =
padv.pipeline.Architecture.SerialStages)
Pipeline runs both up to date and outdated tasks, specified as a numeric or logical 1 (true) or 0
(false).
The property defines the Force argument for the runprocess function in the generated pipeline
file.
4-27
4 Pipeline Generator API
ExitInBatchMode — Exits MATLAB if MATLAB was run with the -batch startup option
1 (true) (default) | 0 (false)
Exits MATLAB if MATLAB was run with the -batch startup option, specified as a numeric or logical 0
(false) or 1 (true).
This property defines the ExitInBatchMode argument for the runprocess function in the
generated pipeline file.
Example: padv.pipeline.JenkinsOptions(ExitInBatchMode=false)
Data Types: logical
Treats all tasks which previously failed as being outdated, specified as a numeric or logical 1 (true)
or 0 (false).
This property defines the RerunFailedTasks argument for the runprocess function in the
generated pipeline file.
Example: padv.pipeline.JenkinsOptions(RerunFailedTasks=true)
Data Types: logical
Treats all tasks which previously generated errors as outdated, specified as a numeric or logical 1
(true) or 0 (false).
This property defines the RerunErroredTasks argument for the runprocess function in the
generated pipeline file.
Example: padv.pipeline.JenkinsOptions(RerunErroredTasks=true)
Data Types: logical
Use this property to specify how the pipeline starts the MATLAB program. This property defines how
the generated pipeline file launches MATLAB.
Example: padv.pipeline.JenkinsOptions(MatlabLaunchCmd = "matlab")
Data Types: string
Use this property to specify the command-line startup options that the pipeline uses when starting
the MATLAB program. This property defines the command-line startup options that appear next to
4-28
padv.pipeline.JenkinsOptions
the -batch option and MatlabLaunchCmd value in the"script" section of the generated pipeline
file. The pipeline starts MATLAB with the specified startup options.
By default, the support package launches MATLAB using the -batch option. If you need to run
MATLAB without the -batch option, specify the property AddBatchStartupOption as false.
Note If you run MATLAB using the -nodisplay option, you should set up a virtual display server
before you include the following built-in tasks in your process model:
For information, see "Set Up Virtual Display for No-Display Machine" in the User's Guide.
Specify whether to open MATLAB using -batch startup option, specified as a numeric or logical 0
(false) or 1 (true).
By default, the support package launches MATLAB in CI using the -batch startup option.
If you need to launch MATLAB with options that are not compatible with -batch, specify
AddBatchStartupOption as false.
Example: padv.pipeline.JenkinsOptions(AddBatchStartupOption = false)
Data Types: logical
This property defines the directory where the generated pipeline file generates.
By default, the generated pipeline file is named "simulink_pipeline". To change the name of the
generated pipeline file, specify GeneratedJenkinsFileName.
Example: padv.pipeline.JenkinsOptions(GeneratedPipelineDirectory =
fullfile("derived","pipeline","test"))
Data Types: string
Generate JUnit-style XML reports for each task in the process, specified as a numeric or logical 1
(true) or 0 (false).
4-29
4 Pipeline Generator API
JUnit reports allow you see which tests failed in CI without having to examine the job logs.
If you generate JUnit reports, Jenkins can show test failures and trends directly in the user interface.
For more information on how Jenkins displays JUnit results, see the Jenkins documentation: https://
plugins.jenkins.io/junit/.
Note You must have the JUnit plugin installed on your Jenkins controller to see JUnit results. For
information, see https://plugins.jenkins.io/junit/.
Generate Process Advisor build report, specified as a numeric or logical 1 (true) or 0 (false).
Example: padv.pipeline.JenkinsOptions(GenerateReport = false)
Data Types: logical
File format for the generated report, specified as one of these values:
By default, the report generates in the current working folder with the name
"ProcessAdvisorReport".
Example: padv.pipeline.JenkinsOptions(ReportFormat = "myReport")
Data Types: string
Stop running pipeline after stage fails, specified as a numeric or logical 0 (false) or 1 (true).
By default, the pipeline continues to run, even if a stage in the pipeline fails.
Example: padv.pipeline.JenkinsOptions(StopOnStageFailure = true)
4-30
padv.pipeline.JenkinsOptions
Examples
Create a padv.pipeline.JenkinsOptions object and change the options. When you generate a
pipeline configuration file, the file uses the specified options.
This example shows how to use the pipeline generator API. For information on how to use the
pipeline generator to integrate into a Jenkins CI system, see "Integrate into Jenkins".
Load a project. For this example, you can load a Process Advisor example project. In the MATLAB
Command Window, enter:
processAdvisorExampleStart
JenkinsOptions = padv.pipeline.JenkinsOptions(...
AgentLabel = "high_memory",...
ExitInBatchMode = 0,...
PipelineArchitecture = padv.pipeline.Architecture.SingleStage);
padv.pipeline.generatePipeline(JenkinsOptions);
By default, the generated pipeline file is named simulink_pipeline and is saved in the derived >
pipeline folder, relative to the project root. To change the name of the generated pipeline file, specify
the argument GeneratedJenkinsFileName for padv.pipeline.JenkinsOptions. To change
where the pipeline file generates, specify the argument GeneratedPipelineDirectory.
For information on how to use the pipeline generator to integrate into a Jenkins CI system, see
"Integrate into Jenkins" in the User's Guide.
4-31
5
After you run your tasks, you can use the report generator to create a report with the most recent
task results. The report summarizes the task statuses, task results, and other information about the
task execution.
For example, if you run the tasks in the default MBD pipeline, the report provides an overview of the:
• Model Advisor analysis, including the number of passing, warning, and failing checks
• Test results, organized by iteration
• Generated code files
• Coding standards checks
For an example, see "Prequalify Changes Before Submitting to Source Control" in the User's Guide
PDF.
Functions
Function Description
generateReport Generate report with recent task results
5 Report Generator API
generateReport
Generate report with recent task results
Syntax
generateReport(reportSettings)
generateReport( ___ ,Name,Value)
Description
generateReport(reportSettings) generates a report with the most recent task results.
After you run tasks using the Process Advisor app or runprocess function, you can use the
generateReport function to generate a report of the task results.
Alternatively, you can use runprocess with the GenerateReport name-value argument specified as
true: runprocess(GenerateReport = true).
generateReport( ___ ,Name,Value) specifies options using one or more name-value arguments.
generateReport(padv.ProcessAdvisorReportGenerator(Format="html-file"))
Examples
processAdvisorExampleStart
This command creates a copy of the Process Advisor example project and opens Process Advisor on
the model AHRS_Voter.
Run a task. For this example, in Process Advisor, point to the task Generate Simulink Web View
and click the run button .
Use the generateReport function to generate an HTML report with the task results.
5-2
generateReport
generateReport(padv.ProcessAdvisorReportGenerator(Format="html-file"))
Open and inspect the report. The report shows a summary of the task status, results, inputs, and
outputs.
Input Arguments
reportSettings — Report generation settings
padv.ProcessAdvisorReportGenerator object
File format for the generated report, specified as one of these values:
Example: generateReport(padv.ProcessAdvisorReportGenerator(Format="html-file"))
By default, the report generates in the current working folder with the name
"ProcessAdvisorReport".
Example: generateReport(padv.ProcessAdvisorReportGenerator(OutputPath = "tools/
myReport"))
Data Types: string
Tips
• If you want to run tasks and generate a report in batch mode, you need to specify the
runprocess argument ExitInBatchMode as false and use the exitCode returned by
runprocess to exit:
5-3
5 Report Generator API
Otherwise, the function runprocess automatically exits MATLAB before the report can generate.
Alternative Functionality
Alternatively, you can use runprocess with the GenerateReport name-value argument specified as
true: runprocess(GenerateReport = true).
Version History
Introduced in R2022a
5-4
6
Utilities
Classes
Class Description
padv.util.ArtifactAddress Address for artifact in project
Functions
Function Description
padv.util.getModelName Find name of model that contains artifact
padv.util.getTestCaseID Find ID for test case that contains artifact
6 Utilities
padv.util.ArtifactAddress
Address for artifact in project
Description
Use the padv.util.ArtifactAddress object to represent the address of an artifact in your
project.
Creation
Syntax
addressObj = padv.util.ArtifactAddress(filePath)
addressObj = padv.util.ArtifactAddress( ___ ,"OwningProjectName",projectName)
Description
Input Arguments
6-2
padv.util.ArtifactAddress
Object Functions
Function Description
getFileAddress Get address of file on disk.
getFileAddress(addressObj)
getKey Get unique address of artifact.
getKey(addressObj)
getOwningProject Get name of project that contains the artifact.
getOwningProject(addressObj)
isFileArtifact Determine if input is file.
isFileArtifact(addressObj)
isSubFileArtifact Determine if input is subfile. A subfile is a part of
a larger file.
isSubFileArtifact(addressObj)
Examples
addressObj = padv.util.ArtifactAddress(...
fullfile("tools","sampleChecks.json"));
paArtifact = padv.Artifact("other_file",addressObj)
addressObj = padv.util.ArtifactAddress(fullfile("tools","sampleChecks.json"),...
OwningProjectName=projectName)
You can view which project contains the artifact by using the getOwningProject function.
getOwningProject(addressObj)
6-3
6 Utilities
ans =
Version History
Introduced in R2022a
6-4
padv.util.getModelName
padv.util.getModelName
Package: padv.util
Syntax
modelName = padv.util.getModelName(artifact)
Description
modelName = padv.util.getModelName(artifact) returns the name of the model that
contains artifact.
Input Arguments
artifact — Artifact information
padv.Artifact object
• Running a built-in query. When you run a built-in query, the query returns either a
padv.Artifact object or an array of padv.Artifact objects.
• Using the padv.Artifact class.
Example:
padv.Artifact("sl_model_file",padv.util.ArtifactAddress(fullfile("02_Models",
"AHRS_Voter","specification","AHRS_Voter.slx")))
Output Arguments
modelName — Name of model that contains artifact
string
Version History
Introduced in R2022a
6-5
6 Utilities
padv.util.getTestCaseID
Find ID for test case that contains artifact
Syntax
testCaseID = padv.util.getTestCaseID(artifact)
Description
testCaseID = padv.util.getTestCaseID(artifact) returns the ID for the test case that
contains artifact.
Examples
Open the Process Advisor example project. In the MATLAB Command Window, enter:
processAdvisorExampleStart
Create a query that can find the test cases in the project. Since test cases are part of a larger test file,
test cases are subfile artifacts and you must specify FilterSubFileArtifacts as false to stop
the query from filtering out the test cases.
q = padv.builtin.query.FindArtifacts(ArtifactType = "sl_test_case",...
FilterSubFileArtifacts = false);
Find the test cases in the project by running the query. The query returns the as an array of
padv.Artifact objects.
testCaseArtifacts = run(q);
Find the test case ID for one of the test cases returned by the query.
id = padv.util.getTestCaseID(testCaseArtifacts(1))
Input Arguments
artifact — Artifact information
padv.Artifact object
• Running a built-in query. When you run a built-in query, the query returns either a
padv.Artifact object or an array of padv.Artifact objects.
6-6
padv.util.getTestCaseID
Example:
padv.Artifact("sl_model_file",padv.util.ArtifactAddress(fullfile("02_Models",
"AHRS_Voter","specification","AHRS_Voter.slx")))
Output Arguments
testCaseID — ID for test case that contains artifact
string
ID for the test case that contains the artifact, returned as a string.
Version History
6-7
7
The support package includes example projects that you can use to try the Process Advisor app and
build system. If you use GitHub, GitLab, or Jenkins, you can use the examples for those specific CI
platforms to see example pipeline configuration files and example Dockerfiles.
Example projects:
• processAdvisorExampleStart
• processAdvisorGitHubExampleStart
• processAdvisorGitLabExampleStart
• processAdvisorJenkinsExampleStart
• processAdvisorProjectReferenceExampleStart
7 Process Advisor Example Projects
processAdvisorExampleStart
Set up Process Advisor example project
Syntax
processAdvisorExampleStart
processAdvisorExampleStart(Name=Value)
Description
processAdvisorExampleStart sets up a Process Advisor example project. The function creates a
new copy of the Process Advisor example project and automatically opens the Process Advisor app on
the model AHRS_Voter.
Input Arguments
Name-Value Pair Arguments
By default, the function does not add any pipeline configuration files to the example project.
To configure the pipeline configuration file to use automatic pipeline generation, use the argument
PipelineGen.
Example: processAdvisorExampleStart(CI="jenkins")
Data Types: string
Configure the pipeline configuration file to use automatic pipeline generation, specified as a numeric
or logical 0 (false) or 1 (true).
7-2
processAdvisorExampleStart
Add an example Dockerfile to the project, specified as a numeric or logical 0 (false) or 1 (true).
By default, the function adds an example Dockerfile named Dockerfile to the project root. You can
use the example Dockerfile to create a Docker image that includes MATLAB, other MathWorks®
products, and the CI/CD Automation for Simulink Check™ support package.
For more information on Dockerfiles, see "Create Docker Container for Support Package" in the
User's Guide PDF.
Example: processAdvisorExampleStart(IncludeDockerFile = false)
Data Types: logical
By default, the function does not create a parent folder for the project.
Example: processAdvisorExampleStart(ProjectFolder = "exampleProject")
Data Types: string
Version History
Introduced in R2022a
7-3
7 Process Advisor Example Projects
processAdvisorGitHubExampleStart
Set up Process Advisor example for GitHub
Syntax
processAdvisorGitHubExampleStart
Description
processAdvisorGitHubExampleStart sets up Process Advisor example for GitHub (same as
processAdvisorExampleStart(CI = "github", PipelineGen = false)).
The example includes a pipeline configuration file that can automatically generate a pipeline for
GitHub.
Version History
Introduced in R2022a
7-4
processAdvisorGitLabExampleStart
processAdvisorGitLabExampleStart
Set up Process Advisor example for GitLab
Syntax
processAdvisorGitLabExampleStart
Description
processAdvisorGitLabExampleStart sets up Process Advisor example for GitLab (same as
processAdvisorExampleStart(CI="gitlab")).
The example includes a pipeline configuration file that can automatically generate a pipeline for
GitLab.
Version History
Introduced in R2022a
7-5
7 Process Advisor Example Projects
processAdvisorJenkinsExampleStart
Set up Process Advisor example for Jenkins
Syntax
processAdvisorJenkinsExampleStart
Description
processAdvisorJenkinsExampleStart sets up Process Advisor example for Jenkins (same as
processAdvisorExampleStart(CI="jenkins")).
The example includes a pipeline configuration file that can automatically generate a pipeline for
GitLab. You need to update the example Jenkinsfile to specify the bin directory for your MATLAB
installation and the Git™ branch, credentials, and URL for your repository.
Version History
Introduced in R2022a
7-6
processAdvisorProjectReferenceExampleStart
processAdvisorProjectReferenceExampleStart
Set up Process Advisor example that uses project references
Syntax
processAdvisorProjectReferenceExampleStart
Description
processAdvisorProjectReferenceExampleStart sets up a Process Advisor example project
that uses project references.
Version History
Introduced in R2022a
7-7
8
Artifact Types
The build system uses artifact types to identify and categorize the different file types and modeling
constructs in your project.
You can use an artifact type to find specific types of artifacts in your project:
% Find model files in the project by using the artifact type "sl_model_file"
q = padv.builtin.query.FindArtifacts(ArtifactType="sl_model_file");
results = run(q);
results.Address
You can also use an artifact type to create a padv.Artifact object that represents a specific artifact
and run tasks associated with that artifact:
8-2
9
Tokens
The default process model and built-in task source code use the following tokens to specify artifacts,
directories, and other information relevant to the process:
Token Description
$ITERATIONARTIFACT$ Current artifact that the task is acting on
$PWD$ Current working directory
$TIMESTAMP$ Current date and time in the format
'yyyy_mm_dd_HH_MM_ss'
$PROJECTROOT$ Root folder of project
$TASKNAME$ Task name or title
$DEFAULTOUTPUTDIR$ Default output directory for the process model
$ROOTITERATIONARTIFACT$ Root-level artifact for the iteration artifact
You can use these tokens in your process model, but note that:
The support package CI/CD Automation for Simulink Check contains several built-in tasks that you
can use when you define your process. You can reconfigure the tasks in the process model to change
the task behavior. After you install the support package, you can view the source code files for the
built-in tasks. In the MATLAB Command Window, enter:
cd(fullfile(matlabshared.supportpkg.getSupportPackageRoot,...
"toolbox","padv","build_service","ml","+padv","+builtin","+task"))
The built-in tasks include tasks for generating model reports, performing model analysis, running
tests, generating code, and analyzing code:
*Built-in tasks that require a display might generate an error if there is no display available. If you
run MATLAB using the -nodisplay option or you use a machine that does not have a display (like
many CI runners and Docker containers), you should set up a virtual display server on that machine
before you run the tasks. For information, see "Set Up Virtual Display for No-Display Machine" in the
User's Guide.
Reference pages for the built-in task are listed alphabetically on the following pages:
10-2
Check Coding Standards or Prove Code Quality
• Check Coding Standards (default) — Quickly analyze generated model code for many types of
run-time defects, coding standards, and code metrics by usingPolyspace Bug Finder.
• Prove Code Quality — Check every operation in your code for a set of possible run-time errors
and try to prove the absence of the error for all execution paths by using Polyspace Code Prover.
For information, see "Advanced - Polyspace Code Prover Option" and "Perform Code Prover
Verification" in this PDF.
Note You can use both Bug Finder and Code Prover in your software development workflow. For
information on how to include both a Bug Finder task and a Code Prover task in your process model,
see "Check Coding Standards and Prove Code Quality" in this PDF.
For information on the differences between Bug Finder and Code Prover, see https://
www.mathworks.com/help/bugfinder/gs/use-bug-finder-and-code-prover.html.
This task runs on the generated model code for each model in the project. If a model does not have
generated code, the task skips the model and displays a warning message.
Optionally, you can have the task automatically upload results to Polyspace Access™ so that your
team can review the results in the Polyspace Access web interface. For information, see "Advanced -
Polyspace Access Configuration Options" and "Upload to Polyspace Access" in this PDF.
Note Starting in R2023b, this task is not supported on macOS (Apple silicon).
Prerequisites
• This task requires that your Polyspace installation is integrated with MATLAB and Simulink. If you
have not already integrated your installation, use the function polyspacesetup. For information,
see https://www.mathworks.com/help/bugfinder/ug/integrate-polyspace-with-matlab-and-
simulink.html.
• If you start MATLAB with the -batch option, the task requires a Polyspace server product. The
required server product depends on the task configuration:
• Check Coding Standards (default) — Requires the Polyspace Bug Finder Server™ product.
• Prove Code Quality — Requires the Polyspace Code Prover Server product.
10-3
10 Built-In Task Library
If you want to have one task instance that uses Bug Finder and another task instance that uses Code
Prover, see "Check Coding Standards and Prove Code Quality" in this PDF.
Reconfigure Task
You can change how a task performs an action by setting the properties of the task object.
Polyspace Options
Property Description
TreatAsRefModel By default, the task automatically identifies
whether a model is a top model or a reference
model before analyzing the model code. But you
can specify TreatAsRefModel as true or
false if you want to override the behavior and
only analyze reference model code or top model
code.
Default: ""
ResultDir Directory where build system stores results from
analyzing model code
Default: fullfile('$DEFAULTOUTPUTDIR$',
'$ITERATIONARTIFACT$', 'ps_results')
Reports Reports output by the task
Default: ["BugFinderSummary"
"CodingStandards"]
ReportPath Path to reports output by the task
Default:
string(fullfile('$DEFAULTOUTPUTDIR$',
'$ITERATIONARTIFACT$', 'ps_results'))
ReportFormat Format of output reports
Default: "PDF"
ReportNames Names of output reports
Default: ["$ITERATIONARTIFACT
$_BugFinderSummary"
"$ITERATIONARTIFACT$_CodingStandards"]
10-4
Check Coding Standards or Prove Code Quality
Property Description
VerificationMode Polyspace mode, specified as either:
Default:"BugFinder"
Property Description
SavePsPrjFileAfterAnalysis Save Polyspace project file after analyzing model
code
Default: 1
PsPrjFileName Polyspace project file path
Default: "$ITERATIONARTIFACT
$_BugFinder"
10-5
10 Built-In Task Library
Property Description
PsAccessEnable Enable task to upload Bug Finder analysis results
to Polyspace Access, specified as a numeric or
logical 1 (true) or 0 (false).
Default: false
PsAccessHostName Polyspace Access machine host name, specified
as a string. You can find the host name in the
URL of the Polyspace Access interface, for
example, https://hostname:port/metrics/
index.html.
Default: ""
PsAccessPortNumber Polyspace Access port, specified as a string. You
can find the port number in the URL of the
Polyspace Access interface, for example,
https://hostname:portNumber/metrics/
index.html.
Default: "9443"
PsAccessProtocol HTTP protocol used to access Polyspace Access,
specified as either "http" or "https".
Default: "https"
PsAccessCredentialsFile Full path to text file where you store your login
credentials for Polyspace Access, specified as a
string.
Default: string.empty
10-6
Check Coding Standards or Prove Code Quality
Property Description
PsAccessApiKey API key for Polyspace Access, specified as a
string.
Default: string.empty
PsAccessUserName Username for Polyspace Access, specified as a
string.
Default: ""
PsAccessEncryptedPassword Password for Polyspace Access, specified as a
string.
Default: ""
10-7
10 Built-In Task Library
Property Description
PsAccessParentFolder Path of parent folder in Polyspace Access
explorer under which you store uploaded results,
specified as a string.
Default: ""
PsAccessResultsName Name of uploaded results in Polyspace Access
explorer, specified as a string.
Default: ""
If you have a Polyspace Code Prover license, you can reconfigure the task to check every operation in
your code for a set of possible run-time errors and try to prove the absence of the error for all
execution paths.
To reconfigure the task, specify the VerificationMode property as "CodeProver". For example:
psTask = pm.addTask(padv.builtin.task.AnalyzeModelCode);
psTask.Title = "Prove Code Quality";
psTask.VerificationMode = "CodeProver";
This code specifies a value for the Title property since the default task title is "Check Coding
Standards". You can use the other task properties to specify the report templates and other task
settings.
You can use both Bug Finder and Code Prover in your software development workflow.
Both Polyspace Bug Finder and Polyspace Code Prover detect run-time errors through static analysis.
• Bug Finder quickly analyzes your code and detects many types of defects.
• Code Prover checks every operation in your code for a set of possible run-time errors and try to
prove the absence of the error for all execution paths.
To include both a Bug Finder task and a Code Prover task in your process model, you must add two
separate instances of the built-in task padv.builtin.task.AnalyzeModelCode to the process
model. Each instance needs a unique value for the Name property. Use the VerificationMode
property to specify whether the task uses Bug Finder (default) or Code Prover ("CodeProver"). You
can use the other task properties to specify the report templates and other task settings.
For example:
10-8
Check Coding Standards or Prove Code Quality
Note that this code specifies different result directories and report paths for each task to prevent the
task outputs from overwriting each other.
If you have a Polyspace Access license, you can reconfigure this task to automatically upload results
to Polyspace Access for your team to review.
Before you reconfigure the task, make sure that you have performed this one-time setup: https://
www.mathworks.com/help/bugfinder/gs/run-bug-finder-on-
server.html#mw_c7a5eb97-7327-4f99-9717-77773d462d8b
To reconfigure the task, update your process model to specify the property PsAccessEnable as
true and to specify values for these properties:
• PsAccessHostName
• PsAccessPortNumber
• PsAccessProtocol
• PsAccessParentFolder
• And one of the following sets of credentials:
• PsAccessCredentialsFile
• PsAccessApiKey
• PsAccessUserName and PsAccessEncryptedPassword
For example:
10-9
10 Built-In Task Library
end
This code uses a credentials file, myCredentials.txt, to pass credentials to Polyspace Access, but
you can also use an API key or a username and password. For information on how to generate and
maintain credentials for Polyspace Access, see https://www.mathworks.com/help/bugfinder/ref/
polyspaceaccess.html#mw_595ad91b-5f80-4a87-b6e9-fecf45ce663c.
For information on these properties, see the "Advanced - Polyspace Access Configuration Options" in
the previous section.
• https://www.mathworks.com/help/bugfinder/gs/send-polyspace-analysis-from-desktop-to-remote-
server.html
• https://www.mathworks.com/help/bugfinder/gs/run-bug-finder-on-server.html
Source Code
To view the source code for this built-in task, in the MATLAB Command Window, enter:
open padv.builtin.task.AnalyzeModelCode
10-10
Check Modeling Standards
You can configure this task to specify which model standards the task runs. For example, you can
specify a Model Advisor configuration file or list of check identifiers to include in the Model Advisor
analysis. If you do not specify which model standards to run, the task runs a subset of high-integrity
systems checks by default.
maTask = addTask(pm,padv.builtin.task.RunModelStandards);
Reconfigure Task
You can change how a task performs an action by setting the properties of the task object.
For example, if you want to specify a list of Model Advisor checks for the task to run, you can modify
the CheckIDList property of the task object maTask:
maTask.CheckIDList = {'mathworks.jmaab.db_0032',...
'mathworks.jmaab.jc_0281'};
Property Description
CheckIDList List of unique identifiers for the Model Advisor
checks, specified as a character vector, or cell
array of character vectors. For example,
{'mathworks.jmaab.db_0032','mathworks.
jmaab.jc_0281'}.
Default: <missing>
10-11
10 Built-In Task Library
Property Description
DisplayResults Report display setting for the Model Advisor,
specified as either:
Default: "Summary"
ExtensiveAnalysis Extensive analysis setting for the Model Advisor,
specified as either:
Default: "on"
Force Force delete modeladvisor/system folders,
specified as either:
Default: "on"
ParallelMode Parallel execution setting for the Model Advisor,
specified as "off" or "on".
Default: "off"
ReportFormat Format of the generated report, specified as
either:
Default: "html"
10-12
Check Modeling Standards
Property Description
ReportName Prefix for the Model Advisor report file name,
specified as a character vector. An underscore
and the model name, "_modelName", are
appended to the report file name.
Default: "$ITERATIONARTIFACT
$_ModelAdvisor"
ReportPath Folder for the generated report, specified as a
character vector.
Default:
string(fullfile('$DEFAULTOUTPUTDIR$',
'$ITERATIONARTIFACT$',
'model_standards'))
ShowExclusions Exclusion display setting for the report, specified
as either:
Default: "on"
TempDir Temporary working folder setting for the Model
Advisor, specified as either:
Default: "off"
The task uses these properties to specify input arguments for the function ModelAdvisor.run. For
more information on the arguments, see the Simulink Check documentation for ModelAdvisor.run:
https://www.mathworks.com/help/slcheck/ref/modeladvisor.run.html.
You can also reconfigure the task object to specify a different Model Advisor configuration file by
using addInputQueries:
10-13
10 Built-In Task Library
end
addInputQueries adds the Model Advisor configuration file as an input to the task and uses that
configuration file when you run Model Advisor.
Note If you specify both a Model Advisor configuration file and the CheckIDList, the task uses the
Model Advisor configuration file.
Source Code
To view the source code for this built-in task, in the MATLAB Command Window, enter:
open padv.builtin.task.RunModelStandards
10-14
Detect Design Errors
dedObj = addTask(pm,padv.builtin.task.DetectDesignErrors);
Reconfigure Task
You can change how a task performs an action by setting the properties of the task object.
For example, you can set the properties of the task object to change the analysis options:
dedObj.DetectDeadLogic = "on";
Property Description
DataFileName Folder and file name for the MAT-file that
contains the data generated during the analysis,
specified as a character array. The data is stored
in an sldvData structure.
Default: "$ITERATIONARTIFACT$_sldvdata"
DesignMinMaxCheck Check that the intermediate and output signals in
models are within the range of specified
minimum and maximum constraints, specified as
"on" or "off".
Default: "off"
DetectActiveLogic Analyze models for active logic, specified as "on"
or "off". Note that this parameter is enabled
only if DetectDeadLogic is "on".
Default: "off"
DetectBlockInputRangeViolations Analyze models for block input range violations,
specified as "on" or "off".
Default: "off"
10-15
10 Built-In Task Library
Property Description
DetectDeadLogic Analyze models for dead logic, specified as "on"
or "off".
Default: "off"
DetectDivisionByZero Analyze models for division-by-zero errors,
specified as "on" or "off".
Default: "on"
DetectDSMAccessViolations Analyze models for data store access violations,
specified as "on" or "off".
Default: "off"
DetectHISMViolationsHisl_0002 Check the usage of rem and reciprocal
operations that cause non-finite results, specified
as "on" or "off".
Default: "on"
DetectHISMViolationsHisl_0003 Check the usage of Square Root (Sqrt)
operations with inputs that can be negative,
specified as "on" or "off".
Default: "on"
DetectHISMViolationsHisl_0004 Check the usage of log and log10 operations
that cause non-finite results, specified as "on" or
"off".
Default: "on"
DetectHISMViolationsHisl_0028 Check the usage of Reciprocal Square Root
(rSqrt) blocks with inputs that can go zero or
negative, specified as "on" or "off".
Default: "on"
DetectInfNaN Analyze models for non-finite and NaN floating-
point values, specified as "on" or "off".
Default: "off"
DetectIntegerOverflow Analyze models for integer and fixed-point data
overflow errors, specified as "on" or "off".
Default: "on"
DetectOutOfBounds Analyze models for out of bounds array access
errors, specified as "on" or "off".
Default: "on"
DetectSubnormal Analyze models for subnormal floating-point
values, specified as "on" or "off".
Default: "off"
10-16
Detect Design Errors
Property Description
DisplayReport After analysis, display the report that Simulink
Design Verifier generates, specified as "on" or
"off".
Default: "off"
MaxProcessTime Maximum time (in seconds) that Simulink Design
Verifier spends analyzing a model, specified as a
double.
Default: 300
Options Options for the generated report, specified as
"summary", "objectives", "objects", or a
combination of these options in an array.
Default: "HTML"
ReportFilePath Folder and file name for the analysis report,
specified as a character array.
Default: fullfile('$DEFAULTOUTPUTDIR$',
'$ITERATIONARTIFACT
$','design_error_detections','$ITERATI
ONARTIFACT
$_Design_Error_Detection_Report')
ShowUI Display messages in the log window, specified as
a numeric or logical 1 (true) or 0 (false). When
ShowUI is specified as 0, messages appear in the
MATLAB Command Window.
Default: 0
The task uses these properties to create a design verification options object by using the function
sldevoptions and generate a report by using the function sldvreport. For more information on
the options, see the Simulink Design Verifier documentation for sldevoptions and sldvreport.
Source Code
To view the source code for this built-in task, in the MATLAB Command Window, enter:
open padv.builtin.task.DetectDesignErrors
10-17
10 Built-In Task Library
Generate Code
This task uses Embedded Coder to generate code. The task returns the generated code report as an
output file.
Note This task generates code but does not build executable files.
addTask(pm,padv.builtin.task.GenerateCode);
Reconfigure Task
You can change how a task performs an action by setting the properties of the task object.
Property Description
TreatAsRefModel By default, the task automatically identifies
whether a model is a top model or a reference
model before generating code. But you can
specify TreatAsRefModel as true or false if
you want to override the behavior and only
generate reference model code or top model
code.
Default: []
GenerateCodeOnly By default, the task generates code only and does
not build an executable file.
Default: 1
ObfuscateCode Generate obfuscated C code, specified as a
numeric or logical 1 (true) or 0 (false).
Default: 0
10-18
Generate Code
Property Description
UpdateThisModelReferenceTarget Conditional rebuild option for model reference
build, specified as either:
• "Force"
• "IfOutOfDateOrStructuralChange"
• "IfOutOfDate"
Default:
"IfOutOfDateOrStructuralChange"
ForceTopModelBuild Force top model of model hierarchy to build,
specified as a numeric or logical 1 (true) or 0
(false).
Default: 0
IncludeModelReferenceSimulationTargets Build model reference simulation targets,
specified as a numeric or logical 1 (true) or 0
(false).
Default: 0
The task uses these properties to generate code by using the function slbuild. For more
information on the slbuild arguments, see the documentation for slbuild.
Source Code
To view the source code for this built-in task, in the MATLAB Command Window, enter:
open padv.builtin.task.GenerateCode
10-19
10 Built-In Task Library
• If you make a change to a model and run the task, the task compares your version of the model to
either the head of the current branch or latest version on the main branch in Git.
• If you do not make any changes to a model and run the task, the task compares the model to the
previous version available on the main branch in Git.
You can use the task properties to specify different report options, filtering options, and the name of
the Git branch used for the comparison.
Prerequisites
• To find and compare model ancestors, this task requires that you use Git source control for your
project. For information on how to add a project to Git source control, see https://
www.mathworks.com/help/simulink/ug/add-a-project-to-source-control.html.
• If you run MATLAB using the -nodisplay option or you use a machine that does not have a
display (like many CI runners and Docker containers), you should set up a virtual display server
before you include this task in your process model. For information, see "Set Up Virtual Display
for No-Display Machine" in the User's Guide.
Reconfigure Task
You can change how a task performs an action by setting the properties of the task object.
10-20
Generate Model Comparison
Report Options
Property Description
ReportName Names of generated comparison report, specified
as a string.
Default: "$ITERATIONARTIFACT
$_Model_Comparison"
ReportPath Path to generated comparison report, specified as
a string.
Default: fullfile('$DEFAULTOUTPUTDIR$',
'$ITERATIONARTIFACT
$','model_comparison')
ReportFormat Format of generated comparison report, specified
as either "DOCX", "HTML", or "PDF".
Default: "HTML"
Advanced Options
Property Description
Filter Setting for filtering model comparison report,
specified as either:
Default: "default"
MainBranch Name of Git branch used for comparison,
specified as a string.
Default: "main"
The task uses these properties to specify input arguments for the function visdiff. For information
on visdiff, see https://www.mathworks.com/help/matlab/ref/visdiff.html.
10-21
10 Built-In Task Library
Source Code
To view the source code for this built-in task, in the MATLAB Command Window, enter:
open padv.builtin.task.GenerateModelComparison
10-22
Generate SDD Report
Prerequisites
• If you run MATLAB using the -nodisplay option or you use a machine that does not have a
display (like many CI runners and Docker containers), you should set up a virtual display server
before you include this task in your process model. For information, see "Set Up Virtual Display
for No-Display Machine" in the User's Guide.
addTask(pm,padv.builtin.task.GenerateSDDReport);
Reconfigure Task
You can change how a task performs an action by setting the properties of the task object.
Property Description
DisplayReport Open the generated report, specified as a
numeric or logical 1 (true) or 0 (false).
Default: 0
IncludeCustomLibraries Include custom libraries in the design
description, specified as a numeric or logical 1
(true) or 0 (false).
Default: 0
IncludeDetails Include design details, like block parameters, in
the design description, specified as a numeric or
logical 1 (true) or 0 (false).
Default: 1
IncludeGlossary Include a glossary in the design description,
specified as a numeric or logical 1 (true) or 0
(false).
Default: 1
10-23
10 Built-In Task Library
Property Description
IncludeLookupTables Include lookup tables in the design description,
specified as a numeric or logical 1 (true) or 0
(false).
Default: 1
IncludeModelRefs Include model references in the design
description, specified as a numeric or logical 1
(true) or 0 (false).
Default: 0
IncludeRequirementsLinks Include requirement links in the design
description, specified as a numeric or logical 1
(true) or 0 (false).
Default: 1
IncrOutputName Increment the report name to avoid overwriting
an existing report, specified as a numeric or
logical 1 (true) or 0 (false).
Default: 0
LegalNotice Legal notice that appears on the report, specified
as a string array.
Default: 1
10-24
Generate SDD Report
Property Description
ReportFormat Output format for the generated report, specified
as either:
Default: "html"
ReportName File name for the generated report, specified as a
string array.
Default: "$ITERATIONARTIFACT$_SDD"
ReportPath Path to the generated report, specified as a string
array.
Default:
string(fullfile('$DEFAULTOUTPUTDIR$',
'$ITERATIONARTIFACT$',
'system_design_description'))
ReportTitle Title of the report, specified as a string.
Default: ""
TitleImgPath Path of image that appears on report title page,
specified as a string.
Default: ""
Subtitle Subtitle of the report, specified as a string.
Default: ""
UseStatusWindow Display report generation status messages in
separate window, specified as a numeric or
logical 1 (true) or 0 (false).
Default: 0
The task uses these properties to specify the report options for an SDD object. For information on the
System Design Description options, see https://www.mathworks.com/help/rptgenext/ug/system-
design-description-dialog-box.html.
Source Code
To view the source code for this built-in task, in the MATLAB Command Window, enter:
10-25
10 Built-In Task Library
open padv.builtin.task.GenerateSDDReport
10-26
Generate Simulink Web View
Prerequisites
• If you run MATLAB using the -nodisplay option or you use a machine that does not have a
display (like many CI runners and Docker containers), you should set up a virtual display server
before you include this task in your process model. For information, see "Set Up Virtual Display
for No-Display Machine" in the User's Guide.
addTask(pm,padv.builtin.task.GenerateSimulinkWebView);
Reconfigure Task
You can change how a task performs an action by setting the properties of the task object.
Property Description
FollowLinks Follow links into library blocks, specified as
either:
Default: 1
FollowModelReference Access referenced models in a web view,
specified as either:
Default: 1
IncludeNotes Include user notes, specified as a numeric or
logical 1 (true) or 0 (false).
Default: 1
10-27
10 Built-In Task Library
Property Description
IncrementalExport Starting in R2022b, export models incrementally,
specified as a numeric or logical 1 (true) or 0
(false).
Default: 0
LookUnderMasks Export the ability to interact with masked blocks,
specified as either "None" or "All".
Default: "All"
PackagingType Type of web view output package, specified as
"zipped", "unzipped", or "both".
Default: "unzipped"
RecurseFolder Export models in subfolders, specified as a
numeric or logical 1 (true) or 0 (false).
Default: 0
ReportName File name for the generated report, specified as a
string array.
Default: "$ITERATIONARTIFACT$_webview"
ReportPath Path to the generated report, specified as a string
array.
Default:
string(fullfile('$DEFAULTOUTPUTDIR$',
'$ITERATIONARTIFACT$', 'webview'))
SearchScope Systems to export, relative to the system_name
system, specified as "All",
"CurrentAndBelow", "CurrentAndAbove", or
"Current".
Default: "All"
ShowProgressBar Display the status bar when you export a web
view, specified as a numeric or logical 1 (true) or
0 (false).
Default: 0
ViewFile Display the web view in a web browser when you
export the web view, specified as a numeric or
logical 1 (true) or 0 (false).
Default: 0
The task uses these properties to specify the input arguments for the function slwebview. For
information on the arguments, see the documentation for slwebview: https://www.mathworks.com/
help/rptgenext/ug/slwebview.html.
10-28
Generate Simulink Web View
Source Code
To view the source code for this built-in task, in the MATLAB Command Window, enter:
open padv.builtin.task.GenerateSimulinkWebView
10-29
10 Built-In Task Library
Inspect Code
This task uses the Simulink Code Inspector to detect unintended functionality in your models by
establishing model-to-code and code-to-model traceability. The results of this task can help you to
satisfy code-review objectives in DO-178 and other high-integrity standards.
addTask(pm,padv.builtin.task.RunCodeInspection);
Reconfigure Task
You can change how a task performs an action by setting the properties of the task object.
Property Description
IsTopModel By default, the task automatically identifies
whether a model is a top model or a reference
model before generating code. But you can
specify IsTopModel as true or false if you
want to override the behavior and only generate
top model code or reference model code.
Default: []
ReportFolder Path to the generated report, specified as a string
array.
Default:
string(fullfile('$DEFAULTOUTPUTDIR$',
'$ITERATIONARTIFACT$',
'code_inspection'))
The task uses these properties to create a code inspection object (slci.Configuration).
Source Code
To view the source code for this built-in task, in the MATLAB Command Window, enter:
10-30
Inspect Code
open padv.builtin.task.RunCodeInspection
10-31
10 Built-In Task Library
Prerequisites
• You can use the built-in task padv.builtin.task.RunTestsPerTestCase to run your test
cases. This task only supports merging coverage results from normal simulation mode results. The
merging of coverage results from software-in-the-loop (SIL), processor-in-the-loop (PIL), and other
modes is not supported.
addTask(pm,padv.builtin.task.MergeTestResults);
Reconfigure Task
You can change how a task performs an action by setting the properties of the task object.
Property Description
CovAllTestInMdlSumm Include each test in the model summary, specified
as a numeric or logical 1 (true) or 0 (false).
Default: 0
CovBarGrInMdlSumm Produce bar graphs in the model summary,
specified as a numeric or logical 1 (true) or 0
(false).
Default: 1
CovComplexInBlkTable Include cyclomatic complexity numbers in block
details, specified as a numeric or logical 1 (true)
or 0 (false).
Default: 1
10-32
Merge Test Results
Property Description
CovComplexInSumm Include cyclomatic complexity numbers in
summary, specified as a numeric or logical 1
(true) or 0 (false).
Default: 1
CovElimFullCov Exclude fully covered model objects from report,
specified as a numeric or logical 1 (true) or 0
(false).
Default: 0
CovElimFullCovDetails Exclude fully covered model object details from
report, specified as a numeric or logical 1 (true)
or 0 (false).
Default: 1
CovFiltExecMetric Filter Execution metric from report, specified as
a numeric or logical 1 (true) or 0 (false).
Default: 0
CovFiltSFEvent Filter Stateflow events from report, specified as a
numeric or logical 1 (true) or 0 (false).
Default: 0
CovGenerateWebViewReport Generate web view report, specified as a numeric
or logical 1 (true) or 0 (false).
Default: 0
CovHitCntInMdlSumm Display hit/count ratio in the model summary,
specified as a numeric or logical 1 (true) or 0
(false).
Default: 0
CovReportName Name of generated model coverage report,
specified as a string.
Default: "$ITERATIONARTIFACT
$_ModelCoverage_Report.html"
CovReportNameSIL Name of generated software-in-the-loop (SIL)
code coverage report, specified as a string.
Default: "$ITERATIONARTIFACT
$_SIL_CodeCoverage_Report.html"
CovReportNamePIL Name of generated processor-in-the-loop (PIL)
code coverage report, specified as a string.
Default: "$ITERATIONARTIFACT
$_PIL_CodeCoverage_Report.html"
10-33
10 Built-In Task Library
Property Description
CovShowReport Show coverage report, specified as a numeric or
logical 1 (true) or 0 (false).
Default: 0
CovTwoColorBarGraphs Use two-color bar graphs, specified as a numeric
or logical 1 (true) or 0 (false).
Default: 1
Author Name of the report author, specified as a string
array.
Default: 0
IncludeCoverageResult Include coverage metrics that are collected at
test execution, specified as a numeric or logical 1
(true) or 0 (false).
Default: 1
IncludeErrorMessages Include error messages from the test case
simulations, specified as a numeric or logical 1
(true) or 0 (false).
Default: 1
IncludeMATLABFigures Include the figures opened from a callback script,
custom criteria, or by the model in the report,
specified as a numeric or logical 1 (true) or 0
(false).
Default: 0
IncludeMLVersion Include the version of MATLAB used to run the
test cases, specified as a numeric or logical 1
(true) or 0 (false).
Default: 1
IncludeSimulationMetadata Include simulation metadata for each test case or
iteration, specified as a numeric or logical 1
(true) or 0 (false).
Default: 0
10-34
Merge Test Results
Property Description
IncludeSimulationSignalPlots Include the simulation output plots of each signal,
specified as a numeric or logical 1 (true) or 0
(false).
Default: 0
IncludeTestRequirement Include the test requirement link defined under
Requirements in the test case, specified as a
numeric or logical 1 (true) or 0 (false).
Default: 1
IncludeTestResults Include all or a subset of test results in the
report, specified as either:
Default: 0
LaunchReport Open the generated report, specified as a
numeric or logical 1 (true) or 0 (false).
Default: 0
LoadSimulationSignalData Task loads simulation signal data when loading
test results, specified as a numeric or logical 1
(true) or 0 (false).
Default: 0
NumPlotColumnsPerPage Number of columns of plots to include on report
pages, specified as an integer 1, 2, 3, or 4.
Default: 1
NumPlotRowsPerPage Number of rows of plots to include on report
pages, specified as an integer 1, 2, 3, or 4.
Default: 2
ReportFormat Output format for the generated report, specified
as either:
Default: "pdf"
10-35
10 Built-In Task Library
Property Description
ReportPath Path to the generated report, specified as a string
array.
Default: fullfile('$DEFAULTOUTPUTDIR$',
'$ITERATIONARTIFACT$' ,
'test_results')
ReportName File name for the generated report, specified as a
string array.
Default: "$ITERATIONARTIFACT
$_Test_Report"
ReportTitle Title of the report, specified as a string.
Source Code
To view the source code for this built-in task, in the MATLAB Command Window, enter:
open padv.builtin.task.MergeTestResults
10-36
Run Tests (per model)
Note Since this task runs each test case individually, the task only executes test-case level callbacks.
The task does not execute test-file level callbacks or test-suite level callbacks.
addTask(pm,padv.builtin.task.RunTestsPerModel);
Reconfigure Task
You can change how a task performs an action by setting the properties of the task object.
Property Description
Author Name of the report author, specified as a string
array.
Default: 0
IncludeCoverageResult Include coverage metrics that are collected at
test execution, specified as a numeric or logical 1
(true) or 0 (false).
Default: 1
IncludeErrorMessages Include error messages from the test case
simulations, specified as a numeric or logical 1
(true) or 0 (false).
Default: 1
10-37
10 Built-In Task Library
Property Description
IncludeMATLABFigures Include the figures opened from a callback script,
custom criteria, or by the model in the report,
specified as a numeric or logical 1 (true) or 0
(false).
Default: 0
IncludeMLVersion Include the version of MATLAB used to run the
test cases, specified as a numeric or logical 1
(true) or 0 (false).
Default: 1
IncludeSimulationMetadata Include simulation metadata for each test case or
iteration, specified as a numeric or logical 1
(true) or 0 (false).
Default: 0
IncludeSimulationSignalPlots Include the simulation output plots of each signal,
specified as a numeric or logical 1 (true) or 0
(false).
Default: 0
IncludeTestRequirement Include the test requirement link defined under
Requirements in the test case, specified as a
numeric or logical 1 (true) or 0 (false).
Default: 1
IncludeTestResults Include all or a subset of test results in the
report, specified as either:
Default: 0
LaunchReport Open the generated report, specified as a
numeric or logical 1 (true) or 0 (false).
Default: 0
NumPlotColumnsPerPage Number of columns of plots to include on report
pages, specified as an integer 1, 2, 3, or 4.
Default: 1
NumPlotRowsPerPage Number of rows of plots to include on report
pages, specified as an integer 1, 2, 3, or 4.
Default: 2
10-38
Run Tests (per model)
Property Description
ReportFormat Output format for the generated report, specified
as either:
Default: "pdf"
ReportPath Path to the generated report, specified as a string
array.
Default: fullfile('$DEFAULTOUTPUTDIR$',
'$ITERATIONARTIFACT$','test_results')
ReportName File name for the generated report, specified as a
string array.
Default: "$ITERATIONARTIFACT$_Test"
ReportTitle Title of the report, specified as a string.
Default: "$ITERATIONARTIFACT
$_ResultFile"
ResultFilePath Path to test result file, specified as a string array.
Default: fullfile('$DEFAULTOUTPUTDIR$',
'$ITERATIONARTIFACT$','test_results')
SaveResultsAfterRun Save the test results to a file after execution,
specified as a numeric or logical 1 (true) or 0
(false).
Default: 1
Source Code
To view the source code for this built-in task, in the MATLAB Command Window, enter:
open padv.builtin.task.RunTestsPerModel
10-39
10 Built-In Task Library
Note Since this task runs each test case individually, the task only executes test-case level callbacks.
The task does not execute test-file level callbacks or test-suite level callbacks.
To generate a consolidated test results report and a merged coverage report for your model, you can
use the built-in task padv.builtin.task.MergeTestResults.
addTask(pm,padv.builtin.task.RunTestsPerTestCase);
Reconfigure Task
You can change how a task performs an action by setting the properties of the task object.
Property Description
ResultFileName Name of test result file, specified as a string
array.
Default: "$ITERATIONARTIFACT
$_ResultFile"
If you want the task to only run on test cases that have a specific test tag, specify the
IterationQuery using the built-in query padv.builtin.query.FindTestCasesForModel and
specify the test tag using the Tags argument. For example, to have the task only run on test cases
that were tagged with the test tag FeatureA:
addTask(pm,padv.builtin.task.RunTestsPerTestCase,...
IterationQuery = padv.builtin.query.FindTestCasesForModel(Tags="FeatureA"));
Source Code
To view the source code for this built-in task, in the MATLAB Command Window, enter:
open padv.builtin.task.RunTestsPerTestCase
10-40
11
The support package CI/CD Automation for Simulink Check contains several built-in queries that can
find specific sets of artifacts in your project. You can use the queries when you define your process,
but note that you can only use certain queries as an input query (InputQueries) or iteration query
(IterationQuery) for a task. The built-in queries include:
*If you specify the query input argument InProject as true, you can no longer use the query as an
input query.
Reference pages for the built-in task are listed alphabetically on the following pages.
Tip You can access help for the built-in queries from the MATLAB Command Window. For example,
this code returns help information for the built-in query padv.builtin.query.FindArtifacts:
11 Built-In Query Library
help padv.builtin.query.FindArtifacts
11-2
padv.builtin.query.FindArtifacts
padv.builtin.query.FindArtifacts
This query returns each of the artifacts in project that meet the criteria specified by the optional
input arguments.
Syntax
q = padv.builtin.query.FindArtifacts() finds all artifacts in the project.
Input Arguments
Name-Value Arguments
• Name — Unique identifier for query, specified as character vector or string. Example:
"CustomQueryForArtifacts"
• ArtifactType — Type of artifact, specified as a string or a cell array of character vectors. For a
list of valid artifact types, see the chapter "Artifact Types" in this PDF. Example:
{"sl_model_file","m_file"}
• IncludeLabel — Find artifacts that have a specific project label, specified as a cell array where
the first entry is the project label category and the second entry is the project label name.
Example: {"Classification","Design"}
• ExcludeLabel — Exclude artifacts that have a specific project label, specified as a cell array
where the first entry is the project label category and the second entry is the project label name.
Example: {"Classification","Design"}
• IncludePath — Find artifacts where the path contains specific text, specified as a character
vector or string. Example: "HLR"
• ExcludePath — Exclude artifacts where the path contains specific text, specified as a character
vector. Example: "HLR"
• InProject — Include only artifacts that have been added to the project, specified as a numeric or
logical 1 (true) or 0 (false). Example: true
Note If you specify InProject as true, you can no longer use the query as an input query.
11-3
11 Built-In Query Library
For example, suppose that you have a custom task, MyCustomTask, that you add to your process
model. You can use the built-in query padv.builtin.query.FindArtifacts to find specific types
of artifacts. To find the data dictionaries in the project, you specify the ArtifactType argument as
"sl_data_dictionary_file".
For example:
1 Open a project. For this example, you can open the Process Advisor example project.
processAdvisorExampleStart
2 Create an instance of the query. You can use the arguments of the query to filter the query
results. For example, you can use the IncludeLabel argument to have the query only return
artifacts that use the Design project label from the Classification project label category.
q = padv.builtin.query.FindArtifacts(...
IncludeLabel = {'Classification','Design'});
3 Run the query and inspect the array of artifacts that the query returns.
run(q)
ans =
Type
Parent
ArtifactAddress
11-4
padv.builtin.query.FindFilesWithLabel
padv.builtin.query.FindFilesWithLabel
This query returns files in the project that use the specified project label.
Syntax
q = padv.builtin.query.FindFilesWithLabel(categoryName,labelName) finds files that
use the project label labelName from the project label category categoryName.
Input Arguments
• categoryName — Name of project label category, specified as a character vector or string.
Example: "ModelLabels"
Name-Value Arguments
• Name — Unique identifier for query, specified as character vector or string. Example:
"CustomQueryForArtifacts"
• IncludeLabel — Find artifacts that have a specific project label, specified as a cell array where
the first entry is the project label category and the second entry is the project label name.
Example: {"Classification","Design"}
• ExcludeLabel — Exclude artifacts that have a specific project label, specified as a cell array
where the first entry is the project label category and the second entry is the project label name.
Example: {"Classification","Design"}
• IncludePath — Find artifacts where the path contains specific text, specified as a character
vector or string. Example: "HLR"
• ExcludePath — Exclude artifacts where the path contains specific text, specified as a character
vector. Example: "HLR"
• InProject — Include only artifacts that have been added to the project, specified as a numeric or
logical 1 (true) or 0 (false). Example: true
11-5
11 Built-In Query Library
For example, suppose that you want the built-in task padv.builtin.task.RunModelStandards to
only run for models that use the project label RunModelAdvisor from the project label category
ModelLabels. You can change the IterationQuery for the task to specify a different set of
artifacts for the task to run on. You can use the built-in query
padv.builtin.query.FindFilesWithLabel to find the models that use that project label.
Specify the first input argument as the project label category and the second argument as the project
label name.
maTask = pm.addTask(padv.builtin.task.RunModelStandards());
maTask.IterationQuery = ...
padv.builtin.query.FindFilesWithLabel("ModelLabels","RunModelAdvisor");
11-6
padv.builtin.query.FindFileWithAddress
padv.builtin.query.FindFileWithAddress
This query returns the file at the specified address in the project.
Syntax
q = padv.builtin.query.FindFileWithAddress(Type = ArtifactType,Path =
FilePath) finds a file, of type ArtifactType, at the address specified by FilePath.
To find multiple files, specify ArtifactType and FilePath as vectors of the same length.
Input Arguments
• ArtifactType — Type of artifact, specified as a string or string array. For a list of valid artifact
types, see the chapter "Artifact Types" in this PDF.
Examples:
• "sl_model_file"
• ["sl_model_file", "m_file"]
Examples:
• fullfile("02_Models","AHRS_Voter","specification","AHRS_Voter.slx")
• [fullfile("myFiles","myModel.slx"), fullfile("myFiles","myScript.m")]
For example, by default, the Check Modeling Standards task runs a subset of high-integrity checks.
But suppose that you want the task to run the Model Advisor checks specified by the Model Advisor
configuration file sampleChecks.json instead. In the process model, you can use the
addInputQueries function to specify an input query that finds the Model Advisor configuration file.
You can use the built-in query padv.builtin.query.FindFileWithAddress as an input query to
find the Model Advisor configuration file:
• The first argument, "ma_config_file", specifies that the artifact type of the file is a Model
Advisor configuration file.
• The second argument specifies the path to the Model Advisor configuration file.
11-7
11 Built-In Query Library
end
To find multiple files, specify the artifact type (Type) and the file path (Path) using vectors of the
same length. For example:
padv.builtin.query.FindFileWithAddress(...
Type=["ma_config_file",...
"sl_model_file"],...
Path=[fullfile("tools","sampleChecks.json"),...
fullfile("02_Models","AHRS_Voter","specification","AHRS_Voter.slx")])
If you only specify one value for Type, the query uses the same artifact type for each specified file
specified by Path.
padv.builtin.query.FindFileWithAddress(...
Type="ma_config_file",...
Path=[fullfile("tools","sampleChecks.json"), fullfile("tools","myCustomChecks.json")])
For example:
1 Open a project. For this example, you can open the Process Advisor example project.
processAdvisorExampleStart
2 Create an instance of the query. For example, create a query that finds a file with the artifact
type Model Advisor configuration file (ma_config_file) at the file path specified by
fullfile("tools","sampleChecks.json").
q = padv.builtin.query.FindFileWithAddress( ...
Type = "ma_config_file",...
Path = fullfile("tools","sampleChecks.json"))
run(q)
ans =
"tools\sampleChecks.json"
11-8
padv.builtin.query.FindModels
padv.builtin.query.FindModels
This query returns each of the models in project that meet the criteria specified by the optional input
arguments.
Syntax
q = padv.builtin.query.FindModels() finds all models in the project. The models include
Simulink models and System Composer models.
Input Arguments
Name-Value Arguments
• Name — Unique identifier for query, specified as character vector or string. Example:
"CustomQuery"
• IncludeLabel — Find artifacts that have a specific project label, specified as a cell array where
the first entry is the project label category and the second entry is the project label name.
Example: {"Classification","Design"}
• ExcludeLabel — Exclude artifacts that have a specific project label, specified as a cell array
where the first entry is the project label category and the second entry is the project label name.
Example: {"Classification","Design"}
• IncludePath — Find artifacts where the path contains specific text, specified as a character
vector or string. Example: "Control"
• ExcludePath — Exclude artifacts where the path contains specific text, specified as a character
vector. Example: "Control"
• InProject — Include only artifacts that have been added to the project, specified as a numeric or
logical 1 (true) or 0 (false). Example: true
Note If you specify InProject as true, you can no longer use the query as an input query.
For example, suppose that you only want to run the Check Modeling Standards task for models
that have Control in their file path. By default, the Check Modeling Standards task uses the built-
11-9
11 Built-In Query Library
1 Use the built-in query padv.builtin.query.FindModels to find the models in the project.
2 Specify the IncludePath argument of the query to filter out any models that do not have
Control in the file path.
end
For the Process Advisor example project, the model AHRS_Voter.slx no longer appears under the
task title in Process Advisor because AHRS_Voter.slx does not include Control in the path.
For example:
1 Open a project. For this example, you can open the Process Advisor example project.
processAdvisorExampleStart
2 Create an instance of the query. You can use the arguments of the query to filter the query
results. For example, you can use the IncludeLabel argument to have the query only return
artifacts that use the Design project label from the Classification project label category.
q = padv.builtin.query.FindModels(...
IncludeLabel = {"Classification","Design"});
3 Run the query and inspect the array of artifacts that the query returns.
run(q)
ans =
11-10
padv.builtin.query.FindModels
Type
Parent
ArtifactAddress
11-11
11 Built-In Query Library
padv.builtin.query.FindModelsWithLabel
This query returns each of the models in project that use the specified project label.
Syntax
q = padv.builtin.query.FindModelsWithLabel(categoryName,labelName) finds models
that use the project label labelName from the project label category categoryName.
Input Arguments
• categoryName — Name of project label category, specified as a character vector or string.
Example: "ModelLabels"
Name-Value Arguments
• Name — Unique identifier for query, specified as character vector or string. Example:
"CustomQueryForArtifacts"
• IncludeLabel — Find artifacts that have a specific project label, specified as a cell array where
the first entry is the project label category and the second entry is the project label name.
Example: {"Classification","Design"}
• ExcludeLabel — Exclude artifacts that have a specific project label, specified as a cell array
where the first entry is the project label category and the second entry is the project label name.
Example: {"Classification","Design"}
• IncludePath — Find artifacts where the path contains specific text, specified as a character
vector or string. Example: "HLR"
• ExcludePath — Exclude artifacts where the path contains specific text, specified as a character
vector. Example: "HLR"
• InProject — Include only artifacts that have been added to the project, specified as a numeric or
logical 1 (true) or 0 (false). Example: true
For example, suppose that you want the built-in task padv.builtin.task.RunModelStandards to
only run for models that use the project label RunModelAdvisor from the project label category
ModelLabels. You can change the IterationQuery for the task to specify a different set of
artifacts for the task to run on. You can use the built-in query
padv.builtin.query.FindModelsWithLabel to find the models that use that project label.
11-12
padv.builtin.query.FindModelsWithLabel
Specify the first input argument as the project label category and the second argument as the project
label name.
maTask = pm.addTask(padv.builtin.task.RunModelStandards());
maTask.IterationQuery = ...
padv.builtin.query.FindModelsWithLabel("ModelLabels","RunModelAdvisor");
11-13
11 Built-In Query Library
padv.builtin.query.FindModelsWithTestCases
This query returns each of the models in the project that are associated with a test case. You can use
the optional name-value arguments to filter the results.
Syntax
q = padv.builtin.query.FindModelsWithTestCases() finds all models that are associated
with a test case.
Input Arguments
Name-Value Arguments
• Name — Unique identifier for query, specified as character vector or string. Example:
"CustomQuery"
• IncludeLabel — Find artifacts that have a specific project label, specified as a cell array where
the first entry is the project label category and the second entry is the project label name.
Example: {"Classification","Design"}
• ExcludeLabel — Exclude artifacts that have a specific project label, specified as a cell array
where the first entry is the project label category and the second entry is the project label name.
Example: {"Classification","Design"}
• IncludePath — Find artifacts where the path contains specific text, specified as a character
vector or string. Example: "Control"
• ExcludePath — Exclude artifacts where the path contains specific text, specified as a character
vector. Example: "Control"
For example, suppose that you only want to run the Merge Test Results task for certain models that
do not have Control in the file path. By default, the Merge Test Results task uses the built-in query
padv.builtin.query.FindModelsWithTestCases as the IterationQuery. In the process
model, you can change the IterationQuery for the task to:
11-14
padv.builtin.query.FindModelsWithTestCases
mergeTestTask = pm.addTask(padv.builtin.task.MergeTestResults());
mergeTestTask.IterationQuery = padv.builtin.query.FindModelsWithTestCases(...
ExcludePath = "Control");
11-15
11 Built-In Query Library
padv.builtin.query.FindProjectFile
This query returns the project file.
Syntax
q = padv.builtin.query.FindProjectFile() finds the project file.
For example, suppose that you have a custom task, MyCustomTask, that you want to run once for the
project. You can use the built-in query padv.builtin.query.FindProjectFile to find the project
file and specify the query as the IterationQuery for the custom task.
11-16
padv.builtin.query.FindRefModels
padv.builtin.query.FindRefModels
This query returns each of the referenced models in the project. You can use optional name-value
arguments to filter the results.
Syntax
q = padv.builtin.query.FindRefModels() finds all reference models in the project.
Input Arguments
Name-Value Arguments
• Name — Unique identifier for query, specified as character vector or string. Example:
"CustomQuery"
• IncludeLabel — Find artifacts that have a specific project label, specified as a cell array where
the first entry is the project label category and the second entry is the project label name.
Example: {"Classification","Design"}
• ExcludeLabel — Exclude artifacts that have a specific project label, specified as a cell array
where the first entry is the project label category and the second entry is the project label name.
Example: {"Classification","Design"}
• IncludePath — Find artifacts where the path contains specific text, specified as a character
vector or string. Example: "Control"
• ExcludePath — Exclude artifacts where the path contains specific text, specified as a character
vector. Example: "Control"
For example, suppose that you want the built-in task padv.builtin.task.RunModelStandards to
only run on reference models in the project. You can change the IterationQuery for the task to
specify a different set of artifacts for the task to run on. You can use the built-in query
padv.builtin.query.FindRefModels to find the reference models.
maTask = pm.addTask(padv.builtin.task.RunModelStandards());
maTask.IterationQuery = ...
padv.builtin.query.FindRefModels;
11-17
11 Built-In Query Library
padv.builtin.query.FindRequirements
This query returns each of the requirement sets (.slreqx) within the project. You can use optional
name-value arguments to filter the results.
Syntax
q = padv.builtin.query.FindRequirements() finds all requirement sets in the project.
Input Arguments
Name-Value Arguments
• Name — Unique identifier for query, specified as character vector or string. Example:
"CustomQuery"
• IncludeLabel — Find artifacts that have a specific project label, specified as a cell array where
the first entry is the project label category and the second entry is the project label name.
Example: {"Level","System"}
• ExcludeLabel — Exclude artifacts that have a specific project label, specified as a cell array
where the first entry is the project label category and the second entry is the project label name.
Example: {"Level","System"}
• IncludePath — Find artifacts where the path contains specific text, specified as a character
vector or string. Example: "System"
• ExcludePath — Exclude artifacts where the path contains specific text, specified as a character
vector. Example: "System"
• InProject — Include only artifacts that have been added to the project, specified as a numeric or
logical 1 (true) or 0 (false). Example: true
Note If you specify InProject as true, you can no longer use the query as an input query.
For example, suppose that you have a custom task, MyCustomTask, that you add to your process
model. You can use the built-in query padv.builtin.query.FindRequirements to find
requirement sets in the project. If you specify padv.builtin.query.FindRequirements as the
IterationQuery for the task, the task runs once for each requirement set in the project.
11-18
padv.builtin.query.FindRequirements
11-19
11 Built-In Query Library
padv.builtin.query.FindRequirementsForModel
This query returns each of the requirements associated with a model. You can use optional name-
value arguments to filter the results.
Syntax
q = padv.builtin.query.FindRequirementsForModel() finds all requirements associated
with models in the project.
Input Arguments
Name-Value Arguments
• Name — Unique identifier for query, specified as character vector or string. Example:
"CustomQuery"
• IncludeLabel — Find artifacts that have a specific project label, specified as a cell array where
the first entry is the project label category and the second entry is the project label name.
Example: {"Level","System"}
• ExcludeLabel — Exclude artifacts that have a specific project label, specified as a cell array
where the first entry is the project label category and the second entry is the project label name.
Example: {"Level","System"}
• IncludePath — Find artifacts where the path contains specific text, specified as a character
vector or string. Example: "System"
• ExcludePath — Exclude artifacts where the path contains specific text, specified as a character
vector. Example: "System"
11-20
padv.builtin.query.FindTestCasesForModel
padv.builtin.query.FindTestCasesForModel
This query returns each of the test cases associated with a model. You can use optional name-value
arguments to filter the results.
Note The query also finds test cases associated with subsystem references. A subsystem reference
allows you to save the contents of a subsystem in a separate file and reference it using a Subsystem
Reference block.
Syntax
q = padv.builtin.query.FindTestCasesForModel() finds test cases associated with a model.
Input Arguments
Name-Value Arguments
• Name — Unique identifier for query, specified as character vector or string. Example:
"CustomQuery"
• IncludeLabel — Find artifacts that have a specific project label, specified as a cell array where
the first entry is the project label category and the second entry is the project label name.
Example: {"Level","HLR"}
• ExcludeLabel — Exclude artifacts that have a specific project label, specified as a cell array
where the first entry is the project label category and the second entry is the project label name.
Example: {"Level","HLR"}
• IncludePath — Find artifacts where the path contains specific text, specified as a character
vector or string. Example: "HLR"
• ExcludePath — Exclude artifacts where the path contains specific text, specified as a character
vector. Example: "HLR"
• Tags — Only include test cases that use a specific test case tag or tags. Example:
{"tag1","tag2"}
For example, suppose that you want the Run Tests task to only run on test cases that use the specific
test case tag TagA. You can use the built-in query
11-21
11 Built-In Query Library
milTask = pm.addTask(padv.builtin.task.RunTestsPerTestCase());
milTask.IterationQuery = padv.builtin.query.FindTestCasesForModel(...
Tags = "TagA");
If you need to include multiple instances of a task, you need to specify different Name values for each
task.
11-22
padv.builtin.query.FindTopModels
padv.builtin.query.FindTopModels
This query returns each of the top models in the project. You can use optional name-value arguments
to filter the results.
Syntax
q = padv.builtin.query.FindTopModels() finds all top models in the project.
Input Arguments
Name-Value Arguments
• Name — Unique identifier for query, specified as character vector or string. Example:
"CustomQuery"
• IncludeLabel — Find artifacts that have a specific project label, specified as a cell array where
the first entry is the project label category and the second entry is the project label name.
Example: {"Classification","Design"}
• ExcludeLabel — Exclude artifacts that have a specific project label, specified as a cell array
where the first entry is the project label category and the second entry is the project label name.
Example: {"Classification","Design"}
• IncludePath — Find artifacts where the path contains specific text, specified as a character
vector or string. Example: "Control"
• ExcludePath — Exclude artifacts where the path contains specific text, specified as a character
vector. Example: "Control"
For example, suppose that you want the built-in task padv.builtin.task.RunModelStandards to
only run on top models in the project. By default, the Check Modeling Standards task uses the
built-in query padv.builtin.query.FindModels as the IterationQuery. In the process model,
you can change the IterationQuery for the task to:
1 Use the built-in query padv.builtin.query.FindTopModels to find the top models in the
project.
2 Specify the IncludePath argument of the query to only include top models that have Control
in the file path.
11-23
11 Built-In Query Library
maTask = pm.addTask(padv.builtin.task.RunModelStandards());
maTask.IterationQuery = ...
padv.builtin.query.FindTopModels(;
For the Process Advisor example project, the model Flight_Control.slx appears under the task
title in Process Advisor.
11-24
padv.builtin.query.GetDependentArtifacts
padv.builtin.query.GetDependentArtifacts
This query returns the dependent artifacts for a given artifact.
Syntax
q = padv.builtin.query.GetDependentArtifacts() gets the dependent artifacts for a given
artifact.
Use in Task
You can use this query in your custom tasks to find artifacts that your tasks can use as inputs
(InputQueries).
[email protected](options.Name,...
IterationQuery=options.IterationQuery,...
InputQueries=options.InputQueries,...
InputDependencyQuery=options.InputDependencyQuery);
end
function taskResult = run(obj,input)
taskResult = padv.TaskResult;
taskResult.Status = padv.TaskStatus.Pass;
end
end
end
When you run a task, the build system runs the InputDependencyQuery to find any additional
dependencies that can affect whether task results are up-to-date.
11-25
11 Built-In Query Library
padv.builtin.query.GetIterationArtifact
This query returns the artifact that the task is iterating over.
Syntax
q = padv.builtin.query.GetIterationArtifact() gets the artifact that the task is iterating
over.
Use in Task
You can use this query in your custom tasks to find artifacts that your tasks can use as inputs
(InputQueries).
[email protected](options.Name,...
IterationQuery=options.IterationQuery,...
InputQueries=options.InputQueries,...
InputDependencyQuery=options.InputDependencyQuery);
end
function taskResult = run(obj,input)
taskResult = padv.TaskResult;
taskResult.Status = padv.TaskStatus.Pass;
end
end
end
When you run a task, the build system runs the InputQueries to find the inputs to the task.
11-26
padv.builtin.query.GetOutputsOfDependentTask
padv.builtin.query.GetOutputsOfDependentTask
This query returns the outputs from the predecessor task.
Syntax
q = padv.builtin.query.GetOutputsOfDependentTask() gets the outputs from the
predecessor task. You must define the predecessor task by using the function dependsOn on the task
objects.
Input Arguments
Name-Value Arguments
• Name — Unique identifier for query, specified as character vector or string. Example:
"CustomQuery"
Use in Task
You can use this query in your custom tasks to find artifacts that your tasks can use as inputs
(InputQueries).
...
options.InputQueries = [padv.builtin.query.GetIterationArtifact,...
padv.builtin.query.GetOutputsOfDependentTask(Task="padv.builtin.task.RunTestsPerTestCase")];
options.InputDependencyQuery = padv.builtin.query.GetDependentArtifacts;
...
When you run the Merge Test Results task, the build system runs this input query, which passes the
outputs of the Run Tests task as inputs to the Merge Test Results task.
Note Note that since the Merge Test Results task depends on data from the Run Tests task, the
default process model uses the dependsOn function to explicitly specify the dependency relationship
between the tasks.
11-27
11 Built-In Query Library
11-28