diff --git a/plugins/EnergyScan.java b/plugins/EnergyScan.java index d6b1ff0..288ef7f 100644 --- a/plugins/EnergyScan.java +++ b/plugins/EnergyScan.java @@ -2,6 +2,8 @@ * Copyright (c) 2014 Paul Scherrer Institute. All rights reserved. */ +import ch.psi.pshell.core.Controller; +import ch.psi.pshell.core.Controller.ControllerStateException; import ch.psi.pshell.dev.Device; import ch.psi.pshell.dev.DeviceListener; import ch.psi.pshell.epics.ChannelDoubleArray; @@ -299,6 +301,27 @@ public class EnergyScan extends Panel { } checkParameterControls(); } + + void run() throws ControllerStateException{ + HashMap args = new HashMap(); + Double e1 = (Double) spinnerE1.getValue(); + Double e2 = (Double) spinnerE2.getValue(); + args.put("E1", e1); + args.put("E2", e2); + args.put("TIME", (Double) spinnerTime.getValue()); + args.put("DELAY", (Double) spinnerDelay.getValue()); + args.put("MODE", comboMode.getSelectedItem().toString()); + args.put("OFFSET", (Double) spinnerOffset.getValue()); + + String file = expandPath(textFile.getText()); + args.put("FILE", file); + + String folder = expandPath(textFolder.getText()); + args.put("FOLDER", folder); + runAsync("EnergyScan", args); + plot.getAxis(Plot.AxisId.X).setRange(Math.min(e1, e2), Math.max(e1, e2)); + + } @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents @@ -719,24 +742,7 @@ public class EnergyScan extends Panel { private void buttonExecuteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExecuteActionPerformed try { - - HashMap args = new HashMap(); - Double e1 = (Double) spinnerE1.getValue(); - Double e2 = (Double) spinnerE2.getValue(); - args.put("E1", e1); - args.put("E2", e2); - args.put("TIME", (Double) spinnerTime.getValue()); - args.put("DELAY", (Double) spinnerDelay.getValue()); - args.put("MODE", comboMode.getSelectedItem().toString()); - args.put("OFFSET", (Double) spinnerOffset.getValue()); - - String file = expandPath(textFile.getText()); - args.put("FILE", file); - - String folder = expandPath(textFolder.getText()); - args.put("FOLDER", folder); - runAsync("EnergyScan", args); - plot.getAxis(Plot.AxisId.X).setRange(Math.min(e1, e2), Math.max(e1, e2)); + run(); } catch (Exception ex) { SwingUtils.showException(this, ex); }