Ignore:
Timestamp:
06/21/11 20:54:18 (13 years ago)
Author:
tbretz
Message:
Added new connection/disconnection scheme; added eventCheck stub
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/EventBuilder.c

    r11090 r11091  
    4343extern void factStat(int severity, int err, char* message ) ;
    4444
     45extern int  eventCheck( PEVNT_HEADER *fadhd, EVENT *event) ;
    4546
    4647extern void debugRead(int isock, int ibyte, int32_t event, int state,
     
    295296
    296297   
    297    needmem = sizeof(EVENT) + NPIX*nRoi*2 + NTMARK*nRoi*2 ;
     298   needmem = sizeof(EVENT) + NPIX*nRoi*2 + NTMARK*nRoi*2; //
    298299
    299300   headmem = NBOARDS* sizeof(PEVNT_HEADER) ;
     
    576577           snprintf(str,MXSTR,"Socket %d closed by FAD",i);
    577578           factOut(kInfo,441, str ) ;
    578            j = GenSock(1, i, 0,NULL, &rd[i]) ;
     579           GenSock(1, i, 0,NULL, &rd[i]) ;
    579580           gi_ErrCnt[i]++ ;
    580581           gi_NumConnect[ b ]-- ;
     
    852853 snprintf(str,MXSTR,"close all sockets ...");
    853854 factOut(kInfo,-1, str ) ;
    854  for (i=0; i<MAX_SOCK; i++)   
    855     if (rd[i].sockStat ==0 ) { 
    856        j=close(rd[i].socket) ;
    857        if (j>0) {
    858           snprintf(str,MXSTR,"Error closing socket %d | %m",i);
    859           factOut(kFatal,771, str ) ;
    860        }
    861        rd[i].sockStat = -1 ;        //flag (try to reopen next round)
    862        gi_NumConnect[ i/7 ]-- ;
    863     }
     855 for (i=0; i<MAX_SOCK; i++) { 
     856    GenSock(-1, i, 0, NULL, &rd[i]) ; //close and destroy socket   
     857    gi_NumConnect[ i/7 ]-- ;
     858 }
    864859
    865860 xwait.tv_sec = 0;
     
    944939        if (evtCtrl.evtStat[k0] > 90 && evtCtrl.evtStat[k0] <500) {
    945940           int      id   = evtCtrl.evtBuf[k0] ;
    946            uint32_t irun = mBuffer[id].runNum ;
    947941           int      ievt = mBuffer[id].evNum ;
    948942           int      roi  = mBuffer[id].nRoi ;
     943//         uint32_t irun = mBuffer[id].runNum ;
    949944//snprintf(str,MXSTR,"P processing %d %d %d %d",ievt,k,id,evtCtrl.evtStat[k0]) ;
    950945//factOut(kDebug,-1, str ) ;
     
    964959             }
    965960           }
    966 //and set correct event header ; also check for consistency in event
    967           mBuffer[id].fEvent->Roi = roi ;
    968           mBuffer[id].fEvent->EventNum = ievt ;
    969           mBuffer[id].fEvent->TriggerType = 0 ; // TBD
    970           mBuffer[id].fEvent->SoftTrig = 0 ;
    971           for (ib=0; ib<NBOARDS; ib++) {
    972              mBuffer[id].fEvent->BoardTime[ib] = 123 ;
    973 
    974 
    975 
    976 
     961
     962
     963//and set correct event header ; also check for consistency in event (not yet)
     964           mBuffer[id].fEvent->Roi = roi ;
     965           mBuffer[id].fEvent->EventNum = ievt ;
     966           mBuffer[id].fEvent->TriggerType = 0 ; // TBD
     967           mBuffer[id].fEvent->SoftTrig = 0 ;
     968           for (ib=0; ib<NBOARDS; ib++) {
     969              if (mBuffer[id].board[ib] == -1 ) {  //board is not read
     970                 mBuffer[id].FADhead[ib].start_package_flag = 0 ;
     971                 mBuffer[id].fEvent->BoardTime[ib] = 0 ;
     972              } else {
     973                 mBuffer[id].fEvent->BoardTime[ib] =
     974                 ntohl(mBuffer[id].FADhead[ib].time) ;
     975              }
    977976           }
     977
     978           int i=eventCheck(mBuffer[id].FADhead,mBuffer[id].fEvent) ;
     979           
     980           if (i<0) evtCtrl.evtStat[k0] = 999 ; //flag event to be skipped
     981
    978982           numProc++ ;
    979983           evtCtrl.evtStat[k0] = 520 ;
     
    13061310
    13071311
    1308 
     1312/*
    13091313     xwait.tv_sec = 20;;
    13101314     xwait.tv_nsec= 0 ;  // sleep for ~20sec
     
    13241328
    13251329     g_runStat = -1 ;
    1326 
     1330*/
    13271331
    13281332
     
    13711375
    13721376
     1377
     1378int  eventCheck( PEVNT_HEADER *fadhd, EVENT *event)
     1379{
     1380   int i=0;
     1381
     1382   printf("------------%d\n",ntohl(fadhd[7].fad_evt_counter) );
     1383   for (i=0; i<NBOARDS; i++) {
     1384      printf("b=%2d,=%5d\n",i,fadhd[i].board_id);
     1385   }
     1386   return 0;
     1387}
     1388
     1389
    13731390void factStat(int severity, int err, char* message ) {
    13741391  printf("%3d %3d : %s\n",severity,err,message) ;
     
    13771394
    13781395void debugRead(int isock, int ibyte, int32_t event, int state, uint32_t tsec, uint32_t tusec ) {
    1379   printf("%3d %5d %9d %3d %12d\n",isock, ibyte, event, state, tusec) ;
     1396//  printf("%3d %5d %9d %3d %12d\n",isock, ibyte, event, state, tusec) ;
    13801397}
    13811398
Note: See TracChangeset for help on using the changeset viewer.