slreportgen.finder.AnnotationFinder class
Package: slreportgen.finder
Superclasses:
Find Simulink annotation objects
Description
Find annotation objects in a Simulink® or Stateflow® diagram.
Construction
creates a finder that finds by default all annotations in the specified diagram. To
constrain the search to specific types of annotations, use the properties of this
finder.finder
= AnnotationFinder(diagram
)
Note
This finder provides two ways to get search results:
To return the search results as an array, use the
find
method. Add the results directly to a report or process the results in afor
loop.To iterate through the results one at a time, use the
hasNext
andnext
methods in awhile
loop.
Neither option has a performance advantage.
sets properties using name-value pairs. You can specify multiple name-value pair
arguments in any order.finder
= AnnotationFinder(Name=Value
)
Input Arguments
Properties
Methods
finds annotations in
the results
= find(finder)diagram
specified by the finder. This method returns the
annotations it finds wrapped in result objects of type
slreportgen.finder.DiagramElementResult
. To add tables of the
annotation properties, add the results objects directly to the report or add them to a
reporter that you then add to a report. The reports to which you can add the
results
of this method must be reports of type
slreportgen.report.Report
.
tf = hasNext(finder)
determines if the diagram that the finder
searches contains at least one annotation. If the diagram has at least one annotation,
the hasNext
method queues that annotation as the next annotation that
the next
method will return. The hasNext
method then
returns true
. Use the next
method to obtain that
annotation. On subsequent calls, the hasNext
method determines if the
diagram has an annotation that the next
method has not yet retrieved.
It queues the annotation for the next
method to retrieve and returns
true
. If there are no more annotations to be retrieved, this
method returns false
. To search a diagram progressively for
annotations, use the hasNext
method with the next
method in a while loop.
result = next(finder)
returns the next search
result
in the result queue that the hasNext
method created. This method returns the annotation that it finds wrapped in a result
object of type slreportgen.finder.DiagramElementResult
. To add tables of
the annotation properties, add the results objects directly to the report or add them to
a reporter that you then add to a report. The reports to which you can add the
results
of this method must be of type
slreportgen.report.Report
.
Copy Semantics
Handle. To learn how handle classes affect copy operations, see Copying Objects.
Examples
Find Annotations in a Model
Create a report that finds annotations in the slrgex_sf_car
model.
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('Annotations in %s Model',model_name))); add(rpt,TableOfContents); diagFinder = SystemDiagramFinder(model_name); diagrams = find(diagFinder); while hasNext(diagFinder) diagram = next(diagFinder); annotFinder = AnnotationFinder(diagram.Object); annotations = find(annotFinder); if ~isempty(annotations) chapter = Chapter(Title=diagram.Name); add(chapter, diagram); sect = Section(Title="Annotations"); add(sect,annotations); add(chapter,sect); add(rpt,chapter); end end close(rpt); close_system(model_name); rptview(rpt);