forked from saltastro/timDIMM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
timdimm
executable file
·187 lines (163 loc) · 6.24 KB
/
timdimm
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
180
181
182
183
184
185
186
187
#!/usr/bin/env python
from Tkinter import *
import os
import time
def run(program, *args):
pid = os.fork()
if not pid:
os.execvp(program, (program,) + args)
return pid
def massreboot(b):
print "Sending shutdown to MASS computer..."
os.system("ssh massdimm@massdimm \"sudo shutdown -r now\"")
def park(b, pid):
b.config(state=DISABLED)
print "\nParking MASS and telescope....\n"
os.system("./park")
b.config(text="Initialize")
quit.config(state=NORMAL)
main.config(state=DISABLED)
b.config(state=NORMAL)
b.config(command=lambda c=b: init(c))
#os.system("./ox_wagon.py RESET")
#time.sleep(2)
#os.system("./ox_wagon.py SCOPE")
#time.sleep(5)
#time.sleep(10)
#for i in range(8):
# print 'WAIT until both sliding and dropping roofs are FULLY CLOSED before sending ANY new commands to the ox-wagon and/or telecope\n'
# time.sleep(60)
#print 'Ox-wagon Fully Closed'
#os.system("./ox_wagon.py RESET")
#time.sleep(5)
#os.system("./ox_wagon.py STATUS")
#print "MAKE SURE that 'Telescope Powered On' in the above status is 'False'\n"
#print "... if not open an other terminal and run the following commands:\n"
#print "cd ~/timDIMM\n"
#print "./ox_wagon.py reset\n"
#print "./ox_wagon.py status\n"
def init(b):
print "\nInitializing mount and MASS....\n"
pid = run("./init")
quit.config(state=DISABLED)
time.sleep(60)
main.config(state=NORMAL)
b.config(text="Park")
b.config(command=lambda but=b,p=pid: park(but, p))
print "READY TO START SEEING MEASUREMENTS\n"
#for i in range(6):
# print 'WAIT until both sliding and dropping roofs are FULLY OPENED before sending ANY new commands to the ox-wagon and/or telecope\n'
# time.sleep(60)
#print 'Ox-wagon Fully Opened'
#os.system("./ox_wagon.py RESET")
#time.sleep(5)
#os.system("./ox_wagon.py STATUS")
#print "!!!MAKE SURE that 'Telescope Powered On' in the above status is 'True!!!'\n"
#print "... if not open an other terminal and run the following commands:\n"
#print "cd ~/timDIMM\n"
#print "./ox_wagon.py reset\n"
#print "./ox_wagon.py status\n"
time.sleep(5)
def killdimm9(b, pid):
print "\nKilling DS9 process #%d\n" % pid
os.system("kill -9 %d" % pid)
time.sleep(10)
os.system("killall ds9")
b.config(relief=RAISED)
b.config(text="DS9 DIMM Viewer")
b.config(command=lambda c=b: dimm9(c))
def dimm9(b):
pid = run("./dimm9")
b.config(relief=SUNKEN)
b.config(text="Kill DS9")
b.config(command=lambda but=b,p=pid: killdimm9(but, p))
def killmeasure_seeing(b, pid):
print "\nKilling main timDIMM process #%d\n" % pid
b.config(text="Stopping...")
b.config(state=DISABLED)
os.system("touch STOP_SPIRAL")
os.system("kill -9 %d" % pid)
#os.system("./turbina.rb stop_now")
if os.path.isfile("current_object"): os.remove("current_object")
time.sleep(5)
os.system("./pygto900.py park")
#time.sleep(5)
#os.system("./ox_wagon.py RESET")
#time.sleep(5)
#os.system("./ox_wagon.py STATUS")
b.config(text="Measure Seeing")
initpark.config(state=NORMAL)
b.config(state=NORMAL)
b.config(command=lambda c=b: measure_seeing(c))
print 'READY TO START MEASURING SEEING'
def measure_seeing(b):
if os.path.isfile("STOP_SPIRAL"): os.remove("STOP_SPIRAL")
#take it out of park
os.system("./pygto900.py park_off")
pid = run("./run_measure_seeing.py")
b.config(text="Stop Measuring Seeing")
initpark.config(state=DISABLED)
b.config(command=lambda but=b,p=pid: killmeasure_seeing(but, p))
def open_oxwagon(b):
print 'Opening Ox Wagon'
#os.system("./ox_wagon.py RESET")
os.system("./ox_wagon.py open 3600")
#for i in range(6):
# print 'WAIT until both sliding and dropping roofs are FULLY OPENED before sending ANY new commands to the ox-wagon and/or telecope\n'
# time.sleep(60)
#print 'Ox-wagon Fully Opened'
#os.system("./ox_wagon.py RESET")
#time.sleep(5)
#os.system("./ox_wagon.py STATUS")
#print "MAKE SURE that 'Telescope Powered On' in the above status is 'True'\n"
#print "... if not open an other terminal and run the following commands:\n"
#print "cd ~/timDIMM\n"
#print "./ox_wagon.py reset\n"
#print "./ox_wagon.py status\n"
def close_oxwagon(b):
print 'Closing Ox Wagon'
#os.system("./ox_wagon.py RESET")
#time.sleep(2)
#os.system("./ox_wagon.py SCOPE")
#time.sleep(2)
os.system("./ox_wagon.py CLOSE")
#time.sleep(10)
#for i in range(8):
# print 'WAIT until both sliding and dropping roofs are FULLY CLOSED before sending ANY new commands to the ox-wagon and/or telecope\n'
# time.sleep(60)
#print 'Ox-wagon Fully Closed'
#os.system("./ox_wagon.py RESET")
#time.sleep(2)
#os.system("./ox_wagon.py STATUS")
#print "MAKE SURE that 'Telescope Powered On' in the above status is 'False'\n"
#print "... if not open an other terminal and run the following commands:\n"
#print "cd ~/timDIMM\n"
#print "./ox_wagon.py reset\n"
#print "./ox_wagon.py status\n"
root = Tk()
root.title("timDIMM")
root.geometry("200x300-0-0")
frame = Frame(root)
frame.pack()
#reboot = Button(frame, text="Reboot MASS Computer")
#reboot.pack(padx=10, pady=5, fill=X)
#reboot.config(command=lambda b=reboot: massreboot(b))
ds9 = Button(frame, text="DS9")
ds9.pack(padx=10, pady=5, fill=X)
ds9.config(command=lambda b=ds9: dimm9(b))
initpark = Button(frame, text="Initialize")
initpark.pack(padx=10, pady=5, fill=X)
initpark.config(command=lambda b=initpark: init(b))
main = Button(frame, text="Measure Seeing", width=180)
main.pack(padx=10, pady=5, expand=True, fill=X)
main.config(command=lambda b=main: measure_seeing(b))
wagon = Button(frame, text="Open Ox Wagon", width=180)
wagon.pack(padx=10, pady=5, expand=True, fill=X)
wagon.config(command=lambda b=wagon: open_oxwagon(b))
wagon = Button(frame, text="Close Ox Wagon", width=180)
wagon.pack(padx=10, pady=5, expand=True, fill=X)
wagon.config(command=lambda b=wagon: close_oxwagon(b))
quit = Button(frame, text="QUIT", fg="red", command=frame.quit)
quit.pack(pady=20, padx=10, fill=BOTH)
#os.system("./tcp_serial_redirect.py -P 7001 /dev/tty.usbserial-A700dzoI >& serial.log &")
root.mainloop()