MicrorocLabviewReader Class Reference

#include <MicrorocLabviewReader.hh>

Inheritance diagram for MicrorocLabviewReader:

Inheritance graph
[legend]
Collaboration diagram for MicrorocLabviewReader:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 MicrorocLabviewReader (Run &aRun, FILE *aFile, ui32 lastEventId, bool forceAnalog, std::set< unsigned int > *=NULL)
 ~MicrorocLabviewReader ()
int getNextEvent (Event &eventToFill)
unsigned int getSpecificData (const unsigned int nBytes)

Static Public Member Functions

static const char * type (const int subtype=0)

Private Attributes

ui16 nbBufferedData
unsigned int bufferedData

Detailed Description

CLASS DATAREADER //

Definition at line 32 of file MicrorocLabviewReader.hh.


Constructor & Destructor Documentation

MicrorocLabviewReader::MicrorocLabviewReader ( Run aRun,
FILE *  aFile,
ui32  lastEventId,
bool  forceAnalog,
std::set< unsigned int > *  = NULL 
)

MicrorocLabviewReader::~MicrorocLabviewReader (  ) 

Definition at line 48 of file MicrorocLabviewReader.cpp.

00049 {
00050   FILE_LOG(logDEBUG1)<< "----MicrorocLabviewReader destructor"<< endl;
00051 }


Member Function Documentation

static const char* MicrorocLabviewReader::type ( const int  subtype = 0  )  [inline, static]

Reimplemented from MicrorocMergeReader.

Definition at line 36 of file MicrorocLabviewReader.hh.

Referenced by main().

00036 { return LABVIEWMR; };

int MicrorocLabviewReader::getNextEvent ( Event eventToFill  )  [virtual]

Implements MicrorocMergeReader.

Definition at line 59 of file MicrorocLabviewReader.cpp.

