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

Annotation of /chewbacca/PamOffLineSW/techmodel/RunHeaderReader.cpp

Parent Directory Parent Directory | Revision Log Revision Log


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

1 mocchiut 1.1 /** @file
2     * $Source: /repository/PamOffLineSW/techmodel/RunHeaderReader.cpp,v $
3     * $Id: RunHeaderReader.cpp,v 1.5 2008-03-04 18:09:31 messineo Exp $
4     * $Author: messineo $
5     *
6     * Implementation of the RunHeader class.
7     */
8    
9    
10     extern "C" {
11     #include "CRC.h"
12     }
13     #include "ReaderAlgorithms.h"
14    
15     using namespace pamela::techmodel;
16    
17    
18     /**
19     * Constructor.
20     */
21     RunHeaderReader::RunHeaderReader(void):
22     TechmodelAlgorithm(PacketType::Log, "TechmodelRunHeaderReader") {
23     RunHeader = new RunHeaderEvent();
24     }
25    
26     /**
27     * Get a string with the version info of the algorithm.
28     */
29     std::string RunHeaderReader::GetVersionInfo(void) const {
30     return
31     "$Header: /repository/PamOffLineSW/techmodel/RunHeaderReader.cpp,v 1.5 2008-03-04 18:09:31 messineo Exp $\n";
32     }
33    
34     /**
35     * Initialize the algorithm with a special run. This will initialize the
36     * event reader routines for all packet types.
37     */
38     void RunHeaderReader::Init(PamelaRun *run) {
39     run->WriteSubPacket(this, &RunHeader, RunHeader->Class());
40     }
41    
42     /**
43     * Unpack the RunHeader event from an input file.
44     */
45     void RunHeaderReader::PKT_RunEvent(char* subData, long int length) throw (WrongCRCException)
46     {
47     std::stringstream oss;
48     string msg;
49    
50     UINT16 subCRC; //calculated CRC of the data
51     UINT16 readCRC; //CRC read from the end of the subpacket
52     long int dataLength = length - 2; //the block of data
53     subCRC = CM_Compute_CRC16(0, (UINT8*)subData, dataLength);
54     readCRC = (((UINT16)(subData[length - 2]<<8))&0xFF00) + (((UINT16)subData[length - 1])&0x00FF);
55    
56     //TODO:check here ....
57     //ORIG: if (subCRC != readCRC) throw WrongCRCException(" Wrong CRC for RunHeader Packet ");
58    
59     if (subCRC != readCRC)
60     {
61     oss.str("");
62     oss<<"Wrong CRC for RunHeader Packet: "<<" CRC COMPUTED= "<< subCRC<<" CRC READ= "<< readCRC;
63     msg=oss.str();
64     PamOffLineSW::mainLogUtil->logError(msg);
65     throw WrongCRCException(" Wrong CRC for RunHeader Packet. THE PACKET IS DISCARDED ");
66     }
67    
68     RunHeader->COMPILATIONTIMESTAMP = (((UINT32)subData[0]<<24)&0xFF000000) + (((UINT32)subData[1]<<16)&0x00FF0000) + (((UINT32)subData[2]<<8)&0x0000FF00) + (((UINT32)subData[3])&0x000000FF);
69     RunHeader->RM_ACQ_SETTING_MODE = (BYTE)subData[4];
70     RunHeader->OBT_TIME_SYNC = (((UINT32)subData[5]<<24)&0xFF000000) + (((UINT32)subData[6]<<16)&0x00FF0000) + (((UINT32)subData[7]<<8)&0x0000FF00) + (((UINT32)subData[8])&0x000000FF);
71     RunHeader->LAST_TIME_SYNC_INFO = (((UINT32)subData[9]<<24)&0xFF000000) + (((UINT32)subData[10]<<16)&0x00FF0000) + (((UINT32)subData[11]<<8)&0x0000FF00) + (((UINT32)subData[12])&0x000000FF);
72     RunHeader->FAVOURITE_WORKING_SCHEDULE = (BYTE)subData[13];
73     RunHeader->EFFECTIVE_WORKING_SCHEDULE = (BYTE)subData[14];
74     RunHeader->PRH_VAR_TRIGGER_MODE_A = (((UINT32)subData[15]<<24)&0xFF000000) + (((UINT32)subData[16]<<16)&0x00FF0000) + (((UINT32)subData[17]<<8)&0x0000FF00) + (((UINT32)subData[18])&0x000000FF);
75     RunHeader->PRH_VAR_TRIGGER_MODE_B = (((UINT32)subData[19]<<24)&0xFF000000) + (((UINT32)subData[20]<<16)&0x00FF0000) + (((UINT32)subData[21]<<8)&0x0000FF00) + (((UINT32)subData[22])&0x000000FF);
76     RunHeader->RM_ACQ_AFTER_CALIB = (BYTE)subData[23];
77     RunHeader->TRK_CALIB_USED = (((UINT32)subData[24]<<24)&0xFF000000) + (((UINT32)subData[25]<<16)&0x00FF0000) + (((UINT32)subData[26]<<8)&0x0000FF00) + (((UINT32)subData[27])&0x000000FF);
78     RunHeader->ACQ_BUILD_INFO = (((UINT32)subData[28]<<24)&0xFF000000) + (((UINT32)subData[29]<<16)&0x00FF0000) + (((UINT32)subData[30]<<8)&0x0000FF00) + (((UINT32)subData[31])&0x000000FF);
79     RunHeader->ACQ_VAR_INFO = ((((UINT16)subData[32]<<8)&0xFF00) + (((UINT16)subData[33])&0x00FF));
80     RunHeader->CAL_DSP_MASK = (BYTE)subData[34];
81     /*
82     if (subCRC != readCRC)
83     {
84     oss.str("");
85     oss<<"Wrong CRC for RunHeader Packet: "<<" CRC COMPUTED= "<< subCRC<<" CRC READ= "<< readCRC;
86     msg=oss.str();
87     PamOffLineSW::mainLogUtil->logWarning(msg);
88     throw WrongCRCException_PKTUsed(" Wrong CRC for RunHeader Packet. ");
89     }
90     */
91     }
92    

  ViewVC Help
Powered by ViewVC 1.1.23