Closedown
This commit is contained in:
@@ -3,6 +3,10 @@
|
||||
*/
|
||||
|
||||
import ch.psi.pshell.plot.LinePlotSeries;
|
||||
import ch.psi.pshell.plot.Plot;
|
||||
import ch.psi.pshell.scan.Scan;
|
||||
import ch.psi.pshell.scan.ScanListener;
|
||||
import ch.psi.pshell.scan.ScanRecord;
|
||||
import ch.psi.pshell.scan.ScanResult;
|
||||
import ch.psi.pshell.ui.Panel;
|
||||
import ch.psi.pshell.ui.Plugin;
|
||||
@@ -11,6 +15,7 @@ import ch.psi.utils.State;
|
||||
import java.awt.Color;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
@@ -21,13 +26,22 @@ import java.util.logging.Logger;
|
||||
public class GunSolenoidAlignment extends Panel {
|
||||
|
||||
public GunSolenoidAlignment() {
|
||||
initComponents();
|
||||
initComponents();
|
||||
}
|
||||
|
||||
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]);
|
||||
}
|
||||
};
|
||||
|
||||
//Overridable callbacks
|
||||
@Override
|
||||
public void onInitialize(int runCount) {
|
||||
|
||||
progressBar.setValue(0);
|
||||
getController().addScanListener(scanListener);
|
||||
centroidPlot.getAxis(Plot.AxisId.X).setLabel("Centroid Excursion");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -38,7 +52,7 @@ public class GunSolenoidAlignment extends Panel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecutedFile(String fileName, Object result) {
|
||||
public void onExecutedFile(String fileName, Object result) {
|
||||
}
|
||||
|
||||
|
||||
@@ -47,20 +61,19 @@ public class GunSolenoidAlignment extends Panel {
|
||||
protected void doUpdate() {
|
||||
}
|
||||
|
||||
LinePlotSeries scanSeries;
|
||||
|
||||
int index=1;
|
||||
void onEndScan(ScanResult sr){
|
||||
|
||||
ArrayList x = sr.getReadable(0);
|
||||
ArrayList y = sr.getReadable(1);
|
||||
|
||||
LinePlotSeries s = new LinePlotSeries(String.valueOf(index++));
|
||||
centroidPlot.addSeries(s);
|
||||
|
||||
|
||||
System.out.println("END!");
|
||||
s.setData((double[])Convert.toDouble(x), (double[])Convert.toDouble(y));
|
||||
System.out.println("OK!");
|
||||
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!");
|
||||
|
||||
}
|
||||
|
||||
@@ -90,6 +103,7 @@ public class GunSolenoidAlignment extends Panel {
|
||||
spinnerNumImages = new javax.swing.JSpinner();
|
||||
centroidPlot = new ch.psi.pshell.plot.LinePlotJFree();
|
||||
buttonClear = new javax.swing.JButton();
|
||||
progressBar = new javax.swing.JProgressBar();
|
||||
|
||||
buttonRun.setText("Run");
|
||||
buttonRun.addActionListener(new java.awt.event.ActionListener() {
|
||||
@@ -238,11 +252,12 @@ public class GunSolenoidAlignment extends Panel {
|
||||
.addComponent(spinnerNumBackgrounds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(57, 57, 57)
|
||||
.addComponent(checkSaveImages)
|
||||
.addContainerGap(75, Short.MAX_VALUE))
|
||||
.addContainerGap(70, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
centroidPlot.setLegendVisible(true);
|
||||
centroidPlot.setTitle("Centroid");
|
||||
centroidPlot.setTitle("");
|
||||
centroidPlot.setTitleFont(new java.awt.Font("DejaVu Sans", 0, 14)); // NOI18N
|
||||
|
||||
buttonClear.setText("Clear");
|
||||
buttonClear.addActionListener(new java.awt.event.ActionListener() {
|
||||
@@ -251,47 +266,47 @@ public class GunSolenoidAlignment extends Panel {
|
||||
}
|
||||
});
|
||||
|
||||
progressBar.setMaximum(1000);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(centroidPlot, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(0, 155, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonRun, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(buttonAbort, javax.swing.GroupLayout.PREFERRED_SIZE, 92, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(12, 12, 12)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(buttonRun, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonAbort, javax.swing.GroupLayout.DEFAULT_SIZE, 92, Short.MAX_VALUE))
|
||||
.addGap(100, 100, 100))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addComponent(buttonClear)
|
||||
.addContainerGap())))))
|
||||
.addGap(12, 12, 12)
|
||||
.addComponent(progressBar, javax.swing.GroupLayout.DEFAULT_SIZE, 272, Short.MAX_VALUE)
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(buttonClear))
|
||||
.addComponent(centroidPlot, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(41, 41, 41)
|
||||
.addComponent(buttonRun)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(buttonAbort)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(centroidPlot, javax.swing.GroupLayout.PREFERRED_SIZE, 289, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(buttonRun)
|
||||
.addComponent(buttonAbort))
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(buttonClear)
|
||||
.addGap(9, 9, 9)))
|
||||
.addComponent(centroidPlot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(buttonClear)
|
||||
.addComponent(progressBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
@@ -308,6 +323,12 @@ 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++));
|
||||
centroidPlot.addSeries(scanSeries);
|
||||
scanSeries.setLinesVisible(false);
|
||||
scanSeries.setPointSize(4);
|
||||
|
||||
HashMap args = new HashMap();
|
||||
args.put("I1", spinnerI1.getValue());
|
||||
args.put("I2", spinnerI2.getValue());
|
||||
@@ -319,8 +340,8 @@ public class GunSolenoidAlignment extends Panel {
|
||||
args.put("use_background", checkBackground.isSelected());
|
||||
args.put("multiple_background", radioBackMultiple.isSelected());
|
||||
((Plugin)this).runAsync("Alignment/Gun_solenoid_alignment",args).thenAccept((Object t) -> {
|
||||
System.out.println("Finish");
|
||||
onEndScan((ScanResult) t);
|
||||
List ret = (List)t;
|
||||
onEndScan((ScanResult)ret.get(0), (List)ret.get(1), (List)ret.get(2) );
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
System.out.println("Error " + ex.toString());
|
||||
@@ -358,6 +379,7 @@ public class GunSolenoidAlignment extends Panel {
|
||||
private javax.swing.JLabel jLabel5;
|
||||
private javax.swing.JLabel jLabel6;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JProgressBar progressBar;
|
||||
private javax.swing.JRadioButton radioBackMultiple;
|
||||
private javax.swing.JRadioButton radioBackSimple;
|
||||
private javax.swing.JSpinner spinnerI1;
|
||||
|
||||
Reference in New Issue
Block a user