This commit is contained in:
@@ -0,0 +1,102 @@
|
||||
import subprocess
|
||||
import time
|
||||
import traceback
|
||||
|
||||
running = False
|
||||
counts = {}
|
||||
|
||||
def countHLS(motor):
|
||||
global counts
|
||||
try:
|
||||
time.sleep(1.0)
|
||||
counts[motor]=0
|
||||
def on_change(value):
|
||||
global counts
|
||||
print "LimitSW changed on" , motor, "to", value
|
||||
if int(value) == 1:
|
||||
counts[motor]=counts[motor]+1
|
||||
|
||||
with Channel(motor+".HLS", callback=on_change, monitored=True, name="test") as ch:
|
||||
if int(ch.read()) == 1:
|
||||
counts[motor]=1
|
||||
while(running==True):
|
||||
time.sleep(0.1)
|
||||
print "High Limit Switch motor "+motor +" reached "+ str(counts[motor]) + " times\n"
|
||||
return counts[motor]
|
||||
except:
|
||||
print "Exception counting "+str(motor)
|
||||
traceback.print_exc()
|
||||
raise
|
||||
|
||||
|
||||
def countLLS(motor):
|
||||
global counts
|
||||
try:
|
||||
time.sleep(1.0)
|
||||
counts[motor]=0
|
||||
def on_change(value):
|
||||
global counts
|
||||
print "LimitSW changed on" , motor, "to", value
|
||||
if int(value) == 1:
|
||||
counts[motor]=counts[motor]+1
|
||||
|
||||
with Channel(motor+".LLS", callback=on_change, monitored=True, name="test") as ch:
|
||||
if int(ch.read()) == 1:
|
||||
counts[motor]=1
|
||||
while(running==True):
|
||||
time.sleep(0.1)
|
||||
print "Low Limit Switch motor "+motor +" reached "+ str(counts[motor]) + " times\n"
|
||||
return counts[motor]
|
||||
except:
|
||||
print "Exception counting "+str(motor)
|
||||
traceback.print_exc()
|
||||
raise
|
||||
|
||||
def init():
|
||||
try:
|
||||
global running
|
||||
running = True
|
||||
|
||||
subprocess.call("X_X11MA_init-AU.sh", shell=True)
|
||||
# Positions at limit switches are not checked
|
||||
time.sleep(1.0)
|
||||
caput('X11MA-OP2-AVsize',20)
|
||||
caput('X11MA-OP2-AHsize',20)
|
||||
|
||||
running = False
|
||||
return 0
|
||||
except:
|
||||
print "Exception in init"
|
||||
traceback.print_exc()
|
||||
raise
|
||||
|
||||
|
||||
#Fork and join
|
||||
try:
|
||||
futures = fork(init,(countHLS,("X11MA-OP2-AU:TRY1",)), \
|
||||
(countLLS,("X11MA-OP2-AU:TRY4",)), \
|
||||
(countHLS,("X11MA-OP2-AU:TRZ1",)), \
|
||||
(countLLS,("X11MA-OP2-AU:TRZ4",)), \
|
||||
(countHLS,("X11MA-OP2-BP1:TRY",)), \
|
||||
(countHLS,("X11MA-OP2-BP1:TRZ",)) )
|
||||
ret = join(futures)
|
||||
|
||||
#check limit switch status after init
|
||||
limitsw=True
|
||||
for i in range(1,6):
|
||||
if(ret[i]!=1):
|
||||
limitsw=False
|
||||
print "Limit switch status for all motors: %s" %("OK" if limitsw == True else "Not OK")
|
||||
|
||||
#final status report
|
||||
if(limitsw==True):
|
||||
print "init-AU: ==> done. OK!"
|
||||
set_return("OK")
|
||||
else:
|
||||
print "init-AU: ==> not done. NOT OK!"
|
||||
set_return("Not OK")
|
||||
|
||||
except:
|
||||
set_return("Error")
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ def countHS(motor):
|
||||
counts[motor]=1
|
||||
while(running==True):
|
||||
time.sleep(0.1)
|
||||
print "Home Switch motor "+motor +" reached "+ str(counts[motor]) + " times"
|
||||
print "Home Switch motor "+motor +" reached "+ str(counts[motor]) + " times\n"
|
||||
return counts[motor]
|
||||
except:
|
||||
print "Exception counting "+str(motor)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
run("xrays_default")
|
||||
|
||||
time.sleep(3)
|
||||
|
||||
caput("X11MA-OP-SL:GO.PROC",1)
|
||||
time.sleep(30)
|
||||
exit_slit.write(20.0)
|
||||
|
||||
print "Init Exit Slit OK."
|
||||
Reference in New Issue
Block a user