|
|
|
|
@@ -13,9 +13,12 @@ import ch.psi.pshell.ui.Panel;
|
|
|
|
|
import ch.psi.pshell.ui.Plugin;
|
|
|
|
|
import ch.psi.utils.Convert;
|
|
|
|
|
import ch.psi.utils.State;
|
|
|
|
|
import java.awt.Component;
|
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.logging.Level;
|
|
|
|
|
import javax.swing.JPanel;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
@@ -32,9 +35,11 @@ public class LaserGunAlignment extends Panel {
|
|
|
|
|
public void onNewRecord(Scan scan, ScanRecord record) {
|
|
|
|
|
try {
|
|
|
|
|
if (running) {
|
|
|
|
|
double error_x = 0.2;
|
|
|
|
|
double error_y = 0.4;
|
|
|
|
|
scanSeries.appendData((Double) record.getValues()[0], (Double) record.getValues()[1], error_x, error_y);
|
|
|
|
|
double x = (Double) record.getValues()[0];
|
|
|
|
|
double y = (Double) record.getValues()[1];
|
|
|
|
|
double stdev_x = (Double) record.getValues()[2];
|
|
|
|
|
double stdev_y = (Double) record.getValues()[3];
|
|
|
|
|
scanSeries.appendData(x, y, stdev_x, stdev_y);
|
|
|
|
|
progressBar.setValue((int) (1000.0 * record.getIndex() / scan.getNumberOfRecords()));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
@@ -59,6 +64,15 @@ public class LaserGunAlignment extends Panel {
|
|
|
|
|
if (state != State.Busy) {
|
|
|
|
|
running = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (Component c : panelParameters.getComponents()) {
|
|
|
|
|
if (!(c instanceof JPanel)){
|
|
|
|
|
c.setEnabled(state == State.Ready);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (state == State.Ready){
|
|
|
|
|
checkBackgroundActionPerformed(null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@@ -75,14 +89,32 @@ public class LaserGunAlignment extends Panel {
|
|
|
|
|
int index = 1;
|
|
|
|
|
|
|
|
|
|
void onEndScan(ScanResult sr, List hx, List hy) {
|
|
|
|
|
System.out.println("In onEndScan");
|
|
|
|
|
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);
|
|
|
|
|
LinePlotErrorSeries hull = new LinePlotErrorSeries(scanSeries.getName() + "H", scanSeries.getColor());
|
|
|
|
|
centroidPlot.addSeries(hull);
|
|
|
|
|
hull.setData((double[]) Convert.toDouble(x), (double[]) Convert.toDouble(y));
|
|
|
|
|
hull.setData((double[]) Convert.toDouble(x), (double[]) Convert.toDouble(y));
|
|
|
|
|
System.out.println("Set");
|
|
|
|
|
//Add ELOG entry
|
|
|
|
|
if (checkElog.isSelected()) {
|
|
|
|
|
String file = Paths.get(getController().getSetup().getContextPath(), "CentroidPlot.jpg").toString();
|
|
|
|
|
try {
|
|
|
|
|
Thread.sleep(250); //Some time to plot update
|
|
|
|
|
centroidPlot.saveSnapshot(file , "jpg");
|
|
|
|
|
evalAsync("elog('Gun solenoid current scan', gsa_log_msg, ['"+ file +"',])", true).handle((ret, ex) -> {
|
|
|
|
|
if (ex != null){
|
|
|
|
|
getLogger().log(Level.WARNING, null, ex);
|
|
|
|
|
} else {
|
|
|
|
|
getLogger().info("Success generating ELOG entry");
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
showException(ex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
@@ -92,7 +124,7 @@ public class LaserGunAlignment extends Panel {
|
|
|
|
|
buttonGroupBack = new javax.swing.ButtonGroup();
|
|
|
|
|
buttonRun = new javax.swing.JButton();
|
|
|
|
|
buttonAbort = new javax.swing.JButton();
|
|
|
|
|
jPanel1 = new javax.swing.JPanel();
|
|
|
|
|
panelParameters = new javax.swing.JPanel();
|
|
|
|
|
jLabel1 = new javax.swing.JLabel();
|
|
|
|
|
spinnerI1 = new javax.swing.JSpinner();
|
|
|
|
|
jLabel2 = new javax.swing.JLabel();
|
|
|
|
|
@@ -129,7 +161,7 @@ public class LaserGunAlignment extends Panel {
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Parameters"));
|
|
|
|
|
panelParameters.setBorder(javax.swing.BorderFactory.createTitledBorder("Parameters"));
|
|
|
|
|
|
|
|
|
|
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
|
|
|
|
|
jLabel1.setText("phi_start");
|
|
|
|
|
@@ -185,43 +217,43 @@ public class LaserGunAlignment extends Panel {
|
|
|
|
|
checkZeroSolenoids.setSelected(true);
|
|
|
|
|
checkZeroSolenoids.setText("Zero solenoids");
|
|
|
|
|
|
|
|
|
|
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
|
|
|
|
jPanel1.setLayout(jPanel1Layout);
|
|
|
|
|
jPanel1Layout.setHorizontalGroup(
|
|
|
|
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
|
|
javax.swing.GroupLayout panelParametersLayout = new javax.swing.GroupLayout(panelParameters);
|
|
|
|
|
panelParameters.setLayout(panelParametersLayout);
|
|
|
|
|
panelParametersLayout.setHorizontalGroup(
|
|
|
|
|
panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(panelParametersLayout.createSequentialGroup()
|
|
|
|
|
.addContainerGap()
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
|
|
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(panelParametersLayout.createSequentialGroup()
|
|
|
|
|
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
|
|
.addComponent(spinnerI1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
|
|
.addGroup(panelParametersLayout.createSequentialGroup()
|
|
|
|
|
.addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
|
|
.addComponent(spinnerI2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
|
|
.addGroup(panelParametersLayout.createSequentialGroup()
|
|
|
|
|
.addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
|
|
.addComponent(spinnerStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
|
|
.addGroup(panelParametersLayout.createSequentialGroup()
|
|
|
|
|
.addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
|
|
.addComponent(spinnerSettlingTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
|
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
|
|
|
|
|
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelParametersLayout.createSequentialGroup()
|
|
|
|
|
.addComponent(jLabel5)
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
|
|
.addComponent(spinnerNumBackgrounds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
|
|
.addGroup(panelParametersLayout.createSequentialGroup()
|
|
|
|
|
.addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 158, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
|
|
.addComponent(spinnerNumImages, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
|
|
|
|
.addGroup(panelParametersLayout.createSequentialGroup()
|
|
|
|
|
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
|
|
|
|
.addComponent(radioBackSimple)
|
|
|
|
|
.addComponent(checkBackground))
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
|
|
.addGroup(panelParametersLayout.createSequentialGroup()
|
|
|
|
|
.addGap(36, 36, 36)
|
|
|
|
|
.addComponent(radioBackMultiple))
|
|
|
|
|
.addComponent(checkSaveImages)
|
|
|
|
|
@@ -231,31 +263,31 @@ public class LaserGunAlignment extends Panel {
|
|
|
|
|
.addContainerGap())
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerI1, spinnerI2, spinnerNumBackgrounds, spinnerNumImages, spinnerSettlingTime, spinnerStep});
|
|
|
|
|
panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerI1, spinnerI2, spinnerNumBackgrounds, spinnerNumImages, spinnerSettlingTime, spinnerStep});
|
|
|
|
|
|
|
|
|
|
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3, jLabel4, jLabel5, jLabel6});
|
|
|
|
|
panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3, jLabel4, jLabel5, jLabel6});
|
|
|
|
|
|
|
|
|
|
jPanel1Layout.setVerticalGroup(
|
|
|
|
|
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(jPanel1Layout.createSequentialGroup()
|
|
|
|
|
panelParametersLayout.setVerticalGroup(
|
|
|
|
|
panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(panelParametersLayout.createSequentialGroup()
|
|
|
|
|
.addGap(18, 18, 18)
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
|
|
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
|
|
.addComponent(jLabel1)
|
|
|
|
|
.addComponent(spinnerI1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
|
|
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
|
|
.addComponent(jLabel2)
|
|
|
|
|
.addComponent(spinnerI2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
|
|
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
|
|
.addComponent(jLabel3)
|
|
|
|
|
.addComponent(spinnerStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
|
|
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
|
|
.addComponent(jLabel4)
|
|
|
|
|
.addComponent(spinnerSettlingTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
|
|
.addGap(4, 4, 4)
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
|
|
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
|
|
.addComponent(jLabel6)
|
|
|
|
|
.addComponent(spinnerNumImages, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
|
|
.addGap(18, 18, 18)
|
|
|
|
|
@@ -265,7 +297,7 @@ public class LaserGunAlignment extends Panel {
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
|
|
.addComponent(radioBackMultiple)
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
|
|
|
|
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
|
|
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
|
|
|
|
.addComponent(jLabel5)
|
|
|
|
|
.addComponent(spinnerNumBackgrounds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
|
|
|
|
.addGap(57, 57, 57)
|
|
|
|
|
@@ -295,7 +327,7 @@ public class LaserGunAlignment extends Panel {
|
|
|
|
|
layout.setHorizontalGroup(
|
|
|
|
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(layout.createSequentialGroup()
|
|
|
|
|
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addComponent(panelParameters, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
|
|
|
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
|
|
|
|
.addGroup(layout.createSequentialGroup()
|
|
|
|
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
|
|
|
|
@@ -328,7 +360,7 @@ public class LaserGunAlignment extends Panel {
|
|
|
|
|
.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))
|
|
|
|
|
.addComponent(panelParameters, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
|
|
|
|
.addContainerGap())
|
|
|
|
|
);
|
|
|
|
|
}// </editor-fold>//GEN-END:initComponents
|
|
|
|
|
@@ -364,12 +396,13 @@ public class LaserGunAlignment extends Panel {
|
|
|
|
|
args.put("multiple_background", radioBackMultiple.isSelected());
|
|
|
|
|
args.put("zero_solenoids", checkZeroSolenoids.isSelected());
|
|
|
|
|
args.put("do_elog", checkElog.isSelected());
|
|
|
|
|
|
|
|
|
|
((Plugin) this).runAsync("Alignment/Laser_gun_alignment", args).thenAccept((Object t) -> {
|
|
|
|
|
List ret = (List) t;
|
|
|
|
|
onEndScan((ScanResult) ret.get(0), (List) ret.get(1), (List) ret.get(2));
|
|
|
|
|
|
|
|
|
|
runAsync("Alignment/Laser_gun_alignment", args).thenAccept((Object ret) -> {
|
|
|
|
|
List l = (List) ret;
|
|
|
|
|
onEndScan((ScanResult) l.get(0), (List) l.get(1), (List) l.get(2));
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
System.err.println(ex);
|
|
|
|
|
running = false;
|
|
|
|
|
showException(ex);
|
|
|
|
|
}
|
|
|
|
|
@@ -406,7 +439,7 @@ public class LaserGunAlignment extends Panel {
|
|
|
|
|
private javax.swing.JLabel jLabel4;
|
|
|
|
|
private javax.swing.JLabel jLabel5;
|
|
|
|
|
private javax.swing.JLabel jLabel6;
|
|
|
|
|
private javax.swing.JPanel jPanel1;
|
|
|
|
|
private javax.swing.JPanel panelParameters;
|
|
|
|
|
private javax.swing.JProgressBar progressBar;
|
|
|
|
|
private javax.swing.JRadioButton radioBackMultiple;
|
|
|
|
|
private javax.swing.JRadioButton radioBackSimple;
|
|
|
|
|
|