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."
|
||||
@@ -1,27 +1,28 @@
|
||||
import sys
|
||||
|
||||
#seting parameters
|
||||
sensor = KEI11
|
||||
if sensor == KEI10:
|
||||
sensor = 'KEI11'
|
||||
if sensor == 'KEI10':
|
||||
detector= keithley_1a
|
||||
detector_range='X11MA-KEI10:RANGE'
|
||||
elif sensor == KEI11:
|
||||
elif sensor == 'KEI11':
|
||||
detector= keithley_2a
|
||||
detector_range='X11MA-KEI11:RANGE'
|
||||
else:
|
||||
print "Select a proper detector: KEI10 or KEI11."
|
||||
sys.exit()
|
||||
|
||||
caput(detector_range, 5) # 6 --> 200 nA
|
||||
caput(detector_range, 4) # 6 --> 200 nA
|
||||
exit_slit.move(30.0)
|
||||
speed = exit_slit.getSpeed()
|
||||
min_speed=exit_slit.getMinSpeed()
|
||||
exit_slit.setSpeed(min_speed)
|
||||
|
||||
#scan Energy Slit
|
||||
time.sleep(1)
|
||||
run('beamline_init/with_x-rays/functions/SlitCalib.py',{"Slit":exit_slit, "Slit_offset":exit_slit_offset, "detector":detector, "start":30, "end":-20.0, "step_size":1.0, "final_pos":20.0})
|
||||
time.sleep(1)
|
||||
|
||||
#resetting parameters
|
||||
caput(detector_range, 0) # 0--> AUTO
|
||||
exit_slit.setSpeed(speed)
|
||||
exit_slit.setSpeed(speed)
|
||||
|
||||
@@ -28,7 +28,7 @@ fit_threshold=readable_[0]*0.05
|
||||
|
||||
#filter the positions with analog values above the threshold
|
||||
for i in range(8,len(positions_),1):
|
||||
if(readable_[i]>fit_threshold):
|
||||
if(readable_[i]<fit_threshold):
|
||||
readable.append(readable_[i])
|
||||
positions.append(positions_[i])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user