Files
x06da/script/fbm.py
2019-03-06 11:35:18 +01:00

78 lines
2.4 KiB
Python

###################################################################################################
#
###################################################################################################
#tc1 = caget('X06DA-OP-MO:TC1') # theta1 thermo couple 1
energy = get_energy() # Mono energy
dtz = detector_z.read()
if current.read() < 200:
raise Exception ('Ring current too low')
if fe_absorber.read()!= 'OPEN':
raise Exception ('FrontEndAbsorber closed') # FrontEnd absorber shutter state
if fe_shutter.read() != 'OPEN':
raise Exception ('FrontendShutter closed')
if eh_shutter.read() != 'OPEN': # ExpHutch shutter state
raise Exception ('ExpHutchShutter closed ')
if mono_energy.read()> 17.5: #Mono energy
raise Exception ('Sorry, no feedback above 17.5 keV for now')
tc = 40 # 2015.09.20 quick fix by MT JW
cur = es_beam.read()
op1 = caget('X06DA-OP-XPM1:CHAN1', 'd')
if op1 < 1.0:
sete_failed = 1
raise Exception ('X06DA-OP-XPM1:CHAN1 < 10 - please check monochromator, frontend, primary slits, ring current and undulator - program exits')
# define max deviations
dmx = 14.0 # 2 x distance mirror HR-XBPM
ymax = 2e-3 # endwhile criterion for vertical correction
if cur < tc: #check if beam is on CVD-XBPM
sete_failed = 1
raise Exception ('evere problem - NO BEAM ON HR-DIFFRACTOMETER XBPM')
# initial mirror TRY3 position
y3i = try3.read()
print "initial y3i: " + str(y3i)
# how much beam is off?
by = es_beam_posv.read()
print "EBOX-POSV before rock: " + str(by)
# if beam is not off, do nothing
if abs(by) > ymax:
rock(th1)
# result of ROCK
time.sleep(2.0)
by = es_beam_posv.read()
print "EBOX-POSV after rock: " + str(by)
# feedback
while abs(by) >= ymax :
by = es_beam_posv.read()
print "current EBOX-POSV: " + str(by)
cur = es_beam.read()
if cur > tc:
if (eh_shutter.read() == 'OPEN') and (abs(by) > ymax):
if abs(by) > (50*ymax):
raise Exception ('TODO')
#limit mirror TRY3 movement
y3 = try3.read()
if abs(y3i - y3 - 1e-4 * round(by/1e-3)) > 0.008:
raise Exception ('Feedback trying to move mirror Y3 beyond safe limit')
try3.moveRel(-1e-4 * round(by/1e-3))
print "current X06DA-OP-MI1:TRY3: ", y3
time.sleep(0.25)
print "TRY3 net movement: " + str(y3i-try3.read()) #print how much TRY3 moved