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

Contents of /chewbacca/PamOffLineSW/techmodel/ArrDumpReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Wed Aug 5 18:48:37 2009 UTC (15 years, 4 months ago) by pam-fi
Branch: MAIN
CVS Tags: v10RED, v9r00, v9r01, HEAD
Changes since 1.2: +3 -3 lines
Various minor modifications for compatibility with gcc 4.4, removal of warnings due to mismatch between char* and const char*, bug fix.

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

  ViewVC Help
Powered by ViewVC 1.1.23