Closedown

This commit is contained in:
gobbo_a
2017-04-13 15:18:53 +02:00
parent 31f29baa65
commit 8ddf2e0f9d
4 changed files with 37 additions and 26 deletions

View File

@@ -13,6 +13,7 @@ import ch.psi.pshell.ui.App;
import ch.psi.pshell.ui.Panel;
import ch.psi.pshell.ui.Plugin;
import ch.psi.utils.State;
import ch.psi.utils.swing.SwingUtils;
import java.util.ArrayList;
import java.util.List;
import javax.swing.DefaultComboBoxModel;
@@ -22,15 +23,18 @@ import javax.swing.DefaultComboBoxModel;
*/
public class WireScan extends Panel {
final String[] seriesNames = new String[]{"bpm1_x", "bpm1_y", "bpm1_q", "bpm2_x", "bpm2_y", "bpm2_q"};
final int[] seriesYAxis = new int[]{1, 1, 2, 1, 1, 2};
LinePlotSeries[] series = new LinePlotSeries[seriesNames.length];
public WireScan() {
initComponents();
for (int i=0; i< seriesNames.length; i++){
plot.addSeries(new LinePlotSeries(seriesNames[i]));
series[i] = new LinePlotSeries(seriesNames[i], null, seriesYAxis[i]);
plot.addSeries(series[i]);
}
plot.getAxis(Plot.AxisId.X).setLabel("");
plot.getAxis(Plot.AxisId.Y).setLabel("Position");
plot.getAxis(Plot.AxisId.X).setLabel("Position");
plot.getAxis(Plot.AxisId.Y).setLabel("mm");
plot.getAxis(Plot.AxisId.Y2).setLabel("pc");
plot.setLegendVisible(true);
}
@@ -102,20 +106,23 @@ public class WireScan extends Panel {
@Override
public void onNewRecord(Scan scan, ScanRecord record) {
System.out.println( (Double) record.getValues()[1]);
if ("WireScan".equals(getContext().getExecutionPars().getName())) {
double position = (Double) record.getValues()[1];
for (int i=0; i< series.length; i++){
plot.addSeries(new LinePlotSeries(seriesNames[i]));
series[i].appendData(position,(Double) record.getValues()[4 + i]);
try{
if ("WireScan".equals(getContext().getExecutionPars().getName())) {
double position = (Double) record.getValues()[1];
for (int i=0; i< series.length; i++){
if (record.getValues()[4 + i] != null){
series[i].appendData(position,(Double) record.getValues()[4 + i]);
}
}
}
} catch(Exception ex){
ex.printStackTrace();
}
}
@Override
public void onScanEnded(Scan scan, Exception ex) {
getContext().removeScanListener(this);
getContext().removeScanListener(this);
}
};
@@ -376,7 +383,9 @@ public class WireScan extends Panel {
runAsync("Diagnostics/WireScan", parameters).handle((ret, ex) -> {
if (ex != null) {
getLogger().info("Exception executing scan: " + ex);
} else {
showException((Exception) ex);
} else {
SwingUtils.showMessage(WireScan.this, "Success", "Data file: \n" + getContext().getDataManager().getLastOutput());
}
return ret;
});