thermferm/rdconfig.c

changeset 513
a2732027afb3
parent 506
cdcd07bbee30
child 518
fd36bedab944
equal deleted inserted replaced
512:fd1354e2a045 513:a2732027afb3
58 Config.tempFormat = 'C'; 58 Config.tempFormat = 'C';
59 if (Config.temp_address) 59 if (Config.temp_address)
60 free(Config.temp_address); 60 free(Config.temp_address);
61 if (Config.hum_address) 61 if (Config.hum_address)
62 free(Config.hum_address); 62 free(Config.hum_address);
63 Config.temp_hum_idx = 0;
63 Config.temp_address = Config.hum_address = NULL; 64 Config.temp_address = Config.hum_address = NULL;
64 Config.temp_value = 20000; 65 Config.temp_value = 20000;
65 Config.temp_state = Config.hum_state = 1; // missing 66 Config.temp_state = Config.hum_state = 1; // missing
66 Config.hum_value = 50000; 67 Config.hum_value = 50000;
67 #ifdef HAVE_MOSQUITTO_H 68 #ifdef HAVE_MOSQUITTO_H
242 } 243 }
243 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_VALUE", "%d", Config.hum_value)) < 0) { 244 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HUM_VALUE", "%d", Config.hum_value)) < 0) {
244 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 245 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
245 return 1; 246 return 1;
246 } 247 }
248 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_HUM_IDX", "%d", Config.temp_hum_idx)) < 0) {
249 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
250 return 1;
251 }
247 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NEXT_UNIT", "%d", Config.next_unit)) < 0) { 252 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NEXT_UNIT", "%d", Config.next_unit)) < 0) {
248 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 253 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
249 return 1; 254 return 1;
250 } 255 }
251 #ifdef HAVE_MOSQUITTO_H 256 #ifdef HAVE_MOSQUITTO_H
353 } 358 }
354 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_TEMPERATURE", "%d", tmp3->air_temperature)) < 0)) { 359 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_TEMPERATURE", "%d", tmp3->air_temperature)) < 0)) {
355 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 360 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
356 return 1; 361 return 1;
357 } 362 }
363 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "AIR_IDX", "%d", tmp3->air_idx)) < 0)) {
364 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
365 return 1;
366 }
358 } 367 }
359 if (tmp3->beer_address) { 368 if (tmp3->beer_address) {
360 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_ADDRESS", "%s", tmp3->beer_address)) < 0)) { 369 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_ADDRESS", "%s", tmp3->beer_address)) < 0)) {
361 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 370 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
362 return 1; 371 return 1;
367 } 376 }
368 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_TEMPERATURE", "%d", tmp3->beer_temperature)) < 0)) { 377 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_TEMPERATURE", "%d", tmp3->beer_temperature)) < 0)) {
369 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 378 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
370 return 1; 379 return 1;
371 } 380 }
381 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "BEER_IDX", "%d", tmp3->beer_idx)) < 0)) {
382 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
383 return 1;
384 }
372 } 385 }
373 if (tmp3->heater_address) { 386 if (tmp3->heater_address) {
374 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_ADDRESS", "%s", tmp3->heater_address)) < 0)) { 387 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_ADDRESS", "%s", tmp3->heater_address)) < 0)) {
375 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 388 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
376 return 1; 389 return 1;
385 } 398 }
386 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_USAGE", "%d", tmp3->heater_usage)) < 0)) { 399 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_USAGE", "%d", tmp3->heater_usage)) < 0)) {
387 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 400 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
388 return 1; 401 return 1;
389 } 402 }
403 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HEATER_IDX", "%d", tmp3->heater_idx)) < 0)) {
404 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
405 return 1;
406 }
390 } 407 }
391 if (tmp3->cooler_address) { 408 if (tmp3->cooler_address) {
392 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_ADDRESS", "%s", tmp3->cooler_address)) < 0)) { 409 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_ADDRESS", "%s", tmp3->cooler_address)) < 0)) {
393 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 410 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
394 return 1; 411 return 1;
403 } 420 }
404 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_USAGE", "%d", tmp3->cooler_usage)) < 0)) { 421 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_USAGE", "%d", tmp3->cooler_usage)) < 0)) {
405 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 422 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
406 return 1; 423 return 1;
407 } 424 }
425 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COOLER_IDX", "%d", tmp3->cooler_idx)) < 0)) {
426 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
427 return 1;
428 }
408 } 429 }
409 if (tmp3->fan_address) { 430 if (tmp3->fan_address) {
410 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_ADDRESS", "%s", tmp3->fan_address)) < 0)) { 431 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_ADDRESS", "%s", tmp3->fan_address)) < 0)) {
411 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 432 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
412 return 1; 433 return 1;
421 } 442 }
422 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_USAGE", "%d", tmp3->fan_usage)) < 0)) { 443 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_USAGE", "%d", tmp3->fan_usage)) < 0)) {
423 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 444 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
424 return 1; 445 return 1;
425 } 446 }
447 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "FAN_IDX", "%d", tmp3->fan_idx)) < 0)) {
448 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
449 return 1;
450 }
426 } 451 }
427 if (tmp3->light_address) { 452 if (tmp3->light_address) {
428 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LIGHT_ADDRESS", "%s", tmp3->light_address)) < 0)) { 453 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LIGHT_ADDRESS", "%s", tmp3->light_address)) < 0)) {
429 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 454 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
430 return 1; 455 return 1;
439 } 464 }
440 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LIGHT_USAGE", "%d", tmp3->light_usage)) < 0)) { 465 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LIGHT_USAGE", "%d", tmp3->light_usage)) < 0)) {
441 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 466 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
442 return 1; 467 return 1;
443 } 468 }
469 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "LIGHT_IDX", "%d", tmp3->light_idx)) < 0)) {
470 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
471 return 1;
472 }
444 } 473 }
445 if (tmp3->door_address) { 474 if (tmp3->door_address) {
446 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_ADDRESS", "%s", tmp3->door_address)) < 0)) { 475 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_ADDRESS", "%s", tmp3->door_address)) < 0)) {
447 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 476 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
448 return 1; 477 return 1;
449 } 478 }
450 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_STATE", "%d", tmp3->door_state)) < 0)) { 479 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_STATE", "%d", tmp3->door_state)) < 0)) {
451 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 480 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
452 return 1; 481 return 1;
453 } 482 }
483 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DOOR_IDX", "%d", tmp3->door_idx)) < 0)) {
484 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
485 return 1;
486 }
454 } 487 }
455 if (tmp3->psu_address) { 488 if (tmp3->psu_address) {
456 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PSU_ADDRESS", "%s", tmp3->psu_address)) < 0)) { 489 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PSU_ADDRESS", "%s", tmp3->psu_address)) < 0)) {
457 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 490 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
458 return 1; 491 return 1;
459 } 492 }
460 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PSU_STATE", "%d", tmp3->psu_state)) < 0)) { 493 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PSU_STATE", "%d", tmp3->psu_state)) < 0)) {
494 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
495 return 1;
496 }
497 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PSU_IDX", "%d", tmp3->psu_idx)) < 0)) {
461 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 498 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
462 return 1; 499 return 1;
463 } 500 }
464 } 501 }
465 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MODE", "%s", UNITMODE[tmp3->mode] )) < 0) { 502 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MODE", "%s", UNITMODE[tmp3->mode] )) < 0) {
1038 unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0; 1075 unit->volume = unit->prof_peak_abs = unit->prof_peak_rel = 0.0;
1039 unit->air_temperature = unit->beer_temperature = unit->beer_set = unit->fridge_set = 20.0; 1076 unit->air_temperature = unit->beer_temperature = unit->beer_set = unit->fridge_set = 20.0;
1040 unit->air_state = unit->beer_state = 1; // missing 1077 unit->air_state = unit->beer_state = 1; // missing
1041 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = \ 1078 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = \
1042 unit->light_state = unit->psu_state = unit->mode = unit->prof_state = 0; 1079 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 = \
1081 unit->door_idx = unit->light_idx = unit->psu_idx = 0;
1043 unit->heater_delay = unit->cooler_delay = unit->fan_delay = 20; /* 5 minutes delay */ 1082 unit->heater_delay = unit->cooler_delay = unit->fan_delay = 20; /* 5 minutes delay */
1044 unit->light_delay = 1; /* 15 seconds delay */ 1083 unit->light_delay = 1; /* 15 seconds delay */
1045 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; 1084 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0;
1046 unit->heater_usage = unit->cooler_usage = unit->fan_usage = unit->light_usage = 0; 1085 unit->heater_usage = unit->cooler_usage = unit->fan_usage = unit->light_usage = 0;
1047 unit->temp_set_min = 1.0; 1086 unit->temp_set_min = 1.0;
1086 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1125 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1087 if (sscanf((const char *)key, "%d", &ival) == 1) 1126 if (sscanf((const char *)key, "%d", &ival) == 1)
1088 unit->air_state = ival; 1127 unit->air_state = ival;
1089 xmlFree(key); 1128 xmlFree(key);
1090 } 1129 }
1130 if ((!xmlStrcmp(cur->name, (const xmlChar *)"AIR_IDX"))) {
1131 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1132 if (sscanf((const char *)key, "%d", &ival) == 1)
1133 unit->air_idx = ival;
1134 xmlFree(key);
1135 }
1091 if ((!xmlStrcmp(cur->name, (const xmlChar *)"AIR_TEMPERATURE"))) { 1136 if ((!xmlStrcmp(cur->name, (const xmlChar *)"AIR_TEMPERATURE"))) {
1092 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1137 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1093 if (sscanf((const char *)key, "%d", &ival) == 1) 1138 if (sscanf((const char *)key, "%d", &ival) == 1)
1094 unit->air_temperature = ival; 1139 unit->air_temperature = ival;
1095 xmlFree(key); 1140 xmlFree(key);
1101 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1146 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1102 if (sscanf((const char *)key, "%d", &ival) == 1) 1147 if (sscanf((const char *)key, "%d", &ival) == 1)
1103 unit->beer_state = ival; 1148 unit->beer_state = ival;
1104 xmlFree(key); 1149 xmlFree(key);
1105 } 1150 }
1151 if ((!xmlStrcmp(cur->name, (const xmlChar *)"BEER_IDX"))) {
1152 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1153 if (sscanf((const char *)key, "%d", &ival) == 1)
1154 unit->beer_idx = ival;
1155 xmlFree(key);
1156 }
1106 if ((!xmlStrcmp(cur->name, (const xmlChar *)"BEER_TEMPERATURE"))) { 1157 if ((!xmlStrcmp(cur->name, (const xmlChar *)"BEER_TEMPERATURE"))) {
1107 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1158 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1108 if (sscanf((const char *)key, "%d", &ival) == 1) 1159 if (sscanf((const char *)key, "%d", &ival) == 1)
1109 unit->beer_temperature = ival; 1160 unit->beer_temperature = ival;
1110 xmlFree(key); 1161 xmlFree(key);
1116 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1167 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1117 if (sscanf((const char *)key, "%d", &ival) == 1) 1168 if (sscanf((const char *)key, "%d", &ival) == 1)
1118 unit->heater_delay = ival; 1169 unit->heater_delay = ival;
1119 xmlFree(key); 1170 xmlFree(key);
1120 } 1171 }
1172 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HEATER_IDX"))) {
1173 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1174 if (sscanf((const char *)key, "%d", &ival) == 1)
1175 unit->heater_idx = ival;
1176 xmlFree(key);
1177 }
1121 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HEATER_USAGE"))) { 1178 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HEATER_USAGE"))) {
1122 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1179 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1123 if (sscanf((const char *)key, "%d", &ival) == 1) 1180 if (sscanf((const char *)key, "%d", &ival) == 1)
1124 unit->heater_usage = ival; 1181 unit->heater_usage = ival;
1125 xmlFree(key); 1182 xmlFree(key);
1131 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1188 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1132 if (sscanf((const char *)key, "%d", &ival) == 1) 1189 if (sscanf((const char *)key, "%d", &ival) == 1)
1133 unit->cooler_delay = ival; 1190 unit->cooler_delay = ival;
1134 xmlFree(key); 1191 xmlFree(key);
1135 } 1192 }
1193 if ((!xmlStrcmp(cur->name, (const xmlChar *)"COOLER_IDX"))) {
1194 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1195 if (sscanf((const char *)key, "%d", &ival) == 1)
1196 unit->cooler_idx = ival;
1197 xmlFree(key);
1198 }
1136 if ((!xmlStrcmp(cur->name, (const xmlChar *)"COOLER_USAGE"))) { 1199 if ((!xmlStrcmp(cur->name, (const xmlChar *)"COOLER_USAGE"))) {
1137 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1200 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1138 if (sscanf((const char *)key, "%d", &ival) == 1) 1201 if (sscanf((const char *)key, "%d", &ival) == 1)
1139 unit->cooler_usage = ival; 1202 unit->cooler_usage = ival;
1140 xmlFree(key); 1203 xmlFree(key);
1146 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1209 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1147 if (sscanf((const char *)key, "%d", &ival) == 1) 1210 if (sscanf((const char *)key, "%d", &ival) == 1)
1148 unit->fan_delay = ival; 1211 unit->fan_delay = ival;
1149 xmlFree(key); 1212 xmlFree(key);
1150 } 1213 }
1214 if ((!xmlStrcmp(cur->name, (const xmlChar *)"FAN_IDX"))) {
1215 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1216 if (sscanf((const char *)key, "%d", &ival) == 1)
1217 unit->fan_idx = ival;
1218 xmlFree(key);
1219 }
1151 if ((!xmlStrcmp(cur->name, (const xmlChar *)"FAN_USAGE"))) { 1220 if ((!xmlStrcmp(cur->name, (const xmlChar *)"FAN_USAGE"))) {
1152 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1221 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1153 if (sscanf((const char *)key, "%d", &ival) == 1) 1222 if (sscanf((const char *)key, "%d", &ival) == 1)
1154 unit->fan_usage = ival; 1223 unit->fan_usage = ival;
1155 xmlFree(key); 1224 xmlFree(key);
1161 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1230 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1162 if (sscanf((const char *)key, "%d", &ival) == 1) 1231 if (sscanf((const char *)key, "%d", &ival) == 1)
1163 unit->light_delay = ival; 1232 unit->light_delay = ival;
1164 xmlFree(key); 1233 xmlFree(key);
1165 } 1234 }
1235 if ((!xmlStrcmp(cur->name, (const xmlChar *)"LIGHT_IDX"))) {
1236 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1237 if (sscanf((const char *)key, "%d", &ival) == 1)
1238 unit->light_idx = ival;
1239 xmlFree(key);
1240 }
1166 if ((!xmlStrcmp(cur->name, (const xmlChar *)"LIGHT_USAGE"))) { 1241 if ((!xmlStrcmp(cur->name, (const xmlChar *)"LIGHT_USAGE"))) {
1167 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1242 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1168 if (sscanf((const char *)key, "%d", &ival) == 1) 1243 if (sscanf((const char *)key, "%d", &ival) == 1)
1169 unit->light_usage = ival; 1244 unit->light_usage = ival;
1170 xmlFree(key); 1245 xmlFree(key);
1171 } 1246 }
1172 if ((!xmlStrcmp(cur->name, (const xmlChar *)"DOOR_ADDRESS"))) { 1247 if ((!xmlStrcmp(cur->name, (const xmlChar *)"DOOR_ADDRESS"))) {
1173 unit->door_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1248 unit->door_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1174 } 1249 }
1250 if ((!xmlStrcmp(cur->name, (const xmlChar *)"DOOR_IDX"))) {
1251 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1252 if (sscanf((const char *)key, "%d", &ival) == 1)
1253 unit->door_idx = ival;
1254 xmlFree(key);
1255 }
1175 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PSU_ADDRESS"))) { 1256 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PSU_ADDRESS"))) {
1176 unit->psu_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1257 unit->psu_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1258 }
1259 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PSU_IDX"))) {
1260 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1261 if (sscanf((const char *)key, "%d", &ival) == 1)
1262 unit->psu_idx = ival;
1263 xmlFree(key);
1177 } 1264 }
1178 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MODE"))) { 1265 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MODE"))) {
1179 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1266 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1180 for (i = 0; i < 5; i++) { 1267 for (i = 0; i < 5; i++) {
1181 if (! xmlStrcmp(key, (const xmlChar *)UNITMODE[i])) { 1268 if (! xmlStrcmp(key, (const xmlChar *)UNITMODE[i])) {
1410 unit->prof_primary_done = ival; 1497 unit->prof_primary_done = ival;
1411 xmlFree(key); 1498 xmlFree(key);
1412 } 1499 }
1413 cur = cur->next; 1500 cur = cur->next;
1414 } 1501 }
1415
1416 /*
1417 * If there is no alias name, create it.
1418 */
1419 // if (unit->alias == NULL) {
1420 // char an[128];
1421 // sprintf(an, "unit%d", number);
1422 // unit->alias = xstrcpy(an);
1423 // }
1424 1502
1425 if (Config.units == NULL) { 1503 if (Config.units == NULL) {
1426 Config.units = unit; 1504 Config.units = unit;
1427 } else { 1505 } else {
1428 for (tmp = Config.units; tmp; tmp = tmp->next) { 1506 for (tmp = Config.units; tmp; tmp = tmp->next) {
1441 int parseFermenters(xmlDocPtr doc, xmlNodePtr cur) 1519 int parseFermenters(xmlDocPtr doc, xmlNodePtr cur)
1442 { 1520 {
1443 cur = cur->xmlChildrenNode; 1521 cur = cur->xmlChildrenNode;
1444 while (cur != NULL) { 1522 while (cur != NULL) {
1445 if ((!xmlStrcmp(cur->name, (const xmlChar *)"UNIT"))) { 1523 if ((!xmlStrcmp(cur->name, (const xmlChar *)"UNIT"))) {
1446 parseUnit(doc, cur/* , Config.next_unit*/); 1524 parseUnit(doc, cur);
1447 // Config.next_unit++;
1448 } 1525 }
1449 cur = cur->next; 1526 cur = cur->next;
1450 } 1527 }
1451 return 0; 1528 return 0;
1452 } 1529 }
2062 Config.temp_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 2139 Config.temp_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
2063 } 2140 }
2064 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HUM_ADDRESS"))) { 2141 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HUM_ADDRESS"))) {
2065 Config.hum_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 2142 Config.hum_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
2066 } 2143 }
2144 if ((!xmlStrcmp(cur->name, (const xmlChar *)"TEMP_HUM_IDX"))) {
2145 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
2146 if (sscanf((const char *)key, "%d", &ival) == 1)
2147 Config.temp_hum_idx = ival;
2148 xmlFree(key);
2149 }
2067 if ((!xmlStrcmp(cur->name, (const xmlChar *)"NEXT_UNIT"))) { 2150 if ((!xmlStrcmp(cur->name, (const xmlChar *)"NEXT_UNIT"))) {
2068 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 2151 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
2069 if (sscanf((const char *)key, "%d", &ival) == 1) 2152 if (sscanf((const char *)key, "%d", &ival) == 1)
2070 Config.next_unit = ival; 2153 Config.next_unit = ival;
2071 xmlFree(key); 2154 xmlFree(key);

mercurial