]> jspc29.x-matter.uni-frankfurt.de Git - daqdata.git/commitdiff
New function: Worker_setStatistic. Sets a value for already existing statistic. Serge...
authorhadaq <hadaq>
Wed, 28 May 2008 14:56:16 +0000 (14:56 +0000)
committerhadaq <hadaq>
Wed, 28 May 2008 14:56:16 +0000 (14:56 +0000)
hadaq/worker.c
hadaq/worker.h

index c7ad44d0c3a040b155496197619acfdc6d9c8bbe..735a4e0e764c9333bf14cbe0be2dce62bd7c8780 100644 (file)
@@ -1,4 +1,4 @@
-static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/worker.c,v 6.29 2007-04-14 21:49:37 hadaq Exp $";
+static char *rcsId = "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/worker.c,v 6.30 2008-05-28 14:56:16 hadaq Exp $";
 
 #define WORKER_NEW_PROTOCOL
 
@@ -410,3 +410,25 @@ int Worker_getStatistic(const char *name, const char *stat, unsigned long int *v
        }
        return retVal;
 }
+
+int Worker_setStatistic(const char *name, const char *stat, unsigned long int *value)
+{
+       int retVal = -1;
+       int i;
+       Worker myS, *my = &myS;
+       strcpy(my->name, name);
+
+       if (-1 == openStatShm(my)) {
+               *value = 0;
+       } else {
+               for (i = 0; i < WORKER_MAX_NUM_STATS && strcmp(my->statistics[i].name, "") != 0; i++) {
+                       if (strcasecmp(stat, my->statistics[i].name) == 0) {
+                               my->statistics[i].value = *value;
+                               retVal = 0;
+                               i = WORKER_MAX_NUM_STATS;
+                       }
+               }
+               closeStatShm(my);
+       }
+       return retVal;
+}
index 29625a62d9ed85c584343266693be0949b981792..161d9a724301c67d58ebb09cd498ed536369eec2 100644 (file)
@@ -45,5 +45,6 @@ void Worker_fini(Worker *my);
 unsigned long *Worker_addStatistic(Worker *my, const char *name);
 void Worker_dump(Worker *my, time_t interval);
 int Worker_getStatistic(const char *name, const char *stat, unsigned long int *value);
+int Worker_setStatistic(const char *name, const char *stat, unsigned long int *value);
 
 #endif