padv.builtin.task.FindClones Class
Namespace: padv.builtin.task
Superclasses: padv.Task
Task for detecting identical modeling patterns using Clone Detector
Description
This class requires CI/CD Automation for Simulink Check.
The padv.builtin.task.FindClones
class provides tasks that can identify
clones in a model. Clones are modeling patterns with identical block types and connections. By
default, it creates separate tasks to find clones across model and to find clones using the
library in the Process Advisor app.
When task provided by the class detects clones in the model, it generates a clone detection
report in HTML format and saves the clone detection results in MAT files for further
analysis.
You can add the task to your process model by using the
method addTask
. After you add the task to your process model, you can run the
task from the Process Advisor app or by using the function runprocess
.
To view the source code for this built-in task, in the MATLAB® Command Window, enter:
open padv.builtin.task.FindClones
Note
Generation of the clone detection report is supported in Simulink® versions R2023b or later.
The padv.builtin.task.FindClones
class is a handle
class.
Creation
Description
creates
tasks for detecting identical modeling patterns using Clone Detector.task
= padv.builtin.task.FindClones
sets certain properties using one or more name-value arguments. For example, task
= padv.builtin.task.FindClones(Name=Value
)task
= padv.builtin.task.FindClones(Name="MyFindClonesTask")
creates a task with
the specified name.
You can use this syntax to set property values for Name
,
Title
, InputQueries
,
InputDependencyQuery
, IterationQuery
,
LaunchToolAction
, and LaunchToolText
.
The padv.builtin.task.FindClones
class also has other properties, but you cannot set
those properties during task creation.
Properties
The FindClones
class inherits properties from padv.Task
. The properties listed in
Specialized Inherited Properties are padv.Task
properties that the FindClones
task overrides.
The task also has properties for specifying Find Clone Options for specifying the clone detection task settings.
Specialized Inherited PropertiesName
— Unique identifier for task in process
"padv.builtin.task.FindClones"
(default) | string
Unique identifier for the task in the process, specified as a string.
Example: "MyFindClonesTask"
Data Types: string
Title
— Human-readable name that appears in Process Advisor app
"Find Clones"
(default) | "Find Clones Across Model"
| "Find Library Clones"
| string
Human-readable name that appears in the Process Advisor app, specified as a string.
Example: "My Find Clones Task"
Data Types: string
DescriptionText
— Task description
"This task uses Clone Detector to detect clone patterns in your models."
(default) | string
Task description, specified as a string.
When you point to a task in Process Advisor and click the information icon, the tooltip shows the task description.
Example: "This task identifies clones in your
models."
Data Types: string
DescriptionCSH
— Path to task documentation
path to FindClones
documentation (default) | string
Path to task documentation, specified as a string.
When you point to a task in Process Advisor, click the ellipsis (...), and click Help, Process Advisor opens the task documentation.
Example: fullfile(pwd,"taskHelpFiles","myTaskDocumentation.pdf")
Data Types: string
InputQueries
— Inputs to task
padv.builtin.query.FindArtifacts('ArtifactType','sl_library_file')
(default) | padv.Query
object | name of padv.Query
object | array of padv.Query
objects
Inputs to the task, specified as:
a
padv.Query
objectthe name of a
padv.Query
objectan array of
padv.Query
objectsan array of names of
padv.Query
objects
By default, the task FindClones
gets the current model that the task
is iterating over by using these built-in queries:
padv.builtin.query.GetIterationArtifact
padv.builtin.query.FindArtifacts
on the taskpadv.builtin.task.FindClones
.
InputDependencyQuery
— Query that finds artifact dependencies for task inputs
padv.builtin.query.FindArtifacts
(default) | padv.Query
object | name of padv.Query
object
Query that finds artifact dependencies for task inputs, specified as a
padv.Query
object or the name of a padv.Query
object.
The build system runs the query specified by
InputDependencyQuery
to find the dependencies for the task
inputs, since those dependencies can impact if task results are up to date.
For more information about task inputs, see Overview of Process Model.
Example: padv.builtin.query.FindArtifacts
IterationQuery
— Query that find artifacts that task iterates over
padv.builtin.query.FindModels
(default) | padv.Query
object | name of padv.Query
object
Query that finds the artifacts that the task iterates over, specified as a
padv.Query
object or the name of a padv.Query
object. When you specify IterationQuery
, the task runs one time
for each artifact returned by the query. In the Process
Advisor app, the artifacts returned by IterationQuery
appear under the task title.
For more information about task iterations, see Overview of Process Model.
Example: padv.builtin.query.FindProjectFile
LaunchToolAction
— Function that launches tool
@launchToolAction
(default) | function handle
Function that launches a tool, specified as the function handle.
When you point to a task in the Process Advisor app, you can click the ellipsis (...) to see more options. For built-in tasks, you have the option to launch a tool associated with the task.
By default, the task FindClones
launches the Clone Detector
app.
Data Types: function_handle
LaunchToolText
— Description of action that LaunchToolAction
property performs
"Open Find Clones Options"
(default) | string
Description of the action that the LaunchToolAction
property
performs, specified as a string.
Data Types: string
RequiredIterationArtifactType
— Artifact type that task can run on
"sl_model_file"
(default) | ...
Type of artifact, specified as one or more of the values listed in this table. To specify multiple values, use an array.
Category | Artifact Type | Description |
---|---|---|
MATLAB | "m_class" | MATLAB class |
"m_file" | MATLAB file | |
"m_func" | MATLAB function | |
"m_method" | MATLAB class method | |
"m_property" | MATLAB class property | |
Model Advisor | "ma_config_file" | Model Advisor configuration file |
"ma_justification_file" | Model Advisor justification file | |
Process Advisor | "padv_dep_artifacts" | Related artifacts that current artifact depends on |
"padv_output_file" | Process Advisor output file | |
Project | "project" | Current project file |
Requirements | "mwreq_item" | Requirement (since R2024b) |
| Requirement (for R2024a and earlier) | |
"sl_req_file" | Requirement file | |
"sl_req_table" | Requirements Table | |
Stateflow® | "sf_chart" | Stateflow chart |
"sf_graphical_fcn" | Stateflow graphical function | |
"sf_group" | Stateflow group | |
"sf_state" | Stateflow state | |
"sf_state_transition_chart" | Stateflow state transition chart | |
"sf_truth_table" | Stateflow truth table | |
Simulink | "sl_block_diagram" | Block diagram |
"sl_data_dictionary_file" | Data dictionary file | |
"sl_embedded_matlab_fcn" | MATLAB function | |
"sl_block_diagram" | Block diagram | |
"sl_library_file" | Library file | |
"sl_model_file" | Simulink model file | |
"sl_protected_model_file" | Protected Simulink model file | |
"sl_subsystem" | Subsystem | |
"sl_subsystem_file" | Subsystem file | |
System Composer™ | "zc_block_diagram" | System Composer architecture |
"zc_component" | System Composer architecture component | |
"zc_file" | System Composer architecture file | |
Tests | "harness_info_file" | Harness info file |
"sl_harness_block_diagram" | Harness block diagram | |
"sl_harness_file" | Test harness file | |
"sl_test_case" | Simulink Test™ case | |
"sl_test_case_result" | Simulink Test case result | |
"sl_test_file" | Simulink Test file | |
"sl_test_iteration" | Simulink Test iteration | |
"sl_test_iteration_result" | Simulink Test iteration result | |
"sl_test_report_file" | Simulink Test result report | |
"sl_test_result_file" | Simulink Test result file | |
"sl_test_resultset" | Simulink Test result set | |
"sl_test_seq" | Test Sequence | |
"sl_test_suite" | Simulink Test suite | |
"sl_test_suite_result" | Simulink Test suite result |
Example: "sl_model_file"
Example: ["sl_model_file", "zc_file"]
OutputDirectory
— Location for standard task outputs
fullfile('$DEFAULTOUTPUTDIR$','$ITERATIONARTIFACT$','find_clones')
(default) | string
Location for standard task outputs, specified as a string.
The built-in tasks use tokens, such as $DEFAULTOUTPUTDIR$
, as
placeholders for dynamic path resolution during run time. For more information, see
Dynamically Resolve Paths with Tokens.
Data Types: string
ReportPath
— Path to generated report
fullfile('$DEFAULTOUTPUTDIR$','$ITERATIONARTIFACT$','find_clones')
(default) | string
Path to the generated report, specified as a string.
The built-in tasks use tokens, such as $DEFAULTOUTPUTDIR$
, as
placeholders for dynamic path resolution during run time. For more information, see
Dynamically Resolve Paths with Tokens.
Data Types: string
DetectLibraryClones
— Option to detect clones from library
true
or 1
(default) | false
or 0
Option to detect clones from all the libraries in the project, specified as a
numeric or logical 1
(true
) or
0
(false
).
Example: true
Data Types: logical
TreatLibraryClonesAs
— Outcome of library clone detection task
"Failure"
(default) | "Warning"
Outcome when library clone detection task finds a clone, specified as
"Failure"
or "Warning"
.
Example: "Warning"
LibraryReportName
— File name for generated library clone detection report
"$ITERATIONARTIFACT$_LibraryClonesReport"
(default) | string
File name for the generated library clone detection report, specified as a string.
The built-in tasks use tokens, such as $ITERATIONARTIFACT$
, as
placeholders for dynamic path resolution during run time. For more information, see
Dynamically Resolve Paths with Tokens.
Example: "myLibraryCloneDetectionReport"
Data Types: string
LibraryResultFilename
— MATLAB file name for generated library clone detection results
"$ITERATIONARTIFACT$_LibraryResults.mat"
(default) | string
MATLAB file name for the generated library clone detection results, specified as a string.
The built-in tasks use tokens, such as $ITERATIONARTIFACT$
, as
placeholders for dynamic path resolution during run time. For more information, see
Dynamically Resolve Paths with Tokens.
Example: "myLibraryCloneDetectionResults.mat"
Data Types: string
DetectClonesAcrossModel
— Option to detect clones across model
true
or 1
(default) | false
or 0
Option to detect clones across model, specified as a numeric or logical
1
(true
) or 0
(false
).
Example: true
Data Types: logical
TreatAcrossModelClonesAs
— Outcome of detection of clones across model task
"Warning"
(default) | "Failure"
Outcome when detection of clones across model task finds a clone, specified as
"Failure"
or "Warning"
.
The built-in tasks use tokens, such as $ITERATIONARTIFACT$
, as
placeholders for dynamic path resolution during run time. For more information, see
Dynamically Resolve Paths with Tokens.
Example: "Warning"
AcrossModelReportName
— File name for generated detection of clones across model report
"$ITERATIONARTIFACT$_AcrossModelClonesReport"
(default) | string
File name for the generated detection of clones across model report, specified as a string.
The built-in tasks use tokens, such as $ITERATIONARTIFACT$
, as
placeholders for dynamic path resolution during run time. For more information, see
Dynamically Resolve Paths with Tokens.
Example: "myAcrossModelClonesReport"
Data Types: string
AcrossModelResultFilename
— MATLAB file name for generated detection of clones across model results
"$ITERATIONARTIFACT$_AcrossModelResults.mat"
(default) | string
MATLAB file name for the generated detection of clones across model results, specified as a string.
Example: "myAcrossModelClonesResults.mat"
Data Types: string
MinimumRegionSize
— Minimum number of blocks
4
(default) | uint32
Minimum number of blocks in a region required to consider a pattern as a clone,
specified as a uint32
integer.
This property applies only when DetectClonesAcrossModel
is
true
.
Example: 10
Data Types: uint32
MinimumCloneGroupSize
— Minimum number of clone pattern occurrences
3
(default) | uint32
Minimum number of clone pattern occurrences required to consider a pattern as a
clone group, specified as a uint32
integer.
This property applies only when DetectClonesAcrossModel
is
true
.
Example: 5
Data Types: uint32
Methods
Specialized Public Methods
This class overrides the following inherited methods.
run | Find clones using Clone Detector app. Note You do not need to manually invoke this method. When you run a task using
the Process
Advisor app or the
The function taskResult = run(obj, input) ... end |
dryRun |
Dry run the task to validate task inputs and generate
representative task outputs without actually running the task. The function taskResult = dryRun(obj, input) ... end |
launchToolAction | Launch the Clone Detector app. Process Advisor uses this method when you open the tool associated with a task. |
Examples
Add Find Clones Task to Process
Add a task that can identify clones for the models in your project.
Open the process model for your project. If you do not have a process model, open the Process Advisor app to automatically create a process model.
In the process model file, add the FindClones
task to your process
model by calling the addTask
method on the
padv.ProcessModel
object pm
.
findclonesTask = pm.addTask(padv.builtin.task.FindClones);
You can reconfigure the task behavior by using the task properties. For example, to
change the size of minimum number of blocks in a region required to consider a pattern
as a clone, set the task property
MinimumRegionSize
.
findclonesTask.MinimumRegionSize = "7";
When the task identifies clones in the model, it saves the clone data in the MAT
files ITERATIONARTIFACT_LibraryResults.mat
and
ITERATIONARTIFACT_AcrossModelResults.mat
,
where ITERATIONARTIFACT
is the input artifact
for the task, inside the folder OutputDirectory
. The clone
information in these MAT files is similar to the
Simulink.CloneDetection.Results
object, which you can use to
analyze the results of the FindClones
task.
The task also creates another MAT file in the folder
m2m_ITERATIONARTIFACT
in the folder
OutputDirectory
. To highlight the clones in the model, navigate to
the OutputDirectory
folder that contains the folder
m2m_ITERATIONARTIFACT
and then open the
Clone Detector app from the Process Advisor app. Clone
Detector app uses the MAT file from this folder to highlight the clones. You can
highlight a particular clone in the model by clicking on the hyperlinks in the
Clone Detector app.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)