thermferm/server.c

changeset 219
ae720212accc
parent 217
2922d439ff63
child 223
14700edd2a67
--- a/thermferm/server.c	Mon Aug 11 12:34:49 2014 +0200
+++ b/thermferm/server.c	Mon Aug 11 18:38:57 2014 +0200
@@ -1268,7 +1268,28 @@
 			    } else if (val && (strcmp(kwd, (char *)"PROF_STATE") == 0)) {
 				for (i = 0; i < 5; i++) {
 				    if (strcmp(val, PROFSTATE[i]) == 0) {
-					unit->prof_state = i;
+					switch (i) {
+						case PROFILE_OFF:	if (unit->prof_state == PROFILE_DONE)
+									    unit->prof_state = PROFILE_OFF;
+									break;
+						case PROFILE_PAUSE:	if (unit->prof_state == PROFILE_RUN)
+									    unit->prof_state = PROFILE_PAUSE;
+									else if (unit->prof_state == PROFILE_PAUSE)
+									    unit->prof_state = PROFILE_RUN;
+									break;
+						case PROFILE_RUN:	if (unit->prof_state == PROFILE_OFF) {
+									    unit->prof_state = PROFILE_RUN;
+									    unit->prof_started = time(NULL);
+									    unit->prof_paused = 0;
+									}
+									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;
+									}
+									break;
+					}
 					break;
 				    }
 				}

mercurial