aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux/lustrev4_lustrec_heater_control/heater_control.c
blob: 6025cd13691a9577f169ef961b684167586932cd (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
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
#include <assert.h>
#include "heater_control.h"

/* C code generated by lustrec
   Version number 1.6-@GITBRANCH@
   Code is C99 compliant
   Using (double) floating-point numbers */
   
/* Import dependencies */

/* Global constants (definitions) */
double FAILURE = -999.0;
double TMIN = 6.0;
double TMAX = 9.0;
double DELTA = 0.5;

/* Struct definitions */
struct not_a_sauna2_mem {struct not_a_sauna2_reg {double __not_a_sauna2_2;
                                                  } _reg; 
                         struct _arrow_mem *ni_0;
                         };
struct heater_control_mem {struct heater_control_reg {_Bool __heater_control_16;
                                                      } _reg; 
                           struct _arrow_mem *ni_1;
                           };
struct not_a_sauna_mem {struct not_a_sauna_reg {double __not_a_sauna_2;
                                                } _reg; 
                        struct _arrow_mem *ni_2;
                        };


void not_a_sauna2_reset (struct not_a_sauna2_mem *self) {
  
  _arrow_reset(self->ni_0);
  return;
}

void not_a_sauna2_step (double T, double T1, double T2, double T3,
                        _Bool Heat_on, 
                        _Bool (*ok),
                        struct not_a_sauna2_mem *self) {
  _Bool __not_a_sauna2_1;
  
  
  _arrow_step (1, 0, &__not_a_sauna2_1, self->ni_0);
  if (__not_a_sauna2_1) {
    *ok = 1;
  } else {
    *ok = (self->_reg.__not_a_sauna2_2 < (9.0 - 6.0));
  }
  self->_reg.__not_a_sauna2_2 = T;
  
  return;
}

void heater_control_reset (struct heater_control_mem *self) {
  
  _arrow_reset(self->ni_1);
  return;
}

void heater_control_step (double T, double T1, double T2, double T3, 
                          _Bool (*Heat_on),
                          struct heater_control_mem *self) {
  double Median_42_max2_150_m;
  double Median_42_max2_152_m;
  double Median_42_min2_141_m;
  double Median_42_min2_143_m;
  double Median_52_max2_150_m;
  double Median_52_max2_152_m;
  double Median_52_min2_141_m;
  double Median_52_min2_143_m;
  double Tguess;
  _Bool V12;
  _Bool V13;
  _Bool V23;
  _Bool __heater_control_12;
  double abs_15_a;
  double abs_15_v;
  double abs_23_a;
  double abs_23_v;
  double abs_7_a;
  double abs_7_v;
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  abs_7_v = (T1 - T2);
  if ((abs_7_v >= 0.0)) {
    abs_7_a = abs_7_v;
  } else {
    abs_7_a = (- abs_7_v);
  }
  abs_23_v = (T2 - T3);
  if ((abs_23_v >= 0.0)) {
    abs_23_a = abs_23_v;
  } else {
    abs_23_a = (- abs_23_v);
  }
  abs_15_v = (T1 - T3);
  if ((abs_15_v >= 0.0)) {
    abs_15_a = abs_15_v;
  } else {
    abs_15_a = (- abs_15_v);
  }
  V23 = (abs_23_a < 0.5);
  V13 = (abs_15_a < 0.5);
  V12 = (abs_7_a < 0.5);
  if ((T2 < T3)) {
    Median_52_min2_141_m = T2;
  } else {
    Median_52_min2_141_m = T3;
  }
  if ((T2 > T3)) {
    Median_42_max2_150_m = T2;
  } else {
    Median_42_max2_150_m = T3;
  }
  if ((T2 < T3)) {
    Median_42_min2_141_m = T2;
  } else {
    Median_42_min2_141_m = T3;
  }
  if ((T2 > T3)) {
    Median_52_max2_150_m = T2;
  } else {
    Median_52_max2_150_m = T3;
  }
  if ((T1 < Median_52_min2_141_m)) {
    Median_52_min2_143_m = T1;
  } else {
    Median_52_min2_143_m = Median_52_min2_141_m;
  }
  if ((T1 > Median_52_max2_150_m)) {
    Median_52_max2_152_m = T1;
  } else {
    Median_52_max2_152_m = Median_52_max2_150_m;
  }
  if ((T1 < Median_42_min2_141_m)) {
    Median_42_min2_143_m = T1;
  } else {
    Median_42_min2_143_m = Median_42_min2_141_m;
  }
  if ((T1 > Median_42_max2_150_m)) {
    Median_42_max2_152_m = T1;
  } else {
    Median_42_max2_152_m = Median_42_max2_150_m;
  }
  if ((((!V12) && (!V13)) && (!V23))) {
    Tguess = -999.0;
  } else {
    if (((((V12 && (!V13)) && (!V23)) || ((V13 && (!V12)) && (!V23))) || ((V23 && (!V12)) && (!V13)))) {
      Tguess = ((((T1 + T2) + T3) - Median_42_min2_143_m) - Median_42_max2_152_m);
    } else {
      if (((V12 && V13) && V23)) {
        Tguess = ((((T1 + T2) + T3) - Median_52_min2_143_m) - Median_52_max2_152_m);
      } else {
        if (V12) {
          Tguess = ((T1 + T2) / 2.0);
        } else {
          if (V13) {
            Tguess = ((T1 + T3) / 2.0);
          } else {
            Tguess = ((T2 + T3) / 2.0);
          }
        }
      }
    }
  }
  _arrow_step (1, 0, &__heater_control_12, self->ni_1);
  if (__heater_control_12) {
    *Heat_on = 1;
  } else {
    if ((Tguess == -999.0)) {
      *Heat_on = 0;
    } else {
      if ((Tguess < 6.0)) {
        *Heat_on = 1;
      } else {
        if ((Tguess > 9.0)) {
          *Heat_on = 0;
        } else {
          *Heat_on = self->_reg.__heater_control_16;
        }
      }
    }
  }
  self->_reg.__heater_control_16 = *Heat_on;
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  return;
}

void not_a_sauna_reset (struct not_a_sauna_mem *self) {
  
  _arrow_reset(self->ni_2);
  return;
}

void not_a_sauna_step (double T, double T1, double T2, double T3,
                       _Bool Heat_on, 
                       _Bool (*ok),
                       struct not_a_sauna_mem *self) {
  _Bool __not_a_sauna_1;
  
  
  _arrow_step (1, 0, &__not_a_sauna_1, self->ni_2);
  if (__not_a_sauna_1) {
    *ok = 1;
  } else {
    *ok = (self->_reg.__not_a_sauna_2 < (9.0 + 1.0));
  }
  self->_reg.__not_a_sauna_2 = T;
  
  return;
}

void oneoftree_step (_Bool f1, _Bool f2, _Bool f3, 
                     _Bool (*r)
                     ) {
  
  *r = ((((f1 && (!f2)) && (!f3)) || ((f2 && (!f1)) && (!f3))) || ((f3 && (!f1)) && (!f2)));
  return;
}

void noneoftree_step (_Bool f1, _Bool f2, _Bool f3, 
                      _Bool (*r)
                      ) {
  
  *r = (((!f1) && (!f2)) && (!f3));
  return;
}

void alloftree_step (_Bool f1, _Bool f2, _Bool f3, 
                     _Bool (*r)
                     ) {
  
  *r = ((f1 && f2) && f3);
  return;
}

void abs_step (double v, 
               double (*a)
               ) {
  
  if ((v >= 0.0)) {
    *a = v;
  } else {
    *a = (- v);
  }
  return;
}

void Median_step (double a, double b, double c, 
                  double (*z)
                  ) {
  double __Median_1;
  double __Median_2;
  double __Median_3;
  double __Median_4;
  
  
  
  
  
  min2_step (b, c, &__Median_3);
  min2_step (a, __Median_3, &__Median_4);
  max2_step (b, c, &__Median_1);
  max2_step (a, __Median_1, &__Median_2);
  *z = ((((a + b) + c) - __Median_4) - __Median_2);
  
  
  
  
  return;
}

void Average_step (double a, double b, 
                   double (*z)
                   ) {
  
  *z = ((a + b) / 2.0);
  return;
}

void min2_step (double one, double two, 
                double (*m)
                ) {
  
  if ((one < two)) {
    *m = one;
  } else {
    *m = two;
  }
  return;
}

void max2_step (double one, double two, 
                double (*m)
                ) {
  
  if ((one > two)) {
    *m = one;
  } else {
    *m = two;
  }
  return;
}