Main Content

万博1manbetxsimulink.data.dictionary.enumtypedefinition

将枚举类型定义存储在数据字典中

Description

一个万博1manbetxsimulink.data.dictionary.enumtypedefinition对象在数据词典中定义了枚举的数据类型。您将对象存储在数据字典条目中,因此链接到字典的模型可以使用枚举的类型定义。

In the MATLAB®基础工作区,万博1manbetxsimulink.data.dictionary.enumtypedefinition对象保留有关枚举类型的信息,但不能定义其他变量或模型使用的类型。

创建

Description

When you use the functionimportEnumTypes要将枚举类型的定义导入数据字典,Simulink万博1manbetx®创建一个万博1manbetxsimulink.data.dictionary.enumtypedefinitionobject in the dictionary for each imported definition. The dictionary stores each object in an individual entry.

例子

万博1manbetxsimulink.data.dictionary.enumtypedefinition函数创建a万博1manbetxsimulink.data.dictionary.enumtypedefinitionobject with default property values and a single enumeration member that has underlying integer value0

特性

展开全部

Flag to prefix enumerations with the class name in generated code, specified astrueor错误的

If you specifytrue,,,,when you generate code the identifier of each enumeration member begins with the name of the enumeration class. For example, an enumeration classLEDCOLOR与枚举成员绿色and红色的将生成代码中的枚举成员定义为LEDCOLOR_GREENandLEDCOLOR_RED

数据类型:逻辑

标志以控制生成代码中的数据类型定义,指定为'汽车',,,,“进口”, 或者“出口”。这table describes the behavior of generated code for each value.

Value 行动
一个uto(默认)

如果您不指定the propertyheaderfile,将数据类型定义导出到模型_types.h, 在哪里模型是模型名称。

If you specifyheaderfile,从指定的标头文件导入数据类型定义。

出口

Export the data type definition to a separate header file.

如果您不指定the propertyheaderfile,标题文件名默认为类型。h, 在哪里类型is the data type name.

Imported

从单独的标头文件导入数据类型定义。

如果您不指定the propertyheaderfile,标题文件名默认为类型。h, 在哪里类型is the data type name.

默认枚举成员,,,,specified as a character vector. SpecifyDefaultValue作为您已经定义的枚举成员的名称。

当您创建一个万博1manbetxsimulink.data.dictionary.enumtypedefinitionobject,DefaultValue是一个空的角色向量,'',,,,and Simulink uses the first enumeration member as the default member.

Example:'enummember1'

Description of the enumerated data type, specified as a character vector. Use this property to explain the purpose of the type in generated code.

Example:'Two possible colors of LED indicator: GREEN and RED.'

数据类型:char

定义枚举数据类型的标题文件的名称,以生成代码,指定为字符向量。用一个。hextension to specify the file name.

如果您不指定HeaderFile,,,,generated code uses a default header file name that depends on the value of theDataScope财产 。

Example:'mytypeincludefile.h'

数据类型:char

枚举成员基础的整数值的数据类型,指定为字符向量。生成的代码使用您指定的数据类型存储基础整数值。

You can specify one of these supported integer types:

  • 'int8'

  • 'int16'

  • 'int32'

  • 'uint8'

  • 'uint16'

要使用目标硬件的本机整数类型存储在生成代码中的基础整数值,请指定StorageType作为空的角色向量,'',这是默认值。

Example:'int16'

''

对象功能

附录 将枚举成员添加到数据字典中的列举数据类型定义
删除 从数据字典中的列举数据类型定义中删除枚举成员

例子

全部收缩

Create an object that can store the definition of an enumerated type. By default, the new type defines a single enumeration memberENUM1具有基础整数价值0

Mycolors= Simulink.data.dictionary.EnumTypeDefinition
mycolors = 万博1manbetxsimulink.data.dictionary.enumtypedefinition enum1

将一些枚举成员添加到类型的定义中。

附录(Mycolors,'Orange',,,,1,,,,'')附录(Mycolors,'黑色的',,,,2,'')附录(Mycolors,'青色',,,,3,'')mycolors
mycolors = 万博1manbetxsimulink.data.dictionary.enumtypedefinition enum1Orange Black Cyan

删除默认枚举成员ENUM1。自从ENUM1是列表中的第一个枚举成员,用索引识别它1

删除术(Mycolors,1)Mycolors
mycolors = 万博1manbetxsimulink.data.dictionary.enumtypedinition橙色黑色青色

通过配置代表它的对象的属性来自定义枚举类型。

mycolors.description =“这些是我最喜欢的颜色。”;Mycolors。DefaultValue ='青色';mycolors.headerfile ='colorsType.h';

打开数据字典mydictionary_ex_api.sldd并用一个万博1manbetxsimulink.data.dictionary命名的对象mydictionaryobj

myDictionaryObj = 万博1manbetxsimulink.data.dictionary.open('myDictionary_ex_API.sldd');

导入定义枚举类型的对象Mycolors到字典。

importFromBaseWorkspace(myDictionaryObj,'varList',,,,{``mycolors''});

备择方案

您可以使用Model Explorer添加和修改数据字典中存储的枚举数据类型。

版本历史记录

Introduced in R2015a