Script execution

This commit is contained in:
gac-x04sa
2018-10-31 10:34:53 +01:00
parent 8ab85e5b91
commit 56c9af5587
+42 -40
View File
@@ -2,6 +2,11 @@
# Deployment specific global definitions - executed after startup.py
###################################################################################################
###################################################################################################
# Interlocks
###################################################################################################
class MyInterlock1 (Interlock):
def __init__(self):
Interlock.__init__(self, (alpha, gamma))
@@ -13,7 +18,9 @@ class MyInterlock1 (Interlock):
#interlock1 = MyInterlock1()
###################################################################################################
# Hardware
###################################################################################################
def open_shutter():
"""
@@ -27,6 +34,9 @@ def close_shutter():
"""
shutter.write("Off")
###################################################################################################
# Pseudo-devices
###################################################################################################
run("cpython/wrapper")
run("device/Mythen")
@@ -37,16 +47,37 @@ run("device/Image")
def after_sample(record, scan):
close_shutter()
count_time = 1.0
count_id = None
image_filename = None
###################################################################################################
# Configuration
###################################################################################################
COUNT_TIME_PREFERENCE = "count_time"
def get_count_time():
"""
"""
setting = get_setting(COUNT_TIME_PREFERENCE)
try:
return float(setting)
except:
return 1.0
def set_count_time(value):
"""
"""
count_time = value
set_setting(COUNT_TIME_PREFERENCE, value )
###################################################################################################
# Scan callbacks
###################################################################################################
count_id = None
image_filename = None
def trigger_detectors(position, scan):
global count_time, count_id, image_filename
pix_is_on = pixel in scan.readables
@@ -65,7 +96,6 @@ def trigger_detectors(position, scan):
else:
print "Preset monitor counting is not supported\!"
#waitcount
if pix_is_on:
pixel.wait_finished()
@@ -76,14 +106,10 @@ def trigger_detectors(position, scan):
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()
#pixel.logwrite()
else :
image_filename = None
count_id = + 1
@@ -99,35 +125,10 @@ def save_metadata(rec):
append_diag_datasets()
"""
#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()
"""
###################################################################################################
# Scan metadata
###################################################################################################
def get_diag_channels():
diag_channels = [ phi, \
@@ -178,6 +179,7 @@ def append_diag_datasets(parent = None):
append_dataset(group+get_diag_name(f), x)
except:
log("Error sampling " + str(get_diag_name(f)) + ": " + str(sys.exc_info()[1]))
#PSEUDO_DEVICES = h, k, l, lambda