Main Content

coder.dictionary.Entry class

Package: coder.dictionary

Configure Embedded Coder Dictionary definition

Since R2019b

Description

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 coder.dictionary.Section objects, which represent the categories of an Embedded Coder Dictionary. 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.

Creation

The functions addEntry, getEntry, copyEntry, and find create coder.dictionary.Entry objects.

Properties

expand all

A coder.dictionary.Entry object has these properties.

Name of the coder dictionary definition that the entry represents. The name must be unique among the definitions in the section of the dictionary.

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

Storage Classes

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

Custom text that you can use to describe the purpose and functionality of the storage class.

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

Specification to access data associated with the model. Access the data directly (Direct), through customizable get and set functions (Function), or by using a pointer (Pointer). For more information, see Access Data Through Functions by Using Storage Classes in Embedded Coder Dictionary.

Dependencies

  • Setting this property to Function or Pointer:

    • Sets DataScope to Imported.

    • Means that you cannot specify multi-instance properties.

    • Sets the PreserveDimensions property to false. To preserve dimensions of multidimensional arrays in the generated code, set DataAccess to Direct.

In addition, setting this property to Function enables these properties:

  • AccessMode

  • AllowedAccess

  • GetFunctionName

  • SetFunctionName

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.

Dependencies

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

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

TokenDescription
$RName of root model
$NName of associated data element
$GName of storage class
$UUser token text, which you specify for a model as described in Identifier Format Control

Dependencies

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

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

TokenDescription
$RName of root model
$NName of associated data element
$GName of storage class
$UUser token text, which you specify for a model as described in Identifier Format Control

Dependencies

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.

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.

Dependencies

This property is enabled only when you set DataAccess to Function.

Specification for the storage class to allow read and write (ReadWrite), read-only (ReadOnly), or write-only (WriteOnly) access to the data.

Dependencies

This property is enabled only when you set DataAccess to Function.

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

TokenDescription
$NName of associated data element (required)
$RName of root model
$MMangle text that ensures uniqueness
$UUser token text. See Identifier Format Control.

Dependencies

This property is enabled only when you set DataAccess to Function and AllowedAccess to ReadWrite or ReadOnly.

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

TokenDescription
$NName of associated data element (required)
$RName of root model
$MMangle text that ensures uniqueness
$UUser token text. See Identifier Format Control.

Dependencies

This property is enabled only when you set DataAccess to Function and AllowedAccess to ReadWrite or WriteOnly.

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.

Dependencies

Selecting this property enables the properties SingleInstanceStorageType, MultiInstanceStorageType, and MultiInstanceStructureTypeName, MultiInstanceStructureInstanceName.

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.

Dependencies

Setting this property to Structured enables StructureTypeName and StructureInstanceName.

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

TokenDescription
$RName of root model
$NBase name of associated function, such as step
$GName of storage class
$UUser token text, which you specify for a model as described in Identifier Format Control
$MName-mangling text inserted, if necessary, to avoid name collisions

Dependencies

Setting StorageType to Structured enables this property.

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

TokenDescription
$RName of root model
$NBase name of associated function, such as step
$GName of storage class
$UUser token text, which you specify for a model as described in Identifier Format Control
$MName-mangling text inserted, if necessary, to avoid name collisions

Dependencies

Setting StorageType to Structured enables this property.

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.

Dependencies

  • Setting the property UseDifferentPropSettingsForInstanceData to true enables this property.

  • Setting this property to Structured enables the properties SingleInstanceStructureTypeName and SingleInstanceStructureInstanceName.

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

TokenDescription
$RName of root model
$NBase name of associated function, such as step
$GName of storage class
$UUser token text, which you specify for a model as described in Identifier Format Control
$MName-mangling text inserted, if necessary, to avoid name collisions

Dependencies

Setting SingleInstanceStorageType to Structured enables this property.

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

TokenDescription
$RName of root model
$NBase name of associated function, such as step
$GName of storage class
$UUser token text, which you specify for a model as described in Identifier Format Control
$MName-mangling text inserted, if necessary, to avoid name collisions

Dependencies

Setting SingleInstanceStorageType to Structured enables this property.

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.

Dependencies

Setting the property UseDifferentPropSettingsForInstanceData to true enables this property.

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

TokenDescription
$RName of root model
$NBase name of associated function, such as step
$GName of storage class
$UUser token text, which you specify for a model as described in Identifier Format Control
$MName-mangling text inserted, if necessary, to avoid name collisions

Dependencies

  • Setting the property UseDifferentPropSettingsForInstanceData to true enables this property.

  • If you set the property DataAccess to Function, you cannot set this property.

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

