-
Notifications
You must be signed in to change notification settings - Fork 1
/
TdcSubEvent.h
100 lines (81 loc) · 3.06 KB
/
TdcSubEvent.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#ifndef HADAQ_TDCSUBEVENT_H
#define HADAQ_TDCSUBEVENT_H
#include "base/SubEvent.h"
#include "hadaq/TdcMessage.h"
namespace hadaq {
/** Extended message for \ref hadaq::TdcMessage */
typedef base::MessageExt<hadaq::TdcMessage> TdcMessageExt;
/** subevent with \ref hadaq::TdcMessage */
typedef base::SubEventEx<hadaq::TdcMessageExt> TdcSubEvent;
/** \brief Output float message
*
* \ingroup stream_hadaq_classes
*
* Stores channel, edge and relative to channel 0 time stamp as float
* Configured when calling base::ProcMgr::instance()->SetStoreKind(2); */
struct MessageFloat {
uint8_t ch; ///< channel and edge
float stamp; ///< time stamp minus channel0 time, ns
/** stamp */
float getStamp() const { return stamp; }
/** channel */
uint8_t getCh() const { return ch & 0x7F; }
/** edge 0 - rising, 1 - falling */
uint8_t getEdge() const { return ch >> 7; } // 0 - rising, 1 - falling
/** is rising */
bool isRising() const { return getEdge() == 0; }
/** is falling */
bool isFalling() const { return getEdge() == 1; }
/** constructor */
MessageFloat() : ch(0), stamp(0.) {}
/** constructor */
MessageFloat(const MessageFloat& src) : ch(src.ch), stamp(src.stamp) {}
/** constructor */
MessageFloat(unsigned _ch, bool _rising, float _stamp) :
ch(_ch | (_rising ? 0x00 : 0x80)),
stamp(_stamp)
{
}
/** compare operator - used for time sorting */
bool operator<(const MessageFloat &rhs) const
{ return (stamp < rhs.stamp); }
};
/** subevent with \ref hadaq::MessageFloat */
typedef base::SubEventEx<hadaq::MessageFloat> TdcSubEventFloat;
/** \brief Output double message
*
* \ingroup stream_hadaq_classes
*
* Stores channel, edge and full time stamp as double
* Configured when calling base::ProcMgr::instance()->SetStoreKind(3); */
struct MessageDouble {
uint8_t ch; ///< channel and edge
double stamp; ///< full time stamp, s
/** stamp */
double getStamp() const { return stamp; }
/** channel */
uint8_t getCh() const { return ch & 0x7F; }
/** edge 0 - rising, 1 - falling */
uint8_t getEdge() const { return ch >> 7; }
/** is rising */
bool isRising() const { return getEdge() == 0; }
/** is falling */
bool isFalling() const { return getEdge() == 1; }
/** constructor */
MessageDouble() : ch(0), stamp(0.) {}
/** constructor */
MessageDouble(const MessageDouble& src) : ch(src.ch), stamp(src.stamp) {}
/** constructor */
MessageDouble(unsigned _ch, bool _rising, double _stamp) :
ch(_ch | (_rising ? 0x00 : 0x80)),
stamp(_stamp)
{
}
/** compare operator - used for time sorting */
bool operator<(const MessageDouble &rhs) const
{ return (stamp < rhs.stamp); }
};
/** subevent with \ref hadaq::MessageDouble */
typedef base::SubEventEx<hadaq::MessageDouble> TdcSubEventDouble;
}
#endif