Commit 0a24e789549be408fe5be464432f3af6c9c56669

Authored by Jehun12
1 parent 1afa113c

Added Energy saving mode and optimised heating

Showing 1 changed file with 135 additions and 71 deletions   Show diff stats
... ... @@ -10,11 +10,12 @@
10 10 #define TASK_NUMBER 32
11 11 #define T_INIT_THRESH 40
12 12 #define T_STEP_THRESH 80
13   -#define T_HOLD_THRESH 85 //OP is 88
  13 +#define T_HOLD_THRESH 88
  14 +#define T_ECO_MODE_THRESH 50
14 15 #define INIT_HEAT_TIME 15
15   -#define INIT_WAIT_TIME 15
  16 +#define INIT_WAIT_TIME 12
16 17 #define STEP_HEAT_TIME 2
17   -#define STEP_WAIT_TIME 8 //OP is 5
  18 +#define STEP_WAIT_TIME 6
18 19 #define HOLD_HEAT_TIME 1
19 20 #define HOLD_WAIT_TIME 8
20 21 #define HOLD_PUMP_HEAT_TIME 3
... ... @@ -70,28 +71,28 @@ void* processHeat(void* arg)
70 71 while(!stopHeat)
71 72 {
72 73 tNow = clock();
73   -
  74 +
74 75 //Chaufffe initiale
75 76 if (task[0])
76 77 {
77 78 printx(INFO, HEAT, "Entering in task 0\n");
78 79 tTask = clock();
79   -
  80 +
80 81 if (tAct < T_INIT_THRESH)
81 82 {
82 83 setHeatOn();
83   - printx(INFO, HEAT, "Début chauffe initiale 0\n");
  84 + printx(INFO, HEAT, "Début chauffe initiale 0\n");
84 85 task[0] = false;
85 86 task[1] = true;
86 87 }
87   -
  88 +
88 89 else
89 90 {
90 91 task[0] = false;
91 92 task[6] = true;
92 93 }
93 94 }
94   -
  95 +
95 96 else if (task[1])
96 97 {
97 98 printx(INFO, HEAT, "Entering in task 1\n");
... ... @@ -99,7 +100,7 @@ void* processHeat(void* arg)
99 100 task[1] = false;
100 101 task[2] = true;
101 102 }
102   -
  103 +
103 104 else if (task[2])
104 105 {
105 106 printx(INFO, HEAT, "Entering in task 2\n");
... ... @@ -112,7 +113,7 @@ void* processHeat(void* arg)
112 113 task[3] = true;
113 114 }
114 115 }
115   -
  116 +
116 117 else if (task[3])
117 118 {
118 119 printx(INFO, HEAT, "Entering in task 3\n");
... ... @@ -120,7 +121,7 @@ void* processHeat(void* arg)
120 121 task[3] = false;
121 122 task[4] = true;
122 123 }
123   -
  124 +
124 125 else if (task[4])
125 126 {
126 127 printx(INFO, HEAT, "Entering in task 4\n");
... ... @@ -131,8 +132,8 @@ void* processHeat(void* arg)
131 132 task[5] = true;
132 133 }
133 134 }
134   -
135   -
  135 +
  136 +
136 137 //Chauffe par palier
137 138 else if (task[5])
138 139 {
... ... @@ -141,26 +142,26 @@ void* processHeat(void* arg)
141 142 task[5] = false;
142 143 task[6] = true;
143 144 }
144   -
145   -
  145 +
  146 +
146 147 else if (task[6])
147 148 {
148 149 printx(INFO, HEAT, "Entering in task 6\n");
149 150 if (tAct < T_STEP_THRESH)
150 151 {
151   - printx(INFO, HEAT, "Début Chauffe par palier 3\n");
  152 + printx(INFO, HEAT, "Début Chauffe par palier 3\n");
152 153 setHeatOn();
153 154 task[6] = false;
154 155 task[7] = true;
155 156 }
156   -
  157 +
157 158 else
158 159 {
159 160 task[6] = false;
160   - task[11] = true; //Numéro de tache début "Maintien au chaud"
  161 + task[11] = true; //Numéro de tache début "Maintien au chaud"
161 162 }
162 163 }
163   -
  164 +
164 165 else if (task[7])
165 166 {
166 167 printx(INFO, HEAT, "Entering in task 7\n");
... ... @@ -168,19 +169,19 @@ void* processHeat(void* arg)
168 169 task[7] = false;
169 170 task[8] = true;
170 171 }
171   -
  172 +
172 173 else if (task[8])
173 174 {
174 175 printx(INFO, HEAT, "Entering in task 8\n");
175 176 if( ((tNow - tTask) / CLOCKS_PER_SEC) > STEP_HEAT_TIME )
176 177 {
177   - printx(INFO, HEAT, "Fin de chauffe palier intermédiaire 4\n");
  178 + printx(INFO, HEAT, "Fin de chauffe palier intermédiaire 4\n");
178 179 setHeatOff();
179 180 task[8] = false;
180 181 task[9] = true;
181 182 }
182 183 }
183   -
  184 +
