Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.

Tue, 02 Sep 2014 14:10:37 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Tue, 02 Sep 2014 14:10:37 +0200
changeset 276
a19cc3770f09
parent 275
a86c702c2e4f
child 277
6f9a7cca8f19

Profile progress logging now also shows the percentage done. The DEVICE PUT command logs all changed values.

thermferm/server.c file | annotate | diff | comparison | revisions
thermferm/thermferm.c file | annotate | diff | comparison | revisions
--- a/thermferm/server.c	Mon Sep 01 22:06:39 2014 +0200
+++ b/thermferm/server.c	Tue Sep 02 14:10:37 2014 +0200
@@ -381,6 +381,8 @@
 			    if (strcmp(kwd, (char *)"TYPE") == 0) {
 				for (i = 0; i < 8; i++) {
 				    if (strcmp(val, DEVTYPE[i]) == 0) {
+					if (device->type != i)
+					    syslog(LOG_NOTICE, "Device %s changed type %s to %s", device->uuid, DEVTYPE[device->type], DEVTYPE[i]);
 					device->type = i;
 					break;
 				    }
@@ -389,48 +391,73 @@
 			    } else if (strcmp(kwd, (char *)"DIRECTION") == 0) {
 				for (i = 0; i < 7; i++) {
 				    if (strcmp(val, DEVDIR[i]) == 0) {
+					if (device->direction != i)
+					    syslog(LOG_NOTICE, "Device %s changed direction %s to %s", device->uuid, DEVDIR[device->type], DEVDIR[i]);
 					device->direction = i;
 					break;
 				    }
 				}
 
 			    } else if (strcmp(kwd, (char *)"VALUE") == 0) {
-				if (sscanf(val, "%d", &ival) == 1)
+				if (sscanf(val, "%d", &ival) == 1) {
+				    if (device->value != ival)
+					syslog(LOG_NOTICE, "Device %s changed value %d to %d", device->uuid, device->value, ival);
 				    device->value = ival;
+				}
 
 			    } else if (strcmp(kwd, (char *)"OFFSET") == 0) {
-				if (sscanf(val, "%d", &ival) == 1)
+				if (sscanf(val, "%d", &ival) == 1) {
+				    if (device->offset != ival)
+					syslog(LOG_NOTICE, "Device %s changed offset %d to %d", device->uuid, device->offset, ival);
 				    device->offset = ival;
+				}
 
 			    } else if (strcmp(kwd, (char *)"PRESENT") == 0) {
 				for (i = 0; i < 4; i++) {
 				    if (strcmp(val, DEVPRESENT[i]) == 0) {
+					if (device->present != i)
+					    syslog(LOG_NOTICE, "Device %s changed present %s to %s", device->uuid, DEVPRESENT[device->present], DEVPRESENT[i]);
 					device->present = i;
 				        break;
 				    }
 				}
 
 			    } else if (strcmp(kwd, (char *)"ADDRESS") == 0) {
-				if (device->address)
+				if (device->address) {
+				    if (strcmp(device->address, val))
+					syslog(LOG_NOTICE, "Device %s changed address %s to %s", device->uuid, device->address, val);
 				    free(device->address);
+				}
 				device->address = xstrcpy(val);
 
 			    } else if (strcmp(kwd, (char *)"SUBDEVICE") == 0) {
-				if (sscanf(val, "%d", &ival) == 1)
+				if (sscanf(val, "%d", &ival) == 1) {
+				    if (device->subdevice != ival)
+					syslog(LOG_NOTICE, "Device %s changed subdevice %d to %d", device->uuid, device->subdevice, ival);
 				    device->subdevice = ival;
+				}
 
 			    } else if (strcmp(kwd, (char *)"GPIOPIN") == 0) {
-				if (sscanf(val, "%d", &ival) == 1)
+				if (sscanf(val, "%d", &ival) == 1) {
+				    if (device->gpiopin != ival)
+					syslog(LOG_NOTICE, "Device %s changed gpiopin %d to %d", device->uuid, device->gpiopin, ival);
 				    device->gpiopin = ival;
+				}
 
 			    } else if (strcmp(kwd, (char *)"DESCRIPTION") == 0) {
-				if (device->description)
+				if (device->description) {
+				    if (strcmp(device->description, val))
+					syslog(LOG_NOTICE, "Device %s changed description %s to %s", device->uuid, device->description, val);
 				    free(device->description);
+				}
 				device->description = xstrcpy(val);
 
 			    } else if (strcmp(kwd, (char *)"COMMENT") == 0) {
-				if (device->comment)
+				if (device->comment) {
+				    if (strcmp(device->comment, val))
+					syslog(LOG_NOTICE, "Device %s changed comment %s to %s", device->uuid, device->comment, val);
 				    free(device->comment);
+				}
 				device->comment = xstrcpy(val);
 
 			    }
--- a/thermferm/thermferm.c	Mon Sep 01 22:06:39 2014 +0200
+++ b/thermferm/thermferm.c	Tue Sep 02 14:10:37 2014 +0200
@@ -833,7 +833,7 @@
     profiles_list	*profile;
     prof_step		*step;
     int			rc, run = 1, seconds = 0, minutes = 0, piddelay = 0, temp, deviation;
-    int			run_seconds, run_minutes, run_hours;
+    int			run_seconds, run_minutes, run_hours, tot_minutes;
     float		err = 0.0, sp, pv, P_err, D_err, Out;
 #ifdef HAVE_WIRINGPI_H
     struct tm		*tm;
@@ -1125,8 +1125,7 @@
 						 * When all done, set state to PROFILE_DONE.
 						 */
 						previous_target = profile->inittemp;
-						time_until_now = 0;
-						current_step = 0;
+						time_until_now = current_step = tot_minutes = 0;
 						run_seconds = (int)(now - unit->prof_started - unit->prof_paused);
 						run_minutes = run_seconds / 60;
 						run_hours = run_minutes / 60;
@@ -1141,6 +1140,7 @@
 						     * step->target
 						     */
 						    current_step++;
+						    tot_minutes += ((step->steptime + step->resttime) * 60);
 						    if ((run_hours >= time_until_now) && (run_hours < (time_until_now + step->steptime + step->resttime))) {
 							/*
 							 * This is our current step
@@ -1169,9 +1169,10 @@
 						    fprintf(stdout, " %s %02d:%02d\n", valid_step ? "TRUE":"FALSE", minutes, seconds);
 
 						if (valid_step == TRUE) {
-						    if (((minutes == 15) || (minutes == 45)) && (seconds == 1)) {
-						    	syslog(LOG_NOTICE, "Profile `%s' running %dd %02d:%02d in step %d, target %.3f degrees", 
-								profile->name, run_hours / 24, run_hours % 24, run_minutes % 60, current_step, unit->prof_target);
+						    if (((minutes == 10) || (minutes == 40)) && (seconds == 1)) {
+						    	syslog(LOG_NOTICE, "Profile `%s' running %dd %02d:%02d in step %d, %d%% done, target %.3f degrees", 
+								profile->name, run_hours / 24, run_hours % 24, run_minutes % 60, current_step, 
+								(100 * run_minutes) / tot_minutes, unit->prof_target);
 						    }
 						} else {
 						    /*

mercurial