78 free(tmp2->heater_address); |
78 free(tmp2->heater_address); |
79 if (tmp2->cooler_address) |
79 if (tmp2->cooler_address) |
80 free(tmp2->cooler_address); |
80 free(tmp2->cooler_address); |
81 if (tmp2->fan_address) |
81 if (tmp2->fan_address) |
82 free(tmp2->fan_address); |
82 free(tmp2->fan_address); |
|
83 if (tmp2->light_address) |
|
84 free(tmp2->light_address); |
83 if (tmp2->door_address) |
85 if (tmp2->door_address) |
84 free(tmp2->door_address); |
86 free(tmp2->door_address); |
|
87 if (tmp2->psu_address) |
|
88 free(tmp2->psu_address); |
85 if (tmp2->profile) |
89 if (tmp2->profile) |
86 free(tmp2->profile); |
90 free(tmp2->profile); |
87 free(tmp2); |
91 free(tmp2); |
88 } |
92 } |
89 Config.units = NULL; |
93 Config.units = NULL; |
397 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_USAGE", "%d", tmp3->fan_usage)) < 0)) { |
401 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_USAGE", "%d", tmp3->fan_usage)) < 0)) { |
398 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
402 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
399 return 1; |
403 return 1; |
400 } |
404 } |
401 } |
405 } |
|
406 if (tmp3->light_address) { |
|
407 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LIGHT_ADDRESS", "%s", tmp3->light_address)) < 0)) { |
|
408 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
409 return 1; |
|
410 } |
|
411 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LIGHT_STATE", "%d", tmp3->light_state)) < 0)) { |
|
412 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
413 return 1; |
|
414 } |
|
415 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LIGHT_DELAY", "%d", tmp3->light_delay)) < 0)) { |
|
416 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
417 return 1; |
|
418 } |
|
419 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LIGHT_USAGE", "%d", tmp3->light_usage)) < 0)) { |
|
420 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
421 return 1; |
|
422 } |
|
423 } |
402 if (tmp3->door_address) { |
424 if (tmp3->door_address) { |
403 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_ADDRESS", "%s", tmp3->door_address)) < 0)) { |
425 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_ADDRESS", "%s", tmp3->door_address)) < 0)) { |
404 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
426 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
405 return 1; |
427 return 1; |
406 } |
428 } |
407 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_STATE", "%d", tmp3->door_state)) < 0)) { |
429 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_STATE", "%d", tmp3->door_state)) < 0)) { |
408 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
430 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
409 return 1; |
431 return 1; |
|
432 } |
|
433 } |
|
434 if (tmp3->psu_address) { |
|
435 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PSU_ADDRESS", "%s", tmp3->psu_address)) < 0)) { |
|
436 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
437 return 1; |
|
438 } |
|
439 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PSU_STATE", "%d", tmp3->psu_state)) < 0)) { |
|
440 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
441 return 1; |
410 } |
442 } |
411 } |
443 } |
412 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MODE", "%s", UNITMODE[tmp3->mode] )) < 0) { |
444 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MODE", "%s", UNITMODE[tmp3->mode] )) < 0) { |
413 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
445 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
414 return 1; |
446 return 1; |
870 |
902 |
871 unit = (units_list *)malloc(sizeof(units_list)); |
903 unit = (units_list *)malloc(sizeof(units_list)); |
872 unit->next = NULL; |
904 unit->next = NULL; |
873 unit->version = 1; |
905 unit->version = 1; |
874 unit->uuid = unit->name = unit->air_address = unit->beer_address = unit->heater_address = \ |
906 unit->uuid = unit->name = unit->air_address = unit->beer_address = unit->heater_address = \ |
875 unit->cooler_address = unit->fan_address = unit->door_address = unit->profile = NULL; |
907 unit->cooler_address = unit->fan_address = unit->door_address = \ |
|
908 unit->light_address = unit->psu_address = unit->profile = NULL; |
876 unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0; |
909 unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0; |
877 unit->air_temperature = unit->beer_temperature = unit->beer_set = unit->fridge_set = 20.0; |
910 unit->air_temperature = unit->beer_temperature = unit->beer_set = unit->fridge_set = 20.0; |
878 unit->air_state = unit->beer_state = 1; // missing |
911 unit->air_state = unit->beer_state = 1; // missing |
879 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = unit->prof_state = 0; |
912 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = \ |
|
913 unit->light_state = unit->psu_state = unit->mode = unit->prof_state = 0; |
880 unit->heater_delay = unit->cooler_delay = unit->fan_delay = 20; /* 5 minutes delay */ |
914 unit->heater_delay = unit->cooler_delay = unit->fan_delay = 20; /* 5 minutes delay */ |
881 unit->heater_wait = unit->cooler_wait = unit->fan_wait = 0; |
915 unit->light_delay = 1; /* 15 seconds delay */ |
882 unit->heater_usage = unit->cooler_usage = unit->fan_usage = 0; |
916 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; |
|
917 unit->heater_usage = unit->cooler_usage = unit->fan_usage = unit->light_usage = 0; |
883 unit->temp_set_min = 1.0; |
918 unit->temp_set_min = 1.0; |
884 unit->temp_set_max = 30.0; |
919 unit->temp_set_max = 30.0; |
885 unit->idle_rangeH = 1.0; |
920 unit->idle_rangeH = 1.0; |
886 unit->idle_rangeL = -1.0; |
921 unit->idle_rangeL = -1.0; |
887 unit->prof_started = unit->prof_paused = unit->prof_primary_done = (time_t)0; |
922 unit->prof_started = unit->prof_paused = unit->prof_primary_done = (time_t)0; |
984 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1019 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
985 if (sscanf((const char *)key, "%d", &ival) == 1) |
1020 if (sscanf((const char *)key, "%d", &ival) == 1) |
986 unit->fan_usage = ival; |
1021 unit->fan_usage = ival; |
987 xmlFree(key); |
1022 xmlFree(key); |
988 } |
1023 } |
|
1024 if ((!xmlStrcmp(cur->name, (const xmlChar *)"LIGHT_ADDRESS"))) { |
|
1025 unit->light_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1026 } |
|
1027 if ((!xmlStrcmp(cur->name, (const xmlChar *)"LIGHT_DELAY"))) { |
|
1028 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1029 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
1030 unit->light_delay = ival; |
|
1031 xmlFree(key); |
|
1032 } |
|
1033 if ((!xmlStrcmp(cur->name, (const xmlChar *)"LIGHT_USAGE"))) { |
|
1034 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1035 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
1036 unit->light_usage = ival; |
|
1037 xmlFree(key); |
|
1038 } |
989 if ((!xmlStrcmp(cur->name, (const xmlChar *)"DOOR_ADDRESS"))) { |
1039 if ((!xmlStrcmp(cur->name, (const xmlChar *)"DOOR_ADDRESS"))) { |
990 unit->door_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1040 unit->door_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1041 } |
|
1042 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PSU_ADDRESS"))) { |
|
1043 unit->psu_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
991 } |
1044 } |
992 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MODE"))) { |
1045 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MODE"))) { |
993 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
1046 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
994 for (i = 0; i < 5; i++) { |
1047 for (i = 0; i < 5; i++) { |
995 if (! xmlStrcmp(key, (const xmlChar *)UNITMODE[i])) { |
1048 if (! xmlStrcmp(key, (const xmlChar *)UNITMODE[i])) { |