brewco/rdconfig.c

changeset 473
fdd30e935079
parent 465
3aac3276689d
--- a/brewco/rdconfig.c	Tue Dec 22 21:07:14 2015 +0100
+++ b/brewco/rdconfig.c	Sat Dec 26 21:45:44 2015 +0100
@@ -395,46 +395,46 @@
 	    }
 
             if (unit->PID_hlt) {
-                if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_KP", "%.2lf", unit->PID_hlt->dispKp)) < 0) {
+                if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_KP", "%lf", PID_getKp(unit->PID_hlt))) < 0) {
                     syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
                     return 1;
                 }
-                if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_KI", "%.2lf", unit->PID_hlt->dispKi)) < 0) {
+                if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_KI", "%lf", PID_getKi(unit->PID_hlt))) < 0) {
                     syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
                     return 1;
                 }
-                if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_KD", "%.2lf", unit->PID_hlt->dispKd)) < 0) {
+                if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_KD", "%lf", PID_getKd(unit->PID_hlt))) < 0) {
                     syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
                     return 1;
                 }
-		if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_SAMPLETIIME", "%ld", unit->PID_hlt->SampleTime)) < 0) {
+		if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_SAMPLETIME", "%d", PID_getSampleTime(unit->PID_hlt))) < 0) {
 		    syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
 		    return 1;
 		}
-                if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_DIRECTION", "%s", PIDDIRECTION[unit->PID_hlt->Direction])) < 0) {
+                if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_HLT_DIRECTION", "%s", PIDDIRECTION[PID_getDirection(unit->PID_hlt)])) < 0) {
                     syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
                     return 1;
                 }
             }
 
             if (unit->PID_mlt) {
-                if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_KP", "%.2lf", unit->PID_mlt->dispKp)) < 0) {
+                if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_KP", "%lf", PID_getKp(unit->PID_mlt))) < 0) {
                     syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
                     return 1;
                 }
-                if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_KI", "%.2lf", unit->PID_mlt->dispKi)) < 0) {
+                if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_KI", "%lf", PID_getKi(unit->PID_mlt))) < 0) {
                     syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
                     return 1;
                 }
-                if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_KD", "%.2lf", unit->PID_mlt->dispKd)) < 0) {
+                if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_KD", "%lf", PID_getKd(unit->PID_mlt))) < 0) {
                     syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
                     return 1;
                 }
-		if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_SAMPLETIIME", "%ld", unit->PID_mlt->SampleTime)) < 0) {
+		if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_SAMPLETIME", "%d", PID_getSampleTime(unit->PID_mlt))) < 0) {
 		    syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
 		    return 1;
 		}
-                if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_DIRECTION", "%s", PIDDIRECTION[unit->PID_mlt->Direction])) < 0) {
+                if ((rc = xmlTextWriterWriteFormatElement(writer, BAD_CAST "PID_MLT_DIRECTION", "%s", PIDDIRECTION[PID_getDirection(unit->PID_mlt)])) < 0) {
                     syslog(LOG_NOTICE, "wrconfig: error at xmlTextWriterWriteFormatElement");
                     return 1;
                 }
@@ -609,9 +609,6 @@
     mypath = xstrcpy(etcpath);
     mypath = xstrcat(mypath, (char *)"brewco.xml");
 
-    if (debug)
-	fprintf(stdout, "Writing %s\n", mypath);
-
     if ((fp = fopen(mypath, "w")) == NULL) {
 	syslog(LOG_NOTICE, "could not rewrite %s", mypath);
 	free(mypath);

mercurial