From c0ff5935f7594c77b71c1121e78a6c98b2cb2dd9 Mon Sep 17 00:00:00 2001 From: hadaq Date: Wed, 23 Jul 2008 13:49:02 +0000 Subject: [PATCH] New options: [-i] ignore trigger mismatch conditions, [-O path] path for eb_runinfo2ora.txt. Sergey. --- hadaq/evtbuild.c | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/hadaq/evtbuild.c b/hadaq/evtbuild.c index 2625a48..8527031 100644 --- a/hadaq/evtbuild.c +++ b/hadaq/evtbuild.c @@ -1,5 +1,5 @@ static char *rcsId = - "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.90 2008-06-17 18:51:06 hadaq Exp $"; + "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.91 2008-07-23 13:49:02 hadaq Exp $"; #define _POSIX_C_SOURCE 199309L @@ -104,7 +104,7 @@ typedef struct TheArgsS char lustrePath[PARAM_MAX_VALUE_LEN]; unsigned short buffStat; unsigned short epicsCtrl; - + unsigned short ignore; /* ignore all trigger mismatch conditions */ char shmname[PARAM_MAX_VALUE_LEN]; unsigned int ebnum; char runinfo2ora[PARAM_MAX_VALUE_LEN]; @@ -199,6 +199,7 @@ static void usage (const char *progName) 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"); + syslog (LOG_ERR, "Usage: [--orapath path] path to eb_runinfo2ora.txt"); } static void argsDump (TheArgs * my) @@ -279,9 +280,10 @@ static void argsDefault (TheArgs * my) strcpy (my->rfioRemotePath, ""); strcpy (my->lustrePath, ""); - my->buffStat = 0; + my->buffStat = 0; my->epicsCtrl = 0; - my->ebnum = 0; + my->ebnum = 1; + my->ignore = 0; /* read path from DAQ_SETUP and define full file name */ sprintf(my->runinfo2ora,"%s_runinfo2ora.txt",getenv("DAQ_SETUP")); @@ -312,10 +314,12 @@ static int argsFromCL (TheArgs * my, int argc, char *argv[]) {"lustre", 1, 0, 'L'}, {"shmname", 1, 0, 'S'}, {"ebnum", 1, 0, 'B'}, + {"orapath", 1, 0, 'O'}, + {"ignore", 0, 0, 'i'}, {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:B:", + "am:f:r:o:d:q:p:v:x:I:tz:e:n:h:w:tz:e:n:Hs:l:R:bEL:S:B:O:i", long_options, &option_index); if (i == -1) break; @@ -393,9 +397,15 @@ static int argsFromCL (TheArgs * my, int argc, char *argv[]) case 'E': my->epicsCtrl = 1; break; + case 'i': + my->ignore = 1; + break; case 'B': my->ebnum = strtoul (optarg, NULL, 0); break; + case 'O': + sprintf(my->runinfo2ora,"%s_runinfo2ora.txt",optarg); + break; case 'H': usage (argv[0]); return -1; @@ -943,8 +953,8 @@ int is_mismatch_enough_to_stop(TheArgs * theArgs, TheStats * my) /* max number of evts with tag error allowed */ unsigned long maxtagerror = (*my->evtsComplete) * 0.03; - if ((*my->bytesWritten) >= minfilesize) { - if ((*my->evtsDiscarded) > maxdiscarded) { + if ((*my->bytesWritten) >= minfilesize && !(theArgs->ignore) ) { + if ((*my->evtsDiscarded) > maxdiscarded && !(theArgs->ignore) ) { syslog (LOG_ERR, " evtbuild.c: Too many events are broken!"); syslog (LOG_ERR, " evtbuild.c: bytes written: %u, minimum file size: %u", @@ -956,7 +966,7 @@ int is_mismatch_enough_to_stop(TheArgs * theArgs, TheStats * my) #endif sleep(5); } - if ((*my->evtsTagError) > maxtagerror) { + if ((*my->evtsTagError) > maxtagerror && !(theArgs->ignore) ) { syslog(LOG_ERR, " evtbuild.c: Too many TagErrors!"); syslog (LOG_ERR, " evtbuild.c: bytes written: %u, minimum file size: %u", @@ -1091,9 +1101,14 @@ static int openFile (TheArgs * theArgs) static once = 1; diff_time = 1; + + struct timeval tv; - if( !(theArgs->epicsCtrl) ) - runNr = genId32 (); + if( !(theArgs->epicsCtrl) ) { + /* runNr = genId32 (); */ + gettimeofday( &tv, NULL ); + runNr = tv.tv_sec - TIMEOFFSET; + } seqNr = 0; @@ -1119,15 +1134,10 @@ static int openFile (TheArgs * theArgs) * %j : day of year (001-366) %S : second (00-59) * %H : hour (00-23) */ - if( theArgs->epicsCtrl && theArgs->ebnum > 0 ) { - time_t iocTime; - iocTime = theArgs->runNr + TIMEOFFSET; - strftime( fileName + strlen(fileName), 18, "%y%j%H%M%S", - localtime(&iocTime) ); - } - else - strftime( fileName + strlen(fileName), 18, "%y%j%H%M%S", - localtime(&ourTime) ); + time_t iocTime; + iocTime = theArgs->runNr + TIMEOFFSET; + strftime( fileName + strlen(fileName), 18, "%y%j%H%M%S", + localtime(&iocTime) ); /* if ebnum == 0 then we assume that there is only 1 EB, * RUNID distribution by IOC is not needed and file name -- 2.43.0