getDiagramReporter

Class: slreportgen.finder.DiagramElementResult
Package: slreportgen.finder

Returns Diagram reporter for diagram element result

Syntax

reporter = getDiagramReporter(result)

Description

reporter = getDiagramReporter(result) returns a reporter that generates a snapshot of the element returned in the diagram element result, or empty, []. If the result contains a diagram element, such as a Simulink® block, or Stateflow® chart or subchart, that contains a diagram, this method returns a reporter that generates a snapshot of the diagram. Otherwise, it returns empty, []. For example, this method returns a diagram reporter for chart and subchart results but [] for state results, which do not contain diagrams. To include the diagram of an applicable search result in a report, add this reporter to the report, either directly or via a Chapter or Section reporter.

Input Arguments

expand all

DiagramElementResult object, which is the output of the slreportgen.finder.DiagramElementFinder class.

Output Arguments

expand all

Diagram reporter object, returned as an slreportgen.report.Diagram object, depending on the search result. If the search result is an object that contains a diagram, such as a subsystem block or a subchart, the output is a diagram reporter. Otherwise, it is empty, []. If not empty, the diagram reporter generates a snapshot image of the diagram element.

Examples

Add Stateflow Function Diagram to Report

The sf_car model uses a Simulink Function, which is a function that uses a Simulink subsystem to compute its inputs from its outputs. In addition to the properties of the function, include the subsystem block diagram in the report.

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

model = "sf_car";
load_system(model)

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

diagFinder = DiagramFinder(model);
diagrams = find(diagFinder);
for diag = diagrams
    elemFinder = DiagramElementFinder(diag);
    elemFinder.Types = "slfunction";
    elems = find(elemFinder);
    for elem = elems
        section = Section("Title", ...
            strrep(elem.Type, newline,' '));
        rptr = getDiagramReporter(elem);
        if ~isempty(rptr)
            add(section,rptr)
        end
        r = getReporter(elem);
        add(section,elem)
        add(chapter,section)
    end
end

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

Introduced in R2018b