This can be accomplished using the STF hooks. In the STF, you can create the elements of the custom target's UI using the 'rtwoptions' structure. This is used to create both invisible ('non UI') and visible UI components by specifying the type of the component, default value of the component, and etc. When you create a component using this structure, you can add additional fields such as 'tlcvariable' and 'makevariable'. The field 'tlcvariable' allows you to control the name of this variable as available to the Target Language Compiler whereas 'makevariable' allows you to control the name as available in the make file creation.
For example, following code creates a 'non-UI' component that can be accessed from TLC and make file with their names as specified below:
rtwoptions(oIdx).prompt = 'myNonUI';
rtwoptions(oIdx).type = 'NonUI';
rtwoptions(oIdx).default = 'off';
rtwoptions(oIdx).tlcvariable = 'myNonUI';
rtwoptions(oIdx).makevariable = 'MYNONUI';
These values can be modified using the STF hooks during the BUILD process.
For example, in the 'after_tlc' hook, you can use the following code to modify the variable after generating the code:
case 'after_tlc'
disp('############Executing After TLC Hook##########');
set_param(gcs,'myNonUI','on')
disp('###Done changing the non UI parameter myNonUI');
This variable can then be used in the TMF to create corresponding variable in the 'model.mk' file. There is ZIP file attached that illustrates this with an example.
1. Download and extract the files to a location that is in MATLAB path. Please make sure to add the sub-folders to the path as well.
2. Open the model and build it. You will see that the generated 'pk.mk' file in the code generation folder has the value of modified non-UI variable 'myNonUI'.
Best Answer