Main Content

slreportgen.report.Bus class

Package: slreportgen.report
Superclasses: slreportgen.report.Reporter

Reporter for buses selected or created by Simulink blocks

Since R2021a

Description

Use an object of the slreportgen.report.Bus class to report on buses that are selected or created by Simulink® blocks.

A bus reporter finds buses to report by searching a model, subsystem, block, or signal for blocks that select signals from a bus or combine signals to create a bus. For a model or subsystem, the Bus reporter reports all of the buses selected or created in the model or subsystem. For a block, the reporter reports the bus that is selected or created by the block. For a signal, the reporter reports all of the buses selected or created by the blocks that are connected to the port specified by the signal. Use the Object property to specify the model, subsystem, block, or signal for which to report buses.

By default, a Bus reporter generates:

  • A hierarchical list of the signals in the bus

  • A table with details about the selected signals or the signals used to create the bus

  • Paragraphs with details about bus objects and connected blocks for each bus-related block found

Use the reporter properties to customize the content and appearance of the generated report. For example, use the ReportedBlockType property to specify which types of blocks to use when searching for buses.

Note

To use an slreportgen.report.Bus reporter in a report, you must create the report using the slreportgen.report.Report class or subclass.

The slreportgen.report.Bus class is a handle class.

Class Attributes

HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

busRptr = slreportgen.report.Bus() creates an slreportgen.report.Bus object with default property values. You must set the Object property to the model, block, or signal for which you want to report buses. Use other properties to specify report options.

example

busRptr = slreportgen.report.Bus(object) sets the Object property to object.

busRptr = slreportgen.report.Bus(Name=Value) sets the Bus object properties using name-value pairs. You can specify multiple name-value pair arguments in any order.

Properties

expand all

Model, block, or signal to search for buses, specified as one of the following values:

  • String scalar or character vector that contains the name of a model, Subsystem block, Bus Creator block, Bus Assignment block, or Bus Selector block

Title for each reported bus, specified as a string scalar, character vector, DOM object, or function handle. The contents of this property are reported with each bus included by the reporter. If this property is empty, no title is reported.

If this property contains text or a function handle that returns text, the text is added to an mlreportgen.dom.Paragraph object with the style BusTitleParagraph.

If this property is specified as a function handle, the function must return content that can be added to a report, such as a string scalar, character vector, or DOM object. The function must accept a struct with these fields:

  • PortHandle — Handle to the input port or output port of the bus signal. For In Bus Element and Out Bus Element blocks in a subsystem, this field is the port handle of the subsystem that corresponds to the blocks. For In Bus Element and Out Bus Element blocks in the top level of a model, this field is -1.

  • BlockName — Name of reported model,  Bus CreatorBus Selector, Bus Assignment, or Subsystem block that creates or selects the reported bus, specified as a string scalar.

  • BlockPath — Full path of model, Bus CreatorBus Selector, Bus Assignment, or Subsystem block that creates or selects the reported bus, specified as a string scalar.

  • BusPortString — For a bus created or selected by a model or subsystem port, this field contains the input port or output port connected to the bus signal, specified as a string scalar. For example, "Inport <x>". Otherwise, this field is an empty string (""). 

For example: busRptr.Title = @(blkInfo) blkInfo.BlockName;

Types of blocks used to report bus information, specified as one of these values:

  • "auto" — Reports bus information from Bus CreatorBus Assignment, and Out Bus Element blocks if the input is a Bus CreatorBus Assignment, or Out Bus Element block. Otherwise, reports bus information from Bus Selector and In Bus Element blocks.

  • "all" — Reports bus information from all supported bus-related block types.

  • List of block types, specified as a string array or a cell array of character vectors. Valid block types are:

    • BusCreator

    • BusSelector

    • BusAssignment

    • Inport

    • Outport

    For example: ["BusCreator","BusSelector"]

For models or subsystems, the Bus reporter reports bus information from all blocks of the types that this property specifies. For signals, the reporter reports bus information from all blocks of the specified types that are connected to the signal (source and destination). For blocks, this property is used only if the IncludeNestedBuses property is true. For Bus Selector and In Bus Element blocks, the reporter reports bus information from all blocks of the specified type that are connected to the output signals of the block. For Bus CreatorBus Assignment, and Out Bus Element blocks, the reporter reports bus information from all blocks of the specified type that are connected to the input signals of the block.

