thermferm/rdconfig.c

changeset 716
5c30c8ef83a8
parent 714
24749c296a50
--- a/thermferm/rdconfig.c	Wed May 01 14:38:37 2024 +0200
+++ b/thermferm/rdconfig.c	Thu May 02 15:49:16 2024 +0200
@@ -174,6 +174,10 @@
 	    free(simulator->fan_address);
 	if (simulator->light_address)
 	    free(simulator->light_address);
+	if (simulator->door_address)
+	    free(simulator->door_address);
+	if (simulator->psu_address)
+	    free(simulator->psu_address);
 	free(simulator);
     }
     Config.simulators = NULL;
@@ -487,6 +491,12 @@
 	    xmlTextWriterWriteFormatElement(writer, BAD_CAST "LIGHT_ADDRESS", "%s", simulator->light_address);
 	    xmlTextWriterWriteFormatElement(writer, BAD_CAST "LIGHT_PRESENT", "%s", DEVPRESENT[simulator->light_present]);
 	    xmlTextWriterWriteFormatElement(writer, BAD_CAST "LIGHT_POWER", "%d", simulator->light_power);
+	    xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_ADDRESS", "%s", simulator->door_address);
+            xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_PRESENT", "%s", DEVPRESENT[simulator->door_present]);
+            xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_VALUE", "%d", simulator->door_value);
+	    xmlTextWriterWriteFormatElement(writer, BAD_CAST "PSU_ADDRESS", "%s", simulator->psu_address);
+            xmlTextWriterWriteFormatElement(writer, BAD_CAST "PSU_PRESENT", "%s", DEVPRESENT[simulator->psu_present]);
+            xmlTextWriterWriteFormatElement(writer, BAD_CAST "PSU_VALUE", "%d", simulator->psu_value);
 	    xmlTextWriterWriteFormatElement(writer, BAD_CAST "FRIGO_ISOLATION", "%.3f", simulator->frigo_isolation);
 	    xmlTextWriterWriteFormatElement(writer, BAD_CAST "TIMESTAMP", "%ld", (long)simulator->timestamp);
 	    xmlTextWriterWriteFormatElement(writer, BAD_CAST "S_YEAST_HEAT", "%f", simulator->s_yeast_heat);
@@ -1379,6 +1389,7 @@
     simulator->uuid = simulator->name = NULL;
     simulator->room_tempaddress = simulator->room_humaddress = simulator->air_address = simulator->beer_address = simulator->beer_address2 = NULL;
     simulator->chiller_address = simulator->cooler_address = simulator->heater_address = simulator->fan_address = simulator->light_address = NULL;
+    simulator->door_address = simulator->psu_address = NULL;
     simulator->simno = simulator->volume_air = simulator->volume_beer = 0;
     simulator->room_temperature = simulator->air_temperature = simulator->beer_temperature = simulator->s_cool_temp = simulator->s_heat_temp = 20.0;
     simulator->chiller_temperature = 1.5;
@@ -1622,6 +1633,44 @@
                 simulator->light_power = ival;
             xmlFree(key);
         }
+        if ((!xmlStrcmp(cur->name, (const xmlChar *)"DOOR_ADDRESS"))) {
+            simulator->door_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+        }
+        if ((!xmlStrcmp(cur->name, (const xmlChar *)"DOOR_PRESENT"))) {
+            key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+            for (i = 0; i < 4; i++) {
+                if (! xmlStrcmp(key, (const xmlChar *)DEVPRESENT[i])) {
+                    simulator->door_present = i;
+                    break;
+                }
+            }
+            xmlFree(key);
+        }
+        if ((!xmlStrcmp(cur->name, (const xmlChar *)"DOOR_VALUE"))) {
+            key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+            if (sscanf((const char *)key, "%d", &ival) == 1)
+                simulator->door_value = ival;
+            xmlFree(key);
+        }
+        if ((!xmlStrcmp(cur->name, (const xmlChar *)"PSU_ADDRESS"))) {
+            simulator->psu_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+        }
+        if ((!xmlStrcmp(cur->name, (const xmlChar *)"PSU_PRESENT"))) {
+            key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+            for (i = 0; i < 4; i++) {
+                if (! xmlStrcmp(key, (const xmlChar *)DEVPRESENT[i])) {
+                    simulator->psu_present = i;
+                    break;
+                }
+            }
+            xmlFree(key);
+        }
+        if ((!xmlStrcmp(cur->name, (const xmlChar *)"PSU_VALUE"))) {
+            key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+            if (sscanf((const char *)key, "%d", &ival) == 1)
+                simulator->psu_value = ival;
+            xmlFree(key);
+        }
 	if ((!xmlStrcmp(cur->name, (const xmlChar *)"FRIGO_ISOLATION"))) {
 	    key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
 	    if (sscanf((const char *)key, "%f", &fval) == 1)

mercurial