Help screens for the commands are moved into the commands.

Sat, 27 Jun 2015 14:08:49 +0200

author
Michiel Broek <mbroek@mbse.eu>
date
Sat, 27 Jun 2015 14:08:49 +0200
changeset 380
75afd21885f2
parent 379
50675fd80fed
child 381
b22f8bf63b17

Help screens for the commands are moved into the commands.

thermferm/server.c file | annotate | diff | comparison | revisions
www-thermferm/liveview.php file | annotate | diff | comparison | revisions
--- a/thermferm/server.c	Sat Jun 27 12:52:04 2015 +0200
+++ b/thermferm/server.c	Sat Jun 27 14:08:49 2015 +0200
@@ -313,7 +313,7 @@
  */
 int cmd_archive(char *buf)
 {
-    char		*opt, *param, *name = NULL, *filename = NULL, mbits[11], tstr[24];
+    char		*opt, *param, *name = NULL, *filename = NULL, *logname = NULL, mbits[11], tstr[24];
     DIR			*dd;
     FILE		*fp;
     struct dirent	entry, *result;
@@ -321,6 +321,9 @@
     struct stat		sbuf;
     struct tm		*tbuf;
     time_t		ftime;
+    int			found;
+    units_list		*unit;
+
 
     opt = strtok(buf, " \0");
     opt = strtok(NULL, " \0");
@@ -361,7 +364,21 @@
 		if (result->d_name[0] != '.') {
 		    filename = xstrcpy(name);
 		    filename = xstrcat(filename, result->d_name);
-		    if ((stat(filename, &sbuf)) == 0) {
+		    /*
+		     * Remove files from the list when they are in use
+		     */
+		    found = 0;
+		    for (unit = Config.units; unit; unit = unit->next) {
+			if (unit->mode != UNITMODE_OFF) {
+			    logname = xstrcpy(unit->name);
+			    logname = xstrcat(logname, (char *)".log");
+			    if (! strcmp(result->d_name, logname))
+				found = 1;
+			    free(logname);
+			    logname = NULL;
+			}
+		    }
+		    if ((found == 0) && ((stat(filename, &sbuf)) == 0)) {
 		        fill_list(&lsx, result->d_name, sbuf.st_mode, sbuf.st_size, sbuf.st_mtime);
 		    }
 		    free(filename);
@@ -635,6 +652,18 @@
     }
     param = strtok(NULL, "\0");
 
+    if (strcmp(opt, (char *)"HELP") == 0) {
+	srv_send((char *)"100 Help text follows:");
+	srv_send((char *)"Recognized commands:");
+	srv_send((char *)"DEVICE ADD type               Add device (RC433/DHT/I2C/SPI)");
+	srv_send((char *)"DEVICE DEL uuid               Delete device by uuid");
+	srv_send((char *)"DEVICE LIST                   List all devices");
+	srv_send((char *)"DEVICE GET uuid               Read device by uuid parameters");
+	srv_send((char *)"DEVICE PUT uuid               Write device by uuid parameters");
+	srv_send((char *)".");
+	return 0;
+    }
+
     if (strcmp(opt, (char *)"LIST") == 0) {
 	srv_send((char *)"212 Devices list follows:");
 	for (device = Config.devices; device; device = device->next) {
@@ -942,6 +971,15 @@
 	return 1;
     }
 
+    if (strcmp(opt, (char *)"HELP") == 0) {
+	srv_send((char *)"100 Help text follows:");
+	srv_send((char *)"Recognized commands:");
+	srv_send((char *)"GLOBAL GET                    Get global settings");
+	srv_send((char *)"GLOBAL PUT                    Put global settings");
+	srv_send((char *)".");
+	return 0;
+    }
+
     if (strcmp(opt, (char *)"GET") == 0) {
 	srv_send((char *)"213 Global Settings record follows:");
 	srv_send((char *)"RELEASE,%s", VERSION);
@@ -1081,6 +1119,14 @@
 	srv_send((char *)".");
 	return 1;
 
+    } else if (strcmp(opt, (char *)"HELP") == 0) {
+	srv_send((char *)"100 Help text follows:");
+	srv_send((char *)"Recognized commands:");
+	srv_send((char *)"LIST                           List available units");
+	srv_send((char *)"LIST LOG uuid                  List logfile of unit by uuid");
+	srv_send((char *)".");
+	return 0;
+
     } else if (strcmp(opt, (char *)"LOG") == 0) {
 
 	param = strtok(NULL, "\0");
@@ -1224,6 +1270,21 @@
 	return 1;
     }
 
+    if (strcmp(opt, (char *)"HELP") == 0) {
+	srv_send((char *)"100 Help text follows:");
+	srv_send((char *)"Recognized commands:");
+	srv_send((char *)"PROFILE uuid,name             Profile rename");
+	srv_send((char *)"PROFILE ADD name              Add new Profile with name");
+	srv_send((char *)"PROFILE DEL uuid              Delete Profile by uuid");
+	srv_send((char *)"PROFILE LIST                  List available profiles");
+	srv_send((char *)"PROFILE GET uuid              Get Profile record by uuid");
+	srv_send((char *)"PROFILE PUT uuid              Put Profile record by uuid");
+	srv_send((char *)"PROFILE GETS uuid             Profile get steps list");
+	srv_send((char *)"PROFILE PUTS uuid             Profile put steps list");
+	srv_send((char *)".");
+	return 0;
+    }
+
     if (strcmp(opt, (char *)"LIST") == 0) {
 	/*
 	 * Fermenting profiles
@@ -1481,6 +1542,18 @@
     }
     param = strtok(NULL, "\0");
 
+    if (strcmp(opt, (char *)"HELP") == 0) {
+	srv_send((char *)"100 Help text follows:");
+	srv_send((char *)"Recognized commands:");
+	srv_send((char *)"SIMULATOR ADD name            Add a new Simulator with name");
+	srv_send((char *)"SIMULATOR DEL uuid            Delete Simulator by uuid");
+	srv_send((char *)"SIMULATOR LIST                List all Simulators");
+	srv_send((char *)"SIMULATOR GET uuid            Get Simulator record by uuid");
+	srv_send((char *)"SIMULATOR PUT uuid            Put Simulator record by uuid");
+	srv_send((char *)".");
+	return 0;
+    }
+
     if (strcmp(opt, (char *)"LIST") == 0) {
 	srv_send((char *)"212 Simulators list follows:");
 	for (simulator = Config.simulators; simulator; simulator = simulator->next) {
@@ -1846,6 +1919,18 @@
     }
     param = strtok(NULL, "\0");
 
+    if (strcmp(opt, (char *)"HELP") == 0) {
+	srv_send((char *)"100 Help text follows:");
+	srv_send((char *)"Recognized commands:");
+	srv_send((char *)"UNIT ADD name                 Add a new Unit with name");
+	srv_send((char *)"UNIT DEL uuid                 Delete Unit by uuid");
+	srv_send((char *)"UNIT LIST                     List all Units");
+	srv_send((char *)"UNIT GET uuid                 Get Unit record by uuid");
+	srv_send((char *)"UNIT PUT uuid                 Put Unit record by uuid");
+	srv_send((char *)".");
+	return 0;
+    }
+
     if ((strcmp(opt, (char *)"LIST") == 0) && (param == NULL)) {
 	srv_send((char *)"212 Fermenter list follows:");
 	for (unit = Config.units; unit; unit = unit->next) {
@@ -2459,36 +2544,21 @@
 //                                12345678901234567890123456789012345678901234567890123456789012345678901234567890
 		srv_send((char *)"ARCHIVE <CMD> [parameters]    Archive commands");
 		srv_send((char *)"ARCHIVE HELP                  Archive help screen");
-		srv_send((char *)"DEVICE ADD type               Add new Device type");
-		srv_send((char *)"DEVICE DEL uuid               Delete Device by uuid");
-		srv_send((char *)"DEVICE LIST                   List Devices");
-		srv_send((char *)"DEVICE GET uuid               Get Device record by uuid");
-		srv_send((char *)"DEVICE PUT uuid               Put Device record by uuid");
-		srv_send((char *)"GLOBAL GET                    Get global settings");
-		srv_send((char *)"GLOBAL PUT                    Put global settings");
-		srv_send((char *)"LIST                          List all fermenter units");
-		srv_send((char *)"LIST LOG uuid                 List logfile data graphsteps");
+		srv_send((char *)"DEVICE <CMD> [parameters]     Device commands");
+		srv_send((char *)"DEVICE HELP                   Device help screen");
+		srv_send((char *)"GLOBAL <CMD> [parameters]     Global commands");
+		srv_send((char *)"GLOBAL HELP                   Global help screen");
+		srv_send((char *)"LIST <CMD> [parameters]       List commands");
+		srv_send((char *)"LIST HELP                     List help screen");
 		srv_send((char *)"PING                          Check if server is alive");
-		srv_send((char *)"PROFILE uuid,name             Profile rename");
-		srv_send((char *)"PROFILE ADD name              Add new Profile with name");
-		srv_send((char *)"PROFILE DEL uuid              Delete Profile by uuid");
-		srv_send((char *)"PROFILE LIST                  List available profiles");
-		srv_send((char *)"PROFILE GET uuid              Get Profile record by uuid");
-		srv_send((char *)"PROFILE PUT uuid              Put Profile record by uuid");
-		srv_send((char *)"PROFILE GETS uuid             Profile get steps list");
-		srv_send((char *)"PROFILE PUTS uuid             Profile put steps list");
+		srv_send((char *)"PROFILE <CMD> [parameters]    Profile commands");
+		srv_send((char *)"PROFILE HELP                  Profile help screen");
 #ifdef USE_SIMULATOR
-		srv_send((char *)"SIMULATOR ADD name            Add a new Simulator with name");
-		srv_send((char *)"SIMULATOR DEL uuid            Delete Simulator by uuid");
-		srv_send((char *)"SIMULATOR LIST                List all Simulators");
-		srv_send((char *)"SIMULATOR GET uuid            Get Simulator record by uuid");
-		srv_send((char *)"SIMULATOR PUT uuid            Put Simulator record by uuid");
+		srv_send((char *)"SIMULATOR <CMD> [parameters]  Simulator commands");
+		srv_send((char *)"SIMULATOR HELP                Simulator help screen");
 #endif
-		srv_send((char *)"UNIT ADD name                 Add a new Unit with name");
-		srv_send((char *)"UNIT DEL uuid                 Delete Unit by uuid");
-		srv_send((char *)"UNIT LIST                     List all Units");
-		srv_send((char *)"UNIT GET uuid                 Get Unit record by uuid");
-		srv_send((char *)"UNIT PUT uuid                 Put Unit record by uuid");
+		srv_send((char *)"UNIT <CMD> [parameters]       Unit commands");
+		srv_send((char *)"UNIT HELP                     Unit help screen");
 		srv_send((char *)".");
 	    } else if (strncmp(buf, "LIST", 4) == 0) {
 		cmd_list(buf);
--- a/www-thermferm/liveview.php	Sat Jun 27 12:52:04 2015 +0200
+++ b/www-thermferm/liveview.php	Sat Jun 27 14:08:49 2015 +0200
@@ -134,7 +134,7 @@
 	$outstr .= '       });'.PHP_EOL;
 
 	$outstr .= '       var settings'.$unr.' = {'.PHP_EOL;
-	$outstr .= '         title: "'.$name.' history",'.PHP_EOL;
+	$outstr .= '         title: "'.$name.'",'.PHP_EOL;
 	$outstr .= '         description: "",'.PHP_EOL;
 	$outstr .= '         padding: { left: 5, top: 5, right: 5, bottom: 5 },'.PHP_EOL;
 	$outstr .= '         titlePadding: { left: 0, top: 0, right: 0, bottom: 10 },'.PHP_EOL;

mercurial