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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Tue Sep 23 07:20:27 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/RunTrailerReader.cpp,v $
3     * $Id: RunTrailerReader.cpp,v 1.6 2008-03-04 18:09:29 messineo Exp $
4     * $Author: messineo $
5     *
6     * Implementation of the RunHeader class.
7     */
8    
9    
10     extern "C" {
11     #include "CRC.h"
12     }
13     #include "ReaderAlgorithms.h"
14     using namespace pamela::techmodel;
15    
16     /**
17     * Constructor.
18     */
19     RunTrailerReader::RunTrailerReader(void):
20     TechmodelAlgorithm(PacketType::Log, "TechmodelRunTrailerReader") {
21     RunTrailer = new RunTrailerEvent();
22     }
23    
24     /**
25     * Get a string with the version info of the algorithm.
26     */
27     std::string RunTrailerReader::GetVersionInfo(void) const {
28     return
29     "$Header: /repository/PamOffLineSW/techmodel/RunTrailerReader.cpp,v 1.6 2008-03-04 18:09:29 messineo Exp $\n";
30     }
31    
32     /**
33     * Initialize the algorithm with a special run. This will initialize the
34     * event reader routines for all packet types.
35     */
36     void RunTrailerReader::Init(PamelaRun *run) {
37     run->WriteSubPacket(this, &RunTrailer, RunTrailer->Class());
38     }
39    
40    
41     /**
42     * Unpack the RunTrailer event
43     */
44     void RunTrailerReader::PKT_RunEvent(char* subData, long int length) throw (WrongCRCException){
45     std::stringstream oss;
46     string msg;
47    
48     UINT16 subCRC; //CRC of the data
49     UINT16 readCRC; //CRC read from the end of the subpacket
50     long int dataLength;
51    
52     //the 2 bytes subtracted belong to the final event CRC bytes
53     dataLength = length - (long int)2;
54     subCRC = CM_Compute_CRC16(0, (BYTE*)subData, dataLength);
55     //took the final CRC to compare it with the previous calculated CRC of the data
56     readCRC = (((UINT16)(subData[length - 2]<<8))&0xFF00) + (((UINT16)subData[length - 1])&0x00FF);
57    
58     //ORIG: if (subCRC != readCRC) throw WrongCRCException(" Wrong CRC for RunTrailer Packet ");
59     if (subCRC != readCRC)
60     {
61     oss.str("");
62     oss<<"Wrong CRC for RunTrailer Packet: "<<" CRC COMPUTED= "<< subCRC<<" CRC READ= "<< readCRC;
63     msg=oss.str();
64     PamOffLineSW::mainLogUtil->logError(msg);
65     throw WrongCRCException(" Wrong CRC for RunTrailer Packet. THE PACKET IS DISCARDED ");
66     }
67    
68     RunTrailer->PKT_COUNTER = (((UINT32)subData[0]<<24)&0xFF000000) + (((UINT32)subData[1]<<16)&0x00FF0000) + (((UINT32)subData[2]<<8)&0x0000FF00) + (((UINT32)subData[3])&0x000000FF);
69     RunTrailer->PKT_ReadyCounter = (((UINT32)subData[4]<<24)&0xFF000000) + (((UINT32)subData[5]<<16)&0x00FF0000) + (((UINT32)subData[6]<<8)&0x0000FF00) + (((UINT32)subData[7])&0x000000FF);
70     RunTrailer->OBT_TYME_SYNC = (((UINT32)subData[8]<<24)&0xFF000000) + (((UINT32)subData[9]<<16)&0x00FF0000) + (((UINT32)subData[10]<<8)&0x0000FF00) + (((UINT32)subData[11])&0x000000FF);
71     RunTrailer->LAST_TYME_SYNC_INFO = (((UINT32)subData[12]<<24)&0xFF000000) + (((UINT32)subData[13]<<16)&0x00FF0000) + (((UINT32)subData[14]<<8)&0x0000FF00) + (((UINT32)subData[15])&0x000000FF);
72     /*
73     if (subCRC != readCRC)
74     {
75     oss.str("");
76     oss<<"Wrong CRC for RunTrailer Packet: "<<" CRC COMPUTED= "<< subCRC<<" CRC READ= "<< readCRC;
77     msg=oss.str();
78     PamOffLineSW::mainLogUtil->logWarning(msg);
79     throw WrongCRCException_PKTUsed(" Wrong CRC for RunTrailer Packet. ");
80     }
81     */
82     }
83    

  ViewVC Help
Powered by ViewVC 1.1.23