Files
dev/script/SIStem.py

79 lines
1.8 KiB
Python

#Debugging
if get_exec_pars().args is None:
"""
PRE_ACTIONS = {"motor2":0.1}
POSITIONERS = ["master", "motor"]
START = [0.0,0.0]
STOP = [1.0,1.0]
STEPS = [3, 5]
SENSORS = ["scienta.dataMatrix", "sin"]
SETTLING_TIME = 0.1
PASSES = 1
ZIGZAG = True
COMPRESSION = True
"""
NAME="Test"
print "Debug"
import json
def load_parameters(name):
filename = get_context().setup.expandPath("{home}/scans/" + name + ".json")
with open(filename) as config_file:
config = json.load(config_file)
for key in config.keys():
globals()[key] = config[key]
print str(key), " = ", config[key]
if NAME:
load_parameters(NAME)
#Enforece parameter types
positioners = string_to_obj(POSITIONERS)
sensors = string_to_obj(SENSORS)
start = list(to_array(START, 'd'))
end = list(to_array(STOP, 'd'))
steps = list(to_array(STEPS, 'i'))
latency = SETTLING_TIME
passes = int(PASSES)
zigzag = bool(ZIGZAG)
#Execute pre-actions
for key in PRE_ACTIONS.keys():
dev = string_to_obj(key)
if isinstance(dev, Writable):
log("Setting " + dev.name + " to: " + str(PRE_ACTIONS[key]))
dev.write(PRE_ACTIONS[key])
for key in PRE_ACTIONS.keys():
dev = string_to_obj(key)
if isinstance(dev, Device):
log("Waiting " + dev.name)
dev.waitReady(-1)
#Run scan
if COMPRESSION:
set_exec_pars(compression=[scienta.dataMatrix])
def before_read(pos, scan):
trigger_scienta()
def after_read(rec, scan):
pass
#handle_diagnostics(rec)
try:
ret= ascan(positioners, sensors, start, end, steps, \
latency = latency, relative = False, passes = passes, zigzag = zigzag, \
before_read = before_read, after_read = after_read,
snaps = diag_channels)
finally:
scienta.zeroSupplies()