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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Tue Sep 23 07:20:24 2008 UTC (16 years, 2 months ago) by mocchiut
Branch point for: v0r00, MAIN
Initial revision

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

  ViewVC Help
Powered by ViewVC 1.1.23