Find Stateflow diagram elements
StateflowDiagramElementFinder creates a finder object that finds
elements in a Stateflow® chart diagram.
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 = DiagramElementFinder(
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 = DiagramElementFinder(
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
Types— Types of diagram elements to find
Types of Stateflowdiagram elements to find, specified as a string, character
array, array of strings, or a cell array of character arrays. If the type is
an array, it specifies a set of element types. The default is
all, which finds all
elements in all diagrams. Use one of these values to constrain the search to
specific diagram element types. You can use either the fully qualified name
or the short name.
|Fully Qualified Name||Short Name|
IncludeCommented— Include commented-out chart elements
Whether to include commented-out chart elements in the search results,
specified as a logical. If
false, commented-out elements
are excluded from the search results.
Properties— Properties of elements to find
Properties of objects to find, specified as a cell array of name-value pairs. The finder returns only elements that have the specified properties with the specified values.
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
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 element. If the chart diagram has at least one
hasNext method queues that element as the next element
next method will return. The
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
true. If there are no more elements to be retrieved, this
false. To search a chart diagram progressively for
elements, use the
hasNext method with the
result = next(finder) returns the next search
result in the result queue that the
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
Handle. To learn how handle classes affect copy operations, see Copying Objects (MATLAB).
Create a report that finds Stateflow states and transitions in the
import slreportgen.report.* import slreportgen.finder.* model_name = 'fuelsys'; 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); for while hasNext(chartFinder) chart = next(chartFinder); chapter = Chapter("Title",chart.Name); add(chapter, chart); sect = Section("Title","States"); stateFinder = StateFinder("Container",chart.Object, ... "Types", "state"); states = find(stateFinder,chart.Object); for state = states add(sect,state); end add(chapter,sect); sect = Section("Title","Transitions"); transitionFinder = StateflowDiagramElementFinder("Content", 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);