- Load the model.
- Update any configuration settings in the Configuration Parameters dialog box.
- Build the model.
How to refresh System Target File (.tlc) SelectCallback?
4 views (last 30 days)
Monika Jaskolka on 22 Apr 2020
I have a custom target file that is based on ert.tlc. I am editing the target-specific code generation options for a model's Configuration Parameters dialog box using a custom SelectCallback script (e.g., custom_ert_callback.m). In my custom_ert.tlc I have:
rtwgensettings.SelectCallback = 'custom_ert_callback(hDlg,hSrc)';
Using this SelectCallback, I am changing some of the configuration parameters to be specific values for my custom target, or disabling some altogether so the user can't edit it themselves. For example:
slConfigUISetVal(hDlg,hSrc,'ArrayBoundsChecking', 'error'); % Set parameter
slConfigUISetEnabled(hDlg,hSrc,'ArrayBoundsChecking', false); % Disable users from changing it
My question is, after changes are made to the callback, how do I refesh the target to reflect the changes in a model's configuration parameters? For example, I have a closed model that is already using my custom target (i.e. the SystemTargetFile parameter is already set to custom_ert.tlc). I then change the custom_ert_callback.m to apply the above changes, that is, make the ArrayBoundsChecking parameter disabled and set it to 'error'. When I open the model, and view the Configuration Parameters, this field is still enabled and the value is still set to 'none'. Is there a way to ensure the changes are registered? I essentially want something akin to the sl_refresh_customizations command, but for tlc callbacks.
The only way I can acheive a 'refresh' is to set the target file back to ert.tlc, and then back again to my custom tlc:
set_param(gcs, 'SystemTargetFile', 'ert.tlc');
set_param(gcs, 'SystemTargetFile', 'custom_ert.tlc');
Is there a better way?
Fangjun Jiang on 22 Apr 2020
Edited: Fangjun Jiang on 22 Apr 2020
Reloading the model should should make it effective
From the document
rtwgensettings.SelectCallback: This structure field specifies a SelectCallback function. You must setrtwgensettings.Version = '1'; or your callback will be ignored. SelectCallback is associated with the target rather than with any of its individual options. The SelectCallback function is triggered when you:
The SelectCallback function is useful for setting up (or disabling) configuration parameters specific to the target.
Or consider rtwgensettings.PostApplyCallback
rtwgensettings.PostApplyCallback: this property specifies a PostApplyCallback function. The PostApplyCallback function is triggered when the user clicks the Apply or OK button after editing options in the Configuration Parameters dialog box. ThePostApplyCallback function is called after the changes have been applied to the configuration set.