|
|
|
|
@@ -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")
|
|
|
|
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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) {
|
|
|
|
|
|