void comp_temps() { // If the product temperature is below the threshold, stop pumping heat if (temps[0] <= desired_product_temp) { printf("COLD!\n"); // Set the outputs to the heatpump relays to open allOFF(); // Keep the fans running turnON(FANS); } else { printf("WARM!\n"); // Cycle through the heatpumps int i; for (i = 1; i < 5; ++i) { // If the pump is too hot, turn it off, start cooldown if (temps[i] >= PUMPHT) { turnOFF(heats[i-1]); } else { // Otherwise turn the pump on printf("%d:%f\n",i,temps[i]); turnON(heats[i-1]); } } } }
int main (int argc, char *argv[]) { // Bind the clean-up function to program exit atexit(dbmsg_disconnect); /////////////////////////////////////////////////////////////////////////////// if (argc < 2) { // Initialize the controller init_local(); // Determine heater posture based on current readings comp_temps(); /////////////////////////////////////////////////////////////////////////////// } else { // Initialize the web controller init_web(); // One time variables devStat state; int pin = 5; // Parse the input parameters while ((argc > 1) && (argv[1][0] == '-')) { switch (argv[1][1]) { case 'h': // Heater pin = (int)argv[1][2] - '1'; break; case 'f': // Fan pin = 4; break; case 'r': // Run state = ON; break; case 's': // Stop state = OFF; break; case 'a': // All on allON(); return 0; case 'x': // All stop allOFF(); return 0; case 't': desired_product_temp = get_desired_temp(); return 0; default: printf("Invalid parameters\n"); display_help(); return 0; } ++argv; --argc; } if (state == OFF) { turnOFF(heats[pin]); } else { turnON(heats[pin]); } } return 0; }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { //setup hardware init(); // setzen der varibalen für bus in mainconfig //create UI ui->setupUi(this); //timer for clock timer_clock = new QTimer(this); connect(timer_clock, SIGNAL(timeout()), this, SLOT(time_update())); timer_clock->start(1000);//check every second for new time //initial reading time_update(); //start main threads sThread = new steuerungThreadLicht(this); mThread = new ModelThreadLicht(this); Ueberwachung = new thread_Ueberwachung(this, sThread); sThread->start(); mThread->start(); Ueberwachung->start(); //communication ui->sThread connect(this, SIGNAL(allOff()), sThread, SLOT(allOFF())); connect(this, SIGNAL(TeenkreisLichtOn()), sThread, SLOT(teenLichtOn())); connect(this, SIGNAL(JugendLichtOn()), sThread, SLOT(jugendLichtON())); }