This commit is contained in:
x07maop
2015-06-23 09:14:31 +02:00
parent 36e1f1066c
commit 6b77ebae46

View File

@@ -4,10 +4,12 @@
import ch.psi.pshell.core.Controller;
import ch.psi.pshell.core.Controller.ControllerStateException;
import ch.psi.pshell.core.PlotDescriptor;
import ch.psi.pshell.dev.Device;
import ch.psi.pshell.dev.DeviceListener;
import ch.psi.pshell.epics.ChannelDoubleArray;
import ch.psi.pshell.epics.ChannelInteger;
import ch.psi.pshell.plot.LinePlot;
import ch.psi.pshell.plot.LinePlotBase;
import ch.psi.pshell.plot.LinePlotJFree;
import ch.psi.pshell.plot.LinePlotSeries;
@@ -23,6 +25,7 @@ import java.io.FileInputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Properties;
import javax.swing.DefaultComboBoxModel;
@@ -103,12 +106,14 @@ public class EnergyScan extends Panel {
Mode[] batch;
int batchIndex;
LinePlotBase plot;
LinePlotSeries series;
LinePlotBase scanPlot;
LinePlotSeries scanSeries;
public class PluginPanel extends MonitoredPanel {
final LinePlotBase plot;
final LinePlotSeries series;
public PluginPanel() {
initComponents();
buttonDefaultsActionPerformed(null);
@@ -149,6 +154,7 @@ public class EnergyScan extends Panel {
Integer c = count.take();
if (c == null) {
series.clear();
scanSeries.clear();
} else {
double[] ydata = null;
if (radioE.isSelected()) {
@@ -179,10 +185,12 @@ public class EnergyScan extends Panel {
}
if (ydata == null) {
series.clear();
scanSeries.clear();
} else {
edata.setSize(c);
double[] xdata = edata.read();
series.setData(xdata, ydata);
scanSeries.setData(xdata, ydata);
}
}
} catch (Exception ex) {
@@ -325,14 +333,19 @@ public class EnergyScan extends Panel {
args.put("FOLDER", folder);
runAsync("EnergyScan", args);
plot.getAxis(Plot.AxisId.X).setRange(Math.min(e1, e2), Math.max(e1, e2));
scanPlot.getAxis(Plot.AxisId.X).setRange(Math.min(e1, e2), Math.max(e1, e2));
}
protected void onExecutedFile(String fileName){
protected void onExecutedFile(String fileName, Object result){
try {
switch (fileName){
case "EnergyScan":
//TODO: Check if exception has happenned before continuing
if (result instanceof Exception ){
batchIndex=0;
batch=null;
throw ((Exception)result);
}
if (batch!=null){
batchIndex++;
if (batchIndex>=batch.length){
@@ -771,6 +784,11 @@ public class EnergyScan extends Panel {
private void buttonExecuteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExecuteActionPerformed
try {
PlotDescriptor descriptors = new PlotDescriptor("Scan Data");
ArrayList<LinePlot> plots = getController().plot(new PlotDescriptor[]{descriptors},null);
scanPlot = (LinePlotBase) plots.get(0);
scanSeries = plot.getSeries(0);
batchIndex = 0;
switch(comboRunType.getSelectedIndex()){
case 5: