Main Content

slreportgen.finder.DiagramElementResult class

Package: slreportgen.finder
Superclasses:

Create diagram element finder result object

Description

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

Construction

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. Enclose each property name in single quotes.

Input Arguments

expand all

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

Properties

expand all

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.

Additional information to add to this result. You can set it to any type of value.

Methods

getDiagramReporterReturns Diagram reporter for diagram element result
getReporter Get diagram element reporter

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects.

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.

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);

Introduced in R2017b