Create a Simulink Bus Object Report

This example shows how to create a report that describes all of the 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.

Open Model

Open a model that has bus objects.

model = "sldemo_bus_arrays";
open_system(model);

Create Report

Create and open a report object.

rpt = slreportgen.report.Report(model + "_bus_object_report","pdf");
open(rpt);

Add a title page and a table of contents.

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

Find and Report on Bus Objects

Find all the variables used in the model.

finder = slreportgen.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 slreportgen.report.BusObject 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 = slreportgen.report.BusObject(result);
        % Create a Chapter
        chapter = mlreportgen.report.Chapter(busReporter.Name);
        % Add bus to chapter
        add(chapter,busReporter)
        % Add chapter to the report
        add(rpt,chapter);
    end
end

Close Report

Close and view the report.

close(rpt);
rptview(rpt);       
 

View Sample Report

To see a more comprehensive bus object report, view the asbhl20_bus_object_report.pdf that is available with this example. You must have Aerospace Blockset™ to open the asbhl20 model.

rptview asbhl20_bus_object_report.pdf

See Also

| | | |

Related Topics