Main Content

slreportgen.finder.AnnotationFinder class

Package: slreportgen.finder

Find Simulink annotation objects

Description

Find annotation objects in a Simulink® or Stateflow® diagram.

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

Creation

Description

example

finder = AnnotationFinder(diagram) creates a finder that finds by default all annotations in the specified diagram. To constrain the search to specific types of annotations, 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 = AnnotationFinder(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

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

  • Handle to a Simulink block

  • Path to a Simulink block

  • Handle to a Stateflow chart block

  • Path to a Stateflow chart block

  • Stateflow chart ID

  • Stateflow chart object

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 system that is highest in the hierarchy. For example, a model and its subsystems are sorted in the order: myModel, myModel/subsystem1, myModel/subsystem1/nestedSubststem.

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

ValueDescription
[] (default)
  • If Container is a block diagram, search only the top level of the diagram.

  • If Container is a Stateflow chart, 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 objects that have the specified properties with the specified values.

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

Methods

expand all

Examples

collapse all

Create a report that finds annotations in 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");
add(rpt,TitlePage(...
            Title=sprintf("Annotations in %s Model",model_name)));
add(rpt,TableOfContents);

diagFinder = SystemDiagramFinder(model_name);
diagrams = find(diagFinder);
while hasNext(diagFinder)
    diagram = next(diagFinder);
    annotFinder = AnnotationFinder(diagram.Object);
    annotations = find(annotFinder);
    if ~isempty(annotations)
        chapter = Chapter(Title=diagram.Name);
        add(chapter, diagram);
        sect = Section(Title="Annotations");       
        add(sect,annotations);
        add(chapter,sect);
        add(rpt,chapter);
    end
end

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

Version History

Introduced in R2017b