Files
x07mb/script/2018_0905_090323_BeamMovementsMicroscope.py
2022-03-04 14:28:28 +01:00

426 lines
15 KiB
Python

#Script imported from: 2018_0905_090323_BeamMovementsMicroscope.xml
#Pre-actions
caput('X07MB-OP2:START-CSMPL', '0')
sleep(0.1)
caput('X07MB-XMAP:StopAll', '1')
sleep(0.1)
caput('X07MB-XMAP:CollectMode', '0')
sleep(0.2)
caput('X07MB-XMAP:Apply', '1')
sleep(0.1)
caput('X07MB-XMAP:PresetReal', '0')
sleep(0.1)
caput('X07MB-OP2:TOTAL-CYCLES', '5')
sleep(0.1)
caput('X07MB-ES1-PP2:VO5', '0')
sleep(0.1)
caput('X07MB-OP-WV1:WT_SET', '1')
sleep(0.1)
#TODO: Set the diplay names of positioners and detectors
scan = ManualScan(['Energy'], ['ScanX_set', 'ScanY_set', 'ROT_set', 'TRX1_set', 'TRZ1_set', 'DET_set', 'Energy_set', 'Mono_offset', 'I_SLS', 'I0_KEITHLEY1', 'KEITHLEY1_GAIN', 'I1_KEITHLEY2', 'KEITHLEY2_GAIN', 'KEITHLEY3', 'KEITHLEY3_GAIN', 'XBPM3_GAIN', 'XBPM3_SAI14_CUR_MEAN', 'XBPM3_SAI15_CUR_MEAN', 'XBPM3_SAI16_CUR_MEAN', 'XBPM3_SAI17_CUR_MEAN', 'XBPM3_POSX', 'XBPM3_POSY', 'XBPM4_GAIN', 'XBPM4_SAI19_CUR_MEAN', 'XBPM4_SAI20_CUR_MEAN', 'XBPM4_SAI21_CUR_MEAN', 'XBPM4_SAI22_CUR_MEAN', 'XBPM4_POSX', 'XBPM4_POSY', 'D1_Si', 'D1_ICR', 'D1_OCR', 'DD1_ELTM', 'DD1_ERTM', 'DD1_DTIM', 'Spec_1[2048]', 'MONO_THETA_TC1', 'MONO_TRX_TC1', 'MONO_C2_TC_Z', 'MONO_C2_TC_Y', 'MONO_TC1', 'MONO_TC2', 'MONO_TC3', 'MONO_TC4', 'MONO_TC5', 'MONO_TC6', 'MONO_TC7', 'MONO_TC8', 'MONO_TC9', 'MONO_TC10', 'MONO_TC11', 'MONO_TC12', 'MONO_TC13', 'MONO_TC14', 'MONO_TC15', 'MONO_TC16', 'ES1MF1', 'ES1MC1', 'OPKBMF1', 'OPSL2MF1', 'Mic_X', 'Mic_Y', 'Mic_sigma_X', 'Mic_Sigma_Y', 'Theta', 'Pitch', 'Roll', 'D1_Si_corr', 'Si_sum_cps'] , [3900.0], [5000.0], [220])
scan.start()
#Creating channels: dimension 1
#RegionPositioner Energy
Energy = Channel('X07MB-OP-MO:E-SET', type = 'd')
EnergyReadback = Channel('X07MB-OP-MO:E-GET', type = 'd')
#ScalarDetector ScanX_set
ScanX_set = Channel('X07MB-ES-MA1:ScanX.VAL', type = 'd')
#ScalarDetector ScanY_set
ScanY_set = Channel('X07MB-ES-MA1:ScanY.VAL', type = 'd')
#ScalarDetector ROT_set
ROT_set = Channel('X07MB-ES-MA1:ROT.VAL', type = 'd')
#ScalarDetector TRX1_set
TRX1_set = Channel('X07MB-ES-MA1:TRX1.VAL', type = 'd')
#ScalarDetector TRZ1_set
TRZ1_set = Channel('X07MB-ES-MA1:TRZ1.VAL', type = 'd')
#ScalarDetector DET_set
DET_set = Channel('X07MB-ES-RONTEC:TRX.VAL', type = 'd')
#ScalarDetector Energy_set
Energy_set = Channel('X07MB-OP-MO:E-SET', type = 'd')
#ScalarDetector Mono_offset
Mono_offset = Channel('X07MB-OP-MO:BEAM-OFS', type = 'd')
#ScalarDetector I_SLS
I_SLS = Channel('ARIDI-PCT:CURRENT', type = 'd')
#ScalarDetector I0_KEITHLEY1
I0_KEITHLEY1 = Channel('X07MB-OP2-SAI_07:MEAN', type = 'd')
#ScalarDetector KEITHLEY1_GAIN
KEITHLEY1_GAIN = Channel('X07MB-OP-KEITH1:setGain', type = 'd')
#ScalarDetector I1_KEITHLEY2
I1_KEITHLEY2 = Channel('X07MB-OP2-SAI_08:MEAN', type = 'd')
#ScalarDetector KEITHLEY2_GAIN
KEITHLEY2_GAIN = Channel('X07MB-OP-KEITH2:setGain', type = 'd')
#ScalarDetector KEITHLEY3
KEITHLEY3 = Channel('X07MB-OP2-SAI_06:MEAN', type = 'd')
#ScalarDetector KEITHLEY3_GAIN
KEITHLEY3_GAIN = Channel('X07MB-OP-KEITH3:setGain', type = 'd')
#ScalarDetector XBPM3_GAIN
XBPM3_GAIN = Channel('X07MB-OP2:LCAD3-GAIN', type = 'd')
#ScalarDetector XBPM3_SAI14_CUR_MEAN
XBPM3_SAI14_CUR_MEAN = Channel('X07MB-OP2-SAI_14:CUR-MEAN', type = 'd')
#ScalarDetector XBPM3_SAI15_CUR_MEAN
XBPM3_SAI15_CUR_MEAN = Channel('X07MB-OP2-SAI_15:CUR-MEAN', type = 'd')
#ScalarDetector XBPM3_SAI16_CUR_MEAN
XBPM3_SAI16_CUR_MEAN = Channel('X07MB-OP2-SAI_16:CUR-MEAN', type = 'd')
#ScalarDetector XBPM3_SAI17_CUR_MEAN
XBPM3_SAI17_CUR_MEAN = Channel('X07MB-OP2-SAI_17:CUR-MEAN', type = 'd')
#ScalarDetector XBPM3_POSX
XBPM3_POSX = Channel('X07MB-OP-BPM3:POSX', type = 'd')
#ScalarDetector XBPM3_POSY
XBPM3_POSY = Channel('X07MB-OP-BPM3:POSY', type = 'd')
#ScalarDetector XBPM4_GAIN
XBPM4_GAIN = Channel('X07MB-OP2:LCAD3-GAIN', type = 'd')
#ScalarDetector XBPM4_SAI19_CUR_MEAN
XBPM4_SAI19_CUR_MEAN = Channel('X07MB-OP2-SAI_19:CUR-MEAN', type = 'd')
#ScalarDetector XBPM4_SAI20_CUR_MEAN
XBPM4_SAI20_CUR_MEAN = Channel('X07MB-OP2-SAI_20:CUR-MEAN', type = 'd')
#ScalarDetector XBPM4_SAI21_CUR_MEAN
XBPM4_SAI21_CUR_MEAN = Channel('X07MB-OP2-SAI_21:CUR-MEAN', type = 'd')
#ScalarDetector XBPM4_SAI22_CUR_MEAN
XBPM4_SAI22_CUR_MEAN = Channel('X07MB-OP2-SAI_22:CUR-MEAN', type = 'd')
#ScalarDetector XBPM4_POSX
XBPM4_POSX = Channel('X07MB-OP-BPM4:POSX', type = 'd')
#ScalarDetector XBPM4_POSY
XBPM4_POSY = Channel('X07MB-OP-BPM4:POSY', type = 'd')
#ScalarDetector D1_Si
D1_Si = Channel('X07MB-XMAP:mca1.R0', type = 'd')
#ScalarDetector D1_ICR
D1_ICR = Channel('X07MB-XMAP:dxp1:InputCountRate', type = 'd')
#ScalarDetector D1_OCR
D1_OCR = Channel('X07MB-XMAP:dxp1:OutputCountRate', type = 'd')
#ScalarDetector DD1_ELTM
DD1_ELTM = Channel('X07MB-XMAP:mca1.ELTM', type = 'd')
#ScalarDetector DD1_ERTM
DD1_ERTM = Channel('X07MB-XMAP:mca1.ERTM', type = 'd')
#ScalarDetector DD1_DTIM
DD1_DTIM = Channel('X07MB-XMAP:mca1.DTIM', type = 'd')
#ArrayDetector Spec_1
Spec_1 = Channel('X07MB-XMAP:mca1.VAL', type = '[d', size = 2048)
#ScalarDetector MONO_THETA_TC1
MONO_THETA_TC1 = Channel('X07MB-OP-MOTHETA:TC1', type = 'd')
#ScalarDetector MONO_TRX_TC1
MONO_TRX_TC1 = Channel('X07MB-OP-MOTRX:TC1', type = 'd')
#ScalarDetector MONO_C2_TC_Z
MONO_C2_TC_Z = Channel('X07MB-OP-MOC2:TC_Z', type = 'd')
#ScalarDetector MONO_C2_TC_Y
MONO_C2_TC_Y = Channel('X07MB-OP-MOC2:TC_Y', type = 'd')
#ScalarDetector MONO_TC1
MONO_TC1 = Channel('X07MB-OP-MO:TC1', type = 'd')
#ScalarDetector MONO_TC2
MONO_TC2 = Channel('X07MB-OP-MO:TC2', type = 'd')
#ScalarDetector MONO_TC3
MONO_TC3 = Channel('X07MB-OP-MO:TC3', type = 'd')
#ScalarDetector MONO_TC4
MONO_TC4 = Channel('X07MB-OP-MO:TC4', type = 'd')
#ScalarDetector MONO_TC5
MONO_TC5 = Channel('X07MB-OP-MO:TC5', type = 'd')
#ScalarDetector MONO_TC6
MONO_TC6 = Channel('X07MB-OP-MO:TC6', type = 'd')
#ScalarDetector MONO_TC7
MONO_TC7 = Channel('X07MB-OP-MO:TC7', type = 'd')
#ScalarDetector MONO_TC8
MONO_TC8 = Channel('X07MB-OP-MO:TC8', type = 'd')
#ScalarDetector MONO_TC9
MONO_TC9 = Channel('X07MB-OP-MO:TC9', type = 'd')
#ScalarDetector MONO_TC10
MONO_TC10 = Channel('X07MB-OP-MO:TC10', type = 'd')
#ScalarDetector MONO_TC11
MONO_TC11 = Channel('X07MB-OP-MO:TC11', type = 'd')
#ScalarDetector MONO_TC12
MONO_TC12 = Channel('X07MB-OP-MO:TC12', type = 'd')
#ScalarDetector MONO_TC13
MONO_TC13 = Channel('X07MB-OP-MO:TC13', type = 'd')
#ScalarDetector MONO_TC14
MONO_TC14 = Channel('X07MB-OP-MO:TC14', type = 'd')
#ScalarDetector MONO_TC15
MONO_TC15 = Channel('X07MB-OP-MO:TC15', type = 'd')
#ScalarDetector MONO_TC16
MONO_TC16 = Channel('X07MB-OP-MO:TC16', type = 'd')
#ScalarDetector ES1MF1
ES1MF1 = Channel('X07MB-ES1-MF1:PRESSURE', type = 'd')
#ScalarDetector ES1MC1
ES1MC1 = Channel('X07MB-ES1-MC1:PRESSURE', type = 'd')
#ScalarDetector OPKBMF1
OPKBMF1 = Channel('X07MB-OP-KBMF1:PRESSURE', type = 'd')
#ScalarDetector OPSL2MF1
OPSL2MF1 = Channel('X07MB-OP-SL2MF1:PRESSURE', type = 'd')
#ScalarDetector Mic_X
Mic_X = Channel('X07MB-PC-PSCAN:CAM1-BEAMPOS_X', type = 'd')
#ScalarDetector Mic_Y
Mic_Y = Channel('X07MB-PC-PSCAN:CAM1-BEAMPOS_Y', type = 'd')
#ScalarDetector Mic_sigma_X
Mic_sigma_X = Channel('X07MB-PC-PSCAN:CAM1-SIGMA_X', type = 'd')
#ScalarDetector Mic_Sigma_Y
Mic_Sigma_Y = Channel('X07MB-PC-PSCAN:CAM1-SIGMA_Y', type = 'd')
#ScalarDetector Theta
Theta = Channel('X07MB-OP-MO:THETA.RBV', type = 'd')
#ScalarDetector Pitch
Pitch = Channel('X07MB-OP-MO:C2-ROX.RBV', type = 'd')
#ScalarDetector Roll
Roll = Channel('X07MB-OP-MO:C2-ROZ.RBV', type = 'd')
#Dimension 1
#RegionPositioner Energy
for setpoint1 in frange(3900.0, 5000.0, 5.0, True):
#Region 1 pre-actions
if setpoint1 == 3900.0:
caput('X07MB-OP2:TOTAL-CYCLES', '5')
sleep(5.0)
Energy.put(setpoint1, timeout=None) # TODO: Set appropriate timeout
readback1 = EnergyReadback.get()
if abs(readback1 - setpoint1) > 2.5 : # TODO: Check accuracy
raise Exception('Actor Energy could not be set to the value ' + str(setpoint1))
sleep( 3.0 ) # Settling time
#Dimension Actions
caputq('X07MB-XMAP:EraseStart', '1')
sleep(0.1)
caput('X07MB-OP2:SMPL', '1')
sleep(0.1)
cawait('X07MB-OP2:SMPL-DONE', 1, type = 'l')
sleep(0.1)
caput('X07MB-XMAP:StopAll', '1')
sleep(0.1)
#Detector ScanX_set
detector1 = ScanX_set.get()
#Detector ScanY_set
detector2 = ScanY_set.get()
#Detector ROT_set
detector3 = ROT_set.get()
#Detector TRX1_set
detector4 = TRX1_set.get()
#Detector TRZ1_set
detector5 = TRZ1_set.get()
#Detector DET_set
detector6 = DET_set.get()
#Detector Energy_set
detector7 = Energy_set.get()
#Detector Mono_offset
detector8 = Mono_offset.get()
#Detector I_SLS
detector9 = I_SLS.get()
#Detector I0_KEITHLEY1
detector10 = I0_KEITHLEY1.get()
#Detector KEITHLEY1_GAIN
detector11 = KEITHLEY1_GAIN.get()
#Detector I1_KEITHLEY2
detector12 = I1_KEITHLEY2.get()
#Detector KEITHLEY2_GAIN
detector13 = KEITHLEY2_GAIN.get()
#Detector KEITHLEY3
detector14 = KEITHLEY3.get()
#Detector KEITHLEY3_GAIN
detector15 = KEITHLEY3_GAIN.get()
#Detector XBPM3_GAIN
detector16 = XBPM3_GAIN.get()
#Detector XBPM3_SAI14_CUR_MEAN
detector17 = XBPM3_SAI14_CUR_MEAN.get()
#Detector XBPM3_SAI15_CUR_MEAN
detector18 = XBPM3_SAI15_CUR_MEAN.get()
#Detector XBPM3_SAI16_CUR_MEAN
detector19 = XBPM3_SAI16_CUR_MEAN.get()
#Detector XBPM3_SAI17_CUR_MEAN
detector20 = XBPM3_SAI17_CUR_MEAN.get()
#Detector XBPM3_POSX
detector21 = XBPM3_POSX.get()
#Detector XBPM3_POSY
detector22 = XBPM3_POSY.get()
#Detector XBPM4_GAIN
detector23 = XBPM4_GAIN.get()
#Detector XBPM4_SAI19_CUR_MEAN
detector24 = XBPM4_SAI19_CUR_MEAN.get()
#Detector XBPM4_SAI20_CUR_MEAN
detector25 = XBPM4_SAI20_CUR_MEAN.get()
#Detector XBPM4_SAI21_CUR_MEAN
detector26 = XBPM4_SAI21_CUR_MEAN.get()
#Detector XBPM4_SAI22_CUR_MEAN
detector27 = XBPM4_SAI22_CUR_MEAN.get()
#Detector XBPM4_POSX
detector28 = XBPM4_POSX.get()
#Detector XBPM4_POSY
detector29 = XBPM4_POSY.get()
#Detector D1_Si
detector30 = D1_Si.get()
#Detector D1_ICR
detector31 = D1_ICR.get()
#Detector D1_OCR
detector32 = D1_OCR.get()
#Detector DD1_ELTM
detector33 = DD1_ELTM.get()
#Detector DD1_ERTM
detector34 = DD1_ERTM.get()
#Detector DD1_DTIM
detector35 = DD1_DTIM.get()
#Detector Spec_1
detector36 = Spec_1.get()
#Detector MONO_THETA_TC1
detector37 = MONO_THETA_TC1.get()
#Detector MONO_TRX_TC1
detector38 = MONO_TRX_TC1.get()
#Detector MONO_C2_TC_Z
detector39 = MONO_C2_TC_Z.get()
#Detector MONO_C2_TC_Y
detector40 = MONO_C2_TC_Y.get()
#Detector MONO_TC1
detector41 = MONO_TC1.get()
#Detector MONO_TC2
detector42 = MONO_TC2.get()
#Detector MONO_TC3
detector43 = MONO_TC3.get()
#Detector MONO_TC4
detector44 = MONO_TC4.get()
#Detector MONO_TC5
detector45 = MONO_TC5.get()
#Detector MONO_TC6
detector46 = MONO_TC6.get()
#Detector MONO_TC7
detector47 = MONO_TC7.get()
#Detector MONO_TC8
detector48 = MONO_TC8.get()
#Detector MONO_TC9
detector49 = MONO_TC9.get()
#Detector MONO_TC10
detector50 = MONO_TC10.get()
#Detector MONO_TC11
detector51 = MONO_TC11.get()
#Detector MONO_TC12
detector52 = MONO_TC12.get()
#Detector MONO_TC13
detector53 = MONO_TC13.get()
#Detector MONO_TC14
detector54 = MONO_TC14.get()
#Detector MONO_TC15
detector55 = MONO_TC15.get()
#Detector MONO_TC16
detector56 = MONO_TC16.get()
#Detector ES1MF1
detector57 = ES1MF1.get()
#Detector ES1MC1
detector58 = ES1MC1.get()
#Detector OPKBMF1
detector59 = OPKBMF1.get()
#Detector OPSL2MF1
detector60 = OPSL2MF1.get()
#Detector Mic_X
detector61 = Mic_X.get()
#Detector Mic_Y
detector62 = Mic_Y.get()
#Detector Mic_sigma_X
detector63 = Mic_sigma_X.get()
#Detector Mic_Sigma_Y
detector64 = Mic_Sigma_Y.get()
#Detector Theta
detector65 = Theta.get()
#Detector Pitch
detector66 = Pitch.get()
#Detector Roll
detector67 = Roll.get()
#Manipulation D1_Si_corr
#Variable Mappings
a = detector30
b = detector31
c = detector32
d = detector33
#TODO: Move, if needed, this import to the file header: import math
DeadTime = 1.182e-7
ICR = b
OCR = c
Test = 1.e8
TestICR = ICR
n = 0
while ((Test > DeadTime) and (n < 30)):
TrueICR = ICR * math.exp(TestICR * DeadTime)
Test = (TrueICR - TestICR) / TestICR
TestICR = TrueICR
n = n + 1
D1_Si_corr = a * TrueICR / OCR / d
#Manipulation Si_sum_cps
#Variable Mappings
detector30_corr = detector33
detector33 = detector33
#TODO: Move, if needed, this import to the file header: import math
DeadTime = 1.182e-7
SUM_DET = 0.
SUM_DET = SUM_DET + detector30_corr
Si_sum_cps = SUM_DET
scan.append ([setpoint1], [readback1], [detector1, detector2, detector3, detector4, detector5, detector6, detector7, detector8, detector9, detector10, detector11, detector12, detector13, detector14, detector15, detector16, detector17, detector18, detector19, detector20, detector21, detector22, detector23, detector24, detector25, detector26, detector27, detector28, detector29, detector30, detector31, detector32, detector33, detector34, detector35, detector36, detector37, detector38, detector39, detector40, detector41, detector42, detector43, detector44, detector45, detector46, detector47, detector48, detector49, detector50, detector51, detector52, detector53, detector54, detector55, detector56, detector57, detector58, detector59, detector60, detector61, detector62, detector63, detector64, detector65, detector66, detector67, D1_Si_corr, Si_sum_cps])
#Closing channels
Energy.close()
EnergyReadback.close()
ScanX_set.close()
ScanY_set.close()
ROT_set.close()
TRX1_set.close()
TRZ1_set.close()
DET_set.close()
Energy_set.close()
Mono_offset.close()
I_SLS.close()
I0_KEITHLEY1.close()
KEITHLEY1_GAIN.close()
I1_KEITHLEY2.close()
KEITHLEY2_GAIN.close()
KEITHLEY3.close()
KEITHLEY3_GAIN.close()
XBPM3_GAIN.close()
XBPM3_SAI14_CUR_MEAN.close()
XBPM3_SAI15_CUR_MEAN.close()
XBPM3_SAI16_CUR_MEAN.close()
XBPM3_SAI17_CUR_MEAN.close()
XBPM3_POSX.close()
XBPM3_POSY.close()
XBPM4_GAIN.close()
XBPM4_SAI19_CUR_MEAN.close()
XBPM4_SAI20_CUR_MEAN.close()
XBPM4_SAI21_CUR_MEAN.close()
XBPM4_SAI22_CUR_MEAN.close()
XBPM4_POSX.close()
XBPM4_POSY.close()
D1_Si.close()
D1_ICR.close()
D1_OCR.close()
DD1_ELTM.close()
DD1_ERTM.close()
DD1_DTIM.close()
Spec_1.close()
MONO_THETA_TC1.close()
MONO_TRX_TC1.close()
MONO_C2_TC_Z.close()
MONO_C2_TC_Y.close()
MONO_TC1.close()
MONO_TC2.close()
MONO_TC3.close()
MONO_TC4.close()
MONO_TC5.close()
MONO_TC6.close()
MONO_TC7.close()
MONO_TC8.close()
MONO_TC9.close()
MONO_TC10.close()
MONO_TC11.close()
MONO_TC12.close()
MONO_TC13.close()
MONO_TC14.close()
MONO_TC15.close()
MONO_TC16.close()
ES1MF1.close()
ES1MC1.close()
OPKBMF1.close()
OPSL2MF1.close()
Mic_X.close()
Mic_Y.close()
Mic_sigma_X.close()
Mic_Sigma_Y.close()
Theta.close()
Pitch.close()
Roll.close()
scan.end()
#Post-actions
caput('X07MB-OP2:START-CSMPL', '1')
sleep(0.1)