Jpp  17.0.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FramePreamble.hh
Go to the documentation of this file.
1 #ifndef __ANTARESDAQ__FRAMEPREAMBLE__
2 #define __ANTARESDAQ__FRAMEPREAMBLE__
3 
4 /**
5  * @file FramePreamble.hh
6  * @author Joris van Rantwijk
7  * @date Feb 2002
8  *
9  * Class definition for Antares DAQ Data-Frame Preamble.
10  */
11 
12 #include <ostream>
13 #include <iomanip>
14 
15 #include <TROOT.h>
16 #include <TObject.h>
17 
19 
20 /**
21  * This object holds the information from the 'preamble' of a data frame.
22  */
24 public:
25 
26  /** Total length of the frame in 4-byte words. */
27  unsigned int frameSize;
28 
29  /** Data type code (DAQ_xxx) */
30  unsigned short dataType;
31 
32  /** Unique code representing the shore station for this frame */
33  unsigned short frameTarget;
34 
35  /** Frame 'time stamp' in units of 50ns (MSW) */
36  unsigned int frameTime1;
37  /** Frame 'time stamp' in units of 50ns (LSW) */
38  unsigned int frameTime2;
39  /** \return 64 bit frame time */
41  {
43  }
44 
45  /** Number of frames since start of the run */
46  unsigned int frameIndex;
47 
48  /** Status of frame Xon/Xoff */
49  unsigned short status;
50 
51  /** Number of items actually sent in this frame */
52  unsigned short nbItems;
53 
54  /** ID of originating LCM */
55  unsigned short LCM_ID;
56 
57  /** ID of originating ARS */
58  unsigned short ARS_ID;
59 
60  /** Run-number as given by the RunControl */
61  unsigned int runNumber;
62 
63  /**
64  * get LCM idendifier
65  * \return LCM identifier
66  */
67  const unsigned short lcm_id() const { return LCM_ID; }
68 
69  /**
70  * get ARS idendifier
71  * \return ARS identifier
72  */
73  const unsigned short ars_id() const { return ARS_ID; }
74 
75  /**
76  * get data type
77  * \return data type
78  */
79  const unsigned short data_type() const { return dataType; }
80 
81  /**
82  * get number of items
83  * \return number of items
84  */
85  const unsigned short numberOfItems() const { return nbItems; }
86 
87  /**
88  * Return a pointer to the frame data buffer.
89  * The returned value points to the start of the frame preamble.
90  * \return pointer to data
91  */
92  virtual const unsigned char* getdata() const { return NULL; }
93 
94  /**
95  * Return the length of the frame data buffer.
96  * The returned value is in <b>bytes</b> (not words), and includes
97  * the frame preamble.
98  * \return length of data
99  */
100  virtual const unsigned int getdatalen() const { return Length(); }
101 
102  /** Construct an empty preamble object. */
104 
105  /**
106  * destructor
107  */
108  virtual ~DaqFramePreamble() {};
109 
110  /** Return length of an encoded frame preamble in bytes. */
111  static const unsigned int Length() { return 32; }
112 
113  /**
114  * Print ASCII.
115  *
116  * \param out output stream
117  * \param object frame preamble
118  * \return output stream
119  */
120  friend std::ostream& operator<<(std::ostream& out, const DaqFramePreamble& object)
121  {
122  using namespace std;
123 
124  out << "frameSize " << object.frameSize << endl;
125  out << "dataType " << object.dataType << endl;
126  out << "frameTarget " << object.frameTarget << endl;
127  out << "frameTime1 " << object.frameTime1 << endl;
128  out << "frameTime2 " << object.frameTime2 << endl;
129  out << "frameIndex " << object.frameIndex << endl;
130  out << "status " << object.status << endl;
131  out << "nbItems " << object.nbItems << endl;
132  out << "LCM_ID " << object.LCM_ID << endl;
133  out << "ARS_ID " << object.ARS_ID << endl;
134  out << "runNumber " << object.runNumber << endl;
135 
136  return out;
137  }
138 
140 };
141 
142 
143 /**
144  * equal operator for DAQ frame preamble
145  *
146  * \param first DAQ frame preamble
147  * \param second DAQ frame preamble
148  * \return true if first equals second; else false
149  */
150 static inline const bool operator==(const DaqFramePreamble& first, const DaqFramePreamble& second)
151 {
152  return (first.dataType == second.dataType &&
153  first.frameIndex == second.frameIndex &&
154  first.LCM_ID == second.LCM_ID &&
155  first.ARS_ID == second.ARS_ID &&
156  first.runNumber == second.runNumber);
157 }
158 
159 /**
160  * not-equal operator for DAQ frame preamble
161  *
162  * \param first DAQ frame preamble
163  * \param second DAQ frame preamble
164  * \return true if first not equals second; else false
165  */
166 static inline const bool operator!=(const DaqFramePreamble& first, const DaqFramePreamble& second)
167 {
168  return (first.dataType != second.dataType ||
169  first.frameIndex != second.frameIndex ||
170  first.LCM_ID != second.LCM_ID ||
171  first.ARS_ID != second.ARS_ID ||
172  first.runNumber != second.runNumber);
173 }
174 
175 #endif
176 
177 /* End */
virtual const unsigned int getdatalen() const
Return the length of the frame data buffer.
virtual const unsigned char * getdata() const
Return a pointer to the frame data buffer.
static const unsigned int Length()
Return length of an encoded frame preamble in bytes.
unsigned short nbItems
Number of items actually sent in this frame.
const unsigned short ars_id() const
get ARS idendifier
DaqFramePreamble()
Construct an empty preamble object.
friend std::ostream & operator<<(std::ostream &out, const DaqFramePreamble &object)
Print ASCII.
then echo The file $DIR KM3NeT_00000001_00000000 root already please rename or remove it first
unsigned short ARS_ID
ID of originating ARS.
const unsigned short lcm_id() const
get LCM idendifier
This object holds the information from the &#39;preamble&#39; of a data frame.
bool operator==(Packet const &p, ID const &id)
unsigned short LCM_ID
ID of originating LCM.
ulonglong frameTime()
unsigned int frameTime2
Frame &#39;time stamp&#39; in units of 50ns (LSW)
unsigned int frameSize
Total length of the frame in 4-byte words.
unsigned int runNumber
Run-number as given by the RunControl.
unsigned short frameTarget
Unique code representing the shore station for this frame.
virtual ~DaqFramePreamble()
destructor
unsigned int frameIndex
Number of frames since start of the run.
unsigned int frameTime1
Frame &#39;time stamp&#39; in units of 50ns (MSW)
unsigned short status
Status of frame Xon/Xoff.
JNullType operator!=(JAnyType, JAnyType)
ClassDef(DaqFramePreamble, 2)
const unsigned short data_type() const
get data type
const unsigned short numberOfItems() const
get number of items
unsigned short dataType
Data type code (DAQ_xxx)