Changeset: 19458ff5eadb for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=19458ff5eadb
Modified Files:
        sql/backends/monet5/datacell/actuator.c
        sql/backends/monet5/datacell/basket.c
        sql/backends/monet5/datacell/datacell.c
        sql/backends/monet5/datacell/dcoperator.c
        sql/backends/monet5/datacell/dcsocket.c
        sql/backends/monet5/datacell/emitter.c
        sql/backends/monet5/datacell/opt_datacell.c
        sql/backends/monet5/datacell/petrinet.c
        sql/backends/monet5/datacell/receptor.c
        sql/backends/monet5/datacell/sensor.c
Branch: Jul2012
Log Message:

datacell: uncrustify


diffs (truncated from 3895 to 300 lines):

diff --git a/sql/backends/monet5/datacell/actuator.c 
b/sql/backends/monet5/datacell/actuator.c
--- a/sql/backends/monet5/datacell/actuator.c
+++ b/sql/backends/monet5/datacell/actuator.c
@@ -19,10 +19,10 @@
 
 /*
  * @a M. Kersten, E. Liarou, R. Goncalves
-The Actuator Simulation program
+   The Actuator Simulation program
 
-This program listens to an event stream on a particular port.
-It collects statistics on the events.
+   This program listens to an event stream on a particular port.
+   It collects statistics on the events.
  * @f actuator
  */
 #ifndef ACTUATOR
