Use the programmatic interface to retrieve and configure function defaults in the code mappings of a Simulink model.
To interactively observe how your commands are reflected in the Code Mappings editor and the model dictionary, make sure the Code Mappings editor is open with the Function Defaults tab selected, and the model dictionary open with the Function Customization Template section selected. To learn how to open the Code Mappings editor, see Open the Code Mappings Editor – C. To learn how to open the model dictionary, see Open the Embedded Coder Dictionary.
Open the model CoderMapAPI
.
Get the code mappings object of this model.
Specify FunctionName
as an empty string for all model functions so that their names in the generated code are determined by the value you set for the function defaults.
Get the default customization template of the InitializeTerminate
and Execution
functions.
exeFCNsTemplate =
'FCN_Template__2'
initTermFCNsTemplate =
'FCN_Template__1'
Generate code from the model.
Model entry-point functions are declared in the generated header file of the model. Store the header file name.
model_h_file =
"ECoderMapAPI_ert_rtw/ECoderMapAPI.h"
Function Naming Rule of FCN_Template__1
begins with Template_1
and Function Naming Rule of FCN_Template__2 begins with Template_2
. This is the entry-point function declaration section in the generated header file:
/* Model entry point functions */
extern void Template_1_FCN_ECoderMapAPI_initialize(void);
extern void Template_2_FCN_ECoderMapAPI_step(void);
extern void Template_1_FCN_ECoderMapAPI_terminate(void);
The function names are generated according to the specified Function Customization Template values for those functions.
To open the header file and, enter this command in the MATLAB Command Window:
Switch between the templates of the two function categories.
Generate code from the model again.
The entry-point function names are updated according to their updated Function Customization Templates:
/* Model entry point functions */
extern void Template_2_FCN_ECoderMapAPI_initialize(void);
extern void Template_1_FCN_ECoderMapAPI_step(void);
extern void Template_2_FCN_ECoderMapAPI_terminate(void);