Fri, 27 Nov 2015 22:56:00 +0100
Added simulator configuration.
/***************************************************************************** * Copyright (C) 2015 * * Michiel Broek <mbroek at mbse dot eu> * * This file is part of the mbsePi-apps * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2, or (at your option) any * later version. * * mbsePi-apps is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with ThermFerm; see the file COPYING. If not, write to the Free * Software Foundation, 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *****************************************************************************/ #include "brewco.h" #include "simulator.h" #ifdef USE_SIMULATOR extern int my_shutdown; extern int debug; extern sys_config Config; int SIM_hlt_value = 0; int SIM_mlt_value = 0; #ifdef HAVE_WIRINGPI_H PI_THREAD (my_simulator_loop) #else void *my_simulator_loop(void *threadid) #endif { time_t now, last = (time_t)0; int seconds = 0; // double hlt_heat_transfer, mlt_heat_transfer; // double vhc_air = 0.00121, vhc_water = 4.1796; syslog(LOG_NOTICE, "Thread my_simulator_loop started"); if (debug) fprintf(stdout, "Thread my_simulator_loop started\n"); /* * Heater and cooler have the air temperature */ Config.simulator->hlt_heater_temp = Config.simulator->mlt_heater_temp = Config.simulator->room_temperature; for (;;) { if (my_shutdown) break; now = time(NULL); if (now != last) { last = now; /* * Each second */ seconds++; /* * First calculate the heat loss for the HLT and MLT liquids. * Then decrease both liquid temperatures. */ /* * If heating, calculate the heating element temperature. * If not heating, shift towards the liquid temperature. */ /* * Shift the liquid temperature towards the heating elements temperature, * but never higher then 100 degrees celcius. */ /* * If heating, calculate temperature of the heating plate. If heating is off but * the plate is warmer then the air, calculate the cooling down temperature. * Finally, calculate the new air and plate temperature. */ // syslog(LOG_NOTICE, "air=%.3f beer=%.3f heater=%.3f cooler=%.3f", simulator->air_temperature, simulator->beer_temperature, // simulator->s_heat_temp, simulator->s_cool_temp); // if (debug) // fprintf(stdout, "sqm_room_air=%f air=%f air_heat_transfer=%f air_change=%f sqm_beer_air=%f beer=%f beer_heat_transfer=%f\n", // sqm_room_air, simulator->air_temperature, air_heat_transfer, air_change, // sqm_beer_air, simulator->beer_temperature, beer_heat_transfer); } usleep(100000); } syslog(LOG_NOTICE, "Thread my_simulator_loop stopped"); if (debug) fprintf(stdout, "Thread my_simulator_loop stopped\n"); return 0; } #endif