--- yoda/techmodel/LogReader.cpp 2004/09/21 20:24:33 1.5 +++ yoda/techmodel/LogReader.cpp 2004/12/03 22:08:00 2.1 @@ -1,6 +1,6 @@ /** @file * $Source: /home/cvsmanager/yoda/techmodel/LogReader.cpp,v $ - * $Id: LogReader.cpp,v 1.4 2004/08/24 16:01:57 kusanagi Exp $ + * $Id: LogReader.cpp,v 2.0 2004/09/21 20:50:54 kusanagi Exp $ * $Author: kusanagi $ * * Implementation of the LogReader class. @@ -20,7 +20,6 @@ #include #include "stdio.h" #include "ReaderAlgorithms.h" - #include "event/log/LogRecord.h" using namespace pamela; @@ -42,7 +41,7 @@ */ std::string LogReader::GetVersionInfo(void) const { return - "$Header: /home/cvsmanager/yoda/techmodel/LogReader.cpp,v 1.4 2004/08/24 16:01:57 kusanagi Exp $\n"; + "$Header: /home/cvsmanager/yoda/techmodel/LogReader.cpp,v 2.0 2004/09/21 20:50:54 kusanagi Exp $\n"; } /** @@ -58,7 +57,7 @@ /** * Unpack the Log event from an input file. */ -void LogReader::RunEvent(int EventNumber, long int length) { +void LogReader::RunEvent(int EventNumber, long int length) throw (WrongCRCException){ char *subData; char eventCRC[2]; UINT16 subCRC; //CRC of the data @@ -70,33 +69,27 @@ subData = new char[dataLength]; InputFile->read(subData, sizeof(unsigned char)*dataLength); - subCRC = CM_Compute_CRC16(0, (BYTE*)subData, dataLength); + subCRC = CM_Compute_CRC16(0, (BYTE*)&subData, dataLength); //took the final CRC to compare it with the previous calculated CRC of the data InputFile->read(eventCRC, sizeof(eventCRC)); readCRC = (((UINT16)(eventCRC[0]<<8))&0xFF00) + (((UINT16)eventCRC[1])&0x00FF); -if (subCRC == readCRC){ - LogRecord* rec; - long int offset = 0; - int i = 0; - Log->Records->Clear(); - TClonesArray &recs = *(Log->Records); - while (offset < dataLength){ - rec = new(recs[i++]) LogRecord(); //add a new Log - rec->RECORD_OBT = (((UINT32)subData[offset]<<24)&0xFF000000) + (((UINT32)subData[offset+1]<<16)&0x00FF0000) + (((UINT32)subData[offset+2]<<8)&0x0000FF00) + (((UINT32)subData[offset+3])&0x000000FF); - rec->MASKTYPE = (((UINT8)subData[offset+4]<<8)&0xFF); - rec->FILE_ID = (((UINT8)subData[offset+5]<<8)&0xFF); - rec->LINE_NO = ((((UINT16)subData[offset+6]<<8)&0xFF00) + (((UINT16)subData[offset+7])&0x00FF)); - rec->INFO1 = (((UINT32)subData[offset+8]<<24)&0xFF000000) + (((UINT32)subData[offset+9]<<16)&0x00FF0000) + (((UINT32)subData[offset+10]<<8)&0x0000FF00) + (((UINT32)subData[offset+11])&0x000000FF); - offset = offset + 12; - } - } else { - std::stringstream oss; - oss.flush(); - oss << "Wrong CRC on Subpacket internal to Log Packet";// starting at position"; - //<< start; - logger->warn(oss.str().c_str()); + if (subCRC != readCRC) throw WrongCRCException(" Wrong CRC for RunTrailer Packet "); + + LogRecord* rec; + long int offset = 0; + int i = 0; + Log->Records->Clear(); + TClonesArray &recs = *(Log->Records); + while (offset < dataLength){ + rec = new(recs[i++]) LogRecord(); //add a new Log + rec->RECORD_OBT = (((UINT32)subData[offset]<<24)&0xFF000000) + (((UINT32)subData[offset+1]<<16)&0x00FF0000) + (((UINT32)subData[offset+2]<<8)&0x0000FF00) + (((UINT32)subData[offset+3])&0x000000FF); + rec->MASKTYPE = (((UINT8)subData[offset+4]<<8)&0xFF); + rec->FILE_ID = (((UINT8)subData[offset+5]<<8)&0xFF); + rec->LINE_NO = ((((UINT16)subData[offset+6]<<8)&0xFF00) + (((UINT16)subData[offset+7])&0x00FF)); + rec->INFO1 = (((UINT32)subData[offset+8]<<24)&0xFF000000) + (((UINT32)subData[offset+9]<<16)&0x00FF0000) + (((UINT32)subData[offset+10]<<8)&0x0000FF00) + (((UINT32)subData[offset+11])&0x000000FF); + offset = offset + 12; } delete [] subData; }