1 |
mocchiut |
1.1 |
/** @file |
2 |
|
|
* $Source: /repository/PamOffLineSW/techmodel/ArrDumpReader.cpp,v $ |
3 |
|
|
* $Id: ArrDumpReader.cpp,v 1.4 2008-03-04 18:09:30 messineo Exp $ |
4 |
|
|
* $Author: messineo $ |
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: /repository/PamOffLineSW/techmodel/ArrDumpReader.cpp,v 1.4 2008-03-04 18:09:30 messineo 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 |
|
|
if (subCRC != readCRC) |
79 |
|
|
{ |
80 |
|
|
oss.str(""); |
81 |
|
|
oss<<"Wrong CRC for ArrDump Packet: "<<" CRC COMPUTED= "<< subCRC<<" CRC READ= "<< readCRC; |
82 |
|
|
msg=oss.str(); |
83 |
|
|
PamOffLineSW::mainLogUtil->logWarning(msg); |
84 |
|
|
throw WrongCRCException_PKTUsed(" Wrong CRC for ArrDump Packet. "); |
85 |
|
|
} |
86 |
|
|
*/ |
87 |
|
|
|
88 |
|
|
|
89 |
|
|
} |