thermferm/rdconfig.c

changeset 310
53774295e14a
parent 306
97602274eb58
child 312
7b0f819a3805
--- a/thermferm/rdconfig.c	Sun Feb 15 18:21:20 2015 +0100
+++ b/thermferm/rdconfig.c	Sun Feb 15 20:38:54 2015 +0100
@@ -469,6 +469,18 @@
 		syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
 		return 1;
 	    }
+	    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_KP", "%.2f", tmp3->PID_Kp)) < 0) {
+		syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+		return 1;
+	    }
+	    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_KD", "%.2f", tmp3->PID_Kd)) < 0) {
+		syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+		return 1;
+	    }
+	    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_KI", "%.2f", tmp3->PID_Ki)) < 0) {
+		syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+		return 1;
+	    }
 	    if (tmp3->profile) {
 		if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROFILE", "%s", tmp3->profile)) < 0) {
 		    syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
@@ -921,7 +933,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;
 
     cur = cur->xmlChildrenNode;
     while (cur != NULL) {
@@ -1088,6 +1100,24 @@
 		unit->idle_rangeH = val;
 	    xmlFree(key);
 	}
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_KP"))) {
+	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+	    if (sscanf((const char *)key, "%f", &val) == 1)
+		unit->PID_Kp = val;
+	    xmlFree(key);
+	}
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_KD"))) {
+	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+	    if (sscanf((const char *)key, "%f", &val) == 1)
+		unit->PID_Kd = val;
+	    xmlFree(key);
+	}
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_KI"))) {
+	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+	    if (sscanf((const char *)key, "%f", &val) == 1)
+		unit->PID_Ki = val;
+	    xmlFree(key);
+	}
 	if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROFILE"))) {
 	    unit->profile = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
 	}

mercurial