Main Content

slreportgen.finder.StateFinder class

Package: slreportgen.finder

Find Stateflow states

Description

Finds Stateflow® states.

The slreportgen.finder.StateFinder class is a handle class.

Creation

Description

example

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 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 a for loop.

  • To iterate through the results one at a time, use the hasNext and next methods in a while loop.

Neither option has a performance advantage.

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

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.

Number of levels to search Container, specified as one of these values:

ValueDescription
[] (default)

Search only for elements visible from the top level of the chart. The search includes elements in nested states but excludes elements in subcharts.

nonnegative integer

Search the specified number of levels

inf

Search all levels

Sorting method for finder results, specified as one of these values:

ValueDescription
"none"Do not sort results.
"alphabetical"Sort results alphabetically by name.
"systemAlpha"Sort results alphabetically by parent system name.
"depth"Sort results by depth in the model hierarchy. The first result in the sorted list belongs to the object that is highest in the hierarchy. For example, a model and its subsystems are sorted in the order: myModel, myModel/subsystem1, myModel/subsystem1/nestedSubststem.

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

expand all

Examples

collapse all

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

Run the following command to access the supporting files used in this example.

openExample('rptgenext/SimulinkReportGeneratorFilesExample');
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)

Version History

Introduced in R2017b