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

Diff of /yoda/techmodel/CalibS4Reader.cpp

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

revision 1.3 by kusanagi, Tue Sep 21 20:24:33 2004 UTC revision 2.2 by kusanagi, Fri Dec 3 22:08:00 2004 UTC
# Line 1  Line 1 
1  /** @file  /** @file
2   * $Source: /home/cvsmanager/yoda/techmodel/CalibS4Reader.cpp,v $   * $Source: /home/cvsmanager/yoda/techmodel/CalibS4Reader.cpp,v $
3   * $Id: CalibS4Reader.cpp,v 1.2 2004/07/17 20:03:38 kusanagi Exp $   * $Id: CalibS4Reader.cpp,v 2.1 2004/10/17 12:28:38 kusanagi Exp $
4   * $Author: kusanagi $   * $Author: kusanagi $
5   *   *
6   * Implementation of the LogReader class.   * Implementation of the LogReader class.
# Line 42  CalibS4Reader::CalibS4Reader(void): Line 42  CalibS4Reader::CalibS4Reader(void):
42   */   */
43  std::string CalibS4Reader::GetVersionInfo(void) const {  std::string CalibS4Reader::GetVersionInfo(void) const {
44    return    return
45      "$Header: /home/cvsmanager/yoda/techmodel/CalibS4Reader.cpp,v 1.2 2004/07/17 20:03:38 kusanagi Exp $\n";      "$Header: /home/cvsmanager/yoda/techmodel/CalibS4Reader.cpp,v 2.1 2004/10/17 12:28:38 kusanagi Exp $\n";
46  }  }
47    
48  /**  /**
# Line 58  void CalibS4Reader::Init(PamelaRun *run) Line 58  void CalibS4Reader::Init(PamelaRun *run)
58  /**  /**
59   * Unpack the CalibS4 event from an input file.   * Unpack the CalibS4 event from an input file.
60   */   */
61  void CalibS4Reader::RunEvent(int EventNumber, long int length) {  void CalibS4Reader::RunEvent(int EventNumber, long int dataLength) throw (Exception){
62      char     *subData;      char      subData[dataLength];
     char      eventCRC[2];  
     UINT16    subCRC;      //CRC of the data  
     UINT16    readCRC;     //CRC read from the end of the subpacket  
     long int  dataLength;  
   
     //the 2 bytes subtracted belong to the final event CRC bytes  
     dataLength = length - (long int)2;  
   
     subData = new char[dataLength];  
63      InputFile->read(subData, sizeof(unsigned char)*dataLength);      InputFile->read(subData, sizeof(unsigned char)*dataLength);
     subCRC = CM_Compute_CRC16(0, (BYTE*)subData, dataLength);  
64    
65      //took the final CRC to compare it with the previous calculated CRC of the data      for (int i = 0; i < 384; i++){
66      InputFile->read(eventCRC, sizeof(eventCRC));          CalibS4->S4register[i]  = ((UINT16)subData[i*6] + (UINT16)subData[(i*6)+1])&0x0FFF;
67      readCRC = (((UINT16)(eventCRC[0]<<8))&0xFF00) + (((UINT16)eventCRC[1])&0x00FF);          CalibS4->S4command[i]   = (BYTE)subData[(i*6)+2];
68                CalibS4->S4length[i]    = ((UINT16)subData[(i*6)+3])&0xFF00 + ((UINT16)subData[(i*6)+4])&0x00FF;
69      if (subCRC == readCRC){          CalibS4->S4crc[i]       = (BYTE)subData[(i*6)+5];
         //put here the reader  
     } else {  
         logger->warn(_T("Wrong CRC for CalibS4 Packet "));  
70      }      }
71        
72  }  }
73    

Legend:
Removed from v.1.3  
changed lines
  Added in v.2.2

  ViewVC Help
Powered by ViewVC 1.1.23