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 finder's find or next method 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 pair 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.

Data Types: string | char | handle

Name of an enumerated type to find, specified as a string scalar or character vector. 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.

Data Types: string | char

Names of systems that use an enumeration types to be found, specified as a string scalar or character vector (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.

Data Types: string | char

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

  • "all"

  • "MATLAB file"

  • "dynamic class"

  • "data dictionary"

Source TypeValueDescription
MATLAB® file"BasicColors.m"The enumerated type is defined in the MATLAB file BasicColors.m.
Dynamic class"Simulink.defineIntEnumType"The enumerated type is defined dynamically and has no source. 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"sldemo_fuelsys_dd_controller.sldd"The enumerated type is defined in the data dictionary named sldemo_fuelsys_dd_controller.sldd.

Data Types: 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"}

Data Types: string | char

Regular expression matching, specified as false or true. If Regexp is false, regular expression matching is not enabled. If Regexp is true, regular expression matching is enabled for the values of the Name and Users properties. For example, this code finds variables that start with vehicle.

Run the following command to access the supporting files used in this example.

openExample('rptgenext/SimulinkReportGeneratorFilesExample');
finder = slreportgen.finder.EnumerationTypeFinder("sf_car");
finder.Regexp = true;
finder.Name = "^vehicle";

You can match only those input arguments that have character vector values.

Data Types: logical

Compiled status of the models, specified as one of the values in the table.

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 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".

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);

Version History

Introduced in R2023b