thermferm/thermferm.c

changeset 550
04c942cded91
parent 548
2924fe4911d9
child 554
ab9f22ab57b5
--- a/thermferm/thermferm.c	Sat Jul 21 20:40:02 2018 +0200
+++ b/thermferm/thermferm.c	Mon Jul 23 14:41:21 2018 +0200
@@ -38,6 +38,7 @@
 
 
 int			my_shutdown = FALSE;
+int			my_reboot = FALSE;
 static pid_t		pgrp, mypid;
 int			run_pause = FALSE;
 int			run_hold = FALSE;
@@ -912,7 +913,9 @@
 	/*
 	 * For debugging run in foreground.
 	 */
-	rc = server();
+	do {
+	    rc = server();
+	} while (my_reboot == TRUE);
     } else {
 	/*
 	 * Server initialization is complete. Now we can fork the 
@@ -952,7 +955,9 @@
 			    _exit(2);
 			}
 			mypid = getpid();
-			rc = server();
+			do {
+			    rc = server();
+			} while (my_reboot == TRUE);
 			break;
 			/* Not reached */
 	    default:
@@ -991,6 +996,8 @@
     unsigned char	LCDstatC, LCDstatH;
     int			LCDunit;
 
+    syslog(LOG_NOTICE, "Server process started");
+    my_shutdown = my_reboot = FALSE;
     if (lockprog((char *)"thermferm")) {
 	syslog(LOG_NOTICE, "Can't lock");
 	return 1;
@@ -1672,9 +1679,9 @@
 			if ((unit->mode == UNITMODE_BEER) && ((unit->air_temperature / 1000.0) > (unit->PID_heat->Input + 8.0))) {
 			    unit->PID_heat->OutP = 0.0;
 			}
-			if (debug)
-			    fprintf(stdout, "Heat: sp=%.2f Input=%.2f iState=%.2f Err=%.2f Out=%.2f\n",
-				unit->PID_heat->SetP, unit->PID_heat->Input, unit->PID_heat->iState, unit->PID_heat->Err, unit->PID_heat->OutP);
+//			if (debug)
+//			    fprintf(stdout, "Heat: sp=%.2f Input=%.2f iState=%.2f Err=%.2f Out=%.2f\n",
+//				unit->PID_heat->SetP, unit->PID_heat->Input, unit->PID_heat->iState, unit->PID_heat->Err, unit->PID_heat->OutP);
 			if (seconds == 60) {
 			    syslog(LOG_NOTICE, "Heat: sp=%.2f Input=%.2f iState=%.2f Err=%.2f Out=%.2f",
 				unit->PID_heat->SetP, unit->PID_heat->Input, unit->PID_heat->iState, unit->PID_heat->Err, unit->PID_heat->OutP);
@@ -1701,9 +1708,9 @@
 				}
 			    }
 			}
-		    	if (debug)
-			    fprintf(stdout, "Cool: sp=%.2f Input=%.2f iState=%.2f Err=%.2f Out=%.2f\n",
-				unit->PID_cool->SetP, unit->PID_cool->Input, unit->PID_cool->iState, unit->PID_cool->Err, unit->PID_cool->OutP);
+//		    	if (debug)
+//			    fprintf(stdout, "Cool: sp=%.2f Input=%.2f iState=%.2f Err=%.2f Out=%.2f\n",
+//				unit->PID_cool->SetP, unit->PID_cool->Input, unit->PID_cool->iState, unit->PID_cool->Err, unit->PID_cool->OutP);
 		    	if (seconds == 60) {
 			    syslog(LOG_NOTICE, "Cool: sp=%.2f Input=%.2f iState=%.2f Err=%.2f Out=%.2f",
 				unit->PID_cool->SetP, unit->PID_cool->Input, unit->PID_cool->iState, unit->PID_cool->Err, unit->PID_cool->OutP);
@@ -1797,9 +1804,9 @@
 			    device_out(unit->cooler_address, 0);
 			}
 		    }
-		    if (debug)
-			fprintf(stdout, "Final: PIDheat=%.2f PWRheat=%d  PIDcool=%.2f PWRcool=%d\n", 
-					unit->PID_heat->OutP, unit->heater_state, unit->PID_cool->OutP, unit->cooler_state);
+//		    if (debug)
+//			fprintf(stdout, "Final: PIDheat=%.2f PWRheat=%d  PIDcool=%.2f PWRcool=%d\n", 
+//					unit->PID_heat->OutP, unit->heater_state, unit->PID_cool->OutP, unit->cooler_state);
 
 		    /*
 		     * If there is a fan, and the unit door is closed, and the unit should be doing
@@ -2067,8 +2074,6 @@
 #endif
 
     syslog(LOG_NOTICE, "Out of loop");
-    if (debug)
-	fprintf(stdout, (char *)"Out of loop\n");
 
     /*
      * Give threads time to cleanup
@@ -2084,6 +2089,8 @@
     }
     wrconfig();
     ulockprog((char *)"thermferm");
+
+    syslog(LOG_NOTICE, "Server process ended");
     return 0;
 }
 

mercurial