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

Diff of /yoda/techmodel/McmdReader.cpp

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

revision 1.2 by kusanagi, Sat Jul 17 20:03:38 2004 UTC revision 3.0 by kusanagi, Fri Mar 4 15:54:11 2005 UTC
# Line 1  Line 1 
1  /** @file  /** @file
2   * $Source: /home/cvsmanager/yoda/techmodel/McmdReader.cpp,v $   * $Source: /home/cvsmanager/yoda/techmodel/McmdReader.cpp,v $
3   * $Id: McmdReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 kusanagi Exp $   * $Id: McmdReader.cpp,v 2.1 2004/12/03 22:08:00 kusanagi Exp $
4   * $Author: kusanagi $   * $Author: kusanagi $
5   *   *
6   * Implementation of the McmdReader class.   * Implementation of the McmdReader class.
# Line 8  Line 8 
8    
9  #define BYTE unsigned char  #define BYTE unsigned char
10  #include <string>  #include <string>
11  #include <log4cpp/Category.hh>  #include <log4cxx/logger.h>
12  extern "C" {  extern "C" {
13  #include <sys/time.h>  #include <sys/time.h>
14  #include "CRC.h"  #include "CRC.h"
# Line 23  extern "C" { Line 23  extern "C" {
23  using namespace pamela;  using namespace pamela;
24  using namespace pamela::techmodel;  using namespace pamela::techmodel;
25    
26  static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.McmdReader");    static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.McmdReader"));
27    static std::stringstream oss;
28  /**  /**
29   * Constructor.   * Constructor.
30   */   */
31  McmdReader::McmdReader(void):  McmdReader::McmdReader(void):
32    TechmodelAlgorithm(PacketType::Mcmd, "Mcmd") {    TechmodelAlgorithm(PacketType::Mcmd, "Mcmd") {
33    cat <<  log4cpp::Priority::DEBUG    logger->debug(_T("Constructor"));
       <<  "Constructor "  
       <<  "\n " << log4cpp::CategoryStream::ENDLINE;  
34    Mcmd = new McmdEvent();    Mcmd = new McmdEvent();
35  }  }
36    
# Line 41  McmdReader::McmdReader(void): Line 39  McmdReader::McmdReader(void):
39   */   */
40  std::string McmdReader::GetVersionInfo(void) const {  std::string McmdReader::GetVersionInfo(void) const {
41    return    return
42      "$Header: /home/cvsmanager/yoda/techmodel/McmdReader.cpp,v 1.1.1.1 2004/07/06 12:20:23 kusanagi Exp $\n";      "$Header: /home/cvsmanager/yoda/techmodel/McmdReader.cpp,v 2.1 2004/12/03 22:08:00 kusanagi Exp $\n";
43  }  }
44    
45  /**  /**
# Line 49  std::string McmdReader::GetVersionInfo(v Line 47  std::string McmdReader::GetVersionInfo(v
47   * event reader routines for all packet types.   * event reader routines for all packet types.
48   */   */
49  void McmdReader::Init(PamelaRun *run) {  void McmdReader::Init(PamelaRun *run) {
50      logger->debug(_T("Initialize"));
51    SetInputStream(run);    SetInputStream(run);
52    run->WriteSubPacket(this, &Mcmd, Mcmd->Class());    run->WriteSubPacket(this, &Mcmd, Mcmd->Class());
53  }  }
# Line 76  void McmdReader::Init(PamelaRun *run) { Line 75  void McmdReader::Init(PamelaRun *run) {
75   * @Event Number   * @Event Number
76   * @length is the size in bytes of the event (or packet)   * @length is the size in bytes of the event (or packet)
77   */   */
78  void McmdReader::RunEvent(int EventNumber, long int length) {  void McmdReader::RunEvent(int EventNumber, long int length) throw (WrongCRCException){
79        
80    int i = 0;    int i = 0;
81    char OBT[4];    char OBT[4];
# Line 165  void McmdReader::RunEvent(int EventNumbe Line 164  void McmdReader::RunEvent(int EventNumbe
164          rec->McmdLength      = (0x0fff)&(((UINT16)(subHeader[4]<<8)) + ((UINT16)subHeader[5]));          rec->McmdLength      = (0x0fff)&(((UINT16)(subHeader[4]<<8)) + ((UINT16)subHeader[5]));
165          rec->TimeTag         = (((UINT32)OBT[6]<<24)&0xFF000000) + (((UINT32)OBT[7]<<16)&0x00FF0000) +  (((UINT32)OBT[8]<<8)&0x0000FF00) + (((UINT32)OBT[9])&0x000000FF);          rec->TimeTag         = (((UINT32)OBT[6]<<24)&0xFF000000) + (((UINT32)OBT[7]<<16)&0x00FF0000) +  (((UINT32)OBT[8]<<8)&0x0000FF00) + (((UINT32)OBT[9])&0x000000FF);
166          rec->endID           = (BYTE)subTrailer[1];          rec->endID           = (BYTE)subTrailer[1];
167          rec->setMcmdData((BYTE*)&subData);  
168          //partialCRC = CM_Compute_CRC16(partialCRC, (BYTE*)&readCRC, 1);          rec->McmdData        = new TArrayC(dataLength, subData);
169          //free(subData);          delete [] subData;
170      } else {      } else {
171          cat <<  log4cpp::Priority::ERROR              oss.str("");
172              <<  "Wrong CRC on Subpacket int MCMD Packet starting at position " << start              oss << "Wrong CRC on Subpacket internal to TMTC Packet starting at position"
173              <<  "\n " << log4cpp::CategoryStream::ENDLINE;                  << start;
174                logger->warn(oss.str().c_str());
175      }      }
176    }    }
177      //in the end compare the calculated partial CRC with the MCMD packet CRC      //in the end compare the calculated partial CRC with the MCMD packet CRC
178      InputFile->read(eventCRC, sizeof(eventCRC));      InputFile->read(eventCRC, sizeof(eventCRC));
179      readCRC = (((UINT16)(eventCRC[0]<<8))&0xFF00) + (((UINT16)eventCRC[1])&0x00FF);      readCRC = (((UINT16)(eventCRC[0]<<8))&0xFF00) + (((UINT16)eventCRC[1])&0x00FF);
180            
181      if(!(partialCRC == readCRC)) {      if(partialCRC != readCRC) throw WrongCRCException(" Wrong Global CRC for MCMD Packet ");
182             cat <<  log4cpp::Priority::ERROR      /*if(!(partialCRC == readCRC)) {
183              <<  "Wrong CRC for CalibS4 Packet"          throw WrongCRCException();
184              <<  "\n " << log4cpp::CategoryStream::ENDLINE;      }*/
     }  
185  }  }
186    
187    

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

  ViewVC Help
Powered by ViewVC 1.1.23