From: Maps Date: Thu, 11 May 2017 13:18:28 +0000 (+0200) Subject: Revert "PK: changes to the eventbuilder by Paweł Staszel" X-Git-Url: https://jspc29.x-matter.uni-frankfurt.de/git/?a=commitdiff_plain;h=73f47f39cbd300e4053ca1b658f7ca16e91cca27;p=daqdata.git Revert "PK: changes to the eventbuilder by Paweł Staszel" This reverts commit 7ca7fcabede60c03aa41976a105f4a1ecf3bcd76. It's usage is internal for now and the commit made for documentation purposes. --- diff --git a/hadaq/evtbuild.c b/hadaq/evtbuild.c index a4bc52d..cd3e091 100644 --- a/hadaq/evtbuild.c +++ b/hadaq/evtbuild.c @@ -79,8 +79,6 @@ static FILE *outFile; static FILE *outLustreFile; static FILE *outSecondFile; -static FILE* logfile; - static AnsiTape *outTape; static uint32_t seqNr; static uint32_t runNr; @@ -97,11 +95,6 @@ static char msglog[300]; static jmp_buf terminateJmp; -static int frameCounter = 100; -static int triggerCounter = 0; -static int triggerCounter2 = 0; -static int trbCounterOffset = 0; - void sigHandler(int sig) { longjmp(terminateJmp, sig); @@ -618,10 +611,8 @@ static int openFile(TheArgs *theArgs, TheStats *theStats) } } - fprintf(logfile," attempting to open file: %s \n",theArgs->outPath); if (NULL == (outFile = fopen(theArgs->outPath, "wb"))) { sprintf(msglog, " %s, %d: fopen: failed to open file %s: %s", __FILE__, __LINE__, theArgs->outPath, strerror(errno)); - fprintf(logfile," %s, %d: fopen: failed to open file %s: %s", __FILE__, __LINE__, theArgs->outPath, strerror(errno)); storeLogInfo(theArgs, msglog); syslog(LOG_ERR, "opening file %s: %s", theArgs->outPath, strerror(errno)); outFile = NULL; @@ -635,12 +626,8 @@ static int openFile(TheArgs *theArgs, TheStats *theStats) unlink(theArgs->outPath); sprintf(msglog, " %s, %d: no space left to open new file %s: %s", __FILE__, __LINE__, theArgs->outPath, - strerror(errno)); - - fprintf(logfile," %s, %d: no space left to open new file %s: %s", __FILE__, __LINE__, theArgs->outPath, - strerror(errno)); - - storeLogInfo(theArgs, msglog); + strerror(errno)); + storeLogInfo(theArgs, msglog); syslog(LOG_ERR, "opening file %s: %s", theArgs->outPath, strerror(errno)); return -1; } @@ -757,20 +744,13 @@ static int openFile(TheArgs *theArgs, TheStats *theStats) static int writeFile(TheArgs *theArgs, void *evt) { - int writeFileR; Evt_setSeqNr(evt, seqNr++); Evt_setRunNr(evt, runNr); if (outFile != NULL) { - - /*fprintf(stderr," writing event: event size = %d paddedSize = %d \n",Evt_size(evt),Evt_paddedSize(evt));*/ - /*fprintf(stderr," outFile = %s \n",outFile);*/ - writeFileR = fwrite(evt, 1, Evt_paddedSize(evt), outFile); - writeFileR = fflush(outFile); - } else if (outTape != NULL) { writeFileR = writeAnsiTape(outTape, evt, Evt_paddedSize(evt)); } @@ -812,14 +792,8 @@ static int closeFile(TheArgs *theArgs) } if (outFile != NULL) { - - fprintf(stderr," Closing the outFile \n"); - - closeFileR = fclose(outFile); - - fprintf(stderr," outFile Closed \n"); - - if (0 != closeFileR) { + closeFileR = fclose(outFile); + if (0 != closeFileR) { sprintf(msglog, " %s, %d: closeFile: failed to close file: %s", __FILE__, __LINE__, strerror(errno)); storeLogInfo(theArgs, msglog); syslog(LOG_ERR, "%s, %d: failed to fclose 'outFile': %s", __FILE__, __LINE__, strerror(errno)); @@ -881,7 +855,7 @@ static int rfio_openConnection(TheArgs *theArgs, TheStats *theStats) fRemote = rfio_fopen_gsidaq_dm(rfioBase, theArgs->rfio_pcOption, pcDataMover, &piDataMover, -Fi theArgs->rfio_iCopyMode, theArgs->rfioLustrePath, + theArgs->rfio_iCopyMode, theArgs->rfioLustrePath, theArgs->rfio_iCopyFrac, theArgs->rfio_iMaxFile, theArgs->rfio_iPathConv); @@ -943,26 +917,13 @@ int main(int argc, char *argv[]) uint32_t lastTrigNr = 0; int firstFile = 1; - /* PAWEL */ - void *OLDevt; - int OLDevtSet=0; - /* PAWEL */ - - logfile = fopen("/local.1/log/evtbuild.log","w"); - - fprintf(stderr,"Entered Pawel evt builder\n"); - fprintf(logfile,"----------> entered main in pawel \n"); - fflush(logfile); signal(SIGINT, sigHandler); signal(SIGTERM, sigHandler); signal(SIGHUP, sigHandler); - fprintf(logfile,"----------> line 1 \n"); - fflush(logfile); - openlog(argv[0], LOG_PID | LOG_PERROR, LOG_LOCAL0); setlogmask(LOG_UPTO(LOG_INFO)); @@ -970,18 +931,11 @@ int main(int argc, char *argv[]) Args_fromParam(theArgs, argc, argv); - fprintf(logfile,"----------> line 2 \n"); - fflush(logfile); - if (0 > Args_fromCL(theArgs, argc, argv)) { usage(argv[0]); exit(EXIT_FAILURE); } - - fprintf(logfile,"----------> line 3 \n"); - fflush(logfile); - storeLogInfo(theArgs, " started."); if (0 > makeQueues(theArgs)) { @@ -989,19 +943,10 @@ int main(int argc, char *argv[]) exit(EXIT_FAILURE); } - - fprintf(logfile,"----------> line 4 \n"); - - fflush(logfile); - if (Args_check(theArgs)) { exit(EXIT_FAILURE); } - - fprintf(logfile,"----------> line 5 \n"); - fflush(logfile); - /* Init debugging structure */ if (theArgs->debugOptsCnt) Debug_init(theDebug); @@ -1039,7 +984,7 @@ int main(int argc, char *argv[]) sprintf(msglog, " %s, %d: initOnline: failed to init online service: %s", __FILE__, __LINE__, strerror(errno)); storeLogInfo(theArgs, msglog); } -syslog(LOG_WARNING, "Entered Pawel evt builder"); + if (theArgs->nrOfMsgs == 0) { /* no '-m' option was on command line, we assume that the @@ -1201,11 +1146,7 @@ syslog(LOG_WARNING, "Entered Pawel evt builder"); currId = 0; - while (setjmp(terminateJmp) == 0) { - - - void *evt; void *subEvt; int step; @@ -1239,17 +1180,12 @@ syslog(LOG_WARNING, "Entered Pawel evt builder"); strftime(s, 20, "%Y-%m-%dT%H:%M:%S", localtime(&ourTime)); printf("ioc time: %s\n", s); printf("ioc runid: %d\n", runNr); - - fprintf(logfile," in main: attempt to open new file \n"); - + if (-1 == openFile(theArgs, theStats)) { syslog(LOG_ERR, "error opening output file, exiting"); - fprintf(logfile,"error opening output file, exiting \n"); exit(EXIT_FAILURE); } - fflush(logfile); - storeInfoStart(argv[0], ourTime, theArgs); /* store simple start run info */ @@ -1262,9 +1198,6 @@ syslog(LOG_WARNING, "Entered Pawel evt builder"); } (*theStats->bytesWritten) += Evt_size(evt); - - fprintf(stderr," calling write 1 \n"); - writeFile(theArgs, evt); deleteEvt(evt); } @@ -1562,13 +1495,6 @@ syslog(LOG_WARNING, "Entered Pawel evt builder"); } } - - void *subEvt2 = Evt_data(evt); - uint32_t headerWord1_2 = SubEvt_dataValue(subEvt2, 2); - - const uint32_t trigFlag_2 = 0x80000000; - if((headerWord1_2 & trigFlag_2))triggerCounter2++; - if (!evtIsBroken) { if (theArgs->debugOptsCnt) { @@ -1601,98 +1527,8 @@ syslog(LOG_WARNING, "Entered Pawel evt builder"); goto bailOut1; } } - - - /*fprintf(stderr," calling write 2 \n");*/ - /* -------------- checking trigger flag by PS */ - - - - - frameCounter = frameCounter+1; - void *subEvt = Evt_data(evt); - - uint32_t headerWord1 = SubEvt_dataValue(subEvt, 3); - - /* - fprintf(stderr, "@@@ Header word 0x%x\n", headerWord1); - */ - - const uint32_t trigFlag = 0x80000000; - if((headerWord1 & trigFlag)){ - - frameCounter=0; - triggerCounter++; - - uint32_t trbCounter = headerWord1 & 0x00ffffff; - if(triggerCounter==1) trbCounterOffset = trbCounter -1; - - /* - trbCounter = trbCounter - trbCounterOffset; - */ - - fprintf(stderr," collected VD events: = %d \n", - trbCounter); - fprintf(logfile," ->$#$#$# got trigger!!!!!!!! triggerCounter = %d triggerCounter2 = %d trbCounter = %d \n", - triggerCounter,triggerCounter2,trbCounter); - fflush(logfile); - - } - - - /*if((frameCounter>5) && (frameCounter<11)){*/ - if((frameCounter<9)){ - - - (*theStats->bytesWritten) += Evt_size(evt); - - /* - fprintf(stderr," fC = %d, event size = %d \n",frameCounter,Evt_size(evt)); - fprintf(logfile," fC = %d, event size = %d \n",frameCounter,Evt_size(evt)); - fflush(logfile); - */ - - /* --------------- end of trigger checking block */ - /*fprintf(stderr, "Pawel!\n");*/ - - writeFile(theArgs, evt); - - /* PAWEL */ - /* - if(OLDevtSet != 0){ - - fwrite(OLDevt, 1, Evt_paddedSize(OLDevt),outFile); - fflush(outFile); - fflush(stderr); - - } - */ - /* PAWEL */ - - }else{ - /* - fprintf(logfile," fC = %d, event size = %d \n",frameCounter,Evt_size(evt)); - fflush(logfile); - */ - /*fprintf(stderr," fC = %d, event size = %d \n",frameCounter,Evt_size(evt));*/ - - /* Uncomment consecutive line in order to run without external trigger */ - /* - (*theStats->bytesWritten) += Evt_size(evt); - writeFile(theArgs, evt); - */ - /* End line to be uncommented to run without external trigger */ - - } - - /* PAWEL */ - if (OLDevtSet != 0){ - free(OLDevt); - } - OLDevt = malloc(Evt_paddedSize(evt)); - memcpy(OLDevt,evt, Evt_paddedSize(evt)); - OLDevtSet = 1; - /* PAWEL */ + (*theStats->bytesWritten) += Evt_size(evt); + writeFile(theArgs, evt); if (theArgs->resdownscale) { @@ -1803,27 +1639,16 @@ syslog(LOG_WARNING, "Entered Pawel evt builder"); * Something went wrong with sinchronization of Event Builders, * close the file. */ - if ((!(theArgs->epicsCtrl) && (*theStats->bytesWritten) >= theArgs->maxFileSz) || (theArgs->epicsCtrl && runNr < newRunId) || /* (theArgs->epicsCtrl && (*theStats->bytesWritten) >= 1900000000) JAM disable closing run ourselfs if we are slave */ (theArgs->epicsCtrl && newRunId == 0)) { - - - fprintf(logfile," check runID (passed if), runNr=%d, newRunId=%d , maxFileSz=%d , epicsCtrl=%d \n",runNr,newRunId,theArgs->maxFileSz,theArgs->epicsCtrl); - fflush(logfile); - fprintf(logfile," bytesWritten=%d \n",(*theStats->bytesWritten)); - fflush(logfile); - evt = newEvt(EvtDecoding_64bitAligned, EvtId_runStop); for (i = 0; i < theArgs->slowCtrlFileCnt; i++) evt = appendFile(evt, theArgs->slowCtrlFiles[i]); (*theStats->bytesWritten) += Evt_size(evt); - - fprintf(stderr," calling write 3 \n"); - writeFile(theArgs, evt); deleteEvt(evt); @@ -1887,13 +1712,8 @@ syslog(LOG_WARNING, "Entered Pawel evt builder"); Res_closeFile(theArgs); (*theStats->evtsRes) = 0; } - } - } /* end of while loop*/ - - - - fprintf(stderr," T2 I'm here \n"); - + } + } bailOut1: @@ -1915,10 +1735,6 @@ syslog(LOG_WARNING, "Entered Pawel evt builder"); /******/ Res_closeFile(theArgs); } - - fprintf(stderr," T1 I'm here \n"); - - storeInfoStop(argv[0], ourTime, worker, theArgs); /* store simple stop run info */