thermferm/server.c

changeset 310
53774295e14a
parent 306
97602274eb58
child 311
f3b0e9ac9bcb
--- a/thermferm/server.c	Sun Feb 15 18:21:20 2015 +0100
+++ b/thermferm/server.c	Sun Feb 15 20:38:54 2015 +0100
@@ -1505,7 +1505,7 @@
 	unit->idle_rangeL = -1.0;
 	unit->prof_started = unit->prof_paused = unit->prof_primary_done = (time_t)0;
 	unit->prof_percent = 0;
-	unit->PID_err_old = unit->PID_I_err = 0.0;
+	unit->PID_err_old = unit->PID_I_err = unit->PID_Kp = unit->PID_Kd = unit->PID_Ki = 0.0;
 
 	/*
 	 * Block main process
@@ -1615,6 +1615,9 @@
 		srv_send((char *)"TEMP_SET_MAX,%.1f", unit->temp_set_max);
 		srv_send((char *)"IDLE_RANGE_L,%.1f", unit->idle_rangeL);
 		srv_send((char *)"IDLE_RANGE_H,%.1f", unit->idle_rangeH);
+		srv_send((char *)"PID_KP,%.2f", unit->PID_Kp);
+		srv_send((char *)"PID_KD,%.2f", unit->PID_Kd);
+		srv_send((char *)"PID_KI,%.2f", unit->PID_Ki);
 		srv_send((char *)".");
 		return 1;
 	    }
@@ -1875,11 +1878,32 @@
 
 			    } else if (val && (strcmp(kwd, (char *)"BEER_SET") == 0)) {
 				if ((sscanf(val, "%f", &fval) == 1) && (fval >= unit->temp_set_min) && (fval <= unit->temp_set_max)) {
-				    if (unit->fridge_set != fval)
+				    if (unit->beer_set != fval)
 				    	syslog(LOG_NOTICE, "Fermenter unit %s beer temperature %.1f to %.1f", unit->uuid, unit->beer_set, fval);
 				    unit->beer_set = fval;
 				}
 
+			    } else if (val && (strcmp(kwd, (char *)"PID_KP") == 0)) {
+				if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) {
+				    if (unit->PID_Kp != fval)
+					syslog(LOG_NOTICE, "Fermenter unit %s PID Kp %.2f to %.2f", unit->uuid, unit->PID_Kp, fval);
+				    unit->PID_Kp = fval;
+				}
+
+			    } else if (val && (strcmp(kwd, (char *)"PID_KD") == 0)) {
+				if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) {
+				    if (unit->PID_Kd != fval)
+					syslog(LOG_NOTICE, "Fermenter unit %s PID Kd %.2f to %.2f", unit->uuid, unit->PID_Kd, fval);
+				    unit->PID_Kd = fval;
+				}
+	
+			    } else if (val && (strcmp(kwd, (char *)"PID_KI") == 0)) {
+				if ((sscanf(val, "%f", &fval) == 1) && (fval >= 0.0)) {
+				    if (unit->PID_Ki != fval)
+					syslog(LOG_NOTICE, "Fermenter unit %s PID Ki %.2f to %.2f", unit->uuid, unit->PID_Ki, fval);
+				    unit->PID_Ki = fval;
+				}
+
 			    } else if (strcmp(kwd, (char *)"PROFILE") == 0) {
 				if (unit->prof_state == PROFILE_OFF) {
 				    /*

mercurial