Changeset 11293 for trunk/FACT++
- Timestamp:
- 07/08/11 15:35:12 (13 years ago)
- Location:
- trunk/FACT++/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/FACT++/src/EventBuilder.c
r11282 r11293 71 71 int gp_runStat ; 72 72 int gw_runStat ; 73 74 int gi_memStat = +1 ; 75 73 76 int32_t gi_myRun ; 74 77 … … 307 310 308 311 if ( gj.usdMem + needmem + headmem > g_maxMem) { 309 snprintf(str,MXSTR,"no memory left to keep event %d",evID) ; 310 factOut(kError,882, str ) ; 312 gj.maxMem = gj.usdMem + needmem + headmem ; 313 if (gi_memStat>0 ) { 314 gi_memStat = -99 ; 315 snprintf(str,MXSTR,"no memory left to keep event %d",evID) ; 316 factOut(kError,882, str ) ; 317 } 311 318 return -11 ; 312 319 } … … 353 360 if (gj.usdMem > gj.maxMem ) gj.maxMem = gj.usdMem ; 354 361 362 gj.rateNew++ ; 363 355 364 //register event in 'active list (reading)' 356 365 … … 360 369 evtIdx[i] = evtCtrl.lastPtr ; 361 370 362 gj.readEvt++ ; //#events read363 gj.evtBuf++ ;364 365 371 366 372 snprintf(str,MXSTR,"%5d start new evt %8d %8d %2d",evID,i,evtCtrl.lastPtr,0); … … 368 374 evtCtrl.lastPtr++ ; 369 375 if (evtCtrl.lastPtr == MAX_EVT*MAX_RUN ) evtCtrl.lastPtr = 0; 370 371 376 372 377 gi.evtGet++ ; … … 426 431 427 432 gj.usdMem = gj.usdMem - freemem - headmem; 428 gj.evtBuf-- ; 433 434 if (gi_memStat < 0 ) { 435 if (gj.usdMem <= 0.75 * gj.maxMem ) gi_memStat = +1 ; 436 } 437 429 438 430 439 return 0 ; … … 479 488 int actBoards = 0, minLen ; 480 489 int32_t jrd ; 481 int64_t stat[9] ;482 490 int boardId, roi,drs,px,src,pixS,pixH,pixC,pixR,tmS ; 483 uint qtot = 0, qread = 0, qconn = 0 ;484 491 485 492 int goodhed = 0 ; … … 524 531 525 532 resetEvtStat(); 526 gj.usdMem = gj.maxMem = 0 ; 527 gj.evtBuf = 0 ; 533 gj.usdMem = gj.maxMem = gj.xxxMem = 0 ; 534 gj.totMem = g_maxMem ; 535 gj.bufNew = gj.bufEvt = 0 ; 536 gj.evtSkip= gj.evtWrite = gj.evtErr = 0 ; 528 537 529 538 for (k=0; k<NBOARDS; k++) { 530 539 gi_NumConnect[k]=0; 531 540 gi.numConn[k] =0; 541 gj.numConn[k] =0; 542 gj.errConn[k] =0; 543 gj.rateBytes[k] =0; 544 gj.totBytes[k] =0; 532 545 } 533 546 … … 564 577 gi_runStat = g_runStat; 565 578 gj.readStat= g_runStat; 566 gj.totMem = g_maxMem ;567 579 // if (gi.totMem < 50000000 ) gi.totMem = 500000000 ; 568 580 … … 575 587 gi_NumConnect[ b ] = 0 ; //must close all connections 576 588 gi.numConn[ b ] = 0; 589 gj.numConn[ b ] = 0; 577 590 if ( sockDef[b] == 0) s0= 0 ; //sockets to be defined and opened 578 591 else if (g_port[b].sockDef == 0) s0=-1 ; //sockets to be destroyed … … 626 639 gi_NumConnect[ b ]++ ; 627 640 gi.numConn[ b ]++ ; 641 gj.numConn[ b ]++ ; 628 642 snprintf(str,MXSTR,"+++connect %d %d",b,gi.numConn[ b ]); 629 643 factOut(kInfo,-1, str ) ; … … 637 651 638 652 if (jrd >0 ) { 639 qread+=jrd ;640 653 debugStream(i,&rd[i].rBuf->B[ rd[i].bufPos],jrd) ; 641 654 } … … 648 661 gi_NumConnect[ b ]-- ; 649 662 gi.numConn[ b ]-- ; 663 gj.numConn[ b ]-- ; 650 664 651 665 } else if ( jrd<0 ) { //did not read anything … … 660 674 661 675 gi.gotByte[ b ] += jrd ; 676 gj.rateBytes[b] += jrd ; 662 677 663 678 if ( rd[i].bufTyp <0 ) { // we are skipping this board ... … … 690 705 if (evID < 0) { 691 706 xwait.tv_sec = 0; 692 xwait.tv_nsec= 20000000 ; // sleep for ~20 msec707 xwait.tv_nsec= 10000000 ; // sleep for ~10 msec 693 708 nanosleep( &xwait , NULL ) ; 694 709 goto EndBuf1 ; //hope there is free space next round … … 834 849 gi.numRead[ numok ] ++ ; 835 850 836 int qwait=0, qdel=0, qskip=0 ;837 851 g_actTime = time(NULL) ; 838 852 if ( g_actTime > gi_SecTime ) { … … 846 860 if ( kd < 0 ) kd+= (MAX_EVT*MAX_RUN) ; 847 861 862 gj.bufNew = gj.bufEvt = 0 ; 848 863 int k1=evtCtrl.frstPtr; 849 864 for ( k=k1; k<(k1+kd); k++ ) { 850 865 int k0 = k % (MAX_EVT*MAX_RUN) ; 851 866 //would be better to use bitmaps for evtStat (allow '&' instead of multi-if) 867 852 868 if (evtCtrl.evtStat[k0] > 0 853 869 && evtCtrl.evtStat[k0] < 90 ) { 854 855 qwait++; 856 857 if( evtCtrl.pcTime[k0] < g_actTime-10 ) { 858 int id =evtCtrl.evtBuf[k0] ; 859 snprintf(str,MXSTR,"%5d skip short evt %8d %8d %2d",mBuffer[id].evNum,evtCtrl.evtBuf[k0],k0 ,evtCtrl.evtStat[k0]); 860 factOut(kWarn,601, str ) ; 861 evtCtrl.evtStat[k0] = 91 ; //timeout for incomplete events 862 gi.evtSkp++ ; 863 gi.evtTot++ ; 864 gj.skipEvt++; 865 qskip++; 866 } 867 868 870 gj.bufNew++ ; //incomplete event in Buffer 871 872 if ( evtCtrl.pcTime[k0] < g_actTime-10 ) { 873 int id =evtCtrl.evtBuf[k0] ; 874 snprintf(str,MXSTR,"%5d skip short evt %8d %8d %2d",mBuffer[id].evNum,evtCtrl.evtBuf[k0],k0 ,evtCtrl.evtStat[k0]); 875 factOut(kWarn,601, str ) ; 876 evtCtrl.evtStat[k0] = 91 ; //timeout for incomplete events 877 gi.evtSkp++ ; 878 gi.evtTot++ ; 879 gj.evtSkip++; 880 } 869 881 } else if (evtCtrl.evtStat[k0] >= 900 ) { 870 882 … … 874 886 mBufFree(id) ; //event written--> free memory 875 887 evtCtrl.evtStat[k0] = -1; 876 qdel++; 877 qtot++; 888 gj.evtWrite++ ; 889 gj.rateWrite++ ; 890 } else if (evtCtrl.evtStat[k0] >= 900 ) { 891 gj.bufEvt++ ; //complete event in Buffer 878 892 } 879 893 … … 883 897 } 884 898 885 qconn=0 ; 886 int ib ; 887 for (ib=0; ib<NBOARDS; ib++) qconn+=gi_NumConnect[ib] ; 888 stat[0]= qwait; 889 stat[1]= qskip; 890 stat[2]= qdel ; 891 stat[3]= qtot ; 892 stat[4]= gj.usdMem ; 893 stat[5]= qread; 894 stat[6]= qconn; 895 896 qread=0 ; 899 897 900 gj.deltaT = 1000 ; //temporary, must be improved 901 902 int b; 903 for ( b=0; b<NBOARDS; b++) gj.totBytes[k] +=gj.rateBytes[b] ; 904 gj.totMem = g_maxMem ; 905 if (gj.maxMem >= gj.xxxMem) gj.xxxMem = gj.maxMem ; 898 906 899 907 factStat(gj); 900 908 factStatNew(gi) ; 901 909 902 gj.readEvt = gj.procEvt = gj.writEvt = gj.skipEvt = 0 ; 910 gj.rateNew = gj.rateWrite = 0 ; 911 for ( b=0; b<NBOARDS; b++) gj.rateBytes[k] =0 ; 903 912 } 904 913 … … 948 957 gi_NumConnect[ i/7 ]-- ; 949 958 gi.numConn[ i/7 ]-- ; 959 gj.numConn[ i/7 ]-- ; 950 960 } 951 961 } … … 1074 1084 1075 1085 int i=eventCheck(mBuffer[id].FADhead,mBuffer[id].fEvent) ; 1076 1086 // gj.procEvt++ ; 1077 1087 gi.procTot++ ; 1078 1088 numProc++ ; … … 1259 1269 snprintf(str,MXSTR,"%5d successfully wrote for run %d id %5d",ievt,irun,k0); 1260 1270 factOut(kDebug,504, str ) ; 1261 1271 // gj.writEvt++ ; 1262 1272 } else { 1263 1273 snprintf(str,MXSTR,"W error writing event for run %d",irun) ; … … 1407 1417 } 1408 1418 1409 gj.evtBuf =1410 gj.readEvt =1411 gj.procEvt =1412 gj.writEvt =1413 gj.skipEvt = 0 ;1414 1419 1415 1420 //start all threads (more to come) when we are allowed to .... -
trunk/FACT++/src/FAD.h
r11273 r11293 79 79 uint16_t roi; 80 80 uint16_t filling; 81 uint16_t adc_data[];81 int16_t adc_data[]; 82 82 } __attribute__((__packed__)) PCHANNEL; 83 83 … … 287 287 int32_t writStat ; //write thread 288 288 289 //info about some rates 289 //info about (current state of) the buffer 290 int32_t bufNew ; //# incomplete events in buffer 291 int32_t bufEvt ; //# complete events in buffer 292 uint64_t totMem; //# Bytes available in Buffer 293 uint64_t usdMem; //# Bytes currently used 294 uint64_t xxxMem; //max # Bytes ever used ** 295 uint64_t maxMem; //max # Bytes used during past cycle 296 297 //counters 298 int32_t evtSkip ; //# incomplete Events skipped (timeout) 299 int32_t evtWrite ; //# Events written (or flushed if noWrite) 300 int32_t evtErr ; //# Events with errors 301 302 //rates 290 303 int32_t deltaT ; //time in milli-seconds for rates 291 int32_t readEvt ; //#events read 292 int32_t procEvt ; //#events processed 293 int32_t writEvt ; //#events written 294 int32_t skipEvt ; //#events skipped 295 296 //some info about current state of event buffer (snapspot) 297 int32_t evtBuf; //#Events currently waiting in Buffer 298 uint64_t totMem; //#Bytes available in Buffer 299 uint64_t usdMem; //#Bytes currently used 300 uint64_t maxMem; //max #Bytes used during past Second 304 int32_t rateNew ; //#New start events recieved 305 int32_t rateWrite ; //#Complete events written (or flushed) 306 307 //connections 308 int8_t numConn[NBOARDS] ; //#connections per board (at the moment) 309 int32_t errConn[NBOARDS] ; //#I/O errors per board (counter) 310 int32_t rateBytes[NBOARDS]; //#Bytes read this cycle ** 311 int64_t totBytes[NBOARDS]; //#Bytes read (counter) 312 313 314 // ** // if counter and rates exist, do only update the rates in 315 // ** // real time; 316 // ** // counters will be updated only once per cycle based on rates 301 317 302 318 } __attribute__((__packed__)) GUI_STAT ; //EventBuilder Status
Note:
See TracChangeset
for help on using the changeset viewer.