Closedown

This commit is contained in:
gac-x03da
2018-02-08 16:39:40 +01:00
parent eaa7d808d7
commit 782c19c695
2 changed files with 63 additions and 19 deletions

View File

@@ -94,10 +94,45 @@ def trig_scienta():
Scienta.waitNewImage(3000, image_id)
print time.time(), " trig_scienta: return"
KEI_SAMPLE = "X03DA-KEITHLEY-1:"
KEI_REF = "X03DA-KEITHLEY-2:"
from keithley import KeiSample, KeiReference
def init_keithley(dwell):
def prepare_keithleys(dwell):
"""
prepare keithleys for gpib polling:
passive, bus triggered, dwell time
dwell = dwell time in seconds (0.1 - 20.0)
"""
KeiSample.prepare(dwell)
KeiReference.prepare(dwell)
def trig_keithleys():
"""
trigger keithleys, do not wait.
after this, you have to wait for at least the dwell time before reading the value!
"""
KeiSample.trig()
KeiReference.trig()
def read_keithleys():
"""
read the keithleys into EPICS.
this requires that at least the dwell time has passed since the last trigger.
the value can then be read from the SampleCurrent and ReferenceCurrent devices.
"""
KeiSample.fetch()
KeiReference.fetch()
def release_keithleys():
"""
switch keithleys to free run.
0.1 s polling and dwell time
"""
KeiSample.release()
KeiReference.release()
def init_keithley_ca(dwell):
"""
prepare keithleys for gpib polling:
passive, bus triggered, dwell time
@@ -120,7 +155,7 @@ def init_keithley(dwell):
caput(KEI_SAMPLE + "NAVG", navg)
caput(KEI_REF + "NAVG", navg)
def read_keithley():
def read_keithley_ca():
"""
trigger keithleys, wait until done, and read the result into EPICS.
the value can then be read by pshell from the channel.
@@ -136,7 +171,7 @@ def read_keithley():
caput(KEI_SAMPLE + "DOFETCH", 1)
caput(KEI_REF + "DOFETCH", 1)
def free_keithley():
def free_keithley_ca():
"""
switch keithleys to free run.
0.1 s polling and dwell time
@@ -289,8 +324,13 @@ def wait_beam():
time.sleep(0.1)
print "Beam ok"
def before_scan():
dwell = Scienta.getStepTime().read()
dwell = min(dwell, 20.0)
dwell = max(dwell, 0.1)
prepare_keithleys(dwell)
def before_readout():
wait_beam()
sample_scienta = False
for dev in ["Scienta.spectrum","EnergyDistribution", "AngleDistribution", "Scienta.dataMatrix"]:
if dev in SENSORS:
@@ -300,9 +340,12 @@ def before_readout():
if dev in SENSORS:
sample_scienta = True
break
wait_beam()
trig_keithleys()
if sample_scienta:
trig_scienta()
fetch_keithleys()
def after_readout(rec):
if get_exec_pars().persist:
@@ -315,7 +358,8 @@ def after_scan():
Close shutter and turn off analyser
"""
caput("X03DA-PC:AFTER-SCAN.PROC", 1)
release_keithleys()
def set_adc_averaging():
pass
#value = Scienta.getStepTime().read() * 10.0 #averaging count in 100ms

View File

@@ -1,25 +1,27 @@
"""
Flying hologram scan (work in progress)
Flying hologram scan (experimental)
Arguments:
PHI_RANGE (tuple (min, max))
THETA_RANGE (tuple (min, max))
STEPS (tuple (phi, theta))
PHI_RANGE (tuple (min, max))
THETA_STEP (scalar)
PHI_STEP (scalar)
SENSORS (list)
ZIGZAG (BOOLEAN)
LATENCY (float) in seconds
SENSORS (list of devices)
"""
THETA_RANGE = (-9.0, 1.0)
THETA_RANGE = (-9.5, 81.5)
THETA_STEP = 1.0
PHI_RANGE = (-10.0, +10.0)
PHI_STEP = 10.0
PHI_RANGE = (-160.0, +160.0)
PHI_STEP = 40.0
LATENCY = 0.0
ZIGZAG = True
ENDSCAN = False
MOTORS = (ManipulatorZ, ManipulatorY)
MOTORS = (ManipulatorTheta)
SENSORS = (Counts, Scienta.spectrum, SampleCurrent, RefCurrent, MachineCurrent)
#SENSORS = (Counts, Scienta.dataMatrix, SampleCurrent, RefCurrent, MachineCurrent)
@@ -50,10 +52,8 @@ try:
ManipulatorPhi.write(phi)
print "phi = ", phi
ManipulatorPhi.waitValueInRange(phi, 1.0, 100)
print time.time(), " cscan: start"
try:
cscan(ManipulatorTheta, SENSORS, THETA_RANGE[0], THETA_RANGE[1], THETA_NSTEPS - 1, time=theta_time, before_read=before_readout, after_read = after_readout)
print time.time(), " cscan: end"
cscan(MOTORS, SENSORS, THETA_RANGE[0], THETA_RANGE[1], THETA_NSTEPS - 1, time=theta_time, before_read=before_readout, after_read = after_readout)
except ContinuousScanFollowingErrorException:
print time.time(), " cscan: exception"
if ZIGZAG: