Package: coder.dictionary
Configure Embedded Coder Dictionary definition
An object of the coder.dictionary.Entry
class represents one definition
of an Embedded Coder Dictionary. In this API, the object is called an
entry. The information that the object represents is a
definition. In this documentation, definition
refers to the definition of the entry object.
A coder.Dictionary
object contains
three coder.dictionary.Section
objects, which represent the sections of an Embedded Coder
Dictionary: Storage Classes, Memory Sections, and Function Customization Templates. A
coder.dictionary.Section
object contains
coder.dictionary.Entry
objects, which represent the definitions stored in
that section of the Embedded Coder Dictionary. The name of the section identifies the type of
code definitions that the section contains. To access the sections of an Embedded Coder
Dictionary, use a coder.Dictionary
object. To access the dictionary entries
within the section, use a coder.dictionary.Section
object.
The functions addEntry
,
getEntry
,
copyEntry
, and
find
create
coder.dictionary.Entry
objects.
A coder.dictionary.Entry
object has these properties.
Name
— Name of code definitionName of the coder dictionary definition that the entry represents. The name must be unique among the definitions in the section of the dictionary.
DataSource
— Location of code definitionThe location of the code definition. This property is read-only.
Built-in
— Provided by Simulink®.
Model name — Defined in a Simulink model.
Dictionary name — Defined in a Simulink data dictionary.
Package name — Defined in the Simulink package or in a custom package.
To access the properties of the code definition that an entry represents, use the getAvailableProperties
, get
, and
set
methods. Each
type of code definition has available properties listed.
Name
— Name of storage classStorageClass1
(default) | character vector | string scalarName of the storage class. The name must be unique among the storage classes in the dictionary.
For lists of built-in and example storage classes that Simulink provides, see Choose Storage Class for Controlling Data Representation in Generated Code.
Description
— Purpose and functionality of storage classCustom text that you can use to describe the purpose and functionality of the storage class.
DataSource
— Location of code definitionThe location of the code definition. This property is read-only.
Built-in
— Provided by Simulink.
Model name — Defined in a Simulink model.
Dictionary name — Defined in a Simulink data dictionary.
Package name — Defined in the Simulink package or in a custom package.
DataAccess
— Specification to access the dataDirect
(default) | Function
Specification to access data associated with the model. Access the data directly
(Direct
) or through customizable get
and
set
functions (Function
). For more information,
see Access Data Through Functions by Using Storage Classes in Embedded Coder Dictionary.
Setting this property to Function
:
Sets DataScope
to
Imported
.
Means that you cannot specify multi-instance properties.
Enables these properties:
AccessMode
AllowedAccess
GetFunctionName
SetFunctionName
Sets the PreserveDimensions
property to
false
. To preserve dimensions of multidimensional
arrays in the generated code, set DataAccess
to
Direct
.
DataScope
— Specification to generate data definitionExported
(default) | Imported
Specification that the generated code defines the data (Exported
)
or import (Imported
) the data definition from external code. Built-in
storage classes and storage classes in packages such as Simulink can use other scope options, such as File
.
Setting this property to Imported
:
Disables DefinitionFile
. To include your external
source code file in the build process, use model configuration parameters.
For an example, see Configure Data Interface.
Means that you cannot set HeaderFile
to
$N.h
, though you can use the $N
token.
To set this property to Exported
, you must use one of the
tokens $N
or $R
in the value of
HeaderFile
.
Header File
— Name of header file that declares data$N.h
(default) | character vector | string scalarName of the header file that declares the data, specified as a name or naming rule. A naming rule includes a combination of text and tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$R | Name of root model |
$N | Name of associated data element |
$G | Name of storage class |
$U | User token text, which you specify for a model as described in Identifier Format Control |
If you set DataScope
to Exported
,
you must use one of the tokens $R
or $N
in
the value of this property.
If you set DataScope
to Imported
,
you cannot set the value of this property to $N.h
, but you
can use the $N
token.
Definition File
— Name of source file that defines data$N.c
(default) | character vector | string scalarName of the source file that defines the data, specified as a name or naming rule. A naming rule includes a combination of text and tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$R | Name of root model |
$N | Name of associated data element |
$G | Name of storage class |
$U | User token text, which you specify for a model as described in Identifier Format Control |
Setting DataScope
to Imported
disables
DefinitionFile
. To include your external source code file in
the build process, use model configuration parameters. For an example, see Configure Data Interface.
AccessMode
— Specification to access data through functionsValue
(default) | Pointer
Specification for the storage class to access data associated with the model through
functions by using Value
or Pointer
. For more
information, see Access Data Through Functions by Using Storage Classes in Embedded Coder Dictionary.
This property is enabled only when you set DataAccess
to
Function
.
AllowedAccess
— Specification to allow access to data through functionsReadWrite
(default) | ReadOnly
| WriteOnly
Specification for the storage class to allow read and write
(ReadWrite
), read-only (ReadOnly
), or write-only
(WriteOnly
) access to the data.
This property is enabled only when you set DataAccess
to
Function
.
GetFunctionName
— Name of the get
function that fetches the associated dataget_$N$M
(default) | character vector | string scalarName of the get
function that fetches the associated data,
specified as a name or naming rule. A naming rule includes a combination of text and
tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$N | Name of associated data element (required) |
$R | Name of root model |
$M | Mangle text that ensures uniqueness |
$U | User token text. See Identifier Format Control. |
This property is enabled only when you set DataAccess
to
Function
and AllowedAccess
to
ReadWrite
or ReadOnly
.
SetFunctionName
— Name of the set
function that modifies the associated dataset_$N$M
(default) | character vector | string scalarName of the set
function that fetches the modified data,
specified as a name or naming rule. A naming rule includes a combination of text and
tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$N | Name of associated data element (required) |
$R | Name of root model |
$M | Mangle text that ensures uniqueness |
$U | User token text. See Identifier Format Control. |
This property is enabled only when you set DataAccess
to
Function
and AllowedAccess
to
ReadWrite
or WriteOnly
.
DifferentInstanceDataSettings
— Specification to assign separate storage settings for single-instance data and multi-instance datafalse
(default) | true
Specification for the storage class to use either the storage settings that you specify for single-instance data or the settings that you specify for multi-instance data. When you apply the storage class to a data item, the Embedded Coder Dictionary determines if it is a single-instance storage class or a multi-instance storage class by the type of data and by the context of the model within the model reference hierarchy.
Selecting this property enables the properties
SingleInstanceStorageType
,
MultiInstanceStorageType
, and
MultiInstanceStructureTypeName
,
MultiInstanceStructureInstanceName
.
StorageType
— Specification to aggregate data into a structureUnstructured
(default) | Structured
Specification to aggregate the data that uses the storage class into a structure in
the generated code. Each data element appears in the code as a field of the structure.
To create a structure, use Structured
.
Setting this property to Structured
enables
StructureTypeName
and
StructureInstanceName
.
StructureTypeName
— Name of structure type$R$N$G$M
(default) | character vector | string scalarName of the structure type in the generated code, specified as a name or a naming rule. A naming rule includes a combination of text and tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$R | Name of root model |
$N | Base name of associated function, such as step |
$G | Name of storage class |
$U | User token text, which you specify for a model as described in Identifier Format Control |
$M | Name-mangling text inserted, if necessary, to avoid name collisions |
Setting StorageType
to Structured
enables
this property.
StructureInstanceName
— Name of structure variable$G$N$M
(default) | character vector | string scalarName of the structure variable in the generated code, specified as a name or a naming rule. A naming rule includes a combination of text and tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$R | Name of root model |
$N | Base name of associated function, such as step |
$G | Name of storage class |
$U | User token text, which you specify for a model as described in Identifier Format Control |
$M | Name-mangling text inserted, if necessary, to avoid name collisions |
Setting StorageType
to Structured
enables
this property.
SingleInstanceStorageType
— Specification to aggregate single-instance data into a structureStructured
(default) | Unstructured
Specification to aggregate the single-instance data that uses the storage class into
a structure in the generated code. Each data element appears in the code as a field of
the structure. To create a structure, use Structured
.
Setting the property
UseDifferentPropSettingsForInstanceData
to
true
enables this property.
Setting this property to Structured
enables the
properties SingleInstanceStructureTypeName
and
SingleInstanceStructureInstanceName
.
SingleInstanceStructureTypeName
— Name of structure type for single-instance data$R$N$G$M
(default) | character vector | string scalarName of the structure type in the generated code, specified as a name or a naming rule. A naming rule includes a combination of text and tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$R | Name of root model |
$N | Base name of associated function, such as step |
$G | Name of storage class |
$U | User token text, which you specify for a model as described in Identifier Format Control |
$M | Name-mangling text inserted, if necessary, to avoid name collisions |
Setting SingleInstanceStorageType
to
Structured
enables this property.
SingleInstanceStructureInstanceName
— Name of structure variable for single-instance data$G$N$M
(default) | character vector | string scalarName of the structure variable in the generated code, specified as a name or a naming rule. A naming rule includes a combination of text and tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$R | Name of root model |
$N | Base name of associated function, such as step |
$G | Name of storage class |
$U | User token text, which you specify for a model as described in Identifier Format Control |
$M | Name-mangling text inserted, if necessary, to avoid name collisions |
Setting SingleInstanceStorageType
to
Structured
enables this property.
MultiInstanceStorageType
— Specification to aggregate multi-instance data into a structureStructured
(default)Specification to aggregate the single-instance data that uses the storage class into a structure in the generated code. Each data element appears in the code as a field of the structure. You cannot change the value of this property.
Setting the property UseDifferentPropSettingsForInstanceData
to true
enables this property.
MultiInstanceStructureTypeName
— Name of structure type for multi-instance data$R$N$G$M
(default) | character vector | string scalarName of the structure type in the generated code, specified as a name or a naming rule. A naming rule includes a combination of text and tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$R | Name of root model |
$N | Base name of associated function, such as step |
$G | Name of storage class |
$U | User token text, which you specify for a model as described in Identifier Format Control |
$M | Name-mangling text inserted, if necessary, to avoid name collisions |
Setting the property
UseDifferentPropSettingsForInstanceData
to
true
enables this property.
If you set the property DataAccess
to
Function
, you cannot set this property.
MultiInstanceStructureInstanceName
— Name of structure variable for multi-instance data$G$N$M
(default) | character vector | string scalarName of the structure variable in the generated code, specified as a name or a naming rule. A naming rule includes a combination of text and tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$R | Name of root model |
$N | Base name of associated function, such as step |
$G | Name of storage class |
$U | User token text, which you specify for a model as described in Identifier Format Control |
$M | Name-mangling text inserted, if necessary, to avoid name collisions |
Setting the property
UseDifferentPropSettingsForInstanceData
to
true
enables this property.
If you set the property DataAccess
to
Function
, you cannot set this property.
DataInit
— How to initialize dataDynamic
(default) | Static
|
None
Specification that the generated codes initialize the data.
Dynamic
— The generated code initializes the data as part
of the model initialization entry-point function.
Static
— The generated code initializes the data in the
same statement that defines and allocates memory for the data. The assignment
statement appears at the top of a .c
or .cpp
source file, outside of a function.
None
— The generated code does not initialize the
data.
If you set Const
to true
, you cannot
set this property to Dynamic
.
Setting this property to Dynamic
sets the property
Const
to false
.
MemorySection
— Location in memory to allocate dataNone
(default) | coder.dictionary.Entry
objectLocation in memory to allocate data, specified as a
coder.dictionary.Entry
object that represents a memory section that
exists in the Embedded Coder Dictionary. For information about memory sections, see
Control Data and Function Placement in Memory by Inserting Pragmas.
PreserveDimensions
— Specification to preserve dimensions of multidimensional arraysfalse
(default) | true
Specification for the storage class to preserve dimensions of multidimensional arrays in the generated code. For more information, see Preserve Dimensions of Multidimensional Arrays in Generated Code.
Const
— Specification to apply const
qualifierfalse
(default) | true
Specification to apply the const
qualifier to the data.
If you select this property, you cannot set DataInit
to
Dynamic
.
Setting DataInit
to Dynamic
\sets this
property to false
.
Volatile
— Specification to apply volatile
qualifierfalse
(default) | true
Specification to apply the volatile
qualifier to the data.
OtherQualifier
— Specification to apply a custom qualifierSpecification to apply a custom qualifier to the data. For example, some memory
architectures support qualifiers far
and
huge
.
Do not use this property to apply the keyword static
. Instead,
use the built-in storage class FileScope
, which you cannot apply with
the Code Mappings editor. See Choose Storage Class for Controlling Data Representation in Generated Code.
AccessibleByParameters
— Whether to allow usage with model parametersfalse
(default) | true
Specification indicating whether to allow usage of the storage class with model parameters.
Setting DataInit
to Static
sets this
property to true
.
Setting DataInit
to Dynamic
sets this
property to false
.
To set the value of this property, set DataInit
to
None
.
AccessibleBySignals
— Whether to allow usage with model signalstrue
(default) | false
Specification indicating whether to allow usage of the storage class with model signals.
Setting DataInit
to Dynamic
sets this
property to true
.
Setting DataInit
to Static
sets this
property to false
.
To set the value of this property, set DataInit
to
None
.
Name
— Name of function templateFunctionTemplate1
(default) | character vector | string scalarName of the template. The name must be unique among the function templates in the dictionary. Embedded Coder® provides the built-in templates listed in this table.
Template | Description |
---|---|
ModelFunction | In the Code Mappings editor, use for entry-point functions for initialization, execution, termination, and reset (see Configure Default Code Generation for Functions) |
UtilityFunction | In the Code Mappings editor, use for shared utility functions (see Configure Default Code Generation for Functions) |
Description
— Purpose and functionality of function templateCustom text that you can use to describe the purpose and functionality of the function template.
FunctionName
— Names of generated functions$R$N
(default) | character vector | string scalarNames of the functions in the generated code, specified as a naming rule. A naming rule includes a combination of text and tokens. Valid tokens are listed in this table.
Token | Description |
---|---|
$R | Name of root model |
$N | Base name of associated function, such as step |
$U | User token text, which you specify for a model as described in Identifier Format Control |
$C | For shared utility functions, a checksum inserted to avoid name collisions |
$M | Name-mangling text inserted, if necessary, to avoid name collisions |
MemorySection
— Location in memory to allocate functionNone
(default) | coder.dictionary.Entry
objectLocation in memory to allocate function, specified as a
coder.dictionary.Entry
object that represents a memory section that
exists in the Embedded Coder Dictionary. For information about memory sections, see
Control Data and Function Placement in Memory by Inserting Pragmas.
Name
— Name of memory sectionName of the memory section. The name must be unique among the memory sections in the dictionary. Embedded Coder provides the built-in memory sections listed in this table.
Memory Section | Description |
---|---|
MemConst | Apply the storage type qualifier const to the
data. |
MemVolatile | Apply the storage type qualifier volatile to the
data. |
MemConstVolatile | Apply the storage type qualifiers const and
volatile to the data. |
Description
— Purpose and functionality of memory sectionCustom text that you can use to describe the purpose and functionality of the memory section.
Comment
— Comment to insert in the generated codeCode comment that the code generator includes with the pragmas or other decorations
that you specify with PreStatement
and
PostStatement
.
PreStatement
— Code to insert before data or function codeCode, such as pragmas, to insert before the definitions and declarations of the data or functions that are in the memory section.
You can use the token $R
to represent the name of the model that
uses the memory section.
When you set StatementsSurround
to
EachVariable
, you can use the token $N
to
represent the name of each variable or function that uses the memory section.
PostStatement
— Code to insert after data or function codeCode, such as pragmas, to insert after the definitions and declarations of the data or functions that are in the memory section.
You can use the token $R
to represent the name of the model that
uses the memory section.
When you set StatementsSurround
to
EachVariable
, you can use the token $N
to
represent the name of each variable or function that uses the memory section.
StatementsSurround
— Specification to wrap data and functions separately or in a groupEachVariable
(default) | AllVariables
Specification to insert code statements (PreStatement
and
PostStatement
):
Around each variable and function that uses the memory section. Select
EachVariable
.
Once, around the entire memory section. The generated code aggregates the
variable and function definitions into a contiguous code block and surrounds the
block with the statements. Select AllVariables
.
get | Get value of code definition property |
set | Set value of code definition property |
getAvailableProperties | Return properties for code definition |
deleteEntry | Delete Embedded Coder Dictionary entry |
valid | Determine if coder.dictionary.Entry object represents a valid
code definition |
Open the model rtwdemo_roll
and represent the Embedded Coder
Dictionary by using the coder.Dictionary
object
coderDictionary
. Use this object to access the Storage Classes
section of the dictionary, which contains the storage class definitions.
rtwdemo_roll
coderDictionary = coder.dictionary.open('rtwdemo_roll');
Create a coder.dictionary.Section
object that represents the
Storage Classes section of the Embedded Coder Dictionary.
storageClassesSect = getSection(coderDictionary, 'StorageClasses');
Add a definition named MyStorageClass
to the Storage Classes
section. The storage class definition uses the default property settings. You can change
these settings by using the set
function.
newEntry = addEntry(storageClassesSect,'MyStorageClass')
newEntry = Entry with properties: Name: 'MyStorageClass' DataSource: 'rtwdemo_roll'