diff --git a/plugins/XPSSpectrum.java b/plugins/XPSSpectrum.java index d6171b7a..f0a290a7 100644 --- a/plugins/XPSSpectrum.java +++ b/plugins/XPSSpectrum.java @@ -14,7 +14,6 @@ import ch.psi.utils.IO; import ch.psi.utils.Serializer; import ch.psi.utils.State; import ch.psi.utils.swing.SwingUtils; -import ch.psi.psaf.Task; import ch.psi.pshell.swing.ValueSelection; import java.awt.Component; import java.io.File; @@ -22,10 +21,9 @@ import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; -import javax.swing.JCheckBox; +import java.util.logging.Level; import javax.swing.JComboBox; import javax.swing.JFileChooser; -import javax.swing.JSpinner; import javax.swing.JToggleButton; import javax.swing.SwingUtilities; import javax.swing.event.TableModelEvent; @@ -92,8 +90,7 @@ public class XPSSpectrum extends Panel { if (!state.isProcessing()){ buttonSkip.setVisible(false); if (running){ - monitoringTask.stop(); - monitoringTask.stopScheduler(); + stopTimer(); running = false; getView().getStatusBar().setProgress(-1); } @@ -167,10 +164,10 @@ public class XPSSpectrum extends Panel { public final String CURRERNT_ITERATION_VAR = "cur_iteration"; int currentScanIndex ; RangeSelection[] scanRanges; - - Task monitoringTask = new Task() { - @Override - protected Object execute() throws Exception { + + @Override + protected void onTimer() { + try{ Object index = XPSSpectrum.this.eval(CURRERNT_RANGE_VAR, true); if ((index!=null) && (index instanceof Integer) && ((Integer)index >= 0)){ int scanIndex = (Integer)index; @@ -178,12 +175,12 @@ public class XPSSpectrum extends Panel { buttonSkip.setEnabled(true); } currentScanIndex = scanIndex; - + int current_iteration = (Integer) XPSSpectrum.this.eval(CURRERNT_ITERATION_VAR, true); int iterations = (Integer)scanRanges[currentScanIndex].getVars()[2]; - + buttonSkip.setVisible((iterations>1) && (current_iteration < (iterations-1))); - + if (detailedScan){ RangeSelection range = rangeSelectionPanel.getRangesOrdered()[scanIndex]; for (int row = 0; row< rangeSelectionPanel.getTable().getRowCount(); row++){ @@ -199,21 +196,20 @@ public class XPSSpectrum extends Panel { } else { rangeSelectionPanel.getTable().clearSelection(); } - - return true; + } catch (Exception ex){ + getLogger().log(Level.FINE, null, ex); } - }; + } void start() throws Controller.ControllerStateException{ HashMap args = new HashMap<>(); args.put("ranges", scanRanges); args.put("pass_energy", Integer.valueOf(comboPass.getSelectedItem().toString())); args.put("save_scienta_image", checkSaveImage.isSelected()); - args.put("ENDSCAN", checkEndScan.isSelected()); - + args.put("ENDSCAN", checkEndScan.isSelected()); currentScanIndex = -1; runAsync("XPSSpectrum", args); - monitoringTask.schedule(100, 500); + startTimer(500); running = true; } diff --git a/script/XPSSpectrum.py b/script/XPSSpectrum.py index 425f3210..ed656f6f 100644 --- a/script/XPSSpectrum.py +++ b/script/XPSSpectrum.py @@ -60,11 +60,11 @@ try: for cur_iteration in range(vars[2]): plots[cur_range+1].setTitle(str(ranges[cur_range]) + " - iteration " + str(cur_iteration+1)) while True: - wait_beam() + #wait_beam() trig_scienta() spectrum_array = Scienta.spectrum.read() spectrum_array[0]=10 - if beam_ok: + if True:#beam_ok: break if ydata is None: ydata = spectrum_array