aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/lustrev4_lv4_heater_control/heater_control.c
blob: 4a2b81749f2bbc03f5f7eac3d5a1f8c54b6b3b56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
/********
* ec2c version 0.67
* c file generated for node : heater_control 
* context   method = HEAP
* ext call  method = PROCEDURES
********/
#include <stdlib.h>
#include <string.h>
#define _heater_control_EC2C_SRC_FILE
#include "heater_control.h"
/*--------
Internal structure for the call
--------*/
typedef struct  {
   void* client_data;
   //INPUTS
   _real _T;
   _real _T1;
   _real _T2;
   _real _T3;
   //OUTPUTS
   _boolean _Heat_on;
   //REGISTERS
   _boolean M73;
   _boolean M73_nil;
   _boolean M5;
} heater_control_ctx;
/*--------
Output procedures must be defined,
Input procedures must be used:
--------*/
void heater_control_I_T(heater_control_ctx* ctx, _real V){
   ctx->_T = V;
}
void heater_control_I_T1(heater_control_ctx* ctx, _real V){
   ctx->_T1 = V;
}
void heater_control_I_T2(heater_control_ctx* ctx, _real V){
   ctx->_T2 = V;
}
void heater_control_I_T3(heater_control_ctx* ctx, _real V){
   ctx->_T3 = V;
}
extern void heater_control_O_Heat_on(void* cdata, _boolean);
#ifdef CKCHECK
extern void heater_control_BOT_Heat_on(void* cdata);
#endif
/*--------
Internal reset input procedure
--------*/
static void heater_control_reset_input(heater_control_ctx* ctx){
   //NOTHING FOR THIS VERSION...
}
/*--------
Reset procedure
--------*/
void heater_control_reset(heater_control_ctx* ctx){
   ctx->M73_nil = _true;
   ctx->M5 = _true;
   heater_control_reset_input(ctx);
}
/*--------
Copy the value of an internal structure
--------*/
void heater_control_copy_ctx(heater_control_ctx* dest, heater_control_ctx
* src){
   memcpy((void*)dest, (void*)src, sizeof(heater_control_ctx));
}
/*--------
Dynamic allocation of an internal structure
--------*/
heater_control_ctx* heater_control_new_ctx(void* cdata){
   heater_control_ctx* ctx = (heater_control_ctx*)calloc(1, sizeof(
heater_control_ctx));
   ctx->client_data = cdata;
   heater_control_reset(ctx);
   return ctx;
}
/*--------
Step procedure
--------*/
void heater_control_step(heater_control_ctx* ctx){
//LOCAL VARIABLES
   _real L16;
   _boolean L15;
   _real L18;
   _real L14;
   _boolean L13;
   _boolean L12;
   _real L24;
   _boolean L23;
   _real L25;
   _real L22;
   _boolean L21;
   _boolean L20;
   _boolean L11;
   _real L30;
   _boolean L29;
   _real L31;
   _real L28;
   _boolean L27;
   _boolean L26;
   _boolean L10;
   _real L32;
   _boolean L38;
   _boolean L37;
   _boolean L40;
   _boolean L39;
   _boolean L36;
   _boolean L42;
   _boolean L41;
   _boolean L35;
   _real L46;
   _real L45;
   _boolean L50;
   _real L49;
   _boolean L48;
   _real L47;
   _real L44;
   _boolean L54;
   _real L53;
   _boolean L52;
   _real L51;
   _real L43;
   _boolean L57;
   _boolean L56;
   _real L59;
   _real L63;
   _real L62;
   _real L65;
   _real L64;
   _real L61;
   _real L58;
   _real L55;
   _real L34;
   _real L9;
   _boolean L8;
   _boolean L68;
   _boolean L71;
   _boolean L70;
   _boolean L67;
   _boolean L7;
   _boolean L4;
   _boolean T73;
//CODE
   L16 = (ctx->_T1 - ctx->_T2);
   L15 = (L16 >= 0.000000);
   L18 = (- L16);
   if (L15) {
      L14 = L16;
   } else {
      L14 = L18;
   }
   L13 = (L14 < 0.500000);
   L12 = (! L13);
   L24 = (ctx->_T1 - ctx->_T3);
   L23 = (L24 >= 0.000000);
   L25 = (- L24);
   if (L23) {
      L22 = L24;
   } else {
      L22 = L25;
   }
   L21 = (L22 < 0.500000);
   L20 = (! L21);
   L11 = (L12 && L20);
   L30 = (ctx->_T2 - ctx->_T3);
   L29 = (L30 >= 0.000000);
   L31 = (- L30);
   if (L29) {
      L28 = L30;
   } else {
      L28 = L31;
   }
   L27 = (L28 < 0.500000);
   L26 = (! L27);
   L10 = (L11 && L26);
   L32 = (- 999.000000);
   L38 = (L13 && L20);
   L37 = (L38 && L26);
   L40 = (L21 && L12);
   L39 = (L40 && L26);
   L36 = (L37 || L39);
   L42 = (L27 && L12);
   L41 = (L42 && L20);
   L35 = (L36 || L41);
   L46 = (ctx->_T1 + ctx->_T2);
   L45 = (L46 + ctx->_T3);
   L50 = (ctx->_T2 < ctx->_T3);
   if (L50) {
      L49 = ctx->_T2;
   } else {
      L49 = ctx->_T3;
   }
   L48 = (ctx->_T1 < L49);
   if (L48) {
      L47 = ctx->_T1;
   } else {
      L47 = L49;
   }
   L44 = (L45 - L47);
   L54 = (ctx->_T2 > ctx->_T3);
   if (L54) {
      L53 = ctx->_T2;
   } else {
      L53 = ctx->_T3;
   }
   L52 = (ctx->_T1 > L53);
   if (L52) {
      L51 = ctx->_T1;
   } else {
      L51 = L53;
   }
   L43 = (L44 - L51);
   L57 = (L13 && L21);
   L56 = (L57 && L27);
   L59 = (L46 / 2.000000);
   L63 = (ctx->_T1 + ctx->_T3);
   L62 = (L63 / 2.000000);
   L65 = (ctx->_T2 + ctx->_T3);
   L64 = (L65 / 2.000000);
   if (L21) {
      L61 = L62;
   } else {
      L61 = L64;
   }
   if (L13) {
      L58 = L59;
   } else {
      L58 = L61;
   }
   if (L56) {
      L55 = L43;
   } else {
      L55 = L58;
   }
   if (L35) {
      L34 = L43;
   } else {
      L34 = L55;
   }
   if (L10) {
      L9 = L32;
   } else {
      L9 = L34;
   }
   L8 = (L9 == L32);
   L68 = (L9 < 6.000000);
   L71 = (L9 > 9.000000);
   if (L71) {
      L70 = _false;
   } else {
      L70 = ctx->M73;
   }
   if (L68) {
      L67 = _true;
   } else {
      L67 = L70;
   }
   if (L8) {
      L7 = _false;
   } else {
      L7 = L67;
   }
   if (ctx->M5) {
      L4 = _true;
   } else {
      L4 = L7;
   }
   heater_control_O_Heat_on(ctx->client_data, L4);
   T73 = L4;
   ctx->M73 = T73;
   ctx->M73_nil = _false;
   ctx->M5 = ctx->M5 && !(_true);
}