Startup
This commit is contained in:
@@ -12,6 +12,7 @@ import ch.psi.pshell.scan.Scan;
|
||||
import ch.psi.pshell.scan.ScanListener;
|
||||
import ch.psi.pshell.scan.ScanRecord;
|
||||
import ch.psi.pshell.ui.Panel;
|
||||
import ch.psi.utils.Convert;
|
||||
import ch.psi.utils.State;
|
||||
import ch.psi.utils.swing.SwingUtils;
|
||||
import java.awt.Color;
|
||||
@@ -22,18 +23,19 @@ import javax.swing.JSpinner;
|
||||
*
|
||||
*/
|
||||
public class SchottkyScan extends Panel {
|
||||
LinePlotErrorSeries series = new LinePlotErrorSeries("Values");
|
||||
|
||||
|
||||
LinePlotErrorSeries series = new LinePlotErrorSeries("Values");
|
||||
|
||||
public SchottkyScan() {
|
||||
initComponents();
|
||||
plot.setStyle(LinePlotJFree.Style.ErrorY);
|
||||
plot.addSeries(series);
|
||||
plot.getAxis(Plot.AxisId.X).setLabel("Gun Phase");
|
||||
plot.getAxis(Plot.AxisId.Y).setLabel("SINEG01-DICT215:B1_CHARGE");
|
||||
//setPersistedComponents(SwingUtils.getComponentsByType(panelPars, JSpinner.class));
|
||||
plot.getAxis(Plot.AxisId.Y).setLabel("SINEG01-DICT215:B1_CHARGE");
|
||||
setPersistedComponents(SwingUtils.getComponentsByType(panelPars, JSpinner.class));
|
||||
}
|
||||
|
||||
//Overridable callbacks
|
||||
//Overridable callbacks
|
||||
@Override
|
||||
public void onInitialize(int runCount) {
|
||||
}
|
||||
@@ -49,7 +51,7 @@ public class SchottkyScan extends Panel {
|
||||
spinnerSamples.setEnabled(buttonStart.isEnabled());
|
||||
spinnerLatency.setEnabled(buttonStart.isEnabled());
|
||||
spinnerPhaseRef.setEnabled(buttonStart.isEnabled());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExecutedFile(String fileName, Object result) {
|
||||
@@ -59,7 +61,7 @@ public class SchottkyScan extends Panel {
|
||||
@Override
|
||||
protected void doUpdate() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
@@ -67,30 +69,32 @@ public class SchottkyScan extends Panel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
public void onStop() {
|
||||
getContext().removeScanListener(scanListener);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
|
||||
ScanListener scanListener = new ScanListener() {
|
||||
@Override
|
||||
public void onScanStarted(Scan scan, String plotTitle) {
|
||||
if ("SchottkyScan".equals(getContext().getExecutionPars().getName())){
|
||||
series.clear();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onNewRecord(Scan scan, ScanRecord record) {
|
||||
if ("SchottkyScan".equals(getContext().getExecutionPars().getName())){
|
||||
series.appendData((Double)record.getPositions()[0], ((DescStatsDouble)record.getValues()[0]).getMean(),
|
||||
((DescStatsDouble)record.getValues()[0]).getStdev());
|
||||
public void onScanStarted(Scan scan, String plotTitle) {
|
||||
if ("SchottkyScan".equals(getContext().getExecutionPars().getName())) {
|
||||
series.clear();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNewRecord(Scan scan, ScanRecord record) {
|
||||
if ("SchottkyScan".equals(getContext().getExecutionPars().getName())) {
|
||||
series.appendData((Double) record.getPositions()[0], ((DescStatsDouble) record.getValues()[0]).getMean(),
|
||||
((DescStatsDouble) record.getValues()[0]).getStdev());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScanEnded(Scan scan, Exception ex) {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
@@ -99,18 +103,18 @@ public class SchottkyScan extends Panel {
|
||||
buttonAbort = new javax.swing.JButton();
|
||||
panelPars = new javax.swing.JPanel();
|
||||
spinnerStep = new javax.swing.JSpinner();
|
||||
jLabel5 = new javax.swing.JLabel();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
labelLatency = new javax.swing.JLabel();
|
||||
labelStart = new javax.swing.JLabel();
|
||||
spinnerStop = new javax.swing.JSpinner();
|
||||
jLabel3 = new javax.swing.JLabel();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
labelStep = new javax.swing.JLabel();
|
||||
labelStop = new javax.swing.JLabel();
|
||||
spinnerLatency = new javax.swing.JSpinner();
|
||||
spinnerSamples = new javax.swing.JSpinner();
|
||||
jLabel4 = new javax.swing.JLabel();
|
||||
labelSamples = new javax.swing.JLabel();
|
||||
spinnerStart = new javax.swing.JSpinner();
|
||||
plot = new ch.psi.pshell.plot.LinePlotJFree();
|
||||
panelOutput = new javax.swing.JPanel();
|
||||
jLabel7 = new javax.swing.JLabel();
|
||||
labelRefPhase = new javax.swing.JLabel();
|
||||
spinnerPhaseRef = new javax.swing.JSpinner();
|
||||
buttonSet = new javax.swing.JButton();
|
||||
|
||||
@@ -132,26 +136,26 @@ public class SchottkyScan extends Panel {
|
||||
|
||||
spinnerStep.setModel(new javax.swing.SpinnerNumberModel(5.0d, 1.0d, 90.0d, 1.0d));
|
||||
|
||||
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel5.setText("Latency:");
|
||||
labelLatency.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
labelLatency.setText("Latency:");
|
||||
|
||||
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel1.setText("Start:");
|
||||
labelStart.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
labelStart.setText("Start:");
|
||||
|
||||
spinnerStop.setModel(new javax.swing.SpinnerNumberModel(180.0d, -180.0d, 360.0d, 1.0d));
|
||||
|
||||
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel3.setText("Step:");
|
||||
labelStep.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
labelStep.setText("Step:");
|
||||
|
||||
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel2.setText("Stop:");
|
||||
labelStop.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
labelStop.setText("Stop:");
|
||||
|
||||
spinnerLatency.setModel(new javax.swing.SpinnerNumberModel(0.1d, 0.0d, 5.0d, 0.01d));
|
||||
|
||||
spinnerSamples.setModel(new javax.swing.SpinnerNumberModel(1, 1, 50, 1));
|
||||
|
||||
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel4.setText("Nb Samples:");
|
||||
labelSamples.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
labelSamples.setText("Nb Samples:");
|
||||
|
||||
spinnerStart.setModel(new javax.swing.SpinnerNumberModel(0.0d, -180.0d, 360.0d, 1.0d));
|
||||
|
||||
@@ -163,21 +167,21 @@ public class SchottkyScan extends Panel {
|
||||
.addContainerGap()
|
||||
.addGroup(panelParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(panelParsLayout.createSequentialGroup()
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(labelStart)
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(spinnerStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(panelParsLayout.createSequentialGroup()
|
||||
.addComponent(jLabel4)
|
||||
.addComponent(labelSamples)
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(spinnerSamples, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(panelParsLayout.createSequentialGroup()
|
||||
.addComponent(jLabel5)
|
||||
.addComponent(labelLatency)
|
||||
.addGap(0, 0, 0)
|
||||
.addComponent(spinnerLatency, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(panelParsLayout.createSequentialGroup()
|
||||
.addGroup(panelParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jLabel2)
|
||||
.addComponent(jLabel3))
|
||||
.addComponent(labelStop)
|
||||
.addComponent(labelStep))
|
||||
.addGap(1, 1, 1)
|
||||
.addGroup(panelParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(spinnerStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
@@ -185,7 +189,7 @@ public class SchottkyScan extends Panel {
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
panelParsLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3, jLabel4, jLabel5});
|
||||
panelParsLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {labelLatency, labelSamples, labelStart, labelStep, labelStop});
|
||||
|
||||
panelParsLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerLatency, spinnerSamples, spinnerStart, spinnerStep, spinnerStop});
|
||||
|
||||
@@ -194,23 +198,23 @@ public class SchottkyScan extends Panel {
|
||||
.addGroup(panelParsLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(panelParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(labelStart)
|
||||
.addComponent(spinnerStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(panelParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel2)
|
||||
.addComponent(labelStop)
|
||||
.addComponent(spinnerStop, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(panelParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel3)
|
||||
.addComponent(labelStep)
|
||||
.addComponent(spinnerStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(panelParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel4)
|
||||
.addComponent(labelSamples)
|
||||
.addComponent(spinnerSamples, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(panelParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel5)
|
||||
.addComponent(labelLatency)
|
||||
.addComponent(spinnerLatency, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
@@ -219,10 +223,10 @@ public class SchottkyScan extends Panel {
|
||||
|
||||
panelOutput.setBorder(javax.swing.BorderFactory.createTitledBorder("Output"));
|
||||
|
||||
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
jLabel7.setText("Ref Phase:");
|
||||
labelRefPhase.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
|
||||
labelRefPhase.setText("Ref Phase:");
|
||||
|
||||
spinnerPhaseRef.setModel(new javax.swing.SpinnerNumberModel(0.0d, -45.0d, 360.0d, 1.0d));
|
||||
spinnerPhaseRef.setModel(new javax.swing.SpinnerNumberModel(0.0d, -180.0d, 360.0d, 1.0d));
|
||||
spinnerPhaseRef.addChangeListener(new javax.swing.event.ChangeListener() {
|
||||
public void stateChanged(javax.swing.event.ChangeEvent evt) {
|
||||
spinnerPhaseRefStateChanged(evt);
|
||||
@@ -244,7 +248,7 @@ public class SchottkyScan extends Panel {
|
||||
.addContainerGap(25, Short.MAX_VALUE)
|
||||
.addGroup(panelOutputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelOutputLayout.createSequentialGroup()
|
||||
.addComponent(jLabel7)
|
||||
.addComponent(labelRefPhase)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(spinnerPhaseRef, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(buttonSet, javax.swing.GroupLayout.Alignment.TRAILING))
|
||||
@@ -258,7 +262,7 @@ public class SchottkyScan extends Panel {
|
||||
.addGroup(panelOutputLayout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(panelOutputLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel7)
|
||||
.addComponent(labelRefPhase)
|
||||
.addComponent(spinnerPhaseRef, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(buttonSet)
|
||||
@@ -279,7 +283,7 @@ public class SchottkyScan extends Panel {
|
||||
.addComponent(panelPars, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(panelOutput, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 522, Short.MAX_VALUE)
|
||||
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 511, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
@@ -305,29 +309,29 @@ public class SchottkyScan extends Panel {
|
||||
|
||||
private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed
|
||||
//((Plugin)this).
|
||||
plot.removeMarker(null);
|
||||
spinnerPhaseRef.setValue(0.0);
|
||||
ArrayList parameters = new ArrayList();
|
||||
parameters.add(spinnerStart.getValue());
|
||||
parameters.add(spinnerStop.getValue());
|
||||
parameters.add(spinnerStep.getValue());
|
||||
parameters.add(spinnerSamples.getValue());
|
||||
parameters.add(spinnerLatency.getValue());
|
||||
plot.removeMarker(null);
|
||||
spinnerPhaseRef.setValue(0.0);
|
||||
ArrayList parameters = new ArrayList();
|
||||
parameters.add(spinnerStart.getValue());
|
||||
parameters.add(spinnerStop.getValue());
|
||||
parameters.add(spinnerStep.getValue());
|
||||
parameters.add(spinnerSamples.getValue());
|
||||
parameters.add(spinnerLatency.getValue());
|
||||
try {
|
||||
//How to get a callback on the end of execution
|
||||
runAsync("RFscan/SchottkyScan", parameters).handle((ret, ex) -> {
|
||||
if (ex != null){
|
||||
runAsync("RFscan/SchottkyScan", parameters).handle((ret, ex) -> {
|
||||
if (ex != null) {
|
||||
getLogger().info("Exception executing scan: " + ex);
|
||||
} else {
|
||||
spinnerPhaseRef.setValue(ret);
|
||||
spinnerPhaseRef.setValue(Convert.roundDouble((Double) ret, 1));
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
});
|
||||
//runAsync("RFscan/SchottkyScan", parameters);
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
|
||||
|
||||
}//GEN-LAST:event_buttonStartActionPerformed
|
||||
|
||||
private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed
|
||||
@@ -341,40 +345,40 @@ public class SchottkyScan extends Panel {
|
||||
private void spinnerPhaseRefStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerPhaseRefStateChanged
|
||||
try {
|
||||
plot.removeMarker(null);
|
||||
plot.addMarker((Double)spinnerPhaseRef.getValue(), Plot.AxisId.X, "Ref Phase",Color.GREEN);
|
||||
plot.addMarker((Double) spinnerPhaseRef.getValue(), Plot.AxisId.X, "Ref Phase", Color.GREEN);
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}
|
||||
}//GEN-LAST:event_spinnerPhaseRefStateChanged
|
||||
|
||||
private void buttonSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetActionPerformed
|
||||
try {
|
||||
double phaseOffset = -((Double)spinnerPhaseRef.getValue());
|
||||
String cmd = "caput('SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE', " + phaseOffset + ")";
|
||||
cmd += "; " + "caput('SINEG01-RSYS:CMD-LOAD-CALIB-BEAM', 1)";
|
||||
evalAsync(cmd).handle((ret, ex) -> {
|
||||
if (ex != null){
|
||||
showException((Exception)ex);
|
||||
double phaseOffset = -((Double) spinnerPhaseRef.getValue());
|
||||
String cmd = "caput('SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE', " + phaseOffset + ");";
|
||||
cmd += "caput('SINEG01-RSYS:CMD-LOAD-CALIB-BEAM', 1)";
|
||||
evalAsync(cmd).handle((ret, ex) -> {
|
||||
if (ex != null) {
|
||||
showException((Exception) ex);
|
||||
} else {
|
||||
SwingUtils.showMessage(this, "Success", "Success setting ref phase");
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
});
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
}
|
||||
}//GEN-LAST:event_buttonSetActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton buttonAbort;
|
||||
private javax.swing.JButton buttonSet;
|
||||
private javax.swing.JButton buttonStart;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JLabel jLabel3;
|
||||
private javax.swing.JLabel jLabel4;
|
||||
private javax.swing.JLabel jLabel5;
|
||||
private javax.swing.JLabel jLabel7;
|
||||
private javax.swing.JLabel labelLatency;
|
||||
private javax.swing.JLabel labelRefPhase;
|
||||
private javax.swing.JLabel labelSamples;
|
||||
private javax.swing.JLabel labelStart;
|
||||
private javax.swing.JLabel labelStep;
|
||||
private javax.swing.JLabel labelStop;
|
||||
private javax.swing.JPanel panelOutput;
|
||||
private javax.swing.JPanel panelPars;
|
||||
private ch.psi.pshell.plot.LinePlotJFree plot;
|
||||
|
||||
Reference in New Issue
Block a user