Changeset: 0ba21f54fef4 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0ba21f54fef4
Modified Files:
        sql/backends/monet5/datacell/actuator.mx
        sql/backends/monet5/datacell/receptor.mx
        sql/backends/monet5/datacell/sensor.mx
Branch: default
Log Message:

Fixing the sensor/actuators
Mostly debugging related patches.


diffs (truncated from 590 to 300 lines):

diff --git a/sql/backends/monet5/datacell/actuator.mx 
b/sql/backends/monet5/datacell/actuator.mx
--- a/sql/backends/monet5/datacell/actuator.mx
+++ b/sql/backends/monet5/datacell/actuator.mx
@@ -21,9 +21,10 @@
 @verbatim
 actuator [options]
        --host=<host name> default localhost
-       --port=<portnr> 
+       --port=<portnr>  default 50600
        --actuator=<actuator name> 
-       --server=<0 1> 
+       --server 
+       --client 
        --latency=<0 or 1>
        --timestamp=<0 or 1>
 @end verbatim
@@ -91,18 +92,19 @@
        mnstr_printf(ACout, "Several options are provided to control this 
process.\n");
        mnstr_printf(ACout, "\nactuator [options]\n");
        mnstr_printf(ACout, "--host=<host name>, default localhost\n");
-       mnstr_printf(ACout, "--port=<portnr> \n");
+       mnstr_printf(ACout, "--port=<portnr>, default 50600 \n");
        mnstr_printf(ACout, "--actuator=<actuator name> \n");
        mnstr_printf(ACout, "--timestamp=<0 or 1>  default=1\n");
-       mnstr_printf(ACout, "--server=<0 or 1>  default=0\n");
+       mnstr_printf(ACout, "--server  default\n");
+       mnstr_printf(ACout, "--client  default\n");
        mnstr_printf(ACout, "--statistics=<0 or 1>  default=1\n");
        exit(-1);
 }
 
 static char *host = "localhost";
-static int port = 50000;
+static int port = 50600;
 static char *actuator = "X";
-static int server = 0;
+static int server = 1;
 static int trace = 0;
 static int stamp = 1; /* first column is a timestamp*/
 
@@ -183,14 +185,16 @@
        int i, j = 0;
        char *err = NULL;
        char name[MYBUFSIZ + 1];
+       char hostname[1024];
        static SOCKET sockfd;
        Actuator ac = NULL;
        int option_index = 0;
 
