slreportgen.finder.StateFinder class
Package: slreportgen.finder
Superclasses:
Find Stateflow states
Description
Finds Stateflow® states.
Construction
creates a finder that finds by default all uncommented Stateflow states in the specified chart finder
= StateFinder(diagram
)diagram
. To constrain
the search to specific types of chart diagrams, use the properties of this
finder.
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
= StateFinder(Name=Value
)
Input Arguments
Properties
Methods
finds states in the
chart results
= find(finder)diagram
specified by the finder. This method returns the
states it finds wrapped in result objects of type
slreportgen.finder.DiagramElementResult
. To add tables of the state
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 state. If the chart diagram has at least one
state, the hasNext
method queues that state as the next state that the
next
method will return. The hasNext
method then
returns true
. Use the next
method to obtain that
state. On subsequent calls, the hasNext
method determines if the chart
diagram has a state that the next
method has not yet retrieved. It
queues the state for the next
method to retrieve and returns
true
. If there are no more states to be retrieved, this method
returns false
. To search a chart diagram progressively for states,
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 state that it finds wrapped in a result object
of type slreportgen.finder.DiagramElementResult
. To add tables of the
state 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
Create a report that includes properties of all the Stateflow states in the shift_logic
chart of 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"); open(rpt) add(rpt, TitlePage(Title=sprintf('States in %s Model',model_name))); add(rpt, TableOfContents); chartFinder = ChartDiagramFinder(model_name); charts = find(chartFinder); while hasNext(chartFinder) diagram = next(chartFinder); stFinder = StateFinder(diagram.Object); states = find(stFinder); if ~isempty(states) chapter = Chapter(Title=diagram.Name); add(chapter,diagram) for state = states sect = Section(Title="States"); add(sect,states) end add(chapter,sect) add(rpt,chapter) end end close(rpt) close_system(model_name) rptview(rpt)