46 lines
1.1 KiB
Python
46 lines
1.1 KiB
Python
if get_exec_pars().source == CommandSource.ui:
|
||
ID_ENERGY = 1250
|
||
HALFWIDTH = 10
|
||
STEP = 0.5
|
||
MODE = "Manual"
|
||
|
||
DRY_MODE = True
|
||
|
||
|
||
try:
|
||
if not DRY_MODE:
|
||
caput('X07MA-PHS-E:OPT', 'PGM')
|
||
energy_id.write(ID_ENERGY)
|
||
wait_device(energy_done, 1 )
|
||
sensors = [signal_i0, signal_tey, 'ca://X07MA-PC-K428:2:getTotalGain', energy]
|
||
|
||
if MODE =="C+":
|
||
set_pol_cplus()
|
||
if MODE =="C-":
|
||
set_pol_cminus()
|
||
if MODE == "LH":
|
||
set_pol_lin(0.0)
|
||
elif MODE == "LV":
|
||
set_pol_lin(90.0)
|
||
|
||
else:
|
||
sensors = [sin, energy]
|
||
|
||
ret = lscan(energy, sensors, ID_ENERGY-HALFWIDTH, ID_ENERGY+HALFWIDTH, STEP, latency = 0.3)
|
||
|
||
xdata = ret.getPositions(0)
|
||
ydata = ret.getReadable(0)
|
||
ymin = min(ydata)
|
||
e0 = xdata[ydata.index(min(ydata))]
|
||
new_offset =ID_ENERGY – e0 + pol_offset.take()
|
||
|
||
set_return(new_offset);
|
||
|
||
except:
|
||
print("Aborting...")
|
||
raise
|
||
finally:
|
||
if not DRY_MODE:
|
||
caput('X07MA-PHS-E:OPT', 'PGM+ID')
|
||
|