Main Content

slreportgen.finder.StateflowDiagramElementFinder class

Package: slreportgen.finder
Superclasses: slreportgen.finder.StateflowObjectFinder

Find Stateflow diagram elements

Description

StateflowDiagramElementFinder creates a finder object that finds elements in a Stateflow® chart diagram.

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

Creation

Description

example

finder = StateflowDiagramElementFinder(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.

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 = StateflowDiagramElementFinder(Name=Value) sets properties using name-value arguments. You can specify multiple name-value 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

  • Stateflow

    state object

  • Path or handle to a Simulink® model

  • Finder result representing a model, chart, or state

Types of Stateflow diagram 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 or 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 NameShort Name
Allall
Stateflow.Annotationannotation
Stateflow.Boxbox
Stateflow.EMFunctionemfunction
Stateflow.Functionfunction
Stateflow.Junctionjunction
Stateflow.Portport
Stateflow.SLFunctionslfunction
Stateflow.Statestate
Stateflow.Transitiontransition
Stateflow.TruthTabletruthtable

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.

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

Sort 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 belong to the object that is highest in the hierarchy. For example, a model and its subsystems are sorted in the order: myModel/block1, myModel/subsystem1/block2, myModel/subsystem1/nestedSubststem/block3.

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.

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

Methods

expand all

Examples

collapse all

Create a report that finds Stateflow states and transitions in the slrgex_fuelsys_fuel_rate_control 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_fuelsys_fuel_rate_control";
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);
while hasNext(chartFinder)
    chart = next(chartFinder);
    chapter = Chapter(Title=chart.Name);
    add(chapter, chart)
    sect = Section(Title="States");
    stateFinder = StateFinder(chart.Object);
    states = find(stateFinder);
    for state = states
        add(sect,state)
    end  
    add(chapter,sect)

    sect = Section(Title="Transitions");
    transitionFinder = StateflowDiagramElementFinder...
       (Container=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)

Version History

Introduced in R2017b