Finds Stateflow® states.
creates a finder that finds by default all uncommented Stateflow states in the specified chart
finder = StateFinder(
diagram. To constrain
the search to specific types of chart diagrams, use the properties of this
This finder has two ways to find objects — find mode and iterator mode. In find mode, use
find method to return the results of a search as an array of results.
Then, use a for loop to process the results. In iterator mode, use its
next methods to return the results of a
search one at a time. Using these iterator methods, use a while loop to process the results.
Neither of these methods has a performance advantage over the other, so use either mode
depending on whether you prefer while or for loops.
sets properties using name-value pairs. You can specify multiple name-value pair
arguments in any order. Enclose each property name in single quotes.
finder = StateFinder(
Container— Chart diagram to search
Chart diagram in which to search, specified as one of these values:
Handle to a Stateflow chart block
Path to a Stateflow chart block
Stateflow chart ID
Stateflow chart object
IncludeCommented— Include commented-out states
Choice to include commented-out states in the search results, specified as
a logical. If
false, commented-out states are excluded
from the search results.
Properties— Properties of states to find
Properties of states to find, specified as a cell array of name-value pairs. The finder returns only states that have the specified properties with the specified values.
finds states in the
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
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
hasNext method queues that state as the next state that the
next method will return. The
hasNext method then
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
false. To search a chart diagram progressively for states,
hasNext method with the
next method in a
result = next(finder) returns the next search
result in the result queue that the
method created. This method returns the state that it finds wrapped in a result object
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
Handle. To learn how handle classes affect copy operations, see Copying Objects (MATLAB).
Create a report that includes properties of all the Stateflow states in the
shift_logic chart of the
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",... 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); sect = Section("Title","States"); add(sect,states); add(chapter,sect); add(rpt,chapter); end end close(rpt); close_system(model_name); rptview(rpt);