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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (download) (vendor branch)
Tue Sep 23 07:20:26 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     * $Author: messineo $
3     * $Date: 2008-03-04 18:09:30 $
4     * $Revision: 1.4 $
5     *
6     * Implementation of the CalibHeaderReader class.
7     */
8    
9     #include "ReaderAlgorithms.h"
10    
11     using namespace pamela::techmodel;
12    
13     /**
14     * Constructor.
15     */
16     CalibHeaderReader::CalibHeaderReader(void):
17     TechmodelAlgorithm(PacketType::CalibHeader, "TechmodelCalibHeaderReader") {
18     calibHeader = new CalibHeaderEvent();
19     }
20    
21     /**
22     * Get a string with the version info of the algorithm.
23     */
24     std::string CalibHeaderReader::GetVersionInfo(void) const {
25     return
26     "$Header: /repository/PamOffLineSW/techmodel/CalibHeaderReader.cpp,v 1.4 2008-03-04 18:09:30 messineo Exp $\n";
27     }
28    
29     /**
30     * Initialize the algorithm with a special run. This will initialize the
31     * event reader routines for all packet types.
32     */
33     void CalibHeaderReader::Init(PamelaRun *run) {
34     run->WriteSubPacket(this, &calibHeader, calibHeader->Class());
35     }
36    
37     /**
38     * Unpack the CalibHeader event from an input file.
39     */
40     void CalibHeaderReader::PKT_RunEvent(char* subData, long int dataLength) throw (WrongCRCException){
41     std::stringstream oss;
42     string msg;
43    
44     UINT16 subCRC; //calculated CRC of the data
45     UINT16 readCRC; //CRC read from the end of the subpacket
46     long int length = dataLength - 2; //the block of data
47    
48     subCRC = CM_Compute_CRC16(0, (UINT8*)subData, length);
49     readCRC = (((UINT16)(subData[dataLength - 2]<<8))&0xFF00) + (((UINT16)subData[dataLength - 1])&0x00FF);
50    
51     //if (subCRC != readCRC) throw WrongCRCException(" Wrong CRC for CalibHeader Packet ");
52     if (subCRC != readCRC)
53     {
54     oss.str("");
55     oss<<"Wrong CRC for CalibHeader Packet: "<<" CRC COMPUTED= "<< subCRC<<" CRC READ= "<< readCRC;
56     msg=oss.str();
57     PamOffLineSW::mainLogUtil->logError(msg);
58     throw WrongCRCException(" Wrong CRC for CalibHeader Packet. THE PACKET IS DISCARDED ");
59     }
60    
61     calibHeader->calibHeaderData = new TArrayC(length, subData);
62     /*
63     if (subCRC != readCRC)
64     {
65     oss.str("");
66     oss<<"Wrong CRC for CalibHeader Packet: "<<" CRC COMPUTED= "<< subCRC<<" CRC READ= "<< readCRC;
67     msg=oss.str();
68     PamOffLineSW::mainLogUtil->logWarning(msg);
69     throw WrongCRCException_PKTUsed(" Wrong CRC for CalibHeader Packet. ");
70     }
71     */
72     }
73    
74    

  ViewVC Help
Powered by ViewVC 1.1.23