-
Notifications
You must be signed in to change notification settings - Fork 14
/
daq_device_deadtime.cc
134 lines (100 loc) · 2.34 KB
/
daq_device_deadtime.cc
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include <iostream>
#include <daq_device_deadtime.h>
using namespace std;
daq_device_deadtime::daq_device_deadtime(const int eventtype
, const int subeventid
, const int n_ticks
, const int n_words
, const int trigger_enabled)
{
m_eventType = eventtype;
m_subeventid = subeventid;
number_of_ticks = n_ticks;
number_of_words = n_words;
if (trigger_enabled)
{
th = new pulserTriggerHandler(m_eventType);
registerTriggerHandler(th);
}
else
{
th = 0;
}
}
daq_device_deadtime::~daq_device_deadtime()
{
if ( th)
{
clearTriggerHandler();
delete th;
}
}
// the put_data function
int daq_device_deadtime::put_data(const int etype, int * adr, const int length )
{
if (etype != m_eventType ) // not our id
{
return 0;
}
if ( number_of_ticks) usleep ( number_of_ticks);
if ( number_of_words)
{
if ( daq_getEventFormat() ) // we are writing PRDF
{
formatPacketHdr(adr);
packetdata_ptr sevt = (packetdata_ptr) adr;
// update id's etc
sevt->sub_id = m_subeventid;
sevt->sub_type=4;
sevt->sub_decoding = 30000 + ID4EVT;
int padding = number_of_words%2;
sevt->structureinfo += padding;
sevt->sub_length += number_of_words + padding;
return sevt->sub_length;
}
else
{
sevt = (subevtdata_ptr) adr;
// set the initial subevent length
sevt->sub_length = SEVTHEADERLENGTH;
// update id's etc
sevt->sub_id = m_subeventid;
sevt->sub_type=4;
sevt->sub_decoding = ID4EVT;
sevt->reserved[0] = 0;
sevt->reserved[1] = 0;
sevt->sub_padding = number_of_words%2;
sevt->sub_length += number_of_words + sevt->sub_padding;
return sevt->sub_length;
}
}
return 0;
}
void daq_device_deadtime::identify(std::ostream& os) const
{
os << "Deadtime Device Event Type: " << m_eventType
<< " n_ticks: " << number_of_ticks << " n_words: " << number_of_words;
if (th)
{
os << " ** Trigger enabled";
}
os << endl;
}
int daq_device_deadtime::max_length(const int etype) const
{
if (etype != m_eventType) return 0;
if ( number_of_words)
{
return SEVTHEADERLENGTH + number_of_words +2;
}
return 0;
}
int daq_device_deadtime::init()
{
return 0;
}
// the rearm() function
int daq_device_deadtime::rearm(const int etype)
{
return 0;
}