-       static struct option long_options[11] = {
+       static struct option long_options[12] = {
                { "port", 1, 0, 'p' },
                { "actuator", 1, 0, 'a' },
-               { "server", 1, 0, 's' },
+               { "client", 0, 0, 'c' },
+               { "server", 0, 0, 's' },
                { "statistics", 1, 0, 'S' },
                { "sequence", 1, 0, 's' },
                { "batch", 1, 0, 'b' },
@@ -208,7 +212,7 @@
 
        for (;; ) {
                /*      int option_index=0;*/
-               int c = getopt_long(argc, argv, "a:p:s:S:b:h:?:t:0", 
long_options, &option_index);
+               int c = getopt_long(argc, argv, "a:c:p:s:S:b:h:?:t:0", 
long_options, &option_index);
 
                if (c == -1)
                        break;
@@ -230,6 +234,12 @@
                case 'b':
                        batchsize = atol(optarg);
                        break;
+               case 'c':
+                       if (strcmp(long_options[option_index].name, "client") 
== 0) {
+                               server = 0;
+                               break;
+                       }
+                       break;
                case 'a':
                        actuator = optarg;
                        break;
@@ -239,7 +249,7 @@
                                break;
                        }
                        if (strcmp(long_options[option_index].name, "server") 
== 0) {
-                               server = atol(optarg);
+                               server = 1;
                                break;
                        } else {
                                usage();
@@ -284,6 +294,10 @@
                mnstr_printf(ACout, "--sequence=%d\n", sequence);
                mnstr_printf(ACout, "--batch=%d\n", batchsize);
        }
+    strncpy(hostname,host,1024);
+    if ( strcmp(host,"localhost")== 0 )
+        gethostname(hostname,1024);
+    host= hostname;
 
        if (protocol == UDP) {
                ac = ACnew(actuator);
diff --git a/sql/backends/monet5/datacell/receptor.mx 
b/sql/backends/monet5/datacell/receptor.mx
--- a/sql/backends/monet5/datacell/receptor.mx
+++ b/sql/backends/monet5/datacell/receptor.mx
@@ -273,7 +273,7 @@
        rc->table.nr_attrs = j;
 
 #ifdef _DEBUG_RECEPTOR_
-       mnstr_printf(RCout, "Instantiate a new receptor %d fields\n", j);
+       mnstr_printf(RCout, "#Instantiate a new receptor %d fields\n", j);
 #endif
        (void)ret;
        rc->status = RCLISTEN;
@@ -295,7 +295,7 @@
        rc->status = RCPAUSE;
 
 #ifdef _DEBUG_RECEPTOR_
-       mnstr_printf(RCout, "Pause a receptor\n");
+       mnstr_printf(RCout, "#Pause a receptor\n");
 #endif
        (void)ret;
        return MAL_SUCCEED;
@@ -313,7 +313,7 @@
        rc->status = RCLISTEN;
 
 #ifdef _DEBUG_RECEPTOR_
-       mnstr_printf(RCout, "Pause a receptor\n");
+       mnstr_printf(RCout, "#Resume a receptor\n");
 #endif
        (void)ret;
        return MAL_SUCCEED;
@@ -327,7 +327,7 @@
        if (rc == NULL)
                throw(MAL, "receptor.drop", "Receptor not defined");
 #ifdef _DEBUG_RECEPTOR_
-       mnstr_printf(RCout, "Drop a receptor\n");
+       mnstr_printf(RCout, "#Drop a receptor\n");
 #endif
        (void)ret;
        if (rcAnchor == rc)
@@ -351,7 +351,7 @@
        if (rc == NULL)
                throw(MAL, "receptor.scenario", "Receptor not defined");
 #ifdef _DEBUG_RECEPTOR_
-       mnstr_printf(RCout, "Define receptor scenario\n");
+       mnstr_printf(RCout, "#Define receptor scenario\n");
 #endif
        (void)ret;
        rc->scenario = GDKstrdup(*fname);
@@ -366,7 +366,7 @@
        if (rc == NULL)
                throw(MAL, "receptor.generator", "Receptor not defined");
 #ifdef _DEBUG_RECEPTOR_
-       mnstr_printf(RCout, "Define receptor generator\n");
+       mnstr_printf(RCout, "#Define receptor generator\n");
 #endif
        (void)ret;
        rc->modnme = GDKstrdup(*modnme);
@@ -394,7 +394,7 @@
                if (protocol == TCP)
                        rc->error = socket_client_connect(&rc->newsockfd, 
rc->host, rc->port);
                if (rc->error) {
-                       mnstr_printf(RCout, "Receptor connect fails: %s\n", 
rc->error);
+                       mnstr_printf(RCout, "#Receptor connect fails: %s\n", 
rc->error);
                        MT_sleep_ms(rc->delay);
                }
        } while (rc->error);
@@ -427,10 +427,10 @@
        rc->receptor = socket_rastream(rc->newsockfd, rc->name);
        if (rc->receptor == NULL) {
                perror("Receptor: Could not open stream");
-               mnstr_printf(RCout, "stream %s.%d.%s\n", rc->host, rc->port, 
rc->name);
+               mnstr_printf(RCout, "#stream %s.%d.%s\n", rc->host, rc->port, 
rc->name);
                socket_close(rc->newsockfd);
 #ifdef _DEBUG_RECEPTOR_
-               mnstr_printf(RCout, "Terminate RCbody loop\n");
+               mnstr_printf(RCout, "#Terminate RCbody loop\n");
 #endif
                return;
        }
@@ -445,7 +445,7 @@
        {
                while (rc->status == RCPAUSE) {
 #ifdef _DEBUG_RECEPTOR_
-                       mnstr_printf(RCout, "pause receptor\n");
+                       mnstr_printf(RCout, "#pause receptor\n");
 #endif
                        MT_sleep_ms(rc->delay);
                }
@@ -466,8 +466,7 @@
                }
 
 #ifdef _DEBUG_RECEPTOR_
-               mnstr_printf(RCout, "wait for data\n");
-               mnstr_printf(RCout, "\nI will read m: %d\n", m);
+               mnstr_printf(RCout, "#wait for data read m: %d\n", m);
 #endif
 
 /*Batch Processing
@@ -483,9 +482,7 @@
                        BSKTlock(&rc->lck, &rc->schema, &rc->name, &rc->delay);
                        buf[n + 1] = 0;
 #ifdef _DEBUG_RECEPTOR_
-                       mnstr_printf(RCout, "\nLOCK\n");
-                       mnstr_printf(RCout, "Receptor buf [%d]:%s \n", n, buf);
-                       mnstr_printf(RCout, "\nEND of buf!\n");
+                       mnstr_printf(RCout, "#Receptor buf [%d]:%s \n", n, buf);
 #endif
                        m = 0;
                        /* use trivial concurrency measure */
@@ -502,7 +499,7 @@
                                if ((n = (int)mnstr_readline(rc->receptor, buf, 
MYBUFSIZ)) > 0) {
                                        buf[n + 1] = 0;
 #ifdef _DEBUG_RECEPTOR_
-                                       mnstr_printf(RCout, "Receptor buf 
[%d]:%s \n", n, buf);
+                                       mnstr_printf(RCout, "#Receptor buf 
[%d]:%s \n", n, buf);
 #endif
                                        if (rc->status != RCLISTEN)
                                                break;
@@ -510,15 +507,15 @@
                                                line = buf;
                                                e = strchr(line, '\n');
                                                if (e == 0) {
-                                                       mnstr_printf(RCout, 
"unfinished line %d %d :%s \n", m, n, line);
+                                                       mnstr_printf(RCout, 
"#unfinished line %d %d :%s \n", m, n, line);
                                                        break;
                                                }
                                                *e = 0;
 #ifdef _DEBUG_RECEPTOR_
-                                               mnstr_printf(RCout, "insert 
line :%s \n", line);
+                                               mnstr_printf(RCout, "#insert 
line :%s \n", line);
 #endif
                                                if (insert_line(&rc->table, 
line, NULL, 0, rc->table.nr_attrs) < 0) {
-                                                       mnstr_printf(RCout, 
"\nfailed insert_line %s\n", line);
+                                                       mnstr_printf(RCout, 
"#failed insert_line %s\n", line);
                                                        break;
                                                }
                                                rc->received++;
@@ -529,9 +526,6 @@
                                cnt++;
                        }
                        BSKTunlock(&rc->lck, &rc->schema, &rc->name);
-#ifdef _DEBUG_RECEPTOR_
-                       mnstr_printf(RCout, "\nUNLOCK\n");
-#endif
                        if (rc->table.error) {
                                mnstr_printf(GDKerr, rc->table.error);
                                rc->table.error = 0;
@@ -546,7 +540,7 @@
                goto bodyRestart;
        }
 #ifdef _DEBUG_RECEPTOR_
-       mnstr_printf(RCout, "Terminate RCbody loop\n");
+       mnstr_printf(RCout, "#Terminate RCbody loop\n");
 #endif
 }
 @-
@@ -570,7 +564,7 @@
                return;
        }
 #ifdef _DEBUG_RECEPTOR_
-       mnstr_printf(RCout, "Execute the scenario '%s'\n", rc->scenario);
+       mnstr_printf(RCout, "#Execute the scenario '%s'\n", rc->scenario);
 #endif
 
        snr = 0;
@@ -597,7 +591,7 @@
                                MT_sleep_ms(rc->delay);
                        }
 #ifdef _DEBUG_RECEPTOR_
-                       mnstr_printf(RCout, "%s", tuple);
+                       mnstr_printf(RCout, "#%s", tuple);
 #endif
                        do {
                                tick = usec();
@@ -687,7 +681,7 @@
        GDKprotect();
 
 #ifdef _DEBUG_RECEPTOR_
-       mnstr_printf(RCout, "Receptor body %s starts at %s:%d\n", rc->name, 
rc->host, rc->port);
+       mnstr_printf(RCout, "#Receptor body %s starts at %s:%d\n", rc->name, 
rc->host, rc->port);
 #endif
        if (protocol == UDP) {
                rc->receptor = udp_rastream(rc->host, rc->port, rc->name);
@@ -698,14 +692,14 @@
                }
                RCbody(rc);
 #ifdef _DEBUG_RECEPTOR_
-               mnstr_printf(RCout, "End of receptor thread\n");
+               mnstr_printf(RCout, "#End of receptor thread\n");
 #endif
                return NULL;
        }
 
        /* Handle the TCP protocol */
 #ifdef _DEBUG_RECEPTOR_
-       mnstr_printf(RCout, "Start the receptor thread, protocol=%d\n", 
rc->protocol);
+       mnstr_printf(RCout, "#Start the receptor thread, protocol=%d\n", 
rc->protocol);
 #endif
        if (rc->protocol == RCPASSIVE &&
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to