thermferm/rdconfig.c

changeset 90
28ee293654fd
parent 86
3d7a241329e2
child 91
901ca9858a7a
equal deleted inserted replaced
89:8bab04a663dd 90:28ee293654fd
27 static char *mypath; 27 static char *mypath;
28 sys_config Config; /* System configuration */ 28 sys_config Config; /* System configuration */
29 29
30 #define MY_ENCODING "utf-8" 30 #define MY_ENCODING "utf-8"
31 31
32 const char UNITMODE[5][8] = { "OFF", "NONE", "FRIDGE", "BEER", "PROFILE" }; 32 const char UNITMODE[5][8] = { "OFF", "NONE", "FRIDGE", "BEER", "PROFILE" };
33 33 const char PROFSTATE[4][6] = { "OFF", "PAUSE", "RUN", "DONE" };
34 34
35 35
36 36
37 37
38 void killconfig(void) 38 void killconfig(void)
340 if (tmp3->profile) { 340 if (tmp3->profile) {
341 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROFILE", "%s", tmp3->profile)) < 0) { 341 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROFILE", "%s", tmp3->profile)) < 0) {
342 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 342 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
343 return 1; 343 return 1;
344 } 344 }
345 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%d", (unsigned int)tmp3->prof_started)) < 0) { 345 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_STARTED", "%d", (unsigned int)tmp3->prof_started)) < 0) {
346 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
347 return 1;
348 }
349 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_STATE", "%s", PROFSTATE[tmp3->prof_state] )) < 0) {
346 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 350 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
347 return 1; 351 return 1;
348 } 352 }
349 } 353 }
350 if ((rc = xmlTextWriterEndElement(writer)) < 0) { 354 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
527 float val; 531 float val;
528 units_list *unit, *tmp; 532 units_list *unit, *tmp;
529 533
530 unit = (units_list *)malloc(sizeof(units_list)); 534 unit = (units_list *)malloc(sizeof(units_list));
531 unit->next = NULL; 535 unit->next = NULL;
536 unit->version = 1;
532 unit->uuid = unit->name = unit->air_address = unit->beer_address = unit->io1_address = unit->io2_address = unit->profile = NULL; 537 unit->uuid = unit->name = unit->air_address = unit->beer_address = unit->io1_address = unit->io2_address = unit->profile = NULL;
533 unit->volume = 0.0; 538 unit->volume = 0.0;
534 unit->heater_available = unit->cooler_available = unit->fan_available = FALSE; 539 unit->heater_available = unit->cooler_available = unit->fan_available = FALSE;
535 unit->air_temp = unit->beer_temp = unit->beer_set = unit->fridge_set = 20.0; 540 unit->air_temp = unit->beer_temp = unit->beer_set = unit->fridge_set = 20.0;
536 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = 0; 541 unit->heater_state = unit->cooler_state = unit->fan_state = unit->door_state = unit->mode = unit->prof_state = 0;
537 unit->temp_set_min = 1.0; 542 unit->temp_set_min = 1.0;
538 unit->temp_set_max = 30.0; 543 unit->temp_set_max = 30.0;
539 unit->idle_rangeH = 1.0; 544 unit->idle_rangeH = 1.0;
540 unit->idle_rangeL = -1.0; 545 unit->idle_rangeL = -1.0;
541 unit->prof_started = (time_t)0; 546 unit->prof_started = (time_t)0;
546 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 551 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
547 if (xmlStrcmp(key, (const xmlChar *)"1")) { 552 if (xmlStrcmp(key, (const xmlChar *)"1")) {
548 xmlFree(key); 553 xmlFree(key);
549 return 1; 554 return 1;
550 } 555 }
556 unit->version = 1;
551 xmlFree(key); 557 xmlFree(key);
552 } 558 }
553 if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) { 559 if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) {
554 unit->uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 560 unit->uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
555 } 561 }
643 } 649 }
644 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROF_STARTED"))) { 650 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROF_STARTED"))) {
645 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 651 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
646 if (sscanf((const char *)key, "%d", &ival) == 1) 652 if (sscanf((const char *)key, "%d", &ival) == 1)
647 unit->prof_started = ival; 653 unit->prof_started = ival;
654 xmlFree(key);
655 }
656 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROF_STATE"))) {
657 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
658 for (i = 0; i < 4; i++) {
659 if (! xmlStrcmp(key, (const xmlChar *)PROFSTATE[i])) {
660 unit->prof_state = i;
661 break;
662 }
663 }
648 xmlFree(key); 664 xmlFree(key);
649 } 665 }
650 cur = cur->next; 666 cur = cur->next;
651 } 667 }
652 668

mercurial