Main Content

本页翻译不是最新的。点击此处可查看最新英文版本。

coder.dictionary.create

创建 Embedded Coder 字典和 coder.Dictionary 对象

自 R2019b 起

说明

示例

coderDictionaryObj = coder.dictionary.create(sourceName) 在由 sourceName 辨识的模型或 Simulink® 数据字典中创建一个 Embedded Coder 字典。该函数返回一个表示新 Embedded Coder 字典的 coder.Dictionary 对象。Embedded Coder 字典使用数据接口配置类型。

当源模型或数据字典已有 Embedded Coder 字典时,使用 coder.dictionary.open 来访问 coder.Dictionary 对象。当您在 Embedded Coder 中打开模型时,或当您为模型或数据字典打开“Embedded Coder 字典”对话框时,会创建一个 Embedded Coder 字典。

示例

coderDictionaryObj = coder.dictionary.create(sourceName,interfaceType) 创建使用指定的代码接口类型的 Embedded Coder 字典。通过使用以下语法,您可以创建使用数据接口配置或服务接口配置的 Embedded Coder 字典。 (自 R2023b 起)

示例

全部折叠

创建一个数据字典。

dataDictionary = Simulink.data.dictionary.create('DataDictionary.sldd');

在该数据字典中创建一个 Embedded Coder 字典。

coderDictionary = coder.dictionary.create(dataDictionary);
coderDictionary = 

  Dictionary with Sections:

                    StorageClasses: [1×1 coder.dictionary.Section]
                    MemorySections: [1×1 coder.dictionary.Section]
    FunctionCustomizationTemplates: [1×1 coder.dictionary.Section]

创建一个数据字典来存储 Embedded Coder 字典。

dataDictionary = Simulink.data.dictionary.create('DataDictionary.sldd');

在该数据字典中创建一个 Embedded Coder 字典。指定服务接口配置类型。

coderDictionary = coder.dictionary.create(dataDictionary,'ServiceInterface');
coderDictionary = 

  Dictionary with properties and Sections:

               ServicesHeaderFileName: 'services.h'
                    InitTermFunctions: [1×1 coder.dictionary.Section]
           PeriodicAperiodicFunctions: [1×1 coder.dictionary.Section]
               DataReceiverInterfaces: [1×1 coder.dictionary.Section]
                 DataSenderInterfaces: [1×1 coder.dictionary.Section]
               DataTransferInterfaces: [1×1 coder.dictionary.Section]
                      TimerInterfaces: [1×1 coder.dictionary.Section]
            ParameterTuningInterfaces: [1×1 coder.dictionary.Section]
    ParameterArgumentTuningInterfaces: [1×1 coder.dictionary.Section]
                MeasurementInterfaces: [1×1 coder.dictionary.Section]
           SubcomponentEntryFunctions: [1×1 coder.dictionary.Section]
               SharedUtilityFunctions: [1×1 coder.dictionary.Section]
                       StorageClasses: [1×1 coder.dictionary.Section]
                   DataMemorySections: [1×1 coder.dictionary.Section]
               FunctionMemorySections: [1×1 coder.dictionary.Section]

现在,您可以访问字典的各个分区,并使用这些分区来添加和编辑服务接口定义。

输入参数

全部折叠

目标模型文件或数据字典的名称,指定为字符向量、字符串标量或 Simulink.data.Dictionary 对象。

  • 必须加载一个模型(例如,通过使用 load_system 加载)或该模型处于打开状态。

    您不需要指定 .slx 文件扩展名。

  • 必须在模型资源管理器、当前文件夹或 MATLAB® 路径中打开一个字典。

    您必须指定 .sldd 文件扩展名。

示例: 'myLoadedModel'

示例: 'myDictionary.sldd'

数据类型: char

自 R2023b 起

代码接口配置类型,指定为 'DataInterface''ServiceInterface'。如果 sourceName 是 Simulink 模型,则 interfaceType 必须为 'DataInterface'

通过考虑如何部署生成的代码来选择代码接口配置类型:

  • 数据接口配置 - 代码生成器创建一个要在目标设备上运行的程序。生成的代码使用您定义的数据接口。

  • 服务接口配置 - 代码生成器创建一个要在更大的应用程序中部署的算法。平台中间件调用算法代码并为目标设备提供服务。生成的代码根据您在服务接口配置中的定义调用服务。要创建服务接口配置,必须使用存储在 Simulink 数据字典中的 Embedded Coder 字典。

示例: 'ServiceInterface'

数据类型: char

输出参数

全部折叠

新创建的 Embedded Coder 字典,以 coder.Dictionary 对象形式返回。

版本历史记录

在 R2019b 中推出

全部展开