Main Content

coder.dictionary.move

Migrate code generation definitions between models and data dictionaries

Description

coder.dictionary.move(sourceName,destinationName) moves code generation definitions, such as storage classes, from the Embedded Coder Dictionary in sourceName to the Embedded Coder Dictionary in destinationName. The definitions are removed from sourceName. The source and destination dictionaries must use the same code interface configuration type. To copy code definitions from one Embedded Coder Dictionary to another, use coder.dictionary.copy.

If a code generation definition in sourceName has the same name as a definition in destinationName, move moves the source entry into the destination, and then renames the entry in the destination.

Use this function to:

  • Move code generation definitions from a model to a Simulink® data dictionary. For more information, see Share Code Interface Configuration Between Models.

  • In a hierarchy of referenced Simulink data dictionaries, move the Embedded Coder Dictionary from one data dictionary to another. In a hierarchy of referenced dictionaries, only one dictionary can store an Embedded Coder Dictionary.

For general information about Embedded Coder Dictionaries and code generation definitions, see Define Service Interfaces, Storage Classes, Memory Sections, and Function Templates for Software Architecture.

example

Examples

collapse all

Create a storage class in the Embedded Coder Dictionary of the example model RollAxisAutopilot. Then, move the storage class to the Embedded Coder Dictionary in EmbeddedCoderIntro.

Open the model RollAxisAutopilot and represent the Embedded Coder Dictionary by using a coder.Dictionary object. Use this object to access the Storage Classes section of the dictionary and represent the section by using a coder.dictionary.Section object.

openExample('RollAxisAutopilot')
coderDictionary = coder.dictionary.open('RollAxisAutopilot');
storageClassesSect = getSection(coderDictionary, 'StorageClasses');

Add a storage class definition named MyStorageClass to the Storage Classes section. The storage class definition uses the default property settings.

newEntry = addEntry(storageClassesSect,'MyStorageClass')
newEntry = 

  Entry with properties:

          Name: 'MyStorageClass'
    DataSource: 'RollAxisAutopilot'

Save a copy of RollAxisAutopilot in your current folder. Saving the model saves the storage class in the Embedded Coder Dictionary.

Open the other model, EmbeddedCoderIntro.

openExample('EmbeddedCoderIntro')

Move the contents of the Embedded Coder Dictionary in RollAxisAutopilot to the Embedded Coder Dictionary in EmbeddedCoderIntro.

coder.dictionary.move('RollAxisAutopilot','EmbeddedCoderIntro')

Open the Embedded Coder Dictionary for EmbeddedCoderIntro.

In the Embedded Coder Dictionary window, on the Storage Classes tab, the storage class MyStorageClass appears. The storage class no longer exists in RollAxisAutopilot.

Input Arguments

collapse all

Source model file or data dictionary, specified as a character vector or string scalar.

  • A model must be loaded (for example, by using load_system) or open.

    You do not need to specify the .slx file extension.

  • A dictionary must be open in the Model Explorer, in the current folder, or on the MATLAB® path.

    You must specify the .sldd file extension.

Example: 'myLoadedModel'

Example: 'myDictionary.sldd'

Data Types: char

Destination model file or data dictionary, specified as a character vector or string scalar.

  • A model must be loaded (for example, by using load_system) or open.

    You do not need to specify the .slx file extension.

  • A dictionary must be open in the Model Explorer, in the current folder, or on the MATLAB path.

    You must specify the .sldd file extension.

  • The interface configuration type of the destination dictionary must match the type of the source dictionary. Check the type by using the getCodeInterfaceType method.

Example: 'myLoadedModel'

Example: 'myDictionary.sldd'

Data Types: char

Version History

Introduced in R2018a

expand all