Closedown

This commit is contained in:
gac-x03da
2021-11-15 14:22:57 +01:00
parent 698ee8e844
commit 02df2cf54d
4 changed files with 38 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
package ch.psi.pshell.swing;
import ch.psi.pshell.swing.*;
import ch.psi.pshell.device.Device;
import ch.psi.pshell.device.DeviceAdapter;
@@ -118,6 +118,7 @@ public final class ScientaPanel extends DevicePanel {
getDevice().getSpectrum().addListener(spectrumListener);
//cameraPanel.startTimer(3000, 0);
startTimer(3000, 0);
getDevice().getSpectrum().updateAsync();
}
}
@@ -131,6 +132,7 @@ public final class ScientaPanel extends DevicePanel {
}
};
/*
DeviceListener spectrumListener = new DeviceAdapter() {
@Override
public void onValueChanged(final Device device, final Object value, final Object former) {
@@ -139,6 +141,7 @@ public final class ScientaPanel extends DevicePanel {
});
}
};
*/
@Override
protected void onHide() {
@@ -162,6 +165,7 @@ public final class ScientaPanel extends DevicePanel {
public class DeviceData {
double[] spectrum;
double[] spectrumX;
LensMode lensMode;
ElementSet elementSet;
AcquisitionMode acquisitionMode;
@@ -187,7 +191,8 @@ public final class ScientaPanel extends DevicePanel {
DeviceData dd = new DeviceData();
//read-once
dd.spectrum = getDevice().getSpectrum().getValue();
dd.spectrum = getDevice().getSpectrum().read();
dd.spectrumX = getDevice().getSpectrumX();
dd.lensMode = getDevice().getLensMode();
dd.elementSet = getDevice().getElementSet();
@@ -208,6 +213,7 @@ public final class ScientaPanel extends DevicePanel {
dd.current = getDevice().getCurrentChannel().getValue().intValue();
dd.total = getDevice().getTotalChannels().getValue().intValue();
dd.iterations = getDevice().getIterations();
return dd;
}
@@ -233,8 +239,6 @@ public final class ScientaPanel extends DevicePanel {
protected void onBackgroundUpdateFinished(Object data) {
DeviceData dd = (DeviceData) data;
updateSpectrum();
updateValueField(valueLow, dd.low);
updateValueField(valueCenter, dd.center);
updateValueField(valueHigh, dd.high);
@@ -253,6 +257,21 @@ public final class ScientaPanel extends DevicePanel {
updateComboField(comboEnergy, dd.energyMode);
updateComboField(comboElement, dd.elementSet);
updateComboField(comboPass, dd.pass);
try {
if ((dd.spectrum == null)||(dd.spectrumX==null)) {
throw new Exception("Invalid spectrum");
}
if (dd.spectrumX.length<dd.spectrum.length){
throw new Exception("Invalid spectrum x size: " + dd.spectrumX.length + " - y size: " + dd.spectrum.length);
}
spectrumSeries.setData(dd.spectrumX, dd.spectrum);
plot.updateSeries(spectrumSeries);
} catch (Exception ex) {
getLogger().log(Level.FINE, null, ex);
spectrumSeries.clear();
}
try {
progress.setValue((int) (getDevice().getProgress() * 1000));
@@ -261,10 +280,17 @@ public final class ScientaPanel extends DevicePanel {
}
}
/*
volatile boolean spectrumUpdateRequested;
void updateSpectrum() {
try {
spectrumUpdateRequested=false;
double[] ySpectrum=getDevice().getSpectrum().take();
double[] xSpectrum = getDevice().getSpectrumX();
if (xSpectrum != null) {
if ((xSpectrum != null)&&(ySpectrum!=null)) {
if (xSpectrum.length<ySpectrum.length){
throw new Exception("Invalid spectrum x size: " + xSpectrum.length + " - y size: " + ySpectrum.length);
}
spectrumSeries.setData(xSpectrum, getDevice().getSpectrum().take());
plot.updateSeries(spectrumSeries);
return;
@@ -274,6 +300,7 @@ public final class ScientaPanel extends DevicePanel {
}
spectrumSeries.clear();
}
*/
/**
* This method is called from within the constructor to initialize the form. WARNING: Do NOT