TokenDescription
$RName of root model
$NBase name of associated function, such as step
$GName of storage class
$UUser token text, which you specify for a model as described in Identifier Format Control
$MName-mangling text inserted, if necessary, to avoid name collisions

Dependencies

  • Setting the property UseDifferentPropSettingsForInstanceData to true enables this property.

  • If you set the property DataAccess to Function, you cannot set this property.

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.

Dependencies

  • If you set Const to true, you cannot set this property to Dynamic.

  • Setting this property to Dynamic sets the property Const to false.

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

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.

Specification to apply the const qualifier to the data.

Dependencies

  • If you select this property, you cannot set DataInit to Dynamic.

  • Setting DataInit to Dynamic \sets this property to false.

Specification to apply the volatile qualifier to the data.

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

Specification indicating whether to allow usage of the storage class with model parameters.

Dependencies

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

Specification indicating whether to allow usage of the storage class with model signals.

Dependencies

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

Function Customization Templates

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

TemplateDescription
ModelFunctionIn the Code Mappings editor, use for entry-point functions for initialization, execution, termination, and reset (see Configure Default Code Generation for Functions)
UtilityFunctionIn the Code Mappings editor, use for shared utility functions (see Configure Default Code Generation for Functions)

Custom text that you can use to describe the purpose and functionality of the function template.

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

TokenDescription
$RName of root model
$NBase name of associated function, such as step
$UUser token text, which you specify for a model as described in Identifier Format Control
$CFor shared utility functions, a checksum inserted to avoid name collisions
$MName-mangling text inserted, if necessary, to avoid name collisions

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

Memory Sections

Name of the memory section, specified as a character vector or string scalar. 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 SectionDescription
MemConstApply the storage type qualifier const to the data.
MemVolatileApply the storage type qualifier volatile to the data.
MemConstVolatileApply the storage type qualifiers const and volatile to the data.

Custom text that you can use to describe the purpose and functionality of the memory section.

Code comment that the code generator includes with the pragmas or other decorations that you specify with PreStatement and PostStatement.

Code, 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.

Code, 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.

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.

Receiver Service Interfaces

Name of the receiver service, specified as a character vector or string scalar. Embedded Coder provides the example services listed in this table.

Receiver ServiceDescription
ReceiverExample1Favor memory optimization over data freshness. This service has DataCommunicationMethod set to OutsideExecution, so the service reads data from another function before the function starts executing.
ReceiverExample2Favor data freshness over memory optimization. This service has DataCommunicationMethod set to DuringExecution, so the service reads data from another function immediately during execution.
ReceiverExample3Use this option to maximize performance of component code or if mutual exclusion is inherent in component model design. This service has DataCommunicationMethod set to DirectAccess, so the service reads data from generated function code directly by using memory that platform services manage for the target execution environment.

How receiver data transmission is handled between the target platform service and the run-time environment, specified as one of these options:

  • OutsideExecution — Read data from another function before the function starts executing. Use this option to favor memory optimization over data freshness.

  • DuringExecution — Read data from another function immediately during execution. The generated function code that calls the service must use a local buffer to maintain value coherence during execution. Use this option to favor data freshness over memory optimization.

  • DirectAccess — Read data from generated function code directly by using memory that platform services manage. Use this option to maximize performance of component code or if mutual exclusion is inherent in component model design.

Names of the receiver 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.

TokenDescription
$RName of root model
$GService name
$NElement name
$XCurrent callable function
$UUser token text, which you specify for a model as described in Identifier Format Control
$MName-mangling text inserted to avoid name collisions

Dependencies

To specify a function naming rule, you must set DataCommunicationMethod to OutsideExecution or DuringExecution.

Storage class definition, specified as one of the definitions in the StorageClasses section of the dictionary.

Dependencies

To specify a storage class receiver services, you must set DataCommunicationMethod to DirectAccess.

Sender Service Interfaces

Name of the sender service, specified as a character vector or string scalar. Embedded Coder provides the example services listed in this table.

Sender ServiceDescription
SenderExample1Favor memory optimization over data freshness. This service has DataCommunicationMethod set to OutsideExecution, so the service sends data to another function after the function executes.
SenderExample2Favor data freshness over memory optimization. This service has DataCommunicationMethod set to DuringExecution, so the service reads data from another function immediately during execution.
SenderExample3Use this option to maximize performance of component code or if mutual exclusion is inherent in component model design. This service has DataCommunicationMethod set to DirectAccess, so the service reads data from generated function code directly by using memory that platform services manage for the target execution environment.

