slreportgen.finder.StateflowDiagramElementFinder class
Package: slreportgen.finder
Superclasses:
Find Stateflow diagram elements
Description
StateflowDiagramElementFinder
creates a finder object that finds
elements in a Stateflow® chart diagram.
Construction
creates a finder that finds elements of a Stateflow chart diagram. By default this finder finds states, transitions, truth
tables, and other elements in the specified Stateflow chart diagram. Use the properties of the finder to constrain the search to
specific types of elements. finder
= StateflowDiagramElementFinder(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
= StateflowDiagramElementFinder(Name=Value
)
Input Arguments
Properties
Methods
finds Stateflow chart diagram elements in the results
= find(finder)diagram
specified by
the finder. This method returns the chart diagram elements it finds wrapped in result
objects of type slreportgen.finder.DiagramElementResult
. To add tables of
the chart diagram element 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 chart diagram that the
finder searches contains at least one element. If the chart diagram has at least one
element, the hasNext
method queues that element as the next element
that the next
method will return. The hasNext
method
then returns true
. Use the next
method to obtain
that element. On subsequent calls, the hasNext
method determines if the
chart diagram has an element that the next
method has not yet
retrieved. It queues the element for the next
method to retrieve and
returns true
. If there are no more elements to be retrieved, this
method returns false
. To search a chart diagram progressively for
elements, 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 chart diagram element that it finds wrapped in a
result object of type slreportgen.finder.DiagramElementResult
. To add
tables of the chart diagram element 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 Stateflow States and Transitions
Create a report that finds Stateflow states and transitions in the
slrgex_fuelsys_fuel_rate_control
model.
import mlreportgen.report.* import slreportgen.report.* import slreportgen.finder.* model_name = "slrgex_fuelsys_fuel_rate_control"; load_system(model_name) rpt = slreportgen.report.Report("output","pdf"); add(rpt, TitlePage(Title=sprintf("%s Charts",model_name))) add(rpt, TableOfContents) chartFinder = ChartDiagramFinder(model_name); while hasNext(chartFinder) chart = next(chartFinder); chapter = Chapter(Title=chart.Name); add(chapter, chart) sect = Section(Title="States"); stateFinder = StateFinder(chart.Object); states = find(stateFinder); for state = states add(sect,state) end add(chapter,sect) sect = Section(Title="Transitions"); transitionFinder = StateflowDiagramElementFinder... (Container=chart.Object,Types="transition"); transitions = find(transitionFinder); for transition = transitions add(sect,transition) end add(chapter,sect) add(rpt, chapter) end close(rpt); close_system(model_name); rptview(rpt)