Removed ws_global function because dynamic menus don't work.

Thu, 21 May 2020 14:32:23 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Thu, 21 May 2020 14:32:23 +0200
changeset 686
ca1fbb3bd3db
parent 685
a4fcdf24b5e7
child 687
93ea9572c780

Removed ws_global function because dynamic menus don't work.

bmsd/co2meters.c file | annotate | diff | comparison | revisions
bmsd/fermenters.c file | annotate | diff | comparison | revisions
bmsd/ispindels.c file | annotate | diff | comparison | revisions
bmsd/nodes.c file | annotate | diff | comparison | revisions
bmsd/nodes.h file | annotate | diff | comparison | revisions
--- a/bmsd/co2meters.c	Thu May 21 14:27:56 2020 +0200
+++ b/bmsd/co2meters.c	Thu May 21 14:32:23 2020 +0200
@@ -188,7 +188,7 @@
 {
     struct json_object	*jobj, *val, *sensor;
     sys_co2meter_list	*co2meter, *tmpp;
-    bool		new_co2meter = true, report = false;
+    bool		new_co2meter = true;
 
 //    fprintf(stdout, "co2meter_set: %s/%s %s\n", edge_node, alias, payload);
 
@@ -220,7 +220,6 @@
 
     if (! co2meter->online) {
     	co2meter->online = true;
-	report = true;
     	syslog(LOG_NOTICE, "Online co2meter %s/%s mode %s", edge_node, alias, co2meter->mode);
     }
 
@@ -302,9 +301,6 @@
     } else {
 	co2meter_mysql_update(co2meter);
     }
-
-    if (report)
-	status_change();
 }
 
 
--- a/bmsd/fermenters.c	Thu May 21 14:27:56 2020 +0200
+++ b/bmsd/fermenters.c	Thu May 21 14:32:23 2020 +0200
@@ -722,7 +722,6 @@
     } else {
 	fermenter_mysql_update(fermenter);
     }
-    status_change();
 }
 
 
@@ -1060,7 +1059,6 @@
 {
     char		*edge_node, *alias, *msg = NULL;
     sys_fermenter_list	*tmpp;
-    bool		report = false;
 
     printf("fermenter_death: %s\n", topic);
     strtok(topic, "/"); // ignore namespace
@@ -1085,7 +1083,6 @@
 		    ws_broadcast(msg);
     		    free(msg);
     		    msg = NULL;
-		    report = true;
 		}
 	    	break;
 	    }
@@ -1104,13 +1101,10 @@
                     ws_broadcast(msg);
                     free(msg);
                     msg = NULL;
-		    report = true;
 		}
 	    }
 	}
     }
-    if (report)
-	status_change();
 }
 
 
--- a/bmsd/ispindels.c	Thu May 21 14:27:56 2020 +0200
+++ b/bmsd/ispindels.c	Thu May 21 14:32:23 2020 +0200
@@ -202,7 +202,7 @@
 {
     sys_ispindel_list	*ispindel, *tmpp;
     struct json_object  *jobj, *metric, *val;
-    bool		new_ispindel = true, report = false;
+    bool		new_ispindel = true;
     char		*datetime, buf[65], *line, *logfile;
     struct tm           *mytime;
     time_t              timestamp;
@@ -238,7 +238,6 @@
 
     if (! ispindel->online) {
     	ispindel->online = true;
-	report = true;
     	syslog(LOG_NOTICE, "Online ispindel %s mode %s", node, ispindel->mode);
     }
 
@@ -295,8 +294,6 @@
 	ispindel_mysql_update(ispindel);
     }
     ispindel_ws_send(ispindel);
