From aee3b46c62dacd754d56eae3921a6c149fa81fd9 Mon Sep 17 00:00:00 2001 From: gac-x04sa Date: Mon, 29 Oct 2018 17:07:04 +0100 Subject: [PATCH] Script execution --- script/local.py | 90 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 3 deletions(-) diff --git a/script/local.py b/script/local.py index a3ed3d1..0f7cf83 100644 --- a/script/local.py +++ b/script/local.py @@ -2,8 +2,6 @@ # Deployment specific global definitions - executed after startup.py ################################################################################################### - - class MyInterlock1 (Interlock): def __init__(self): Interlock.__init__(self, (alpha, gamma)) @@ -31,4 +29,90 @@ def close_shutter(): -run("device/Mythen") \ No newline at end of file +run("device/Mythen") + + + + + +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 + mythen.abort() + open_shutter() + if (count_time != 0): + pix_is_on = pix_is_on(scan)_ + 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 \ No newline at end of file