--- yoda/techmodel/CalibHeaderReader.cpp 2004/09/21 20:50:54 2.0 +++ yoda/techmodel/CalibHeaderReader.cpp 2006/05/30 19:10:03 6.2 @@ -1,23 +1,13 @@ +/** @file + * $Author: kusanagi $ + * $Date: 2006/05/30 19:10:01 $ + * $Revision: 6.1 $ + * + * Implementation of the CalibHeaderReader class. + */ -// Implementation of the CalibHeaderReader class. - - -#define UINT unsigned int -#define BYTE unsigned char -#include -#include -extern "C" { -#include -#include "CRC.h" -} - -#include -#include "stdio.h" #include "ReaderAlgorithms.h" -#include "event/CalibHeaderEvent.h" - -using namespace pamela; using namespace pamela::techmodel; static log4cxx::LoggerPtr logger = log4cxx::Logger::getLogger(_T("pamela.techmodel.CalibHeaderReader")); @@ -36,7 +26,7 @@ */ std::string CalibHeaderReader::GetVersionInfo(void) const { return - "$Header: /home/cvsmanager/yoda/techmodel/CalibHeaderReader.cpp,v 1.2 2004/09/21 20:24:33 kusanagi Exp $\n"; + "$Header: /home/cvsmanager/yoda/techmodel/CalibHeaderReader.cpp,v 6.1 2006/05/30 19:10:01 kusanagi Exp $\n"; } /** @@ -52,8 +42,17 @@ /** * Unpack the CalibHeader event from an input file. */ -void CalibHeaderReader::RunEvent(int EventNumber, long int length) { - - +void CalibHeaderReader::RunEvent(int EventNumber, long int dataLength) throw (WrongCRCException){ + char subData[dataLength]; + UINT16 subCRC; //calculated CRC of the data + UINT16 readCRC; //CRC read from the end of the subpacket + long int length = dataLength - 2; //the block of data + + InputFile->read(subData, sizeof(subData)); + subCRC = CM_Compute_CRC16(0, (UINT8*)subData, length); + readCRC = (((UINT16)(subData[dataLength - 2]<<8))&0xFF00) + (((UINT16)subData[dataLength - 1])&0x00FF); + + if (subCRC != readCRC) throw WrongCRCException(" Wrong CRC for CalibHeader Packet "); + calibHeader->calibHeaderData = new TArrayC(length, subData); }