commit c1c747c22f2e74e904b066a5dbfd1ea8871e2752 Author: gac-x09la Date: Fri Aug 27 14:25:04 2021 +0200 Initial commit diff --git a/build.xml b/build.xml new file mode 100644 index 0000000..1a2e1e9 --- /dev/null +++ b/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project Scienta. + + + diff --git a/nbproject/build-impl.xml b/nbproject/build-impl.xml new file mode 100644 index 0000000..50077d0 --- /dev/null +++ b/nbproject/build-impl.xml @@ -0,0 +1,1771 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/nbproject/genfiles.properties b/nbproject/genfiles.properties new file mode 100644 index 0000000..887e25f --- /dev/null +++ b/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=dffc7ef3 +build.xml.script.CRC32=934e20b5 +build.xml.stylesheet.CRC32=f85dc8f2@1.97.0.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=dffc7ef3 +nbproject/build-impl.xml.script.CRC32=ac73cc8d +nbproject/build-impl.xml.stylesheet.CRC32=d549e5cc@1.97.0.48 diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..e97e658 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,99 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=Scienta +application.vendor=gac-x09la +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.modulepath=\ + ${run.modulepath} +debug.test.classpath=\ + ${run.test.classpath} +debug.test.modulepath=\ + ${run.test.modulepath} +# Files in build.classes.dir which should be excluded from distribution jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +#dist.jar=${dist.dir}/Scienta.jar +dist.jar=../home/extensions/Scienta.jar +dist.javadoc.dir=${dist.dir}/javadoc +dist.jlink.dir=${dist.dir}/jlink +dist.jlink.output=${dist.jlink.dir}/Scienta +endorsed.classpath= +excludes= +file.reference.default=/opt/gfa/pshell/default +includes=** +jar.compress=false +javac.classpath=\ + ${file.reference.default} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.modulepath= +javac.processormodulepath= +javac.processorpath=\ + ${javac.classpath} +javac.source=11 +javac.target=11 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.modulepath=\ + ${javac.modulepath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.html5=false +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +# The jlink additional root modules to resolve +jlink.additionalmodules= +# The jlink additional command line parameters +jlink.additionalparam= +jlink.launcher=true +jlink.launcher.name=Scienta +main.class=ch.psi.pshell.ui.App +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=true +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs=--add-opens java.base/jdk.internal.loader=ALL-UNNAMED +run.modulepath=\ + ${javac.modulepath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +run.test.modulepath=\ + ${javac.test.modulepath} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..858c729 --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + Scienta + + + + + + + + + diff --git a/src/Scienta.java b/src/Scienta.java new file mode 100644 index 0000000..b849699 --- /dev/null +++ b/src/Scienta.java @@ -0,0 +1,411 @@ + +import ch.psi.jcae.ChannelException; +import ch.psi.pshell.device.AccessType; +import ch.psi.pshell.device.ArrayCalibration; +import ch.psi.pshell.device.CameraImageDescriptor; +import ch.psi.pshell.device.MatrixCalibration; +import ch.psi.pshell.device.Device; +import ch.psi.pshell.device.DeviceAdapter; +import ch.psi.pshell.device.DeviceListener; +import ch.psi.pshell.device.Readable.ReadableCalibratedArray; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.logging.Level; +import ch.psi.pshell.epics.*; +import ch.psi.utils.State; +import java.util.concurrent.ExecutionException; +import java.util.logging.Logger; + +/** + * Implementation of Scienta spectrometer analyser. + */ +public class Scienta extends AreaDetector { + final ChannelInteger acquire; + final ChannelInteger slices; + final ChannelDouble lowEnergy, centerEnergy, highEnergy, stepSize, energyWidth; + final GenericArray data; + final ChannelInteger totalSteps, currentStep; + final ChannelString lensMode, acquisitionMode, passEnergy; + final ChannelInteger numSlices; + final Stats[] stats; + final String channelCtrl; + + public Scienta(final String name, final String channelPrefix) { + this(name, channelPrefix + ":cam1", channelPrefix + ":image1"); + } + + public Scienta(String name, String channelCtrl, String channelData) { + super(name, channelCtrl, channelData); + this.channelCtrl = channelCtrl; + + acquire = new ChannelInteger(name + " aquire", channelCtrl + ":Acquire", false); + + slices = new ChannelInteger(name + " slices", channelCtrl + ":SLICES", false); + //frames = new ChannelInteger(name + " frames", channelCtrl + ":FRAMES", false); + + lowEnergy = new ChannelDouble(name + " low energy", channelCtrl + ":LOW_ENERGY", 3, false); + centerEnergy = new ChannelDouble(name + " center energy", channelCtrl + ":CENTRE_ENERGY", 3, false); + highEnergy = new ChannelDouble(name + " high energy", channelCtrl + ":HIGH_ENERGY", 3, false); + stepSize = new ChannelDouble(name + " step size", channelCtrl + ":STEP_SIZE", 3, false); + + energyWidth = new ChannelDouble(name + " energy width", channelCtrl + ":ENERGY_WIDTH_RBV", 3, false); + energyWidth.setAccessType(AccessType.Read); + 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); + numSlices = new ChannelInteger(name + " num slices", channelCtrl + ":SLICES_RBV", false); + + numSlices.setAccessType(AccessType.Read); + + data = new GenericArray(name + " data", channelData + ":ArrayData", SIZE_MAX, false); //If nullable on invalidd value, read blocks on Scienta. + data.setAutoResolveType(false); + + totalSteps = new ChannelInteger(name + " total steps", channelCtrl + ":STEPS_RBV", false); + totalSteps.setAccessType(AccessType.Read); + currentStep = new ChannelInteger(name + " current step", channelCtrl + ":STEPS_COUNTER_RBV", false); + currentStep.setAccessType(AccessType.Read); + + + + + addChildren(new Device[]{acquire, slices, + lowEnergy, centerEnergy, highEnergy, stepSize, energyWidth, + data, + totalSteps, currentStep, + passEnergy, lensMode, acquisitionMode, + numSlices + }); + + stats = new Stats[5]; + stats[0] = new Stats("CountsR1", 1); + stats[1] = new Stats("CountsR2", 2); + stats[2] = new Stats("CountsR3", 3); + stats[3] = new Stats("CountsR4", 4); + stats[4] = new Stats("Counts", 5); + addChildren(stats); + + } + + @Override + protected void doStart() throws IOException, InterruptedException { + + acquire.write(1); + } + + + @Override + protected void doUpdate() throws IOException, InterruptedException { + super.doUpdate(); + acquire.update(); + slices.update(); + lowEnergy.update(); + centerEnergy.update(); + highEnergy.update(); + energyWidth.update(); + stepSize.update(); + totalSteps.update(); + currentStep.update(); + passEnergy.update(); + lensMode.update(); + acquisitionMode.update(); + //channelBegin.update(); + //channelEnd.update(); + ///sliceBegin.update(); + //sliceEnd.update(); + } + + @Override + protected void doSetMonitored(boolean value) { + super.doSetMonitored(value); + acquire.setMonitored(value); + slices.setMonitored(value); + lowEnergy.setMonitored(value); + centerEnergy.setMonitored(value); + highEnergy.setMonitored(value); + energyWidth.setMonitored(value); + stepSize.setMonitored(value); + totalSteps.setMonitored(value); + currentStep.setMonitored(value); + passEnergy.setMonitored(value); + lensMode.setMonitored(value); + acquisitionMode.setMonitored(value); + } + + @Override + protected CameraImageDescriptor doReadImageDescriptor() throws IOException, InterruptedException { + CameraImageDescriptor ret = super.doReadImageDescriptor(); + List channelRange = getChannelRange(); + List sliceRange = getSliceRange(); + + Double cb = channelRange.get(0); + Double ce = channelRange.get(1); + Double sb = sliceRange.get(0); + Double se = sliceRange.get(1); + + if ((cb == null) || (ce == null) || (sb == null) || (se == null) || (ret.width == 0) || (ret.height == 0)) { + ret.calibration = null; + } else { + double scaleX = (ce - cb) / Math.max(ret.width - 1, 1); + double offsetX = cb; + double scaleY = (se - sb) / Math.max(ret.height - 1, 1); + double offsetY = sb; + + ret.calibration = new MatrixCalibration(scaleX, scaleY, offsetX, offsetY); + } + return ret; + } + + //Modes + public enum AcquisitionMode { + Fixed, + Swept_Energy, + Swept_ThetaY, + Swept_Energy_ThetaY + } + + public void setAcquisitionMode(AcquisitionMode mode) throws IOException, InterruptedException { + acquisitionMode.write(String.valueOf(mode).replaceAll("_", " ")); + } + + public AcquisitionMode getAcquisitionMode() throws IOException, InterruptedException { + String val = acquisitionMode.getValue(); + return (AcquisitionMode) convertCtrlEnum(val, AcquisitionMode.class); + } + + public enum EnergyMode { + + Binding, + Kinetic + } + + public void setEnergyMode(EnergyMode mode) throws IOException, InterruptedException { + writeCtrlEnum("ENERGY_MODE", String.valueOf(mode)); + } + + public EnergyMode getEnergyMode() throws IOException, InterruptedException { + return (EnergyMode) readCtrlEnum("ENERGY_MODE", EnergyMode.class); + } + + public enum LensMode { + A14_01, + A14_08, + A30_01, + A30_08, + A7_08, + DA14_01, + DA14_08, + DA30_01, + DA30_08, + DA7_08, + Transmission, + Transmission_XPS + + } + + public void setLensMode(LensMode mode) throws IOException, InterruptedException { + //writeCtrlEnum("LENS_MODE", String.valueOf(mode)); + lensMode.write(mode.equals(LensMode.Transmission_XPS) ? "Transmission XPS" : String.valueOf(mode)); + } + + public LensMode getLensMode() throws IOException, InterruptedException { + //return (LensMode) readCtrlEnum("LENS_MODE", LensMode.class); + String val = lensMode.getValue(); + return convertCtrlEnum(val, LensMode.class); + } + + public enum DetectorMode { + Pulse, + ADC + } + + public void setDetectorMode(DetectorMode mode) throws IOException, InterruptedException { + writeCtrlEnum("DETECTOR_MODE", String.valueOf(mode)); + } + + public DetectorMode getDetectorMode() throws IOException, InterruptedException { + return (DetectorMode) readCtrlEnum("DETECTOR_MODE", DetectorMode.class); + } + + public enum ElementSet { + High_Pass_XPS, + Low_Pass_UPS + } + + public void setElementSet(ElementSet mode) throws IOException, InterruptedException { + throw new IOException("Read-only value"); + //writeCtrlEnum("ELEMENT_SET", String.valueOf(mode)); + } + + public ElementSet getElementSet() throws IOException, InterruptedException { + return readCtrl("ELEMENT_SET_RBV", String.class).equals("High Pass (XPS)") ? ElementSet.High_Pass_XPS : ElementSet.Low_Pass_UPS; + } + + public static final int[] PASS_ENERGY_VALUES = new int[]{1, 2, 5, 10, 20}; + + public void setPassEnergy(int energy) throws IOException, InterruptedException { + //writeCtrl("PASS_ENERGY", String.valueOf(energy)); + passEnergy.write(String.valueOf(energy)); + + } + + public int getPassEnergy() throws IOException, InterruptedException { + //String ret = (String) readCtrl("PASS_ENERGY", String.class); + String ret = passEnergy.getValue(); + try { + return Integer.valueOf(ret); + } catch (Exception ex) { + throw new DeviceInvalidParameterException("Pass Energy", ret); + } + } + + public void zeroSupplies() throws IOException, InterruptedException { + writeCtrl("ZERO_SUPPLIES", 1); + } + + //Progress + //Disconnected operations + public double getProgress() { + Double cur = currentStep.take().doubleValue(); + Double total = totalSteps.take().doubleValue(); + if ((cur == null) || (total == null) || (total == 0)) { + return 0.0; + } + return cur / total; + } + + + //Direct register access + public ChannelInteger getAcquire() { + return acquire; + } + + public ChannelInteger getSlices() { + return slices; + } + + public ChannelDouble getLowEnergy() { + return lowEnergy; + } + + public ChannelDouble getCenterEnergy() { + return centerEnergy; + } + + public ChannelDouble getHighEnergy() { + return highEnergy; + } + + public ChannelDouble getStepSize() { + return stepSize; + } + + public ChannelDouble getEnergyWidth() { + return energyWidth; + } + + public List getChannelRange() throws IOException, InterruptedException { + ArrayList ret = new ArrayList<>(); + switch (getAcquisitionMode()) { + case Fixed: + double eCenter = centerEnergy.getValue(); + int ePass = getPassEnergy(); + double xe = 0.04464; + double xn = 0.04464; + ret.add(eCenter - xe * ePass); + ret.add(eCenter + xn * ePass); + break; + default: + ret.add(lowEnergy.getValue()); + ret.add(highEnergy.getValue()); + break; + + } + return ret; + } + + public List getSliceRange() throws IOException, InterruptedException { + ArrayList ret = new ArrayList<>(); + //ret.add(sliceBegin.getValue()); + //ret.add(sliceEnd.getValue()); + try { + switch (getLensMode()) { + //TODO: + /* + case Angular45: + ret.add(-28.148); + ret.add(27.649); + break; + case Angular60: + ret.add(-34.736); + ret.add(34.119); + break; + */ + case Transmission: + default: + ret.add(-2.332); + ret.add(2.291); + break; + + } + } catch (Exception ex) { + ret.add(Double.NaN); + ret.add(Double.NaN); + } + return ret; + } + + public ChannelInteger getNumSlices() { + return numSlices; + } + + public ChannelInteger getTotalSteps() { + return totalSteps; + } + + public ChannelInteger getCurrentStep() { + return currentStep; + } + + public Stats[] getStats() { + return stats; + } + + public class Stats extends ChannelDouble { + + final int index; + final ChannelInteger uid; + + Stats(String name, int index) { + super(name, channelCtrl.split(":")[0] + ":Stats" + index + ":Total_RBV", 3, false); + this.index = index; + uid = new ChannelInteger(name + " uid", channelCtrl.split(":")[0] + ":Stats" + index + ":UniqueId_RBV", false); + //setParent(Scienta.this); + addChild(uid); + } + + @Override + public boolean isReady() throws IOException, InterruptedException { + Integer imageCounter = getImageCounter().getValue(); + if (imageCounter == null) { + return false; + } + Integer id = uid.take(); + if ((id == null) || (!imageCounter.equals(id))) { + uid.update(); + } + return imageCounter.equals(uid.take()); + } + + @Override + public Double read() throws IOException, InterruptedException { + assertInitialized(); + waitReady(10000); + return super.read(); + } + + public int getUID() throws IOException, InterruptedException { + return uid.getValue(); + } + } +} diff --git a/src/ScientaPanel.form b/src/ScientaPanel.form new file mode 100644 index 0000000..801d98b --- /dev/null +++ b/src/ScientaPanel.form @@ -0,0 +1,680 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/src/ScientaPanel.java b/src/ScientaPanel.java new file mode 100644 index 0000000..fab048b --- /dev/null +++ b/src/ScientaPanel.java @@ -0,0 +1,839 @@ +import ch.psi.pshell.device.Device; +import ch.psi.pshell.device.DeviceAdapter; +import ch.psi.pshell.device.DeviceListener; + + +import ch.psi.pshell.plot.LinePlotSeries; +import ch.psi.pshell.plot.Plot; +import ch.psi.utils.State; +import ch.psi.utils.swing.SwingUtils; +import java.awt.Component; +import java.io.IOException; +import java.util.logging.Level; +import javax.swing.DefaultComboBoxModel; +import javax.swing.JComboBox; +import javax.swing.SwingUtilities; + +import ch.psi.pshell.swing.*; +/** + * + */ +public final class ScientaPanel extends DevicePanel { + + public ScientaPanel() { + initComponents(); + ValueSelection.ValueSelectionListener valueListener = (ValueSelection origin, double value, boolean editing) -> { + if (editing) { + try { + if (origin == valueLow) { + getDevice().getLowEnergy().writeAsync(value); + } else if (origin == valueCenter) { + getDevice().getCenterEnergy().writeAsync(value); + } else if (origin == valueHigh) { + getDevice().getHighEnergy().writeAsync(value); + } else if (origin == valueSize) { + getDevice().getStepSize().writeAsync(value); + } else if (origin == valueSlices) { + getDevice().getSlices().writeAsync((int) value); + } else if (origin == valueIterations) { + getDevice().setIterations((int) value); + }/*else if (origin == valueFrames) { + getDevice().getFrames().writeAsync((int) value); + }*/ + + } catch (Exception ex) { + showException(ex); + } + } + }; + + for (Component vs : SwingUtils.getComponentsByType(this, ValueSelection.class)) { + if (((ValueSelection) vs).isEnabled()) { + ((ValueSelection) vs).addListener(valueListener); + } + } + SwingUtils.setEnumCombo(comboLens, Scienta.LensMode.class); + SwingUtils.setEnumCombo(comboElement, Scienta.ElementSet.class); + SwingUtils.setEnumCombo(comboAcquisition, Scienta.AcquisitionMode.class); + SwingUtils.setEnumCombo(comboEnergy, Scienta.EnergyMode.class); + SwingUtils.setEnumCombo(comboDetector, Scienta.DetectorMode.class); + + DefaultComboBoxModel model = new DefaultComboBoxModel(); + for (Integer energy : Scienta.PASS_ENERGY_VALUES) { + model.addElement(energy); + } + comboPass.setModel(model); + } + + public boolean getShowCameraPanel() { + return cameraPanel.isVisible(); + } + + public void setShowCameraPanel(boolean value) { + cameraPanel.setVisible(value); + } + + @Override + public Scienta getDevice() { + return (Scienta) super.getDevice(); + } + + @Override + public void setDevice(Device device) { + if (getDevice() != null) { + getDevice().getCurrentStep().removeListener(progressListener); + } + super.setDevice(device); + cameraPanel.setDevice(device); + if (device == null) { + stopTimer(); + } else { + getDevice().getCurrentStep().addListener(progressListener); + //cameraPanel.startTimer(3000, 0); + startTimer(3000, 0); + } + } + + DeviceListener progressListener = new DeviceAdapter() { + @Override + public void onValueChanged(final Device device, final Object value, final Object former) { + SwingUtilities.invokeLater(() -> { + valueCurrent.setValue((Double) value); + progress.setValue((int) (getDevice().getProgress() * 1000)); + }); + } + }; + + + @Override + protected void onHide() { + super.onHide(); + } + + @Override + protected void onTimer() { + startBackgroundUpdate(); + } + + //Callbacks + @Override + protected void onDeviceStateChanged(State state, State former) { + } + + @Override + protected void onDeviceValueChanged(Object state, Object former) { + } + + public class DeviceData { + + Scienta.LensMode lensMode; + Scienta.ElementSet elementSet; + Scienta.AcquisitionMode acquisitionMode; + Scienta.EnergyMode energyMode; + Scienta.DetectorMode detectorMode; + double low; + double center; + double high; + double width; + //int frames; + //double time; + double size; + int slices; + int pass; + int iterations; + + int current; + int total; + } + + @Override + protected DeviceData doBackgroundUpdate() throws IOException, InterruptedException { + DeviceData dd = new DeviceData(); + //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(); + + dd.low = getDevice().getLowEnergy().getValue(); + dd.center = getDevice().getCenterEnergy().getValue(); + dd.high = getDevice().getHighEnergy().getValue(); + dd.width = getDevice().getEnergyWidth().getValue(); + //dd.frames = getDevice().getFrames().getValue(); + dd.size = getDevice().getStepSize().getValue(); + dd.slices = getDevice().getSlices().getValue(); + + dd.current = getDevice().getCurrentStep().getValue().intValue(); + dd.total = getDevice().getTotalSteps().getValue().intValue(); + dd.iterations = getDevice().getIterations(); + return dd; + } + + void updateValueField(ValueSelection field, double value) { + try { + field.setValue(value); + } catch (Exception ex) { + getLogger().log(Level.FINE, null, ex); + } + } + + void updateComboField(JComboBox field, Object value) { + try { + if (field.getSelectedItem() != value) { + field.setSelectedItem(value); + } + } catch (Exception ex) { + getLogger().log(Level.FINE, null, ex); + } + } + + @Override + protected void onBackgroundUpdateFinished(Object data) { + DeviceData dd = (DeviceData) data; + updateValueField(valueLow, dd.low); + updateValueField(valueCenter, dd.center); + updateValueField(valueHigh, dd.high); + updateValueField(valueWidth, dd.width); + //updateValue(valueFrames, dd.frames); + updateValueField(valueSize, dd.size); + updateValueField(valueSlices, dd.slices); + updateValueField(valueIterations, dd.iterations); + updateValueField(valueTotal, dd.total); + updateValueField(valueCurrent, dd.current); + + updateComboField(comboLens, dd.lensMode); + updateComboField(comboAcquisition, dd.acquisitionMode); + updateComboField(comboDetector, dd.detectorMode); + updateComboField(comboEnergy, dd.energyMode); + updateComboField(comboElement, dd.elementSet); + updateComboField(comboPass, dd.pass); + + try { + progress.setValue((int) (getDevice().getProgress() * 1000)); + } catch (Exception ex) { + getLogger().log(Level.FINE, null, ex); + } + } + + + /** + * This method is called from within the constructor to initialize the form. WARNING: Do NOT + * modify this code. The content of this method is always regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + cameraPanel = new ch.psi.pshell.swing.CameraPanel(); + scientaPanel = new javax.swing.JPanel(); + jPanel5 = new javax.swing.JPanel(); + progress = new javax.swing.JProgressBar(); + jLabel6 = new javax.swing.JLabel(); + valueCurrent = new ch.psi.pshell.swing.ValueSelection(); + jLabel16 = new javax.swing.JLabel(); + valueTotal = new ch.psi.pshell.swing.ValueSelection(); + jPanel6 = new javax.swing.JPanel(); + jPanel1 = new javax.swing.JPanel(); + jLabel1 = new javax.swing.JLabel(); + comboLens = new javax.swing.JComboBox(); + jLabel2 = new javax.swing.JLabel(); + comboAcquisition = new javax.swing.JComboBox(); + jLabel3 = new javax.swing.JLabel(); + comboEnergy = new javax.swing.JComboBox(); + jLabel4 = new javax.swing.JLabel(); + comboDetector = new javax.swing.JComboBox(); + jLabel5 = new javax.swing.JLabel(); + comboElement = new javax.swing.JComboBox(); + jPanel4 = new javax.swing.JPanel(); + jLabel11 = new javax.swing.JLabel(); + comboPass = new javax.swing.JComboBox(); + jLabel12 = new javax.swing.JLabel(); + valueLow = new ch.psi.pshell.swing.ValueSelection(); + jLabel13 = new javax.swing.JLabel(); + valueCenter = new ch.psi.pshell.swing.ValueSelection(); + jLabel14 = new javax.swing.JLabel(); + valueHigh = new ch.psi.pshell.swing.ValueSelection(); + jLabel15 = new javax.swing.JLabel(); + valueWidth = new ch.psi.pshell.swing.ValueSelection(); + jPanel2 = new javax.swing.JPanel(); + jLabel8 = new javax.swing.JLabel(); + jLabel9 = new javax.swing.JLabel(); + valueSize = new ch.psi.pshell.swing.ValueSelection(); + jLabel10 = new javax.swing.JLabel(); + valueSlices = new ch.psi.pshell.swing.ValueSelection(); + jLabel17 = new javax.swing.JLabel(); + valueIterations = new ch.psi.pshell.swing.ValueSelection(); + buttonZeroSupplies = new javax.swing.JButton(); + jPanel3 = new javax.swing.JPanel(); + jPanel7 = new javax.swing.JPanel(); + + cameraPanel.setBorder(null); + + jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder("Progress")); + + progress.setMaximum(1000); + + jLabel6.setText("Current step:"); + + valueCurrent.setDecimals(0); + valueCurrent.setEnabled(false); + valueCurrent.setMaxValue(100000.0); + valueCurrent.setMinValue(0.0); + valueCurrent.setShowButtons(false); + + jLabel16.setText("Total:"); + + valueTotal.setDecimals(0); + valueTotal.setEnabled(false); + valueTotal.setMaxValue(100000.0); + valueTotal.setMinValue(0.0); + valueTotal.setShowButtons(false); + + javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5); + jPanel5.setLayout(jPanel5Layout); + jPanel5Layout.setHorizontalGroup( + jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel6) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(valueCurrent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jLabel16) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(valueTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(progress, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addContainerGap()) + ); + jPanel5Layout.setVerticalGroup( + jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel5Layout.createSequentialGroup() + .addGap(4, 4, 4) + .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel6) + .addComponent(valueCurrent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(valueTotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(progress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel16)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Modes")); + + jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel1.setText("Lens:"); + + comboLens.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + comboLens.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + comboLensActionPerformed(evt); + } + }); + + jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel2.setText("Acquisition:"); + + comboAcquisition.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + comboAcquisition.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + comboAcquisitionActionPerformed(evt); + } + }); + + jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel3.setText("Energy:"); + + comboEnergy.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + comboEnergy.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + comboEnergyActionPerformed(evt); + } + }); + + jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel4.setText("Detector:"); + + comboDetector.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + comboDetector.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + comboDetectorActionPerformed(evt); + } + }); + + jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel5.setText("Element:"); + + comboElement.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); + comboElement.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + comboElementActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); + jPanel1.setLayout(jPanel1Layout); + jPanel1Layout.setHorizontalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel5) + .addComponent(jLabel4) + .addComponent(jLabel3) + .addComponent(jLabel2) + .addComponent(jLabel1)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(comboLens, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(comboAcquisition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(comboElement, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(comboDetector, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(comboEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3, jLabel4, jLabel5}); + + jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {comboAcquisition, comboDetector, comboElement, comboEnergy, comboLens}); + + jPanel1Layout.setVerticalGroup( + jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel1Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(comboLens, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2) + .addComponent(comboAcquisition, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(comboEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel4) + .addComponent(comboDetector, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel5) + .addComponent(comboElement, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(17, Short.MAX_VALUE)) + ); + + jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Energy")); + + jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel11.setText("Pass:"); + + comboPass.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "2", "5", "10", "20", "50", "100", "200" })); + comboPass.setToolTipText(""); + comboPass.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + comboPassActionPerformed(evt); + } + }); + + jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel12.setText("Low:"); + + valueLow.setDecimals(2); + valueLow.setMaxValue(2000.0); + valueLow.setMinValue(0.0); + valueLow.setShowButtons(false); + + jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel13.setText("Center:"); + + valueCenter.setDecimals(2); + valueCenter.setMaxValue(2000.0); + valueCenter.setMinValue(0.0); + valueCenter.setShowButtons(false); + + jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel14.setText("High:"); + + valueHigh.setDecimals(2); + valueHigh.setMaxValue(2000.0); + valueHigh.setMinValue(0.0); + valueHigh.setShowButtons(false); + + jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel15.setText("Width:"); + + valueWidth.setDecimals(2); + valueWidth.setEnabled(false); + valueWidth.setMaxValue(2000.0); + valueWidth.setMinValue(0.0); + valueWidth.setShowButtons(false); + + javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4); + jPanel4.setLayout(jPanel4Layout); + jPanel4Layout.setHorizontalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel15) + .addComponent(jLabel14) + .addComponent(jLabel13) + .addComponent(jLabel12) + .addComponent(jLabel11)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(valueWidth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(valueHigh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(valueCenter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(comboPass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(valueLow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + jPanel4Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {comboPass, valueCenter, valueHigh, valueLow, valueWidth}); + + jPanel4Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel11, jLabel12, jLabel13, jLabel14, jLabel15}); + + jPanel4Layout.setVerticalGroup( + jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel4Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel11) + .addComponent(comboPass, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel12) + .addComponent(valueLow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel13) + .addComponent(valueCenter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel14) + .addComponent(valueHigh, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER) + .addComponent(jLabel15) + .addComponent(valueWidth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(37, Short.MAX_VALUE)) + ); + + jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Step")); + + jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel8.setText("Time:"); + + jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel9.setText("Size:"); + + valueSize.setDecimals(2); + valueSize.setMaxValue(1000.0); + valueSize.setMinValue(0.0); + valueSize.setShowButtons(false); + + jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel10.setText("Slices:"); + + valueSlices.setDecimals(0); + valueSlices.setMaxValue(10000.0); + valueSlices.setMinValue(0.0); + valueSlices.setShowButtons(false); + + jLabel17.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel17.setText("Iter:"); + + valueIterations.setDecimals(0); + valueIterations.setMaxValue(1000.0); + valueIterations.setMinValue(0.0); + valueIterations.setShowButtons(false); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel9) + .addComponent(jLabel8)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(valueSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addComponent(jLabel10) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(valueSlices, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addComponent(jLabel17) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(valueIterations, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))) + .addContainerGap()) + ); + + jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel10, jLabel17, jLabel8, jLabel9}); + + jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {valueIterations, valueSize, valueSlices}); + + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel10) + .addComponent(valueSlices, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jLabel8) + .addGap(10, 10, 10) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel9) + .addComponent(valueSize, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel17) + .addComponent(valueIterations, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap()) + ); + + buttonZeroSupplies.setText("Zero Supplies"); + buttonZeroSupplies.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonZeroSuppliesActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6); + jPanel6.setLayout(jPanel6Layout); + jPanel6Layout.setHorizontalGroup( + jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel6Layout.createSequentialGroup() + .addGap(0, 0, 0) + .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel6Layout.createSequentialGroup() + .addComponent(buttonZeroSupplies, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addContainerGap()))) + ); + jPanel6Layout.setVerticalGroup( + jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel6Layout.createSequentialGroup() + .addGap(0, 0, 0) + .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(jPanel6Layout.createSequentialGroup() + .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonZeroSupplies))) + .addGap(0, 0, 0)) + ); + + jPanel6Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jPanel1, jPanel4}); + + javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3); + jPanel3.setLayout(jPanel3Layout); + jPanel3Layout.setHorizontalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 100, Short.MAX_VALUE) + ); + jPanel3Layout.setVerticalGroup( + jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 100, Short.MAX_VALUE) + ); + + javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7); + jPanel7.setLayout(jPanel7Layout); + jPanel7Layout.setHorizontalGroup( + jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 0, Short.MAX_VALUE) + ); + jPanel7Layout.setVerticalGroup( + jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGap(0, 100, Short.MAX_VALUE) + ); + + javax.swing.GroupLayout scientaPanelLayout = new javax.swing.GroupLayout(scientaPanel); + scientaPanel.setLayout(scientaPanelLayout); + scientaPanelLayout.setHorizontalGroup( + scientaPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(scientaPanelLayout.createSequentialGroup() + .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + scientaPanelLayout.setVerticalGroup( + scientaPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(scientaPanelLayout.createSequentialGroup() + .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + ); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(cameraPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(scientaPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(cameraPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(scientaPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + ); + }// //GEN-END:initComponents + + private void comboLensActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboLensActionPerformed + try { + if (!isBackgroundUpdate()) { + Scienta.LensMode mode = (Scienta.LensMode) comboLens.getSelectedItem(); + if (mode != null) { + getDevice().setLensMode(mode); + } + } + } catch (Exception ex) { + showException(ex); + } + + }//GEN-LAST:event_comboLensActionPerformed + + private void comboAcquisitionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboAcquisitionActionPerformed + try { + if (!isBackgroundUpdate()) { + Scienta.AcquisitionMode mode = (Scienta.AcquisitionMode) comboAcquisition.getSelectedItem(); + if (mode != null) { + getDevice().setAcquisitionMode(mode); + } + } + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_comboAcquisitionActionPerformed + + private void comboEnergyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboEnergyActionPerformed + try { + if (!isBackgroundUpdate()) { + Scienta.EnergyMode mode = (Scienta.EnergyMode) comboEnergy.getSelectedItem(); + if (mode != null) { + getDevice().setEnergyMode(mode); + } + } + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_comboEnergyActionPerformed + + private void comboDetectorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboDetectorActionPerformed + try { + if (!isBackgroundUpdate()) { + Scienta.DetectorMode mode = (Scienta.DetectorMode) comboDetector.getSelectedItem(); + if (mode != null) { + getDevice().setDetectorMode(mode); + } + } + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_comboDetectorActionPerformed + + private void comboElementActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboElementActionPerformed + try { + if (!isBackgroundUpdate()) { + Scienta.ElementSet mode = (Scienta.ElementSet) comboElement.getSelectedItem(); + if (mode != null) { + getDevice().setElementSet(mode); + } + } + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_comboElementActionPerformed + + private void comboPassActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboPassActionPerformed + try { + if (!isBackgroundUpdate()) { + int val = (int) comboPass.getSelectedItem(); + getDevice().setPassEnergy(val); + } + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_comboPassActionPerformed + + private void buttonZeroSuppliesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonZeroSuppliesActionPerformed + try { + getDevice().zeroSupplies(); + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_buttonZeroSuppliesActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton buttonZeroSupplies; + private ch.psi.pshell.swing.CameraPanel cameraPanel; + private javax.swing.JComboBox comboAcquisition; + private javax.swing.JComboBox comboDetector; + private javax.swing.JComboBox comboElement; + private javax.swing.JComboBox comboEnergy; + private javax.swing.JComboBox comboLens; + private javax.swing.JComboBox comboPass; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel10; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel12; + private javax.swing.JLabel jLabel13; + private javax.swing.JLabel jLabel14; + private javax.swing.JLabel jLabel15; + private javax.swing.JLabel jLabel16; + private javax.swing.JLabel jLabel17; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel6; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel6; + private javax.swing.JPanel jPanel7; + private javax.swing.JProgressBar progress; + private javax.swing.JPanel scientaPanel; + private ch.psi.pshell.swing.ValueSelection valueCenter; + private ch.psi.pshell.swing.ValueSelection valueCurrent; + private ch.psi.pshell.swing.ValueSelection valueHigh; + private ch.psi.pshell.swing.ValueSelection valueIterations; + private ch.psi.pshell.swing.ValueSelection valueLow; + private ch.psi.pshell.swing.ValueSelection valueSize; + private ch.psi.pshell.swing.ValueSelection valueSlices; + private ch.psi.pshell.swing.ValueSelection valueTotal; + private ch.psi.pshell.swing.ValueSelection valueWidth; + // End of variables declaration//GEN-END:variables +}