827 |
827 |
828 |
828 |
829 int server(void) |
829 int server(void) |
830 { |
830 { |
831 char buf[1024], *filename, target[40], heater[40], cooler[40], fan[40], door[40]; |
831 char buf[1024], *filename, target[40], heater[40], cooler[40], fan[40], door[40]; |
|
832 char use_heater[40], use_cooler[40], use_fan[40]; |
832 time_t now, last = (time_t)0; |
833 time_t now, last = (time_t)0; |
833 units_list *unit; |
834 units_list *unit; |
834 profiles_list *profile; |
835 profiles_list *profile; |
835 prof_step *step; |
836 prof_step *step; |
836 int rc, run = 1, seconds = 0, minutes = 0, piddelay = 0, temp, deviation; |
837 int rc, run = 1, seconds = 0, minutes = 0, piddelay = 0, temp, deviation; |
1445 snprintf(target, 39, "NA"); |
1446 snprintf(target, 39, "NA"); |
1446 snprintf(heater, 39, "NA"); |
1447 snprintf(heater, 39, "NA"); |
1447 snprintf(cooler, 39, "NA"); |
1448 snprintf(cooler, 39, "NA"); |
1448 snprintf(fan, 39, "NA"); |
1449 snprintf(fan, 39, "NA"); |
1449 snprintf(door, 39, "NA"); |
1450 snprintf(door, 39, "NA"); |
|
1451 snprintf(use_heater, 39, "NA"); |
|
1452 snprintf(use_cooler, 39, "NA"); |
|
1453 snprintf(use_fan, 39, "NA"); |
|
1454 |
1450 |
1455 |
1451 if (unit->mode == UNITMODE_BEER) |
1456 if (unit->mode == UNITMODE_BEER) |
1452 snprintf(target, 39, "%.1f", unit->beer_set); |
1457 snprintf(target, 39, "%.1f", unit->beer_set); |
1453 else if (unit->mode == UNITMODE_FRIDGE) |
1458 else if (unit->mode == UNITMODE_FRIDGE) |
1454 snprintf(target, 39, "%.1f", unit->fridge_set); |
1459 snprintf(target, 39, "%.1f", unit->fridge_set); |
1455 else if (unit->mode == UNITMODE_PROFILE) |
1460 else if (unit->mode == UNITMODE_PROFILE) |
1456 snprintf(target, 39, "%.1f", unit->prof_target); |
1461 snprintf(target, 39, "%.1f", unit->prof_target); |
1457 |
1462 |
1458 if (unit->heater_address) { |
1463 if (unit->heater_address) { |
1459 snprintf(heater, 39, "%d", unit->heater_state); |
1464 snprintf(heater, 39, "%d", unit->heater_state); |
|
1465 snprintf(use_heater, 39, "%d", unit->heater_usage); |
1460 } |
1466 } |
1461 if (unit->cooler_address) { |
1467 if (unit->cooler_address) { |
1462 snprintf(cooler, 39, "%d", unit->cooler_state); |
1468 snprintf(cooler, 39, "%d", unit->cooler_state); |
|
1469 snprintf(use_cooler, 39, "%d", unit->cooler_usage); |
1463 } |
1470 } |
1464 if (unit->fan_address) { |
1471 if (unit->fan_address) { |
1465 snprintf(fan, 39, "%d", unit->fan_state); |
1472 snprintf(fan, 39, "%d", unit->fan_state); |
|
1473 snprintf(use_fan, 39, "%d", unit->fan_usage); |
1466 } |
1474 } |
1467 if (unit->door_address) { |
1475 if (unit->door_address) { |
1468 snprintf(door, 39, "%d", unit->door_state); |
1476 snprintf(door, 39, "%d", unit->door_state); |
1469 } |
1477 } |
1470 |
1478 |
1471 snprintf(buf, 1023, "%s,%.3f,%.3f,%s,%s,%s,%s,%s", |
1479 snprintf(buf, 1023, "%s,%.3f,%.3f,%s,%s,%s,%s,%s,%s,%s,%s", |
1472 UNITMODE[unit->mode], unit->air_temperature / 1000.0, |
1480 UNITMODE[unit->mode], unit->air_temperature / 1000.0, |
1473 unit->beer_temperature / 1000.0, target, heater, cooler, fan, door); |
1481 unit->beer_temperature / 1000.0, target, heater, cooler, fan, door, use_heater, use_cooler, use_fan); |
1474 filename = xstrcpy(unit->name); |
1482 filename = xstrcpy(unit->name); |
1475 filename = xstrcat(filename, (char *)".log"); |
1483 filename = xstrcat(filename, (char *)".log"); |
1476 logger(filename, buf); |
1484 logger(filename, buf); |
1477 free(filename); |
1485 free(filename); |
1478 filename = NULL; |
1486 filename = NULL; |