thermferm/rdconfig.c

changeset 175
b73490398368
parent 174
244de612c572
child 176
8c7d87a2c094
--- a/thermferm/rdconfig.c	Sat Aug 02 22:33:15 2014 +0200
+++ b/thermferm/rdconfig.c	Sun Aug 03 22:49:33 2014 +0200
@@ -69,10 +69,14 @@
 	    free(tmp2->air_address);
 	if (tmp2->beer_address)
 	    free(tmp2->beer_address);
-	if (tmp2->io1_address)
-	    free(tmp2->io1_address);
-	if (tmp2->io2_address)
-	    free(tmp2->io2_address);
+	if (tmp2->heater_address)
+	    free(tmp2->heater_address);
+	if (tmp2->cooler_address)
+	    free(tmp2->cooler_address);
+	if (tmp2->fan_address)
+	    free(tmp2->fan_address);
+	if (tmp2->door_address)
+	    free(tmp2->door_address);
 	if (tmp2->profile)
 	    free(tmp2->profile);
 	free(tmp2);
@@ -308,25 +312,45 @@
 		    return 1;
 		}
 	    }
-	    if (tmp3->io1_address && ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IO1_ADDRESS", "%s", tmp3->io1_address)) < 0)) {
-		syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
-		return 1;
+	    if (tmp3->heater_address) {
+		if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_ADDRESS", "%s", tmp3->heater_address)) < 0)) {
+		    syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+		    return 1;
+		}
+		if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_STATE", "%d", tmp3->heater_state)) < 0)) {
+		    syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+		    return 1;
+		}
 	    }
-	    if (tmp3->io2_address && ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IO2_ADDRESS", "%s", tmp3->io2_address)) < 0)) {
-		syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
-		return 1;
+	    if (tmp3->cooler_address) {
+		if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_ADDRESS", "%s", tmp3->cooler_address)) < 0)) {
+		    syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+		    return 1;
+		}
+		if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_STATE", "%d", tmp3->cooler_state)) < 0)) {
+		    syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+		    return 1;                                   
+		}
 	    }
-	    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER", "%s", tmp3->heater_available ? "YES":"NO")) < 0) {
-		syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
-		return 1;                           
+	    if (tmp3->fan_address) {
+		if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_ADDRESS", "%s", tmp3->fan_address)) < 0)) {
+		    syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+		    return 1;
+		}
+		if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_STATE", "%d", tmp3->fan_state)) < 0)) {
+		    syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+		    return 1;                                   
+		}
 	    }
-	    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER", "%s", tmp3->cooler_available? "YES":"NO")) < 0) {
-		syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+	    if (tmp3->door_address) {
+		if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_ADDRESS", "%s", tmp3->door_address)) < 0)) {
+		    syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
 		return 1;
-	    }
-	    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN", "%s", tmp3->fan_available ? "YES":"NO")) < 0) {
-		syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
+		}
+		if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_STATE", "%d", tmp3->door_state)) < 0)) {
+		    syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
 		return 1;
+		}
 	    }
 	    if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MODE", "%s", UNITMODE[tmp3->mode] )) < 0) {
 		syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
@@ -645,9 +669,9 @@
     unit = (units_list *)malloc(sizeof(units_list));
     unit->next = NULL;
     unit->version = 1;
-    unit->uuid = unit->name = unit->air_address = unit->beer_address = unit->io1_address = unit->io2_address = unit->profile = NULL;
+    unit->uuid = unit->name = unit->air_address = unit->beer_address = unit->heater_address = \
+		 unit->cooler_address = unit->fan_address = unit->door_address = unit->profile = NULL;
     unit->volume = 0.0;
-    unit->heater_available = unit->cooler_available = unit->fan_available = FALSE;
     unit->air_temperature = unit->beer_temperature = unit->beer_set = unit->fridge_set = 20.0;
     unit->air_state = unit->beer_state = 1; // missing
     unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = unit->prof_state = 0;
@@ -710,29 +734,17 @@
 		unit->beer_temperature = ival;
 	    xmlFree(key);
 	}
-	if ((!xmlStrcmp(cur->name, (const xmlChar *)"IO1_ADDRESS"))) {
-	    unit->io1_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
-	}
-	if ((!xmlStrcmp(cur->name, (const xmlChar *)"IO2_ADDRESS"))) {
-	    unit->io2_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"HEATER_ADDRESS"))) {
+	    unit->heater_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
 	}
-	if ((!xmlStrcmp(cur->name, (const xmlChar *)"HEATER"))) {
-	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
-	    if (! xmlStrcmp(key, (const xmlChar *)"TRUE"))
-		unit->heater_available = TRUE;
-	    xmlFree(key);
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"COOLER_ADDRESS"))) {
+	    unit->cooler_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
 	}
-	if ((!xmlStrcmp(cur->name, (const xmlChar *)"COOLER"))) {
-	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
-	    if (! xmlStrcmp(key, (const xmlChar *)"TRUE"))
-		unit->cooler_available = TRUE;
-	    xmlFree(key);
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"FAN_ADDRESS"))) {
+	    unit->fan_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
 	}
-	if ((!xmlStrcmp(cur->name, (const xmlChar *)"FAN"))) {
-	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
-	    if (! xmlStrcmp(key, (const xmlChar *)"TRUE"))
-		unit->fan_available = TRUE;
-	    xmlFree(key);
+	if ((!xmlStrcmp(cur->name, (const xmlChar *)"DOOR_ADDRESS"))) {
+	    unit->door_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
 	}
 	if ((!xmlStrcmp(cur->name, (const xmlChar *)"MODE"))) {
 	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);

mercurial