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 
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
70  setEventLengthIn64BitWords(eventLengthIn64BitWords);
71  setEventStatusNibble(eventStatusNibble);
72  setTTSBits(ttsBits);
73  setCRC(crc);
74  setSLinkTransmissionErrorBit(slinkTransmissionError);
75  setBadSourceIDBit(badFEDID);
76  setSLinkCRCErrorBit(slinkCRCError);
77  }
78 
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 
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
void setSLinkCRCErrorBit(const bool bitSet)
std::ostream & operator<<(std::ostream &os, const FEDDAQEventType &value)
void setSLinkTransmissionErrorBit(const bool bitSet)
Definition: value.py:1
void setEventStatusNibble(const uint8_t eventStatusNibble)
void printHexValue(const uint8_t value, std::ostream &os)
Definition: utils.h:42
void setTTSBits(const FEDTTSBits ttsBits)
void setEventLengthIn64BitWords(const uint32_t eventLengthIn64BitWords)
void setBadSourceIDBit(const bool bitSet)