# HG changeset patch # User Michiel Broek # Date 1449951646 -3600 # Node ID 045db83dd013c238917e4c0c67150b74cd87b597 # Parent f84501d8dd87379abfefe77906f6b4715f8b0324 Build a simulated immersion chiller. It will start on SIGUSR1 signal and stop on a SIGUSR2 signal. Hardcoded is te coolwater temperature at 14 degrees celcius. diff -r f84501d8dd87 -r 045db83dd013 brewco/brewco.c --- a/brewco/brewco.c Sat Dec 12 19:31:35 2015 +0100 +++ b/brewco/brewco.c Sat Dec 12 21:20:46 2015 +0100 @@ -42,6 +42,10 @@ extern int lcdHandle; extern int slcdHandle; extern int sock; +#ifdef USE_SIMULATOR +extern int SIM_cooler; +#endif + #ifndef HAVE_WIRINGPI_H pthread_t threads[5]; @@ -89,6 +93,14 @@ void die(int onsig) { switch (onsig) { +#ifdef USE_SIMULATOR + case SIGUSR1: syslog(LOG_NOTICE, "Got SIGUSR1, start cooler"); + SIM_cooler = TRUE; + return; + case SIGUSR2: syslog(LOG_NOTICE, "Got SIGUSR2, stop cooler"); + SIM_cooler = FALSE; + return; +#endif case SIGHUP: syslog(LOG_NOTICE, "Got SIGHUP, shutting down"); break; case SIGINT: syslog(LOG_NOTICE, "Keyboard interrupt, shutting down"); diff -r f84501d8dd87 -r 045db83dd013 brewco/simulator.c --- a/brewco/simulator.c Sat Dec 12 19:31:35 2015 +0100 +++ b/brewco/simulator.c Sat Dec 12 21:20:46 2015 +0100 @@ -31,6 +31,7 @@ int SIM_hlt_value = 0; int SIM_mlt_value = 0; +int SIM_cooler = FALSE; #ifdef HAVE_WIRINGPI_H @@ -80,13 +81,20 @@ if (SIM_hlt_value) { Config.simulator->hlt_heater_temp += (250 - Config.simulator->hlt_heater_temp) / 2000; } else { - Config.simulator->hlt_heater_temp -= (Config.simulator->hlt_heater_temp - Config.simulator->hlt_temperature) / 1000; + Config.simulator->hlt_heater_temp -= (Config.simulator->hlt_heater_temp - Config.simulator->hlt_temperature) / 500; } Config.simulator->mlt_heater_state = SIM_mlt_value; if (SIM_mlt_value) { Config.simulator->mlt_heater_temp += (250 - Config.simulator->mlt_heater_temp) / 2000; } else { - Config.simulator->mlt_heater_temp -= (Config.simulator->mlt_heater_temp - Config.simulator->mlt_temperature) / 1000; + Config.simulator->mlt_heater_temp -= (Config.simulator->mlt_heater_temp - Config.simulator->mlt_temperature) / 500; + } + + /* + * If cooling, bring down the MLT temperature. Assume 14 degrees coolwater. + */ + if (SIM_cooler) { + Config.simulator->mlt_temperature -= (Config.simulator->mlt_temperature - 14) / (250 * Config.simulator->hlt_heater_volume); } /* @@ -108,10 +116,10 @@ * Each second */ if (debug) - fprintf(stdout, "HLT temp=%f plate=%f val=%d MLT temp=%f plate=%f val=%d Room %.1f loops=%d\n", + fprintf(stdout, "HLT temp=%f plate=%f val=%d MLT temp=%f plate=%f val=%d Room %.1f loops=%d cool=%s\n", Config.simulator->hlt_temperature, Config.simulator->hlt_heater_temp, Config.simulator->hlt_heater_state, Config.simulator->mlt_temperature, Config.simulator->mlt_heater_temp, Config.simulator->mlt_heater_state, - Config.simulator->room_temperature, loops); + Config.simulator->room_temperature, loops, SIM_cooler ? "Yes":"No"); loops = 0; } usleep(50000);