130 slcdPuts(slcdHandle, text); |
130 slcdPuts(slcdHandle, text); |
131 } |
131 } |
132 |
132 |
133 |
133 |
134 |
134 |
135 int manual_menu(units_list *); |
135 int manual_menu(units_list *, double, double); |
136 int manual_menu(units_list *unit) |
136 int manual_menu(units_list *unit, double hlt, double mlt) |
137 { |
137 { |
138 int key; |
138 int key, i; |
139 static int man_hlt_heat, man_mlt_heat, man_mlt_pump; |
139 static int man_hlt_heat, man_mlt_heat, man_mlt_pump; |
140 |
140 |
141 switch (manual) { |
141 switch (manual) { |
142 case MANUAL_SELHLT: prompt(104, NULL); |
142 case MANUAL_SELHLT: prompt(104, NULL); |
143 prompt(219, NULL); |
143 prompt(219, NULL); |
175 device_out(unit->mlt_pump.uuid, man_mlt_pump); |
175 device_out(unit->mlt_pump.uuid, man_mlt_pump); |
176 } |
176 } |
177 break; |
177 break; |
178 case MANUAL_HLT: prompt(104, NULL); |
178 case MANUAL_HLT: prompt(104, NULL); |
179 prompt(413, NULL); |
179 prompt(413, NULL); |
180 |
180 tempstatus(*unit->PID_hlt->myInput, *unit->PID_mlt->myInput); |
181 key = keywait(); |
181 |
|
182 for (i = 1; i < 100; i++) { |
|
183 usleep(10000); |
|
184 slcdDummy(slcdHandle); |
|
185 key = keycheck(); |
|
186 if ((key != KEY_NONE) || my_shutdown) |
|
187 break; |
|
188 } |
182 if (key == KEY_RETURN) { |
189 if (key == KEY_RETURN) { |
183 if (man_hlt_heat) |
190 if (man_hlt_heat) |
184 man_hlt_heat = 0; |
191 man_hlt_heat = 0; |
185 else |
192 else |
186 man_hlt_heat = 1; |
193 man_hlt_heat = 1; |
193 if (debug) |
200 if (debug) |
194 fprintf(stdout, "device_out(%s, %d) HLT heater\n", unit->hlt_heater.uuid, man_hlt_heat); |
201 fprintf(stdout, "device_out(%s, %d) HLT heater\n", unit->hlt_heater.uuid, man_hlt_heat); |
195 break; |
202 break; |
196 case MANUAL_MLT: prompt(104, NULL); |
203 case MANUAL_MLT: prompt(104, NULL); |
197 prompt(406, NULL); |
204 prompt(406, NULL); |
198 key = keywait(); |
205 tempstatus(*unit->PID_hlt->myInput, *unit->PID_mlt->myInput); |
|
206 |
|
207 for (i = 1; i < 100; i++) { |
|
208 usleep(10000); |
|
209 slcdDummy(slcdHandle); |
|
210 key = keycheck(); |
|
211 if ((key != KEY_NONE) || my_shutdown) |
|
212 break; |
|
213 } |
199 if (key == KEY_RETURN) { |
214 if (key == KEY_RETURN) { |
200 if (man_mlt_heat) |
215 if (man_mlt_heat) |
201 man_mlt_heat = 0; |
216 man_mlt_heat = 0; |
202 else |
217 else |
203 man_mlt_heat = 1; |
218 man_mlt_heat = 1; |
223 |
238 |
224 |
239 |
225 int server(void); |
240 int server(void); |
226 int server(void) |
241 int server(void) |
227 { |
242 { |
228 int rc = 0, run = 1, key; |
243 int rc = 0, run = 1, key, temp; |
229 int do_init = TRUE, seconds = 0, minutes = 0; |
244 int do_init = TRUE, seconds = 0, minutes = 0; |
230 units_list *unit; |
245 units_list *unit; |
231 brew_session *brew = NULL; |
246 brew_session *brew = NULL; |
232 #ifndef HAVE_WIRINGPI_H |
247 #ifndef HAVE_WIRINGPI_H |
233 long t = 0; |
248 long t = 0; |
234 #endif |
249 #endif |
235 struct tm *tm; |
|
236 time_t now, last = (time_t)0; |
250 time_t now, last = (time_t)0; |
237 static double hltInput, hltOutput, hltSetpoint, mltInput, mltOutput, mltSetpoint; |
251 static double hltInput, hltOutput, hltSetpoint, mltInput, mltOutput, mltSetpoint; |
238 |
252 |
239 prompt(101, NULL); |
253 prompt(101, NULL); |
240 |
254 |
424 /* |
438 /* |
425 * Each second |
439 * Each second |
426 */ |
440 */ |
427 last = now; |
441 last = now; |
428 seconds++; |
442 seconds++; |
429 fprintf(stdout, "1 second %ld millis\n", millis()); |
443 if (seconds > 59) { |
|
444 seconds = 0; |
|
445 minutes++; |
|
446 } |
|
447 |
|
448 fprintf(stdout, "%d seconds %d minutes %ld millis\n", seconds, minutes, millis()); |
|
449 |
|
450 rc = device_in(unit->hlt_sensor.uuid, &temp); |
|
451 if (rc == DEVPRESENT_YES) { |
|
452 hltInput = temp / 1000.0; |
|
453 unit->hlt_sensor.state = 0; |
|
454 } else if (rc == DEVPRESENT_ERROR) { |
|
455 unit->hlt_sensor.state = 1; |
|
456 } else { |
|
457 unit->hlt_sensor.state = 2; |
|
458 } |
|
459 rc = device_in(unit->mlt_sensor.uuid, &temp); |
|
460 if (rc == DEVPRESENT_YES) { |
|
461 mltInput = temp / 1000.0; |
|
462 unit->mlt_sensor.state = 0; |
|
463 } else if (rc == DEVPRESENT_ERROR) { |
|
464 unit->mlt_sensor.state = 1; |
|
465 } else { |
|
466 unit->mlt_sensor.state = 2; |
|
467 } |
|
468 |
430 if (debug && ((seconds % 10) == 1)) { |
469 if (debug && ((seconds % 10) == 1)) { |
431 fprintf(stdout, "MLT: In=%.2lf Out=%.2lf Set=%.2lf HLT: In=%.2lf Out=%.2lf Set=%.2lf\n", |
470 fprintf(stdout, "MLT: In=%.2lf Out=%.2lf Set=%.2lf HLT: In=%.2lf Out=%.2lf Set=%.2lf\n", |
432 mltInput, mltOutput, mltSetpoint, hltInput, hltOutput, hltSetpoint); |
471 mltInput, mltOutput, mltSetpoint, hltInput, hltOutput, hltSetpoint); |
433 } |
472 } |
434 |
473 |