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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download)
Tue Sep 23 07:20:27 2008 UTC (16 years, 2 months ago) by mocchiut
Branch: MAIN
Branch point for: v0r00
Initial revision

1 /** @file
2 * $Source: /repository/PamOffLineSW/techmodel/TabDumpReader.cpp,v $
3 * $Id: TabDumpReader.cpp,v 1.4 2008-03-04 18:09:30 messineo Exp $
4 * $Author: messineo $
5 *
6 * Implementation of the TabDumpReader class.
7 */
8
9 extern "C" {
10 #include "CRC.h"
11 }
12 #include "ReaderAlgorithms.h"
13 using namespace pamela::techmodel;
14
15 /**
16 * Constructor.
17 */
18 TabDumpReader::TabDumpReader(void):
19 TechmodelAlgorithm(PacketType::TabDump, "TechmodelTabDump") {
20 TabDump = new TabDumpEvent();
21 }
22
23 /**
24 * Get a string with the version info of the algorithm.
25 */
26 std::string TabDumpReader::GetVersionInfo(void) const {
27 return "$Header: /repository/PamOffLineSW/techmodel/TabDumpReader.cpp,v 1.4 2008-03-04 18:09:30 messineo 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 TabDumpReader::Init(PamelaRun *run) {
35 run->WriteSubPacket(this, &TabDump, TabDump->Class());
36 }
37
38 /**
39 * Unpack the TabDump event
40 */
41 void TabDumpReader::PKT_RunEvent(char* subData, long int length) throw (WrongCRCException){
42 std::stringstream oss;
43 string msg;
44 UINT16 subCRC; //calculated CRC of the data
45 UINT16 readCRC; //CRC read from the end of the subpacket
46 long int dataLength = length - 2; //the block of data
47 subCRC = CM_Compute_CRC16(0, (UINT8*)subData, dataLength);
48 readCRC = (((UINT16)(subData[length - 2]<<8))&0xFF00) + (((UINT16)subData[length - 1])&0x00FF);
49
50 //if (subCRC != readCRC) throw WrongCRCException(" Wrong CRC for TabDump Packet ");
51 if (subCRC != readCRC)
52 {
53 oss.str("");
54 oss<<"Wrong CRC for TabDump Packet: "<<" CRC COMPUTED= "<< subCRC<<" CRC READ= "<< readCRC;
55 msg=oss.str();
56 PamOffLineSW::mainLogUtil->logError(msg);
57 throw WrongCRCException(" Wrong CRC for TabDump Packet. THE PACKET IS DISCARDED ");
58 }
59
60 TabDumpRecord* rec;
61 TabDump->PARAMETER_STAMP = (((UINT32)subData[0]<<24)&0xFF000000) + (((UINT32)subData[1]<<16)&0x00FF0000) + (((UINT32)subData[2]<<8)&0x0000FF00) + (((UINT32)subData[3])&0x000000FF);
62 long int offset = 4;
63 int i = 0;
64 TabDump->Records->Clear();
65 TClonesArray &recs = *(TabDump->Records);
66 while (offset < dataLength){
67 rec = new(recs[i++]) TabDumpRecord(); //add a new TabDump
68 rec->Tab_ID = ((UINT8)subData[offset])&0xFF;
69 rec->Nrow = ((UINT8)subData[offset+1])&0xFF;
70 rec->Ncol = ((UINT8)subData[offset+2])&0xFF;
71 rec->Data = new TArrayI((int)((rec->Nrow)*(rec->Ncol)), (int*)(subData+offset+3));
72 offset = offset + sizeof(UINT32)*(rec->Nrow)*(rec->Ncol) + 3;
73 }
74
75 /*
76 if (subCRC != readCRC)
77 {
78 oss.str("");
79 oss<<"Wrong CRC for TabDump Packet: "<<" CRC COMPUTED= "<< subCRC<<" CRC READ= "<< readCRC;
80 msg=oss.str();
81 PamOffLineSW::mainLogUtil->logWarning(msg);
82 throw WrongCRCException_PKTUsed(" Wrong CRC for TabDump Packet. ");
83 }
84 */
85
86 }

  ViewVC Help
Powered by ViewVC 1.1.23