Closedown
This commit is contained in:
@@ -2,6 +2,13 @@
|
||||
* Copyright (c) 2014-2017 Paul Scherrer Institute. All rights reserved.
|
||||
*/
|
||||
|
||||
import ch.psi.pshell.device.DescStatsDouble;
|
||||
import ch.psi.pshell.plot.LinePlotErrorSeries;
|
||||
import ch.psi.pshell.plot.LinePlotJFree;
|
||||
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.ui.Panel;
|
||||
import ch.psi.utils.State;
|
||||
|
||||
@@ -9,20 +16,30 @@ import ch.psi.utils.State;
|
||||
*
|
||||
*/
|
||||
public class GunScan extends Panel {
|
||||
LinePlotErrorSeries series = new LinePlotErrorSeries("Values");
|
||||
|
||||
public GunScan() {
|
||||
initComponents();
|
||||
plot.setStyle(LinePlotJFree.Style.ErrorY);
|
||||
plot.addSeries(series);
|
||||
plot.getAxis(Plot.AxisId.X).setLabel("Gun Phase");
|
||||
plot.getAxis(Plot.AxisId.Y).setLabel("MeV");
|
||||
}
|
||||
|
||||
//Overridable callbacks
|
||||
@Override
|
||||
public void onInitialize(int runCount) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStateChange(State state, State former) {
|
||||
|
||||
buttonAbort.setEnabled(state.isProcessing());
|
||||
buttonStart.setEnabled(state == State.Ready);
|
||||
spinnerStart.setEnabled(buttonStart.isEnabled());
|
||||
spinnerStop.setEnabled(buttonStart.isEnabled());
|
||||
spinnerStep.setEnabled(buttonStart.isEnabled());
|
||||
spinnerSamples.setEnabled(buttonStart.isEnabled());
|
||||
spinnerLatency.setEnabled(buttonStart.isEnabled());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -34,6 +51,37 @@ public class GunScan extends Panel {
|
||||
@Override
|
||||
protected void doUpdate() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
getContext().addScanListener(scanListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStop() {
|
||||
getContext().removeScanListener(scanListener);
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
ScanListener scanListener = new ScanListener() {
|
||||
@Override
|
||||
public void onScanStarted(Scan scan, String plotTitle) {
|
||||
if ("GunScan".equals(getContext().getExecutionPars().getName())){
|
||||
series.clear();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onNewRecord(Scan scan, ScanRecord record) {
|
||||
if ("GunScan".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
|
||||
@@ -57,7 +105,7 @@ public class GunScan extends Panel {
|
||||
dispersionLabel = new javax.swing.JLabel();
|
||||
plot = new ch.psi.pshell.plot.LinePlotJFree();
|
||||
buttonStart = new javax.swing.JButton();
|
||||
buttonStop = new javax.swing.JButton();
|
||||
buttonAbort = new javax.swing.JButton();
|
||||
|
||||
setPreferredSize(new java.awt.Dimension(737, 445));
|
||||
|
||||
@@ -184,7 +232,7 @@ public class GunScan extends Panel {
|
||||
|
||||
buttonStart.setText("Start");
|
||||
|
||||
buttonStop.setText("Stop");
|
||||
buttonAbort.setText("Abort");
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
@@ -198,7 +246,7 @@ public class GunScan extends Panel {
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(buttonStart)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonStop)))
|
||||
.addComponent(buttonAbort)))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
@@ -216,7 +264,7 @@ public class GunScan extends Panel {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(buttonStart)
|
||||
.addComponent(buttonStop))))
|
||||
.addComponent(buttonAbort))))
|
||||
.addGap(14, 14, 14))
|
||||
);
|
||||
|
||||
@@ -224,8 +272,8 @@ public class GunScan extends Panel {
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton buttonAbort;
|
||||
private javax.swing.JButton buttonStart;
|
||||
private javax.swing.JButton buttonStop;
|
||||
private javax.swing.JLabel dispersionLabel;
|
||||
private javax.swing.JLabel energyLabel;
|
||||
private javax.swing.JPanel jPanel1;
|
||||
|
||||
Reference in New Issue
Block a user