slreportgen.finder.BlockFinder class
Package: slreportgen.finder
Superclasses:
Find Simulink blocks
Description
Finds blocks in a Simulink® diagram.
Construction
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 pairs. You can specify multiple name-value pair
arguments in any order.finder
= BlockFinder(Name=Value
)
Input Arguments
Properties
Methods
results = find(finder)
finds blocks in the
diagram
specified by the finder. This method returns the blocks
it finds wrapped in result objects of type
slreportgen.finder.BlockResult
. To add tables of the block properties,
add the results objects directly to the report or add them to a reporter that you then
add to a report. The reports to which you can add the results
of
this method must be of reports of type slreportgen.report.Report
tf = hasNext(finder)
determines if the diagram that the finder
searches contains at least one block. If the diagram has at least one block, the
hasNext
method queues that block as the next block that the
next
method will return. The hasNext
method then
returns true
. Use the next
method to obtain that
block. On subsequent calls, the hasNext
method determines if the
diagram has a block that the next
method has not yet retrieved. It
queues the block for the next
method to retrieve and returns
true
. If there are no more blocks to be retrieved, this method
returns false
. To search a diagram progressively for blocks, use the
hasNext
method with the next
method in a while
loop.
result = next(finder)
returns the next search
result
in the result queue that the hasNext
method created. This method returns the block that it finds wrapped in a result object
of type slreportgen.finder.BlockResult
. To add tables of the block
properties, add the result object to the report directly or add it to a reporter that
you then add to a report. The reports to which you can add the
results
of this method must be of type
slreportgen.report.Report
.
Copy Semantics
Handle. To learn how handle classes affect copy operations, see Copying Objects.
Examples
Find Inport and Outport Blocks in a Model
Find Inport and Output blocks in the slrgex_sf_car
model.
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
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