CMS 3D CMS Logo

Phase2TrackerFEDDAQTrailer.cc
Go to the documentation of this file.
1 #include <iomanip>
2 #include <ostream>
4 
5 namespace Phase2Tracker {
6 
7  std::ostream& operator<<(std::ostream& os, const FEDTTSBits& value) {
8  switch (value) {
10  os << "Disconected 0";
11  break;
12  case TTS_WARN_OVERFLOW:
13  os << "Warning overflow";
14  break;
15  case TTS_OUT_OF_SYNC:
16  os << "Out of sync";
17  break;
18  case TTS_BUSY:
19  os << "Busy";
20  break;
21  case TTS_READY:
22  os << "Ready";
23  break;
24  case TTS_ERROR:
25  os << "Error";
26  break;
27  case TTS_INVALID:
28  os << "Invalid";
29  break;
30  case TTS_DISCONNECTED1:
31  os << "Disconected 1";
32  break;
33  default:
34  os << "Unrecognized";
35  os << " (";
36  printHexValue(value, os);
37  os << ")";
38  break;
39  }
40  return os;
41  }
42 
44  switch (ttsNibble()) {
45  case TTS_DISCONNECTED0:
46  case TTS_WARN_OVERFLOW:
47  case TTS_OUT_OF_SYNC:
48  case TTS_BUSY:
49  case TTS_READY:
50  case TTS_ERROR:
51  case TTS_DISCONNECTED1:
52  return FEDTTSBits(ttsNibble());
53  default:
54  return TTS_INVALID;
55  }
56  }
57 
58  FEDDAQTrailer::FEDDAQTrailer(const uint32_t eventLengthIn64BitWords,
59  const uint16_t crc,
60  const FEDTTSBits ttsBits,
61  const bool slinkTransmissionError,
62  const bool badFEDID,
63  const bool slinkCRCError,
64  const uint8_t eventStatusNibble) {
65  //clear everything (T,x,$ all set to 0)
66  memset(trailer_, 0x0, 8);
67  //set the EoE nibble to indicate this is the last fragment
68  trailer_[7] = 0xA0;
69  //set variable fields vith values supplied
73  setCRC(crc);
75  setBadSourceIDBit(badFEDID);
77  }
78 
79  void FEDDAQTrailer::setEventLengthIn64BitWords(const uint32_t eventLengthIn64BitWords) {
80  trailer_[4] = (eventLengthIn64BitWords & 0x000000FF);
81  trailer_[5] = ((eventLengthIn64BitWords & 0x0000FF00) >> 8);
82  trailer_[6] = ((eventLengthIn64BitWords & 0x00FF0000) >> 16);
83  }
84 
85  void FEDDAQTrailer::setCRC(const uint16_t crc) {
86  trailer_[2] = (crc & 0x00FF);
87  trailer_[3] = ((crc >> 8) & 0x00FF);
88  }
89 
91  if (bitSet)
92  trailer_[1] |= 0x80;
93  else
94  trailer_[1] &= (~0x80);
95  }
96 
97  void FEDDAQTrailer::setBadSourceIDBit(const bool bitSet) {
98  if (bitSet)
99  trailer_[1] |= 0x40;
100  else
101  trailer_[1] &= (~0x40);
102  }
103 
104  void FEDDAQTrailer::setSLinkCRCErrorBit(const bool bitSet) {
105  if (bitSet)
106  trailer_[0] |= 0x04;
107  else
108  trailer_[0] &= (~0x40);
109  }
110 
111  void FEDDAQTrailer::setEventStatusNibble(const uint8_t eventStatusNibble) {
112  trailer_[1] = ((trailer_[1] & 0xF0) | (eventStatusNibble & 0x0F));
113  }
114 
115  void FEDDAQTrailer::setTTSBits(const FEDTTSBits ttsBits) { trailer_[0] = ((trailer_[0] & 0x0F) | (ttsBits & 0xF0)); }
116 
117 } // namespace Phase2Tracker
Phase2Tracker::FEDDAQTrailer::setEventLengthIn64BitWords
void setEventLengthIn64BitWords(const uint32_t eventLengthIn64BitWords)
Definition: Phase2TrackerFEDDAQTrailer.cc:79
Phase2Tracker::TTS_BUSY
Definition: Phase2TrackerFEDDAQTrailer.h:19
Phase2Tracker::TTS_READY
Definition: Phase2TrackerFEDDAQTrailer.h:20
Phase2Tracker::FEDDAQTrailer::slinkTransmissionError
bool slinkTransmissionError() const
Definition: Phase2TrackerFEDDAQTrailer.h:43
Phase2Tracker::FEDDAQTrailer::ttsBits
FEDTTSBits ttsBits() const
Definition: Phase2TrackerFEDDAQTrailer.cc:43
Phase2Tracker::FEDDAQTrailer::eventStatusNibble
uint8_t eventStatusNibble() const
Definition: Phase2TrackerFEDDAQTrailer.h:102
Phase2Tracker::FEDDAQTrailer::setBadSourceIDBit
void setBadSourceIDBit(const bool bitSet)
Definition: Phase2TrackerFEDDAQTrailer.cc:97
Phase2Tracker::operator<<
std::ostream & operator<<(std::ostream &os, const FEDDAQEventType &value)
Definition: Phase2TrackerFEDDAQHeader.cc:7
Phase2Tracker::FEDDAQTrailer::eventLengthIn64BitWords
uint32_t eventLengthIn64BitWords() const
Definition: Phase2TrackerFEDDAQTrailer.h:90
Phase2Tracker::TTS_WARN_OVERFLOW
Definition: Phase2TrackerFEDDAQTrailer.h:17
Phase2Tracker::FEDDAQTrailer::setSLinkCRCErrorBit
void setSLinkCRCErrorBit(const bool bitSet)
Definition: Phase2TrackerFEDDAQTrailer.cc:104
Phase2Tracker::FEDDAQTrailer::crc
uint16_t crc() const
Definition: Phase2TrackerFEDDAQTrailer.h:96
Phase2Tracker::FEDDAQTrailer::trailer_
uint8_t trailer_[8]
Definition: Phase2TrackerFEDDAQTrailer.h:78
Phase2Tracker::TTS_INVALID
Definition: Phase2TrackerFEDDAQTrailer.h:23
Phase2Tracker::TTS_OUT_OF_SYNC
Definition: Phase2TrackerFEDDAQTrailer.h:18
Phase2Tracker::FEDDAQTrailer::setCRC
void setCRC(const uint16_t crc)
Definition: Phase2TrackerFEDDAQTrailer.cc:85
Phase2TrackerFEDDAQTrailer.h
value
Definition: value.py:1
Phase2Tracker::FEDDAQTrailer::ttsNibble
uint8_t ttsNibble() const
Definition: Phase2TrackerFEDDAQTrailer.h:104
Phase2Tracker::printHexValue
void printHexValue(const uint8_t value, std::ostream &os)
Definition: utils.h:42
Phase2Tracker::FEDDAQTrailer::setEventStatusNibble
void setEventStatusNibble(const uint8_t eventStatusNibble)
Definition: Phase2TrackerFEDDAQTrailer.cc:111
Phase2Tracker::TTS_ERROR
Definition: Phase2TrackerFEDDAQTrailer.h:21
Phase2Tracker::TTS_DISCONNECTED0
Definition: Phase2TrackerFEDDAQTrailer.h:16
Phase2Tracker::TTS_DISCONNECTED1
Definition: Phase2TrackerFEDDAQTrailer.h:22
Phase2Tracker::FEDTTSBits
FEDTTSBits
Definition: Phase2TrackerFEDDAQTrailer.h:15
Phase2Tracker::FEDDAQTrailer::setTTSBits
void setTTSBits(const FEDTTSBits ttsBits)
Definition: Phase2TrackerFEDDAQTrailer.cc:115
Phase2Tracker::FEDDAQTrailer::setSLinkTransmissionErrorBit
void setSLinkTransmissionErrorBit(const bool bitSet)
Definition: Phase2TrackerFEDDAQTrailer.cc:90
Phase2Tracker::FEDDAQTrailer::slinkCRCError
bool slinkCRCError() const
Definition: Phase2TrackerFEDDAQTrailer.h:56
Phase2Tracker
Definition: Phase2TrackerFEDBuffer.h:12
Phase2Tracker::FEDDAQTrailer::FEDDAQTrailer
FEDDAQTrailer()
Definition: Phase2TrackerFEDDAQTrailer.h:32