thermferm/rdconfig.c

changeset 397
00ca08f5a6f8
parent 388
05a55609cd9a
child 418
0bfe08c7ba6e
--- a/thermferm/rdconfig.c	Tue Sep 15 17:29:15 2015 +0200
+++ b/thermferm/rdconfig.c	Wed Sep 16 22:05:05 2015 +0200
@@ -640,7 +640,15 @@
 		syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
 		return 1;
 	    }
-	    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INITTEMP", "%.1f", tmp4->inittemp)) < 0) {
+	    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INITTEMP_LO", "%.1f", tmp4->inittemp_lo)) < 0) {
+		syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+		return 1;
+	    }
+	    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INITTEMP_HI", "%.1f", tmp4->inittemp_hi)) < 0) {
+		syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+		return 1;
+	    }
+	    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FRIDGE_MODE", "%d", tmp4->fridge_mode)) < 0) {
 		syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
 		return 1;
 	    }
@@ -666,10 +674,18 @@
 			syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
 			return 1;
 		    }
-		    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TARGET", "%.1f", tmp5->target)) < 0) {
+		    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TARGET_LO", "%.1f", tmp5->target_lo)) < 0) {
 		        syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
 			return 1;
 		    }
+		    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TARGET_HI", "%.1f", tmp5->target_hi)) < 0) {
+			syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+			return 1;
+		    }
+		    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FRIDGE_MODE", "%d", tmp5->fridge_mode)) < 0) {
+			syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+			return 1;
+		    }
 		    if ((rc = xmlTextWriterEndElement(writer)) < 0) {
 			syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement");
 			return 1;
@@ -1436,8 +1452,8 @@
     step = (prof_step *)malloc(sizeof(prof_step));
     step->next = NULL;
     step->version = 1;
-    step->steptime = step->resttime = 0;
-    step->target = 20.0;
+    step->steptime = step->resttime = step->fridge_mode = 0;
+    step->target_lo = step->target_hi = 20.0;
 
     cur = cur->xmlChildrenNode;
     while (cur != NULL) {
@@ -1462,10 +1478,30 @@
 		step->steptime = ival;
 	    xmlFree(key);
 	}
-	if ((!xmlStrcmp(cur->name, (const xmlChar *)"TARGET"))) {
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"TARGET"))) {	/* Upgrade from single values */
+	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+	    if (sscanf((const char *)key, "%f", &val) == 1) {
+		step->target_lo = val - 0.2;
+		step->target_hi = val + 0.2;
+	    }
+	    xmlFree(key);
+	}
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"TARGET_LO"))) {
 	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
 	    if (sscanf((const char *)key, "%f", &val) == 1)
-		step->target = val;
+		step->target_lo = val;
+	    xmlFree(key);
+	}
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"TARGET_HI"))) {
+	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+	    if (sscanf((const char *)key, "%f", &val) == 1)
+		step->target_hi = val;
+	    xmlFree(key);   
+	}
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"FRIDGE_MODE"))) {
+	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+	    if (sscanf((const char *)key, "%d", &ival) == 1)
+		step->fridge_mode = ival;
 	    xmlFree(key);
 	}
 	cur = cur->next;
@@ -1511,8 +1547,8 @@
     profile->next = NULL;
     profile->version = 1;
     profile->uuid = profile->name = NULL;
-    profile->busy = 0;
-    profile->inittemp = 20.0;
+    profile->busy = profile->fridge_mode = 0;
+    profile->inittemp_lo = profile->inittemp_hi = 20.0;
     profile->steps = NULL;
 
     cur = cur->xmlChildrenNode;
@@ -1538,10 +1574,30 @@
 		profile->busy = ival;
 	    xmlFree(key);
 	}
-	if ((!xmlStrcmp(cur->name, (const xmlChar *)"INITTEMP"))) {
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"INITTEMP"))) {	/* Upgrade from single temp */
+	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+	    if (sscanf((const char *)key, "%f", &fval) == 1) {
+		profile->inittemp_lo = fval - 0.2;
+		profile->inittemp_hi = fval + 0.2;
+	    }
+	    xmlFree(key);
+	}
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"INITTEMP_LO"))) {
 	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
 	    if (sscanf((const char *)key, "%f", &fval) == 1)
-		profile->inittemp = fval;
+		profile->inittemp_lo = fval;
+	    xmlFree(key);
+	}
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"INITTEMP_HI"))) {
+	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+	    if (sscanf((const char *)key, "%f", &fval) == 1)
+		profile->inittemp_hi = fval;
+	    xmlFree(key);
+	}
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"FRIDGE_MODE"))) {
+	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+	    if (sscanf((const char *)key, "%d", &ival) == 1)
+		profile->fridge_mode = ival;
 	    xmlFree(key);
 	}
 	if ((!xmlStrcmp(cur->name, (const xmlChar *)"STEPS"))) {

mercurial