Hook functions for RTW

12 vues (au cours des 30 derniers jours)
Ubaldo
Ubaldo le 10 Mai 2017
Commenté : Laszlo Dombai le 16 Jan 2020
Hi all, I followed the guide for specifying a RTW hook function (namely I copied the ert_make_rtw_hook.m in my path and edited it at my convenience). All I want to do is to move MyModel.trc from my current folder to C:\FolderB at the end of the building process. Therefore, edited the part of code related to the 'exit' phase. What happens at the end of the building process is... nothing. How can I solve it?
Here is how my MyModel_make_rtw_hook.m
function MyModel_make_rtw_hook(hookMethod,modelName,rtwroot,templateMakefile,buildOpts,buildArgs)
switch hookMethod
case 'error'
msg = DAStudio.message('RTW:makertw:buildAborted', modelName);
disp(msg);
case 'entry'
msg = DAStudio.message('RTW:makertw:enterRTWBuild', modelName);
disp(msg);
option = LocalParseArgList(buildArgs);
if ~strcmp(option,'none')
ert_unspecified_hardware(modelName);
cs = getActiveConfigSet(modelName);
cscopy = cs.copy;
ert_auto_configuration(modelName,option);
locReportDifference(cscopy, cs);
end
case 'before_tlc'
case 'after_tlc'
case 'before_make'
case 'after_make'
case 'exit'
if strcmp(get_param(modelName,'GenCodeOnly'),'off')
msgID = 'RTW:makertw:exitRTWBuild';
else
msgID = 'RTW:makertw:exitRTWGenCodeOnly';
end
msg = DAStudio.message(msgID,modelName);
disp(msg);
% Move MyModel.trc into C:\FolderB
movefile MyModel.trc 'C:\FolderB'
end
% Simple parse function to find:
% optimized_fixed_point=1
% optimized_floating_point=1
function option = LocalParseArgList(args)
if strfind(args,'optimized_fixed_point=1')
option = 'optimized_fixed_point';
elseif strfind(args,'optimized_floating_point=1')
option = 'optimized_floating_point';
else
option = 'none';
end
% local function: report difference between the configuration set settings
% before and after running auto-configuration script.
function locReportDifference(cs1, cs2)
[iseq, diffs] = slprivate('diff_config_sets', cs1, cs2, 'string');
if ~iseq
msg = DAStudio.message('RTW:makertw:incompatibleParamsUpdated', diffs);
summary = DAStudio.message('RTW:makertw:autoconfigSummary');
rtwprivate('rtw_disp_info',...
get_param(cs2.getModel, 'Name'),...
summary,...
msg);
end
  1 commentaire
Ubaldo
Ubaldo le 10 Mai 2017
I found an answer by myself. The *_make_rtw_hook.m shall have the TARGET name and NOT the MODEL name. That is, MyModel_make_rtw_hook.m will not work, MyTarget_make_rtw_hook.m will work.

Connectez-vous pour commenter.

Réponses (1)

MATLAB_atian
MATLAB_atian le 16 Nov 2017
Hi can you give me your guide editing the hook function
  2 commentaires
Ubaldo
Ubaldo le 17 Nov 2017
Hello. I don't remember where I took the guide. If I remember properly, the way to use hook functions is written in the .m files of the hook functions.
Laszlo Dombai
Laszlo Dombai le 16 Jan 2020
Search for the next text in Matlab Help:
"Customize Build Process with STF_make_rtw_hook File"

Connectez-vous pour commenter.

Catégories

En savoir plus sur Deployment, Integration, and Supported Hardware dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by