From: hadaq Date: Fri, 6 Jun 2008 15:39:50 +0000 (+0000) Subject: Took out rates from statistic. IOC itself will calculate them. Sergey Yurevich X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=fe8bad27347389ce399e667e4574db54215c16c0;p=daqdata.git Took out rates from statistic. IOC itself will calculate them. Sergey Yurevich --- diff --git a/hadaq/evtbuild.c b/hadaq/evtbuild.c index 508f7b0..63b798e 100644 --- a/hadaq/evtbuild.c +++ b/hadaq/evtbuild.c @@ -1,10 +1,10 @@ static char *rcsId = - "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.87 2008-06-04 16:12:06 hadaq Exp $"; + "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.88 2008-06-06 15:39:50 hadaq Exp $"; #define _POSIX_C_SOURCE 199309L #define SYSLOG_NAMES -/* #define RFIO */ +/* #define RFIO */ #include #include @@ -99,13 +99,13 @@ typedef struct TheArgsS unsigned long varQSize[MAXINPATH]; int varQSizeCnt; - unsigned int rfioFlag; char rfioRemotePath[PARAM_MAX_VALUE_LEN]; char lustrePath[PARAM_MAX_VALUE_LEN]; unsigned short buffStat; unsigned short epicsCtrl; char shmname[PARAM_MAX_VALUE_LEN]; + unsigned int ebnum; } TheArgs; typedef struct TheStatsS @@ -121,9 +121,6 @@ typedef struct TheStatsS unsigned long *evtbuildBuff[MAXINPATH]; unsigned long *nrOfMsgs; unsigned long *runId; - unsigned long *evtsCompleteRate; - unsigned long *bytesWrittenRate; - unsigned long *evtsDiscardedRate; } TheStats; static jmp_buf terminateJmp; @@ -199,6 +196,7 @@ static void usage (const char *progName) syslog (LOG_ERR, "Usage: [--buffstat] show fill levels of buffers"); syslog (LOG_ERR, "Usage: [--epicsctrl] enable synch and distribution of RUN Id by Epics for parallel event builders"); syslog (LOG_ERR, "Usage: [--lustre path_to_lustre] path to the file on the Lustre cluster"); + syslog (LOG_ERR, "Usage: [--ebnum] number of the event builder"); } static void argsDump (TheArgs * my) @@ -241,6 +239,7 @@ static void argsDump (TheArgs * my) if( strcmp( my->lustrePath, "" ) != 0 ) { syslog (LOG_DEBUG, "lustre path: %s", my->lustrePath); } + syslog (LOG_DEBUG, "EB numder: %d", my->ebnum); } static void argsDefault (TheArgs * my) @@ -280,6 +279,7 @@ static void argsDefault (TheArgs * my) strcpy (my->lustrePath, ""); my->buffStat = 0; my->epicsCtrl = 0; + my->ebnum = 0; } static int argsFromCL (TheArgs * my, int argc, char *argv[]) @@ -306,10 +306,11 @@ static int argsFromCL (TheArgs * my, int argc, char *argv[]) {"epicsctrl", 0, 0, 'E'}, {"lustre", 1, 0, 'L'}, {"shmname", 1, 0, 'S'}, + {"ebnum", 1, 0, 'B'}, {0, 0, 0, 0} }; i = getopt_long (argc, argv, - "am:f:r:o:d:q:p:v:x:I:tz:e:n:h:w:tz:e:n:Hs:l:R:bEL:S:", + "am:f:r:o:d:q:p:v:x:I:tz:e:n:h:w:tz:e:n:Hs:l:R:bEL:S:B:", long_options, &option_index); if (i == -1) break; @@ -387,6 +388,9 @@ static int argsFromCL (TheArgs * my, int argc, char *argv[]) case 'E': my->epicsCtrl = 1; break; + case 'B': + my->ebnum = strtoul (optarg, NULL, 0); + break; case 'H': usage (argv[0]); return -1; @@ -540,9 +544,6 @@ static void add2Stat( TheArgs * theArgs, TheStats * my, float interval, ShmTrans { /* Add statistic for fill levels of buffers in percentage. */ - static unsigned long lastEvtsComplete; - static unsigned long lastBytesWritten; - static unsigned long lastEvtsDisc; static time_t t_0 = 0; float buffSize, queueSize; time_t t, dT; @@ -561,26 +562,6 @@ static void add2Stat( TheArgs * theArgs, TheStats * my, float interval, ShmTrans fillLevel = (unsigned long) (100*queueSize+0.5)/buffSize; (*my->evtbuildBuff[i]) = fillLevel; } - - /* Add more statistic for evtsComplete and bytesWritten per second */ - if( (*my->evtsComplete) >= lastEvtsComplete ) - (*my->evtsCompleteRate) = (*my->evtsComplete - lastEvtsComplete) / dT; - else - (*my->evtsCompleteRate) = (*my->evtsComplete); - - if( (*my->bytesWritten) >= lastBytesWritten) - (*my->bytesWrittenRate) = (*my->bytesWritten - lastBytesWritten) / dT; - else - (*my->bytesWrittenRate) = (*my->bytesWritten); - - if( (*my->evtsDiscarded) >= lastEvtsDisc) - (*my->evtsDiscardedRate) = (*my->evtsDiscarded - lastEvtsDisc) / dT; - else - (*my->evtsDiscardedRate) = (*my->evtsDiscarded); - - lastEvtsComplete = *my->evtsComplete; - lastBytesWritten = *my->bytesWritten; - lastEvtsDisc = *my->evtsDiscarded; } t_0 = t; @@ -720,7 +701,7 @@ static void statsBufferDump (TheArgs *theArgs, TheStats *my, float interval, char buf[_POSIX_PATH_MAX]; sprintf( buf, "%s%s", progName, theArgs->shmname ); Worker_getStatistic( buf, "runId", &runId2print); - printf("ioc: RUN Id = %lu\n", runId2print); + printf("ioc: RUN Id = %lu RUN Nr = %lu\n", runId2print, runNr); } } @@ -1139,8 +1120,22 @@ static int openFile (TheArgs * theArgs) /* construct a default filename */ strcpy (fileName, theArgs->expId); - strftime (fileName + strlen (fileName), 18, "%y%j%H%M%S.hld", + + /* %y : year (00-99) %M : minute (00-59) + * %j : day of year (001-366) %S : second (00-59) + * %H : hour (00-23) + */ + strftime (fileName + strlen (fileName), 18, "%y%j%H%M%S", localtime (&ourTime)); + + /* if ebnum == 0 then we assume that there is only 1 EB, + * RUNID distribution by IOC is not needed and file name + * can be in the usual format without EB identificator. + */ + if( theArgs->epicsCtrl && theArgs->ebnum > 0 ) + sprintf( fileName, "%s%02d.hld", fileName, theArgs->ebnum); + else + sprintf( fileName, "%s.hld", fileName); outTape = NULL; outFile = NULL; @@ -1657,13 +1652,10 @@ int main (int argc, char *argv[]) } theStats->evtsDiscarded = Worker_addStatistic (worker, "evtsDiscarded"); - theStats->evtsDiscardedRate = Worker_addStatistic (worker, "evtsDiscardedRate"); theStats->evtsComplete = Worker_addStatistic (worker, "evtsComplete"); - theStats->evtsCompleteRate = Worker_addStatistic (worker, "evtsCompleteRate"); theStats->evtsDataError = Worker_addStatistic (worker, "evtsDataError"); theStats->evtsTagError = Worker_addStatistic (worker, "evtsTagError"); theStats->bytesWritten = Worker_addStatistic (worker, "bytesWritten"); - theStats->bytesWrittenRate = Worker_addStatistic (worker, "bytesWrittenRate"); theStats->runId = Worker_addStatistic (worker, "runId"); (*theStats->runId) = 0; /* initialize to zero */ @@ -1725,6 +1717,14 @@ int main (int argc, char *argv[]) else res_time = ourTime = time (NULL); + char s[20]; + time_t my_time; + my_time = time(NULL); + strftime( s, 20, "%Y-%m-%dT%H:%M:%S", localtime(&my_time) ); + printf("local time: %s\n", s); + strftime( s, 20, "%Y-%m-%dT%H:%M:%S", localtime(&ourTime) ); + printf("ioc time: %s\n", s); + printf("ioc runid: %d\n", runNr); if (-1 == openFile (theArgs)) {