184 185 else if (task[9])
185 186 {
186 187 printx(INFO, HEAT, "Entering in task 9\n");
... ... @@ -188,20 +189,20 @@ void* processHeat(void* arg)
188 189 task[9] = false;
189 190 task[10] = true;
190 191 }
191   -
  192 +
192 193 else if (task[10])
193 194 {
194 195 printx(INFO, HEAT, "Entering in task 10\n");
195 196 if( ((tNow - tTask) / CLOCKS_PER_SEC) > STEP_WAIT_TIME )
196 197 {
197   - printx(INFO, HEAT, "Fin d'attente palier intermédiaire 5\n");
198   -
  198 + printx(INFO, HEAT, "Fin d'attente palier intermédiaire 5\n");
  199 +
199 200 if ( tAct < T_STEP_THRESH )
200 201 {
201 202 task[10] = false;
202 203 task[5] = true;
203 204 }
204   -
  205 +
205 206 else
206 207 {
207 208 task[10] = false;
... ... @@ -209,26 +210,36 @@ void* processHeat(void* arg)
209 210 }
210 211 }
211 212 }
212   -
213   -
  213 +
  214 +
214 215 // Maintien au chaud
215 216 else if (task[11])
216 217 {
217 218 printx(INFO, HEAT, "Entering in task 11\n");
218 219 tTask = clock();
219   - task[11] = false;
220   - task[12] = true;
  220 +
  221 + if (eco_mode)
  222 + {
  223 + task[11] = false;
  224 + task[24] = true; //Numéro tache Mode éco
  225 + }
  226 +
  227 + else
  228 + {
  229 + task[11] = false;
  230 + task[12] = true;
  231 + }
221 232 }
222   -
  233 +
223 234 else if (task[12])
224 235 {
225 236 printx(INFO, HEAT, "Entering in task 12\n");
226   - printx(INFO, HEAT, "Début Maintien au chaud 6\n");
  237 + printx(INFO, HEAT, "Début Maintien au chaud 6\n");
227 238 setHeatOk();
228 239 task[12]=false;
229 240 task[13]=true;
230 241 }
231   -
  242 +
232 243 else if (task[13])
233 244 {
234 245 printx(INFO, HEAT, "Entering in task 13\n");
... ... @@ -236,41 +247,41 @@ void* processHeat(void* arg)
236 247 task[13] = false;
237 248 task[14] = true;
238 249 }
239   -
  250 +
240 251 else if (task[14])
241 252 {
242 253 printx(INFO, HEAT, "Entering in task 14\n");
243 254 if(hold_heat)
244 255 {
245 256 if( (tAct < T_HOLD_THRESH))
246   - {
  257 + {
247 258 if (!isPumpOn())
248 259 {
249   - printx(INFO, HEAT, "Début Chauffe maintien sans pompe 7\n");
  260 + printx(INFO, HEAT, "Début Chauffe maintien sans pompe 7\n");
250 261 setHeatOn();
251 262 task[14] = false;
252 263 task[15] = true;
253 264 }
254   -
255   - else
  265 +
  266 + else
256 267 {
257   - printx(INFO, HEAT, "Début Chauffe maintien avec pompe 7'\n");
  268 + printx(INFO, HEAT, "Début Chauffe maintien avec pompe 7'\n");
258 269 setHeatOn();
259 270 task[14]=false;
260   - task[19]=true; //Numéro de tache "T<Thold && pumpitup"
  271 + task[19]=true; //Numéro de tache "T<Thold && pumpitup"
261 272 }
262 273 }
263   -
  274 +
264 275 }
265   -
  276 +
266 277 else
267 278 {
268   - printx(INFO, HEAT, "Maintien au chaud annulé 7 ' ' Go etape de fin\n");
  279 + printx(INFO, HEAT, "Maintien au chaud annulé 7 ' ' Go etape de fin\n");
269 280 task[14]=false;
270   - task[23]=true; //Sinon go étape d'attente fin
  281 + task[23]=true; //Sinon go étape d'attente fin
271 282 }
272 283 }
273   -
  284 +
274 285 else if (task[15])
275 286 {
276 287 printx(INFO, HEAT, "Entering in task 15\n");
... ... @@ -278,7 +289,7 @@ void* processHeat(void* arg)
278 289 task[15] = false;
279 290 task[16] = true;
280 291 }
281   -
  292 +
282 293 //Maintien au chaud sans pompage
283 294 else if (task[16])
284 295 {
... ... @@ -291,7 +302,7 @@ void* processHeat(void* arg)
291 302 task[17] = true;
292 303 }
293 304 }
294   -
  305 +
295 306 else if (task[17])
296 307 {
297 308 printx(INFO, HEAT, "Entering in task 17\n");
... ... @@ -299,7 +310,7 @@ void* processHeat(void* arg)
299 310 task[17] = false;
300 311 task[18] = true;
301 312 }
302   -
  313 +
