59 for (unit = Config.units; unit; unit = unit->next) { |
59 for (unit = Config.units; unit; unit = unit->next) { |
60 if (unit->uuid) |
60 if (unit->uuid) |
61 free(unit->uuid); |
61 free(unit->uuid); |
62 if (unit->name) |
62 if (unit->name) |
63 free(unit->name); |
63 free(unit->name); |
64 if (unit->hlt_sensor) |
64 if (unit->hlt_sensor.uuid) |
65 free(unit->hlt_sensor); |
65 free(unit->hlt_sensor.uuid); |
66 if (unit->mlt_sensor) |
66 if (unit->mlt_sensor.uuid) |
67 free(unit->mlt_sensor); |
67 free(unit->mlt_sensor.uuid); |
68 if (unit->hlt_heater) |
68 if (unit->hlt_heater) |
69 free(unit->hlt_heater); |
69 free(unit->hlt_heater); |
70 if (unit->mlt_heater) |
70 if (unit->mlt_heater) |
71 free(unit->mlt_heater); |
71 free(unit->mlt_heater); |
72 if (unit->mlt_pump) |
72 if (unit->mlt_pump) |
271 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ACTIVE", "%d", unit->active)) < 0)) { |
271 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ACTIVE", "%d", unit->active)) < 0)) { |
272 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
272 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
273 return 1; |
273 return 1; |
274 } |
274 } |
275 |
275 |
276 if (unit->hlt_sensor) { |
276 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HLT_SENSOR_UUID", "%s", unit->hlt_sensor.uuid)) < 0)) { |
277 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HLT_SENSOR_UUID", "%s", unit->hlt_sensor->uuid)) < 0)) { |
277 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
278 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
278 return 1; |
279 return 1; |
279 } |
280 } |
280 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HLT_SENSOR_STATE", "%d", unit->hlt_sensor.state)) < 0)) { |
281 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HLT_SENSOR_STATE", "%d", unit->hlt_sensor->state)) < 0)) { |
281 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
282 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
282 return 1; |
283 return 1; |
283 } |
284 } |
284 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HLT_SENSOR_VALUE", "%d", unit->hlt_sensor.value)) < 0)) { |
285 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HLT_SENSOR_VALUE", "%d", unit->hlt_sensor->value)) < 0)) { |
285 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
286 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
286 return 1; |
287 return 1; |
|
288 } |
|
289 } |
287 } |
290 |
288 |
291 if (unit->hlt_heater) { |
289 if (unit->hlt_heater) { |
292 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HLT_HEATER_UUID", "%s", unit->hlt_heater->uuid)) < 0)) { |
290 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HLT_HEATER_UUID", "%s", unit->hlt_heater->uuid)) < 0)) { |
293 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
291 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
306 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HLT_HEATER_MLTFIRST", "%d", unit->hlt_heater_mltfirst)) < 0)) { |
304 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HLT_HEATER_MLTFIRST", "%d", unit->hlt_heater_mltfirst)) < 0)) { |
307 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
305 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
308 return 1; |
306 return 1; |
309 } |
307 } |
310 |
308 |
311 if (unit->mlt_sensor) { |
309 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MLT_SENSOR_UUID", "%s", unit->mlt_sensor.uuid)) < 0)) { |
312 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MLT_SENSOR_UUID", "%s", unit->mlt_sensor->uuid)) < 0)) { |
310 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
313 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
311 return 1; |
314 return 1; |
312 } |
315 } |
313 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MLT_SENSOR_STATE", "%d", unit->mlt_sensor.state)) < 0)) { |
316 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MLT_SENSOR_STATE", "%d", unit->mlt_sensor->state)) < 0)) { |
314 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
317 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
315 return 1; |
318 return 1; |
316 } |
319 } |
317 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MLT_SENSOR_VALUE", "%d", unit->mlt_sensor.value)) < 0)) { |
320 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MLT_SENSOR_VALUE", "%d", unit->mlt_sensor->value)) < 0)) { |
318 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
321 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
319 return 1; |
322 return 1; |
|
323 } |
|
324 } |
320 } |
325 |
321 |
326 if (unit->mlt_heater) { |
322 if (unit->mlt_heater) { |
327 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MLT_HEATER_UUID", "%s", unit->mlt_heater->uuid)) < 0)) { |
323 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MLT_HEATER_UUID", "%s", unit->mlt_heater->uuid)) < 0)) { |
328 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
324 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
726 unit->next = NULL; |
722 unit->next = NULL; |
727 unit->version = 1; |
723 unit->version = 1; |
728 unit->uuid = unit->name = NULL; |
724 unit->uuid = unit->name = NULL; |
729 unit->number = 0; |
725 unit->number = 0; |
730 unit->active = 0; |
726 unit->active = 0; |
731 unit->hlt_sensor = unit->mlt_sensor = NULL; |
727 unit->hlt_sensor.uuid = xstrcpy((char *)"00000000-0000-0000-0000-000000000000"); |
|
728 unit->hlt_sensor.state = 0; |
|
729 unit->hlt_sensor.value = 0; |
|
730 unit->mlt_sensor.uuid = xstrcpy((char *)"00000000-0000-0000-0000-000000000000"); |
|
731 unit->mlt_sensor.state = 0; |
|
732 unit->mlt_sensor.value = 0; |
732 unit->hlt_heater = unit->mlt_heater = unit->mlt_pump = NULL; |
733 unit->hlt_heater = unit->mlt_heater = unit->mlt_pump = NULL; |
733 unit->hlt_heater_mltfirst = 0; |
734 unit->hlt_heater_mltfirst = 0; |
734 unit->pump_cycle = 7; |
735 unit->pump_cycle = 7; |
735 unit->pump_rest = 2; |
736 unit->pump_rest = 2; |
736 unit->pump_premash = 1; |
737 unit->pump_premash = 1; |
777 unit->active = ival; |
778 unit->active = ival; |
778 xmlFree(key); |
779 xmlFree(key); |
779 } |
780 } |
780 |
781 |
781 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HLT_SENSOR_UUID"))) { |
782 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HLT_SENSOR_UUID"))) { |
782 if (unit->hlt_sensor == NULL) { |
783 unit->hlt_sensor.uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
783 unit->hlt_sensor = (sensor_var *)malloc(sizeof(sensor_var)); |
|
784 unit->hlt_sensor->uuid[0] = '\0'; |
|
785 unit->hlt_sensor->state = 1; // missing |
|
786 unit->hlt_sensor->value = 0; |
|
787 } |
|
788 snprintf(unit->hlt_sensor->uuid, 36, "%s", xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)); |
|
789 } |
784 } |
790 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HLT_SENSOR_STATE"))) { |
785 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HLT_SENSOR_STATE"))) { |
791 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
786 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
792 if (sscanf((const char *)key, "%d", &ival) == 1) |
787 if (sscanf((const char *)key, "%d", &ival) == 1) |
793 unit->hlt_sensor->state = ival; |
788 unit->hlt_sensor.state = ival; |
794 xmlFree(key); |
789 xmlFree(key); |
795 } |
790 } |
796 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HLT_SENSOR_VALUE"))) { |
791 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HLT_SENSOR_VALUE"))) { |
797 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
792 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
798 if (sscanf((const char *)key, "%d", &ival) == 1) |
793 if (sscanf((const char *)key, "%d", &ival) == 1) |
799 unit->hlt_sensor->value = ival; |
794 unit->hlt_sensor.value = ival; |
800 xmlFree(key); |
795 xmlFree(key); |
801 } |
796 } |
802 |
797 |
803 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HLT_HEATER_UUID"))) { |
798 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HLT_HEATER_UUID"))) { |
804 if (unit->hlt_heater == NULL) { |
799 if (unit->hlt_heater == NULL) { |
828 unit->hlt_heater_mltfirst = ival; |
823 unit->hlt_heater_mltfirst = ival; |
829 xmlFree(key); |
824 xmlFree(key); |
830 } |
825 } |
831 |
826 |
832 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_SENSOR_UUID"))) { |
827 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_SENSOR_UUID"))) { |
833 if (unit->mlt_sensor == NULL) { |
828 unit->mlt_sensor.uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
834 unit->mlt_sensor = (sensor_var *)malloc(sizeof(sensor_var)); |
|
835 unit->mlt_sensor->uuid[0] = '\0'; |
|
836 unit->mlt_sensor->state = 1; // missing |
|
837 unit->mlt_sensor->value = 0; |
|
838 } |
|
839 snprintf(unit->mlt_sensor->uuid, 36, "%s", xmlNodeListGetString(doc, cur->xmlChildrenNode, 1)); |
|
840 } |
829 } |
841 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_SENSOR_STATE"))) { |
830 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_SENSOR_STATE"))) { |
842 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
831 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
843 if (sscanf((const char *)key, "%d", &ival) == 1) |
832 if (sscanf((const char *)key, "%d", &ival) == 1) |
844 unit->mlt_sensor->state = ival; |
833 unit->mlt_sensor.state = ival; |
845 xmlFree(key); |
834 xmlFree(key); |
846 } |
835 } |
847 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_SENSOR_VALUE"))) { |
836 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_SENSOR_VALUE"))) { |
848 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
837 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
849 if (sscanf((const char *)key, "%d", &ival) == 1) |
838 if (sscanf((const char *)key, "%d", &ival) == 1) |
850 unit->mlt_sensor->value = ival; |
839 unit->mlt_sensor.value = ival; |
851 xmlFree(key); |
840 xmlFree(key); |
852 } |
841 } |
853 |
842 |
854 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_HEATER_UUID"))) { |
843 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_HEATER_UUID"))) { |
855 if (unit->mlt_heater == NULL) { |
844 if (unit->mlt_heater == NULL) { |