/[PAMELA software]/chewbacca/event/PscuHeader.h
ViewVC logotype

Annotation of /chewbacca/event/PscuHeader.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Wed Aug 5 18:48:41 2009 UTC (15 years, 3 months ago) by pam-fi
Branch: MAIN
CVS Tags: v10RED, v9r00, v9r01, HEAD
Changes since 1.1: +4 -3 lines
File MIME type: text/plain
Various minor modifications for compatibility with gcc 4.4, removal of warnings due to mismatch between char* and const char*, bug fix.

1 mocchiut 1.1 /** @file
2 pam-fi 1.2 * $Source: /afs/ba.infn.it/user/pamela/src/CVS/chewbacca/event/PscuHeader.h,v $
3     * $Id: PscuHeader.h,v 1.1.1.1 2008-09-23 07:19:51 mocchiut Exp $
4     * $Author: mocchiut $
5 mocchiut 1.1 *
6     * Header file for the PscuHeader class.
7     */
8     #ifndef PSCU_HEADER_H
9     #define PSCU_HEADER_H
10    
11     #include "Exception.h"
12     #include "SubPacket.h"
13 pam-fi 1.2 #include <limits>
14 mocchiut 1.1
15     namespace pamela {
16     /**
17     * Class containing the PSCU header and trailer information.
18     */
19     class PscuHeader: public pamela::SubPacket {
20    
21     private:
22    
23     public:
24     unsigned int Header; /**< Packet type header (must be 0xFAFEDE) */
25     UINT8 PacketId1; /**< Packet type first byte */
26     UINT8 PacketId2; /**< Packet type second byte */
27     UINT32 Counter; /**< PSCU event counter */
28     UINT32 OrbitalTime; /**< Raw Orbital time */
29     UINT32 PacketLenght;
30     UINT8 CRC; /**< PSCU Header Checksum */ //!
31    
32     /* This parameter represent the offset of the header relative to the begin
33     * of the file it has been extracted. It's purpose is to
34     * check whenever the CPU (for error) store the same packet more than one time.
35     * It's not clear if it will be mantained or not in the definitive release.
36     */
37     UINT32 FileOffset;
38    
39     PscuHeader();
40     virtual ~PscuHeader(){};
41     const pamela::PacketType* GetPacketType(void) const throw(UnidentifiedPacketException);
42     /** Get the Header. */
43     int GetHeader(void) const { return Header; }
44     /** Get packet id 1. */
45     unsigned char GetPacketId1(void) const { return PacketId1; }
46     /** Get packet id 2. */
47     unsigned char GetPacketId2(void) const { return PacketId2; }
48     /** Get the PSCU event counter. */
49     int GetCounter(void) const { return Counter; }
50     /** Get the orbital time. */
51     int GetOrbitalTime(void) const { return OrbitalTime; }
52     /** Get the header CRC. */
53     unsigned char GetCRC(void) const { return CRC; }
54     /** Get the packet length for this packet. */
55     int GetPacketLenght(void) const { return PacketLenght; }
56     /** Get the offset of the packet relative to the begin of the raw file. */
57     int GetFileOffset(void) const { return FileOffset; }
58    
59     /** Set the orbital time. Intended to use by the raw reader. */
60     void SetHeader(int var) { Header = var; }
61     /** Set the packet id. Intended to use by the raw reader. */
62     void SetPacketId(short var1, short var2) { PacketId1 = var1; PacketId2 = var2; }
63     /** Set the counter. Intended to use by the raw reader. */
64     void SetCounter(int var) { Counter = var; }
65     /** Set the orbital time. Intended to use by the raw reader. */
66     void SetOrbitalTime(int var) { OrbitalTime = var; }
67     /** Set the packet length. Intended to use by the raw reader. */
68     void SetPacketLenght(int var) { PacketLenght = var; }
69     /** Set the packet length. Intended to use by the raw reader. */
70     void SetCRC(short var) { CRC = var; }
71     /** Get the offset of the packet relative to the begin of the raw file. */
72     int SetFileOffset(unsigned long int var) { if ( var > numeric_limits<unsigned int>::max() ) var -= numeric_limits<unsigned int>::max() ;FileOffset = (unsigned int)var; return(0); }
73    
74     const char* Print(){
75     oss.str("");
76     oss << "\n Packet Counter : " << hex << Counter
77     << "\n Id1 - Id2 : " << hex << (UINT16)PacketId1 << " - " << hex << (UINT16)PacketId2
78     << "\n Orbital Time : " << hex << OrbitalTime
79     << "\n Lenght : " << hex << PacketLenght
80     << "\n CRC : " << hex << (UINT16)CRC
81     << "\n Header Start Position : " << hex << FileOffset;
82     return oss.str().c_str();
83     }
84    
85     static const char* Print(char* buff){
86     static stringstream out;
87     out.str("");
88     out << "\n Packet Counter : " << hex << (((UINT32)buff[5]<<16)&0x00FF0000) + (((UINT32)buff[6]<<8)&0x0000FF00) + (((UINT32)buff[7])&0x000000FF)
89     << "\n Id1 - Id2 : " << hex << (UINT16)buff[3] << " - " << hex << (UINT16)buff[4]
90     << "\n Orbital Time : " << hex << (((UINT32)buff[8]<<24)&0xFF000000) + (((UINT32)buff[9]<<16)&0x00FF0000) + (((UINT32)buff[10]<<8)&0x0000FF00) + (((UINT32)buff[11])&0x000000FF)
91     << "\n Lenght : " << hex << (((UINT32)buff[12]<<16)&0x00FF0000) + (((UINT32)buff[13]<<8)&0x0000FF00) + (((UINT32)buff[14])&0x000000FF)
92     << "\n CRC : " << hex << (UINT16)buff[15];
93     return out.str().c_str();
94     }
95    
96     ClassDef(PscuHeader, 1)
97     };
98     }
99    
100     #endif /* PSCU_HEADER_H */

  ViewVC Help
Powered by ViewVC 1.1.23