Main Content

slreportgen.finder.StateflowDiagramElementFinder class

Package: slreportgen.finder

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:

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

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

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

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.

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