1348 unit->volume = 0.0; |
1348 unit->volume = 0.0; |
1349 unit->air_state = unit->beer_state = 1; |
1349 unit->air_state = unit->beer_state = 1; |
1350 unit->air_temperature = unit->beer_temperature = 20000; |
1350 unit->air_temperature = unit->beer_temperature = 20000; |
1351 unit->beer_set = unit->fridge_set = 20.0; |
1351 unit->beer_set = unit->fridge_set = 20.0; |
1352 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = unit->prof_state = 0; |
1352 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = unit->prof_state = 0; |
|
1353 unit->heater_delay = unit->cooler_delay = unit->fan_delay = 20; /* 5 minutes delay */ |
|
1354 unit->heater_wait = unit->cooler_wait = unit->fan_wait = 0; |
1353 unit->temp_set_min = 1.0; |
1355 unit->temp_set_min = 1.0; |
1354 unit->temp_set_max = 30.0; |
1356 unit->temp_set_max = 30.0; |
1355 unit->idle_rangeH = 1.0; |
1357 unit->idle_rangeH = 1.0; |
1356 unit->idle_rangeL = -1.0; |
1358 unit->idle_rangeL = -1.0; |
1357 unit->prof_started = unit->prof_paused = (time_t)0; |
1359 unit->prof_started = unit->prof_paused = (time_t)0; |
1427 srv_send((char *)"BEER_ADDRESS,%s", MBSE_SS(unit->beer_address)); |
1429 srv_send((char *)"BEER_ADDRESS,%s", MBSE_SS(unit->beer_address)); |
1428 srv_send((char *)"BEER_STATE,%s", TEMPSTATE[unit->beer_state]); |
1430 srv_send((char *)"BEER_STATE,%s", TEMPSTATE[unit->beer_state]); |
1429 srv_send((char *)"BEER_TEMPERATURE,%.3f", unit->beer_temperature / 1000.0); |
1431 srv_send((char *)"BEER_TEMPERATURE,%.3f", unit->beer_temperature / 1000.0); |
1430 srv_send((char *)"HEATER_ADDRESS,%s", unit->heater_address); |
1432 srv_send((char *)"HEATER_ADDRESS,%s", unit->heater_address); |
1431 srv_send((char *)"HEATER_STATE,%d", unit->heater_state); |
1433 srv_send((char *)"HEATER_STATE,%d", unit->heater_state); |
|
1434 srv_send((char *)"HEATER_DELAY,%d", unit->heater_delay); |
1432 srv_send((char *)"COOLER_ADDRESS,%s", unit->cooler_address); |
1435 srv_send((char *)"COOLER_ADDRESS,%s", unit->cooler_address); |
1433 srv_send((char *)"COOLER_STATE,%d", unit->cooler_state); |
1436 srv_send((char *)"COOLER_STATE,%d", unit->cooler_state); |
|
1437 srv_send((char *)"COOLER_DELAY,%d", unit->cooler_delay); |
1434 srv_send((char *)"FAN_ADDRESS,%s", unit->fan_address); |
1438 srv_send((char *)"FAN_ADDRESS,%s", unit->fan_address); |
1435 srv_send((char *)"FAN_STATE,%d", unit->fan_state); |
1439 srv_send((char *)"FAN_STATE,%d", unit->fan_state); |
|
1440 srv_send((char *)"FAN_DELAY,%d", unit->fan_delay); |
1436 srv_send((char *)"DOOR_ADDRESS,%s", unit->door_address); |
1441 srv_send((char *)"DOOR_ADDRESS,%s", unit->door_address); |
1437 srv_send((char *)"DOOR_STATE,%d", unit->door_state); |
1442 srv_send((char *)"DOOR_STATE,%d", unit->door_state); |
1438 srv_send((char *)"MODE,%s", UNITMODE[unit->mode]); |
1443 srv_send((char *)"MODE,%s", UNITMODE[unit->mode]); |
1439 srv_send((char *)"FRIDGE_SET,%.1f", unit->fridge_set); |
1444 srv_send((char *)"FRIDGE_SET,%.1f", unit->fridge_set); |
1440 srv_send((char *)"BEER_SET,%.1f", unit->beer_set); |
1445 srv_send((char *)"BEER_SET,%.1f", unit->beer_set); |
1539 |
1544 |
1540 } else if (val && (strcmp(kwd, (char *)"HEATER_STATE") == 0)) { |
1545 } else if (val && (strcmp(kwd, (char *)"HEATER_STATE") == 0)) { |
1541 if ((sscanf(val, "%d", &ival) == 1) && ((ival == 0) || (ival == 100))) |
1546 if ((sscanf(val, "%d", &ival) == 1) && ((ival == 0) || (ival == 100))) |
1542 unit->heater_state = ival; |
1547 unit->heater_state = ival; |
1543 |
1548 |
|
1549 } else if (val && (strcmp(kwd, (char *)"HEATER_DELAY") == 0)) { |
|
1550 if ((sscanf(val, "%d", &ival) == 1) && ((ival == 0) || (ival == 100))) |
|
1551 unit->heater_delay = ival; |
|
1552 |
1544 } else if (strcmp(kwd, (char *)"COOLER_ADDRESS") == 0) { |
1553 } else if (strcmp(kwd, (char *)"COOLER_ADDRESS") == 0) { |
1545 if (unit->cooler_address) { |
1554 if (unit->cooler_address) { |
1546 device_count(FALSE, unit->cooler_address); |
1555 device_count(FALSE, unit->cooler_address); |
1547 free(unit->cooler_address); |
1556 free(unit->cooler_address); |
1548 } |
1557 } |
1553 unit->cooler_address = NULL; |
1562 unit->cooler_address = NULL; |
1554 |
1563 |
1555 } else if (val && (strcmp(kwd, (char *)"COOLER_STATE") == 0)) { |
1564 } else if (val && (strcmp(kwd, (char *)"COOLER_STATE") == 0)) { |
1556 if ((sscanf(val, "%d", &ival) == 1) && ((ival == 0) || (ival == 100))) |
1565 if ((sscanf(val, "%d", &ival) == 1) && ((ival == 0) || (ival == 100))) |
1557 unit->cooler_state = ival; |
1566 unit->cooler_state = ival; |
|
1567 |
|
1568 } else if (val && (strcmp(kwd, (char *)"COOLER_DELAY") == 0)) { |
|
1569 if ((sscanf(val, "%d", &ival) == 1) && ((ival == 0) || (ival == 100))) |
|
1570 unit->cooler_delay = ival; |
1558 |
1571 |
1559 } else if (strcmp(kwd, (char *)"FAN_ADDRESS") == 0) { |
1572 } else if (strcmp(kwd, (char *)"FAN_ADDRESS") == 0) { |
1560 if (unit->fan_address) { |
1573 if (unit->fan_address) { |
1561 device_count(FALSE, unit->fan_address); |
1574 device_count(FALSE, unit->fan_address); |
1562 free(unit->fan_address); |
1575 free(unit->fan_address); |
1569 |
1582 |
1570 } else if (val && (strcmp(kwd, (char *)"FAN_STATE") == 0)) { |
1583 } else if (val && (strcmp(kwd, (char *)"FAN_STATE") == 0)) { |
1571 if ((sscanf(val, "%d", &ival) == 1) && ((ival == 0) || (ival == 100))) |
1584 if ((sscanf(val, "%d", &ival) == 1) && ((ival == 0) || (ival == 100))) |
1572 unit->fan_state = ival; |
1585 unit->fan_state = ival; |
1573 |
1586 |
|
1587 } else if (val && (strcmp(kwd, (char *)"FAN_DELAY") == 0)) { |
|
1588 if ((sscanf(val, "%d", &ival) == 1) && ((ival == 0) || (ival == 100))) |
|
1589 unit->fan_delay = ival; |
|
1590 |
1574 } else if (strcmp(kwd, (char *)"DOOR_ADDRESS") == 0) { |
1591 } else if (strcmp(kwd, (char *)"DOOR_ADDRESS") == 0) { |
1575 if (unit->door_address) { |
1592 if (unit->door_address) { |
1576 device_count(FALSE, unit->door_address); |
1593 device_count(FALSE, unit->door_address); |
1577 free(unit->door_address); |
1594 free(unit->door_address); |
1578 } |
1595 } |
1591 syslog(LOG_NOTICE, "Mode from %s to %s via web interface", UNITMODE[unit->mode], UNITMODE[i]); |
1608 syslog(LOG_NOTICE, "Mode from %s to %s via web interface", UNITMODE[unit->mode], UNITMODE[i]); |
1592 unit->mode = i; |
1609 unit->mode = i; |
1593 /* Allways turn everything off after a mode change */ |
1610 /* Allways turn everything off after a mode change */ |
1594 unit->PID_I_err = unit->PID_err_old = 0.0; |
1611 unit->PID_I_err = unit->PID_err_old = 0.0; |
1595 unit->heater_state = unit->cooler_state = unit->fan_state = 0; |
1612 unit->heater_state = unit->cooler_state = unit->fan_state = 0; |
|
1613 unit->heater_wait = unit->cooler_wait = unit->fan_wait = 0; |
1596 device_out(unit->heater_address, unit->heater_state); |
1614 device_out(unit->heater_address, unit->heater_state); |
1597 device_out(unit->cooler_address, unit->cooler_state); |
1615 device_out(unit->cooler_address, unit->cooler_state); |
1598 device_out(unit->fan_address, unit->fan_state); |
1616 device_out(unit->fan_address, unit->fan_state); |
1599 if (unit->mode == UNITMODE_PROFILE) { |
1617 if (unit->mode == UNITMODE_PROFILE) { |
1600 /* |
1618 /* |
1633 /* |
1651 /* |
1634 * Reset all output devices |
1652 * Reset all output devices |
1635 */ |
1653 */ |
1636 unit->PID_I_err = unit->PID_err_old = 0.0; |
1654 unit->PID_I_err = unit->PID_err_old = 0.0; |
1637 unit->heater_state = unit->cooler_state = unit->fan_state = 0; |
1655 unit->heater_state = unit->cooler_state = unit->fan_state = 0; |
|
1656 unit->heater_wait = unit->cooler_wait = unit->fan_wait = 0; |
1638 device_out(unit->heater_address, unit->heater_state); |
1657 device_out(unit->heater_address, unit->heater_state); |
1639 device_out(unit->cooler_address, unit->cooler_state); |
1658 device_out(unit->cooler_address, unit->cooler_state); |
1640 device_out(unit->fan_address, unit->fan_state); |
1659 device_out(unit->fan_address, unit->fan_state); |
1641 } |
1660 } |
1642 |
1661 |