Commit 717e403d12969cf1635e26be26944ee8daf89593
1 parent
12ca1331
Sperated output
Showing
6 changed files
with
83 additions
and
35 deletions
Show diff stats
1 | #include <stdio.h> | 1 | #include <stdio.h> |
2 | #include <time.h> | 2 | #include <time.h> |
3 | #include <stdbool.h> | 3 | #include <stdbool.h> |
4 | +#include <unistd.h> | ||
4 | #include "hvc.h" | 5 | #include "hvc.h" |
5 | #include "heat.h" | 6 | #include "heat.h" |
6 | #include "pump.h" | 7 | #include "pump.h" |
@@ -60,7 +61,7 @@ void resetHeatOk(void) | @@ -60,7 +61,7 @@ void resetHeatOk(void) | ||
60 | 61 | ||
61 | bool isHeatOk(void) | 62 | bool isHeatOk(void) |
62 | { | 63 | { |
63 | - return heat_ok; | 64 | + return (tAct > T_STEP_THRESH && tAct < T_HOLD_THRESH); |
64 | } | 65 | } |
65 | 66 | ||
66 | void* processHeat(void* arg) | 67 | void* processHeat(void* arg) |
@@ -72,12 +73,13 @@ void* processHeat(void* arg) | @@ -72,12 +73,13 @@ void* processHeat(void* arg) | ||
72 | //Chaufffe initiale | 73 | //Chaufffe initiale |
73 | if (task[0]) | 74 | if (task[0]) |
74 | { | 75 | { |
76 | + printx(INFO, HEAT, "Entering in task 0\n"); | ||
75 | tTask = clock(); | 77 | tTask = clock(); |
76 | 78 | ||
77 | if (tAct < T_INIT_THRESH) | 79 | if (tAct < T_INIT_THRESH) |
78 | { | 80 | { |
79 | setHeatOn(); | 81 | setHeatOn(); |
80 | - printx(INFO, BUS, "Début chauffe initiale 0\n"); | 82 | + printx(INFO, HEAT, "Début chauffe initiale 0\n"); |
81 | task[0] = false; | 83 | task[0] = false; |
82 | task[1] = true; | 84 | task[1] = true; |
83 | } | 85 | } |
@@ -91,6 +93,7 @@ void* processHeat(void* arg) | @@ -91,6 +93,7 @@ void* processHeat(void* arg) | ||
91 | 93 | ||
92 | else if (task[1]) | 94 | else if (task[1]) |
93 | { | 95 | { |
96 | + printx(INFO, HEAT, "Entering in task 1\n"); | ||
94 | tTask = clock(); | 97 | tTask = clock(); |
95 | task[1] = false; | 98 | task[1] = false; |
96 | task[2] = true; | 99 | task[2] = true; |
@@ -98,10 +101,12 @@ void* processHeat(void* arg) | @@ -98,10 +101,12 @@ void* processHeat(void* arg) | ||
98 | 101 | ||
99 | else if (task[2]) | 102 | else if (task[2]) |
100 | { | 103 | { |
104 | + printx(INFO, HEAT, "Entering in task 2\n"); | ||
105 | + printx(INFO, HEAT, "Time heating : %d (%d - %d) / %d\n", (tNow - tTask) / CLOCKS_PER_SEC, tNow, tTask, CLOCKS_PER_SEC); | ||
101 | if( ((tNow - tTask) / CLOCKS_PER_SEC) > INIT_HEAT_TIME ) | 106 | if( ((tNow - tTask) / CLOCKS_PER_SEC) > INIT_HEAT_TIME ) |
102 | { | 107 | { |
103 | setHeatOff(); | 108 | setHeatOff(); |
104 | - printx(INFO, BUS, "Fin chauffe initiale 1\n"); | 109 | + printx(INFO, HEAT, "Fin chauffe initiale 1\n"); |
105 | task[2] = false; | 110 | task[2] = false; |
106 | task[3] = true; | 111 | task[3] = true; |
107 | } | 112 | } |
@@ -109,6 +114,7 @@ void* processHeat(void* arg) | @@ -109,6 +114,7 @@ void* processHeat(void* arg) | ||
109 | 114 | ||
110 | else if (task[3]) | 115 | else if (task[3]) |
111 | { | 116 | { |
117 | + printx(INFO, HEAT, "Entering in task 3\n"); | ||
112 | tTask = clock(); | 118 | tTask = clock(); |
113 | task[3] = false; | 119 | task[3] = false; |
114 | task[4] = true; | 120 | task[4] = true; |
@@ -116,9 +122,10 @@ void* processHeat(void* arg) | @@ -116,9 +122,10 @@ void* processHeat(void* arg) | ||
116 | 122 | ||
117 | else if (task[4]) | 123 | else if (task[4]) |
118 | { | 124 | { |
125 | + printx(INFO, HEAT, "Entering in task 4\n"); | ||
119 | if( ((tNow - tTask) / CLOCKS_PER_SEC) > INIT_WAIT_TIME ) | 126 | if( ((tNow - tTask) / CLOCKS_PER_SEC) > INIT_WAIT_TIME ) |
120 | { | 127 | { |
121 | - printx(INFO, BUS, "Fin attente %d sec 2\n", INIT_WAIT_TIME); | 128 | + printx(INFO, HEAT, "Fin attente %d sec 2\n", INIT_WAIT_TIME); |
122 | task[4] = false; | 129 | task[4] = false; |
123 | task[5] = true; | 130 | task[5] = true; |
124 | } | 131 | } |
@@ -128,6 +135,7 @@ void* processHeat(void* arg) | @@ -128,6 +135,7 @@ void* processHeat(void* arg) | ||
128 | //Chauffe par palier | 135 | //Chauffe par palier |
129 | else if (task[5]) | 136 | else if (task[5]) |
130 | { | 137 | { |
138 | + printx(INFO, HEAT, "Entering in task 5\n"); | ||
131 | tTask = clock(); | 139 | tTask = clock(); |
132 | task[5] = false; | 140 | task[5] = false; |
133 | task[6] = true; | 141 | task[6] = true; |
@@ -136,9 +144,10 @@ void* processHeat(void* arg) | @@ -136,9 +144,10 @@ void* processHeat(void* arg) | ||
136 | 144 | ||
137 | else if (task[6]) | 145 | else if (task[6]) |
138 | { | 146 | { |
147 | + printx(INFO, HEAT, "Entering in task 6\n"); | ||
139 | if (tAct < T_STEP_THRESH) | 148 | if (tAct < T_STEP_THRESH) |
140 | { | 149 | { |
141 | - printx(INFO, BUS, "Début Chauffe par palier 3\n"); | 150 | + printx(INFO, HEAT, "Début Chauffe par palier 3\n"); |
142 | setHeatOn(); | 151 | setHeatOn(); |
143 | task[6] = false; | 152 | task[6] = false; |
144 | task[7] = true; | 153 | task[7] = true; |
@@ -153,6 +162,7 @@ void* processHeat(void* arg) | @@ -153,6 +162,7 @@ void* processHeat(void* arg) | ||
153 | 162 | ||
154 | else if (task[7]) | 163 | else if (task[7]) |
155 | { | 164 | { |
165 | + printx(INFO, HEAT, "Entering in task 7\n"); | ||
156 | tTask = clock(); | 166 | tTask = clock(); |
157 | task[7] = false; | 167 | task[7] = false; |
158 | task[8] = true; | 168 | task[8] = true; |
@@ -160,9 +170,10 @@ void* processHeat(void* arg) | @@ -160,9 +170,10 @@ void* processHeat(void* arg) | ||
160 | 170 | ||
161 | else if (task[8]) | 171 | else if (task[8]) |
162 | { | 172 | { |
173 | + printx(INFO, HEAT, "Entering in task 8\n"); | ||
163 | if( ((tNow - tTask) / CLOCKS_PER_SEC) > STEP_HEAT_TIME ) | 174 | if( ((tNow - tTask) / CLOCKS_PER_SEC) > STEP_HEAT_TIME ) |
164 | { | 175 | { |
165 | - printx(INFO, BUS, "Fin de chauffe palier intermédiaire 4\n"); | 176 | + printx(INFO, HEAT, "Fin de chauffe palier intermédiaire 4\n"); |
166 | setHeatOff(); | 177 | setHeatOff(); |
167 | task[8] = false; | 178 | task[8] = false; |
168 | task[9] = true; | 179 | task[9] = true; |
@@ -171,6 +182,7 @@ void* processHeat(void* arg) | @@ -171,6 +182,7 @@ void* processHeat(void* arg) | ||
171 | 182 | ||
172 | else if (task[9]) | 183 | else if (task[9]) |
173 | { | 184 | { |
185 | + printx(INFO, HEAT, "Entering in task 9\n"); | ||
174 | tTask = clock(); | 186 | tTask = clock(); |
175 | task[9] = false; | 187 | task[9] = false; |
176 | task[10] = true; | 188 | task[10] = true; |
@@ -178,9 +190,10 @@ void* processHeat(void* arg) | @@ -178,9 +190,10 @@ void* processHeat(void* arg) | ||
178 | 190 | ||
179 | else if (task[10]) | 191 | else if (task[10]) |
180 | { | 192 | { |
193 | + printx(INFO, HEAT, "Entering in task 10\n"); | ||
181 | if( ((tNow - tTask) / CLOCKS_PER_SEC) > STEP_WAIT_TIME ) | 194 | if( ((tNow - tTask) / CLOCKS_PER_SEC) > STEP_WAIT_TIME ) |
182 | { | 195 | { |
183 | - printx(INFO, BUS, "Fin d'attente palier intermédiaire 5\n"); | 196 | + printx(INFO, HEAT, "Fin d'attente palier intermédiaire 5\n"); |
184 | 197 | ||
185 | if ( tAct < T_STEP_THRESH ) | 198 | if ( tAct < T_STEP_THRESH ) |
186 | { | 199 | { |
@@ -200,6 +213,7 @@ void* processHeat(void* arg) | @@ -200,6 +213,7 @@ void* processHeat(void* arg) | ||
200 | // Maintien au chaud | 213 | // Maintien au chaud |
201 | else if (task[11]) | 214 | else if (task[11]) |
202 | { | 215 | { |
216 | + printx(INFO, HEAT, "Entering in task 11\n"); | ||
203 | tTask = clock(); | 217 | tTask = clock(); |
204 | task[11] = false; | 218 | task[11] = false; |
205 | task[12] = true; | 219 | task[12] = true; |
@@ -207,7 +221,8 @@ void* processHeat(void* arg) | @@ -207,7 +221,8 @@ void* processHeat(void* arg) | ||
207 | 221 | ||
208 | else if (task[12]) | 222 | else if (task[12]) |
209 | { | 223 | { |
210 | - printx(INFO, BUS, "Début Maintien au chaud 6\n"); | 224 | + printx(INFO, HEAT, "Entering in task 12\n"); |
225 | + printx(INFO, HEAT, "Début Maintien au chaud 6\n"); | ||
211 | setHeatOk(); | 226 | setHeatOk(); |
212 | task[12]=false; | 227 | task[12]=false; |
213 | task[13]=true; | 228 | task[13]=true; |
@@ -215,20 +230,22 @@ void* processHeat(void* arg) | @@ -215,20 +230,22 @@ void* processHeat(void* arg) | ||
215 | 230 | ||
216 | else if (task[13]) | 231 | else if (task[13]) |
217 | { | 232 | { |
233 | + printx(INFO, HEAT, "Entering in task 13\n"); | ||
218 | tTask = clock(); | 234 | tTask = clock(); |
219 | task[13] = false; | 235 | task[13] = false; |
220 | task[14] = true; | 236 | task[14] = true; |
221 | } | 237 | } |
222 | 238 | ||
223 | else if (task[14]) | 239 | else if (task[14]) |
224 | - { | 240 | + { |
241 | + printx(INFO, HEAT, "Entering in task 14\n"); | ||
225 | if(hold_heat) | 242 | if(hold_heat) |
226 | { | 243 | { |
227 | if( (tAct < T_HOLD_THRESH)) | 244 | if( (tAct < T_HOLD_THRESH)) |
228 | { | 245 | { |
229 | if (!isPumpOn()) | 246 | if (!isPumpOn()) |
230 | { | 247 | { |
231 | - printx(INFO, BUS, "Début Chauffe maintien sans pompe 7\n"); | 248 | + printx(INFO, HEAT, "Début Chauffe maintien sans pompe 7\n"); |
232 | setHeatOn(); | 249 | setHeatOn(); |
233 | task[14] = false; | 250 | task[14] = false; |
234 | task[15] = true; | 251 | task[15] = true; |
@@ -236,7 +253,7 @@ void* processHeat(void* arg) | @@ -236,7 +253,7 @@ void* processHeat(void* arg) | ||
236 | 253 | ||
237 | else | 254 | else |
238 | { | 255 | { |
239 | - printx(INFO, BUS, "Début Chauffe maintien avec pompe 7'\n"); | 256 | + printx(INFO, HEAT, "Début Chauffe maintien avec pompe 7'\n"); |
240 | setHeatOn(); | 257 | setHeatOn(); |
241 | task[14]=false; | 258 | task[14]=false; |
242 | task[19]=true; //Numéro de tache "T<Thold && pumpitup" | 259 | task[19]=true; //Numéro de tache "T<Thold && pumpitup" |
@@ -247,7 +264,7 @@ void* processHeat(void* arg) | @@ -247,7 +264,7 @@ void* processHeat(void* arg) | ||
247 | 264 | ||
248 | else | 265 | else |
249 | { | 266 | { |
250 | - printx(INFO, BUS, "Maintien au chaud annulé 7 ' ' Go etape de fin\n"); | 267 | + printx(INFO, HEAT, "Maintien au chaud annulé 7 ' ' Go etape de fin\n"); |
251 | task[14]=false; | 268 | task[14]=false; |
252 | task[23]=true; //Sinon go étape d'attente fin | 269 | task[23]=true; //Sinon go étape d'attente fin |
253 | } | 270 | } |
@@ -255,6 +272,7 @@ void* processHeat(void* arg) | @@ -255,6 +272,7 @@ void* processHeat(void* arg) | ||
255 | 272 | ||
256 | else if (task[15]) | 273 | else if (task[15]) |
257 | { | 274 | { |
275 | + printx(INFO, HEAT, "Entering in task 15\n"); | ||
258 | tTask = clock(); | 276 | tTask = clock(); |
259 | task[15] = false; | 277 | task[15] = false; |
260 | task[16] = true; | 278 | task[16] = true; |
@@ -263,9 +281,10 @@ void* processHeat(void* arg) | @@ -263,9 +281,10 @@ void* processHeat(void* arg) | ||
263 | //Maintien au chaud sans pompage | 281 | //Maintien au chaud sans pompage |
264 | else if (task[16]) | 282 | else if (task[16]) |
265 | { | 283 | { |
284 | + printx(INFO, HEAT, "Entering in task 16\n"); | ||
266 | if( ((tNow - tTask) / CLOCKS_PER_SEC) > HOLD_HEAT_TIME ) | 285 | if( ((tNow - tTask) / CLOCKS_PER_SEC) > HOLD_HEAT_TIME ) |
267 | { | 286 | { |
268 | - printx(INFO, BUS, "Fin chauffe maintien sans pompe 8\n"); | 287 | + printx(INFO, HEAT, "Fin chauffe maintien sans pompe 8\n"); |
269 | setHeatOff(); | 288 | setHeatOff(); |
270 | task[16] = false; | 289 | task[16] = false; |
271 | task[17] = true; | 290 | task[17] = true; |
@@ -274,6 +293,7 @@ void* processHeat(void* arg) | @@ -274,6 +293,7 @@ void* processHeat(void* arg) | ||
274 | 293 | ||
275 | else if (task[17]) | 294 | else if (task[17]) |
276 | { | 295 | { |
296 | + printx(INFO, HEAT, "Entering in task 17\n"); | ||
277 | tTask = clock(); | 297 | tTask = clock(); |
278 | task[17] = false; | 298 | task[17] = false; |
279 | task[18] = true; | 299 | task[18] = true; |
@@ -281,11 +301,12 @@ void* processHeat(void* arg) | @@ -281,11 +301,12 @@ void* processHeat(void* arg) | ||
281 | 301 | ||
282 | else if (task[18]) | 302 | else if (task[18]) |
283 | { | 303 | { |
304 | + printx(INFO, HEAT, "Entering in task 18\n"); | ||
284 | if( ((tNow - tTask) / CLOCKS_PER_SEC) > HOLD_WAIT_TIME ) | 305 | if( ((tNow - tTask) / CLOCKS_PER_SEC) > HOLD_WAIT_TIME ) |
285 | { | 306 | { |
286 | if ( tAct < T_HOLD_THRESH) | 307 | if ( tAct < T_HOLD_THRESH) |
287 | { | 308 | { |
288 | - printx(INFO, BUS, "Fin d'attente chauffe intermédiaire maintien 9\n"); | 309 | + printx(INFO, HEAT, "Fin d'attente chauffe intermédiaire maintien 9\n"); |
289 | task[18] = false; | 310 | task[18] = false; |
290 | task[11] = true; //Retour au début de "Maintien au chaud" | 311 | task[11] = true; //Retour au début de "Maintien au chaud" |
291 | } | 312 | } |
@@ -295,6 +316,7 @@ void* processHeat(void* arg) | @@ -295,6 +316,7 @@ void* processHeat(void* arg) | ||
295 | //Maintien au chaud avec pompage | 316 | //Maintien au chaud avec pompage |
296 | else if (task[19]) | 317 | else if (task[19]) |
297 | { | 318 | { |
319 | + printx(INFO, HEAT, "Entering in task 19\n"); | ||
298 | tTask = clock(); | 320 | tTask = clock(); |
299 | task[19] = false; | 321 | task[19] = false; |
300 | task[20] = true; | 322 | task[20] = true; |
@@ -302,9 +324,10 @@ void* processHeat(void* arg) | @@ -302,9 +324,10 @@ void* processHeat(void* arg) | ||
302 | 324 | ||
303 | else if (task[20]) | 325 | else if (task[20]) |
304 | { | 326 | { |
327 | + printx(INFO, HEAT, "Entering in task 20\n"); | ||
305 | if( ((tNow - tTask) / CLOCKS_PER_SEC) > HOLD_PUMP_HEAT_TIME ) | 328 | if( ((tNow - tTask) / CLOCKS_PER_SEC) > HOLD_PUMP_HEAT_TIME ) |
306 | { | 329 | { |
307 | - printx(INFO, BUS, "Fin chauffe maintien avec pompe 10\n"); | 330 | + printx(INFO, HEAT, "Fin chauffe maintien avec pompe 10\n"); |
308 | setHeatOff(); | 331 | setHeatOff(); |
309 | task[20] = false; | 332 | task[20] = false; |
310 | task[21] = true; | 333 | task[21] = true; |
@@ -313,6 +336,7 @@ void* processHeat(void* arg) | @@ -313,6 +336,7 @@ void* processHeat(void* arg) | ||
313 | 336 | ||
314 | else if (task[21]) | 337 | else if (task[21]) |
315 | { | 338 | { |
339 | + printx(INFO, HEAT, "Entering in task 21\n"); | ||
316 | tTask = clock(); | 340 | tTask = clock(); |
317 | task[21] = false; | 341 | task[21] = false; |
318 | task[22] = true; | 342 | task[22] = true; |
@@ -320,11 +344,12 @@ void* processHeat(void* arg) | @@ -320,11 +344,12 @@ void* processHeat(void* arg) | ||
320 | 344 | ||
321 | else if (task[22]) | 345 | else if (task[22]) |
322 | { | 346 | { |
347 | + printx(INFO, HEAT, "Entering in task 22\n"); | ||
323 | if( ((tNow - tTask) / CLOCKS_PER_SEC) > HOLD_PUMP_WAIT_TIME ) | 348 | if( ((tNow - tTask) / CLOCKS_PER_SEC) > HOLD_PUMP_WAIT_TIME ) |
324 | { | 349 | { |
325 | if ( tAct < T_HOLD_THRESH) | 350 | if ( tAct < T_HOLD_THRESH) |
326 | { | 351 | { |
327 | - printx(INFO, BUS, "Fin d'attente chauffe intermédiaire maintien avec pompe 11\n"); | 352 | + printx(INFO, HEAT, "Fin d'attente chauffe intermédiaire maintien avec pompe 11\n"); |
328 | task[22] = false; | 353 | task[22] = false; |
329 | task[11] = true; //Retour au début de "Maintien au chaud" | 354 | task[11] = true; //Retour au début de "Maintien au chaud" |
330 | } | 355 | } |
@@ -334,6 +359,7 @@ void* processHeat(void* arg) | @@ -334,6 +359,7 @@ void* processHeat(void* arg) | ||
334 | //Fin de maintien au chaud (demandé par l'extérieur) et reboucle quand hold_heat est remis | 359 | //Fin de maintien au chaud (demandé par l'extérieur) et reboucle quand hold_heat est remis |
335 | else if(task[23]) | 360 | else if(task[23]) |
336 | { | 361 | { |
362 | + printx(INFO, HEAT, "Entering in task 23\n"); | ||
337 | setHeatOff(); | 363 | setHeatOff(); |
338 | heat_ok=false; | 364 | heat_ok=false; |
339 | 365 | ||
@@ -351,8 +377,7 @@ void* processHeat(void* arg) | @@ -351,8 +377,7 @@ void* processHeat(void* arg) | ||
351 | //task[]=false; | 377 | //task[]=false; |
352 | //task[]=true; | 378 | //task[]=true; |
353 | } | 379 | } |
354 | - | ||
355 | - | 380 | + usleep(20000); |
356 | } | 381 | } |
357 | 382 | ||
358 | 383 |
@@ -128,7 +128,8 @@ bool initHVC() | @@ -128,7 +128,8 @@ bool initHVC() | ||
128 | sendData(&hvc_fd, GET_PUMP); | 128 | sendData(&hvc_fd, GET_PUMP); |
129 | data = getData(&hvc_fd); | 129 | data = getData(&hvc_fd); |
130 | 130 | ||
131 | - previousPumpState = data == PUMP_STATE_HIGH; | 131 | + previousPumpState = (data == PUMP_STATE_HIGH); |
132 | + printf("Data received from HVC for PUMP %02x\n", data); | ||
132 | 133 | ||
133 | return true; | 134 | return true; |
134 | } | 135 | } |
@@ -187,12 +188,14 @@ void* processHVC(void* we) | @@ -187,12 +188,14 @@ void* processHVC(void* we) | ||
187 | } | 188 | } |
188 | 189 | ||
189 | // Querying pump state | 190 | // Querying pump state |
190 | - sendData(&hvc_fd, GET_TEMP); | 191 | + sendData(&hvc_fd, GET_PUMP); |
191 | data = getData(&hvc_fd); | 192 | data = getData(&hvc_fd); |
192 | - pumpState = data == PUMP_STATE_HIGH; | 193 | + pumpState = (data == PUMP_STATE_HIGH); |
194 | + printx(DEBUG, HVC, "PUMP %d %d Flow : %d\n", previousPumpState, pumpState, pumped); | ||
193 | if(pumpState ^ previousPumpState) | 195 | if(pumpState ^ previousPumpState) |
194 | pumped++; | 196 | pumped++; |
195 | previousPumpState = pumpState; | 197 | previousPumpState = pumpState; |
198 | + actDeb(pumped); | ||
196 | 199 | ||
197 | usleep(HVC_POLLING_TIME); | 200 | usleep(HVC_POLLING_TIME); |
198 | } | 201 | } |
@@ -17,6 +17,7 @@ int main(void) | @@ -17,6 +17,7 @@ int main(void) | ||
17 | pthread_t tBUS; | 17 | pthread_t tBUS; |
18 | pthread_t tHVC; | 18 | pthread_t tHVC; |
19 | pthread_t tHeat; | 19 | pthread_t tHeat; |
20 | + pthread_t tPump; | ||
20 | initUILog(); | 21 | initUILog(); |
21 | if(!initLog()) | 22 | if(!initLog()) |
22 | { | 23 | { |
@@ -48,8 +49,11 @@ int main(void) | @@ -48,8 +49,11 @@ int main(void) | ||
48 | pthread_create(&tHVC, NULL, processHVC, NULL); | 49 | pthread_create(&tHVC, NULL, processHVC, NULL); |
49 | initProcessHeat(); | 50 | initProcessHeat(); |
50 | initProcessPump(); | 51 | initProcessPump(); |
51 | - //setPumpOn(); | ||
52 | pthread_create(&tHeat, NULL, processHeat, NULL); | 52 | pthread_create(&tHeat, NULL, processHeat, NULL); |
53 | + pthread_create(&tPump, NULL, processPump, NULL); | ||
54 | + | ||
55 | + setVolWanted(1); | ||
56 | + setCoffeeWanted(); | ||
53 | 57 | ||
54 | pthread_join(tUI, NULL); | 58 | pthread_join(tUI, NULL); |
55 | closeLog(); | 59 | closeLog(); |
printx.c
@@ -11,9 +11,9 @@ | @@ -11,9 +11,9 @@ | ||
11 | #define S_RESET "\33[0m" | 11 | #define S_RESET "\33[0m" |
12 | #define MAX_BUFFER 128 | 12 | #define MAX_BUFFER 128 |
13 | 13 | ||
14 | -FILE* logfiles[6] = {NULL, NULL, NULL, NULL, NULL, NULL}; | 14 | +FILE* logfiles[8] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; |
15 | char s_color[4][12] = {"\x1b[01;31m", "\x1b[01;33m", "\x1b[01;32m", "\x1b[01;36m"}; | 15 | char s_color[4][12] = {"\x1b[01;31m", "\x1b[01;33m", "\x1b[01;32m", "\x1b[01;36m"}; |
16 | -char f_name[6][5] = {"MAIN", "UI ", "NFC ", "HVC ", "BUS ", "TEMP"}; | 16 | +char f_name[8][5] = {"MAIN", "UI ", "NFC ", "HVC ", "BUS ", "TEMP", "PUMP", "HEAT"}; |
17 | struct timeval tv; | 17 | struct timeval tv; |
18 | 18 | ||
19 | void removeCharFromString(char c, char *str) | 19 | void removeCharFromString(char c, char *str) |
@@ -68,6 +68,20 @@ bool initLog() | @@ -68,6 +68,20 @@ bool initLog() | ||
68 | return false; | 68 | return false; |
69 | } | 69 | } |
70 | 70 | ||
71 | + logfiles[6] = fopen("log/pump.log", "a"); | ||
72 | + if(logfiles[6] == NULL) | ||
73 | + { | ||
74 | + printf("Unable to open the pump log file\n"); | ||
75 | + return false; | ||
76 | + } | ||
77 | + | ||
78 | + logfiles[7] = fopen("log/heat.log", "a"); | ||
79 | + if(logfiles[7] == NULL) | ||
80 | + { | ||
81 | + printf("Unable to open the heat log file\n"); | ||
82 | + return false; | ||
83 | + } | ||
84 | + | ||
71 | return true; | 85 | return true; |
72 | } | 86 | } |
73 | 87 | ||
@@ -79,6 +93,8 @@ void closeLog() | @@ -79,6 +93,8 @@ void closeLog() | ||
79 | fclose(logfiles[3]); | 93 | fclose(logfiles[3]); |
80 | fclose(logfiles[4]); | 94 | fclose(logfiles[4]); |
81 | fclose(logfiles[5]); | 95 | fclose(logfiles[5]); |
96 | + fclose(logfiles[6]); | ||
97 | + fclose(logfiles[7]); | ||
82 | } | 98 | } |
83 | 99 | ||
84 | void printx(severity s, msgfrom from, char* str, ...) | 100 | void printx(severity s, msgfrom from, char* str, ...) |
printx.h
@@ -78,7 +78,7 @@ void* processPump(void* arg) | @@ -78,7 +78,7 @@ void* processPump(void* arg) | ||
78 | { | 78 | { |
79 | if (coffee_wanted) | 79 | if (coffee_wanted) |
80 | { | 80 | { |
81 | - printx(INFO, BUS, "Demande de café prise en compte 1\n"); | 81 | + printx(INFO, PUMP, "Demande de café prise en compte 1\n"); |
82 | taskP[0]=false; | 82 | taskP[0]=false; |
83 | taskP[1]=true; | 83 | taskP[1]=true; |
84 | } | 84 | } |
@@ -88,14 +88,14 @@ void* processPump(void* arg) | @@ -88,14 +88,14 @@ void* processPump(void* arg) | ||
88 | { | 88 | { |
89 | if (isHeatOk()) | 89 | if (isHeatOk()) |
90 | { | 90 | { |
91 | - printx(INFO, BUS, "Chauffe eau a bonne temperature OK 2\n"); | 91 | + printx(INFO, PUMP, "Chauffe eau a bonne temperature OK 2\n"); |
92 | taskP[1]=false; | 92 | taskP[1]=false; |
93 | taskP[3]=true; | 93 | taskP[3]=true; |
94 | } | 94 | } |
95 | 95 | ||
96 | else | 96 | else |
97 | { | 97 | { |
98 | - printx(INFO, BUS, "Attente chauffe eau a bonne temperature 2'\n"); | 98 | + printx(INFO, PUMP, "Attente chauffe eau a bonne temperature 2'\n"); |
99 | taskP[1]=false; | 99 | taskP[1]=false; |
100 | taskP[2]=true; | 100 | taskP[2]=true; |
101 | } | 101 | } |
@@ -113,7 +113,7 @@ void* processPump(void* arg) | @@ -113,7 +113,7 @@ void* processPump(void* arg) | ||
113 | else if (taskP[3]) | 113 | else if (taskP[3]) |
114 | { | 114 | { |
115 | tTaskP = clock(); | 115 | tTaskP = clock(); |
116 | - printx(INFO, BUS, "Distribution de l'eau Pompe ON 3\n"); | 116 | + printx(INFO, PUMP, "Distribution de l'eau Pompe ON 3\n"); |
117 | taskP[3]=false; | 117 | taskP[3]=false; |
118 | taskP[4]=true; | 118 | taskP[4]=true; |
119 | } | 119 | } |
@@ -125,14 +125,14 @@ void* processPump(void* arg) | @@ -125,14 +125,14 @@ void* processPump(void* arg) | ||
125 | 125 | ||
126 | if (volDeb > volWanted) | 126 | if (volDeb > volWanted) |
127 | { | 127 | { |
128 | - printx(INFO, BUS, "Fin de Distribution de l'eau Pompe OFF 4\n"); | 128 | + printx(INFO, PUMP, "Fin de Distribution de l'eau Pompe OFF 4\n"); |
129 | taskP[4]=false; | 129 | taskP[4]=false; |
130 | taskP[5]=true; | 130 | taskP[5]=true; |
131 | } | 131 | } |
132 | 132 | ||
133 | else if ( ((tNowP - tTaskP) / CLOCKS_PER_SEC) > 60 ) | 133 | else if ( ((tNowP - tTaskP) / CLOCKS_PER_SEC) > 60 ) |
134 | { | 134 | { |
135 | - printx(INFO, BUS, "Pompe utilisée depuis plus d'1 min, mise en pause 4'\n"); | 135 | + printx(INFO, PUMP, "Pompe utilisée depuis plus d'1 min, mise en pause 4'\n"); |
136 | taskP[4]=false; | 136 | taskP[4]=false; |
137 | taskP[6]=false; | 137 | taskP[6]=false; |
138 | } | 138 | } |
@@ -143,7 +143,7 @@ void* processPump(void* arg) | @@ -143,7 +143,7 @@ void* processPump(void* arg) | ||
143 | setPumpOff(); | 143 | setPumpOff(); |
144 | pump_on=false; | 144 | pump_on=false; |
145 | 145 | ||
146 | - printx(INFO, BUS, "Cafe servi 5\n"); | 146 | + printx(INFO, PUMP, "Cafe servi 5\n"); |
147 | volWanted=0; | 147 | volWanted=0; |
148 | coffee_wanted=false; | 148 | coffee_wanted=false; |
149 | 149 | ||
@@ -156,7 +156,7 @@ void* processPump(void* arg) | @@ -156,7 +156,7 @@ void* processPump(void* arg) | ||
156 | setPumpOff(); | 156 | setPumpOff(); |
157 | pump_on=false; | 157 | pump_on=false; |
158 | 158 | ||
159 | - printx(INFO, BUS, "En pause, Pompe OFF 6"); | 159 | + printx(INFO, PUMP, "En pause, Pompe OFF 6"); |
160 | 160 | ||
161 | tTaskP = clock(); | 161 | tTaskP = clock(); |
162 | taskP[6]=false; | 162 | taskP[6]=false; |
@@ -167,13 +167,13 @@ void* processPump(void* arg) | @@ -167,13 +167,13 @@ void* processPump(void* arg) | ||
167 | { | 167 | { |
168 | if ( ((tNowP - tTaskP) / CLOCKS_PER_SEC) > 60 ) | 168 | if ( ((tNowP - tTaskP) / CLOCKS_PER_SEC) > 60 ) |
169 | { | 169 | { |
170 | - printx(INFO, BUS, "Pause terminée 7\n"); | 170 | + printx(INFO, PUMP, "Pause terminée 7\n"); |
171 | taskP[7]=false; | 171 | taskP[7]=false; |
172 | taskP[4]=true; | 172 | taskP[4]=true; |
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | - sleep(50); | 176 | + usleep(20000); |
177 | } | 177 | } |
178 | 178 | ||
179 | return NULL; | 179 | return NULL; |