-    if (report)
-	status_change();
 
     /*
      * The data is complete, see if we can write a log entry.
--- a/bmsd/nodes.c	Thu May 21 14:27:56 2020 +0200
+++ b/bmsd/nodes.c	Thu May 21 14:32:23 2020 +0200
@@ -294,14 +294,12 @@
     sys_ispindel_list	*tmpi;
     time_t		now = time(NULL);
     char		*msg = NULL;
-    bool		report = false;
 
     for (tmpn = nodes; tmpn; tmpn = tmpn->next) {
 //	if (debug)
 //	    printf("%-20s online %s  %ld  %d\n", tmpn->node, tmpn->online ? "yes":"no ", tmpn->lastseen, tmpn->interval);
 	if (tmpn->online && ((now - tmpn->lastseen) > (tmpn->interval * 2 + 5))) { // 2 times interval + 5 seconds
 	    syslog(LOG_NOTICE, "Timeout node `%s/%s' after %ld seconds", tmpn->group_id, tmpn->node, (now - tmpn->lastseen));
-	    report = true;
 	    tmpn->online = false;
 	    node_mysql_death(tmpn->node);
 	    msg = xstrcpy((char *)"{\"node\":\"");
@@ -372,93 +370,7 @@
 	    }
 	}
     }
-
-    if (report)
-	status_change();
 }
 
 
 
-void status_change(void)
-{
-    sys_node_list       *tmpn;
-    sys_fermenter_list  *tmpf;
-    sys_co2meter_list   *tmpc;
-    sys_ispindel_list   *tmpi;
-    char                *msg = NULL;
-    bool                comma = false;
-
-    msg = xstrcpy((char *)"{\"status\":{\"nodes\":[");
-
-    for (tmpn = nodes; tmpn; tmpn = tmpn->next) {
-	if (comma)
-	    msg = xstrcat(msg, (char *)",");
-	comma = true;
-	msg = xstrcat(msg, (char *)"{\"uuid\":\"");
-	msg = xstrcat(msg, tmpn->uuid);
-	msg = xstrcat(msg, (char *)"\",\"node\":\"");
-	msg = xstrcat(msg, tmpn->node);
-	msg = xstrcat(msg, (char *)"\",\"online\":");
-	msg = xstrcat(msg, (tmpn->online) ? (char *)"1":(char *)"0");
-	msg = xstrcat(msg, (char *)"}");
-    }
-
-    msg = xstrcat(msg, (char *)"],\"fermenters\":[");
-    comma = false;
-    for (tmpf = fermenters; tmpf; tmpf = tmpf->next) {
-	if (comma)
-            msg = xstrcat(msg, (char *)",");
-        comma = true;
-	msg = xstrcat(msg, (char *)"{\"uuid\":\"");
-        msg = xstrcat(msg, tmpf->uuid);
-        msg = xstrcat(msg, (char *)"\",\"node\":\"");
-        msg = xstrcat(msg, tmpf->node);
-        msg = xstrcat(msg, (char *)"\",\"unit\":\"");
-        msg = xstrcat(msg, tmpf->alias);
-        msg = xstrcat(msg, (char *)"\",\"online\":");
-        msg = xstrcat(msg, (tmpf->online) ? (char *)"1":(char *)"0");
-        msg = xstrcat(msg, (char *)"}");
-    }
-
-    msg = xstrcat(msg, (char *)"],\"co2meters\":[");
-    comma = false;
-    for (tmpc = co2meters; tmpc; tmpc = tmpc->next) {
-	if (comma)
-            msg = xstrcat(msg, (char *)",");
-        comma = true;
-        msg = xstrcat(msg, (char *)"{\"uuid\":\"");
-        msg = xstrcat(msg, tmpc->uuid);
-        msg = xstrcat(msg, (char *)"\",\"node\":\"");
-        msg = xstrcat(msg, tmpc->node);
-        msg = xstrcat(msg, (char *)"\",\"unit\":\"");
-        msg = xstrcat(msg, tmpc->alias);
-        msg = xstrcat(msg, (char *)"\",\"online\":");
-        msg = xstrcat(msg, (tmpc->online) ? (char *)"1":(char *)"0");
-        msg = xstrcat(msg, (char *)"}");
-    }
-
-    msg = xstrcat(msg, (char *)"],\"ispindels\":[");
-    comma = false;
-    for (tmpi = ispindels; tmpi; tmpi = tmpi->next) {
-	if (comma)
-            msg = xstrcat(msg, (char *)",");
-        comma = true;
-        msg = xstrcat(msg, (char *)"{\"uuid\":\"");
-        msg = xstrcat(msg, tmpi->uuid);
-        msg = xstrcat(msg, (char *)"\",\"node\":\"");
-        msg = xstrcat(msg, tmpi->node);
-        msg = xstrcat(msg, (char *)"\",\"unit\":\"");
-        msg = xstrcat(msg, tmpi->alias);
-        msg = xstrcat(msg, (char *)"\",\"online\":");
-        msg = xstrcat(msg, (tmpi->online) ? (char *)"1":(char *)"0");
-        msg = xstrcat(msg, (char *)"}");
-    }
-
-    msg = xstrcat(msg, (char *)"]}}");
-//    syslog(LOG_NOTICE, msg);
-    ws_broadcast(msg);
-    free(msg);
-    msg = NULL;
-}
-
-
--- a/bmsd/nodes.h	Thu May 21 14:27:56 2020 +0200
+++ b/bmsd/nodes.h	Thu May 21 14:32:23 2020 +0200
@@ -27,9 +27,4 @@
  */
 void nodes_check_online(void);
 
-/**
- * @brief Report status change of nodes so that the client menus are updated.
- */
-void status_change(void);
-
 #endif

mercurial