Jpp  15.0.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Functions
print.cpp File Reference
#include "print.hpp"
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cctype>
#include <DataFormats/infoword.hh>
#include "structs.hpp"
#include "datatypes.hpp"

Go to the source code of this file.

Classes

struct  DOMID_h
 

Functions

std::ostream & operator<< (std::ostream &stream, DOMID_h const &domid)
 
void print_header (CLBCommonHeader const &header, dom_map_type const &name_map)
 
void print_optical_data (const char *const buffer, ssize_t buffer_size, int max_col)
 
void print_acoustic_data (const char *const buffer, ssize_t buffer_size, int max_col)
 
void print_monitoring_data (const char *const buffer, ssize_t buffer_size, int max_col)
 

Function Documentation

std::ostream& operator<< ( std::ostream &  stream,
DOMID_h const &  domid 
)

Definition at line 24 of file print.cpp.

25 {
26  /*
27  * The MAC address of a WR node starts with 08:00:30.
28  * The DOMID is defined by the MAC address removing the initial 08:00.
29  */
30 
31  std::ostringstream oss("0800", std::ostringstream::ate);
32  oss << std::hex << domid.m_val;
33  if (oss.tellp() != 12) {
34  return stream << "undefined";
35  }
36 
37  std::string const no = oss.str();
38  std::size_t const s = no.size();
39  for (std::size_t i = 0; i < s; i += 2) {
40  stream
41  << char(std::toupper(no[i]))
42  << char(std::toupper(no[i + 1]))
43  << (i != s - 2 ? ":" : "");
44  }
45 
46  return stream;
47 }
void print_header ( CLBCommonHeader const &  header,
dom_map_type const &  name_map 
)

Definition at line 49 of file print.cpp.

52  {
53  bool const valid = validTimeStamp(header);
54  bool const trailer = isTrailer(header);
55 
56  std::string name("");
57  if (! name_map.empty()) {
58  dom_map_type::const_iterator const it
59  = name_map.find(header.domIdentifier());
60 
61  if (it != name_map.end()) {
62  name = " - " + it->second;
63  } else {
64  name = " - unknown";
65  }
66  }
67 
68  std::cout
69  << "DataType: " << header.dataType() << '\n'
70  << "RunNumber: " << header.runNumber() << '\n'
71  << "UDPSequenceNumber: " << header.udpSequenceNumber() << '\n'
72 
73  << "Timestamp:\n"
74  << " Seconds: " << header.timeStamp().sec() << '\n'
75  << " Tics: " << header.timeStamp().tics() << '\n'
76  << " " << UTCTime_h(header.timeStamp(), valid) << '\n'
77 
78  << "DOMIdentifier: " << header.domIdentifier()
79  << " (MAC: " << DOMID_h(header.domIdentifier()) << name << ')' << '\n'
80  << "DOMStatus 1: " << header.domStatus(1) << '\n'
81  << "DOMStatus 2: " << header.domStatus(2);
82 
83  if (trailer && header.dataType() == ttdc) {
84  std::cout << " (trailer)\n";
85  } else {
86  std::cout << '\n';
87  }
88 
89  std::cout
90  << "DOMStatus 3: " << header.domStatus(3) << '\n'
91  << "DOMStatus 4: " << header.domStatus(4) << std::endl;
92 }
then echo Enter input within $TIMEOUT_S seconds echo n User name
Definition: JCookie.sh:42
bool validTimeStamp(CLBCommonHeader const &header)
bool isTrailer(CLBCommonHeader const &header)
unsigned int const ttdc
Definition: datatypes.cpp:7
void print_optical_data ( const char *const  buffer,
ssize_t  buffer_size,
int  max_col 
)

Definition at line 94 of file print.cpp.

98  {
99  unsigned int const nhits =
100  (buffer_size - sizeof(CLBCommonHeader)) / sizeof(hit_t);
101 
102  std::cout << "Number of hits: " << nhits << '\n';
103 
104  if (nhits) {
105  const int printing = 20 > nhits ? nhits : 20;
106  const unsigned int n = max_col > 37 ? max_col / 37 : 1;
107 
108  for (int i = 0; i < printing; ++i) {
109  const hit_t* const hit = static_cast<const hit_t* const>(
110  static_cast<const void* const>(buffer
111  + sizeof(CLBCommonHeader)
112  + i * sizeof(hit_t)));
113 
114  std::cout
115  << "Hit"
116  << std::setfill('0') << std::setw(2)
117  << i
118  << ": "
119  << *hit << ' ';
120 
121  if ((i + 1) % n == 0) {
122  std::cout << '\n';
123  } else {
124  std::cout << "| ";
125  }
126  }
127  }
128 
129  std::cout << '\n';
130 }
const int n
Definition: JPolint.hh:660
static const size_t buffer_size
const char *const hit_t
Definition: io_ascii.hh:24
void print_acoustic_data ( const char *const  buffer,
ssize_t  buffer_size,
int  max_col 
)

Definition at line 132 of file print.cpp.

136  {
137  CLBCommonHeader const* const header = static_cast<CLBCommonHeader const*>(
138  static_cast<void const*>(buffer));
139 
140  if (
141  ! header->udpSequenceNumber()
142  && is_infoword(buffer + sizeof(CLBCommonHeader))
143  ) {
144  std::cout << "InfoWord: yes\n"
145  << *static_cast<InfoWord const*>(static_cast<void const*>(
146  buffer + sizeof(CLBCommonHeader)
147  ))
148  << '\n';
149  } else {
150  std::cout << "InfoWord: no\n";
151  }
152 }
bool is_infoword(const void *const data)
Definition: infoword.hh:93
uint32_t udpSequenceNumber() const
void print_monitoring_data ( const char *const  buffer,
ssize_t  buffer_size,
int  max_col 
)

Definition at line 154 of file print.cpp.

158  {
159  const unsigned int n = max_col > 14 ? max_col / 14 : 1;
160 
161  for (int i = 0; i < 31; ++i) {
162  uint32_t const* const field = static_cast<uint32_t const*>(
163  static_cast<void const*>(buffer + sizeof(CLBCommonHeader) + i * 4)
164  );
165 
166  std::cout
167  << "CH"
168  << std::setfill('0') << std::setw(2)
169  << i << ": "
170  << std::setfill(' ') << std::setw(6)
171  << htonl(*field) << " ";
172 
173  if ((i + 1) % n == 0) {
174  std::cout << '\n';
175  }
176  }
177 
178  std::cout << '\n';
179 
180  ssize_t const minimum_size = sizeof(CLBCommonHeader) + sizeof(int) * 31;
181 
182  if (buffer_size > minimum_size) {
183  std::cout
184  << "SlowControl data:\n"
185  << *static_cast<SCData const*>(static_cast<void const*>(
186  buffer + minimum_size
187  ))
188  << '\n';
189  }
190 }
const int n
Definition: JPolint.hh:660
static const size_t buffer_size