thermferm/rdconfig.c

changeset 518
fd36bedab944
parent 513
a2732027afb3
child 534
92b546d4a839
equal deleted inserted replaced
517:5fd12d9f3f84 518:fd36bedab944
79 free(tmp2->name); 79 free(tmp2->name);
80 if (tmp2->air_address) 80 if (tmp2->air_address)
81 free(tmp2->air_address); 81 free(tmp2->air_address);
82 if (tmp2->beer_address) 82 if (tmp2->beer_address)
83 free(tmp2->beer_address); 83 free(tmp2->beer_address);
84 if (tmp2->chiller_address)
85 free(tmp2->chiller_address);
84 if (tmp2->heater_address) 86 if (tmp2->heater_address)
85 free(tmp2->heater_address); 87 free(tmp2->heater_address);
86 if (tmp2->cooler_address) 88 if (tmp2->cooler_address)
87 free(tmp2->cooler_address); 89 free(tmp2->cooler_address);
88 if (tmp2->fan_address) 90 if (tmp2->fan_address)
377 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_TEMPERATURE", "%d", tmp3->beer_temperature)) < 0)) { 379 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_TEMPERATURE", "%d", tmp3->beer_temperature)) < 0)) {
378 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 380 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
379 return 1; 381 return 1;
380 } 382 }
381 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_IDX", "%d", tmp3->beer_idx)) < 0)) { 383 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_IDX", "%d", tmp3->beer_idx)) < 0)) {
384 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
385 return 1;
386 }
387 }
388 if (tmp3->chiller_address) {
389 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CHILLER_ADDRESS", "%s", tmp3->chiller_address)) < 0)) {
390 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
391 return 1;
392 }
393 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CHILLER_STATE", "%d", tmp3->chiller_state)) < 0)) {
394 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
395 return 1;
396 }
397 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CHILLER_TEMPERATURE", "%d", tmp3->chiller_temperature)) < 0)) {
398 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
399 return 1;
400 }
401 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "CHILLER_IDX", "%d", tmp3->chiller_idx)) < 0)) {
382 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 402 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
383 return 1; 403 return 1;
384 } 404 }
385 } 405 }
386 if (tmp3->heater_address) { 406 if (tmp3->heater_address) {
1067 units_list *unit, *tmp; 1087 units_list *unit, *tmp;
1068 1088
1069 unit = (units_list *)malloc(sizeof(units_list)); 1089 unit = (units_list *)malloc(sizeof(units_list));
1070 unit->next = NULL; 1090 unit->next = NULL;
1071 unit->version = 1; 1091 unit->version = 1;
1072 unit->uuid = unit->name = unit->alias = unit->air_address = unit->beer_address = unit->heater_address = \ 1092 unit->uuid = unit->name = unit->alias = unit->air_address = unit->beer_address = unit->chiller_address = unit->heater_address = \
1073 unit->cooler_address = unit->fan_address = unit->door_address = \ 1093 unit->cooler_address = unit->fan_address = unit->door_address = \
1074 unit->light_address = unit->psu_address = unit->profile = NULL; 1094 unit->light_address = unit->psu_address = unit->profile = NULL;
1075 unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0; 1095 unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0;
1076 unit->air_temperature = unit->beer_temperature = unit->beer_set = unit->fridge_set = 20.0; 1096 unit->air_temperature = unit->beer_temperature = unit->chiller_temperature = unit->beer_set = unit->fridge_set = 20.0;
1077 unit->air_state = unit->beer_state = 1; // missing 1097 unit->air_state = unit->beer_state = unit->chiller_state = 1; // missing
1078 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = \ 1098 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = \
1079 unit->light_state = unit->psu_state = unit->mode = unit->prof_state = 0; 1099 unit->light_state = unit->psu_state = unit->mode = unit->prof_state = 0;
1080 unit->air_idx = unit->beer_idx = unit->heater_idx = unit->cooler_idx = unit->fan_idx = \ 1100 unit->air_idx = unit->beer_idx = unit->chiller_idx = unit->heater_idx = unit->cooler_idx = unit->fan_idx = \
1081 unit->door_idx = unit->light_idx = unit->psu_idx = 0; 1101 unit->door_idx = unit->light_idx = unit->psu_idx = 0;
1082 unit->heater_delay = unit->cooler_delay = unit->fan_delay = 20; /* 5 minutes delay */ 1102 unit->heater_delay = unit->cooler_delay = unit->fan_delay = 20; /* 5 minutes delay */
1083 unit->light_delay = 1; /* 15 seconds delay */ 1103 unit->light_delay = 1; /* 15 seconds delay */
1084 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; 1104 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0;
1085 unit->heater_usage = unit->cooler_usage = unit->fan_usage = unit->light_usage = 0; 1105 unit->heater_usage = unit->cooler_usage = unit->fan_usage = unit->light_usage = 0;
1158 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1178 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1159 if (sscanf((const char *)key, "%d", &ival) == 1) 1179 if (sscanf((const char *)key, "%d", &ival) == 1)
1160 unit->beer_temperature = ival; 1180 unit->beer_temperature = ival;
1161 xmlFree(key); 1181 xmlFree(key);
1162 } 1182 }
1183 if ((!xmlStrcmp(cur->name, (const xmlChar *)"CHILLER_ADDRESS"))) {
1184 unit->chiller_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1185 }
1186 if ((!xmlStrcmp(cur->name, (const xmlChar *)"CHILLER_STATE"))) {
1187 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1188 if (sscanf((const char *)key, "%d", &ival) == 1)
1189 unit->chiller_state = ival;
1190 xmlFree(key);
1191 }
1192 if ((!xmlStrcmp(cur->name, (const xmlChar *)"CHILLER_IDX"))) {
1193 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1194 if (sscanf((const char *)key, "%d", &ival) == 1)
1195 unit->chiller_idx = ival;
1196 xmlFree(key);
1197 }
1198 if ((!xmlStrcmp(cur->name, (const xmlChar *)"CHILLER_TEMPERATURE"))) {
1199 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1200 if (sscanf((const char *)key, "%d", &ival) == 1)
1201 unit->chiller_temperature = ival;
1202 xmlFree(key);
1203 }
1163 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HEATER_ADDRESS"))) { 1204 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HEATER_ADDRESS"))) {
1164 unit->heater_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1205 unit->heater_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1165 } 1206 }
1166 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HEATER_DELAY"))) { 1207 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HEATER_DELAY"))) {
1167 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1208 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);

mercurial