Hook functions for RTW

조회 수: 21 (최근 30일)
Ubaldo
Ubaldo 2017년 5월 10일
댓글: Laszlo Dombai 2020년 1월 16일
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
Ubaldo
Ubaldo 2017년 5월 10일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

MATLAB_atian
MATLAB_atian 2017년 11월 16일
Hi can you give me your guide editing the hook function
  댓글 수: 2
Ubaldo
Ubaldo 2017년 11월 17일
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 2020년 1월 16일
Search for the next text in Matlab Help:
"Customize Build Process with STF_make_rtw_hook File"

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by