Main Content

Configure Parameter and Parameter Argument Tuning Service Interfaces for Model Parameters and Model Parameter Arguments

Since R2022b

Some components require interface support for tunable parameters and parameter arguments. When a parameter or parameter argument is tunable, you can change the value that is stored in memory during program execution.

To configure parameter and parameter argument tuning service interfaces, configure how a parameter or parameter argument is stored in memory during program execution by defining a storage class in the dictionary.

Use the Code Mappings editor to configure the parameter tuning service interface when you do not want to use the default value specified in a shared coder dictionary.

In the dialog box that appears if you click the pencil icon or in the Property Inspector, you can specify the identifier that the code generator uses to represent a parameter in the generated code

Configure Parameter Tuning Service Interfaces by Using the Code Mappings Editor

In this example, the component model references a shared coder dictionary that defines the default parameter tuning service interfaces for model parameters. To configure the model to use something other than the default service interface, use the Code Mappings editor.

Open the component model, ComponentDeploymentFcn.

openExample('ComponentDeploymentFcn');

Screenshot of component model

In this model, model parameter k is tunable and defines the gain of the Gain block within the Accumulator Function-Call Subsystem block.

Verify that the component model references the shared coder dictionary, ComponentDeploymentCoderDictionary.sldd.

In the Model Configuration Parameters dialog box, verify that the Shared coder dictionary parameter is set to ComponentDeploymentCoderDictionary.sldd. This dictionary defines default service interfaces, including parameter tuning service interfaces, of the component model.

Open the Embedded Coder app.

To configure the functions to use a parameter tuning service interface other than the default defined by the shared coder dictionary, use the Code Mappings editor.

To open the Code Mappings editor, in the C Code tab, click Code Interface > Component Interface.

On the Parameters tab, notice that the Parameter Tuning Service of the parameter k, is set to Dictionary default: ParameterTuningService.

Default configuration of the code mappings by using dictionary default values

To specify that a parameter or parameter argument is not tunable and therefore does not need a tuning service interface, set the Parameter Tuning Service to Not tunable.

Parameter tuning service for parameter k configured to 'Not tunable' in Code Mappings editor

To configure the parameter to use a tuning service interface other than the default defined by the dictionary, you must create a new storage class in the dictionary, and reference the storage class in a new parameter tuning service interface definition in the dictionary.

For information on how to create a new parameter tuning service interface definition in the dictionary, see Define Service Interfaces, Storage Classes, Memory Sections, and Function Templates for Software Architecture.

Configure Parameter Tuning Service Interfaces Programmatically

To configure parameter tuning service interfaces of a parameter programmatically, access the code mapping properties of the component model.

Open the model.

openExample('ComponentDeploymentFcn');

Get the code mappings for the model by using the coder.mapping.api.get function.

cm = coder.mapping.api.get('ComponentDeploymentFcn');

In this model, model parameter k is tunable and defines the gain of the Gain block within the Accumulator Function-Call Subsystem block. Get the current parameter tuning service interface configuration by using the getModelParameter function.

getModelParameter(cm, 'k', 'ParameterTuningService')
ans =

    'Dictionary default'
The parameter is configured to use the default parameter tuning service interface defined in the shared coder dictionary.

To specify that a parameter or parameter argument is not tunable and therefore does not need a tuning service interface, use the setModelParameter function to set the parameter tuning service interface to Not tunable.

setModelParameter(cm, 'k', 'ParameterTuningService', 'Not tunable')

To configure the parameter to use a different parameter tuning service interface, create a new parameter tuning service interface definition in the dictionary. Then, use the setModelParameter function and specify the ParameterTuningService property to the new service interface you defined in the dictionary.

See Also

| | |

Related Topics