CMS 3D CMS Logo

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