00059                                                     {
00060   // Start data reconstruction
00061   Level(0);
00062 
00063         ui16 dataFormat = run.getDataFormat();
00064 
00065   if (dataFormat == 0) {
00066     // first read of the file
00067     bcIdDifAbsOrgMap.clear();
00068     // read file header
00069     dataFormat = getData(1);
00070     if ( dataFormat == 0x10  ) { dataFormat = 0xa; }
00071                 run.setDataFormat(dataFormat);
00072     if ( run.getDataFormat() != 15 && run.getDataFormat() != 14 )
00073     {
00074       FILE_LOG(logERROR) << "labview data format[" << dec << dataFormat << "] not implemented" << endl;
00075       return(LAST_FILE_EVENT);
00076     }
00077 
00078 
00079     if (fileError == EOF) {
00080       FILE_LOG(logERROR) << "parsing file[" << inputFile << "]  - error " << errno << ":" << strerror(errno) << endl;
00081       reset();
00082       return(LAST_FILE_EVENT);
00083     }
00084     display(+1);
00085     FILE_LOG(logINFO) << "  Microroc LABVIEW DATA FORMAT  : " << dataFormat << endl;
00086 
00087     if ( dataFormat != 15 && run.getDataFormat() != 14  ){
00088       // unknown format
00089       FILE_LOG(logERROR) << " Microroc LABVIEW data format  " << dataFormat << " is not implemented" << endl;
00090       reset();
00091       return(LAST_FILE_EVENT);
00092     }
00093 
00094         if ( dataFormat == 15 || dataFormat == 14 )
00095   {
00096 
00097                 run.setDaqSoftware(getData(2) );
00098                 display(+1);
00099                 FILE_LOG(logINFO) << hex << "  DAQ software version  : " << run.getDaqSoftware() <<endl;
00100 
00101    run.setSDccFirmware(getData(2));
00102    display(+1);
00103    FILE_LOG(logINFO) << hex << "  SDcc firware  : 0x" << run.getSDccFirmware() << endl;
00104 
00105    run.setDifFirmware(getData(2));
00106    display(+1);
00107    FILE_LOG(logINFO) << hex << "  Dif firware  : 0x" << run.getDifFirmware() << endl;
00108   
00109     globalTime = getData(4)    ; // labview time is second since 1 janv 1970 and globalTime milli second
00110     FILE_LOG(logDEBUG) << "globalTime in second:[0x"  << hex << globalTime << "] decimal[" << dec << globalTime << "]" <<   endl;
00111     globalTime *= 1000;
00112     FILE_LOG(logDEBUG) << "globalTime in millisecond:[" << globalTime << "]" <<  endl;
00113 
00114     globalTimeMilli = getData(4)    ; // labview time in millisecond
00115     FILE_LOG(logDEBUG) << "Plus globalTimeMilli in millisecond:[0x"  << hex << globalTimeMilli << "] decimal [" << dec <<  globalTimeMilli << "]" <<  endl;
00116   }
00117 
00118 
00119     if (fileError == EOF) {
00120       FILE_LOG(logDEBUG) << "  END OF DATA FILE" << endl;
00121       reset();
00122       return(LAST_FILE_EVENT);
00123     }
00124     //FILE_LOG(logDEBUG) << run.getDetector() << endl;
00125     display(-1);
00126     return NEW_CONFIG;
00127   }
00128 
00129   if (  skipNbEvent != 0 && debugEventId < skipNbEvent)
00130   {
00131     while ( debugEventId < skipNbEvent )
00132     {
00133       unsigned int globalHeader = getSpecificData(1);
00134       if (fileError == EOF) {
00135         FILE_LOG(logDEBUG) << "  END OF DATA FILE" << endl;
00136         return(LAST_FILE_EVENT);
00137       }
00138       FILE_LOG(logDEBUG1) << "DEBUG 1 wait for 0xa0[0x " << hex << globalHeader << "]"  << endl;
00139       while ( globalHeader != 0xa0  )
00140       {
00141         globalHeader = getSpecificData(1);
00142         FILE_LOG(logDEBUG1) << "wait for 0xa0[0x " << hex << globalHeader << "]"  << endl;
00143         if (fileError == EOF) {
00144           FILE_LOG(logDEBUG) << "  END OF DATA FILE" << endl;
00145           return(LAST_FILE_EVENT);
00146         }
00147       }
00148 
00149       unsigned int crc = getSpecificData(2);
00150       globalHeader = getSpecificData(1);
00151       FILE_LOG(logDEBUG1) << "wait for 0xb0[0x " << hex << globalHeader << "]"  << endl;
00152       if ( globalHeader == 0xb0 )
00153       { 
00154         FILE_LOG(logINFO) << "skip event " << debugEventId <<   "\t\t\t\t   \r" << flush;
00155 
00156         debugEventId++;
00157       }
00158     }
00159   
00160    FILE_LOG(logINFO) <<  debugEventId++ << " event(s)  skipped "  << endl;
00161    nbBufferedData = 1;
00162    bufferedData = 0xb0;
00163   }
00164 
00165 
00166   // loops until a non-empty event has been found
00167         bool eventFound = false;
00168         while (! eventFound)
00169                 {
00170       eventFound = MicrorocMergeReader::decodeData(event);
00171       if (fileError == EOF) 
00172       {
00173         FILE_LOG(logDEBUG) << "  END OF DATA FILE" << endl;
00174         reset();
00175         return(LAST_FILE_EVENT);
00176       }
00177           }
00178 
00179   if ( event.getChannelHitSize() > 0 )
00180   {
00181     event.setId(++lastEventId);
00182     return EVENT_CORRECT;
00183   }
00184   else
00185   {
00186     return EVENT_ERROR;
00187   }
00188 }

unsigned int MicrorocLabviewReader::getSpecificData ( const unsigned int  nBytes  )  [virtual]

Implements MicrorocMergeReader.

Definition at line 191 of file MicrorocLabviewReader.cpp.

Referenced by getNextEvent().

00192 {
00193   if (nbBufferedData != 0 )
00194   {
00195     if ( nbBufferedData > 1 ) { FILE_LOG(logERROR) << "  could only buffed 1 byte" << endl; exit(1); }
00196     nbBufferedData = 0;
00197     return  bufferedData;
00198   }
00199 
00200   else
00201   {
00202     return DifReader::getData(nBytes);
00203   }
00204 }


Member Data Documentation

ui16 MicrorocLabviewReader::nbBufferedData [private]

Definition at line 45 of file MicrorocLabviewReader.hh.

Referenced by getNextEvent(), and getSpecificData().

unsigned int MicrorocLabviewReader::bufferedData [private]

Definition at line 46 of file MicrorocLabviewReader.hh.

Referenced by getNextEvent(), and getSpecificData().


The documentation for this class was generated from the following files:
Generated on Mon Jan 7 13:18:44 2013 for MicromegasFramework by  doxygen 1.4.7