Main Content

Report System Inputs and Outputs

This example shows how to create a report that describes the inputs and outputs of a model or subsystem. The report includes a chapter for the top-level model and each subsystem in the model. Each chapter includes a section for the inputs and outputs and a section for the blocks in the system.

This image shows the input and output summaries included in the report.

Open Model

Open a model. This example uses a model that has top-level input and output blocks and a subsystem with inputs and outputs. The top-level input signals are stored in a variable, mappedIO, which is created when the model is opened.

model = "slreportgen_demo_SystemIO";

Report Setup

Import the Report Generator API namespaces so you do not have to use long, fully-qualified class names.

import slreportgen.finder.*

Create and open a Simulink report object. To create a Microsoft® Word, HTML, or single-file HTML report, change "pdf" to "docx", "html", or "html-file", respectively.

rpt = + "_SystemIO_Report","pdf");

Add a title page and table of contents.

titlepage = TitlePage("Title",model + ": System I/O Report","Author","Jane Doe");
toc = TableOfContents();
add(rpt, toc);

Report on Inputs and Outputs

Find and loop through all systems in the model.

finder = SystemDiagramFinder(model);
while hasNext(finder)
    system = next(finder);

Create a new chapter and add the diagram result.

    ch = Chapter("Title",sprintf("System %s",system.Name));

Create an "Inputs and Outputs" section and a SystemIO reporter.

    ioSect = Section("Inputs and Outputs");
    ioRptr = SystemIO(system);    

For subsystem inputs and outputs, the SystemIO reporter by default includes details about the input and output ports of the subsystem. For model inputs and outputs, the reporter includes details about inport and outport blocks. If the system is a model, set the SystemIO options to omit these block details because this report includes the same information in the "Blocks" section of the chapter.

    if strcmp(system.Type,"Simulink.BlockDiagram")
        ioRptr.ShowDetails = false;

Create a section to include details about each block in the system. Source and destination blocks included in SystemIO summary tables link to the corresponding block details in this section.

    blkSect = Section("Blocks");
    blkFinder = BlockFinder(system);
    results = find(blkFinder);

Add the chapter to the report.


Close Report

Close and view the report.