Main Content

Create Simulink Bus Object Reports

This example shows how to create a report that describes all of the bus objects used by a Simulink® model. This report creates a chapter for each bus object. Each chapter has a section for the bus object hierarchy, bus object properties table, bus elements properties table, and list of blocks that use the bus.

Import Packages

Import the Report API packages so that you do not have to use long, fully qualified class names.

import slreportgen.finder.*

Open Model

Open a model that has bus objects.

model = "slrgex_sldemo_bus_arrays";

Create Report

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

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

Add a title page and a table of contents.

titlepage = TitlePage("Title", model + ": Bus Object Report","Author","John Doe");
toc = TableOfContents();
add(rpt, toc);

Find and Report on Bus Objects

Find all the variables used in the model.

finder = ModelVariableFinder(model);

Loop through the variable finder results to find the bus objects and report on them. Use the getVariableValue method to identify which variables are bus objects. Use the reporter to report on the bus objects.

while hasNext(finder)
    result = next(finder);
    if isa(getVariableValue(result),"Simulink.Bus")
        % Create a Bus object reporter
        busReporter = BusObject(result);
        % Create a Chapter
        chapter = Chapter(busReporter.Name);
        % Add bus to chapter
        % Add chapter to the report

Close Report

Close and view the report.


View Sample Report

To see a more comprehensive bus object report, view the asbhl20_bus_object_report.pdf from the HL-20 Project with Optional FlightGear Interface example.

rptview asbhl20_bus_object_report.pdf

See Also

| | | |

Related Topics