-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch_monitor
executable file
·54 lines (43 loc) · 1.95 KB
/
launch_monitor
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
#!/usr/bin/env python3
import sys
from petsys import daqd, config, monitor
import argparse
def main(argv):
parser = argparse.ArgumentParser(description='Monitor setup example')
parser.add_argument("--monitor-toc", dest="monitor_toc", type=str, required=True, help="Monitor TOC")
args = parser.parse_args()
# Connect to DAQD, we'll need to know which ASICs are actually present
conn = daqd.Connection()
conn.initializeSystem()
# Create the monitor
m = monitor.Monitor()
# Create the monitor objects
# The names used here MUST be the same names as used in the actual monitor (online_monitor)
acquisition_t0 = monitor.SingleValue("acquisition_t0", m)
acquisition_elapsed = monitor.SingleValue("acquisition_elapsed", m)
coincidence_counter = monitor.SingleValue("coincidence_counter", m)
channel_counter = {}
channel_energy = {}
for p,s,a,c in conn.getActiveAsicsChannels():
channelID = c
channelID = (channelID << 6) | a
channelID = (channelID << 6) | s
channelID = (channelID << 5) | p
channel_counter[channelID] = monitor.SingleValue("channel_counter/%d" % channelID, m)
channel_energy[channelID] = monitor.Histogram1D(100, 0, 1000, "channel_energy/%d" % channelID, m);
# Actually creates the shared memory block
m.materialize()
# Writes out a TOC file describing the contents/layout of the shared memory block to be read by the monitor
m.writeTOC(args.monitor_toc)
print("LAUNCH ACQUISITION")
while input("(R)read or (Q)uit?") not in [ "q", "Q" ]:
m.lock()
print("Acquisition started at %f seconds UNIX EPOCH" % acquisition_t0.getValue())
print("Acquisition length was %f seconds" % (acquisition_elapsed.getValue() / conn.getSystemFrequency()))
print("Acquisition had %d coincidences" % int(coincidence_counter.getValue()))
m.unlock()
# Wait until acquisition is finisghed, we don't want to remove the shared memory meanwhile
input("PRESS ENTER WHEN ACQUISTION IS FINISHED")
return 0
if __name__ == '__main__':
sys.exit(main(sys.argv))