Fixed temperature logging, added some commands

Fri, 23 May 2014 14:09:07 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Fri, 23 May 2014 14:09:07 +0200
changeset 49
92a9ca143677
parent 48
d8c64f81b192
child 50
8b5e8f1e172d

Fixed temperature logging, added some commands

thermferm/server.c file | annotate | diff | comparison | revisions
thermferm/thermferm.c file | annotate | diff | comparison | revisions
--- a/thermferm/server.c	Thu May 22 13:54:52 2014 +0200
+++ b/thermferm/server.c	Fri May 23 14:09:07 2014 +0200
@@ -58,7 +58,7 @@
 
 
 
-void defaultControlsettings(void)
+void defaultControlSettings(void)
 {
 	cs_mode = 'o';		/* o = Off, f = fridge, b = beer, p = profile-run */
 	cs_beerSet = 20.0;
@@ -80,13 +80,6 @@
 
 
 
-void defaultControlVariables(void)
-{
-    cv_beerDiff = 0.0;
-}
-
-
-
 /*
  * Send message to client
  */
@@ -196,6 +189,12 @@
 			cs_mode, cs_beerSet, cs_fridgeSet, cs_heatEstimator, cs_coolEstimator);
 	    } else if (strncmp(buf, "getControlVariables", 19) == 0) {
 		srv_send("{ \"beerDiff\":%.2f }", cv_beerDiff);
+	    } else if (strncmp(buf, "loadDefaultControlSettings", 26) == 0) {
+		defaultControlSettings();
+		srv_send("ack");
+	    } else if (strncmp(buf, "loadDefaultControlConstants", 27) == 0) {
+		defaultControlConstants();
+		srv_send("ack");
 	    } else if (strncmp(buf, "setBeer=", 8) == 0) {
 		inp = xstrcpy(buf+8);
 		rc = sscanf(inp, "%f", &newtemp);
@@ -222,6 +221,11 @@
 		    srv_send("err");
 		}
 		free(inp);
+	    } else if (strncmp(buf, "setOff", 6) == 0) {
+		if (debug)
+		    fprintf(stdout, "temperature control disabled\n");
+		cs_mode = 'o';
+		srv_send("ack");
 	    } else {
 		if (debug)
 		    fprintf(stdout, "unknown command \"%s\"\n", buf);
--- a/thermferm/thermferm.c	Thu May 22 13:54:52 2014 +0200
+++ b/thermferm/thermferm.c	Fri May 23 14:09:07 2014 +0200
@@ -185,10 +185,6 @@
 	return 1;
     }
 
-//    defaultControlsettings();
-//        defaultControlConstants();
-//	    defaultControlVariables();
-
     lcdPosition(lcdHandle, 0, 0);
     sprintf(buf, "    Thermferm");
     mb_lcdPuts(lcdHandle, buf);
@@ -230,19 +226,6 @@
 			stopLCD();
 			exit(1);
 	    case 0:	/*
-			 * Setup shared memory for the parent process
-			 */
-//			syslog(LOG_NOTICE, "size %d", sizeof(struct _beer));
-//			if ((shmid = shmget(key, sizeof(struct _beer) + 16, IPC_CREAT | 0666)) < 0) {
-//			    syslog(LOG_NOTICE, "shmget: %s", strerror(errno));
-//			    exit(1);
-//			}
-//			beer = shmat(shmid, (void *)0, 0);
-//			if (beer == (void *)(-1)) {
-//			    syslog(LOG_NOTICE, "shmat: %s", strerror(errno));
-//			}
-
-			/*
 			 * Run the daemon
 			 */
 			fclose(stdin);
@@ -327,6 +310,10 @@
 	    sendRCswitch(tmp2->address, 1);
 	    lcdupdate = TRUE;
 	}
+	if (tmp1->update) {
+	    tmp1->update = FALSE;
+	    lcdupdate = TRUE;
+	}
 	old1 = tmp1->next;
 	tmp1 = old1;
 	old2 = tmp2->next;
@@ -343,6 +330,10 @@
 	    sendRCswitch(tmp2->address, 1);
 	    lcdupdate = TRUE;
 	}
+	if (tmp1->update) {
+	    tmp1->update = FALSE;
+	    lcdupdate = TRUE;
+	}
 
 	if (run && lcdupdate) {
 	    lcdPosition(lcdHandle, 0, 0);

mercurial