/** @file * $Source: /home/cvspamela/yoda/techmodel/LogReader.cpp,v $ * $Id: LogReader.cpp,v 1.2 2004/04/28 09:01:27 nagni Exp $ * $Author: nagni $ * * Implementation of the LogReader class. * ToBeDone: * Control the CRC for the entire data Packet not just for single records */ #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/log/LogRecord.h" using namespace pamela; using namespace pamela::techmodel; static log4cpp::Category& cat = log4cpp::Category::getInstance("pamela.techmodel.LogReader"); /** * Constructor. */ LogReader::LogReader(void): TechmodelAlgorithm(PacketType::Log, "TechmodelLogReader") { cat << log4cpp::Priority::DEBUG << "Constructor " << "\n " << log4cpp::CategoryStream::ENDLINE; Log = new LogEvent(); } /** * Get a string with the version info of the algorithm. */ std::string LogReader::GetVersionInfo(void) const { return "$Header: /home/cvspamela/yoda/techmodel/LogReader.cpp,v 1.2 2004/04/28 09:01:27 nagni Exp $\n"; } /** * Initialize the algorithm with a special run. This will initialize the * event reader routines for all packet types. */ void LogReader::Init(PamelaRun *run) { SetInputStream(run); run->WriteSubPacket(this, &Log, Log->Class()); } /** * Unpack the Log event from an input file. */ void LogReader::RunEvent(int EventNumber, long int length) { int i, j; char buff[9]; int numRecords = length/9; TClonesArray &recs = *(Log->Records); LogRecord* rec; for(i = 0; i < numRecords; i++) { InputFile->read(buff, sizeof(buff)); rec = new(recs[i]) LogRecord(); //aggiungo un nuovo TmtcRecord all'evento rec->LG_RECORD_OBT = (((UINT32)buff[0]<<24)&0xFF000000) + (((UINT32)buff[1]<<16)&0x00FF0000) + (((UINT32)buff[2]<<8)&0x0000FF00) + (((UINT32)buff[3])&0x000000FF); rec->LG_LINE = (((UINT16)buff[4]<<8)&0xFF00) + (((UINT16)buff[5])&0x00FF); rec->LG_INFO = (((UINT16)buff[6]<<8)&0xFF00) + (((BYTE)buff[7])&0x00FF); rec->LG_FILE_ID = ((UINT16)buff[8]); } /*for(i = 0; i < numRecords; i++) { LogRecord *record = static_cast((recs).At(i)); cat << log4cpp::Priority::INFO << "\n Record OBT: " << record->LG_RECORD_OBT(); }*/ }