Startup
This commit is contained in:
@@ -26,20 +26,24 @@ import java.util.logging.Logger;
|
||||
public class GunSolenoidAlignment extends Panel {
|
||||
|
||||
public GunSolenoidAlignment() {
|
||||
initComponents();
|
||||
initComponents();
|
||||
}
|
||||
boolean running;
|
||||
|
||||
ScanListener scanListener = new ScanListener() {
|
||||
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]);
|
||||
public void onNewRecord(Scan scan, ScanRecord record) {
|
||||
try {
|
||||
if (running) {
|
||||
scanSeries.appendData((Double) record.getValues()[0], (Double) record.getValues()[1]);
|
||||
progressBar.setValue((int) (1000.0 * record.getIndex() / scan.getNumberOfRecords()));
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
getLogger().log(Level.WARNING, null, ex);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
//Overridable callbacks
|
||||
|
||||
//Overridable callbacks
|
||||
@Override
|
||||
public void onInitialize(int runCount) {
|
||||
progressBar.setValue(0);
|
||||
@@ -49,40 +53,38 @@ public class GunSolenoidAlignment extends Panel {
|
||||
|
||||
@Override
|
||||
public void onStateChange(State state, State former) {
|
||||
|
||||
|
||||
buttonAbort.setEnabled(state == State.Busy);
|
||||
buttonRun.setEnabled(state == State.Ready);
|
||||
if (state !=State.Busy){
|
||||
if (state != State.Busy) {
|
||||
running = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecutedFile(String fileName, Object result) {
|
||||
public void onExecutedFile(String fileName, Object result) {
|
||||
}
|
||||
|
||||
|
||||
//Callback to perform update - in event thread
|
||||
@Override
|
||||
protected void doUpdate() {
|
||||
}
|
||||
|
||||
LinePlotSeries scanSeries;
|
||||
|
||||
int index=1;
|
||||
void onEndScan(ScanResult sr, List hx, List hy){
|
||||
|
||||
int index = 1;
|
||||
|
||||
void onEndScan(ScanResult sr, List hx, List hy) {
|
||||
progressBar.setValue(1000);
|
||||
//double[] x =(double[]) Convert.toDouble(sr.getReadable(0));
|
||||
//double[] y =(double[]) Convert.toDouble(sr.getReadable(1));
|
||||
double[] x =(double[]) Convert.toDouble(hx);
|
||||
double[] y =(double[]) Convert.toDouble(hy);
|
||||
LinePlotSeries hull = new LinePlotSeries(scanSeries.getName() + "H", scanSeries.getColor());
|
||||
centroidPlot.addSeries(hull);
|
||||
hull.setData((double[])Convert.toDouble(x), (double[])Convert.toDouble(y));
|
||||
System.out.println("OK!");
|
||||
|
||||
double[] x = (double[]) Convert.toDouble(hx);
|
||||
double[] y = (double[]) Convert.toDouble(hy);
|
||||
LinePlotSeries hull = new LinePlotSeries(scanSeries.getName() + "H", scanSeries.getColor());
|
||||
centroidPlot.addSeries(hull);
|
||||
hull.setData((double[]) Convert.toDouble(x), (double[]) Convert.toDouble(y));
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
@@ -332,7 +334,7 @@ public class GunSolenoidAlignment extends Panel {
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
//((Plugin)this)
|
||||
|
||||
|
||||
private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed
|
||||
try {
|
||||
abort();
|
||||
@@ -344,7 +346,7 @@ public class GunSolenoidAlignment extends Panel {
|
||||
private void buttonRunActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRunActionPerformed
|
||||
try {
|
||||
progressBar.setValue(0);
|
||||
scanSeries = new LinePlotSeries(String.valueOf(index++));
|
||||
scanSeries = new LinePlotSeries(String.valueOf(index++));
|
||||
centroidPlot.addSeries(scanSeries);
|
||||
scanSeries.setLinesVisible(false);
|
||||
scanSeries.setPointSize(4);
|
||||
@@ -359,17 +361,16 @@ public class GunSolenoidAlignment extends Panel {
|
||||
args.put("number_images", spinnerNumImages.getValue());
|
||||
args.put("number_backgrounds", spinnerNumBackgrounds.getValue());
|
||||
args.put("use_background", checkBackground.isSelected());
|
||||
args.put("multiple_background", radioBackMultiple.isSelected());
|
||||
args.put("zero_solenoids", checkZeroSolenoids.isSelected());
|
||||
args.put("do_elog", checkElog.isSelected());
|
||||
|
||||
((Plugin)this).runAsync("Alignment/Gun_solenoid_alignment",args).thenAccept((Object t) -> {
|
||||
List ret = (List)t;
|
||||
onEndScan((ScanResult)ret.get(0), (List)ret.get(1), (List)ret.get(2) );
|
||||
args.put("multiple_background", radioBackMultiple.isSelected());
|
||||
args.put("zero_solenoids", checkZeroSolenoids.isSelected());
|
||||
args.put("do_elog", checkElog.isSelected());
|
||||
|
||||
((Plugin) this).runAsync("Alignment/Gun_solenoid_alignment", args).thenAccept((Object t) -> {
|
||||
List ret = (List) t;
|
||||
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);
|
||||
}
|
||||
}//GEN-LAST:event_buttonRunActionPerformed
|
||||
@@ -382,11 +383,11 @@ public class GunSolenoidAlignment extends Panel {
|
||||
|
||||
private void buttonClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonClearActionPerformed
|
||||
try {
|
||||
index=1;
|
||||
index = 1;
|
||||
centroidPlot.clear();
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}
|
||||
}//GEN-LAST:event_buttonClearActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
|
||||
Reference in New Issue
Block a user