@@ -68,7 +68,7 @@ static Actuator
 ACnew(str nme)
 {
        Actuator ac;
-       ac = (Actuator)GDKzalloc(sizeof(ACrecord));
+       ac = (Actuator) GDKzalloc(sizeof(ACrecord));
        ac->name = GDKstrdup(nme);
        ac->nxt = acAnchor;
        acAnchor = ac;
@@ -84,25 +84,29 @@ static int protocol = TCP;
 static int mode = PASSIVE;
 
 /*
-The actuator.
-Events leave the Datacell to trigger actions in the real world. It may be as 
simple 
-as being displayed on a screen, upto and including calling the mergency 
fighters
-by telephone. Since, the mapping from event message to real world action is 
situation
-specific, the default provided here is to only show the event message.
+   The actuator.  Events leave the Datacell to trigger actions in the
+   real world. It may be as simple as being displayed on a screen, upto
+   and including calling the mergency fighters by telephone. Since, the
+   mapping from event message to real world action is situation
+   specific, the default provided here is to only show the event
+   message.
 
-Users interested in experimentation with real actuators, can hook up the event
-stream with a SCADA system or directly send the events in a proper format to
-the channel where the actuators is listening.
+   Users interested in experimentation with real actuators, can hook up
+   the event stream with a SCADA system or directly send the events in a
+   proper format to the channel where the actuators is listening.
 
-The actuator runs in two modes, active or passive. In the former case, the tool
-contacts the server and establishes an UDF channel to pass CSV encoded event 
strings.
-Optionally, the event can be tagged with a serial key and a time-stamp.
+   The actuator runs in two modes, active or passive. In the former
+   case, the tool contacts the server and establishes an UDF channel to
+   pass CSV encoded event strings.  Optionally, the event can be tagged
+   with a serial key and a time-stamp.
 
-Events are generated using a built-in random number generator. They are sent 
over the
-channel with an optional delay, expressed in number of microseconds.
+   Events are generated using a built-in random number generator. They
+   are sent over the channel with an optional delay, expressed in number
+   of microseconds.
 
-The code is relatively straightforward to extend to create your favoured dummy 
sensor.
-*/
+   The code is relatively straightforward to extend to create your
+   favoured dummy sensor.
+ */
 static void
 usage(void)
 {
@@ -114,8 +118,8 @@ usage(void)
        mnstr_printf(ACout, "--port=<portnr>, default 50600 \n");
        mnstr_printf(ACout, "--protocol=<name>  either tcp/udp\n");
        mnstr_printf(ACout, "--actuator=<actuator name> to identify the event 
received \n");
-    mnstr_printf(ACout, "--active run as a active listener \n");
-    mnstr_printf(ACout, "--passive run as a passive listener (default)\n");
+       mnstr_printf(ACout, "--active run as a active listener \n");
+       mnstr_printf(ACout, "--passive run as a passive listener (default)\n");
        mnstr_printf(ACout, "--events=<number>  number of events to receive 
(default -1)\n");
        mnstr_printf(ACout, "--statistics=<number>  show statistics after a 
series of events\n");
        exit(-1);
@@ -127,7 +131,7 @@ static char *actuator = "X";
 static int trace = 1;
 static int timestamp = 1; /* first column is a timestamp*/
 
-static int statistics = 0;     /* dump statistics after a certain number 
events */
+static int statistics = 0;  /* dump statistics after a certain number events */
 /*if(statistics!=0)
     print statistics;
    else don't
@@ -156,7 +160,8 @@ static void showStatistics(void)
 {
        double elaps;
        int tuplesIntheBuffer = 2222;
-       if (received == 0) return;
+       if (received == 0)
+               return;
 
 
 
@@ -164,8 +169,8 @@ static void showStatistics(void)
        mnstr_printf(ACout, "Tuples in the buffer :%d\n", tuplesIntheBuffer);
 
        mnstr_printf(ACout, "\nEvents %d\n", received);
-       mnstr_printf(ACout, "Latency per tuple %6.2f microsec\n", 
(((double)totallatency) / received) / tuplesIntheBuffer);
-       elaps = (double)((receivedLast - sendFirst) * tuplesIntheBuffer / 
(received));
+       mnstr_printf(ACout, "Latency per tuple %6.2f microsec\n", (((double) 
totallatency) / received) / tuplesIntheBuffer);
+       elaps = (double) ((receivedLast - sendFirst) * tuplesIntheBuffer / 
(received));
        /*mnstr_printf(ACout, "receivedLast-sendFirst %d microsec\n", 
receivedLast-sendFirst);*/
        mnstr_printf(ACout, "Elapsed per batch %5.2f microsec\n", elaps);
        mnstr_printf(ACout, "Throughput %8.2f tpl/sec\n", 1000000.0 / elaps * 
tuplesIntheBuffer);
@@ -174,10 +179,10 @@ static void showStatistics(void)
 
        /* send a short tuple to stderr for gnuplot datafile*/
        fprintf(stderr, "events %d throughput %6.2f\n", received, 1000000.0 / 
elaps * tuplesIntheBuffer);
-       received=0;
-       totallatency=0;
-       receivedFirst= receivedLast=0;
-       characters=0;
+       received = 0;
+       totallatency = 0;
+       receivedFirst = receivedLast = 0;
+       characters = 0;
 }
 
 static void terminate(Actuator ac)
@@ -191,7 +196,7 @@ static void terminate(Actuator ac)
 
 static void stopListening(int i)
 {
-       (void)i;
+       (void) i;
        signal(i, SIG_IGN);
        if (statistics)
                showStatistics();
@@ -225,13 +230,13 @@ main(int argc, char **argv)
                { "trace", 0, 0, 't' },
                { 0, 0, 0, 0 }
        };
-       THRdata[0] = (void *)file_wastream(stdout, "stdout");
-       THRdata[1] = (void *)file_rastream(stdin, "stdin");
+       THRdata[0] = (void *) file_wastream(stdout, "stdout");
+       THRdata[1] = (void *) file_rastream(stdin, "stdin");
        for (i = 0; i < THREADS; i++) {
                GDKthreads[i].tid = i + 1;
        }
 
-       for (;; ) {
+       for (;;) {
                /*      int option_index=0;*/
                int c = getopt_long(argc, argv, "a:c:p:s:S:b:h:?:t:0", 
long_options, &option_index);
 
@@ -241,10 +246,9 @@ main(int argc, char **argv)
                switch (c) {
                case 't':
                        if (strcmp(long_options[option_index].name, "trace") == 
0) {
-                               trace = optarg? atol(optarg): 1;
-                       } else
-                       if (strcmp(long_options[option_index].name, 
"timestamp") == 0) {
-                               timestamp = optarg? atol(optarg): 1;
+                               trace = optarg ? atol(optarg) : 1;
+                       } else if (strcmp(long_options[option_index].name, 
"timestamp") == 0) {
+                               timestamp = optarg ? atol(optarg) : 1;
                        } else {
                                usage();
                                exit(0);
@@ -252,7 +256,7 @@ main(int argc, char **argv)
                        break;
                case 'e':
                        if (strcmp(long_options[option_index].name, "events") 
== 0) {
-                               events = optarg? atol(optarg): 1;
+                               events = optarg ? atol(optarg) : 1;
                        } else {
                                usage();
                                exit(0);
@@ -263,31 +267,29 @@ main(int argc, char **argv)
                                mode = ACTIVE;
                                break;
                        } else
-                               actuator = optarg? optarg: "dummy";
+                               actuator = optarg ? optarg : "dummy";
                        break;
                case 'p':
                        if (strcmp(long_options[option_index].name, "port") == 
0) {
-                               port = optarg? atol(optarg): -1;
+                               port = optarg ? atol(optarg) : -1;
                                break;
-                       } else
-                       if (strcmp(long_options[option_index].name, "passive") 
== 0) {
+                       } else if (strcmp(long_options[option_index].name, 
"passive") == 0) {
                                mode = PASSIVE;
                                break;
-                       } else
-                       if (strcmp(long_options[option_index].name, "protocol") 
== 0) {
-                if (strcmp(optarg, "TCP") == 0 || strcmp(optarg, "tcp") == 0) {
-                    protocol = TCP;
-                    break;
-                }
-                if (strcmp(optarg, "UDP") == 0 || strcmp(optarg, "udp") == 0) {
-                    protocol = UDP;
-                    break;
-                }
+                       } else if (strcmp(long_options[option_index].name, 
"protocol") == 0) {
+                               if (strcmp(optarg, "TCP") == 0 || 
strcmp(optarg, "tcp") == 0) {
+                                       protocol = TCP;
+                                       break;
+                               }
+                               if (strcmp(optarg, "UDP") == 0 || 
strcmp(optarg, "udp") == 0) {
+                                       protocol = UDP;
+                                       break;
+                               }
                        }
                        break;
                case 's':
                        if (strcmp(long_options[option_index].name, 
"statistics") == 0) {
-                               statistics = optarg? atol(optarg): 100;
+                               statistics = optarg ? atol(optarg) : 100;
                                break;
                        } else {
                                usage();
@@ -322,39 +324,39 @@ main(int argc, char **argv)
                mnstr_printf(ACout, "--events=%d\n", events);
                mnstr_printf(ACout, "--timestamp=%d\n", timestamp);
                mnstr_printf(ACout, "--statistics=%d\n", statistics);
-               mnstr_printf(ACout, "--%s\n", mode == 
ACTIVE?"active":"passive");
+               mnstr_printf(ACout, "--%s\n", mode == ACTIVE ? "active" : 
"passive");
        }
-    strncpy(hostname,host,1024);
-    if ( strcmp(host,"localhost")== 0 )
-        gethostname(hostname,1024);
-    host= hostname;
+       strncpy(hostname, host, 1024);
+       if (strcmp(host, "localhost") == 0)
+               gethostname(hostname, 1024);
+       host = hostname;
 
 
        ac = ACnew(actuator);
        /*name[0] = 0;*/
        err = NULL;
-       if ( mode == PASSIVE) {
+       if (mode == PASSIVE) {
                ac->fromServer = udp_rastream(host, port, actuator);
-               if ( ac->fromServer == 0){
-                       mnstr_printf(ACout, "Failed to access stream 
%s:%d\n",host,port);
+               if (ac->fromServer == 0) {
+                       mnstr_printf(ACout, "Failed to access stream %s:%d\n", 
host, port);
                        return 0;
                }
                consumeStream(ac);
 #ifdef _DEBUG_ACTUATOR_
-                       mnstr_printf(ACout, "stream consumed\n");
+               mnstr_printf(ACout, "stream consumed\n");
 #endif
        }
 
-       if( mode == ACTIVE)
-    do {
-        err = socket_client_connect(&sockfd, host, port);
-        if (err) {
-            mnstr_printf(ACout, "actuator connect fails: %s\n", err);
-            MT_sleep_ms(1000);
-        }
-    } while (err);
+       if (mode == ACTIVE)
+               do {
+                       err = socket_client_connect(&sockfd, host, port);
+                       if (err) {
+                               mnstr_printf(ACout, "actuator connect fails: 
%s\n", err);
+                               MT_sleep_ms(1000);
+                       }
+               } while (err);
 
-       if ( mode == PASSIVE )
+       if (mode == PASSIVE)
        {
                err = socket_server_listen(sockfd, &(ac->newsockfd));
                if (err) {
@@ -368,7 +370,7 @@ main(int argc, char **argv)
                        mnstr_printf(ACout, "Actuator listens\n");
 #endif
 
-                       if ( protocol == UDP)
+                       if (protocol == UDP)
                                ac->fromServer = udp_rastream(host, port, 
actuator);
                        else
                                ac->fromServer = socket_rastream(ac->newsockfd, 
actuator);
@@ -378,8 +380,7 @@ main(int argc, char **argv)
                                return 0;
                        }
                        consumeStream(ac);
-               } else
-               if( mode == ACTIVE ) {
+               } else if (mode == ACTIVE) {
 #ifdef _DEBUG_ACTUATOR_
                        mnstr_printf(ACout, "Actuator connects\n");
 #endif
@@ -392,7 +393,7 @@ main(int argc, char **argv)
 #ifdef _DEBUG_ACTUATOR_
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to