Whether to report nested buses, specified as true or false. If this property is true, the reporter reports bus-related blocks of the type specified by ReportedBlockType that are connected to the selected signals or to signals used to create a bus. If this property is false and Object is a block, the reporter reports only the block specified by Object. If this property is false and Object is a signal, the reporter reports only the blocks directly connected to the signal.

If Object is a model or subsystem, this property has no effect because all blocks of the type specified by the ReportedBlockType property are used to report buses.

Whether to report the hierarchy of bus signals for each bus, specified as true or false. If this property is true, the reporter includes a list of the names of signals in the bus. For blocks that create buses, the list describes the signal hierarchy of the output bus. For blocks that select signals from buses, the list describes the signal hierarchy of the input bus. If the bus includes any nested signals, the signal names are included as a nested list.

The reporter does not include the signal hierarchy for buses created or selected by top-level model input or output ports.

Whether to report details of signals, specified as true or false. If this property is true, the reporter includes a table describing the signals selected from a bus or used to create a bus, depending on the block type.

Whether to report the name of a Simulink.Bus object that is associated with the reported bus, specified as true or false. If this property is true and the reported bus is described by a Simulink.BusObject, the report includes the name of the bus object and links the name to the bus object information reported elsewhere in the report.

The reporter does not include the bus object name for buses created or selected by top-level model input or output ports.

Whether to report the names of blocks connected to each full bus signal, specified as true or false. If this property is true:

  • For blocks that create buses, the reporter reports the names of the blocks connected to the port that outputs the full bus signal.

  • For blocks that select bus signals, the reporter reports the name of the block from which the full bus signal is output.

  • If IncludeBusLinks is true, a Bus Created or Signals Selected link is included after the names of blocks that match the block types specified by ReportedBlockType.

 

The reporter does not include the names of connected blocks for buses created or selected by top-level model input or output ports.

Whether to include a link to a bus created or selected by a connected block, specified as true or false. If this property is true, the reporter includes a link to the bus information for blocks that are reported as a source or destination in the signal table or connected blocks sections. For blocks whose block types are included in ReportedBlockTypes, a Bus Created or Signals Selected link is included next to the block name.

Whether to report block names as links to block details, specified as true or false. If this property is true, a block name in a signal table title links to the block details reported elsewhere in the report.

Whether to report port numbers as links to signal details, specified as true or false. If this property is true, the reporter reports signal port numbers in the signal table as links to the signal details reported elsewhere in the report.

Properties to report for the signals selected by Bus Selector or In Bus Element blocks, specified as a string array or a cell array of character vectors. Specify any of these properties:

  • Outport

  • Name

  • DataType

  • Destination

  • Description

  • Complexity

  • Dimensions

  • Min

  • Max

Properties to report for the signals used to create a bus by Bus Creator, Bus Assignment, and Out Bus Element blocks, specified as a string array or a cell array of character vectors. Specify any of these properties:

  • Inport

  • Name

  • DataType

  • Source

  • Description

  • Complexity

  • Dimensions

  • Min

  • Max

Whether to show empty columns in a signal table, specified as true or false.

Function or expression to filter signals in a signal table, specified as a function handle, string scalar, or character vector. Specify a function as a function handle. Specify an expression as a string scalar or character vector. The function or code is executed for each signal that is selected or used to create a bus.

If TaskFilterFcn is empty, all tasks are included in the report.

If you provide a function handle, the associated function must:

  • Take these arguments:

    • portHandle — Handle to port of the selected signal or signal used to create the bus.

    • parentPath — Full path of parent block used to report bus information, specified as a string scalar.

    • sourcePath — Full path of the source block of the signal, specified as a string scalar.

    • destinationPath— Full path of the destination block of the signal. If there are multiple destinations, this argument is a string array of destination blocks.

  • Return true to filter the specified signal from the report, or false to include the task in the report.

For example, this code uses the SignalFilterFcn property to filter out the signals that feed into the Display3 block:

import slreportgen.report.*
import mlreportgen.report.*


