您当前的位置: 首页 > 

暂无认证

  • 14浏览

    0关注

    93978博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

Simulink自定义目标系统文件配置(4)——file_process.tlc文件

发布时间:2022-09-21 18:00:00 ,浏览量:14

前言

自定义目标系统文件由五大文件组成:

  • xx.tlc 系统目标文件
  • xx_callback_handler.m RTW工具箱回调函数
  • xx_make_rtw_hook.m tlc文件调用
  • xx_file_process.tlc 文件处理TLC文件
  • xx_srmain.tlc 控制主函数文件的生成
xx_file_process.tlc文件处理

该文件的目的是用来控制自动代码生成的过程中,针对不同的情况,在各阶段生成什么样的代码。该文件可以在callback_handle里面配置,也可以在Configuration Parameter中查看。 操作图1 我这边是沿用了ert.tlc的file_process文件,因为对生成代码没有具体的要求。

在callback_handle里面可以设置这个配置项:

% 配置用户自定义的模板文件 slConfigUISetVal(hDlg,hSrc,'ERTCustomFileTemplate','example_file_process.tlc'); slConfigUISetEnabled(hDlg,hSrc,'ERTCustomFileTemplate',0); 

可以参考下面的模板自定义:

%selectfile NULL_FILE %% Uncomment this TLC line to execute the example %% || || %% || || %% \/ \/ %% %assign ERTCustomFileTest = TLC_TRUE %if EXISTS("ERTCustomFileTest") && ERTCustomFileTest == TLC_TRUE %% Add a new C file timestwo.c and put a simple function in it %assign cFile = LibCreateSourceFile("Source", "Custom", "timestwo") %openfile typesBuf
  
  #include "rtwtypes.h" %closefile typesBuf %<LibSetSourceFileSection(cFile,"Includes",typesBuf)> %openfile tmpBuf /* Times two function */ real_T timestwofcn(real_T input) { return (input * 2.0); } %closefile tmpBuf %<LibSetSourceFileSection(cFile,"Functions",tmpBuf)> %% Add a corresponding H file timestwo.h %assign hFile = LibCreateSourceFile("Header", "Custom", "timestwo") %openfile tmpBuf /* Times two function */ extern real_T timestwofcn(real_T input); %closefile tmpBuf %<LibSetSourceFileSection(hFile,"Includes",typesBuf)> %<LibSetSourceFileSection(hFile,"Declarations",tmpBuf)> %% Add a #define to the model's public header file model.h %assign pubName = LibGetMdlPubHdrBaseName() %assign modelH = LibCreateSourceFile("Header", "Simulink", pubName) %openfile tmpBuf

  #define ACCELERATION 9.81 %closefile tmpBuf %<LibSetSourceFileSection(modelH,"Defines",tmpBuf)> %% Add a #define to the model's private header file model_private.h %assign prvName = LibGetMdlPrvHdrBaseName() %assign privateH = LibCreateSourceFile("Header", "Simulink", prvName) %openfile tmpBuf

  #define STARTING_POINT 100.0 %closefile tmpBuf %<LibSetSourceFileSection(privateH,"Defines",tmpBuf)> %% Add a #include to the model's C file model.c %assign srcName = LibGetMdlSrcBaseName() %assign modelC = LibCreateSourceFile("Source", "Simulink", srcName) %openfile tmpBuf /* #include "mytables.h" */ %closefile tmpBuf %<LibSetSourceFileSection(modelC,"Includes",tmpBuf)> %% Create a simple main. Files are located in MATLAB/rtw/c/tlc/mw. %if LibIsSingleRateModel() || LibIsSingleTasking() %include "bareboard_srmain.tlc" %<FcnSingleTaskingMain()> %else %include "bareboard_mrmain.tlc" %<FcnMultiTaskingMain()> %endif %endif

当然,这里也是不建议新手去修改或者自己写,对代码没有特殊要求的话完全可以依靠这个建立工程。

关注
打赏
1655516835
查看更多评论
立即登录/注册

微信扫码登录

0.0510s