/[PAMELA software]/chewbacca/PamOffLineSW/techmodel/LogReader.cpp
ViewVC logotype

Annotation of /chewbacca/PamOffLineSW/techmodel/LogReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (download) (vendor branch)
Tue Sep 23 07:20:28 2008 UTC (16 years, 2 months ago) by mocchiut
Branch: v0r00, MAIN
CVS Tags: v1r02, v1r00, v1r01, start, v10RED, v9r00, v9r01, HEAD
Changes since 1.1: +0 -0 lines
Imported sources, 23/09/2008

1 mocchiut 1.1 /** @file
2     * $Source: /repository/PamOffLineSW/techmodel/LogReader.cpp,v $
3     * $Id: LogReader.cpp,v 1.6 2008-03-04 18:09:30 messineo Exp $
4     * $Author: messineo $
5     *
6     * Implementation of the LogReader class.
7     * ToBeDone:
8     * Control the CRC for the entire data Packet not just for single records
9     */
10    
11     extern "C" {
12     #include "CRC.h"
13     }
14     #include "ReaderAlgorithms.h"
15    
16     using namespace pamela::techmodel;
17    
18    
19     /**
20     * Constructor.
21     */
22     LogReader::LogReader(void):
23     TechmodelAlgorithm(PacketType::Log, "TechmodelLogReader") {
24     Log = new LogEvent();
25     }
26    
27     /**
28     * Get a string with the version info of the algorithm.
29     */
30     std::string LogReader::GetVersionInfo(void) const {
31     return
32     "$Header: /repository/PamOffLineSW/techmodel/LogReader.cpp,v 1.6 2008-03-04 18:09:30 messineo Exp $\n";
33     }
34    
35     /**
36     * Initialize the algorithm with a special run. This will initialize the
37     * event reader routines for all packet types.
38     */
39     void LogReader::Init(PamelaRun *run) {
40     run->WriteSubPacket(this, &Log, Log->Class());
41     }
42    
43     /**
44     * Unpack the Log event from an input file.
45     */
46     void LogReader::PKT_RunEvent(char* subData, long int length) throw (WrongCRCException){
47     std::stringstream oss;
48     string msg;
49    
50     UINT16 subCRC; //calculated CRC of the data
51     UINT16 readCRC; //CRC read from the end of the subpacket
52     long int dataLength = length - 2; //the block of data
53    
54     subCRC = CM_Compute_CRC16(0, (UINT8*)subData, dataLength);
55    
56     //took the final CRC to compare it with the previous calculated CRC of the data
57     readCRC = (((UINT16)(subData[length - 2]<<8))&0xFF00) + (((UINT16)subData[length - 1])&0x00FF);
58    
59     // if (subCRC != readCRC) throw WrongCRCException(" Wrong CRC for Log Packet ");
60     if (subCRC != readCRC)
61     {
62     oss.str("");
63     oss<<"Wrong CRC for Log Packet: "<<" CRC COMPUTED= "<< subCRC<<" CRC READ= "<< readCRC;
64     msg=oss.str();
65     PamOffLineSW::mainLogUtil->logError(msg);
66     throw WrongCRCException(" Wrong CRC for Log Packet. THE PACKET IS DISCARDED ");
67     }
68    
69     Log->COMPILATION_TIMESTAMP = (((UINT32)subData[0]<<24)&0xFF000000) + (((UINT32)subData[1]<<16)&0x00FF0000) + (((UINT32)subData[2]<<8)&0x0000FF00) + (((UINT32)subData[3])&0x000000FF);
70    
71     long int offset = 4;
72     int i = 0;
73     LogRecord* rec;
74     Log->Records->Clear();
75     TClonesArray &recs = *(Log->Records);
76    
77     while (offset < dataLength){
78     rec = new(recs[i++]) LogRecord(); //add a new Log
79     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);
80     rec->MASKTYPE = (((UINT8)subData[offset+4])&0xFF);
81     rec->FILE_ID = (((UINT8)subData[offset+5])&0xFF);
82     rec->LINE_NO = ((((UINT16)subData[offset+6]<<8)&0xFF00) + (((UINT16)subData[offset+7])&0x00FF));
83     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);
84     offset = offset + 12;
85     // cout<<"DBG: rec->RECORD_OBT "<<rec->RECORD_OBT<<endl;
86     }
87    
88     /*
89     if (subCRC != readCRC)
90     {
91     oss.str("");
92     oss<<"Wrong CRC for Log Packet: "<<" CRC COMPUTED= "<< subCRC<<" CRC READ= "<< readCRC;
93     msg=oss.str();
94     PamOffLineSW::mainLogUtil->logWarning(msg);
95     throw WrongCRCException_PKTUsed(" Wrong CRC for Log Packet. ");
96     }
97     */
98    
99    
100     }
101    

  ViewVC Help
Powered by ViewVC 1.1.23