Documentation

slreportgen.finder.StateFinder class

Package: slreportgen.finder
Superclasses:

Find Stateflowstates

Description

Finds Stateflow® states.

Construction

finder = StateFinder(diagram) creates a finder that finds by default all uncommented Stateflow states in the specified chart diagram. To constrain the search to specific types of chart diagrams, use the properties of this finder.

Note

This finder has two ways to find objects — find mode and iterator mode. In find mode, use its 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 hasNext and 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.

finder = StateFinder(Name,Value) sets properties using name-value pairs. You can specify multiple name-value pair arguments in any order. Enclose each property name in single quotes.

Input Arguments

expand all

See Container property.

Properties

expand all

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

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 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.

Example: finder.Properties = {'ArrowSize','5'}

Methods

results = find(finder) finds states in the chart 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 (MATLAB).

Examples

Find Stateflow States

Create a report that includes properties of all the Stateflow states in the shift_logic chart of the sf_car model.

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);

Introduced in R2017b

Was this topic helpful?