Files
x04sa-es3/script/local.py
gac-x04sa 1df29f3b9c Closedown
2018-10-29 17:07:35 +01:00

118 lines
2.8 KiB
Python

###################################################################################################
# Deployment specific global definitions - executed after startup.py
###################################################################################################
class MyInterlock1 (Interlock):
def __init__(self):
Interlock.__init__(self, (alpha, gamma))
def check(self, (a, g)):
if a>=g:
return False
return True
#interlock1 = MyInterlock1()
def open_shutter():
"""
"""
shutter.write("On")
time.sleep(0.1)
def close_shutter():
"""
"""
shutter.write("Off")
run("device/Mythen")
run("device/pIXEL")
def after_sample(record, scan):
close_shutter()
count_time = 1.0
count_id = None
image_filename = None
def pix_is_on():
return pixel in scan.readables
def before_sample(position, scan):
global count_time, count_id, image_filename
pix_is_on = self.pix_is_on(scan)
mythen.abort()
open_shutter()
if (count_time != 0):
if pix_is_on:
pixel.set_expose(count_time)
pix.start()
if (count_time > 0):
mythen.set_acquire_time(count_time)
mythen.set_acquire_mode("Single")
mythen.start()
else:
print "Preset monitor counting is not supported\!"
#waitcount
if pix_is_on:
pixel.wait_finished()
i = 0
while (mythen.is_acquiring()):
time.sleep (0.05)
i += 1
if (i * 0.05 >= count_time * 2):
print "MYTHEN Izero times out, status: " + str(mythen.get_status())
break
#count_end()
# update the IMAGE_FILENAME and COUNT_ID variables
if pix_is_on:
image_filename = pixel.get_image_filename()
count_id = pixel.doUpdate()
pixlogwrite()
else :
image_filename = None
count_id = + 1
close_shutter()
#get_counts
global COUNT_ID
S[0] = mythen.acquire_time.read()
S[1] = mythen.read() #get_total_counts
# S[2] is detector counts from image.mac ###TODO
S[3] = S[2] / count_time / transm.getValue()
S[5] = transm.readback.read()
#TODO:Auto
"""
# set threshold counts in case auto-level support is available
if "AUTO_THRESH1" in globals():
AUTO_THRESH1_COUNT = (S[2]>=AUTO_THRESH1)?S[2]:0
AUTO_THRESH2_COUNT = (S[2]>=AUTO_THRESH2)?S[2]:0
AUTO_THRESH3_COUNT = (S[2]>=AUTO_THRESH3)?S[2]:0
AUTO_THRESH4_COUNT = (S[2]>=AUTO_THRESH4)?S[2]:0
"""
user_getcounts
#TODO: image
#imageUserGetcounts()
MOTOR_READBACKS = phi.readback, omegaH.readback, nu.readback, omegaV.readback, alpha.readback, delta.readback, gamma.readback, \
xv.readback, y1.readback, y2.readback, y3.readback, trx.readback, thy.readback
#PSEUDO_DEVICES = h, k, l, lambda