1445 uuid_generate(uu); |
1445 uuid_generate(uu); |
1446 uuid_unparse(uu, unit->uuid); |
1446 uuid_unparse(uu, unit->uuid); |
1447 unit->name = xstrcpy(param); |
1447 unit->name = xstrcpy(param); |
1448 unit->air_address = unit->beer_address = unit->heater_address = unit->cooler_address = \ |
1448 unit->air_address = unit->beer_address = unit->heater_address = unit->cooler_address = \ |
1449 unit->fan_address = unit->door_address = unit->profile = NULL; |
1449 unit->fan_address = unit->door_address = unit->profile = NULL; |
1450 unit->volume = 0.0; |
1450 unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0; |
1451 unit->air_state = unit->beer_state = 1; |
1451 unit->air_state = unit->beer_state = 1; |
1452 unit->air_temperature = unit->beer_temperature = 20000; |
1452 unit->air_temperature = unit->beer_temperature = 20000; |
1453 unit->beer_set = unit->fridge_set = 20.0; |
1453 unit->beer_set = unit->fridge_set = 20.0; |
1454 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = unit->prof_state = 0; |
1454 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = unit->prof_state = 0; |
1455 unit->heater_delay = unit->cooler_delay = unit->fan_delay = 20; /* 5 minutes delay */ |
1455 unit->heater_delay = unit->cooler_delay = unit->fan_delay = 20; /* 5 minutes delay */ |
1456 unit->heater_wait = unit->cooler_wait = unit->fan_wait = 0; |
1456 unit->heater_wait = unit->cooler_wait = unit->fan_wait = 0; |
1457 unit->temp_set_min = 1.0; |
1457 unit->temp_set_min = 1.0; |
1458 unit->temp_set_max = 30.0; |
1458 unit->temp_set_max = 30.0; |
1459 unit->idle_rangeH = 1.0; |
1459 unit->idle_rangeH = 1.0; |
1460 unit->idle_rangeL = -1.0; |
1460 unit->idle_rangeL = -1.0; |
1461 unit->prof_started = unit->prof_paused = (time_t)0; |
1461 unit->prof_started = unit->prof_paused = unit->prof_primary_done = (time_t)0; |
1462 unit->prof_percent = 0; |
1462 unit->prof_percent = 0; |
1463 unit->PID_err_old = unit->PID_I_err = 0.0; |
1463 unit->PID_err_old = unit->PID_I_err = 0.0; |
1464 |
1464 |
1465 /* |
1465 /* |
1466 * Block main process |
1466 * Block main process |
1552 srv_send((char *)"PROF_STATE,%s %d%%", PROFSTATE[unit->prof_state], unit->prof_percent); |
1552 srv_send((char *)"PROF_STATE,%s %d%%", PROFSTATE[unit->prof_state], unit->prof_percent); |
1553 } else { |
1553 } else { |
1554 srv_send((char *)"PROF_STATE,%s", PROFSTATE[unit->prof_state]); |
1554 srv_send((char *)"PROF_STATE,%s", PROFSTATE[unit->prof_state]); |
1555 } |
1555 } |
1556 srv_send((char *)"PROF_TARGET,%.3f", unit->prof_target); |
1556 srv_send((char *)"PROF_TARGET,%.3f", unit->prof_target); |
|
1557 srv_send((char *)"PROF_PEAK_ABS,%.3f", unit->prof_peak_abs); |
|
1558 srv_send((char *)"PROF_PEAK_REL,%.3f", unit->prof_peak_rel); |
|
1559 srv_send((char *)"PROF_PRIMARY_DONE,%d", (int)unit->prof_primary_done); |
1557 srv_send((char *)"TEMP_SET_MIN,%.1f", unit->temp_set_min); |
1560 srv_send((char *)"TEMP_SET_MIN,%.1f", unit->temp_set_min); |
1558 srv_send((char *)"TEMP_SET_MAX,%.1f", unit->temp_set_max); |
1561 srv_send((char *)"TEMP_SET_MAX,%.1f", unit->temp_set_max); |
1559 srv_send((char *)"IDLE_RANGE_L,%.1f", unit->idle_rangeL); |
1562 srv_send((char *)"IDLE_RANGE_L,%.1f", unit->idle_rangeL); |
1560 srv_send((char *)"IDLE_RANGE_H,%.1f", unit->idle_rangeH); |
1563 srv_send((char *)"IDLE_RANGE_H,%.1f", unit->idle_rangeH); |
1561 srv_send((char *)"."); |
1564 srv_send((char *)"."); |
1825 } |
1828 } |
1826 break; |
1829 break; |
1827 case PROFILE_RUN: if (unit->prof_state == PROFILE_OFF) { |
1830 case PROFILE_RUN: if (unit->prof_state == PROFILE_OFF) { |
1828 unit->prof_state = PROFILE_RUN; |
1831 unit->prof_state = PROFILE_RUN; |
1829 unit->prof_started = time(NULL); |
1832 unit->prof_started = time(NULL); |
1830 unit->prof_paused = 0; |
1833 unit->prof_paused = unit->prof_primary_done = 0; |
|
1834 unit->prof_peak_abs = unit->prof_peak_rel = 0.0; |
1831 syslog(LOG_NOTICE, "Fermenter unit %s profile to RUN", unit->uuid); |
1835 syslog(LOG_NOTICE, "Fermenter unit %s profile to RUN", unit->uuid); |
1832 } |
1836 } |
1833 break; |
1837 break; |
1834 case PROFILE_DONE: break; /* Command is illegal */ |
1838 case PROFILE_DONE: break; /* Command is illegal */ |
1835 case PROFILE_ABORT: if ((unit->prof_state == PROFILE_RUN) || (unit->prof_state == PROFILE_PAUSE)) { |
1839 case PROFILE_ABORT: if ((unit->prof_state == PROFILE_RUN) || (unit->prof_state == PROFILE_PAUSE)) { |