model_name = "sldemo_bus_arrays";
load_system(model_name);
rpt = slreportgen.report.Report("Bus_example","pdf");

append(rpt,slreportgen.report.Diagram(model_name));

ch = Chapter("Buses");

busRptr = Bus(model_name);
busRptr.SignalFilterFcn = @(~, ~, ~, destinationPath) endsWith(destinationPath,"Display3");

append(ch,busRptr);
append(rpt,ch);
close(rpt);
rptview(rpt);

If you provide a string scalar or a character vector, it must contain an expression. The expression:

  • Can use the variables portHandle, parentPath, sourcePath, and destinationPath

  • Must set the variable isFiltered to true to filter the specified task from the report, or false to include the task in the report

For example, this code uses the SignalFilterFcn property to filter out the signals that feed into the Display4 block:

import slreportgen.report.*
import mlreportgen.report.*


model_name = "sldemo_bus_arrays";
load_system(model_name);
rpt = slreportgen.report.Report("Bus_example","pdf");

append(rpt,slreportgen.report.Diagram(model_name));

ch = Chapter("Buses");

busRptr = Bus(model_name);
filterStr = "isFiltered = endsWith(destinationPath,""Display4"");";
busRptr.SignalFilterFcn = filterStr;

append(ch,busRptr);
append(rpt,ch);
close(rpt);
rptview(rpt);

Formatter for signal table, specified as an mlreportgen.report.BaseTable object. The default value of this property is a BaseTable object with the TableStyleName property set to the BusTable style, which is defined in the default template for a Bus reporter. To customize the appearance of the table, modify the properties of the default BaseTable object or replace the object with your own BaseTable object. If you add content to the Title property of the BaseTable object, the content appears in front of the table title in the generated report.

Formatter for the signal hierarchy list, specified as an mlreportgen.dom.OrderedList or mlreportgen.dom.UnorderedList object. The formatter reports and formats the signal hierarchy list if the ShowSignalHierarchy property of this Bus reporter is true. The OrderedList or UnorderedList object must not contain list items.

The default value of this property is an UnorderedList object with the StyleName property set to the BusList style, which is defined in the default template for a Bus reporter. To customize the appearance of the list, modify the properties of the default UnorderedList object or replace the object with your own UnorderedList or OrderedList object.

Paragraph formatter to report and format the connected blocks and bus object details, specified as an mlreportgen.dom.Paragraph object. The default value of this property is an mlreportgen.dom.Paragraph object with the StyleName property set to the BusParagraph style, which is defined in the default template for a Bus reporter. To customize the appearance of the paragraph, modify the properties of the default mlreportgen.dom.Paragraph object or replace the object with a customized mlreportgen.dom.Paragraph object. If you add content to the default or replacement paragraph object, the content appears in front of the content reported for the connected blocks and bus object details in the generated report.

Source of the template for this reporter, specified as one of these options:

  • 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

  • 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 this reporter is appended. 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.

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 source specified by the TemplateSrc property for this reporter.

Hyperlink target for this reporter, specified as a character vector or string scalar that specifies the link target ID or as an mlreportgen.dom.LinkTarget object. A character vector or string scalar value is converted to a LinkTarget object. The link target immediately precedes the content of this reporter in the output report.

Methods

expand all

Examples

collapse all

Use an slreportgen.report.Bus object to report on the buses that are selected by the blocks in a model.

Import the Report API packages so that you do not have to use long fully qualified class names.

import mlreportgen.report.*
import slreportgen.report.*

Load the model.

model_name = "sldemo_bus_arrays";
load_system(model_name);

Create a Simulink report.

rpt = slreportgen.report.Report("Bus_example","pdf");

Add the diagram of the model to the report.

append(rpt,slreportgen.report.Diagram(model_name));

Report the bus information for the model in a chapter.

ch = Chapter("Buses");
busRptr = Bus(model_name);

Use the block name as the title for each block bus.

busRptr.Title = @(blkInfo) blkInfo.BlockName;

Add the bus reporter to the chapter.

append(ch,busRptr);

Add the chapter to the report.

append(rpt,ch);
close(rpt);
rptview(rpt);

Version History

Introduced in R2021a