coder.Dictionary.setDictionaryDefault - Set default service for service interface section or default property value for data
interface category - MATLAB ([original](https://in.mathworks.com/help/ecoder/ref/coder.dictionary.setdictionarydefault.html)) ([raw](?raw))
Class: coder.Dictionary
Namespace: coder
Set default service for service interface section or default property value for data interface category
Since R2023b
Syntax
Description
setDictionaryDefault([serviceDict](#mw%5F7b76b564-b3fb-4695-b95d-cd2108acf4cd),[sectionName](#mw%5Feb8ed069-d8ec-40da-abae-7750ac98d320),[defaultEntry](#mw%5Feae66f50-4c6a-4fc5-b21b-95c7f9bc7ebd))
specifies the default entry defaultEntry
for the service interface section sectionName
in the service interfaces coder dictionaryserviceDict
.
setDictionaryDefault([dataDict](#mw%5F38f79d04-8f73-4236-aaf1-4750f19dc979),[categoryName](#mw%5F6e1d779c-7c6c-498a-93dd-6890634ce0ac),[propName](#mw%5Fb0640ffa-73c5-4e02-98a7-927681465f43),[defaultPropVal](#mw%5Fd184fdeb-2171-4215-a744-db11d9c86c55))
specifies the default value defaultPropVal
for the propertypropName
of the category categoryName
in the data interfaces coder dictionary dataDict
.
Input Arguments
Embedded CoderĀ® Dictionary that contains a service interface configuration, specified as acoder.Dictionary object.
Service interface section name, specified as a string scalar or character vector that corresponds to a section of the service interface definitions in the dictionary. Sections include:
"DataReceiverInterfaces"
"DataSenderInterfaces"
"DataTransferInterfaces"
"InitTermFunctions"
"MeasurementInterfaces"
"ParameterArgumentTuningInterfaces"
"ParameterTuningInterfaces"
"PeriodicAperiodicFunctions"
"SharedUtilityFunctions"
"SubcomponentInitTermFunctions"
"SubcomponentPeriodicAperiodicFunctions"
"TimerInterfaces"
The name of the service interface entry to set as default, specified as a string scalar or character vector. To get the available entries for a section, use the find method for the section.
Example: find(getSection(serviceDict,"DataReceiverInterfaces")).Name
Embedded Coder Dictionary that contains a data interface configuration, specified as acoder.Dictionary object.
Data interface category name, specified as a string scalar or character vector that corresponds to a category in one of the category groups in the dictionary,Function Defaults
and Data Defaults
.
Function Defaults
categories are:
"InitializeTerminate"
"Execution"
"SharedUtility"
Data Defaults
categories are:
"Inports"
"Outports"
"ModelParameters"
"ModelParameterArguments"
"ExternalParameters"
"SharedLocalDataStores"
"GlobalDataStores"
"InternalData"
"Constants"
Name of category property for which to set the dictionary default value, specified as a string scalar or character vector. The list of available properties to use with this method depends on the category type and its specific configuration.
For categories within Function Defaults
, theFunctionCustomizationTemplate
property is available for use with this method. When the FunctionCustomizationTemplate
is set toDefault
, an additional property, MemorySection
, becomes available for use with this method for these categories.
Data Defaults
categories have the StorageClass
property available for use with this method. The set of available properties is dynamic and varies based on the assigned value of the StorageClass
property. For example, when the StorageClass
property is assigned the valueExportToFile
, which is allowed for certain categories, these additional properties become available for use with this method:
"HeaderFile"
"DefinitionFile"
"Owner"
"PreserveDimensions"
To learn more about storage classes and their properties, see Choose Storage Class for Controlling Data Representation in Generated Code.
Default value to set for the specified property. The value type depends on the property whose value is being specified.
The available values for the FunctionCustomizationTemplate
,MemorySection
, and StorageClass
are those defined in the dictionary, in the sectionsFunctionCustomizationTemplates
, MemorySections
, and StorageClasses
respectively. To get the list of available values for each of these properties, use the find
method in combination with the getSection
method. For example, to get the list of available storage class names, enter:
find(getSection(coderDataDict,"StorageClasses")).Name
The available values for other properties depend on the type of property whose value is being specified. To learn more about storage class dependent properties and how to specify their values, see Choose Storage Class for Controlling Data Representation in Generated Code.
Examples
Create a Simulink data dictionary that contains an Embedded Coder Dictionary. Create the Embedded Coder Dictionary so that it represents a service interface configuration.
dictionaryFile = Simulink.data.dictionary.create("codeDefinitions.sldd"); codeDictionary = coder.dictionary.create("codeDefinitions.sldd","ServiceInterface");
Get the default receiver service interface.
receiver = getDictionaryDefault(codeDictionary,"DataReceiverInterfaces")
receiver =
Entry with properties:
Name: 'ReceiverExample1'
DataSource: 'C:\work\serviceDefinitions.sldd'
DataCommunicationMethod: 'OutsideExecution'
FunctionName: 'get_$X$N'
Get a list of the available receiver service interfaces.
recSection = getSection(codeDictionary,"DataReceiverInterfaces"); receivers = find(recSection); receivers.Name
ans =
'ReceiverExample1'
ans =
'ReceiverExample2'
ans =
'ReceiverExample3'
Set a different receiver interface as the default.
setDictionaryDefault(codeDictionary,"DataReceiverInterfaces","ReceiverExample2");
Create a SimulinkĀ® data dictionary, then create the Embedded Coder Dictionary to represent a data interface configuration.
dictFileName = "dataDict.sldd"; dataDict = Simulink.data.dictionary.create(dictFileName); coderDataDict = coder.dictionary.create(dataDict,"DataInterface");
Use the getDictionaryDefault
method to see the default StorageClass
of the Outports
category.
getDictionaryDefault(coderDataDict,"Outports","StorageClass")
Set the default StorageClass
of the Outports
category to GetSet
. Then specify GetFunction
(the naming rule of the get function) as get_outports_$N
and specify SetFunction
(the naming rule of the set function) as set_outports_$N
.
setDictionaryDefault(coderDataDict,"Outports","StorageClass","GetSet") setDictionaryDefault(coderDataDict,"Outports","GetFunction","get_outports_$N") setDictionaryDefault(coderDataDict,"Outports","SetFunction","set_outports_$N")
Discard and close the dictionary, then delete the dictionary file. This allows you to run this example more than once without getting an error while attempting to create the dictionary.
discardChanges(dataDict) Simulink.data.dictionary.closeAll("-save") delete(dictFileName)
Version History
Introduced in R2023b
The sections SubcomponentInitTermFunctions
andSubcomponentPeriodicAperiodicFunctions
replace the sectionSubcomponentEntryFunctions
.