stream  0.10.0
stream analysis framework
TdcSubEvent.h
1 #ifndef HADAQ_TDCSUBEVENT_H
2 #define HADAQ_TDCSUBEVENT_H
3 
4 #include "base/SubEvent.h"
5 
6 #include "hadaq/TdcMessage.h"
7 
8 namespace hadaq {
9 
11  typedef base::MessageExt<hadaq::TdcMessage> TdcMessageExt;
12 
14  typedef base::SubEventEx<hadaq::TdcMessageExt> TdcSubEvent;
15 
23  struct MessageFloat {
24  uint8_t ch;
25  float stamp;
26 
28  float getStamp() const { return stamp; }
30  uint8_t getCh() const { return ch & 0x7F; }
32  uint8_t getEdge() const { return ch >> 7; } // 0 - rising, 1 - falling
34  bool isRising() const { return getEdge() == 0; }
36  bool isFalling() const { return getEdge() == 1; }
37 
39  MessageFloat() : ch(0), stamp(0.) {}
41  MessageFloat(const MessageFloat& src) : ch(src.ch), stamp(src.stamp) {}
43  MessageFloat(unsigned _ch, bool _rising, float _stamp) :
44  ch(_ch | (_rising ? 0x00 : 0x80)),
45  stamp(_stamp)
46  {
47  }
48 
50  bool operator<(const MessageFloat &rhs) const
51  { return (stamp < rhs.stamp); }
52 
53  };
54 
56  typedef base::SubEventEx<hadaq::MessageFloat> TdcSubEventFloat;
57 
65  struct MessageDouble {
66  uint8_t ch;
67  double stamp;
68 
70  double getStamp() const { return stamp; }
72  uint8_t getCh() const { return ch & 0x7F; }
74  uint8_t getEdge() const { return ch >> 7; }
76  bool isRising() const { return getEdge() == 0; }
78  bool isFalling() const { return getEdge() == 1; }
79 
81  MessageDouble() : ch(0), stamp(0.) {}
83  MessageDouble(const MessageDouble& src) : ch(src.ch), stamp(src.stamp) {}
85  MessageDouble(unsigned _ch, bool _rising, double _stamp) :
86  ch(_ch | (_rising ? 0x00 : 0x80)),
87  stamp(_stamp)
88  {
89  }
91  bool operator<(const MessageDouble &rhs) const
92  { return (stamp < rhs.stamp); }
93  };
94 
96  typedef base::SubEventEx<hadaq::MessageDouble> TdcSubEventDouble;
97 
98 }
99 
100 #endif
Extended message - any message plus global time stamp.
Definition: base/SubEvent.h:36
Subevent with vector of extended messages.
Definition: base/SubEvent.h:91
Output double message.
Definition: TdcSubEvent.h:65
double getStamp() const
stamp
Definition: TdcSubEvent.h:70
MessageDouble(const MessageDouble &src)
constructor
Definition: TdcSubEvent.h:83
uint8_t ch
channel and edge
Definition: TdcSubEvent.h:66
double stamp
full time stamp, s
Definition: TdcSubEvent.h:67
uint8_t getCh() const
channel
Definition: TdcSubEvent.h:72
bool isRising() const
is rising
Definition: TdcSubEvent.h:76
MessageDouble(unsigned _ch, bool _rising, double _stamp)
constructor
Definition: TdcSubEvent.h:85
uint8_t getEdge() const
edge 0 - rising, 1 - falling
Definition: TdcSubEvent.h:74
bool operator<(const MessageDouble &rhs) const
compare operator - used for time sorting
Definition: TdcSubEvent.h:91
MessageDouble()
constructor
Definition: TdcSubEvent.h:81
bool isFalling() const
is falling
Definition: TdcSubEvent.h:78
Output float message.
Definition: TdcSubEvent.h:23
MessageFloat()
constructor
Definition: TdcSubEvent.h:39
uint8_t getEdge() const
edge 0 - rising, 1 - falling
Definition: TdcSubEvent.h:32
bool isRising() const
is rising
Definition: TdcSubEvent.h:34
MessageFloat(unsigned _ch, bool _rising, float _stamp)
constructor
Definition: TdcSubEvent.h:43
float stamp
time stamp minus channel0 time, ns
Definition: TdcSubEvent.h:25
MessageFloat(const MessageFloat &src)
constructor
Definition: TdcSubEvent.h:41
bool isFalling() const
is falling
Definition: TdcSubEvent.h:36
uint8_t ch
channel and edge
Definition: TdcSubEvent.h:24
float getStamp() const
stamp
Definition: TdcSubEvent.h:28
uint8_t getCh() const
channel
Definition: TdcSubEvent.h:30
bool operator<(const MessageFloat &rhs) const
compare operator - used for time sorting
Definition: TdcSubEvent.h:50