720 fprintf(stdout, "sp=%.2f pv=%.2f err_old=%.2f err=%.2f P_err=%.2f I_err=%.2f D_err=%.2f Out=%.2f\n", |
720 fprintf(stdout, "sp=%.2f pv=%.2f err_old=%.2f err=%.2f P_err=%.2f I_err=%.2f D_err=%.2f Out=%.2f\n", |
721 sp, pv, unit->PID_err_old, err, P_err, unit->PID_I_err, D_err, Out); |
721 sp, pv, unit->PID_err_old, err, P_err, unit->PID_I_err, D_err, Out); |
722 syslog(LOG_NOTICE, "sp=%.2f pv=%.2f err_old=%.2f err=%.2f P_err=%.2f I_err=%.2f D_err=%.2f Out=%.2f", |
722 syslog(LOG_NOTICE, "sp=%.2f pv=%.2f err_old=%.2f err=%.2f P_err=%.2f I_err=%.2f D_err=%.2f Out=%.2f", |
723 sp, pv, unit->PID_err_old, err, P_err, unit->PID_I_err, D_err, Out); |
723 sp, pv, unit->PID_err_old, err, P_err, unit->PID_I_err, D_err, Out); |
724 if (unit->heater_address) { |
724 if (unit->heater_address) { |
725 if (Out >= 2) |
725 if (Out >= 2) { |
|
726 if (! unit->heater_state) |
|
727 syslog(LOG_NOTICE, "Heater Off => On"); |
726 unit->heater_state = 100; |
728 unit->heater_state = 100; |
727 else |
729 } else { |
|
730 if (unit->heater_state) |
|
731 syslog(LOG_NOTICE, "Heater On => Off"); |
728 unit->heater_state = 0; |
732 unit->heater_state = 0; |
|
733 } |
729 device_out(unit->heater_address, unit->heater_state); |
734 device_out(unit->heater_address, unit->heater_state); |
730 } |
735 } |
731 if (unit->cooler_address) { |
736 if (unit->cooler_address) { |
732 if (Out <= -2) |
737 if (Out <= -2) { |
|
738 if (! unit->cooler_state) |
|
739 syslog(LOG_NOTICE, "Cooler Off => On"); |
733 unit->cooler_state = 100; |
740 unit->cooler_state = 100; |
734 else |
741 } else { |
|
742 if (unit->cooler_state) |
|
743 syslog(LOG_NOTICE, "Cooler On => Off"); |
735 unit->cooler_state = 0; |
744 unit->cooler_state = 0; |
|
745 } |
736 device_out(unit->cooler_address, unit->cooler_state); |
746 device_out(unit->cooler_address, unit->cooler_state); |
737 } |
747 } |
738 if (unit->heater_address && unit->cooler_address && unit->fan_address) { |
748 if (unit->heater_address && unit->cooler_address && unit->fan_address) { |
739 /* |
749 /* |
740 * If the temperature difference between air and beer is more then |
750 * If the temperature difference between air and beer is more then |
743 * most cases will be some sort of radiating heat device. |
753 * most cases will be some sort of radiating heat device. |
744 * For cooling ??? dunno yet. |
754 * For cooling ??? dunno yet. |
745 */ |
755 */ |
746 if (((unit->air_temperature - unit->beer_temperature) > 1000) || |
756 if (((unit->air_temperature - unit->beer_temperature) > 1000) || |
747 ((unit->air_temperature - unit->beer_temperature) < -1000)) { |
757 ((unit->air_temperature - unit->beer_temperature) < -1000)) { |
|
758 if (! unit->fan_state) |
|
759 syslog(LOG_NOTICE, "Fan Off => On"); |
748 unit->fan_state = 100; |
760 unit->fan_state = 100; |
749 } else { |
761 } else { |
|
762 if (unit->fan_state) |
|
763 syslog(LOG_NOTICE, "Fan On => Off"); |
750 unit->fan_state = 0; |
764 unit->fan_state = 0; |
751 } |
765 } |
752 device_out(unit->fan_address, unit->fan_state); |
766 device_out(unit->fan_address, unit->fan_state); |
753 } |
767 } |
754 } else { |
768 } else { |