From bb9c188428d10b324aed533f1d16050afb4c9279 Mon Sep 17 00:00:00 2001 From: gac-x11ma Date: Tue, 14 Jun 2022 16:29:48 +0200 Subject: [PATCH] --- config/sessions.properties | 3 +- config/settings.properties | 10 +- config/variables.properties | 6 +- devices/manip_x.properties | 10 + devices/manip_y.properties | 10 + plugins/XPEEM_Settings.form | 8 +- plugins/XPEEM_Settings.java | 10 +- script/May2022_Holder1_ASSBs_low.py | 478 ++++++++++++++++++++++++++++ script/devices/LEEM2000.py | 49 ++- script/local.py | 21 +- script/templates/EnergyScan_v4.py | 121 +++++++ script/test/test.py | 2 +- 12 files changed, 688 insertions(+), 40 deletions(-) create mode 100644 devices/manip_x.properties create mode 100644 devices/manip_y.properties create mode 100644 script/May2022_Holder1_ASSBs_low.py create mode 100644 script/templates/EnergyScan_v4.py diff --git a/config/sessions.properties b/config/sessions.properties index 3ad7cd9..9b06a6d 100644 --- a/config/sessions.properties +++ b/config/sessions.properties @@ -1,3 +1,2 @@ -#Mon May 23 22:49:52 CEST 2022 +#Tue May 24 11:00:40 CEST 2022 SessionCounter=73 -CurrentSession=73 diff --git a/config/settings.properties b/config/settings.properties index 607a764..edcb234 100644 --- a/config/settings.properties +++ b/config/settings.properties @@ -1,16 +1,16 @@ -#Tue May 24 10:06:26 CEST 2022 +#Fri Jun 10 15:30:15 CEST 2022 HARMONIC_ID_1=1 RSYNC_USER= OUTLIERS_THRESHOLD=1000000000 NORM_FILE=/sls/X11MA/data/e19357/Data1/2021_10 AUTO_SWITCH_VALVE=true -DRY_RUN=false -POL_ID_2=Lin_Ver +DRY_RUN=true +POL_ID_2=Circ_Minus OFFSET_ID_1=-1.4 -ID=ID2 +ID=ID1_ID2 OFFSET_ID_2=-1.2 proposal=proposal -ENERGY=455.0 +ENERGY=642.0 proposer=proposer POL_ID_1=Circ_Plus RSYNC_HOST= diff --git a/config/variables.properties b/config/variables.properties index 34467d0..5c9b343 100644 --- a/config/variables.properties +++ b/config/variables.properties @@ -1,4 +1,4 @@ -#Mon May 23 23:22:11 CEST 2022 -LastRunDate=220523 -FileSequentialNumber=13674 +#Thu Jun 02 11:33:14 CEST 2022 +LastRunDate=220602 +FileSequentialNumber=14154 DaySequentialNumber=9 diff --git a/devices/manip_x.properties b/devices/manip_x.properties new file mode 100644 index 0000000..8f3f487 --- /dev/null +++ b/devices/manip_x.properties @@ -0,0 +1,10 @@ +#Tue Jun 14 16:22:43 CEST 2022 +offset=0.0 +maxValue=4000.0 +rotation=false +precision=1 +scale=1.0 +resolution=NaN +minValue=-4000.0 +unit=um +sign_bit=0 diff --git a/devices/manip_y.properties b/devices/manip_y.properties new file mode 100644 index 0000000..5ae4b63 --- /dev/null +++ b/devices/manip_y.properties @@ -0,0 +1,10 @@ +#Tue Jun 14 16:27:30 CEST 2022 +offset=0.0 +maxValue=4000.0 +rotation=false +precision=1 +scale=1.0 +resolution=NaN +minValue=-4000.0 +unit=um +sign_bit=0 diff --git a/plugins/XPEEM_Settings.form b/plugins/XPEEM_Settings.form index 30247a8..67b52cf 100644 --- a/plugins/XPEEM_Settings.form +++ b/plugins/XPEEM_Settings.form @@ -19,10 +19,10 @@ - - - - + + + + diff --git a/plugins/XPEEM_Settings.java b/plugins/XPEEM_Settings.java index 84ae9f7..c172733 100644 --- a/plugins/XPEEM_Settings.java +++ b/plugins/XPEEM_Settings.java @@ -1,6 +1,9 @@ import ch.psi.pshell.ui.Panel; import ch.psi.utils.State; +import ch.psi.utils.swing.SwingUtils; +import java.awt.Component; +import javax.swing.JButton; /** * @@ -19,7 +22,9 @@ public class XPEEM_Settings extends Panel { @Override public void onStateChange(State state, State former) { - + for (Component c : SwingUtils.getComponentsByType(this, JButton.class)){ + c.setEnabled(state==State.Ready); + } } @Override @@ -95,6 +100,9 @@ public class XPEEM_Settings extends Panel { .addComponent(ButtonDefaultXrays)) .addContainerGap(322, Short.MAX_VALUE)) ); + + layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {ButtonDefaultOptics10kV, ButtonDefaultOptics15kV, ButtonDefaultXrays, ButtonNeutralizePosition}); + layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() diff --git a/script/May2022_Holder1_ASSBs_low.py b/script/May2022_Holder1_ASSBs_low.py new file mode 100644 index 0000000..a572240 --- /dev/null +++ b/script/May2022_Holder1_ASSBs_low.py @@ -0,0 +1,478 @@ + +# Set FE slits to 0.5x0.5mm +# Set Exit slit to 50mm +# Check the Keithleys + + +###Sample BL038 +#set_exec_pars(path="/sls/X11MA/data/X11MA/Data1/XAS/2022/2022_05/BL038/") +#open_vg13() +# +#TRX.write(-5.08) +#TRZ.write(24.7) +# +# +#time.sleep(1) + +##P, S and Cl +#nr_loops=2 +#for i in range(nr_loops): +# caput('X11MA-KEI10:RANGE', 6) +# caput('X11MA-KEI11:RANGE', 6) +# caput('X11MA-KEI12:RANGE', 10) +# caput('X11MA-KEI13:RANGE', 9) +# otf2(start=119, end=220, time=10, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL038_P-S-Cl-low') +#time.sleep(30) + +##C-low +#nr_loops=1 +#for i in range(nr_loops): +# caput('X11MA-KEI10:RANGE', 6) +# caput('X11MA-KEI11:RANGE', 6) +# caput('X11MA-KEI12:RANGE', 9) +# caput('X11MA-KEI13:RANGE', 8) +# otf2(start=275, end=295, time=1, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL038_C-low') + + +####Sample BL039 +#set_exec_pars(path="/sls/X11MA/data/X11MA/Data1/XAS/2022/2022_05/BL039/") +#open_vg13() +# +#TRX.write(-1.1) +#TRZ.write(23.66) +# + +#time.sleep(1) +# +##P, S and Cl +#nr_loops=2 +#for i in range(nr_loops): +# caput('X11MA-KEI10:RANGE', 6) +# caput('X11MA-KEI11:RANGE', 6) +# caput('X11MA-KEI12:RANGE', 10) +# caput('X11MA-KEI13:RANGE', 9) +# otf2(start=119, end=220, time=10, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL039_P-S-Cl-low') +#time.sleep(30) + +##C-low +#nr_loops=1 +#for i in range(nr_loops): +# caput('X11MA-KEI10:RANGE', 6) +# caput('X11MA-KEI11:RANGE', 6) +# caput('X11MA-KEI12:RANGE', 9) +# caput('X11MA-KEI13:RANGE', 8) +# otf2(start=275, end=295, time=1, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL039_C-low') + + +####Sample BL040 +#set_exec_pars(path="/sls/X11MA/data/X11MA/data/XAS/2022/2022_05/BL040/") +#open_vg13() +# +#TRX.write(2.7) +#TRZ.write(22.16) +# +# +#time.sleep(1) +# +##P, S and Cl +#nr_loops=1 +#for i in range(nr_loops): +# caput('X11MA-KEI10:RANGE', 6) +# caput('X11MA-KEI11:RANGE', 6) +# caput('X11MA-KEI12:RANGE', 10) +# caput('X11MA-KEI13:RANGE', 9) +# otf2(start=119, end=220, time=10, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='003_BL040_P-S-Cl-low' ) +#time.sleep(30) +# +##C-low +#nr_loops=1 +#for i in range(nr_loops): +# caput('X11MA-KEI10:RANGE', 6) +# caput('X11MA-KEI11:RANGE', 6) +# caput('X11MA-KEI12:RANGE', 9) +# caput('X11MA-KEI13:RANGE', 8) +# otf2(start=275, end=295, time=1, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='003_BL040_C-low') + +###Sample BL041 +set_exec_pars(path="/sls/X11MA/data/X11MA/Data1/XAS/2022/2022_05/BL041/") +open_vg13() + +TRX.write(7.7) +TRZ.write(23.26) + + +time.sleep(1) + +#P, S and Cl +nr_loops=2 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 10) + caput('X11MA-KEI13:RANGE', 9) + otf2(start=119, end=220, time=10, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL041_P-S-Cl-low_1') + otf2(start=119, end=220, time=10, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL041_P-S-Cl-low_2') +time.sleep(30) + +##C-low +#nr_loops=1 +#for i in range(nr_loops): +# caput('X11MA-KEI10:RANGE', 6) +# caput('X11MA-KEI11:RANGE', 6) +# caput('X11MA-KEI12:RANGE', 9) +# caput('X11MA-KEI13:RANGE', 8) +# otf2(start=275, end=295, time=1, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL041_C-low') + +###Sample BL042 +set_exec_pars(path="/sls/X11MA/data/X11MA/Data1/XAS/2022/2022_05/BL042/") +open_vg13() + +TRX.write(10.99) +TRZ.write(25.07) + + +time.sleep(1) + +#P, S and Cl +nr_loops=2 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 10) + caput('X11MA-KEI13:RANGE', 9) + otf2(start=119, end=220, time=10, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL042_P-S-Cl-low') +time.sleep(30) + +#C-low +nr_loops=1 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 9) + caput('X11MA-KEI13:RANGE', 8) + otf2(start=275, end=295, time=1, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL042_C-low') + +###Sample BL043 +set_exec_pars(path="/sls/X11MA/data/X11MA/Data1/XAS/2022/2022_05/BL043/") +open_vg13() + +TRX.write(-4.988) +TRZ.write(29.575) + + +time.sleep(1) + +#P, S and Cl +nr_loops=2 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 10) + caput('X11MA-KEI13:RANGE', 9) + otf2(start=119, end=220, time=10, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL043_P-S-Cl-low') +time.sleep(30) + +#C-low +nr_loops=1 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 9) + caput('X11MA-KEI13:RANGE', 8) + otf2(start=275, end=295, time=1, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL043_C-low') + +###Sample BL045 +set_exec_pars(path="/sls/X11MA/data/X11MA/Data1/XAS/2022/2022_05/BL045/") +open_vg13() + +TRX.write(0.8) +TRZ.write(29.075) + + +time.sleep(1) + +#P, S and Cl +nr_loops=2 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 10) + caput('X11MA-KEI13:RANGE', 9) + otf2(start=119, end=220, time=10, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL045_P-S-Cl-low') +time.sleep(30) + +#C-low +nr_loops=1 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 9) + caput('X11MA-KEI13:RANGE', 8) + otf2(start=275, end=295, time=1, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL045_C-low') + +###Sample BL046 +set_exec_pars(path="/sls/X11MA/data/X11MA/Data1/XAS/2022/2022_05/BL046/") +open_vg13() + +TRX.write(5.10) +TRZ.write(28.58) + + +time.sleep(1) + +#P, S and Cl +nr_loops=2 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 10) + caput('X11MA-KEI13:RANGE', 9) + otf2(start=119, end=220, time=10, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL046_P-S-Cl-low') +time.sleep(30) + +#C-low +nr_loops=1 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 9) + caput('X11MA-KEI13:RANGE', 8) + otf2(start=275, end=295, time=1, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL046_C-low') + +###Sample BL047 +set_exec_pars(path="/sls/X11MA/data/X11MA/Data1/XAS/2022/2022_05/BL047/") +open_vg13() + +TRX.write(10.1) +TRZ.write(29.367) + + +time.sleep(1) + +#P, S and Cl +nr_loops=2 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 10) + caput('X11MA-KEI13:RANGE', 9) + otf2(start=119, end=220, time=10, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL047_P-S-Cl-low') +time.sleep(30) + +#C-low +nr_loops=1 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 9) + caput('X11MA-KEI13:RANGE', 8) + otf2(start=275, end=295, time=1, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL047_C-low') + +##Sample BL049 +set_exec_pars(path="/sls/X11MA/data/X11MA/Data1/XAS/2022/2022_05/BL049/") +open_vg13() + +TRX.write(-5.1) +TRZ.write(34.367) + + +time.sleep(1) + +#P, S and Cl +nr_loops=2 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 10) + caput('X11MA-KEI13:RANGE', 9) + otf2(start=119, end=220, time=10, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL049_P-S-Cl-low') +time.sleep(30) + +#C-low +nr_loops=1 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 9) + caput('X11MA-KEI13:RANGE', 8) + otf2(start=275, end=295, time=1, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL049_C-low') + + +##Sample BL050 +set_exec_pars(path="/sls/X11MA/data/X11MA/Data1/XAS/2022/2022_05/BL050/") +open_vg13() + +TRX.write(1.9) +TRZ.write(32.367) + + +time.sleep(1) + +#P, S and Cl +nr_loops=2 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 10) + caput('X11MA-KEI13:RANGE', 9) + otf2(start=119, end=220, time=10, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL050_P-S-Cl-low') +time.sleep(30) + +#C-low +nr_loops=1 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 9) + caput('X11MA-KEI13:RANGE', 8) + otf2(start=275, end=295, time=1, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL050_C-low') + +##Sample BL052 +set_exec_pars(path="/sls/X11MA/data/X11MA/Data1/XAS/2022/2022_05/BL052/") +open_vg13() + +TRX.write(8.3) +TRZ.write(35.367) + + +time.sleep(1) + +#P, S and Cl +nr_loops=2 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 10) + caput('X11MA-KEI13:RANGE', 9) + otf2(start=119, end=220, time=10, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL052_P-S-Cl-low') +time.sleep(30) + +#C-low +nr_loops=1 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 9) + caput('X11MA-KEI13:RANGE', 8) + otf2(start=275, end=295, time=1, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL052_C-low') + +##Sample BL054 +set_exec_pars(path="/sls/X11MA/data/X11MA/Data1/XAS/2022/2022_05/BL054/") +open_vg13() + +TRX.write(-6.1) +TRZ.write(38.967) + + +time.sleep(1) + +#P, S and Cl +nr_loops=2 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 10) + caput('X11MA-KEI13:RANGE', 9) + otf2(start=119, end=220, time=10, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL054_P-S-Cl-low') +time.sleep(30) + +#C-low +nr_loops=1 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 9) + caput('X11MA-KEI13:RANGE', 8) + otf2(start=275, end=295, time=1, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL054_C-low') + +##Sample BL055 +set_exec_pars(path="/sls/X11MA/data/X11MA/Data1/XAS/2022/2022_05/BL055/") +open_vg13() + +TRX.write(-2.0) +TRZ.write(38.967) + + +time.sleep(1) + +#P, S and Cl +nr_loops=2 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 10) + caput('X11MA-KEI13:RANGE', 9) + otf2(start=119, end=220, time=10, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL055_P-S-Cl-low') +time.sleep(30) + +#C-low +nr_loops=1 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 9) + caput('X11MA-KEI13:RANGE', 8) + otf2(start=275, end=295, time=1, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL055_C-low') + +##Sample BL056 +set_exec_pars(path="/sls/X11MA/data/X11MA/Data1/XAS/2022/2022_05/BL056/") +open_vg13() + +TRX.write(3.1) +TRZ.write(38.467) + + +time.sleep(1) + +#P, S and Cl +nr_loops=2 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 10) + caput('X11MA-KEI13:RANGE', 9) + otf2(start=119, end=220, time=10, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL056_P-S-Cl-low') +time.sleep(30) + +#C-low +nr_loops=1 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 9) + caput('X11MA-KEI13:RANGE', 8) + otf2(start=275, end=295, time=1, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL056_C-low') + +##Sample BL057 +set_exec_pars(path="/sls/X11MA/data/X11MA/Data1/XAS/2022/2022_05/BL057/") +open_vg13() + +TRX.write(7.3) +TRZ.write(40.40) + + +time.sleep(1) + +#P, S and Cl +nr_loops=2 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 10) + caput('X11MA-KEI13:RANGE', 9) + otf2(start=119, end=220, time=10, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL057_P-S-Cl-low') +time.sleep(30) + +#C-low +nr_loops=1 +for i in range(nr_loops): + caput('X11MA-KEI10:RANGE', 6) + caput('X11MA-KEI11:RANGE', 6) + caput('X11MA-KEI12:RANGE', 9) + caput('X11MA-KEI13:RANGE', 8) + otf2(start=275, end=295, time=1, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='BL057_C-low') + + +time.sleep(1) + +close_vg13() \ No newline at end of file diff --git a/script/devices/LEEM2000.py b/script/devices/LEEM2000.py index aa9ed8d..526947c 100644 --- a/script/devices/LEEM2000.py +++ b/script/devices/LEEM2000.py @@ -11,7 +11,7 @@ class LEEM2000(TcpDevice): self.debug = False self.retries = 1 self.timeout = 1000 - self.move_timeout = 30000 #30s + self.move_timeout = 300000 #5min self.homing_timeout = 300000 #5min def doInitialize(self): @@ -36,7 +36,9 @@ class LEEM2000(TcpDevice): if timeout is None: timeout = self.timeout trailer = chr(0) + #print "TX: ", tx, ret = self.sendReceive(tx+trailer, None,trailer, 0, timeout, retries) + #print " RX: ", ret return str(ret[0:-1]).strip() def get_value(self, name, timeout = None, retries = None): @@ -131,10 +133,10 @@ class LEEM2000(TcpDevice): ret.initialize() return ret - def get_motor(self, motor_id, name=None): + def get_manip_motor(self, motor_id, encoder_index, name=None): if name is None: name=str(motor_id) - ret = LEEM2000Motor(name, motor_id, self) + ret = LEEM2000ManipMotor(name, motor_id, encoder_index, self) ret.initialize() return ret @@ -145,6 +147,13 @@ class LEEM2000(TcpDevice): ret.initialize() return ret + + def get_manip_readback(self, timeout = None, retries = None): + ret = microscope.send_receive("gmv", timeout, retries) + tokens = ret.split(",") + return float(tokens[0]), float(tokens[1]) + + #motor_id = U, D, L or R def move_tilt(self, motor_id, dist_us, timeout = None, retries = None): if timeout is None: @@ -164,14 +173,16 @@ class LEEM2000(TcpDevice): raise Exception("Error homing tilt %s: %s" % (str(cmd), ret)) #motor_id = 11 (X) or 10(Y) - def move_motor_rel_async(self, motor_id, dist_us, timeout = None, retries = None): + def move_motor_rel(self, motor_id, dist_us, timeout = None, retries = None): + if timeout is None: + timeout = self.move_timeout cmd = "mmd " + str(motor_id) + " " + str(dist_us) ret = self.send_receive(cmd, timeout, retries) if ret != '0': raise Exception("Error relative moving motor %s to %s: %s" % (str(motor_id), dist_us, ret)) def stop_motor(self, motor_id, timeout = None, retries = None): - self.move_motor_rel_async( motor_id, 0.0, timeout = None, retries = None) + self.move_motor_rel( motor_id, 0.0, timeout = None, retries = None) def is_motor_moving(self, motor_id, timeout = None, retries = None): cmd = "mmd " + str(motor_id) + " 888888.0" @@ -222,19 +233,26 @@ class LEEM2000Positioner (PositionerBase): def doReadReadback(self): return self.microscope.get_value(self.var) -class LEEM2000Motor(RegisterBase): - def __init__(self,name, motor_id, microscope): - RegisterBase.__init__(self,name) +class LEEM2000ManipMotor(PositionerBase): + def __init__(self,name, motor_id, encoder_index, microscope): + PositionerBase.__init__(self,name, PositionerConfig()) self.motor_id = motor_id - self.microscope = microscope - self.pos = None + self.encoder_index = encoder_index + self.microscope = microscope + self.pos = None def doRead(self): + if self.pos is None: + self.pos = self.doReadReadback() return self.pos def doWrite(self, val): self.microscope.move_motor(self.motor_id, val) - self.pos = val + self.pos = None + + def doReadReadback(self): + pos_mm= self.microscope.get_manip_readback()[self.encoder_index] + return pos_mm*1000.0 class LEEM2000Tilt(RegisterBase): def __init__(self,name, motor_id_pos, motor_id_neg, microscope): @@ -258,17 +276,18 @@ class LEEM2000Tilt(RegisterBase): add_device (LEEM2000("microscope"), True) -add_device (microscope.get_motor(11,"manip_x"), True) -add_device (microscope.get_motor(10,"manip_y"), True) +add_device (microscope.get_manip_motor(11, 0, "manip_x"), True) +add_device (microscope.get_manip_motor(10, 1, "manip_y"), True) add_device (microscope.get_tilt('L','R', "tilt_h"), True) add_device (microscope.get_tilt('D','U', "tilt_v"), True) #add_device (microscope.get_positioner("MOBJ","objective"), True) #add_device (microscope.get_positioner("OSTIGA","obj_stig_a"), True) #add_device (microscope.get_positioner("OSTIGB","obj_stig_b"), True) -add_device (microscope.get_child("MOBJ","objective"), True) +add_device (microscope.get_child("MOBJ","objective"), True) add_device (microscope.get_child("OSTIGA","obj_stig_a"), True) add_device (microscope.get_child("OSTIGB","obj_stig_b"), True) add_device (microscope.get_child("MDRIVE","azimuth_rot"), True) +add_device (microscope.get_child("BOMBV","bv"), True) microscope.setPolling(5000) @@ -313,6 +332,8 @@ add_device(TiltMotor("tilt_horizontal", tilt_h), True) add_device(Fov("fov", microscope), True) tilt_vertical.polling=500 tilt_horizontal.polling=500 +manip_x.polling=500 +manip_y.polling=500 fov.polling=5000 diff --git a/script/local.py b/script/local.py index d7dbe82..104b53e 100644 --- a/script/local.py +++ b/script/local.py @@ -246,13 +246,14 @@ def otf(start, end, time, delay = 0.0, mode = None, offset = None, alpha = None, #folder = get_context().setup.expandPath("{year}_{month}/{date}"); run("templates/EnergyScan", {"E1":start, "E2":end, "TIME":time, "DELAY":float(delay), "MODE":mode, "OFFSET":(offset), "FOLDER":folder, "FILE":name, "ALPHA":float(alpha) if alpha is not None else None}) -def otf2(start, end, time, delay = 0.0, mode = None, offset = None, alpha = None, name = None, folder = 'TEST'): - """ - """ - #run("templates/EnergyScan_v2", {"E1":start, "E2":end, "TIME":time, "DELAY":float(delay), "MODE":mode, "OFFSET":(offset), "FOLDER":folder, "FILE":name, "TAG":name, "ALPHA":float(alpha) if alpha is not None else None}) - run("templates/EnergyScan_v3", {"E1":start, "E2":end, "TIME":time, "DELAY":float(delay), "MODE":mode, "OFFSET":(offset), "FOLDER":folder, "FILE":name, "TAG":name, "ALPHA":float(alpha) if alpha is not None else None}) - # EnergySCan_v3 was created by CP. Apr/22 - +def otf2(start, end, time, delay = 0.0, mode = None, offset = None, alpha = None, name = None, folder = 'TEST'): + """ + """ + #run("templates/EnergyScan_v2", {"E1":start, "E2":end, "TIME":time, "DELAY":float(delay), "MODE":mode, "OFFSET":(offset), "FOLDER":folder, "FILE":name, "TAG":name, "ALPHA":float(alpha) if alpha is not None else None}) + #run("templates/EnergyScan_v3", {"E1":start, "E2":end, "TIME":time, "DELAY":float(delay), "MODE":mode, "OFFSET":(offset), "FOLDER":folder, "FILE":name, "TAG":name, "ALPHA":float(alpha) if alpha is not None else None}) + #EnergySCan_v3 was created by CP. Apr/22 + run("templates/EnergyScan_v4", {"E1":start, "E2":end, "TIME":time, "DELAY":float(delay), "MODE":mode, "OFFSET":(offset), "FOLDER":folder, "FILE":name, "TAG":name, "ALPHA":float(alpha) if alpha is not None else None}) + def otf_img(start, end, time, delay = 0.0, exposure=0.2, roi=None, name = None, save_images=False): folder = get_context().setup.expandPath("{year}_{month}/{date}"); if is_string(roi): @@ -815,9 +816,9 @@ def xrays_default(): def neutralize_position(): manip_x.write(0) manip_y.write(0) - #microscope.move_tilt('U', val) - tilt_h.write(val) - tilt_v.write(val) + time.sleep(1) + microscope.home_tilt('H') + microscope.home_tilt('V') ################################################################################################### #Maths ################################################################################################### diff --git a/script/templates/EnergyScan_v4.py b/script/templates/EnergyScan_v4.py new file mode 100644 index 0000000..9e8095b --- /dev/null +++ b/script/templates/EnergyScan_v4.py @@ -0,0 +1,121 @@ +#Taken from v3 with additional CADC4 channel +# Luka Debenjak 24.5.2022 + +""" +E1 = 800 +E2 = 820 +TIME = 1 #min +DELAY = 0.1 #s +MODE = 'LINEAR' +OFFSET = 0.0 +FOLDER = 'XAS/2020/11/SL-IN/' +FILE = 'test' +ALPHA=0.0 +TAG=None +""" + +print "\nStart energy scan..." +#print E1,E2,TIME,DELAY,str(MODE) ,str(OFFSET) ,str(FOLDER) ,str(FILE) ,str(ALPHA) +if MODE == "LINEAR": + print E1,"eV ->",E2,"eV,",TIME,"min duration,",DELAY,"sec delay,",str(MODE),str(ALPHA),"deg" +else: + print E1,"eV ->",E2,"eV,",TIME,"min duration,",DELAY,"sec delay,",str(MODE) + +folder = os.path.expanduser("~/Data1/") + FOLDER + "/"; + +if TAG is not None: + TAG = ("%03d" % (get_exec_pars().index,)) + "_" + TAG +#set_exec_pars(name= FILE) + + +#Pre-actions +#if NO_BEAM_CHECK == False: +# print "Wait beam" +# wait_beam() + +if MODE is not None: + print "Set polarization" + pol_mode.write(MODE) + if MODE == 'LINEAR': + if ALPHA is not None: + pol_angle.write(ALPHA) + time.sleep(0.5) +wait_pol_done(1.0) # new script to wait for polarization. Wait_device does not work for this channel. CP. Apr/22 + +print "Set offset" +if OFFSET is not None: + pol_offset.write(OFFSET) +#wait_device(pol_done, "DONE") + +print "Set energy" +energy.write(float(E1)) +sleep(0.1) +wait_channel(ALL_DONE, 1, type = 'i') + +caput('E1', E1) +caput('E2', E2) +caput('TIME', TIME) +caput('FOLDER', FOLDER) +caput('FILE', FILE) +time.sleep(DELAY) +#caput('START', '1') start here? + + +#Pseudo-devices +class Time(Readable): + def __init__(self): + self.start = time.time() + def read(self): + return time.time()-self.start + +class NORMtey(Readable): + def read(self): + return float(CADC2.take())/float(CADC1.take()) + +class NORMdiode(Readable): + def read(self): + return float(CADC3.take())/float(CADC1.take()) + +class NORMdiode2(Readable): + def read(self): + return float(CADC4.take())/float(CADC1.take()) + +pol = pol_angle if (pol_mode.readback.read() == "LINEAR") else pol_mode #take pol angle or mode to save in the file. CP. Apr/22 + +scan_completed = False +try: + caput('START', '1') + #sensors = [Ecrbk, CADC1, CADC2, CADC3, NORMtey(), NORMdiode()] + sensors = [Ecrbk, CADC1, CADC2, CADC3, CADC4, field, pol, NORMtey(), NORMdiode(), NORMdiode2()] # add polarization and mag. field in file. CP. Apr/22 + + def monitoring_task(): + global scan_completed + time.sleep(1.0) + try: + plot_titles = [ "I0", "TEYraw", "TFYraw", "TFY2raw", "TEY", "TFY", "TFY2"] + for index, title in enumerate(plot_titles, start=0): get_plots()[index].title = title + except: + pass + wait_channel('START', 'STOP', type = 's') + scan_completed = True + get_exec_pars().currentScan.abort() + + ret = fork(monitoring_task) + + print "Scanning...", + try: + mscan(Ecrbk, sensors, -1, None, range="auto", domain_axis="Ecrbk", enabled_plots = ["NORMtey", "NORMdiode", "NORMdiode2", CADC1,CADC3, CADC2, CADC4], tag=TAG) + finally: + ret[0].cancel(True) + print "Finished Energy scan." + +except: + if not scan_completed: + print sys.exc_info() + print("Aborting...") + while caget('START') == 'START': + caput('START', '0') + time.sleep(0.1) + raise + +after_sample() #To call check_id_error() \ No newline at end of file diff --git a/script/test/test.py b/script/test/test.py index e2771e8..a66fb3d 100755 --- a/script/test/test.py +++ b/script/test/test.py @@ -1 +1 @@ -otf2(start=520, end=570, time=5, delay=10, mode='LINEAR', alpha=0.0, offset=-1.0, name='test') \ No newline at end of file +otf2(start=500, end=510, time=1, delay=10, mode='LINEAR', alpha = 0.0, offset=0.0, name='test') \ No newline at end of file