Main Content

slreportgen.finder.StateflowObjectFinder Class

Namespace: slreportgen.finder
Superclasses: mlreportgen.finder.Result

Find Stateflow objects

Since R2023a

Description

Use objects of the slreportgen.finder.StateflowObjectFinder class to find objects in a Stateflow® chart diagram. You can use these objects to search for:

  • Path or handle to a Simulink® model

  • Path or handle to a Stateflow chart block

  • Stateflow.Chart objects

  • Stateflow.State objects

  • Stateflow.Machine objects

  • slreportgen.finder.StateflowObjectFinder objects that represent a model, Stateflow chart, Stateflow state, or Stateflow machine object

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

Creation

Description

finder = StateflowObjectFinder(diagram) creates a Stateflow object finder object. Use the properties of the finder to constrain the search to specific types of objects.

Note

This finder provides these options 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.

example

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

Properties

expand all

Chart diagram in which to search, specified as one of these values:

  • Path or handle to a Simulink model

  • Path or handle to a Stateflow chart block

  • Stateflow.Chart objects

  • Stateflow.State objects

  • Stateflow.Machine objects

  • slreportgen.finder.StateflowObjectFinder objects that represent a model, Stateflow chart, Stateflow state, or Stateflow machine object

Types of Stateflow diagram objects to find, specified as a string, character array, array of strings, or a cell array of character arrays that contain either these fully qualified or short names in this table:

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
Stateflow.Datadata
Stateflow.Eventevent

If the type is an array, it specifies a set of element types. The default is All or all, which finds all objects in all diagrams. Use one of these values to constrain the search to specific diagram object types.

Whether to include commented-out chart objects in the search results, specified as a logical. If false, commented-out objects are excluded from the search results.

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

ValueDescription
1 (default)

Search only for objects visible from the top level of the chart. The search includes objects in nested states but excludes objects 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 object in the sorted list is 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 objects to find, specified as a cell array of name-value pairs. The finder returns only objects 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 data and events in the shift_logic Stateflow chart within the sf_car model.

First, import the report API namespaces so that you do not have to use long fully qualified class names.

import mlreportgen.report.*
import slreportgen.report.*
import slreportgen.finder.*

Load your Simulink model and create a PDF report.

model_name = "sf_car";
load_system(model_name);
 
rpt = slreportgen.report.Report("output","pdf");

Find all data and events in the shift_logic chart.

objFinder = StateflowObjectFinder("sf_car/shift_logic");
objFinder.Types = ["data", "event"];
results = find(objFinder);

Add the results to your report.

append(rpt,results);

Close the model and view your report.

close(rpt);
close_system(model_name);
rptview(rpt);

Version History

Introduced in R2023a