-
Notifications
You must be signed in to change notification settings - Fork 5
/
MAPSA_GUI.py
179 lines (140 loc) · 5.03 KB
/
MAPSA_GUI.py
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#
# Simple command launcher for testbeam -JD 12-8-2015
#
import sys, select, os, array,subprocess
from Tkinter import *
#import serial
import time
class TBeamControl:
def __init__(self):
self.setting = 'default'
self.readout = 'both'
self.formatstring = 'noprocessing'
self.threshold = '90'
self.testbeam_clock = 'glib'
self.title = 'none'
self.shutter_duration = '500000'
self.normalize = 'False'
self.direction = 'glib'
self.loops = '-1'
self.phase = '0'
def exit(self):
print("Exit by Exit button in UI\n")
sys.exit(0)
def poweron(self,state):
if (state == 1) :
print('turn on\n')
os.system("python power.py -s on")
elif (state == 0) :
print('turn off\n')
os.system("python power.py -s off")
else:
print "Something went wrong."
def calibration(self):
print('Calibration pushed in UI')
self.shutter_duration = e7.get()
commandstring = "python calibration.py -w %s" % (self.shutter_duration)
os.system(commandstring)
def daq(self):
print('DAQ pushed in UI')
self.setting = e1.get()
self.readout = e2.get()
self.formatstring = e3.get()
self.threshold = e4.get()
self.testbeam_clock = e5.get()
self.title = e6.get()
self.shutter_duration = e7.get()
self.normalize = e8.get()
self.direction = e9.get()
self.loops = e10.get()
self.phase = e11.get()
commandstring = "python daq.py -s %s -r %s -f %s -t %s -T %s -y %s -w %s -N %s -D %s -L %s -p %s" % (self.setting, self.readout, self.formatstring, self.threshold, self.testbeam_clock, self.title, self.shutter_duration, self.normalize,self.direction,self.loops,self.phase)
print("pushing function " + commandstring)
os.system(commandstring)
commands = [
'export LD_LIBRARY_PATH=/opt/cactus/lib:$LD_LIBRARY_PATH',
'export PATH=/opt/cactus/bin:$PATH',
'source Setup.sh'
]
for s in commands :
subprocess.call( [s], shell=True )
tbeam = TBeamControl()
root = Tk()
tbeamui = Frame(root)
tbeamui.grid()
root.title("Simple TestBeam script launcher")
root.geometry("420x500");
#text_box = Entry(tbeamui, justify=RIGHT)
#text_box.grid(row = 0, column = 0, columnspan = 3, pady = 5)
#text_box.insert(0, "0")
button_exit = Button(tbeamui, text="Exit")
button_exit["command"]=lambda: tbeam.exit()
button_exit.grid(row=1,column=0, pady=5)
button_poweron = Button(tbeamui, text="Power ON")
button_poweron["command"]=lambda: tbeam.poweron(1)
button_poweron.grid(row=2,column=1, pady=5)
button_poweroff = Button(tbeamui, text="Power OFF")
button_poweroff["command"]=lambda: tbeam.poweron(0)
button_poweroff.grid(row=2,column=2, pady=5)
lab1 = Label(tbeamui, width=20,text="Setting",anchor='w')
lab1.grid(row=3,column=1,pady=5)
e1=Entry(tbeamui)
e1.insert(10,tbeam.setting);
e1.grid(row=3,column=2,pady=5)
lab2 = Label(tbeamui, width=20,text="Readout",anchor='w')
lab2.grid(row=4,column=1,pady=5)
e2=Entry(tbeamui)
e2.insert(10,tbeam.readout);
e2.grid(row=4,column=2,pady=5)
lab3 = Label(tbeamui, width=20,text="Format",anchor='w')
lab3.grid(row=5,column=1,pady=5)
e3=Entry(tbeamui)
e3.insert(10,tbeam.formatstring);
e3.grid(row=5,column=2,pady=5)
lab4 = Label(tbeamui, width=20,text="Threshold",anchor='w')
lab4.grid(row=6,column=1,pady=5)
e4=Entry(tbeamui)
e4.insert(10,tbeam.threshold);
e4.grid(row=6,column=2,pady=5)
lab5 = Label(tbeamui, width=20,text="Testbeam clock",anchor='w')
lab5.grid(row=7,column=1,pady=5)
e5=Entry(tbeamui)
e5.insert(10,tbeam.testbeam_clock);
e5.grid(row=7,column=2,pady=5)
lab6 = Label(tbeamui, width=20,text="Title",anchor='w')
lab6.grid(row=8,column=1,pady=5)
e6=Entry(tbeamui)
e6.insert(10,tbeam.title);
e6.grid(row=8,column=2,pady=5)
lab7 = Label(tbeamui, width=20,text="Shutter duration",anchor='w')
lab7.grid(row=9,column=1,pady=5)
e7=Entry(tbeamui)
e7.insert(10,tbeam.shutter_duration);
e7.grid(row=9,column=2,pady=5)
lab8 = Label(tbeamui, width=20,text="Normalize",anchor='w')
lab8.grid(row=10,column=1,pady=5)
e8=Entry(tbeamui)
e8.insert(10,tbeam.normalize);
e8.grid(row=10,column=2,pady=5)
lab9 = Label(tbeamui, width=20,text="Strip direction",anchor='w')
lab9.grid(row=11,column=1,pady=5)
e9=Entry(tbeamui)
e9.insert(10,tbeam.direction);
e9.grid(row=11,column=2,pady=5)
lab10 = Label(tbeamui, width=20,text="Number of shutters",anchor='w')
lab10.grid(row=12,column=1,pady=5)
e10=Entry(tbeamui)
e10.insert(10,tbeam.loops);
e10.grid(row=12,column=2,pady=5)
lab11 = Label(tbeamui, width=20,text="Shutter phase delay",anchor='w')
lab11.grid(row=13,column=1,pady=5)
e11=Entry(tbeamui)
e11.insert(10,tbeam.phase);
e11.grid(row=13,column=2,pady=5)
button_calibration = Button(tbeamui, text="Run Calibration")
button_calibration["command"]=lambda: tbeam.calibration()
button_calibration.grid(row=14,column=1, pady=5)
button_daq = Button(tbeamui, text="Run DAQ")
button_daq["command"]=lambda: tbeam.daq()
button_daq.grid(row=14,column=2, pady=5)
root.mainloop()