Added logging if profile state is changed via the web interface. Log profile progress each half hour in syslog. Profile resttime steps 0 hours is allowed, meaning resttime or steptime must be set for a valid step. Updated the helptext on the web page.

Mon, 01 Sep 2014 15:43:13 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Mon, 01 Sep 2014 15:43:13 +0200
changeset 274
111b0e9663dc
parent 273
b863e0147296
child 275
a86c702c2e4f

Added logging if profile state is changed via the web interface. Log profile progress each half hour in syslog. Profile resttime steps 0 hours is allowed, meaning resttime or steptime must be set for a valid step. Updated the helptext on the web page.

thermferm/server.c file | annotate | diff | comparison | revisions
thermferm/thermferm.c file | annotate | diff | comparison | revisions
www-thermferm/profiles.php file | annotate | diff | comparison | revisions
--- a/thermferm/server.c	Sun Aug 31 18:25:32 2014 +0200
+++ b/thermferm/server.c	Mon Sep 01 15:43:13 2014 +0200
@@ -1663,24 +1663,31 @@
 				for (i = 0; i < 5; i++) {
 				    if (strcmp(val, PROFSTATE[i]) == 0) {
 					switch (i) {
-						case PROFILE_OFF:	if (unit->prof_state == PROFILE_DONE)
+						case PROFILE_OFF:	if (unit->prof_state == PROFILE_DONE) {
 									    unit->prof_state = PROFILE_OFF;
+									    syslog(LOG_NOTICE, "Profile to OFF via web interface");
+									}
 									break;
-						case PROFILE_PAUSE:	if (unit->prof_state == PROFILE_RUN)
+						case PROFILE_PAUSE:	if (unit->prof_state == PROFILE_RUN) {
 									    unit->prof_state = PROFILE_PAUSE;
-									else if (unit->prof_state == PROFILE_PAUSE)
+									    syslog(LOG_NOTICE, "Profile PAUSE via web interface");
+									} else if (unit->prof_state == PROFILE_PAUSE) {
 									    unit->prof_state = PROFILE_RUN;
+									    syslog(LOG_NOTICE, "Profile RESUME via web interface");
+									}
 									break;
 						case PROFILE_RUN:	if (unit->prof_state == PROFILE_OFF) {
 									    unit->prof_state = PROFILE_RUN;
 									    unit->prof_started = time(NULL);
 									    unit->prof_paused = 0;
+									    syslog(LOG_NOTICE, "Profile to RUN via web interface");
 									}
 									break;
 						case PROFILE_DONE:	break;	/* Command is illegal */
 						case PROFILE_ABORT:	if ((unit->prof_state == PROFILE_RUN) || (unit->prof_state == PROFILE_PAUSE)) {
 									    unit->prof_state = PROFILE_OFF;
 									    unit->prof_started = 0;
+									    syslog(LOG_NOTICE, "Profile ABORT via web interface");
 									}
 									break;
 					}
--- a/thermferm/thermferm.c	Sun Aug 31 18:25:32 2014 +0200
+++ b/thermferm/thermferm.c	Mon Sep 01 15:43:13 2014 +0200
@@ -1166,12 +1166,17 @@
 						    previous_target = step->target;
 						}
 						if (debug)
-						    fprintf(stdout, " %s\n", valid_step ? "TRUE":"FALSE");
+						    fprintf(stdout, " %s %02d:%02d\n", valid_step ? "TRUE":"FALSE", minutes, seconds);
 
-						/*
-						 * No more steps to do
-						 */
-						if (valid_step == FALSE) {
+						if (valid_step == TRUE) {
+						    if (((minutes == 15) || (minutes == 45)) && (seconds == 1)) {
+						    	syslog(LOG_NOTICE, "Profile `%s' running %02d:%02d in step %d, target %.3f degrees", 
+									profile->name, run_hours, run_minutes % 60, current_step, unit->prof_target);
+						    }
+						} else {
+						    /*
+						     * No more steps to do
+						     */
 						    unit->prof_state = PROFILE_DONE;
 						    syslog(LOG_NOTICE, "Profile `%s' is done", profile->name);
 						}
--- a/www-thermferm/profiles.php	Sun Aug 31 18:25:32 2014 +0200
+++ b/www-thermferm/profiles.php	Mon Sep 01 15:43:13 2014 +0200
@@ -68,14 +68,14 @@
      * $steps contains all steps of a profile
      */
     $steps = array (
-	1  => array("steptime" => 0, "resttime" => 1, "target" => 20.0 ),
-	2  => array("steptime" => 0, "resttime" => 1, "target" => 20.0 ),
-	3  => array("steptime" => 0, "resttime" => 1, "target" => 20.0 ),
-	4  => array("steptime" => 0, "resttime" => 1, "target" => 20.0 ),
-	5  => array("steptime" => 0, "resttime" => 1, "target" => 20.0 ),
-	6  => array("steptime" => 0, "resttime" => 1, "target" => 20.0 ),
-	7  => array("steptime" => 0, "resttime" => 1, "target" => 20.0 ),
-	8  => array("steptime" => 0, "resttime" => 1, "target" => 20.0 ),
+	1  => array("steptime" => 0, "resttime" => 0, "target" => 20.0 ),
+	2  => array("steptime" => 0, "resttime" => 0, "target" => 20.0 ),
+	3  => array("steptime" => 0, "resttime" => 0, "target" => 20.0 ),
+	4  => array("steptime" => 0, "resttime" => 0, "target" => 20.0 ),
+	5  => array("steptime" => 0, "resttime" => 0, "target" => 20.0 ),
+	6  => array("steptime" => 0, "resttime" => 0, "target" => 20.0 ),
+	7  => array("steptime" => 0, "resttime" => 0, "target" => 20.0 ),
+	8  => array("steptime" => 0, "resttime" => 0, "target" => 20.0 ),
     );
 
     $answer = send_cmd("PROFILE GETS ".$UUID);
@@ -136,10 +136,11 @@
     $outstr .= '    </div> <!-- etable -->'.PHP_EOL;
     $outstr .= '    <div id="atable" style="margin-left: 100px; width:780px;">'.PHP_EOL;
     $outstr .= '    The steptime is the time to go from the previous to the target temperature.'.PHP_EOL;
-    $outstr .= '    The resttime is the total time in this step including the steptime.'.PHP_EOL;
-    $outstr .= '    Steps are valid if the steptime is greater then zero.'.PHP_EOL;
+    $outstr .= '    The resttime is the time in this step holding the target temperature.'.PHP_EOL;
+    $outstr .= '    The duration of the step is steptime + resttime.'.PHP_EOL;
+    $outstr .= '    Steps are valid if the steptime or resttime is greater then zero.'.PHP_EOL;
     $outstr .= '    Order is important.'.PHP_EOL;
-    $outstr .= '    Lines with a steptime of zero are ignored.'.PHP_EOL;
+    $outstr .= '    Lines with a zero steptime and zero resttime are ignored.'.PHP_EOL;
     $outstr .= '    The step- and resttimes are in hours.'.PHP_EOL;
     $outstr .= '    </div> <!-- atable -->'.PHP_EOL;
     $outstr .= build_footer();
@@ -214,7 +215,6 @@
  *
  * Return: 0 = Ok
  *         1 = Missing data
- *         2 = A resttime < steptime
  *         3 = A target temperature out of range
  *        99 = Cancel key
  */
@@ -235,8 +235,6 @@
             return 99;
 
 	for ($i = 1; $i <= 8; $i++) {
-	    if ($_POST['resttime'.$i] < $_POST['steptime'.$i])
-		return 2;
 
 	    if (($_POST['target'.$i] < -5) || ($_POST['target'.$i] > 30))
 		return 3;
@@ -269,7 +267,7 @@
 			 * the PHP side is line oriented, the server is reading blocks.
 			 * So we just send the data slowly and the server just sees lines.
 			 */
-			if ($_POST['steptime'.$i] > 0) {
+			if (($_POST['steptime'.$i] > 0) || ($_POST['resttime'.$i] > 0)) {
 			    usleep(20000);
 			    socket_write($sock, $_POST['steptime'.$i].','.$_POST['resttime'.$i].','.$_POST['target'.$i], 4096);
 			}

mercurial