From 7e63a6829bf0b453e748f5ca0a0a3d7fac1802eb Mon Sep 17 00:00:00 2001 From: hadaq Date: Mon, 16 Jun 2008 15:42:41 +0000 Subject: [PATCH] 1. DAQ_SETUP is read only once and not each time in storeRunInfoStart/Stop. 2. File name contains time taken from the RUN Id. Sergey Yurevich --- hadaq/evtbuild.c | 63 ++++++++++++++++++++++++------------------------ 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/hadaq/evtbuild.c b/hadaq/evtbuild.c index 63b798e..697091a 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.88 2008-06-06 15:39:50 hadaq Exp $"; + "$Header: /misc/hadesprojects/daq/cvsroot/eventbuilder/hadaq/evtbuild.c,v 6.89 2008-06-16 15:42:41 hadaq Exp $"; #define _POSIX_C_SOURCE 199309L @@ -106,6 +106,7 @@ typedef struct TheArgsS char shmname[PARAM_MAX_VALUE_LEN]; unsigned int ebnum; + char runinfo2ora[PARAM_MAX_VALUE_LEN]; } TheArgs; typedef struct TheStatsS @@ -280,6 +281,9 @@ static void argsDefault (TheArgs * my) my->buffStat = 0; my->epicsCtrl = 0; my->ebnum = 0; + + /* read path from DAQ_SETUP and define full file name */ + sprintf(my->runinfo2ora,"%s_runinfo2ora.txt",getenv("DAQ_SETUP")); } static int argsFromCL (TheArgs * my, int argc, char *argv[]) @@ -844,14 +848,8 @@ static void storeRunInfoStart(time_t t, TheArgs *myArgs) char ltime[20]; /* local time */ strftime(ltime, 20, "%Y-%m-%d %H:%M:%S", localtime(&t)); - /* read path from DAQ_SETUP and define full file name */ - char runinfo2ora[50]; - sprintf(runinfo2ora,"%s_runinfo2ora.txt",getenv("DAQ_SETUP")); - - fp = fopen(runinfo2ora,"a+"); - - fprintf(fp, "start %d %s %s\n", myArgs->runNr, myArgs->outPath, ltime); - + fp = fopen(myArgs->runinfo2ora,"a+"); + fprintf(fp, "start %d %d %s %s\n", myArgs->runNr, myArgs->ebnum, myArgs->outPath, ltime); fclose(fp); } @@ -866,15 +864,9 @@ static void storeRunInfoStop(time_t t, TheArgs *myArgs, TheStats *myStats) char ltime[20]; /* local time */ strftime(ltime, 20, "%Y-%m-%d %H:%M:%S", localtime(&t)); - /* read path from DAQ_SETUP and define full file name */ - char runinfo2ora[50]; - sprintf(runinfo2ora,"%s_runinfo2ora.txt",getenv("DAQ_SETUP")); - - fp = fopen(runinfo2ora,"a+"); - - fprintf(fp, "stop %d %s %s ", myArgs->runNr, ltime, unit(*myStats->evtsComplete)); + fp = fopen(myArgs->runinfo2ora,"a+"); + fprintf(fp, "stop %d %d %s %s ", myArgs->runNr, myArgs->ebnum, ltime, unit(*myStats->evtsComplete)); fprintf(fp, "%s\n", unit(*myStats->bytesWritten)); - fclose(fp); } @@ -1125,8 +1117,15 @@ static int openFile (TheArgs * theArgs) * %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( 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) ); /* if ebnum == 0 then we assume that there is only 1 EB, * RUNID distribution by IOC is not needed and file name @@ -1710,12 +1709,12 @@ int main (int argc, char *argv[]) if (*theStats->bytesWritten == 0) { - if( theArgs->epicsCtrl ) { + if( theArgs->epicsCtrl ) runNr = getRunId( theArgs ); - res_time = ourTime = runNr + TIMEOFFSET; - } - else - res_time = ourTime = time (NULL); +/* res_time = ourTime = runNr + TIMEOFFSET; */ +/* } */ +/* else */ + res_time = ourTime = time (NULL); char s[20]; time_t my_time; @@ -1921,17 +1920,17 @@ int main (int argc, char *argv[]) writeFile (evt); deleteEvt (evt); - if( theArgs->epicsCtrl ) - ourTime = newRunId + TIMEOFFSET; - else - ourTime = time (NULL); +/* if( theArgs->epicsCtrl ) */ +/* ourTime = newRunId + TIMEOFFSET; */ +/* else */ + ourTime = time (NULL); closeFile (); - storeInfoStop (argv[0], ourTime - 2, worker, theArgs); + storeInfoStop (argv[0], ourTime, worker, theArgs); /* store simple stop run info */ - storeRunInfoStop(ourTime - 2, theArgs, theStats); + storeRunInfoStop(ourTime, theArgs, theStats); (*theStats->bytesWritten) = 0; (*theStats->evtsComplete) = 0; @@ -1977,10 +1976,10 @@ int main (int argc, char *argv[]) if (theArgs->resdownscale) closeRESFile (theArgs); - storeInfoStop (argv[0], ourTime - 2, worker, theArgs); + storeInfoStop (argv[0], ourTime, worker, theArgs); /* store simple stop run info */ - storeRunInfoStop(ourTime - 2, theArgs, theStats); + storeRunInfoStop(ourTime, theArgs, theStats); statsDump (theArgs, theStats, 1); -- 2.43.0