/[PAMELA software]/yoda/techmodel/LogReader.cpp
ViewVC logotype

Diff of /yoda/techmodel/LogReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by kusanagi, Tue Jul 6 12:20:23 2004 UTC revision 1.2 by kusanagi, Sat Jul 17 20:03:38 2004 UTC
# Line 1  Line 1 
1  /** @file  /** @file
2   * $Source: /home/cvspamela/yoda/techmodel/LogReader.cpp,v $   * $Source: /home/cvsmanager/yoda/techmodel/LogReader.cpp,v $
3   * $Id: LogReader.cpp,v 1.2 2004/04/28 09:01:27 nagni Exp $   * $Id: LogReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 kusanagi Exp $
4   * $Author: nagni $   * $Author: kusanagi $
5   *   *
6   * Implementation of the LogReader class.   * Implementation of the LogReader class.
7  * ToBeDone:  * ToBeDone:
# Line 44  LogReader::LogReader(void): Line 44  LogReader::LogReader(void):
44   */   */
45  std::string LogReader::GetVersionInfo(void) const {  std::string LogReader::GetVersionInfo(void) const {
46    return    return
47      "$Header: /home/cvspamela/yoda/techmodel/LogReader.cpp,v 1.2 2004/04/28 09:01:27 nagni Exp $\n";      "$Header: /home/cvsmanager/yoda/techmodel/LogReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 kusanagi Exp $\n";
48  }  }
49    
50  /**  /**
# Line 60  void LogReader::Init(PamelaRun *run) { Line 60  void LogReader::Init(PamelaRun *run) {
60   * Unpack the Log event from an input file.   * Unpack the Log event from an input file.
61   */   */
62  void LogReader::RunEvent(int EventNumber, long int length) {  void LogReader::RunEvent(int EventNumber, long int length) {
63      int i, j;      char     *subData;
64      char buff[9];      char      eventCRC[2];
65      int numRecords = length/9;      UINT16    subCRC;      //CRC of the data
66      TClonesArray &recs = *(Log->Records);      UINT16    readCRC;     //CRC read from the end of the subpacket
67      LogRecord* rec;          long int  dataLength;
68    
69        //the 2 bytes subtracted belong to the final event CRC bytes
70        dataLength = length - (long int)2;
71    
72        subData = new char[dataLength];
73        InputFile->read(subData, sizeof(unsigned char)*dataLength);
74        subCRC = CM_Compute_CRC16(0, (BYTE*)subData, dataLength);
75    
76        //took the final CRC to compare it with the previous calculated CRC of the data
77        InputFile->read(eventCRC, sizeof(eventCRC));
78        readCRC = (((UINT16)(eventCRC[0]<<8))&0xFF00) + (((UINT16)eventCRC[1])&0x00FF);
79            
80      for(i = 0; i < numRecords; i++) {  if (subCRC == readCRC){
81          InputFile->read(buff, sizeof(buff));          LogRecord* rec;
82          rec = new(recs[i]) LogRecord(); //aggiungo un nuovo TmtcRecord all'evento          long int offset = 0;
83          rec->LG_RECORD_OBT = (((UINT32)buff[0]<<24)&0xFF000000) + (((UINT32)buff[1]<<16)&0x00FF0000) +  (((UINT32)buff[2]<<8)&0x0000FF00) + (((UINT32)buff[3])&0x000000FF);          int i = 0;
84          rec->LG_LINE       = (((UINT16)buff[4]<<8)&0xFF00) + (((UINT16)buff[5])&0x00FF);          Log->Records->Clear();
85          rec->LG_INFO       = (((UINT16)buff[6]<<8)&0xFF00) + (((BYTE)buff[7])&0x00FF);          TClonesArray &recs = *(Log->Records);
86          rec->LG_FILE_ID    = ((UINT16)buff[8]);          while (offset < dataLength){
87    }              rec = new(recs[i++]) LogRecord(); //add a new Log
88                rec->LG_RECORD_OBT  = (((UINT32)subData[offset]<<24)&0xFF000000) + (((UINT32)subData[offset+1]<<16)&0x00FF0000) +  (((UINT32)subData[offset+2]<<8)&0x0000FF00) + (((UINT32)subData[offset+3])&0x000000FF);
89      /*for(i = 0; i < numRecords; i++) {              rec->LG_LINE        = (((UINT16)subData[offset+4]<<8)&0xFF00) + (((UINT16)subData[offset+5])&0x00FF);
90  LogRecord *record = static_cast<LogRecord*>((recs).At(i));              rec->LG_INFO        = (((UINT16)subData[offset+6]<<8)&0xFF00) + (((UINT16)subData[offset+7])&0x00FF);
91  cat <<  log4cpp::Priority::INFO              rec->LG_FILE_ID     = ((UINT8)subData[offset+8])&0xFF;
92        <<  "\n Record OBT: "              offset = offset + 9;
93        <<  record->LG_RECORD_OBT();          }
94      }*/          free(subData);
95        } else {
96            cat <<  log4cpp::Priority::ERROR
97                <<  "Wrong CRC in Log Packet "
98                <<  "\n " << log4cpp::CategoryStream::ENDLINE;
99        }
100  }  }
   

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

  ViewVC Help
Powered by ViewVC 1.1.23