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 pairs. You can specify multiple name-value
pair arguments in any order.reporter
= slreportgen.report.BusObject(Name=Value
)
Properties
Object
— Object that specifies a Simulink.Bus
object
slreportgen.finder.ModelVariableResult
object | Simulink.VariableUsage
object
Object that specifies the Simulink.Bus
object to report, specified as
an slreportgen.finder.ModelVariableResult
object or a Simulink.VariableUsage
object.
Name
— Name of bus object
string scalar
This read-only property contains the name of bus object to report, specified as a string scalar.
ReportedBusProperties
— Bus object properties to report
[]
(default) | string array | cell array of character vectors
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.
ReportedElementProperties
— Bus element properties to report
[]
(default) | string array | cell array of character vectors
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.
ShowName
— Whether to show name of bus
false
(default) | true
Whether to show the name of the bus object in the report, specified as
true
or false
.
ShowHierarchy
— Whether to show hierarchy of the bus object
true
(default) | false
Whether to include a nested list that represents the bus hierarchy in the report,
specified as true
or false
.
ShowProperties
— Whether to show bus object properties
true
(default) | false
Whether to show the bus object properties table in the report, specified as
true
or false
.
ShowElements
— Whether to show bus object elements properties
true
(default) | false
Whether to show the bus element properties table in the report, specified as
true
or false
.
ShowUsedBy
— Whether to show blocks that use bus object
true
(default) | false
Whether to show a list of the blocks that use the bus object, specified as
true
or false
. If the
ShowUsedBy
property is set to true
, the
reporter includes a list of the blocks that use the bus object in the report. If the
ShowUsedBySnapshot
property is also set to
true
, 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.
ShowUsedBySnapshot
— Whether to show diagram snapshots highlighting blocks that use bus object
true
(default) | false
Whether to show diagram snapshots of parent subsystems and highlight the blocks that
use the bus object, specified as true
or false
. If
the ShowUsedBySnapshot
property is set to 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.
CreateSections
— Whether to create sections
true
(default) | false
Whether to create a separate section for each type of information about the bus
object in the report. If the CreateSections
property is set to
true
, the reporter creates an mlreportgen.report.Section
with a title for each of these types of information:
hierarchy
properties
elements
blocks that use the bus object
If the CreateSections
property is set to
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.
HierarchyListFormatter
— List formatter for hierarchy
mlreportgen.dom.UnorderedList
| mlreportgen.dom.OrderedList
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.
UsedByListFormatter
— List formatter for blocks that use the bus object
mlreportgen.dom.UnorderedList
| mlreportgen.dom.OrderedList
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.
PropertiesTableReporter
— Table reporter for bus object properties
mlreportgen.report.BaseTable
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.
ElementsTableReporter
— Table reporter for bus element properties
mlreportgen.report.BaseTable
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.
HorizontalElementsTable
— Whether to display element properties horizontally
false
(default) | true
Whether to display properties horizontally in the table of element properties,
specified as true
or false
.
If the HorizontalElementsTable
property is set to
true
, the table has one column for each property. For
example:
If the HorizontalElementsTable
property is set to
false
, the property and value cells in the row for the element are
split into multiple rows. For example:
SectionReporter
— Section reporter
mlreportgen.report.Section
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.
PropertyFilterFcn
— Function or expression to filter properties of a reported bus or bus element
[]
(default) | function handle | string scalar | character vector
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 string scalar or character vector.
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
true
to filter the specified property from the report, orfalse
to 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 = load_system('sldemo_bus_arrays'); 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
If you provide a string scalar or a character vector, it must contain an expression. The expression:
Can use the variables
variableName
,variableObject
, andpropertyName
Must set the variable
isFiltered
totrue
to filter the specified property from the report, orfalse
to 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 = load_system('sldemo_bus_arrays'); 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);
TemplateSrc
— Source of template for this reporter
character vector | string scalar | reporter or report | DOM document or document part
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 is used for this reporter or whose template library contains the template for this reporter
Document Object Model (DOM) document or document part whose template is used for this reporter 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.
TemplateName
— Name of template for this reporter
character vector | string scalar
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.
Data Types: char
| string
LinkTarget
— Hyperlink target for this reporter
[]
(default) | character vector | string scalar | mlreportgen.dom.LinkTarget
object
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.
Methods
Public Methods
slreportgen.report.BusObject.createTemplate | Create bus object reporter template |
slreportgen.report.BusObject.customizeReporter | Create custom bus object reporter |
slreportgen.report.BusObject.getClassFolder | Bus object reporter class definition file location |
copy | Create copy of a Simulink reporter object and make deep copies of certain property values |
getImpl | Get implementation of reporter |
Examples
Report on Bus Objects Using Bus Object Reporters
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_name = "sldemo_bus_arrays"; load_system(model_name); % Find all variables used by the model finder = slreportgen.finder.ModelVariableFinder(model_name); % 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 for Bus Objects
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_name = "sldemo_bus_arrays"; load_system(model_name); % Find all variables used by the model finder = slreportgen.finder.ModelVariableFinder(model_name); % 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
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)