From a9b0bd10cf632f52f5364da82acf81c1993c23da Mon Sep 17 00:00:00 2001 From: gac-x09la Date: Wed, 9 Mar 2022 10:59:42 +0100 Subject: [PATCH] Scienta test mode --- src/Scienta.java | 76 ++++++++++++++++++++++++++++--------------- src/ScientaPanel.java | 39 ++++++++++++++++++---- 2 files changed, 81 insertions(+), 34 deletions(-) diff --git a/src/Scienta.java b/src/Scienta.java index fce5faf..ba5514e 100644 --- a/src/Scienta.java +++ b/src/Scienta.java @@ -31,20 +31,22 @@ public class Scienta extends AreaDetector { final ControlledVariable lowEnergy, centerEnergy, highEnergy, stepSize, lowThetaY, centerThetaY, highThetaY, stepSizeThetaY, centerThetaX; final ControlledVariable excitationEnergy; final GenericArray data; - final ChannelInteger totalSteps, currentStep, exposuresComplete; - final ChannelString lensMode, acquisitionMode, passEnergy, estTime, detectorState; + final ChannelInteger totalSteps, currentStep, exposuresComplete, acquisitionMode; + final ChannelString lensMode, passEnergy, estTime, detectorState; final ChannelByteArray status; final ChannelInteger slices, slicesReadback, channels, channelsReadback; final Stats[] stats; final String channelCtrl; final Device[] monitoredChildren; + final boolean test; - public Scienta(final String name, final String channelPrefix) { - this(name, channelPrefix + ":cam1", channelPrefix + ":image1"); + public Scienta(final String name, final String channelPrefix, boolean test) { + this(name, channelPrefix + ":cam1", channelPrefix + ":image1", test); } - public Scienta(String name, String channelCtrl, String channelData) { + public Scienta(String name, String channelCtrl, String channelData, boolean test) { super(name, channelCtrl, channelData); + this.test=test; this.channelCtrl = channelCtrl; acquire = new ChannelInteger(name + " aquire", channelCtrl + ":Acquire", false); @@ -81,7 +83,7 @@ public class Scienta extends AreaDetector { passEnergy = new ChannelString(name + " pass energy", channelCtrl + ":PASS_ENERGY", false); lensMode = new ChannelString(name + " lens mode", channelCtrl + ":LENS_MODE", false); - acquisitionMode = new ChannelString(name + " lens mode", channelCtrl + ":ACQ_MODE", false); + acquisitionMode = new ChannelInteger(name + " acquisition mode", channelCtrl + ":ACQ_MODE", false); slices = new ChannelInteger(name + " slices", channelCtrl + ":SLICES", false); slicesReadback = new ChannelInteger(name + " slices rbv", channelCtrl + ":SLICES_RBV", false); @@ -141,7 +143,7 @@ public class Scienta extends AreaDetector { super.doSetSimulated(); setCache(passEnergy, String.valueOf(PASS_ENERGY_VALUES[0])); setCache(lensMode, LensMode.Transmission.toString()); - setCache(acquisitionMode, ch.psi.pshell.epics.Scienta.AcquisitionMode.Fixed.toString()); + setCache(acquisitionMode, 0); setSimulatedValue("ENERGY_MODE", EnergyMode.Binding.toString()); setSimulatedValue("DETECTOR_MODE", DetectorMode.ADC.toString()); @@ -206,12 +208,19 @@ public class Scienta extends AreaDetector { } public void setAcquisitionMode(AcquisitionMode mode) throws IOException, InterruptedException { - acquisitionMode.write(String.valueOf(mode).replaceAll("_", " ")); + //acquisitionMode.write(String.valueOf(mode).replaceAll("_", " ")); + acquisitionMode.write(Arr.getIndex(AcquisitionMode.values(), (mode==null) ? 0 : mode)); } public AcquisitionMode getAcquisitionMode() throws IOException, InterruptedException { - String val = acquisitionMode.getValue(); - return (AcquisitionMode) convertCtrlEnum(val, AcquisitionMode.class); + //String val = acquisitionMode.getValue(); + //return (AcquisitionMode) convertCtrlEnum(val, AcquisitionMode.class); + try{ + int val = acquisitionMode.getValue(); + return AcquisitionMode.values()[val]; + } catch (Exception ex){ + return null; + } } public enum EnergyMode { @@ -228,6 +237,19 @@ public class Scienta extends AreaDetector { } public enum LensMode { + A14L_01, + A14L_08, + A30L_01, + A30L_08, + DA14L_01, + DA14L_08, + DA30L_01, + DA30L_08, + Transmission, + Transmission_XPS + } + + public enum LensModeTest { A14_01, A14_08, A30_01, @@ -240,15 +262,19 @@ public class Scienta extends AreaDetector { DA7_08, Transmission, Transmission_XPS - + } + + public Class getLensModeClass(){ + return test ? LensModeTest.class : LensMode.class; } - public void setLensMode(LensMode mode) throws IOException, InterruptedException { + public void setLensMode(Object mode) throws IOException, InterruptedException { //writeCtrlEnum("LENS_MODE", String.valueOf(mode)); - lensMode.write(mode.equals(LensMode.Transmission_XPS) ? "Transmission XPS" : String.valueOf(mode)); + String m = mode.toString(); + lensMode.write(m.equals("Transmission_XPS") ? "Transmission XPS" : m); } - public LensMode getLensMode() throws IOException, InterruptedException { + public Object getLensMode() throws IOException, InterruptedException { //return (LensMode) readCtrlEnum("LENS_MODE", LensMode.class); String val = lensMode.getValue(); return convertCtrlEnum(val, LensMode.class); @@ -323,7 +349,7 @@ public class Scienta extends AreaDetector { public Writable getLensModeDev(){ return (Writable) (Object value) -> { - setLensMode(LensMode.valueOf(String.valueOf(value))); + setLensMode(String.valueOf(value)); }; } @@ -501,8 +527,8 @@ public class Scienta extends AreaDetector { ret.add(100.0); ret.add(200.0); } else { - ret.add(lowEnergy.getValue()); - ret.add(highEnergy.getValue()); + ret.add(lowEnergy.getReadback().getValue()); + ret.add(highEnergy.getReadback().getValue()); } } catch (Exception ex) { ret.add(Double.NaN); @@ -517,18 +543,14 @@ public class Scienta extends AreaDetector { if (isSimulated()){ ret.add(200.0); ret.add(400.0); - } else { - switch (getLensMode()) { - case DA30_01: - case DA30_08: - ret.add(lowThetaY.getValue()); - ret.add(highThetaY.getValue()); - break; - default: + } else { + String lens=getLensMode().toString(); + if (lens.startsWith("D")){ + ret.add(lowThetaY.getReadback().getValue()); + ret.add(highThetaY.getReadback().getValue()); + } else { ret.add(lowThetaX.getValue()); ret.add(highThetaX.getValue()); - break; - } } } catch (Exception ex) { diff --git a/src/ScientaPanel.java b/src/ScientaPanel.java index c414abc..88b3b04 100644 --- a/src/ScientaPanel.java +++ b/src/ScientaPanel.java @@ -77,6 +77,7 @@ public final class ScientaPanel extends DevicePanel { getDevice().getCurrentStep().removeListener(progressListener); } super.setDevice(device); + SwingUtils.setEnumCombo(comboLens,getDevice().getLensModeClass()); cameraPanel.setDevice(device); if (device == null) { stopTimer(); @@ -134,7 +135,7 @@ public final class ScientaPanel extends DevicePanel { public class DeviceData { - Scienta.LensMode lensMode; + Object lensMode; Scienta.ElementSet elementSet; Scienta.AcquisitionMode acquisitionMode; Scienta.EnergyMode energyMode; @@ -179,12 +180,36 @@ public final class ScientaPanel extends DevicePanel { DeviceData dd = new DeviceData(); try{ //read-once - dd.lensMode = getDevice().getLensMode(); - dd.elementSet = getDevice().getElementSet(); - dd.acquisitionMode = getDevice().getAcquisitionMode(); - dd.energyMode = getDevice().getEnergyMode(); - dd.detectorMode = getDevice().getDetectorMode(); - dd.pass = getDevice().getPassEnergy(); + try{ + dd.lensMode = getDevice().getLensMode(); + } catch (Exception ex){ + dd.lensMode = null; + } + try{ + dd.elementSet = getDevice().getElementSet(); + } catch (Exception ex){ + dd.elementSet = null; + } + try{ + dd.acquisitionMode = getDevice().getAcquisitionMode(); + } catch (Exception ex){ + dd.acquisitionMode = null; + } + try{ + dd.energyMode = getDevice().getEnergyMode(); + } catch (Exception ex){ + dd.energyMode = null; + } + try{ + dd.detectorMode = getDevice().getDetectorMode(); + } catch (Exception ex){ + dd.detectorMode = null; + } + try{ + dd.pass = getDevice().getPassEnergy(); + } catch (Exception ex){ + dd.pass = 0; + } dd.low = getDevice().getLowEnergy().getValue(); dd.center = getDevice().getCenterEnergy().getValue();