1 |
mocchiut |
1.1 |
/** @file |
2 |
mocchiut |
1.2 |
* $Source: /afs/ba.infn.it/user/pamela/src/CVS/chewbacca/PamOffLineSW/techmodel/ArrDumpReader.cpp,v $ |
3 |
pam-fi |
1.3 |
* $Id: ArrDumpReader.cpp,v 1.2 2009-07-24 13:53:43 mocchiut Exp $ |
4 |
mocchiut |
1.2 |
* $Author: mocchiut $ |
5 |
mocchiut |
1.1 |
* |
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 |
pam-fi |
1.3 |
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 |
mocchiut |
1.1 |
} |
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 |
mocchiut |
1.2 |
while (offset < dataLength){ |
70 |
|
|
rec = new(recs[i++]) ArrDumpRecord(); //add a new TmtcRecord |
71 |
|
|
rec->Arr_ID = ((UINT8)subData[offset])&0xFF; |
72 |
pam-fi |
1.3 |
rec->Arr_len = (((UINT16)subData[offset+1]<<8)&0xFF00) + (((UINT16)subData[offset+2])&0x00FF); |
73 |
mocchiut |
1.2 |
rec->Data = new TArrayI((int)rec->Arr_len, (int*)(subData+offset+3)); |
74 |
|
|
offset = offset + sizeof(UINT32)*(rec->Arr_len) + 3; |
75 |
|
|
} |
76 |
mocchiut |
1.1 |
|
77 |
mocchiut |
1.2 |
|
78 |
mocchiut |
1.1 |
/* |
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 |
|
|
} |