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