Files
dev/script/harmonic.py
2020-06-17 09:52:22 +02:00

81 lines
2.6 KiB
Python

idenergy = 770
############################################################3
#Pre-actions
caput('X07MA-ID:ENERGY', idenergy)
cawait('X07MA-ID:DONE', 'DONE', type = 's')
caput('X07MA-PHS-E:OPT', 'PGM')
halfwidth = 10.0
step = 0.5#1.0
try:
#TODO: Set the diplay names of positioners and detectors
scan = ManualScan(['PGMenergy'], ['I0', 'polarization', 'polangle', 'ringCurrent', 'SetEnergy', 'offset'] , [idenergy-halfwidth], [idenergy+halfwidth], [20])
scan.start()
#Creating channels: dimension 1
#RegionPositioner PGMenergy
PGMenergy = Channel('X07MA-PHS-E:GO.A', type = 'd')
PGMenergyReadback = Channel('X07MA-PGM:CERBK', type = 'd')
#ScalarDetector I0
I0 = Channel('X07MA-ES1-AI:SIGNAL1', type = 'd')
#ScalarDetector polarization
polarization = Channel('X07MA-ID:MODE', type = 'd')
#ScalarDetector polangle
polangle = Channel('X07MA-ID:ALPHA', type = 'd')
ringCurrent = Channel('ARIDI-PCT:CURRENT', type = 'd')
#ScalarDetector SetEnergy
SetEnergy = Channel('X07MA-PHS-E:GO.A', type = 'd')
#ScalarDetector offset
offset = Channel('X07MA-ID:ENERGY-OFFS', type = 'd')
#Dimension 1
#RegionPositioner PGMenergy
for setpoint1 in frange(idenergy-halfwidth, idenergy+halfwidth, step, True):
PGMenergy.put(setpoint1, timeout=180.) # Feb. 2019, changed timeout from 60 to 180s. CP
wait_device(energy_done, 1 )
sleep( 0.5 ) # Settling time
readback1 = PGMenergyReadback.get()
#if abs(readback1 - setpoint1) > 0.5 : # TODO: Check accuracy
#raise Exception('Actor PGMenergy could not be set to the value ' + str(setpoint1))
sleep( 0.5 ) # Settling time
#Detector I0
detector2 = I0.get()
#Detector polarization
detector3 = polarization.get()
#Detector polangle
detector4 = polangle.get()
#Detector ringCurrent
detector6 = ringCurrent.get()
#Detector SetEnergy
detector7 = SetEnergy.get()
#Detector offset
detector10 = offset.get()
scan.append ([setpoint1], [readback1], [detector2, detector3, detector4, detector6, detector7, detector10])
#Closing channels
PGMenergy.close()
PGMenergyReadback.close()
I0.close()
polarization.close()
polangle.close()
ringCurrent.close()
SetEnergy.close()
offset.close()
scan.end()
#Post-actions
caput('X07MA-PHS-E:OPT', 'PGM+ID')
except:
print("Aborting...")
caput('X07MA-PHS-E:OPT', 'PGM+ID')
#if get_exec_pars().source != CommandSource.plugin:
# show_message(str(ex))
raise