196 * Close the element LCDS. |
251 * Close the element LCDS. |
197 */ |
252 */ |
198 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
253 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
199 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
254 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
200 return 1; |
255 return 1; |
|
256 } |
|
257 |
|
258 /* |
|
259 * Brewsystems |
|
260 */ |
|
261 if (Config.units) { |
|
262 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "BREWSYSTEMS")) < 0) { |
|
263 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
|
264 return 1; |
|
265 } |
|
266 for (unit = Config.units; unit; unit = unit->next) { |
|
267 /* |
|
268 * Only configuration items are written, measured values and states |
|
269 * are written to a state file. |
|
270 */ |
|
271 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "BREWSYSTEM")) < 0) { |
|
272 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
|
273 return 1; |
|
274 } |
|
275 if ((rc = xmlTextWriterWriteElement(writer, BAD_CAST "VERSION", BAD_CAST "1")) < 0) { |
|
276 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
|
277 return 1; |
|
278 } |
|
279 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", unit->uuid)) < 0) { |
|
280 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
281 return 1; |
|
282 } |
|
283 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", unit->name)) < 0) { |
|
284 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
285 return 1; |
|
286 } |
|
287 |
|
288 if (unit->hlt_sensor_address) { |
|
289 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HLT_SENSOR_ADDRESS", "%s", unit->hlt_sensor_address)) < 0)) { |
|
290 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
291 return 1; |
|
292 } |
|
293 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HLT_SENSOR_STATE", "%d", unit->hlt_sensor_state)) < 0)) { |
|
294 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
295 return 1; |
|
296 } |
|
297 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HLT_SENSOR_VALUE", "%d", unit->hlt_sensor_value)) < 0)) { |
|
298 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
299 return 1; |
|
300 } |
|
301 } |
|
302 |
|
303 if (unit->hlt_heater_address) { |
|
304 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HLT_HEATER_ADDRESS", "%s", unit->hlt_heater_address)) < 0)) { |
|
305 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
306 return 1; |
|
307 } |
|
308 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HLT_HEATER_STATE", "%d", unit->hlt_heater_state)) < 0)) { |
|
309 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
310 return 1; |
|
311 } |
|
312 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "HLT_HEATER_DELAY", "%d", unit->hlt_heater_delay)) < 0)) { |
|
313 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
314 return 1; |
|
315 } |
|
316 } |
|
317 |
|
318 if (unit->mlt_sensor_address) { |
|
319 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MLT_SENSOR_ADDRESS", "%s", unit->mlt_sensor_address)) < 0)) { |
|
320 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
321 return 1; |
|
322 } |
|
323 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MLT_SENSOR_STATE", "%d", unit->mlt_sensor_state)) < 0)) { |
|
324 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
325 return 1; |
|
326 } |
|
327 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MLT_SENSOR_VALUE", "%d", unit->mlt_sensor_value)) < 0)) { |
|
328 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
329 return 1; |
|
330 } |
|
331 } |
|
332 |
|
333 if (unit->mlt_heater_address) { |
|
334 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MLT_HEATER_ADDRESS", "%s", unit->mlt_heater_address)) < 0)) { |
|
335 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
336 return 1; |
|
337 } |
|
338 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MLT_HEATER_STATE", "%d", unit->mlt_heater_state)) < 0)) { |
|
339 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
340 return 1; |
|
341 } |
|
342 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MLT_HEATER_DELAY", "%d", unit->mlt_heater_delay)) < 0)) { |
|
343 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
344 return 1; |
|
345 } |
|
346 } |
|
347 |
|
348 if (unit->mlt_pump_address) { |
|
349 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MLT_PUMP_ADDRESS", "%s", unit->mlt_pump_address)) < 0)) { |
|
350 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
351 return 1; |
|
352 } |
|
353 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MLT_PUMP_STATE", "%d", unit->mlt_pump_state)) < 0)) { |
|
354 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
355 return 1; |
|
356 } |
|
357 if (((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "MLT_PUMP_DELAY", "%d", unit->mlt_pump_delay)) < 0)) { |
|
358 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
359 return 1; |
|
360 } |
|
361 } |
|
362 |
|
363 if (unit->PID_hlt) { |
|
364 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_IMAX", "%.2f", unit->PID_hlt->iMax)) < 0) { |
|
365 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
366 return 1; |
|
367 } |
|
368 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_IGAIN", "%.2f", unit->PID_hlt->iGain)) < 0) { |
|
369 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
370 return 1; |
|
371 } |
|
372 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_PGAIN", "%.2f", unit->PID_hlt->pGain)) < 0) { |
|
373 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
374 return 1; |
|
375 } |
|
376 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_DGAIN", "%.2f", unit->PID_hlt->dGain)) < 0) { |
|
377 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
378 return 1; |
|
379 } |
|
380 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_INPUT", "%.2f", unit->PID_hlt->Input)) < 0) { |
|
381 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
382 return 1; |
|
383 } |
|
384 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_ERR", "%.2f", unit->PID_hlt->Err)) < 0) { |
|
385 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
386 return 1; |
|
387 } |
|
388 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_ERRLAST", "%.2f", unit->PID_hlt->ErrLast)) < 0) { |
|
389 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
390 return 1; |
|
391 } |
|
392 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_ISTATE", "%.2f", unit->PID_hlt->iState)) < 0) { |
|
393 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
394 return 1; |
|
395 } |
|
396 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_SETP", "%.2f", unit->PID_hlt->SetP)) < 0) { |
|
397 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
398 return 1; |
|
399 } |
|
400 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_OUTP", "%.2f", unit->PID_hlt->OutP)) < 0) { |
|
401 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
402 return 1; |
|
403 } |
|
404 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_MODE", "%s", PIDMODE[unit->PID_hlt->Mode])) < 0) { |
|
405 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
406 return 1; |
|
407 } |
|
408 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_TYPE", "HEAT")) < 0) { |
|
409 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
410 return 1; |
|
411 } |
|
412 } |
|
413 |
|
414 if (unit->PID_mlt) { |
|
415 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_IMAX", "%.2f", unit->PID_mlt->iMax)) < 0) { |
|
416 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
417 return 1; |
|
418 } |
|
419 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_IGAIN", "%.2f", unit->PID_mlt->iGain)) < 0) { |
|
420 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
421 return 1; |
|
422 } |
|
423 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_PGAIN", "%.2f", unit->PID_mlt->pGain)) < 0) { |
|
424 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
425 return 1; |
|
426 } |
|
427 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_DGAIN", "%.2f", unit->PID_mlt->dGain)) < 0) { |
|
428 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
429 return 1; |
|
430 } |
|
431 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_INPUT", "%.2f", unit->PID_mlt->Input)) < 0) { |
|
432 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
433 return 1; |
|
434 } |
|
435 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_ERR", "%.2f", unit->PID_mlt->Err)) < 0) { |
|
436 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
437 return 1; |
|
438 } |
|
439 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_ERRLAST", "%.2f", unit->PID_mlt->ErrLast)) < 0) { |
|
440 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
441 return 1; |
|
442 } |
|
443 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_ISTATE", "%.2f", unit->PID_mlt->iState)) < 0) { |
|
444 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
445 return 1; |
|
446 } |
|
447 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_SETP", "%.2f", unit->PID_mlt->SetP)) < 0) { |
|
448 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
449 return 1; |
|
450 } |
|
451 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_OUTP", "%.2f", unit->PID_mlt->OutP)) < 0) { |
|
452 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
453 return 1; |
|
454 } |
|
455 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_MODE", "%s", PIDMODE[unit->PID_mlt->Mode])) < 0) { |
|
456 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
457 return 1; |
|
458 } |
|
459 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_TYPE", "HEAT")) < 0) { |
|
460 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
461 return 1; |
|
462 } |
|
463 } |
|
464 |
|
465 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
|
466 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
|
467 return 1; |
|
468 } |
|
469 } |
|
470 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
|
471 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
|
472 return 1; |
|
473 } |
|
474 } |
|
475 |
|
476 if (Config.devices) { |
|
477 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "DEVICES")) < 0) { |
|
478 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
|
479 return 1; |
|
480 } |
|
481 #ifdef HAVE_WIRINGPI_H |
|
482 piLock(LOCK_DEVICES); |
|
483 #endif |
|
484 for (device = Config.devices; device; device = device->next) { |
|
485 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "DEVICE")) < 0) { |
|
486 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
|
487 return 1; |
|
488 } |
|
489 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VERSION", "%d", device->version)) < 0) { |
|
490 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
|
491 return 1; |
|
492 } |
|
493 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", device->uuid)) < 0) { |
|
494 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
495 return 1; |
|
496 } |
|
497 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TYPE", "%s", DEVTYPE[device->type])) < 0) { |
|
498 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
499 return 1; |
|
500 } |
|
501 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DIRECTION", "%s", DEVDIR[device->direction])) < 0) { |
|
502 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
503 return 1; |
|
504 } |
|
505 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VALUE", "%d", device->value)) < 0) { |
|
506 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
|
507 return 1; |
|
508 } |
|
509 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "OFFSET", "%d", device->offset)) < 0) { |
|
510 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
|
511 return 1; |
|
512 } |
|
513 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PRESENT", "%s", DEVPRESENT[device->present])) < 0) { |
|
514 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
515 return 1; |
|
516 } |
|
517 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "ADDRESS", "%s", device->address)) < 0) { |
|
518 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
|
519 return 1; |
|
520 } |
|
521 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "SUBDEVICE", "%d", device->subdevice)) < 0) { |
|
522 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
|
523 return 1; |
|
524 } |
|
525 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "GPIOPIN", "%d", device->gpiopin)) < 0) { |
|
526 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
|
527 return 1; |
|
528 } |
|
529 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "DESCRIPTION", "%s", device->description)) < 0) { |
|
530 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
|
531 return 1; |
|
532 } |
|
533 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "INUSE", "%d", device->inuse)) < 0) { |
|
534 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
|
535 return 1; |
|
536 } |
|
537 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "COMMENT", "%s", device->comment)) < 0) { |
|
538 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
|
539 return 1; |
|
540 } |
|
541 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "TIMESTAMP", "%d", (int)device->timestamp)) < 0) { |
|
542 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
|
543 return 1; |
|
544 } |
|
545 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
|
546 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
|
547 return 1; |
|
548 } |
|
549 } |
|
550 #ifdef HAVE_WIRINGPI_H |
|
551 piUnlock(LOCK_DEVICES); |
|
552 #endif |
|
553 |
|
554 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
|
555 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
|
556 return 1; |
|
557 } |
|
558 } |
|
559 |
|
560 #ifdef USE_SIMULATOR |
|
561 if (Config.simulators) { |
|
562 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "SIMULATORS")) < 0) { |
|
563 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
|
564 return 1; |
|
565 } |
|
566 for (simulator = Config.simulators; simulator; simulator = simulator->next) { |
|
567 if ((rc = xmlTextWriterStartElement(writer, BAD_CAST "SIMULATOR")) < 0) { |
|
568 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterStartElement"); |
|
569 return 1; |
|
570 } |
|
571 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "VERSION", "%d", simulator->version)) < 0) { |
|
572 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteElement"); |
|
573 return 1; |
|
574 } |
|
575 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "UUID", "%s", simulator->uuid)) < 0) { |
|
576 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
577 return 1; |
|
578 } |
|
579 if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "NAME", "%s", simulator->name)) < 0) { |
|
580 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement"); |
|
581 return 1; |
|
582 } |
|
583 |
|
584 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
|
585 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
|
586 return 1; |
|
587 } |
|
588 } |
|
589 if ((rc = xmlTextWriterEndElement(writer)) < 0) { |
|
590 syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterEndElement"); |
|
591 return 1; |
|
592 } |
201 } |
593 } |
202 #endif |
594 #endif |
203 |
595 |
204 /* |
596 /* |
205 * All done, close any open elements |
597 * All done, close any open elements |
298 } |
689 } |
299 cur = cur->next; |
690 cur = cur->next; |
300 } |
691 } |
301 return 0; |
692 return 0; |
302 } |
693 } |
|
694 |
|
695 |
|
696 |
|
697 /* |
|
698 * Parse a brewsystem |
|
699 */ |
|
700 int parseBrewsystem(xmlDocPtr doc, xmlNodePtr cur) |
|
701 { |
|
702 xmlChar *key; |
|
703 int i, ival; |
|
704 float val; |
|
705 units_list *unit, *tmp; |
|
706 |
|
707 unit = (units_list *)malloc(sizeof(units_list)); |
|
708 unit->next = NULL; |
|
709 unit->version = 1; |
|
710 unit->uuid = unit->name = unit->hlt_sensor_address = unit->hlt_heater_address = unit->mlt_sensor_address = \ |
|
711 unit->mlt_heater_address = unit->mlt_pump_address = NULL; |
|
712 unit->hlt_sensor_state = unit->mlt_sensor_state = 1; // missing |
|
713 unit->hlt_heater_state = unit->mlt_heater_state = unit->mlt_pump_state = 0; |
|
714 unit->hlt_heater_delay = unit->mlt_heater_delay = unit->mlt_pump_delay = 20; /* 5 minutes delay */ |
|
715 unit->PID_hlt = (pid_var *)malloc(sizeof(pid_var)); |
|
716 unit->PID_mlt = (pid_var *)malloc(sizeof(pid_var)); |
|
717 InitPID(unit->PID_hlt); |
|
718 InitPID(unit->PID_mlt); |
|
719 |
|
720 cur = cur->xmlChildrenNode; |
|
721 while (cur != NULL) { |
|
722 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) { |
|
723 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
724 if (xmlStrcmp(key, (const xmlChar *)"1")) { |
|
725 xmlFree(key); |
|
726 return 1; |
|
727 } |
|
728 unit->version = 1; |
|
729 xmlFree(key); |
|
730 } |
|
731 if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) { |
|
732 unit->uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
733 } |
|
734 if ((!xmlStrcmp(cur->name, (const xmlChar *)"NAME"))) { |
|
735 unit->name = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
736 } |
|
737 |
|
738 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HLT_SENSOR_ADDRESS"))) { |
|
739 unit->hlt_sensor_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
740 } |
|
741 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HLT_SENSOR_STATE"))) { |
|
742 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
743 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
744 unit->hlt_sensor_state = ival; |
|
745 xmlFree(key); |
|
746 } |
|
747 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HLT_SENSOR_VALUE"))) { |
|
748 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
749 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
750 unit->hlt_sensor_value = ival; |
|
751 xmlFree(key); |
|
752 } |
|
753 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HLT_HEATER_ADDRESS"))) { |
|
754 unit->hlt_heater_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
755 } |
|
756 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HLT_HEATER_DELAY"))) { |
|
757 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
758 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
759 unit->hlt_heater_delay = ival; |
|
760 xmlFree(key); |
|
761 } |
|
762 |
|
763 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_SENSOR_ADDRESS"))) { |
|
764 unit->mlt_sensor_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
765 } |
|
766 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_SENSOR_STATE"))) { |
|
767 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
768 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
769 unit->mlt_sensor_state = ival; |
|
770 xmlFree(key); |
|
771 } |
|
772 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_SENSOR_VALUE"))) { |
|
773 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
774 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
775 unit->mlt_sensor_value = ival; |
|
776 xmlFree(key); |
|
777 } |
|
778 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_HEATER_ADDRESS"))) { |
|
779 unit->mlt_heater_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
780 } |
|
781 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_HEATER_DELAY"))) { |
|
782 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
783 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
784 unit->mlt_heater_delay = ival; |
|
785 xmlFree(key); |
|
786 } |
|
787 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_PUMP_ADDRESS"))) { |
|
788 unit->mlt_pump_address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
789 } |
|
790 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_PUMP_DELAY"))) { |
|
791 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
792 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
793 unit->mlt_pump_delay = ival; |
|
794 xmlFree(key); |
|
795 } |
|
796 |
|
797 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_HLT_IMAX"))) { |
|
798 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
799 if (sscanf((const char *)key, "%f", &val) == 1) |
|
800 unit->PID_hlt->iMax = val; |
|
801 xmlFree(key); |
|
802 } |
|
803 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_HLT_IGAIN"))) { |
|
804 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
805 if (sscanf((const char *)key, "%f", &val) == 1) |
|
806 unit->PID_hlt->iGain = val; |
|
807 xmlFree(key); |
|
808 } |
|
809 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_HLT_PGAIN"))) { |
|
810 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
811 if (sscanf((const char *)key, "%f", &val) == 1) |
|
812 unit->PID_hlt->pGain = val; |
|
813 xmlFree(key); |
|
814 } |
|
815 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_HLT_DGAIN"))) { |
|
816 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
817 if (sscanf((const char *)key, "%f", &val) == 1) |
|
818 unit->PID_hlt->dGain = val; |
|
819 xmlFree(key); |
|
820 } |
|
821 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_HLT_INPUT"))) { |
|
822 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
823 if (sscanf((const char *)key, "%f", &val) == 1) |
|
824 unit->PID_hlt->Input = val; |
|
825 xmlFree(key); |
|
826 } |
|
827 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_HLT_ERR"))) { |
|
828 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
829 if (sscanf((const char *)key, "%f", &val) == 1) |
|
830 unit->PID_hlt->Err = val; |
|
831 xmlFree(key); |
|
832 } |
|
833 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_HLT_ERRLAST"))) { |
|
834 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
835 if (sscanf((const char *)key, "%f", &val) == 1) |
|
836 unit->PID_hlt->ErrLast = val; |
|
837 xmlFree(key); |
|
838 } |
|
839 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_HLT_ISTATE"))) { |
|
840 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
841 if (sscanf((const char *)key, "%f", &val) == 1) |
|
842 unit->PID_hlt->iState = val; |
|
843 xmlFree(key); |
|
844 } |
|
845 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_HLT_SETP"))) { |
|
846 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
847 if (sscanf((const char *)key, "%f", &val) == 1) |
|
848 unit->PID_hlt->SetP = val; |
|
849 xmlFree(key); |
|
850 } |
|
851 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_HLT_OUTP"))) { |
|
852 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
853 if (sscanf((const char *)key, "%f", &val) == 1) |
|
854 unit->PID_hlt->OutP = val; |
|
855 xmlFree(key); |
|
856 } |
|
857 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_HLT_MODE"))) { |
|
858 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
859 for (i = 0; i < 3; i++) { |
|
860 if (! xmlStrcmp(key, (const xmlChar *)PIDMODE[i])) { |
|
861 unit->PID_hlt->Mode = i; |
|
862 break; |
|
863 } |
|
864 } |
|
865 xmlFree(key); |
|
866 } |
|
867 |
|
868 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_MLT_IMAX"))) { |
|
869 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
870 if (sscanf((const char *)key, "%f", &val) == 1) |
|
871 unit->PID_mlt->iMax = val; |
|
872 xmlFree(key); |
|
873 } |
|
874 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_MLT_IGAIN"))) { |
|
875 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
876 if (sscanf((const char *)key, "%f", &val) == 1) |
|
877 unit->PID_mlt->iGain = val; |
|
878 xmlFree(key); |
|
879 } |
|
880 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_MLT_PGAIN"))) { |
|
881 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
882 if (sscanf((const char *)key, "%f", &val) == 1) |
|
883 unit->PID_mlt->pGain = val; |
|
884 xmlFree(key); |
|
885 } |
|
886 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_MLT_DGAIN"))) { |
|
887 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
888 if (sscanf((const char *)key, "%f", &val) == 1) |
|
889 unit->PID_mlt->dGain = val; |
|
890 xmlFree(key); |
|
891 } |
|
892 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_MLT_INPUT"))) { |
|
893 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
894 if (sscanf((const char *)key, "%f", &val) == 1) |
|
895 unit->PID_mlt->Input = val; |
|
896 xmlFree(key); |
|
897 } |
|
898 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_MLT_ERR"))) { |
|
899 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
900 if (sscanf((const char *)key, "%f", &val) == 1) |
|
901 unit->PID_mlt->Err = val; |
|
902 xmlFree(key); |
|
903 } |
|
904 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_MLT_ERRLAST"))) { |
|
905 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
906 if (sscanf((const char *)key, "%f", &val) == 1) |
|
907 unit->PID_mlt->ErrLast = val; |
|
908 xmlFree(key); |
|
909 } |
|
910 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_MLT_ISTATE"))) { |
|
911 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
912 if (sscanf((const char *)key, "%f", &val) == 1) |
|
913 unit->PID_mlt->iState = val; |
|
914 xmlFree(key); |
|
915 } |
|
916 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_MLT_SETP"))) { |
|
917 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
918 if (sscanf((const char *)key, "%f", &val) == 1) |
|
919 unit->PID_mlt->SetP = val; |
|
920 xmlFree(key); |
|
921 } |
|
922 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_MLT_OUTP"))) { |
|
923 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
924 if (sscanf((const char *)key, "%f", &val) == 1) |
|
925 unit->PID_mlt->OutP = val; |
|
926 xmlFree(key); |
|
927 } |
|
928 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PID_MLT_MODE"))) { |
|
929 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
930 for (i = 0; i < 3; i++) { |
|
931 if (! xmlStrcmp(key, (const xmlChar *)PIDMODE[i])) { |
|
932 unit->PID_mlt->Mode = i; |
|
933 break; |
|
934 } |
|
935 } |
|
936 xmlFree(key); |
|
937 } |
|
938 |
|
939 cur = cur->next; |
|
940 } |
|
941 |
|
942 if (Config.units == NULL) { |
|
943 Config.units = unit; |
|
944 } else { |
|
945 for (tmp = Config.units; tmp; tmp = tmp->next) { |
|
946 if (tmp->next == NULL) { |
|
947 tmp->next = unit; |
|
948 break; |
|
949 } |
|
950 } |
|
951 } |
|
952 |
|
953 return 0; |
|
954 } |
|
955 |
|
956 |
|
957 |
|
958 int parseBrewsystems(xmlDocPtr doc, xmlNodePtr cur) |
|
959 { |
|
960 cur = cur->xmlChildrenNode; |
|
961 while (cur != NULL) { |
|
962 if ((!xmlStrcmp(cur->name, (const xmlChar *)"BREWSYSTEM"))) { |
|
963 parseBrewsystem(doc, cur); |
|
964 } |
|
965 cur = cur->next; |
|
966 } |
|
967 return 0; |
|
968 } |
|
969 |
|
970 |
|
971 int parseDevice(xmlDocPtr doc, xmlNodePtr cur) |
|
972 { |
|
973 xmlChar *key; |
|
974 devices_list *device, *tmp; |
|
975 int i, ival; |
|
976 |
|
977 device = (devices_list *)malloc(sizeof(devices_list)); |
|
978 device->next = NULL; |
|
979 device->version = 1; |
|
980 device->uuid = device->address = device->description = device->comment = NULL; |
|
981 device->type = device->direction = device->present = device->subdevice = device->inuse = device->offset = 0; |
|
982 device->gpiopin = -1; |
|
983 device->timestamp = (time_t)0; |
|
984 |
|
985 cur = cur->xmlChildrenNode; |
|
986 while (cur != NULL) { |
|
987 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) { |
|
988 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
989 if (xmlStrcmp(key, (const xmlChar *)"1")) { |
|
990 xmlFree(key); |
|
991 return 1; |
|
992 } |
|
993 device->version = 1; |
|
994 xmlFree(key); |
|
995 } |
|
996 if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) { |
|
997 device->uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
998 } |
|
999 if ((!xmlStrcmp(cur->name, (const xmlChar *)"TYPE"))) { |
|
1000 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1001 for (i = 0; i < 8; i++) { |
|
1002 if (! xmlStrcmp(key, (const xmlChar *)DEVTYPE[i])) { |
|
1003 device->type = i; |
|
1004 break; |
|
1005 } |
|
1006 } |
|
1007 xmlFree(key); |
|
1008 } |
|
1009 if ((!xmlStrcmp(cur->name, (const xmlChar *)"DIRECTION"))) { |
|
1010 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1011 for (i = 0; i < 7; i++) { |
|
1012 if (! xmlStrcmp(key, (const xmlChar *)DEVDIR[i])) { |
|
1013 device->direction = i; |
|
1014 break; |
|
1015 } |
|
1016 } |
|
1017 xmlFree(key); |
|
1018 } |
|
1019 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VALUE"))) { |
|
1020 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1021 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
1022 device->value = ival; |
|
1023 xmlFree(key); |
|
1024 } |
|
1025 if ((!xmlStrcmp(cur->name, (const xmlChar *)"OFFSET"))) { |
|
1026 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1027 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
1028 device->offset = ival; |
|
1029 xmlFree(key); |
|
1030 } |
|
1031 if ((!xmlStrcmp(cur->name, (const xmlChar *)"PRESENT"))) { |
|
1032 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1033 for (i = 0; i < 4; i++) { |
|
1034 if (! xmlStrcmp(key, (const xmlChar *)DEVPRESENT[i])) { |
|
1035 device->present = i; |
|
1036 break; |
|
1037 } |
|
1038 } |
|
1039 xmlFree(key); |
|
1040 } |
|
1041 if ((!xmlStrcmp(cur->name, (const xmlChar *)"ADDRESS"))) { |
|
1042 device->address = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1043 } |
|
1044 if ((!xmlStrcmp(cur->name, (const xmlChar *)"SUBDEVICE"))) { |
|
1045 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1046 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
1047 device->subdevice = ival; |
|
1048 xmlFree(key); |
|
1049 } |
|
1050 if ((!xmlStrcmp(cur->name, (const xmlChar *)"GPIOPIN"))) { |
|
1051 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1052 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
1053 device->gpiopin = ival; |
|
1054 xmlFree(key); |
|
1055 } |
|
1056 if ((!xmlStrcmp(cur->name, (const xmlChar *)"DESCRIPTION"))) { |
|
1057 device->description = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1058 } |
|
1059 if ((!xmlStrcmp(cur->name, (const xmlChar *)"INUSE"))) { |
|
1060 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1061 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
1062 device->inuse = ival; |
|
1063 xmlFree(key); |
|
1064 } |
|
1065 if ((!xmlStrcmp(cur->name, (const xmlChar *)"COMMENT"))) { |
|
1066 device->comment = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1067 } |
|
1068 if ((!xmlStrcmp(cur->name, (const xmlChar *)"TIMESTAMP"))) { |
|
1069 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1070 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
1071 device->timestamp = (time_t)ival; |
|
1072 xmlFree(key); |
|
1073 } |
|
1074 |
|
1075 cur = cur->next; |
|
1076 } |
|
1077 |
|
1078 if (Config.devices == NULL) { |
|
1079 Config.devices = device; |
|
1080 } else { |
|
1081 for (tmp = Config.devices; tmp; tmp = tmp->next) { |
|
1082 if (tmp->next == NULL) { |
|
1083 tmp->next = device; |
|
1084 break; |
|
1085 } |
|
1086 } |
|
1087 } |
|
1088 |
|
1089 return 0; |
|
1090 } |
|
1091 |
|
1092 |
|
1093 |
|
1094 int parseDevices(xmlDocPtr doc, xmlNodePtr cur) |
|
1095 { |
|
1096 cur = cur->xmlChildrenNode; |
|
1097 while (cur != NULL) { |
|
1098 if ((!xmlStrcmp(cur->name, (const xmlChar *)"DEVICE"))) { |
|
1099 parseDevice(doc, cur); |
|
1100 } |
|
1101 cur = cur->next; |
|
1102 } |
|
1103 return 0; |
|
1104 } |
|
1105 |
|
1106 |
|
1107 |
|
1108 #ifdef USE_SIMULATOR |
|
1109 int parseSimulator(xmlDocPtr doc, xmlNodePtr cur) |
|
1110 { |
|
1111 xmlChar *key; |
|
1112 simulator_list *simulator, *tmp; |
|
1113 int ival; |
|
1114 float fval; |
|
1115 |
|
1116 simulator = (simulator_list *)malloc(sizeof(simulator_list)); |
|
1117 simulator->next = NULL; |
|
1118 simulator->version = 1; |
|
1119 simulator->uuid = simulator->name = NULL; |
|
1120 simulator->room_temperature = simulator->hlt_heater_temp = simulator->mlt_heater_temp = simulator->s_hlt_temp = simulator->s_mlt_temp = 20.0; |
|
1121 simulator->hlt_heater_temp = simulator->hlt_heater_size = simulator->mlt_heater_temp = simulator->mlt_heater_size = 0.0; |
|
1122 simulator->hlt_heater_time = simulator->mlt_heater_time = simulator->hlt_heater_state = simulator->mlt_heater_state = 0; |
|
1123 simulator->s_hlt_temp = simulator->s_mlt_temp = 0.0; |
|
1124 |
|
1125 cur = cur->xmlChildrenNode; |
|
1126 while (cur != NULL) { |
|
1127 if ((!xmlStrcmp(cur->name, (const xmlChar *)"VERSION"))) { |
|
1128 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1129 if (xmlStrcmp(key, (const xmlChar *)"1")) { |
|
1130 xmlFree(key); |
|
1131 return 1; |
|
1132 } |
|
1133 simulator->version = 1; |
|
1134 xmlFree(key); |
|
1135 } |
|
1136 if ((!xmlStrcmp(cur->name, (const xmlChar *)"UUID"))) { |
|
1137 simulator->uuid = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1138 } |
|
1139 if ((!xmlStrcmp(cur->name, (const xmlChar *)"NAME"))) { |
|
1140 simulator->name = (char *)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1141 } |
|
1142 if ((!xmlStrcmp(cur->name, (const xmlChar *)"ROOM_TEMPERATURE"))) { |
|
1143 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1144 if (sscanf((const char *)key, "%f", &fval) == 1) |
|
1145 simulator->room_temperature = fval; |
|
1146 xmlFree(key); |
|
1147 } |
|
1148 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HLT_TEMPERATURE"))) { |
|
1149 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1150 if (sscanf((const char *)key, "%f", &fval) == 1) |
|
1151 simulator->hlt_temperature = fval; |
|
1152 xmlFree(key); |
|
1153 } |
|
1154 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HLT_HEATER_TEMP"))) { |
|
1155 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1156 if (sscanf((const char *)key, "%f", &fval) == 1) |
|
1157 simulator->hlt_heater_temp = fval; |
|
1158 xmlFree(key); |
|
1159 } |
|
1160 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HLT_HEATER_TIME"))) { |
|
1161 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1162 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
1163 simulator->hlt_heater_time = ival; |
|
1164 xmlFree(key); |
|
1165 } |
|
1166 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HLT_HEATER_SIZE"))) { |
|
1167 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1168 if (sscanf((const char *)key, "%f", &fval) == 1) |
|
1169 simulator->hlt_heater_size = fval; |
|
1170 xmlFree(key); |
|
1171 } |
|
1172 if ((!xmlStrcmp(cur->name, (const xmlChar *)"HLT_HEATER_STATE"))) { |
|
1173 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1174 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
1175 simulator->hlt_heater_state = ival; |
|
1176 xmlFree(key); |
|
1177 } |
|
1178 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_TEMPERATURE"))) { |
|
1179 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1180 if (sscanf((const char *)key, "%f", &fval) == 1) |
|
1181 simulator->mlt_temperature = fval; |
|
1182 xmlFree(key); |
|
1183 } |
|
1184 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_HEATER_TEMP"))) { |
|
1185 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1186 if (sscanf((const char *)key, "%f", &fval) == 1) |
|
1187 simulator->mlt_heater_temp = fval; |
|
1188 xmlFree(key); |
|
1189 } |
|
1190 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_HEATER_TIME"))) { |
|
1191 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1192 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
1193 simulator->mlt_heater_time = ival; |
|
1194 xmlFree(key); |
|
1195 } |
|
1196 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_HEATER_SIZE"))) { |
|
1197 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1198 if (sscanf((const char *)key, "%f", &fval) == 1) |
|
1199 simulator->mlt_heater_size = fval; |
|
1200 xmlFree(key); |
|
1201 } |
|
1202 if ((!xmlStrcmp(cur->name, (const xmlChar *)"MLT_HEATER_STATE"))) { |
|
1203 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1204 if (sscanf((const char *)key, "%d", &ival) == 1) |
|
1205 simulator->mlt_heater_state = ival; |
|
1206 xmlFree(key); |
|
1207 } |
|
1208 if ((!xmlStrcmp(cur->name, (const xmlChar *)"S_HLT_TEMP"))) { |
|
1209 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1210 if (sscanf((const char *)key, "%f", &fval) == 1) |
|
1211 simulator->s_hlt_temp = fval; |
|
1212 xmlFree(key); |
|
1213 } |
|
1214 if ((!xmlStrcmp(cur->name, (const xmlChar *)"S_MLT_TEMP"))) { |
|
1215 key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); |
|
1216 if (sscanf((const char *)key, "%f", &fval) == 1) |
|
1217 simulator->s_mlt_temp = fval; |
|
1218 xmlFree(key); |
|
1219 } |
|
1220 cur = cur->next; |
|
1221 } |
|
1222 |
|
1223 if (Config.simulators == NULL) { |
|
1224 Config.simulators = simulator; |
|
1225 } else { |
|
1226 for (tmp = Config.simulators; tmp; tmp = tmp->next) { |
|
1227 if (tmp->next == NULL) { |
|
1228 tmp->next = simulator; |
|
1229 break; |
|
1230 } |
|
1231 } |
|
1232 } |
|
1233 |
|
1234 return 0; |
|
1235 } |
|
1236 |
|
1237 |
|
1238 |
|
1239 int parseSimulators(xmlDocPtr doc, xmlNodePtr cur) |
|
1240 { |
|
1241 cur = cur->xmlChildrenNode; |
|
1242 while (cur != NULL) { |
|
1243 if ((!xmlStrcmp(cur->name, (const xmlChar *)"SIMULATOR"))) { |
|
1244 parseSimulator(doc, cur); |
|
1245 } |
|
1246 cur = cur->next; |
|
1247 } |
|
1248 return 0; |
|
1249 } |
303 #endif |
1250 #endif |
304 |
1251 |
305 |
1252 |
306 |
1253 |
307 int rdconfig(void) |
1254 int rdconfig(void) |
308 { |
1255 { |
309 int rc = 0; |
1256 int ival, rc = 0; |
310 char *mypath; |
1257 char *mypath; |
311 xmlDocPtr doc; |
1258 xmlDocPtr doc; |
312 xmlNodePtr cur; |
1259 xmlNodePtr cur; |
313 xmlChar *key; |
1260 xmlChar *key; |
314 |
1261 |