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 the Report API packages so that you do not have to use long, fully qualified class names.
import mlreportgen.report.* import slreportgen.finder.* import slreportgen.report.*
Open a model that has bus objects.
model = "slrgex_sldemo_bus_arrays"; open_system(model);
Create and open a report object. To create a Microsoft® Word, HTML, or single-file HTML report, change "
pdf" to "
html", or "
rpt = slreportgen.report.Report(model + "_bus_object_report","pdf"); open(rpt);
Add a title page and a table of contents.
titlepage = TitlePage("Title", model + ": Bus Object Report","Author","John Doe"); add(rpt,titlepage); 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
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 = BusObject(result); % Create a Chapter chapter = Chapter(busReporter.Name); % Add bus to chapter add(chapter,busReporter) % Add chapter to the report add(rpt,chapter); end end
Close and view the report.
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