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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue Sep 23 07:20:25 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
Error occurred while calculating annotation data.
Imported sources, 23/09/2008

1 /** @file
2 * $Source: /repository/PamOffLineSW/techmodel/CalibS4Reader.cpp,v $
3 * $Id: CalibS4Reader.cpp,v 1.5 2008-03-04 18:09:30 messineo Exp $
4 * $Author: messineo $
5 *
6 * Implementation of the LogReader class.
7 * ToBeDone:
8 * Control the CRC for the entire data Packet not just for single records
9 */
10
11
12 extern "C" {
13 #include "CRC.h"
14 }
15 #include "ReaderAlgorithms.h"
16
17 using namespace pamela::techmodel;
18
19
20 /**
21 * Constructor.
22 */
23 CalibS4Reader::CalibS4Reader(void):
24 TechmodelAlgorithm(PacketType::Log, "TechmodelCalibS4Reader") {
25 calibS4 = new CalibS4Event();
26 }
27
28 /**
29 * Get a string with the version info of the algorithm.
30 */
31 std::string CalibS4Reader::GetVersionInfo(void) const {
32 return
33 "$Header: /repository/PamOffLineSW/techmodel/CalibS4Reader.cpp,v 1.5 2008-03-04 18:09:30 messineo Exp $\n";
34 }
35
36 /**
37 * Initialize the algorithm with a special run. This will initialize the
38 * event reader routines for all packet types.
39 */
40 void CalibS4Reader::Init(PamelaRun *run) {
41
42 run->WriteSubPacket(this, &calibS4, calibS4->Class());
43 }
44
45 /**
46 * Unpack the CalibS4 event
47 */
48 void CalibS4Reader::PKT_RunEvent(char* subData, long int length) throw (WrongCRCException){
49 std::stringstream oss;
50 string msg;
51
52 int offset;
53 UINT16 subCRC; //CRC of the data
54 UINT16 readCRC; //CRC read from the end of the subpacket
55 int numRecords = ((length - 2)/6);
56 S4::S4Event* rec;
57 calibS4->Records->Clear();
58 TClonesArray &recs = *(calibS4->Records);
59
60 subCRC = CM_Compute_CRC16(0, (BYTE*)subData, length - 2);
61 readCRC = (((UINT16)(subData[length - 2]<<8))&0xFF00) + (((UINT16)subData[length - 1])&0x00FF);
62
63 //TODO:check here ....
64 //ORIG: if (subCRC != readCRC) throw WrongCRCException(" Wrong CRC for CalibS4 Packet ");
65 if (subCRC != readCRC)
66 {
67 oss.str("");
68 oss<<"Wrong CRC for CalibS4 Packet: "<<" CRC COMPUTED= "<< subCRC<<" CRC READ= "<< readCRC;
69 msg=oss.str();
70 PamOffLineSW::mainLogUtil->logError(msg);
71 throw WrongCRCException(" Wrong CRC for CalibS4 Packet. THE PACKET IS DISCARDED ");
72 }
73
74 for(int i = 0; i < numRecords; i++) {
75 offset = i*6;
76 rec = new(recs[i]) S4::S4Event(); //add a new S4Event
77 rec->S4_REG_STATUS = (((UINT8)subData[offset])&0xF0);
78 rec->S4_DATA = ((((UINT16)subData[offset]<<8)&0x0FFF) + (((UINT16)subData[offset+1])&0x00FF));
79 rec->S4_CMD_NUM = (((UINT8)subData[offset+2])&0xFF);
80 rec->S4_RESP_LENGHT = ((((UINT16)subData[offset+3]<<8)&0xFF00) + (((UINT16)subData[offset+4])&0x00FF));
81 rec->S4_OVERALL_CHKCODE = (((UINT8)subData[offset+5])&0xFF);
82 }
83 /*
84 if (subCRC != readCRC)
85 {
86 oss.str("");
87 oss<<"Wrong CRC for CalibS4 Packet: "<<" CRC COMPUTED= "<< subCRC<<" CRC READ= "<< readCRC;
88 msg=oss.str();
89 PamOffLineSW::mainLogUtil->logWarning(msg);
90 throw WrongCRCException_PKTUsed(" Wrong CRC for CalibS4 Packet. ");
91 }
92 */
93
94 }
95

  ViewVC Help
Powered by ViewVC 1.1.23