303 314 else if (task[18])
304 315 {
305 316 printx(INFO, HEAT, "Entering in task 18\n");
... ... @@ -307,13 +318,13 @@ void* processHeat(void* arg)
307 318 {
308 319 if ( tAct < T_HOLD_THRESH)
309 320 {
310   - printx(INFO, HEAT, "Fin d'attente chauffe intermédiaire maintien 9\n");
311   - task[18] = false;
312   - task[11] = true; //Retour au début de "Maintien au chaud"
  321 + printx(INFO, HEAT, "Fin d'attente chauffe intermédiaire maintien 9\n");
  322 + task[18] = false;
  323 + task[11] = true; //Retour au début de "Maintien au chaud"
313 324 }
314 325 }
315 326 }
316   -
  327 +
317 328 //Maintien au chaud avec pompage
318 329 else if (task[19])
319 330 {
... ... @@ -321,8 +332,8 @@ void* processHeat(void* arg)
321 332 tTask = clock();
322 333 task[19] = false;
323 334 task[20] = true;
324   - }
325   -
  335 + }
  336 +
326 337 else if (task[20])
327 338 {
328 339 printx(INFO, HEAT, "Entering in task 20\n");
... ... @@ -334,7 +345,7 @@ void* processHeat(void* arg)
334 345 task[21] = true;
335 346 }
336 347 }
337   -
  348 +
338 349 else if (task[21])
339 350 {
340 351 printx(INFO, HEAT, "Entering in task 21\n");
... ... @@ -342,7 +353,7 @@ void* processHeat(void* arg)
342 353 task[21] = false;
343 354 task[22] = true;
344 355 }
345   -
  356 +
346 357 else if (task[22])
347 358 {
348 359 printx(INFO, HEAT, "Entering in task 22\n");
... ... @@ -350,37 +361,90 @@ void* processHeat(void* arg)
350 361 {
351 362 if ( tAct < T_HOLD_THRESH)
352 363 {
353   - printx(INFO, HEAT, "Fin d'attente chauffe intermédiaire maintien avec pompe 11\n");
  364 + printx(INFO, HEAT, "Fin d'attente chauffe intermédiaire maintien avec pompe 11\n");
354 365 task[22] = false;
355   - task[11] = true; //Retour au début de "Maintien au chaud"
356   - }
  366 + task[5] = true; //Retour au début de "Chauffe par palier" (shuntera si temperature OK (t>T_HOLD_THRESH))
  367 + }
357 368 }
358 369 }
359 370  
360   - //Fin de maintien au chaud (demandé par l'extérieur) et reboucle quand hold_heat est remis
  371 + //Fin de maintien au chaud (demandé par l'extérieur) et reboucle quand hold_heat est remis
361 372 else if(task[23])
362 373 {
363 374 printx(INFO, HEAT, "Entering in task 23\n");
364 375 setHeatOff();
365   - heat_ok=false;
366   -
  376 + resetHeatOk();
  377 +
367 378 if(hold_heat)
368 379 {
369 380 task[23]=false;
370   - task[0]=true; //Retour au début
  381 + task[0]=true; //Retour au début
371 382 }
372 383 }
373   -
374   -
375   - //Mode économie d'énergie
  384 +
  385 +
  386 + //Mode économie d'énergie
376 387 else if(task[24])
377 388 {
378   - //task[]=false;
379   - //task[]=true;
  389 + printx(INFO, HEAT, "Entering in task 24\n");
  390 + printx(INFO, HEAT, "Début Mode Eco maintien 24\n");
  391 +
  392 + if (eco_mode)
  393 + {
  394 + if (tAct < T_ECO_MODE_THRESH)
  395 + {
  396 + printx(INFO, HEAT, "Debut chauffe maintien Eco Mode 25\n");
  397 + setHeatOn();
  398 + task[24] = false;
  399 + task[25] = true;
  400 + }
  401 + }
  402 +
  403 + else
  404 + {
  405 + task[24] = false;
  406 + task[5] = true; //Retour "Chauffe par palier"
  407 + }
  408 + }
  409 +
  410 + else if (task[25])
  411 + {
  412 + tTask = clock();
  413 + task[25] = false;
  414 + task[26] = true;
380 415 }
  416 +
  417 + else if (task[26])
  418 + {
  419 + if( ((tNow - tTask) / CLOCKS_PER_SEC) > HOLD_HEAT_TIME )
  420 + {
  421 + printx(INFO, HEAT, "Fin chauffe maintien Eco mode 27\n");
  422 + setHeatOff();
  423 + task[26] = false;
  424 + task[27] = true;
  425 + }
  426 + }
  427 +
  428 + else if (task[27])
  429 + {
  430 + tTask = clock();
  431 + task[27] = false;
  432 + task[28] = true;
  433 + }
  434 +
  435 + else if (task[28])
  436 + {
  437 + if( ((tNow - tTask) / CLOCKS_PER_SEC) > HOLD_WAIT_TIME )
  438 + {
  439 + printx(INFO, HEAT, "Fin d'attente maintien Eco mode 29\n");
  440 + task[28] = false;
  441 + task[24] = true;
  442 + }
  443 + }
  444 +
381 445 usleep(20000);
382   - }
383   -
384   -
  446 + }
  447 +
  448 +
385 449 return NULL;
386 450 }
... ...