create simulink bus object reports -凯发k8网页登录
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 mlreportgen.report.* import slreportgen.finder.* import slreportgen.report.*
open model
open a model that has bus objects.
model = "slrgex_sldemo_bus_arrays";
open_system(model);
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 = 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 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
| | | |