Documentation

slreportgen.finder.SystemDiagramFinder class

Package: slreportgen.finder
Superclasses:

Create block diagram finder

Description

Create Simulink® block diagram finder.

Construction

finder = SystemDiagramFinder(container) creates a finder that finds by default all uncommented Simulink block diagrams in the specified container, which can be a Simulink model or subsystem. To constrain the search to specific types of models or subsystems, use the properties of the finder.

Note

This finder can operate in either find or iterator mode. In find mode, use its find method to return the results of a search as an array of results. In iterator mode, use its hasNext and next methods to return the results of a search one-by-one. When searching in models that have many model references, use iterator mode. Iterator mode closes a model after compiling and searching it, whereas find mode keeps all the models that it searches open. Having many open models can consume all system memory and slow report generation. Iterator mode is slower than find mode, so use find mode to search models that reference few or no other models.

finder = SystemDiagramFinder(Name,Value) sets properties using name-value pairs. You can specify multiple name-value pair arguments in any order. Enclose each property name in single quotes.

Input Arguments

expand all

See Container property.

Properties

expand all

System container in which to search, specified as one of these values:

  • Handle of a Simulink model or subsystem

  • Path to a Simulink model or subsystem

Depth of system diagram search, specified as inf or a positive integer. SearchDepth specifies how many levels deep to search a diagram container for diagrams. To search all levels, use inf.

Choice to search masked subsystems, specified as a logical. If this property is true, the finder searches masked Subsystem blocks in the diagram container. It searches to the specified SearchDepth and includes the diagrams it finds in the search results.

Choice to search referenced models, specified as a logical. If this property is true, the finder searches models referenced in the diagram container. It searches to the specified SearchDepth and includes the diagrams it finds in the search results.

Choice to search Simulink library links, specified as a logical. If both this property and IncludeMaskedSubsystems are true, the finder searches links in the diagram container to both Subsystem and masked Subsystem blocks in Simulink libraries. It searches to the specified SearchDepth and includes the diagrams it finds in the search results. If this property is true, but IncludeMaskedSubsystems is false, the finder searches only links to Subsystem blocks in Simulink libraries.

Choice to search user library links, specified as a logical. If this property is true and the IncludeMaskedSubsystems property is true, the finder searches links in the diagram container to Subsystem and masked Subsystem blocks in user libraries. It searches to the specified SearchDepth and includes the diagrams it finds in the search results. If this property is true, but the IncludeMaskedSubsystems property is false, the finder searches only links to Subsystem blocks in user libraries.

Choice to include the root diagram in the search results, specified as a logical. If true and the top-level diagram container is a model, the model block diagram is included in the search results. Otherwise, the search results omit the model block diagram.

Choice to include commented-out diagrams in the search results, specified as a logical. If false, commented-out diagrams are excluded from the search results.

Variants to search for diagrams, specified as a string or character vector. Valid values are:

  • All — All variants

  • Active — Only active variants

  • ActivePlusCode — All active variants and code variants

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'}

Whether to close models, specified as true or false. If true, the next method of the finder closes the currently open model before moving to the next model to search. Closing models prevents excessive consumption of memory when searching a model that references many models.

Note

The find method of the finder ignores this property and leaves all referenced models open. For this reason, you should not use the find method to search models with many model references.

Methods

results = find(finder) finds block diagrams in the container specified by the finder. The finder is an slreportgen.finder.SystemDiagramFinder object. results is an array of slreportgen.finder.DiagramResult objects, each of which contains a block diagram found by this method. Adding the array to a report or reporter adds images of all the block diagrams it contains. The reports to which you can add the results of this method are reports of type slreportgen.report.Report or another reporter object, such as an slreportgen.report.Chapter reporter.

tf = hasNext(finder) determines if the container that the finder searches contains at least one diagram. If the container has at least one diagram, the hasNext method queues that diagram as the next diagram that the next method will return. The hasNext method then returns true. Use the next method to obtain that diagram. On subsequent calls, the hasNext method determines if the container has a diagram that the next has not yet retrieved. It queues the diagram for the next method to retrieve and returns true. If there are no more diagrams to be retrieved, this method returns false. To search a container progressively for diagrams, use the hasNext method with the next method in a while loop.

Note

If the current result is the last result in the search queue for the current model and the AutoCloseModel property is true, this method closes the current model before it opens the next model. Although this increases search time, it reduces memory consumption when searching a top model that references many other models. If your model does not reference many other models, to speed up the search, set the AutoCloseModel property to false or use the find method.

result = next(finder) returns the next search result in the result queue that the hasNext method created. The search result contains the resulting diagram. Adding this result object to a report or reporter adds a Diagram reporter for the diagram.

Copy Semantics

Handle. To learn how handle classes affect copy operations, see Copying Objects (MATLAB).

Examples

Find Block Diagrams

Create a report that finds block diagrams in the sf_car model.

import mlreportgen.report.*
import slreportgen.report.*
import slreportgen.finder.*
model_name = 'sf_car';
load_system(model_name);

rpt = slreportgen.report.Report('output','pdf');
add(rpt, TitlePage('Title', sprintf('%s Systems',...
     model_name)));
add(rpt,TableOfContents);
finder = SystemDiagramFinder(model_name); 
results = find(finder);
for result = results
     chapter = Chapter('Title',result.Name);
     add(chapter,result);
     add(rpt,chapter);
end

close(rpt);
close_system(model_name);
rptview(rpt);

Introduced in R2017b

Was this topic helpful?