slreportgen.finder.BlockFinder class
Package: slreportgen.finder
Find Simulink blocks
Description
Finds blocks in a Simulink® diagram.
The slreportgen.finder.BlockFinder
class is a handle
class.
Creation
Description
creates a finder that finds by default all types of blocks in the specified
Simulink block diagram. To constrain the search to specific types of
blocks, use the properties of the finder.finder
= BlockFinder(diagram
)
Note
This finder provides two ways to get search results:
To return the search results as an array, use the
find
method. Add the results directly to a report or process the results in afor
loop.To iterate through the results one at a time, use the
hasNext
andnext
methods in awhile
loop.
Neither option has a performance advantage.
sets properties using name-value arguments. You can specify multiple
name-value arguments in any order.finder
= BlockFinder(Name=Value
)
Input Arguments
diagram
— Block diagram to search
path | handle
See Container property.
Properties
Container
— Diagram to search
path | handle
Diagram in which to search, specified as one of these values:
Handle to a Simulink model or subsystem
Path to a Simulink model or subsystem
BlockTypes
— Types of blocks to find
string | character array | string array | cell array of character arrays
Type of block to find, such as Gain, specified as a string or character array, or a set of block types to find, specified as a string array or a cell array of character arrays.
IncludeCommented
— Include commented-out blocks
false
(default) | true
Whether to include commented-out blocks in the search results, specified
as a logical. If false
, commented-out blocks are excluded
from the search results.
IncludeVariants
— Variants to include
"Active"
(default) | "All"
| "ActivePlusCode"
Variants of a variant block to include in the search results, specified as one of the values in the table. You can specify the value as a string scalar or a character vector.
Value | Description |
---|---|
"Active" | Active variants (default) |
"All" | All variants |
"ActivePlusCode" | Active variants and code variants |
SearchDepth
— Number of levels to search Container
1
(default) | inf
| nonnegative integer
Number of levels to search Container
, specified as a
nonnegative integer or inf
. Specify
inf
to search all levels.
SortType
— Sorting method for finder results
"none"
(default) | "alphabetical" | "systemAlpha" | "fullPathAlpha" | "blockType" | "depth" | "leftToRight" | "topToBottom" | "runtime"
Sorting method for finder results, specified as one of these values:
Value | Description |
---|---|
"none" | Do not sort results. |
"alphabetical" | Sort results alphabetically by name. |
"systemAlpha" | Sort results alphabetically by parent system name. |
"fullPathAlpha" | Sort results alphabetically by full path. |
"blockType" | Sort results alphabetically by type. |
"depth" | Sort results by depth in the model hierarchy. The first
result in the sorted list belongs to the system that is
highest in the hierarchy. For example, a result in the
top-level model and blocks in subsystems are sorted in the
order: myModel/block1 ,
myModel/subsystem1/block2 ,
myModel/subsystem1/nestedSubststem/block3 . |
"leftToRight" | Sort results by their location in the model layout using rows from left to right. A row of blocks in the model is a subgroup of blocks that are positioned between two horizontal lines. A minimal row is a row that cannot be divided to subrows. The algorithm first groups the blocks into minimal rows and sorts each row from left to right. The algorithm then concatenates the sorted rows from top to bottom. |
"topToBottom" | Sort results by their location in the model layout using columns from top to bottom. A column of blocks in the model is a subgroup of blocks that are positioned between two vertical lines. A minimal column is a column that cannot be divided to subcolumns. The algorithm first groups the blocks into minimal columns and sorts each row from top to bottom. The algorithm then concatenates the sorted rows from right to left. |
"runtime" | Sort nonvirtual blocks by their order of execution in a
model or nonvirtual subsystem. This option compiles the
model containing the specified blocks. Any block result that
represents a virtual block or a block that is not a part of
the system specified by Container is
appended to the end of the sorted block list. For
multitasking systems, blocks are grouped by the task in
which they execute. |
ConnectedSignal
— Limit search to blocks connected to specific signal
[] (default) | slreportgen.finder.SignalResult
| port handle
Limit the search to blocks that are connected to a specific signal,
specified as an slreportgen.finder.SignalResult
object or
port handle. If this property is empty, the search is not limited to blocks
that are connected to specific signals.
Example: finder.ConnectedSignal =
find_system(my_model,findall=true,type="port",name="my_signal")
Properties
— Properties of objects to find
cell array
Properties of objects to find, specified as a cell array of name-value pairs. The finder returns only objects that have the specified properties with the specified values.
Example: finder.Properties = {'Gain','5'}
Methods
Public Methods
Method | Description |
---|---|
find |
|
hasNext |
|
next |
|
Examples
Find Inport and Outport Blocks in a Model
Find Inport and Output blocks in the
slrgex_sf_car
model.
Run the following command to access the supporting files used in this example.
openExample('rptgenext/SimulinkReportGeneratorFilesExample');
import mlreportgen.report.* import slreportgen.report.* import slreportgen.finder.* model_name = "slrgex_sf_car"; load_system(model_name) rpt = slreportgen.report.Report("output","pdf"); add(rpt,TitlePage(Title=sprintf("I/O Blocks in %s Model",model_name))); add(rpt,TableOfContents); diagFinder = SystemDiagramFinder(model_name); diagFinder.IncludeRoot = false; while hasNext(diagFinder) diagram = next(diagFinder); chapter = Chapter(Title=diagram.Name); add(chapter,diagram) sect = Section(Title="Inport Blocks"); ioFinder = BlockFinder(diagram.Object); ioFinder.BlockTypes = "Inport"; blocks = find(ioFinder); for block = blocks add(sect,block) end add(chapter,sect); sect = Section(Title="Outport Blocks"); ioFinder = BlockFinder(diagram.Object); ioFinder.BlockTypes = "Outport"; outblocks = find(ioFinder); for block = outblocks add(sect,block) end add(chapter,sect) add(rpt,chapter) end close(rpt) close_system(model_name) rptview(rpt)
Version History
Introduced in R2017b
See Also
slreportgen.report.Report
| slreportgen.finder.DiagramFinder
| slreportgen.finder.DiagramElementFinder
| slreportgen.finder.SystemDiagramFinder
| slreportgen.report.SimulinkObjectProperties
| slreportgen.report.Diagram
| slreportgen.report.SimulinkObjectProperties
| slreportgen.finder.BlockResult
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 bat365 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)