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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC 1.1.23