RawSummaryDroppedMicroblockV0.cpp
Go to the documentation of this file.
1 #include "DAQDataFormats/RawSummaryDroppedMicroblockV0.h"
2 #include "DAQDataFormats/BitFields.h"
3 #include <boost/format.hpp>
4 
5 /// It is requred to
6 /// 1. include DAQDataFormats/DataFormatFirst.inc
7 /// 2. define CURRENT_CLASS
8 /// 3. define CURRENT_CLASS_VERSION for version of the class
9 /// OR define LAST_CLASS_VERSION for the main structure of the class
10 /// 4. (optional) define CURRENT_FIELDS_SUB_NAMESPACE
11 /// 5. include DAQDataFormats/DataFormatLast.inc
12 /// before the declaration of the DataFormat version class in the header.
13 #include "DAQDataFormats/DataFormatFirst.inc"
14 #define CURRENT_CLASS RawSummaryDroppedMicroblock
15 #define CURRENT_CLASS_VERSION 0
16 #define CURRENT_FIELDS_SUB_NAMESPACE summarydroppedmicroblock
17 #include "DAQDataFormats/DataFormatLast.inc"
18 
19 namespace daqdataformats{
20 namespace VERSION_NAMESPACE{
21 
22 //------------------------Constructors------------------------------------------
24  PREVIOUS_VERSION_CLASS_NAME(version)
25  ,ZEROOUT_GET_AND_SET(Version )
26  ,ZEROOUT_GET_AND_SET(TimeStampLow )
27  ,ZEROOUT_GET_AND_SET(TimeStampHigh )
28  ,ZEROOUT_GET_AND_SET(TimeWindow_sec )
29  ,ZEROOUT_GET_AND_SET(TimeWindow_usec)
30  ,ZEROOUT_GET_AND_SET(NumDroppedMicroblocks )
31  ,ZEROOUT_GET_AND_SET(TimeStamp )
32  ,ZEROOUT_GET_AND_SET(TimeWindowTvUsec)
33  ,ZEROOUT_GET_AND_SET(TimeWindowTvSec )
34  ,ZEROOUT_GET_AND_SET(TimeWindowTv )
35 {}
36 
37 //------------------------------------------------------------------------------
39  PREVIOUS_VERSION_CLASS_NAME(copyin)
40  ,DEEPCOPY_GET_AND_SET(Version )
41  ,DEEPCOPY_GET_AND_SET(TimeStampLow )
42  ,DEEPCOPY_GET_AND_SET(TimeStampHigh )
43  ,DEEPCOPY_GET_AND_SET(TimeWindow_sec )
44  ,DEEPCOPY_GET_AND_SET(TimeWindow_usec)
45  ,DEEPCOPY_GET_AND_SET(NumDroppedMicroblocks )
46  ,DEEPCOPY_GET_AND_SET(TimeStamp )
47  ,DEEPCOPY_GET_AND_SET(TimeWindowTvUsec)
48  ,DEEPCOPY_GET_AND_SET(TimeWindowTvSec )
49  ,DEEPCOPY_GET_AND_SET(TimeWindowTv )
50 {}
51 
52 //------------------------------------------------------------------------------
54 
55 //------------------------------------------------------------------------------
56 // General Initialization
58  EXECUTE_FUNCTION(setVersion)(_version);
59 }
60 
61 //------------------------------------------------------------------------------
62 // get Method for 64 bit time stamp
63 uint64_t RawSummaryDroppedMicroblock::getTimeStamp() const {
64  return getUint64_t(EXECUTE_FUNCTION(getTimeStampLow)(), EXECUTE_FUNCTION(getTimeStampHigh)());
65 }
66 
67 //------------------------------------------------------------------------------
68 // set Method for 64bit time stamp
69 bool RawSummaryDroppedMicroblock::setTimeStamp(const uint64_t timestamp) {
70  uint32_t low, high;
71  getLoAndHi(timestamp, low, high);
72 
73  EXECUTE_FUNCTION(setTimeStampHigh)(high);
74  RETURN_FUNCTION(setTimeStampLow)(low);
75 }
76 
77 //------------------------------------------------------------------------------
78 // get Method for the the seconds of the timeval
79 time_t RawSummaryDroppedMicroblock::getTimeWindowTvSec() const { return (time_t) EXECUTE_FUNCTION(getTimeWindow_sec)();}
80 
81 //------------------------------------------------------------------------------
82 // Get Method for the the microseconds of the timeval
83 suseconds_t RawSummaryDroppedMicroblock::getTimeWindowTvUsec() const { return (suseconds_t) EXECUTE_FUNCTION(getTimeWindow_usec)();}
84 
85 //------------------------------------------------------------------------------
86 bool RawSummaryDroppedMicroblock::setTimeWindowTvSec (const time_t a) { RETURN_FUNCTION(setTimeWindow_sec)((const uint32_t)a);}
87 bool RawSummaryDroppedMicroblock::setTimeWindowTvUsec(const suseconds_t a) { RETURN_FUNCTION(setTimeWindow_usec)((const uint32_t)a);}
88 
89 //------------------------------------------------------------------------------
90 // get Method for 64 bit time stamp, in timeval format
91 timeval RawSummaryDroppedMicroblock::getTimeWindowTv() const {
92 
93  timeval timewindow;
94  timewindow.tv_usec = EXECUTE_FUNCTION(getTimeWindowTvUsec)();
95  timewindow.tv_sec = EXECUTE_FUNCTION(getTimeWindowTvSec)();
96 
97  return timewindow;
98 }
99 
100 //------------------------------------------------------------------------------
101 // set Method for 64bit time stamp, as a timeval
102 bool RawSummaryDroppedMicroblock::setTimeWindowTv(timeval timewindow){
103 
104  EXECUTE_FUNCTION(setTimeWindowTvUsec)(timewindow.tv_usec);
105  RETURN_FUNCTION(setTimeWindowTvSec)(timewindow.tv_sec);
106 }
107 
108 //------------------------------------------------------------------------------
109 void RawSummaryDroppedMicroblock::print(std::ostream& os) const{
110  os<<"++++ Summary Dropped Microblock ++++\n";
111  os<<boost::format("Dropped Microblock Version:\t%u\n")%EXECUTE_FUNCTION(getVersion)();
112  os<<boost::format("Gen Timestamp Low:\t%u\n")%EXECUTE_FUNCTION(getTimeStampLow)();
113  os<<boost::format("Gen Timestamp High:\t%u\n")%EXECUTE_FUNCTION(getTimeStampHigh)();
114  os<<boost::format("Gen Timestamp:\t\t%Lu\n")%(long long unsigned int)EXECUTE_FUNCTION(getTimeStamp)();
115  time_t timeWindowTvSec = EXECUTE_FUNCTION(getTimeWindowTvSec)();
116  char ctimestr[27]; ctime_r(&timeWindowTvSec,ctimestr);
117  os<<boost::format("TimeWindow:\t\t%s")%ctimestr;
118  os<<boost::format("TimeWindow usec:\t\t%d\n")%(uint32_t) EXECUTE_FUNCTION(getTimeWindowTvUsec)();
119  os<<boost::format("Num Dropped Microblocks:\t\t0x%02x\n")%EXECUTE_FUNCTION(getNumDroppedMicroblocks)();
120  os<<boost::format("Dropped Microblock Version:\t%d\n")%EXECUTE_FUNCTION(getVersion)();
121  PRINT_ON_DEBUG("Buffer is set to "<<_Buffer);
122 
123 }
124 
125 }}// end of namespaces
#define EXECUTE_FUNCTION(FULLFUNCTIONNAME)
Execute and return the delegate.
Definition: Macros.h:54
#define DEEPCOPY_GET_AND_SET(FUNC)
Definition: FunctionBind.h:44
#define VERSION_NAMESPACE
#define ZEROOUT_GET_AND_SET(FUNC)
Definition: FunctionBind.h:56
#define RETURN_FUNCTION(FULLFUNCTIONNAME)
Definition: Macros.h:57
const double a
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
const XML_Char * version
Definition: expat.h:187
int32_t version_t
Definition: RawDAQData.h:72
#define PRINT_ON_DEBUG(x)
Definition: RawDAQData.h:35
Class to hold the data from the FEBs in correct formats.