-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorca_mca_run.py
More file actions
50 lines (43 loc) · 1.68 KB
/
Copy pathorca_mca_run.py
File metadata and controls
50 lines (43 loc) · 1.68 KB
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
#!/usr/bin/python
'''
A script file which will connect to an already configured ORCA session (ie MCA is running and the FPGA is loaded).
'''
import telnetlib
import sys
def read_next(orca_connection, maxloops=10000):
result = None
loops = 0
newline = 'OrcaHeartBeat\n'
while (newline == 'OrcaHeartBeat\n' and loops < maxloops):
newline = orca_connection.read_until('\n', 3)
loops = loops + 1
return newline
def take_a_run(filename):
print('filename is: ' + filename)
#connect and look for a heartbeat
orca = telnetlib.Telnet('127.0.0.1', 4667)
raw_input('should be connected')
#if not orca.read_until('OrcaHeartBeat\n',5) == 'OrcaHeartBeat\n':
# print('did not see a heartbeat')
# sys.exit()
#now set the various hardware params:
#### turn of ULD
orca.write('uld = [ORMCA927Model setUpperDiscriminator:0 withValue:' + str(2**14-1) + '];')
raw_input('uld')
#### set livetime for the run to 3000 "units" which I think is 60 seconds...
orca.write('livelimit = [ORMCA927Model setLtPreset:0 withValue:' + str(3000) + '];')
raw_input('livelimit')
#### enable run ends by livetime reached, I didn't find a key but 8 seems right
orca.write('enablelive = [ORMCA927Model setPresetCtrlReg:0 withValue:' + str(8) + '];')
raw_input('enablelive')
#take the run
orca.write('start = [ORMCA927Model startAcquisition:0];')
raw_input('run')
#save the run
orca.write('save = [ORMCA927Model writeSpectrum:0 toFile:' + filename + '];')
raw_input('save')
if __name__ == '__main__':
try:
take_a_run(*sys.argv[1:])
except IndexError:
print('wrong number of arguments given')