]> rtime.felk.cvut.cz Git - ert_linux.git/blob - ert_linux/ert_linux_file_process.tlc
1faad2e3a37da867f99eef85b469c1485f7fbd15
[ert_linux.git] / ert_linux / ert_linux_file_process.tlc
1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2 %% $RCSfile: example_file_process.tlc,v $
3 %% $Revision: 1.1.6.5 $
4 %% $Date: 2010/09/13 16:20:21 $
5 %%
6 %% Abstract:
7 %%   Example Embedded Coder custom file processing template.
8 %%
9 %%   Note: This file can contain any valid TLC code, which Embedded Coder
10 %%   executes just prior to writing the generated source files to disk.
11 %%   Using this template "hook" file, you are able to augment the generated
12 %%   source code and create additional files.
13 %%
14 %% Copyright 1994-2010 The MathWorks, Inc.
15 %%
16 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
17 %selectfile NULL_FILE
18
19 %%  Uncomment this TLC line to execute the example
20 %%   ||   ||
21 %%   ||   ||
22 %%   \/   \/
23 %%  %assign ERTCustomFileTest = TLC_TRUE
24
25 %if EXISTS("ERTCustomFileTest") && ERTCustomFileTest == TLC_TRUE
26   
27   %% Need to set the template compliance flag before you can use the API
28   %<LibSetCodeTemplateComplianceLevel(1)>
29
30   %% Add a new C file timestwo.c and put a simple function in it
31   
32   %assign cFile = LibCreateSourceFile("Source", "Custom", "timestwo")
33   
34   %openfile tmwtypesBuf
35   
36   #include "tmwtypes.h"
37   
38   %closefile tmwtypesBuf
39   
40   %<LibSetSourceFileSection(cFile,"Includes",tmwtypesBuf)>
41
42   %openfile tmpBuf
43
44   /* Times two function */
45   real_T timestwofcn(real_T input) {
46     return (input * 2.0);
47   }
48
49   %closefile tmpBuf
50   
51   %<LibSetSourceFileSection(cFile,"Functions",tmpBuf)>
52   
53   %% Add a corresponding H file timestwo.h
54   
55   %assign hFile = LibCreateSourceFile("Header", "Custom", "timestwo")
56   
57   %openfile tmpBuf
58   
59   /* Times two function */
60   extern real_T timestwofcn(real_T input);
61   
62   %closefile tmpBuf
63   
64   %<LibSetSourceFileSection(hFile,"Includes",tmwtypesBuf)>
65   %<LibSetSourceFileSection(hFile,"Declarations",tmpBuf)>
66   
67   %% Add a #define to the model's public header file model.h
68   
69   %assign pubName = LibGetMdlPubHdrBaseName()
70   %assign modelH  = LibCreateSourceFile("Header", "Simulink", pubName)
71   
72   %openfile tmpBuf
73
74   #define ACCELERATION 9.81
75
76   %closefile tmpBuf
77   
78   %<LibSetSourceFileSection(modelH,"Defines",tmpBuf)>
79   
80   %% Add a #define to the model's private header file model_private.h
81   
82   %assign prvName  = LibGetMdlPrvHdrBaseName()
83   %assign privateH = LibCreateSourceFile("Header", "Simulink", prvName)
84   
85   %openfile tmpBuf
86
87   #define STARTING_POINT 100.0
88
89   %closefile tmpBuf
90   
91   %<LibSetSourceFileSection(privateH,"Defines",tmpBuf)>
92   
93   %% Add a #include to the model's C file model.c
94   
95   %assign srcName = LibGetMdlSrcBaseName()
96   %assign modelC  = LibCreateSourceFile("Source", "Simulink", srcName)
97   
98   %openfile tmpBuf
99   /* #include "mytables.h" */
100   %closefile tmpBuf
101   
102   %<LibSetSourceFileSection(modelC,"Includes",tmpBuf)>
103   
104   %% Create a simple main.  Files are located in MATLAB/rtw/c/tlc/mw.
105   
106   %if LibIsSingleRateModel() || LibIsSingleTasking()
107     %include "bareboard_srmain.tlc"
108     %<FcnSingleTaskingMain()>
109   %else
110     %include "bareboard_mrmain.tlc"
111     %<FcnMultiTaskingMain()>
112   %endif
113   
114 %endif