CbmRoot
StsXyterMessage.cxx
Go to the documentation of this file.
1 
2 #include "StsXyterMessage.h"
3 
4 // tools
5 
6 
7 // C++11
8 
9 // C/C++
10 #include <iomanip>
11 
12 // Namespace
13 using namespace stsxyter; // Class own namespace
14 // Namespaces alias
15 //namespace sxm = stsxyter::Message;
16 
17 
18 //************************* Messages OP ************************************//
19 //----------------------------------------------------------------------------
21  switch (GetField(kFieldSubtype)) {
22  case static_cast<uint16_t>(MessSubType::TsMsb): return MessSubType::TsMsb;
23  case static_cast<uint16_t>(MessSubType::Epoch): return MessSubType::Epoch;
24  case static_cast<uint16_t>(MessSubType::Status): return MessSubType::Status;
25  default: return MessSubType::Empty;
26  } // switch( static_cast< uint16_t>( GetField( kFieldSubtype ) ) )
27 }
28 //----------------------------------------------------------------------------
29 bool Message::PrintMess(std::ostream& os, MessagePrintMask ctrl) const {
30  bool bPrintHex = static_cast<bool>(ctrl & MessagePrintMask::msg_print_Hex);
31  bool bPrintHuman =
32  static_cast<bool>(ctrl & MessagePrintMask::msg_print_Human);
33  bool bPrintPrefix =
34  static_cast<bool>(ctrl & MessagePrintMask::msg_print_Prefix);
35  bool bPrintData = static_cast<bool>(ctrl & MessagePrintMask::msg_print_Data);
36 
37 
38  if (bPrintHex) {
39  const uint8_t* cArrByt = reinterpret_cast<const uint8_t*>(&fuData);
40 
41  // Set fill char to 0 and read previous state
42  char cPrev = os.fill('0');
43  os << "BE = " << std::hex << std::setw(2)
44  << static_cast<uint16_t>(cArrByt[0]) << ":" << std::setw(2)
45  << static_cast<uint16_t>(cArrByt[1]) << ":" << std::setw(2)
46  << static_cast<uint16_t>(cArrByt[2]) << ":" << std::setw(2)
47  << static_cast<uint16_t>(cArrByt[3]) << " LE = " << std::hex
48  << std::setw(2) << static_cast<uint16_t>(cArrByt[3]) << ":"
49  << std::setw(2) << static_cast<uint16_t>(cArrByt[2]) << ":"
50  << std::setw(2) << static_cast<uint16_t>(cArrByt[1]) << ":"
51  << std::setw(2) << static_cast<uint16_t>(cArrByt[0]) << std::dec
52  << " => ";
53 
54  // Restore fill char to original
55  os.fill(cPrev);
56  } // if( ctrl & msg_print_Hex )
57 
58  if (bPrintHuman) {
59  switch (GetMessType()) {
60  case MessType::Dummy: {
61  os << " Dummy Hit ";
62  break;
63  } // case MessType::TsMsb
64  case MessType::Hit: {
65  os << " Hit => "
66  << " Lnk: " << std::setw(3) << GetLinkIndex()
67  << " Ch: " << std::setw(3) << GetHitChannel()
68  << " Adc: " << std::setw(2) << GetHitAdc()
69  << " Ts Full: " << std::setw(4) << GetHitTimeFull()
70  << " Ts Over: " << std::hex << GetHitTimeOver() << std::dec
71  << " Ts: " << std::setw(3) << GetHitTime() << " Missed? "
72  << IsHitMissedEvts();
73  break;
74  } // case MessType::Hit
75  case MessType::TsMsb: {
76  os << " TS_MSB => " << std::setw(12) << GetTsMsbVal();
77  break;
78  } // case MessType::TsMsb
79  case MessType::Epoch: {
80  os << " Epoch => " << std::setw(12) << GetEpochVal();
81  break;
82  } // case MessType::TsMsb
83  case MessType::Status: {
84  os << " Status => "
85  << " Lnk: " << std::setw(2) << GetStatusLink()
86  << " Smx TS: " << std::setw(2) << GetStatusSxTs() << " Status: 0x"
87  << std::setw(4) << std::hex << GetStatusStatus() << std::dec
88  << " Dpb TS: " << std::setw(3) << GetStatusDpbTs()
89  << " CP flag: " << IsCpFlagOn();
90  break;
91  } // case MessType::TsMsb
92  case MessType::Empty: {
93  os << " Empty ";
94  break;
95  } // case MessType::TsMsb
96  default: {
97  } // default
98  } // switch( GetMessType() )
99  } // if( bPrintHuman )
100 
101  if (bPrintPrefix) {
102  switch (GetMessType()) {
103  case MessType::Dummy: {
104  break;
105  } // case MessType::Dummy
106  case MessType::Hit: {
107  break;
108  } // case MessType::Hit
109  case MessType::TsMsb: {
110  break;
111  } // case MessType::TsMsb
112  case MessType::Epoch: {
113  break;
114  } // case MessType::Epoch
115  case MessType::Status: {
116  break;
117  } // case MessType::Status
118  case MessType::Empty: {
119  break;
120  } // case MessType::Empty
121  default: {
122  } // default
123  } // switch( GetMessType() )
124  } // if( bPrintPrefix )
125 
126  if (bPrintData) {
127  switch (GetMessType()) {
128  case MessType::Dummy: {
129  break;
130  } // case MessType::Dummy
131  case MessType::Hit: {
132  break;
133  } // case MessType::Hit
134  case MessType::TsMsb: {
135  break;
136  } // case MessType::TsMsb
137  case MessType::Epoch: {
138  break;
139  } // case MessType::Epoch
140  case MessType::Status: {
141  break;
142  } // case MessType::Status
143  case MessType::Empty: {
144  break;
145  } // case MessType::Empty
146  default: {
147  } // default
148  } // switch( GetMessType() )
149  } // if( bPrintData )
150 
151  // Finish with a new line => 1 line per message printout
152  os << std::endl;
153 
154  return true;
155 }
156 //----------------------------------------------------------------------------
157 //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
158 //**************************************************************************//
159 
160 
161 //*********************** Private methods **********************************//
162 //----------------------------------------------------------------------------
163 //----------------------------------------------------------------------------
164 //**************************************************************************//
stsxyter::MessagePrintMask::msg_print_Hex
@ msg_print_Hex
stsxyter::Message::GetStatusDpbTs
uint16_t GetStatusDpbTs() const
For Status data: Returns the DPB TS when frame received (9 bit field)
Definition: StsXyterMessage.h:364
stsxyter::Message::fuData
uint32_t fuData
Definition: StsXyterMessage.h:168
stsxyter::MessType::Status
@ Status
stsxyter::MessSubType::Status
@ Status
stsxyter::Message::GetTsMsbVal
uint32_t GetTsMsbVal() const
For TS MSB data: Returns the TS MSB 22 bit field)
Definition: StsXyterMessage.h:334
stsxyter::Message::GetLinkIndex
uint16_t GetLinkIndex() const
For all data: Returns the (global) index of the eLink on which the message was received (n bit field)
Definition: StsXyterMessage.h:249
stsxyter::Message::GetHitTimeFull
uint16_t GetHitTimeFull() const
For Hit data: Returns Full timestamp (10 bit field including 2 bits overlap)
Definition: StsXyterMessage.h:280
stsxyter::Message::IsHitMissedEvts
bool IsHitMissedEvts() const
For Hit data: Returns Missed event flag (1 bit field)
Definition: StsXyterMessage.h:301
stsxyter::MessagePrintMask::msg_print_Data
@ msg_print_Data
stsxyter::Message::GetHitAdc
uint16_t GetHitAdc() const
For Hit data: Returns ADC value (5 bit field)
Definition: StsXyterMessage.h:277
stsxyter::MessType::Empty
@ Empty
stsxyter::Message::GetEpochVal
uint32_t GetEpochVal() const
For Epoch data: Returns the Epoch (29 bit field)
Definition: StsXyterMessage.h:346
stsxyter::Message::GetStatusSxTs
uint16_t GetStatusSxTs() const
For Status data: Returns the SMX TS from ACK frame (6 bit field)
Definition: StsXyterMessage.h:356
stsxyter::MessType::Hit
@ Hit
stsxyter::MessSubType::Epoch
@ Epoch
stsxyter::MessagePrintMask::msg_print_Prefix
@ msg_print_Prefix
stsxyter::MessagePrintMask
MessagePrintMask
Printout control.
Definition: StsXyterMessage.h:44
stsxyter::Message::GetStatusStatus
uint16_t GetStatusStatus() const
For Status data: Returns the Status field from ACK frame (4 bit field)
Definition: StsXyterMessage.h:359
StsXyterMessage.h
stsxyter::Message::GetMessType
MessType GetMessType() const
Returns the message type, see enum MessType.
Definition: StsXyterMessage.h:259
stsxyter::MessagePrintMask::msg_print_Human
@ msg_print_Human
stsxyter::MessSubType::Empty
@ Empty
stsxyter::MessSubType
MessSubType
Non-hit Message sub-types.
Definition: StsXyterMessage.h:37
stsxyter::Message::GetHitChannel
uint16_t GetHitChannel() const
For Hit data: Returns StsXYTER channel number (7 bit field)
Definition: StsXyterMessage.h:274
stsxyter::Message::GetStatusLink
uint16_t GetStatusLink() const
For Status data: Returns the Link Inedx (9 bit field)
Definition: StsXyterMessage.h:353
stsxyter::Message::PrintMess
bool PrintMess(std::ostream &os, MessagePrintMask ctrl=MessagePrintMask::msg_print_Human) const
Definition: StsXyterMessage.cxx:29
stsxyter::Message::GetField
uint32_t GetField(uint32_t uShift, uint32_t uLen) const
Definition: StsXyterMessage.h:192
stsxyter::MessSubType::TsMsb
@ TsMsb
stsxyter::Message::GetHitTimeOver
uint16_t GetHitTimeOver() const
For Hit data: Returns timestamp overlap bits (2 bits field, overlap with 2 LSBs of TS_MSB message)
Definition: StsXyterMessage.h:283
stsxyter::Message::IsCpFlagOn
bool IsCpFlagOn() const
For Status data: Returns the CP flag from ACK frame (1 bit field)
Definition: StsXyterMessage.h:367
stsxyter::Message::GetSubType
MessSubType GetSubType() const
For non-Hit data: Returns subtype (2 bit field)
Definition: StsXyterMessage.cxx:20
stsxyter::MessType::TsMsb
@ TsMsb
stsxyter::Message::GetHitTime
uint16_t GetHitTime() const
For Hit data: Returns timestamp (8 bit field, 2 MSB bits overlap removed)
Definition: StsXyterMessage.h:286
stsxyter::MessType::Dummy
@ Dummy
stsxyter::MessType::Epoch
@ Epoch
stsxyter
Definition: StsXyterFinalHit.h:12
stsxyter::kFieldSubtype
static const MessField kFieldSubtype(kusPosSubtype, kusLenSubtype)