slreportgen.finder.DiagramFinder class
Package: slreportgen.finder
Superclasses:
Create finder for diagrams
Description
Finds Simulink® diagrams and Stateflow® charts.
Construction
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
Properties
Methods
results = find(finder)
finds diagrams in the specified
container
. The finder
is an
slreportgen.finder.DiagramFinder
object. results
is an array of slreportgen.finder.DiagramResult
objects, each of which
contains a diagram found by this method. Adding this array to a report or a reporter
adds images of all the diagrams that it contains. The reports to which you can add the
results
of this method are reports of type
slreportgen.report.Report
or another reporter object, such as an
slreportgen.report.Chapter
reporter.
Note
The find
method opens and compiles a top-level model and all
models it references. This method leaves all the models open at the conclusion
of a search, which can slow reporting on models that contain many model
references. To avoid this slowdown, use the hasNext
and
next
methods to search such a model.
tf = hasNext(finder)
determines if the container that the finder
searches contains at least one diagram. If the container has at least one diagram, the
hasNext
method queues that diagram as the next diagram that the
next
method will return. The hasNext
method then
returns true
. Use the next
method to obtain that
diagram. On subsequent calls, the hasNext
method determines if the
container has a diagram that the next
has not yet retrieved. It queues
the diagram for the next
method to retrieve and returns
true
. If there are no more diagrams to be retrieved, this method
returns false
. To search a container progressively for diagrams, use
the hasNext
method with the next
method in a while loop.
Note
If the current result is the last result in the search queue for the current
model and the AutoCloseModel
property is
true
, this method closes the current model before it
opens the next model. Although this increases search time, it reduces memory
consumption when searching a top model that references many other models. If
your model does not reference many other models, to speed up the search, set the
AutoCloseModel
property to false
or
use the find
method.
result = next(finder)
returns the next search
result
in the result queue that the hasNext
method created. The search result contains the resulting diagram. Adding this
result
object to a report or reporter adds a Diagram reporter
for the diagram.
Copy Semantics
Handle. To learn how handle classes affect copy operations, see Copying Objects.
Examples
Find All Block Diagrams and Stateflow Charts
Create a report that includes an image of all diagrams in the
slrgex_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 = 'slrgex_sf_car'; load_system(model_name); rpt = slreportgen.report.Report('output','pdf'); add(rpt, TitlePage(Title=sprintf('%s Systems',model_name))); 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 slrgex_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.
slrgex_sf_car % Use path enginePath = "slrgex_sf_car/Engine"; finder = slreportgen.finder.DiagramFinder(enginePath); results = find(finder); % or use handle engineHandle = get_param("slrgex_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'; load_system(model); finder = slreportgen.finder.DiagramElementFinder(model) finder.Properties = {'Gain','Zw'}; results = find(finder);