How sender data transmission is handled between the task and the run-time environment, specified as one of these options:

  • OutsideExecution — Send data to another function before the function starts executing. Use this option to favor memory optimization over data freshness.

  • DuringExecution — Send data to another function immediately during execution. The generated function code that calls the service must use a local buffer to maintain value coherence during execution. Use this option to favor data freshness over memory optimization.

  • DirectAccess — Send data to generated function code directly by using memory that platform services manage. Use this option to maximize performance of component code or if mutual exclusion is inherent in component model design.

Names of the sender 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.

TokenDescription
$RName of root model
$GService name
$NElement name
$XCurrent callable function
$UUser token text, which you specify for a model as described in Identifier Format Control
$MName-mangling text inserted to avoid name collisions

Dependencies

To specify a function naming rule, you must set DataCommunicationMethod to OutsideExecution or DuringExecution.

Names of the sender functions that send a value by reference 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.

TokenDescription
$RName of root model
$GService name
$XCurrent callable function
$UUser token text, which you specify for a model as described in Identifier Format Control

Dependencies

To specify a function naming rule, the definition must be a data sender service and you must set DataCommunicationMethod to OutsideExecution or DuringExecution.

Storage class definition, specified as one of the definitions in the StorageClasses section of the dictionary.

Dependencies

To specify a storage class receiver services, you must set DataCommunicationMethod to DirectAccess.

Data Transfer Service Interfaces

Name of the data transfer service, specified as a character vector or string scalar. Embedded Coder provides the example services listed in this table.

Data Transfer ServiceDescription
DataTransferExample1Favor memory optimization over data freshness. This service has DataCommunicationMethod set to OutsideExecution, so the service receives and sends data from another function outside of function execution.
DataTransferExample2Favor data freshness over memory optimization. This service has DataCommunicationMethod set to DuringExecution, so the service reads data from another function immediately during execution.

How data transmission is handled between the task and the run-time environment, specified as one of these options:

  • OutsideExecution — Communicate data to another function before the function starts executing. Use this option to favor memory optimization over data freshness.

  • DuringExecution — Communicate data to another function immediately during execution. The generated function code that calls the service must use a local buffer to maintain value coherence during execution. Use this option to favor data freshness over memory optimization.

Names of the receiver 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.

TokenDescription
$RName of root model
$NElement name
$XCurrent callable function
$MName-mangling text inserted to avoid name collisions

Names of the sender 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.

TokenDescription
$RName of root model
$NElement name
$XCurrent callable function
$MName-mangling text inserted to avoid name collisions

Timer Services

Name of the timer service, specified as a character vector or string scalar. Embedded Coder provides the example service listed in this table.

Timer ServiceDescription
TimerServiceExample1The timer service executes outside of function execution.

How data transmission is handled between the task and the run-time environment, specified as one of these options:

  • OutsideExecution — Communicate data to another function before the function starts executing. Use this option to favor memory optimization over data freshness.

  • DuringExecution — Communicate data to another function immediately during execution. The generated function code that calls the service must use a local buffer to maintain value coherence during execution. Use this option to favor data freshness over memory optimization.

Names of the clock tick 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.

TokenDescription
$GService name
$XCurrent callable function
$UUser token text, which you specify for a model as described in Identifier Format Control

Dependencies

  • If you create multiple timer services, use the $G token.

  • If you set DataCommunicationMethod to OutsideExecution, use the $X token.

Parameter Tuning Interfaces

Name of the parameter tuning service, specified as a character vector or string scalar. Embedded Coder provides the example service listed in this table.

Parameter Tuning ServiceDescription
ParameterTuningExample1Service for tuning parameters.

Storage class definition, specified as one of the definitions in the StorageClasses section of the dictionary.

Parameter Argument Tuning Interfaces

Name of the parameter argument tuning service, specified as a character vector or string scalar. Embedded Coder provides the example service listed in this table.

Parameter Argument Tuning ServiceDescription
ParameterArgumentTuningExample1Service for tuning parameter arguments.

Storage class definition, specified as one of the definitions in the StorageClasses section of the dictionary.

Measurement Service Interfaces

Name of the measurement service, specified as a character vector or string scalar. Embedded Coder provides the example service listed in this table.

Measurement ServiceDescription
MeasurementExample1Service for measuring signals.

Storage class definition, specified as one of the definitions in the Storage Class section of the dictionary.

Methods

expand all

Examples

collapse all

Open the model RollAxisAutopilot 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.

openExample('RollAxisAutopilot')
coderDictionary = coder.dictionary.open('RollAxisAutopilot');

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: 'RollAxisAutopilot'

Version History

Introduced in R2019b

expand all