Main Content

slreportgen.finder.DiagramElementResult class

Package: slreportgen.finder
Superclasses: mlreportgen.finder.Result

Create diagram element finder result object

Description

Diagram element search result object for an element in a Simulink® or Stateflow® diagram.

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

Creation

Description

example

result = DiagramElementResult(elem) creates a search result object for a diagram element. The result object contains the specified Simulink or Stateflow diagram element.

Note

The find methods of diagram element finders create and return instances of this slreportgen.finder.DiagramElementResult object. You do not need to create instances yourself.

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

Input Arguments

expand all

Simulink or Stateflow diagram element, specified as a path or handle to the element.

Properties

expand all

Public Properties

Additional user-defined information to add to the result, specified as any value.

Attributes:

NonCopyable
true

Data Types: any

Protected Properties

This read-only property contains a handle to the diagram element returned in this result.

This read-only property specifies the name of the diagram element returned in this result.

This read-only property specifies the type of the diagram element returned in this result.

Example: "Simulink.BlockDiagram"

This read-only property returns the path of the diagram that contains the element returned in this result.

Methods

expand all

Examples

collapse all

The slrgex_sf_car model uses a Simulink Function, which is a function that uses a Simulink subsystem to compute its outputs from its inputs. This example finds the diagrams in the model and for each diagram uses an slreportgen.DiagramElementFinder object to find the Simulink Function subsystems. For each slreportgen.DiagramElementResult object returned by the finder, the example uses the Name property value as a section title and calls the getDiagramReporter method to return the subsystem diagram to add to the section.

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

openExample('rptgenext/SimulinkReportGeneratorFilesExample');
import slreportgen.report.*
import slreportgen.finder.*
import mlreportgen.report.*

model = "slrgex_sf_car";
load_system(model);

rpt = slreportgen.report.Report("output","pdf");
chapter = Chapter();
chapter.Title = "Diagram Element Result Example";

% Find all diagrams in the model
diagFinder = DiagramFinder(model);
diagrams = find(diagFinder);
for diag = diagrams
    % Find all Simulink Function subsystems in the current diagram
    elemFinder = DiagramElementFinder(diag);
    elemFinder.Types = "slfunction";
    elems = find(elemFinder);
    for elem = elems
        section = Section(Title=mlreportgen.utils.normalizeString(elem.Name));
        % Get the diagram reporter from the result and add it to the section
        rptr = getDiagramReporter(elem);
        if ~isempty(rptr)
            add(section,rptr)
        end
        add(section,elem);
        add(chapter,section);
    end
end

add(rpt,chapter);
close(rpt);
rptview(rpt);

Version History

Introduced in R2017b