thermferm/rdconfig.c

changeset 362
c92651a54969
parent 313
8448fcf3d799
child 363
468ec0d96cce
equal deleted inserted replaced
361:308f6a436779 362:c92651a54969
35 const char UNITMODE[5][8] = { "OFF", "NONE", "FRIDGE", "BEER", "PROFILE" }; 35 const char UNITMODE[5][8] = { "OFF", "NONE", "FRIDGE", "BEER", "PROFILE" };
36 const char PROFSTATE[5][6] = { "OFF", "PAUSE", "RUN", "DONE", "ABORT" }; 36 const char PROFSTATE[5][6] = { "OFF", "PAUSE", "RUN", "DONE", "ABORT" };
37 const char DEVTYPE[8][6] = { "NA", "W1", "GPIO", "RC433", "DHT", "I2C", "SPI", "SIM" }; 37 const char DEVTYPE[8][6] = { "NA", "W1", "GPIO", "RC433", "DHT", "I2C", "SPI", "SIM" };
38 const char DEVPRESENT[4][6] = { "UNDEF", "NO", "YES", "ERROR" }; 38 const char DEVPRESENT[4][6] = { "UNDEF", "NO", "YES", "ERROR" };
39 const char DEVDIR[7][11] = { "UNDEF", "IN_BIN", "OUT_BIN", "IN_ANALOG", "OUT_ANALOG", "OUT_PWM", "INTERN" }; 39 const char DEVDIR[7][11] = { "UNDEF", "IN_BIN", "OUT_BIN", "IN_ANALOG", "OUT_ANALOG", "OUT_PWM", "INTERN" };
40 40 const char PIDMODE[3][5] = { "NONE", "AUTO", "BOO" };
41 41
42 42
43 void killconfig(void) 43 void killconfig(void)
44 { 44 {
45 units_list *tmp2; 45 units_list *tmp2;
459 } 459 }
460 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MAX", "%.1f", tmp3->temp_set_max)) < 0) { 460 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TEMP_SET_MAX", "%.1f", tmp3->temp_set_max)) < 0) {
461 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 461 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
462 return 1; 462 return 1;
463 } 463 }
464 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_L", "%.2f", tmp3->idle_rangeL)) < 0) {
465 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
466 return 1;
467 }
468 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "IDLE_RANGE_H", "%.2f", tmp3->idle_rangeH)) < 0) {
469 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
470 return 1;
471 }
472 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_KP", "%.2f", tmp3->PID_Kp)) < 0) {
473 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
474 return 1;
475 }
476 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_KD", "%.2f", tmp3->PID_Kd)) < 0) {
477 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
478 return 1;
479 }
480 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_KI", "%.2f", tmp3->PID_Ki)) < 0) {
481 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
482 return 1;
483 }
484 if (tmp3->profile) { 464 if (tmp3->profile) {
485 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROFILE", "%s", tmp3->profile)) < 0) { 465 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROFILE", "%s", tmp3->profile)) < 0) {
486 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 466 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
487 return 1; 467 return 1;
488 } 468 }
505 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_PEAK_REL", "%.3f", tmp3->prof_peak_rel)) < 0) { 485 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_PEAK_REL", "%.3f", tmp3->prof_peak_rel)) < 0) {
506 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 486 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
507 return 1; 487 return 1;
508 } 488 }
509 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_PRIMARY_DONE", "%d", (unsigned int)tmp3->prof_primary_done)) < 0) { 489 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PROF_PRIMARY_DONE", "%d", (unsigned int)tmp3->prof_primary_done)) < 0) {
490 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
491 return 1;
492 }
493 }
494 if (tmp3->PID_cool) {
495 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDC_IMAX", "%.2f", tmp3->PID_cool->iMax)) < 0) {
496 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
497 return 1;
498 }
499 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDC_IGAIN", "%.2f", tmp3->PID_cool->iGain)) < 0) {
500 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
501 return 1;
502 }
503 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDC_PGAIN", "%.2f", tmp3->PID_cool->pGain)) < 0) {
504 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
505 return 1;
506 }
507 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDC_DGAIN", "%.2f", tmp3->PID_cool->dGain)) < 0) {
508 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
509 return 1;
510 }
511 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDC_IDLERANGE", "%.2f", tmp3->PID_cool->idleRange)) < 0) {
512 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
513 return 1;
514 }
515 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDC_INPUT", "%.2f", tmp3->PID_cool->Input)) < 0) {
516 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
517 return 1;
518 }
519 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDC_INPUTD", "%.2f", tmp3->PID_cool->InputD)) < 0) {
520 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
521 return 1;
522 }
523 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDC_INPUTLAST", "%.2f", tmp3->PID_cool->InputLast)) < 0) {
524 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
525 return 1;
526 }
527 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDC_ERR", "%.2f", tmp3->PID_cool->Err)) < 0) {
528 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
529 return 1;
530 }
531 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDC_ERRLAST", "%.2f", tmp3->PID_cool->ErrLast)) < 0) {
532 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
533 return 1;
534 }
535 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDC_ERRLASTLAST", "%.2f", tmp3->PID_cool->ErrLastLast)) < 0) {
536 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
537 return 1;
538 }
539 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDC_SETP", "%.2f", tmp3->PID_cool->SetP)) < 0) {
540 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
541 return 1;
542 }
543 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDC_OUTP", "%.2f", tmp3->PID_cool->OutP)) < 0) {
544 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
545 return 1;
546 }
547 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDC_MODE", "%s", PIDMODE[tmp3->PID_cool->Mode])) < 0) {
548 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
549 return 1;
550 }
551 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDC_TYPE", "COOL")) < 0) {
552 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
553 return 1;
554 }
555 }
556 if (tmp3->PID_heat) {
557 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDH_IMAX", "%.2f", tmp3->PID_heat->iMax)) < 0) {
558 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
559 return 1;
560 }
561 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDH_IDLERANGE", "%.2f", tmp3->PID_heat->idleRange)) < 0) {
562 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
563 return 1;
564 }
565 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDH_IGAIN", "%.2f", tmp3->PID_heat->iGain)) < 0) {
566 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
567 return 1;
568 }
569 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDH_PGAIN", "%.2f", tmp3->PID_heat->pGain)) < 0) {
570 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
571 return 1;
572 }
573 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDH_DGAIN", "%.2f", tmp3->PID_heat->dGain)) < 0) {
574 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
575 return 1;
576 }
577 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDH_INPUT", "%.2f", tmp3->PID_heat->Input)) < 0) {
578 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
579 return 1;
580 }
581 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDH_INPUTD", "%.2f", tmp3->PID_heat->InputD)) < 0) {
582 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
583 return 1;
584 }
585 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDH_INPUTLAST", "%.2f", tmp3->PID_heat->InputLast)) < 0) {
586 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
587 return 1;
588 }
589 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDH_ERR", "%.2f", tmp3->PID_heat->Err)) < 0) {
590 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
591 return 1;
592 }
593 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDH_ERRLAST", "%.2f", tmp3->PID_heat->ErrLast)) < 0) {
594 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
595 return 1;
596 }
597 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDH_ERRLASTLAST", "%.2f", tmp3->PID_heat->ErrLastLast)) < 0) {
598 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
599 return 1;
600 }
601 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDH_SETP", "%.2f", tmp3->PID_heat->SetP)) < 0) {
602 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
603 return 1;
604 }
605 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDH_OUTP", "%.2f", tmp3->PID_heat->OutP)) < 0) {
606 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
607 return 1;
608 }
609 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDH_MODE", "%s", PIDMODE[tmp3->PID_heat->Mode])) < 0) {
610 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
611 return 1;
612 }
613 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PIDH_TYPE", "HEAT")) < 0) {
510 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); 614 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
511 return 1; 615 return 1;
512 } 616 }
513 } 617 }
514 if ((rc = xmlTextWriterEndElement(writer)) < 0) { 618 if ((rc = xmlTextWriterEndElement(writer)) < 0) {
927 unit->light_delay = 1; /* 15 seconds delay */ 1031 unit->light_delay = 1; /* 15 seconds delay */
928 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0; 1032 unit->heater_wait = unit->cooler_wait = unit->fan_wait = unit->light_wait = 0;
929 unit->heater_usage = unit->cooler_usage = unit->fan_usage = unit->light_usage = 0; 1033 unit->heater_usage = unit->cooler_usage = unit->fan_usage = unit->light_usage = 0;
930 unit->temp_set_min = 1.0; 1034 unit->temp_set_min = 1.0;
931 unit->temp_set_max = 30.0; 1035 unit->temp_set_max = 30.0;
932 unit->idle_rangeH = 1.0;
933 unit->idle_rangeL = -1.0;
934 unit->prof_started = unit->prof_paused = unit->prof_primary_done = (time_t)0; 1036 unit->prof_started = unit->prof_paused = unit->prof_primary_done = (time_t)0;
935 unit->prof_percent = 0; 1037 unit->prof_percent = 0;
936 unit->PID_dState = unit->PID_iState = unit->PID_Kp = unit->PID_Kd = unit->PID_Ki = 0.0; 1038 unit->PID_cool = (pid_var *)malloc(sizeof(pid_var));
1039 unit->PID_heat = (pid_var *)malloc(sizeof(pid_var));
1040 InitPID(unit->PID_cool, PID_TYPE_COOL);
1041 InitPID(unit->PID_heat, PID_TYPE_HEAT);
937 1042
938 cur = cur->xmlChildrenNode; 1043 cur = cur->xmlChildrenNode;
939 while (cur != NULL) { 1044 while (cur != NULL) {
940 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) { 1045 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) {
941 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1046 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1086 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1191 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1087 if (sscanf((const char *)key, "%f", &val) == 1) 1192 if (sscanf((const char *)key, "%f", &val) == 1)
1088 unit->temp_set_max = val; 1193 unit->temp_set_max = val;
1089 xmlFree(key); 1194 xmlFree(key);
1090 } 1195 }
1091 if ((!xmlStrcmp(cur->name, (const xmlChar *)"IDLE_RANGE_L"))) {
1092 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1093 if (sscanf((const char *)key, "%f", &val) == 1)
1094 unit->idle_rangeL = val;
1095 xmlFree(key);
1096 }
1097 if ((!xmlStrcmp(cur->name, (const xmlChar *)"IDLE_RANGE_H"))) {
1098 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1099 if (sscanf((const char *)key, "%f", &val) == 1)
1100 unit->idle_rangeH = val;
1101 xmlFree(key);
1102 }
1103 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_KP"))) { 1196 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_KP"))) {
1104 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1197 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1105 if (sscanf((const char *)key, "%f", &val) == 1) 1198 if (sscanf((const char *)key, "%f", &val) == 1)
1106 unit->PID_Kp = val; 1199 unit->PID_cool->pGain = unit->PID_heat->pGain = val; /* Upgrade config */
1107 xmlFree(key); 1200 xmlFree(key);
1108 } 1201 }
1109 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_KD"))) { 1202 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_KD"))) {
1110 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1203 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1111 if (sscanf((const char *)key, "%f", &val) == 1) 1204 if (sscanf((const char *)key, "%f", &val) == 1)
1112 unit->PID_Kd = val; 1205 unit->PID_cool->dGain = unit->PID_heat->dGain = val; /* Upgrade config */
1113 xmlFree(key); 1206 xmlFree(key);
1114 } 1207 }
1115 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_KI"))) { 1208 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_KI"))) {
1116 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1209 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1117 if (sscanf((const char *)key, "%f", &val) == 1) 1210 if (sscanf((const char *)key, "%f", &val) == 1)
1118 unit->PID_Ki = val; 1211 unit->PID_cool->iGain = unit->PID_heat->iGain = val; /* Upgrade config */
1212 xmlFree(key);
1213 }
1214 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDC_IMAX"))) {
1215 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1216 if (sscanf((const char *)key, "%f", &val) == 1)
1217 unit->PID_cool->iMax = val;
1218 xmlFree(key);
1219 }
1220 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDC_IDLERANGE"))) {
1221 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1222 if (sscanf((const char *)key, "%f", &val) == 1)
1223 unit->PID_cool->idleRange = val;
1224 xmlFree(key);
1225 }
1226 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDC_IGAIN"))) {
1227 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1228 if (sscanf((const char *)key, "%f", &val) == 1)
1229 unit->PID_cool->iGain = val;
1230 xmlFree(key);
1231 }
1232 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDC_PGAIN"))) {
1233 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1234 if (sscanf((const char *)key, "%f", &val) == 1)
1235 unit->PID_cool->pGain = val;
1236 xmlFree(key);
1237 }
1238 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDC_DGAIN"))) {
1239 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1240 if (sscanf((const char *)key, "%f", &val) == 1)
1241 unit->PID_cool->dGain = val;
1242 xmlFree(key);
1243 }
1244 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDC_INPUT"))) {
1245 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1246 if (sscanf((const char *)key, "%f", &val) == 1)
1247 unit->PID_cool->Input = val;
1248 xmlFree(key);
1249 }
1250 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDC_INPUTD"))) {
1251 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1252 if (sscanf((const char *)key, "%f", &val) == 1)
1253 unit->PID_cool->InputD = val;
1254 xmlFree(key);
1255 }
1256 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDC_INPUTLAST"))) {
1257 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1258 if (sscanf((const char *)key, "%f", &val) == 1)
1259 unit->PID_cool->InputLast = val;
1260 xmlFree(key);
1261 }
1262 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDC_ERR"))) {
1263 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1264 if (sscanf((const char *)key, "%f", &val) == 1)
1265 unit->PID_cool->Err = val;
1266 xmlFree(key);
1267 }
1268 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDC_ERRLAST"))) {
1269 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1270 if (sscanf((const char *)key, "%f", &val) == 1)
1271 unit->PID_cool->ErrLast = val;
1272 xmlFree(key);
1273 }
1274 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDC_ERRLASTLAST"))) {
1275 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1276 if (sscanf((const char *)key, "%f", &val) == 1)
1277 unit->PID_cool->ErrLastLast = val;
1278 xmlFree(key);
1279 }
1280 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDC_SETP"))) {
1281 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1282 if (sscanf((const char *)key, "%f", &val) == 1)
1283 unit->PID_cool->SetP = val;
1284 xmlFree(key);
1285 }
1286 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDC_OUTP"))) {
1287 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1288 if (sscanf((const char *)key, "%f", &val) == 1)
1289 unit->PID_cool->OutP = val;
1290 xmlFree(key);
1291 }
1292 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDC_MODE"))) {
1293 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1294 for (i = 0; i < 3; i++) {
1295 if (! xmlStrcmp(key, (const xmlChar *)PIDMODE[i])) {
1296 unit->PID_cool->Mode = i;
1297 break;
1298 }
1299 }
1300 xmlFree(key);
1301 }
1302 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDH_IMAX"))) {
1303 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1304 if (sscanf((const char *)key, "%f", &val) == 1)
1305 unit->PID_heat->iMax = val;
1306 xmlFree(key);
1307 }
1308 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDH_IDLERANGE"))) {
1309 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1310 if (sscanf((const char *)key, "%f", &val) == 1)
1311 unit->PID_heat->idleRange = val;
1312 xmlFree(key);
1313 }
1314 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDH_IGAIN"))) {
1315 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1316 if (sscanf((const char *)key, "%f", &val) == 1)
1317 unit->PID_heat->iGain = val;
1318 xmlFree(key);
1319 }
1320 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDH_PGAIN"))) {
1321 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1322 if (sscanf((const char *)key, "%f", &val) == 1)
1323 unit->PID_heat->pGain = val;
1324 xmlFree(key);
1325 }
1326 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDH_DGAIN"))) {
1327 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1328 if (sscanf((const char *)key, "%f", &val) == 1)
1329 unit->PID_heat->dGain = val;
1330 xmlFree(key);
1331 }
1332 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDH_INPUT"))) {
1333 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1334 if (sscanf((const char *)key, "%f", &val) == 1)
1335 unit->PID_heat->Input = val;
1336 xmlFree(key);
1337 }
1338 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDH_INPUTD"))) {
1339 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1340 if (sscanf((const char *)key, "%f", &val) == 1)
1341 unit->PID_heat->InputD = val;
1342 xmlFree(key);
1343 }
1344 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDH_INPUTLAST"))) {
1345 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1346 if (sscanf((const char *)key, "%f", &val) == 1)
1347 unit->PID_heat->InputLast = val;
1348 xmlFree(key);
1349 }
1350 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDH_ERR"))) {
1351 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1352 if (sscanf((const char *)key, "%f", &val) == 1)
1353 unit->PID_heat->Err = val;
1354 xmlFree(key);
1355 }
1356 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDH_ERRLAST"))) {
1357 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1358 if (sscanf((const char *)key, "%f", &val) == 1)
1359 unit->PID_heat->ErrLast = val;
1360 xmlFree(key);
1361 }
1362 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDH_ERRLASTLAST"))) {
1363 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1364 if (sscanf((const char *)key, "%f", &val) == 1)
1365 unit->PID_heat->ErrLastLast = val;
1366 xmlFree(key);
1367 }
1368 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDH_SETP"))) {
1369 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1370 if (sscanf((const char *)key, "%f", &val) == 1)
1371 unit->PID_heat->SetP = val;
1372 xmlFree(key);
1373 }
1374 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDH_OUTP"))) {
1375 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1376 if (sscanf((const char *)key, "%f", &val) == 1)
1377 unit->PID_heat->OutP = val;
1378 xmlFree(key);
1379 }
1380 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PIDH_MODE"))) {
1381 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1382 for (i = 0; i < 3; i++) {
1383 if (! xmlStrcmp(key, (const xmlChar *)PIDMODE[i])) {
1384 unit->PID_heat->Mode = i;
1385 break;
1386 }
1387 }
1119 xmlFree(key); 1388 xmlFree(key);
1120 } 1389 }
1121 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROFILE"))) { 1390 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PROFILE"))) {
1122 unit->profile = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); 1391 unit->profile = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
1123 } 1392 }

mercurial