Main Content

slreportgen.finder.EnumerationTypeFinder Class

Namespace: slreportgen.finder

Find enumerated data types used in Simulink model

Since R2023b

Description

Use objects of the class slreportgen.finder.EnumerationTypeFinder to find which enumerated data types are used in a Simulink® model or subsystem.

The slreportgen.finder.EnumerationTypeFinder class is a handle class.

Class Attributes

HandleCompatible
true

For information on class attributes, see Class Attributes.

Creation

Description

finder = slreportgen.finder.EnumerationTypeFinder(container) creates a finder that finds variables used in the specified container, which can be a Simulink model or subsystem. See the Container property. To specify the container, use a Simulink model or subsystem block path or handle. You can constrain the search to a specific enumeration type name, user, or type of workspace by setting the properties of the finder. Use the find or next method for the finder to perform the search.

Note

This finder provides these options 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 a for-loop.

  • To iterate through the results one at a time, use the hasNext and next methods in a while-loop.

Neither option has a performance advantage.

finder = slreportgen.finder.EnumerationTypeFinder(Name=Value) sets Properties using one or more name-value arguments. You can specify multiple name-value arguments in any order.

example

Properties

expand all

Model or subsystem to search, specified as a string scalar or character vector that contains the path to the model or subsystem, or as a handle to the model or subsystem.

Attributes:

GetAccess
public
SetAccess
public

Name of an enumerated type to find, specified as a character vector or string scalar. If you do not specify a name, then enumeration types are not filtered based on the name property. This property can include regular expressions if Regexp is set to true.

Attributes:

GetAccess
public
SetAccess
public

Data Types: string | char

Names of systems that use an enumeration types to be found, specified as a character vector or string scalar (to specify a single system) or an array of strings or cell array of character vectors (to specify multiple systems/charts). The finder returns the enumeration types used by a model or chart specified in this property. If the value of the Regexp property is true, the finder treats users names in this property as regular expressions and returns enumeration types used by systems whose names match the regular expressions. If this property is empty, the finder does not filter enumeration types based on users.

Attributes:

GetAccess
public
SetAccess
public

Data Types: string | char

Originating workspace type that defines the enumerated data type, specified as one these values.

Source TypeDescription
"all"Finder finds all the enumeration types regardless of the source type it is specified in.
"MATLAB file"Finder finds only those enumeration types that are specified in a MATLAB® file.
"dynamic class"Finder finds only those enumeration types that are specified dynamically. An enumerated type is defined dynamically when you define it using the function Simulink.defineIntEnumType. With this function, you can specify enumerated types you define externally to MATLAB that you want to import for use within the Simulink environment.
"data dictionary"Finder finds only those enumeration types that are specified in a data dictionary.

Attributes:

GetAccess
public
SetAccess
public

Data Types: char | string

Properties of Simulink.VariableUsage objects to find, specified as a cell array of name-value arguments. The finder returns only those enumerated data types whose associated Simulink.VariableUsage object has the specified property values.

Example: finder.Properties = {"SourceType","MATLAB file"}

Attributes:

GetAccess
public
SetAccess
public

Data Types: cell

Whether to match regular expressions, specified as "on" or "off", or as numeric or logical 1 (true) or 0 (false). A value of "on" is equivalent to true, and "off" is equivalent to false. Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState..

  • "on" — enables regular expression matching for the values of the Name, SourceType, and Users properties.

  • "off" — disables regular expression matching.

For more information on regular expressions, see Regular Expressions.

Attributes:

GetAccess
public
SetAccess
public

Compiled status of the models, specified as one of these values.

ValueDescription
"compiled"Get up-to-date results by compiling models before the search.
"cached"Get results more quickly by using data cached during the previous compilation.

Whether to search in the referenced models, specified as a numeric or logical 1 (true) or 0 (false). You can search in models that are referenced by the model or referenced by a block represented by the Container property. When SearchReferencedModels is true:

  • The finder searches only referenced models within the search depth.

  • The finder searches referenced models to the depth specified by SearchDepth, regardless of the depth of the block that contains the referenced model.

  • The finder searches models that are referenced by referenced models.

Note

You can also set the SearchReferencedModels property by using "off" and "on".

Attributes:

GetAccess
public
SetAccess
public

Data Types: logical

Methods

expand all

Examples

collapse all

This example shows you how to add enumeration types in a model to a report.

Create a Simulink Report.

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

Create a chapter.

chapter = mlreportgen.report.Chapter();
chapter.Title = "EnumerationType Example";

Load the model.

model_name = "slrgex_datatypedemo";
load_system(model_name);

Create an enumeration type finder and set its properties to constrain the search.

finder = slreportgen.finder.EnumerationTypeFinder(model_name);
finder.SourceType = "MATLAB file";

Find enumeration types used by the model.

results = find(finder);

Add the results to the chapter.

append(chapter,results);

Add chapter to the report.

append(rpt,chapter);

Close and view the report.

close(rpt);
rptview(rpt);

This example shows how to find enumeration types that start with Sl and end with Sign.

Load the model.

model_name = "slrgex_datatypedemo";
load_system(model_name)

Create an enumeration type finder.

finder = slreportgen.finder.EnumerationTypeFinder(model_name);

Enable regular expression matching.

finder.Regexp = true;

Use the regular expression ^Sl\w*Sign$ to constrain the search to results that start with Sl and end with Sign.

finder.Name = "^Sl\w*Sign$";

Find the matching enumeration types used by the model.

results = find(finder)
results = 
  EnumerationTypeResult with properties:

        Object: [1×1 Simulink.VariableUsage]
          Name: "SlDemoSign"
        Source: "SlDemoSign.m"
    SourceType: "MATLAB file"
         Users: "slrgex_datatypedemo"
           Tag: []

Version History

Introduced in R2023b