slreportgen.finder.DiagramFinder Class
Namespace: slreportgen.finder
Create finder for diagrams
Description
Finds Simulink® diagrams and Stateflow® charts.
The slreportgen.finder.DiagramFinder
class is a handle
class.
Creation
Description
creates a finder that finds by default all uncommented Simulink block diagrams and Stateflow chart diagrams in the specified
finder
= DiagramFinder(container
)container
. To constrain the search to include specific
types of diagrams, use the properties of this finder.
Note
This finder can operate in either find or iterator mode. In find mode, use its find
method to return the results of a search as an array of results. In iterator mode, use its hasNext
and next
methods to return the results of a search one-by-one. When searching in models that have many model references, use iterator mode. Iterator mode closes a model after compiling and searching it, whereas find mode keeps all the models that it searches open. Having many open models can consume all system memory and slow report generation. Iterator mode is slower than find mode, so use find mode to search models that reference few or no other models.
sets properties using name-value pairs. You can specify multiple name-value
pair arguments in any order.finder
= DiagramFinder(Name=Value
)
Input Arguments
Container
— Model container to search
path | handle | chart ID | chart object
See Container property.
Properties
Container
— Model container to search
path | handle | chart ID | chart object
Model container in which to search, specified as one of these values:
Handle of a Simulink model, subsystem, or model block
Path to a Simulink model, subsystem, or model block
Handle of a Stateflow chart block
Path to a Stateflow chart block
Stateflow chart ID
Stateflow chart object
SearchDepth
— Depth of system diagram search
inf
(default) | positive integer
Depth of system diagram search, specified as inf
or a positive integer. SearchDepth
specifies how many levels deep to search a diagram container for diagrams. To search all levels, use inf
.
IncludeMaskedSubsystems
— Search masked subsystems
true
(default) | false
Choice to search masked subsystems, specified as a logical. If this property is
true
, the finder searches masked Subsystem blocks
in the diagram container. It searches to the specified SearchDepth
and includes the diagrams it finds in the search results.
IncludeReferencedModels
— Search model references
true
(default) | false
Choice to search referenced models, specified as a logical. If this property is
true
, the finder searches models referenced in the diagram
container. It searches to the specified SearchDepth
and includes
the diagrams it finds in the search results.
IncludeReferencedSubsystems
— Whether to search for referenced subsystems
true
or 1
(default) | false
or 0
Whether to search for referenced subsystems, specified as numeric or
logical 1
(true
) or
0
(false
). Results indicate the
source subsystem block rather than individual occurrences of the referenced
subsystem block. Therefore, a single subsystem that is referenced multiple
times has only one result.
IncludeSimulinkLibraryLinks
— Search Simulink library links
true
(default) | false
Choice to search Simulink library links, specified as a logical. If both this property and
IncludeMaskedSubsystems
are true
, the finder
searches links in the diagram container to both Subsystem and masked Subsystem blocks in
Simulink libraries. It searches to the specified SearchDepth
and includes the diagrams it finds in the search results. If this property is
true
, but IncludeMaskedSubsystems
is
false
, the finder searches only links to Subsystem blocks in
Simulink libraries.
IncludeUserLibraryLinks
— Search user library links
true
(default) | false
Choice to search user library links, specified as a logical. If this property is
true
and the IncludeMaskedSubsystems
property is true
, the finder searches links in the diagram container
to Subsystem and masked Subsystem blocks in user libraries. It searches to the specified
SearchDepth
and includes the diagrams it finds in the search
results. If this property is true
, but the
IncludeMaskedSubsystems
property is false
,
the finder searches only links to Subsystem blocks in user libraries.
IncludeCommented
— Include commented-out diagrams
false
(default) | true
Whether to include commented-out diagrams in the search results, specified
as a logical. If false
, commented-out diagrams are
excluded from the search results.
IncludeVariants
— Include diagram variants
string | character vector
Variants to search for diagrams, specified as a string or character vector. The default value
is Active
. Valid values are:
All
— All variantsActive
— Only active variantsActivePlusCode
— All active variants and code variants
SortType
— Sort finder results
"none"
(default) | "alphabetical"
| "numBlocks"
| "depth"
Sort finder results, specified as one of these values:
Value | Description |
---|---|
"none" | Do not sort results. |
"alphabetical" | Sort results alphabetically by name. |
"numBlocks" | Sort results by number of blocks in the system. The first block in the sorted list contains the highest number of blocks. |
"depth" | Sort results by depth in the model hierarchy. The first
system in the sorted list is the system that is highest in
the hierarchy. For example, a model and its subsystems are
sorted in the order: myModel ,
myModel/subsystem1 ,
myModel/subsystem1/nestedSubststem . |
Properties
— Properties of objects to find
cell array
Properties of objects to find, specified as a cell array of name-value pairs. The finder returns only objects that have the specified properties with the specified values.
Example: finder.Properties = {'Gain','5'}
AutoCloseModel
— Whether to close models
true
(default) | false
Whether to close models, specified as true
or false
. If true
, the next
method of the finder closes the currently open model before moving to the next model to search. Closing models prevents excessive consumption of memory when searching a model that references many models.
Note
The find
method of the finder ignores this property and leaves all referenced models open. For this reason, you should not use the find method to search models with many model references.
Data Types: logical
Methods
Public Methods
find |
Note The
|
hasNext |
Note If the current result is the last result in the search
queue for the current model and the
|
next |
|
Examples
Find All Block Diagrams and Stateflow Charts
Create a report that includes an image of all diagrams in the sf_car
model. Although the model used in this example does not contain model references, the example uses iterator mode to illustrate its syntax.
import mlreportgen.report.* import slreportgen.report.* import slreportgen.finder.* model_name = "sf_car"; load_system(model_name); rpt = slreportgen.report.Report("output","pdf"); add(rpt, TitlePage(Title=model_name+" Systems")); finder = DiagramFinder(model_name); while hasNext(finder) add(rpt,next(finder)); end close(rpt); close_system(model_name); rptview(rpt);
Find All Diagrams in a Subsystem
Open the sf_car
model and find all the diagrams in its Engine
subsystem. Use either the path to the subsystem or its handle. You can then include the results in your report.
import mlreportgen.report.* import slreportgen.report.* import slreportgen.finder.* model_name = "sf_car"; load_system(model_name); % Use path enginePath = "sf_car/Engine"; finder = slreportgen.finder.DiagramFinder(enginePath); results = find(finder); % or use handle engineHandle = get_param("sf_car/Engine","Handle"); finder = slreportgen.finder.DiagramFinder(engineHandle); results_enginehandle = find(finder);
Find Diagram Elements with Specific Property Value
To find elements with specific property values, use an object
of the slreportgen.finder.DiagramElementFinder
class. Open the
f14
model and find all Gain blocks with a
value of Zw
.
model = 'f14'; openExample(model); finder = slreportgen.finder.DiagramElementFinder(model) finder.Properties = {'Gain','Zw'}; results = find(finder);
Version History
Introduced in R2017b
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
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)