diff --git a/plugins/GunSolenoidAlignment.java b/plugins/GunSolenoidAlignment.java index 0c30b95..897e8a1 100644 --- a/plugins/GunSolenoidAlignment.java +++ b/plugins/GunSolenoidAlignment.java @@ -28,11 +28,14 @@ public class GunSolenoidAlignment extends Panel { public GunSolenoidAlignment() { initComponents(); } + boolean running; ScanListener scanListener = new ScanListener() { - public void onNewRecord(Scan scan, ScanRecord record) { - progressBar.setValue(getView().getStatusBar().getProgressBar().getValue()); - scanSeries.appendData((Double)record.getValues()[0], (Double)record.getValues()[1]); + public void onNewRecord(Scan scan, ScanRecord record) { + if (running){ + progressBar.setValue(getView().getStatusBar().getProgressBar().getValue()); + scanSeries.appendData((Double)record.getValues()[0], (Double)record.getValues()[1]); + } } }; @@ -49,6 +52,9 @@ public class GunSolenoidAlignment extends Panel { buttonAbort.setEnabled(state == State.Busy); buttonRun.setEnabled(state == State.Ready); + if (state !=State.Busy){ + running = false; + } } @Override @@ -328,6 +334,7 @@ public class GunSolenoidAlignment extends Panel { centroidPlot.addSeries(scanSeries); scanSeries.setLinesVisible(false); scanSeries.setPointSize(4); + running = true; HashMap args = new HashMap(); args.put("I1", spinnerI1.getValue()); @@ -344,6 +351,7 @@ public class GunSolenoidAlignment extends Panel { onEndScan((ScanResult)ret.get(0), (List)ret.get(1), (List)ret.get(2) ); }); } catch (Exception ex) { + running = false; System.out.println("Error " + ex.toString()); showException(ex); }