From c24f66a09c81a8847dda2ade89beff3ca551d63b Mon Sep 17 00:00:00 2001 From: gac-x03da Date: Tue, 15 Aug 2023 12:50:44 +0200 Subject: [PATCH] Closedown --- config/variables.properties | 6 +-- plugins/XPSSpectrum.form | 1 - plugins/XPSSpectrum.java | 74 ++++++++++++++++++++++++++----------- script/XPSSpectrum.py | 1 + 4 files changed, 56 insertions(+), 26 deletions(-) diff --git a/config/variables.properties b/config/variables.properties index f2d68b49..22c706bc 100644 --- a/config/variables.properties +++ b/config/variables.properties @@ -1,4 +1,4 @@ -#Tue Aug 15 12:04:34 CEST 2023 +#Tue Aug 15 12:19:19 CEST 2023 LastRunDate=230815 -FileSequentialNumber=18622 -DaySequentialNumber=12 +FileSequentialNumber=18630 +DaySequentialNumber=20 diff --git a/plugins/XPSSpectrum.form b/plugins/XPSSpectrum.form index 18832b35..21c384f7 100644 --- a/plugins/XPSSpectrum.form +++ b/plugins/XPSSpectrum.form @@ -337,7 +337,6 @@ - diff --git a/plugins/XPSSpectrum.java b/plugins/XPSSpectrum.java index 230c26cd..9be78bf3 100644 --- a/plugins/XPSSpectrum.java +++ b/plugins/XPSSpectrum.java @@ -6,7 +6,8 @@ import ch.psi.pshell.core.Context; import ch.psi.pshell.device.Device; import ch.psi.pshell.device.DeviceAdapter; import ch.psi.pshell.device.DeviceListener; -import ch.psi.pshell.epics.Scienta; +import ch.psi.pshell.device.Writable; +import ch.psi.pshell.epics.AreaDetector; import ch.psi.pshell.plot.LinePlotSeries; import ch.psi.pshell.plot.RangeSelectionPlot.RangeSelection; import ch.psi.pshell.ui.Panel; @@ -20,6 +21,7 @@ import ch.psi.pshell.swing.ValueSelection.ValueSelectionListener; import ch.psi.pshell.ui.ScriptProcessor; import java.awt.Component; import java.io.File; +import java.lang.reflect.Method; import java.nio.file.Files; import java.time.LocalTime; import java.util.ArrayList; @@ -27,6 +29,7 @@ import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.logging.Level; +import java.util.logging.Logger; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JFileChooser; @@ -44,7 +47,7 @@ public class XPSSpectrum extends ScriptProcessor { boolean detailedScan; boolean running; - Scienta scienta; + AreaDetector scienta; SwingUtils.TableChangeListener tableChangeListener; boolean showMiddle = false; @@ -102,15 +105,16 @@ public class XPSSpectrum extends ScriptProcessor { public void onValueChanged(ValueSelection origin, double value, boolean editing) { try{ if (editing){ - scienta = (Scienta) getDevice("Scienta"); - if (origin == valueLow){ - scienta.getLowEnergy().write(value); - } else if (origin == valueHigh){ - scienta.getHighEnergy().write(value); - } else if (origin == valueTime){ - scienta.getStepTime().write(value); - } else if (origin == valueSize){ - scienta.getStepSize().write(value); + if (scienta!=null){ + if (origin == valueLow){ + ((Writable)scienta.getChild(scienta.getName() + " low energy")).write(value); + } else if (origin == valueHigh){ + ((Writable)scienta.getChild(scienta.getName() + " high energy")).write(value); + } else if (origin == valueTime){ + ((Writable)scienta.getChild(scienta.getName() + " exposure time")).write(value); + } else if (origin == valueSize){ + ((Writable)scienta.getChild(scienta.getName() + " step size")).write(value); + } } } } catch (Exception ex){ @@ -164,10 +168,20 @@ public class XPSSpectrum extends ScriptProcessor { @Override public void onInitialize(int runCount) { - scienta = (Scienta) getDevice("Scienta"); - scienta.getTotalChannels().addListener(progressListener); - scienta.getCurrentChannel().addListener(progressListener); - dvpAcqTime.setDevice(scienta.getAcquisitionTime()); + scienta = (AreaDetector) getDevice("Scienta"); + + try { + if (scienta.getChild(scienta.getName() + " current step")!=null){ + scienta.getChild(scienta.getName() + " current step").addListener(progressListener); + scienta.getChild(scienta.getName() + " total steps").addListener(progressListener); + } else { + scienta.getChild(scienta.getName() + " current channel").addListener(progressListener); + scienta.getChild(scienta.getName() + " total points").addListener(progressListener); + } + dvpAcqTime.setDevice((Device)getScienta("getAcquisitionTime")); + } catch (Exception ex) { + Logger.getLogger(XPSSpectrum.class.getName()).log(Level.SEVERE, null, ex); + } startTimer(500, 100); manualInitPlotData(); } @@ -262,7 +276,11 @@ public class XPSSpectrum extends ScriptProcessor { @Override public void onValueChanged(Device device, Object o, Object o1) { if (running) { - getView().getStatusBar().setProgress(scienta.getProgress()); + try { + getView().getStatusBar().setProgress((Double)getScienta("getProgress")); + } catch (Exception ex) { + Logger.getLogger(XPSSpectrum.class.getName()).log(Level.WARNING, null, ex); + } } } }; @@ -359,8 +377,19 @@ public class XPSSpectrum extends ScriptProcessor { currentScanIndex = -1; super.execute(); running = true; - } + } + + Object getScienta(String method) throws Exception{ + Method m = scienta.getClass().getMethod(method, new Class[0]); + return m.invoke(scienta); + } + + void setScienta(String method, Object obj) throws Exception{ + Method m = scienta.getClass().getMethod(method, new Class[]{obj.getClass()}); + m.invoke(scienta, new Object[]{obj}); + } + @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { @@ -708,7 +737,9 @@ public class XPSSpectrum extends ScriptProcessor { private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed try { abort(); - scienta.stop(); + if (scienta!=null){ + scienta.stop(); + } } catch (Exception ex) { showException(ex); } @@ -813,11 +844,10 @@ public class XPSSpectrum extends ScriptProcessor { private void comboPassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboPassActionPerformed try { - scienta = (Scienta) getDevice("Scienta"); if (scienta!=null){ - int energy = Integer.valueOf(comboPass.getSelectedItem().toString()); - if (energy != scienta.getPassEnergy()){ - scienta.setPassEnergy(energy); + Integer energy = Integer.valueOf(comboPass.getSelectedItem().toString()); + if (!energy.equals(getScienta("getPassEnergy"))){ + setScienta("setPassEnergy", energy); } } } catch (Exception ex) { diff --git a/script/XPSSpectrum.py b/script/XPSSpectrum.py index 4155b742..19323261 100644 --- a/script/XPSSpectrum.py +++ b/script/XPSSpectrum.py @@ -15,6 +15,7 @@ cur_iteration = 0 if Scienta.acquisitionMode != Scienta.AcquisitionMode.Swept: Scienta.acquisitionMode = Scienta.AcquisitionMode.Swept ret=[] +SENSORS = ["Scienta.spectrum", "Scienta.dataMatrix"] adjusted_ranges = [] for cur_range in range(len(ranges)):