RawNanoSliceHeaderV0.cpp
Go to the documentation of this file.
1 #include "DAQDataFormats/RawNanoSliceHeaderV0.h"
2 #include <boost/format.hpp>
3 
4 /// It is requred to
5 /// 1. include DAQDataFormats/DataFormatFirst.inc
6 /// 2. define CURRENT_CLASS
7 /// 3. define CURRENT_CLASS_VERSION for version of the class
8 /// OR define LAST_CLASS_VERSION for the main structure of the class
9 /// 4. (optional) define CURRENT_FIELDS_SUB_NAMESPACE
10 /// 5. include DAQDataFormats/DataFormatLast.inc
11 /// before the declaration of the DataFormat version class in the header.
12 #include "DAQDataFormats/DataFormatFirst.inc"
13 #define CURRENT_CLASS RawNanoSliceHeader
14 #define CURRENT_CLASS_VERSION 0
15 #include "DAQDataFormats/DataFormatLast.inc"
16 
17 
18 namespace daqdataformats{
19 namespace VERSION_NAMESPACE{
20 
21 //------------------------Constructors------------------------------------------
23  PREVIOUS_VERSION_CLASS_NAME(version)
24  /*
25  ,ZEROOUT_GET_AND_SET(FEBId)
26  ,ZEROOUT_GET_AND_SET(FEBStatus)
27  ,ZEROOUT_GET_AND_SET(PixelAddr)
28  ,ZEROOUT_GET_AND_SET(Sequence)
29  ,ZEROOUT_GET_AND_SET(Version)
30  ,ZEROOUT_GET_AND_SET(Pad3)
31  ,ZEROOUT_GET_AND_SET(DataPresent)
32  ,ZEROOUT_GET_AND_SET(LinkStatus)
33  ,ZEROOUT_GET_AND_SET(DebugMode)
34  ,ZEROOUT_GET_AND_SET(DAQEnabled)
35  ,ZEROOUT_GET_AND_SET(BufferEmpty)
36  ,ZEROOUT_GET_AND_SET(BufferFull)
37  ,ZEROOUT_GET_AND_SET(CommError)
38  ,ZEROOUT_GET_AND_SET(PacketError)
39  ,ZEROOUT_GET_AND_SET(OverflowError)
40  ,ZEROOUT_GET_AND_SET(ADCError)
41  */
42  ,ZEROOUT_FUNCTION(initWithData)
43  ,ZEROOUT_FUNCTION(setParameters)
44 {}
45 
47  PREVIOUS_VERSION_CLASS_NAME(copyin)
48  /*
49  ,DEEPCOPY_GET_AND_SET(FEBId)
50  ,DEEPCOPY_GET_AND_SET(FEBStatus)
51  ,DEEPCOPY_GET_AND_SET(PixelAddr)
52  ,DEEPCOPY_GET_AND_SET(Sequence)
53  ,DEEPCOPY_GET_AND_SET(Version)
54  ,DEEPCOPY_GET_AND_SET(Pad3)
55  ,DEEPCOPY_GET_AND_SET(DataPresent)
56  ,DEEPCOPY_GET_AND_SET(LinkStatus)
57  ,DEEPCOPY_GET_AND_SET(DebugMode)
58  ,DEEPCOPY_GET_AND_SET(DAQEnabled)
59  ,DEEPCOPY_GET_AND_SET(BufferEmpty)
60  ,DEEPCOPY_GET_AND_SET(BufferFull)
61  ,DEEPCOPY_GET_AND_SET(CommError)
62  ,DEEPCOPY_GET_AND_SET(PacketError)
63  ,DEEPCOPY_GET_AND_SET(OverflowError)
64  ,DEEPCOPY_GET_AND_SET(ADCError)
65  */
66  ,DEEPCOPY_FUNCTION(initWithData)
67  ,DEEPCOPY_FUNCTION(setParameters)
68 {}
69 
70 //------------------------Destructor--------------------------------------------
72 
73 //------------------------------------------------------------------------------
74 // Default initialization at wherever the pointer points
76 
77  /// Set version in the buffer
78  //EXECUTE_FUNCTION(setVersion)(_version);
79  setVersion(_version);
80 
81  /// Set Pad3 in the buffer do the defalut value
82  //EXECUTE_FUNCTION(setPad3)(nanosliceheader::PAD3_DEFAULT_VALUE);
84 }
85 
86 //------------------------------------------------------------------------------
87 // Initialization with data
88  void RawNanoSliceHeader::initWithData(const NanoSliceHeader& pars){
89 
90  /// Set all parameters in the buffer, including version
91  EXECUTE_FUNCTION(setParameters)(pars);
92 
93  /// Set Pad3 do the defalut value
94  //EXECUTE_FUNCTION(setPad3)(nanosliceheader::PAD3_DEFAULT_VALUE);
96  }
97 
98 //------------------------------------------------------------------------------
99 bool RawNanoSliceHeader::setParameters(const NanoSliceHeader& pars){
100 
101  /*
102  EXECUTE_FUNCTION(setLinkStatus ) (pars.LinkStatus);
103  EXECUTE_FUNCTION(setDataPresent) (pars.DataPresent);
104  EXECUTE_FUNCTION(setDebugMode ) (pars.DebugMode);
105  EXECUTE_FUNCTION(setFEBId ) (pars.FEBLinkID);
106  EXECUTE_FUNCTION(setFEBStatus ) (pars.FEBStatus);
107  EXECUTE_FUNCTION(setPixelAddr ) (pars.PixelAddress);
108  EXECUTE_FUNCTION(setSequence ) (pars.FrameSequenceNumber);
109  EXECUTE_FUNCTION(setVersion ) (pars.Version);
110  */
111  setLinkStatus (pars.LinkStatus);
112  setDataPresent (pars.DataPresent);
113  setDebugMode (pars.DebugMode);
114  setFEBId (pars.FEBLinkID);
115  setFEBStatus (pars.FEBStatus);
116  setPixelAddr (pars.PixelAddress);
117  setSequence (pars.FrameSequenceNumber);
118  return setVersion(pars.Version);
119 }
120 
121 //------------------------------------------------------------------------------
123 {
124  //RETURN_FUNCTION(setSequence)(EXECUTE_FUNCTION(getSequence)() + 1);
125  return setSequence(getSequence() + 1);
126 }
127 
128 //------------------------------------------------------------------------------
129 // Printing method
130 void RawNanoSliceHeader::print(std::ostream& os) const {
131 
132  os<<boost::format("NanoSlice Header: LS=%d DP=%d DM=%d FEBID=%u FEBSTAT=%u PIXEL=%u VERSION=%u SEQ=%u\n")
133  /*
134  % EXECUTE_FUNCTION(getLinkStatus)()
135  % EXECUTE_FUNCTION(getDataPresent)()
136  % EXECUTE_FUNCTION(getDebugMode)()
137  % EXECUTE_FUNCTION(getFEBId)()
138  % EXECUTE_FUNCTION(getFEBStatus)()
139  % EXECUTE_FUNCTION(getPixelAddr)()
140  % EXECUTE_FUNCTION(getVersion)()
141  % EXECUTE_FUNCTION(getSequence)();
142  */
143  % getLinkStatus()
144  % getDataPresent()
145  % getDebugMode()
146  % getFEBId()
147  % getFEBStatus()
148  % getPixelAddr()
149  % getVersion()
150  % getSequence();
151 
152  printBuffer(os);
153  os<<"RAW(binary):";
154  printWord(0,true, os);
155  os<<std::endl;
156 }// end of print1
157 
158 }}// end of daqdataformats::version0
#define ZEROOUT_FUNCTION(FUNC)
Definition: FunctionBind.h:52
#define DEEPCOPY_FUNCTION(FUNC)
Definition: FunctionBind.h:40
#define EXECUTE_FUNCTION(FULLFUNCTIONNAME)
Execute and return the delegate.
Definition: Macros.h:54
#define VERSION_NAMESPACE
Data structure for holding all the nanoslice data of interest.
RawNanoSliceHeader(const version_t)
The default constructor.
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
static const uint32_t PAD3_DEFAULT_VALUE
Default value for Pad3.
const XML_Char * version
Definition: expat.h:187
std::string pars("Th23Dmsq32")
int32_t version_t
Definition: RawDAQData.h:72
Class to hold the data from the FEBs in correct formats.