slreportgen.report.BusObject Class
Namespace: slreportgen.report
Superclasses: slreportgen.report.Reporter
Simulink bus object reporter
Description
Creates a reporter that generates information about a Simulink.Bus object in a report.
Note
To use a bus object reporter in a report, you must create the report using the
slreportgen.report.Report class or subclass.
The slreportgen.report.BusObject class is a handle class.
Creation
Description
creates an empty reporter = slreportgen.report.BusObjectslreportgen.report.BusObject reporter object. Customize
the content and formatting of the information reported for a bus object by using the
reporter object properties. Before you add the reporter to a report, you must set the
Object
property of the reporter to an slreportgen.report.ModelVariableResult or
Simulink.VariableUsage object that specifies a
Simulink.Bus object. Adding an empty reporter to a report produces an
error.
creates a reporter for the reporter = slreportgen.report.BusObject(object)Simulink.Bus object specified by an
slreportgen.report.ModelVariableResult or
Simulink.VariableUsage object. See the Object
property.
sets the reporter properties using name-value arguments. You can specify multiple
name-value arguments in any order.reporter = slreportgen.report.BusObject(PropertyName=Value)
Properties
Object that specifies the Simulink.Bus object to report, specified as
an slreportgen.finder.ModelVariableResult object or a Simulink.VariableUsage object.
Attributes:
GetAccess | public |
SetAccess | public |
Name of bus object to report, specified as a string scalar.
Attributes:
GetAccess | public |
SetAccess | protected |
Data Types: string
Bus object properties to report, specified as a string array or a cell array of
character vectors. The properties specified by the
ReportedBusProperties property are further filtered by the
PropertyFilterFcn property. If the
ReportedBusProperties property is empty, the reporter includes
all properties in the report, except the properties filtered by the
PropertyFilterFcn property. The reporter excludes any bus object
property that is not valid for the bus object.
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: char | string | cell
Bus element properties to report, specified as a string array or a cell array of
character vectors. The properties specified by the
ReportedElementProperties property are further filtered by the
function or code specified in the PropertyFilterFcn property. If
the ReportedElementProperties property is empty, the reporter
includes all properties in the report, except the properties filtered by the
PropertyFilterFcn property. The reporter excludes any bus element
property that is not valid for the bus element.
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: char | string | cell
Whether to show the name of the bus object in the report, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — Show the name of the bus object in the report.0(false) — Omit the name of the bus object in the report.
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: logical
Whether to show a nested list that represents the bus hierarchy in the report,
specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — Show a nested list that represents the bus hierarchy in the report.0(false) — Omit the bus hierarchy in the report.
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: logical
Whether to show the bus object properties table in the report, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — Show the bus object properties table in the report.0(false) — Omit the bus object properties table in the report.
Data Types: logical
Whether to show the bus object element properties table in the report, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — Show the bus object element properties table in the report.0(false) — Omit the bus object element properties table in the report.
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: logical
Whether to show a list of the blocks that use the bus object, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The reporter includes a list of the blocks that use the bus object in the report. If theShowUsedBySnapshotproperty is also set totrue, the reporter includes a diagram snapshot for each parent subsystem that uses the bus object. Blocks that use the bus object are highlighted in the snapshot.0(false) — Omit a list of the blocks that use the bus object.
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: logical
Whether to show diagram snapshots of parent subsystems and highlight the blocks that
use the bus object, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The report includes a snapshot for each parent subsystem that uses the bus object. Blocks that use the bus object are highlighted in the snapshot. If a parent subsystem has more than one block that uses the bus object, the reporter shows only one diagram snapshot that highlights the blocks that use the bus object.0(false) — Omit diagram snapshots of parent subsystems.
Attributes:
GetAccess | public |
SetAccess | public |
Whether to create a separate section for each type of information about the bus
object in the report, specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The reporter creates anmlreportgen.report.Sectionwith a title for each of these types of information:hierarchy
properties
elements
blocks that use the bus object
0(false) — The reporter generates labels for tables and lists. For a table, the reporter generates a table title. For a list, the reporter generates text that precedes the list.
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: logical
List formatter that formats the generated bus hierarchy, specified as an mlreportgen.dom.UnorderedList object or an mlreportgen.dom.OrderedList object. The default value of this property is an
object of mlreportgen.dom.UnorderedList. To
customize the list formatting, modify the list object properties or replace the list
object with a customized list object that does not contain list items.
Attributes:
GetAccess | public |
SetAccess | public |
List formatter that formats the generated list of blocks that use the bus object,
specified as an mlreportgen.dom.UnorderedList object or an
mlreportgen.dom.OrderedList object. The
default value of this property is an object of mlreportgen.dom.UnorderedList. To customize the list formatting, modify the
list object properties or replace the list object with a customized list object that
does not contain list items.
Attributes:
GetAccess | public |
SetAccess | public |
Table reporter used to format the table of bus object properties, specified as an
mlreportgen.report.BaseTable object. The default value of this property is a
BaseTable object with the TableStyleName
property set to the BusObjectPropertiesTable style, which is defined
in the default template for a BusObject reporter.
To customize the appearance of the table, modify the properties of the default table
reporter or replace it with a customized table reporter. If you add content to the
Title property of the default or customized table reporter, the
content appears in front of the table title in the generated report.
Attributes:
GetAccess | public |
SetAccess | public |
Table reporter used to format the table of bus element properties, specified as an
mlreportgen.report.BaseTable object. The default value of this property is a
BaseTable object with the TableStyleName
property set to the BusObjectElementsTable style, which is defined in
the default template for a BusObject reporter.
To customize the appearance of the table, modify the properties of the default table
reporter or replace it with a customized table reporter. If you add content to the
Title property of the default or customized table reporter, the
content appears in front of the table title in the generated report.
Attributes:
GetAccess | public |
SetAccess | public |
Whether to display properties horizontally in the table of element properties,
specified as a logical 1
(true) or 0 (false). When you
specify:
1(true) — The table has one column for each property. For example:
0(false) — The property and value cells in the row for the element are split into multiple rows. For example:
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: logical
Reporter for formatting sections when the CreateSections
property is set to true, specified as an mlreportgen.report.Section object. To customize the appearance of the
section, modify the properties of the default section reporter or replace it with a
customized section reporter.
Attributes:
GetAccess | public |
SetAccess | public |
Function or expression to filter the properties of a reported bus or bus element from a report. Specify a function as a function handle. Specify an expression as a character vector or string scalar.
If you provide a function handle, the associated function must:
Take these arguments:
variableName— Name of the model variable that designates the bus or bus element being reportedvariableObject— The bus or bus element being reportedpropertyName— Name of the property of the bus or bus element being reported
Return
trueto filter the specified property from the report, orfalseto include the property in the report.
For example, this code prevents the display of the HeaderFile and
Description properties of a bus object and the
Complexity property of a bus element:
import slreportgen.finder.* import slreportgen.report.* rpt = slreportgen.report.Report("busrpt","pdf"); model = "slrgex_sldemo_bus_arrays"; openExample(model); modelVariableFinder = ModelVariableFinder(model); results = find(modelVariableFinder); for result = results if isa(getVariableValue(result),"Simulink.Bus") busRptr = slreportgen.report.BusObject(result); busRptr.PropertyFilterFcn = @busPropertyFilter; % Create a Chapter chapter = mlreportgen.report.Chapter(busRptr.Name); add(chapter, busRptr); add(rpt,chapter) end end close(rpt); close_system(model); rptview(rpt); function tf = busPropertyFilter(~, variableObject,propertyName) if isa(variableObject, "Simulink.Bus") tf = (propertyName == "HeaderFile") || ... (propertyName == "Description"); else % Filter Simulink.BusElement Complexity property tf = propertyName == "Complexity"; end end
Note
You must run this code from a script since functions can only be created as local or nested functions in code files.
If you provide a string scalar or a character vector, it must contain an expression. The expression:
Can use the variables
variableName,variableObject, andpropertyNameMust set the variable
isFilteredtotrueto filter the specified property from the report, orfalseto include the property in the report
For example, this code filters the HeaderFile property of a bus
object from the report:
import slreportgen.finder.* import slreportgen.report.* rpt = slreportgen.report.Report("busrpt","pdf"); model = "slrgex_sldemo_bus_arrays"; openExample(model); modelVariableFinder = ModelVariableFinder(model); results = find(modelVariableFinder); for result = results if isa(getVariableValue(result),"Simulink.Bus") busRptr = slreportgen.report.BusObject(result); busRptr.PropertyFilterFcn = "isFiltered = " + ... "isa(variableObject, ""Simulink.Bus"") && " + ... "propertyName == ""HeaderFile"";"; % Create a Chapter chapter = mlreportgen.report.Chapter(busRptr.Name); add(chapter, busRptr); add(rpt,chapter) end end close(rpt); close_system(model); rptview(rpt);
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: char | string | function_handle
Source of the template for this reporter, specified in one of these ways:
Character vector or string scalar that specifies the path of the file that contains the template for this reporter
Reporter or report whose template this reporter uses or whose template library contains the template for this reporter
Document Object Model (DOM) document or document part whose template this reporter uses or whose template library contains the template for this reporter
The specified template must be the same type as the report to which you
append this reporter. For example, for a Microsoft® Word report, TemplateSrc must be a Word reporter template.
If the TemplateSrc property is empty, this reporter uses the
default reporter template for the output type of the report.
Attributes:
GetAccess | public |
SetAccess | public |
NonCopyable | true |
Dependent | true |
Name of the template for this reporter, specified as a character vector or string scalar.
The template for this reporter must be in the template library of the template specified by
the TemplateSrc property of this reporter.
Attributes:
GetAccess | public |
SetAccess | public |
Data Types: char | string
Hyperlink target for this reporter, specified as a character vector or string scalar
that specifies the link target ID, or an mlreportgen.dom.LinkTarget object. A character vector or string scalar
value converts to a LinkTarget object. The link target immediately
precedes the content of this reporter in the output report.
Attributes:
GetAccess | public |
SetAccess | public |
Methods
| Method | Purpose |
|---|---|
slreportgen.report.BusObject.createTemplate |
Create reporter template
Input Arguments
Return Values
For more information, see the method
for the |
slreportgen.report.BusObject.customizeReporter |
Create reporter from
Input Arguments
Return Values
For more information, see the method
for the |
slreportgen.report.BusObject.getClassFolder |
Get location of folder that contains
Return Values
For more information, see the method
for the |
copy |
Create copy of reporter object and make deep copies of property values
Input Arguments
Return Values
For more information, see the method
for the |
getImpl |
Get implementation of reporter
Note You cannot add content to the reporter after calling this method. Input Arguments
Return Values
For more information, see the method
for the |
Examples
Report on bus objects in a model by using a model variable finder to find all variables used in the model and then creating a bus reporter for each variable that is a bus object.
% Create a Report rpt = slreportgen.report.Report("MyReport","pdf"); open(rpt); % Load a model model = "slrgex_sldemo_bus_arrays"; openExample(model); % Find all variables used by the model finder = slreportgen.finder.ModelVariableFinder(model); % Create a Bus object reporter object for all results representing a % Simulink.Bus object 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 and view the report close(rpt); rptview(rpt);
Customize the reported content and formatting of the content by setting properties of the bus object reporter. This example uses the ReportedElementProperties property to constrain the element properties that are reported. It uses the HorizontalElementsTable property to generate a properties table with one column for each property.
% Create a Report rpt = slreportgen.report.Report("MyReport","pdf"); open(rpt); % Load a model model = "slrgex_sldemo_bus_arrays"; openExample(model); % Find all variables used by the model finder = slreportgen.finder.ModelVariableFinder(model); % Create a Bus object reporter object for all results representing a % Simulink.BusObject object while hasNext(finder) result = next(finder); if isa(getVariableValue(result), "Simulink.Bus") % Create a Bus object reporter busReporter = slreportgen.report.BusObject(result); % Limit the properties that are reported busReporter.ReportedElementProperties = {"Name","DataType","Min","Max"}; % Display element properties horizontally busReporter.HorizontalElementsTable = true; % 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 and view the report close(rpt); rptview(rpt);
Version History
Introduced in R2019b
See Also
Classes
slreportgen.report.Report|slreportgen.report.Reporter|slreportgen.finder.ModelVariableResult|slreportgen.report.ModelVariable|slreportgen.finder.ModelVariableFinder|slreportgen.report.Bus
Functions
Namespaces
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)