diff --git a/plugins/EnergyScan.form b/plugins/EnergyScan.form
index 8d2274b..402cfab 100644
--- a/plugins/EnergyScan.form
+++ b/plugins/EnergyScan.form
@@ -78,7 +78,7 @@
-
+
@@ -101,7 +101,7 @@
-
+
@@ -271,7 +271,7 @@
-
+
@@ -318,7 +318,7 @@
-
+
diff --git a/plugins/EnergyScan.java b/plugins/EnergyScan.java
index c40974e..c3faf72 100644
--- a/plugins/EnergyScan.java
+++ b/plugins/EnergyScan.java
@@ -21,7 +21,9 @@ import ch.psi.pshell.plot.LinePlotBase;
import ch.psi.pshell.plot.LinePlotSeries;
import ch.psi.pshell.plot.Plot;
import ch.psi.pshell.ui.Panel;
+import ch.psi.utils.Chrono;
import java.util.logging.Logger;
+import javax.swing.SwingUtilities;
/**
*
@@ -52,7 +54,21 @@ public class EnergyScan extends Panel {
k3 = (ChannelDouble) getController().getDevicePool().getByName("keithley_3a");
energy = (ChannelDouble) getController().getDevicePool().getByName("energy");
otf_start = (ChannelInteger) getController().getDevicePool().getByName("otf_start");
-
+ /*
+ otf_start.addListener(new DeviceAdapter() {
+ @Override
+ public void onValueChanged(Device device, Object value, Object former) {
+ if (((Integer) value) == 1) {
+ SwingUtilities.invokeLater(() -> {
+ try {
+ startPlot();
+ } catch (Exception ex) {
+ Logger.getLogger(EnergyScan.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ });
+ }
+ }
+ });*/
for (Device dev : new Device[]{energy}) {
dev.addListener(new DeviceAdapter() {
@Override
@@ -67,6 +83,9 @@ public class EnergyScan extends Panel {
k2.update();
energyCache = (Double) value;
if (otf_start.take() == 1) {
+ SwingUtilities.invokeLater(() -> {
+ plot();
+ });
update();
}
}
@@ -79,7 +98,7 @@ public class EnergyScan extends Panel {
start = System.currentTimeMillis();
- update();
+ plot();
}
@Override
@@ -92,18 +111,7 @@ public class EnergyScan extends Panel {
}
boolean otf;
- @Override
- protected void doUpdate() {
- if ((otf_start.take()== 1) && !otf){
- try {
- startPlot();
- } catch (Exception ex) {
- Logger.getLogger(EnergyScan.class.getName()).log(Level.SEVERE, null, ex);
- }
- }
- otf = otf_start.take() > 0;
- plot();
- }
+
void stopScan() {
try {
@@ -125,7 +133,7 @@ public class EnergyScan extends Panel {
public void setEnabled(boolean value) {
super.setEnabled(value);
buttonExecute.setEnabled(value);
- buttonPlot.setEnabled(value);
+ //buttonPlot.setEnabled(value);
checkParameterControls();
}
@@ -138,22 +146,30 @@ public class EnergyScan extends Panel {
}
//spinnerAlpha.setEnabled(enabled && comboMode.getSelectedItem().equals("LINEAR"));
}
+
+ double last = 0;
void plot() {
try {
- if ((scanPlot != null) && (scanSeries != null) && scanPlot.isShowing()) {
+ if ((scanPlot != null) && (scanSeries != null)) {
//if ((scanPlot != null) && (scanSeries != null) && scanPlot.isShowing() && (count != null)) {
double x = energy.take();
+ if (last < (x -10.0)){
+ if (scanSeries!=null){
+ scanSeries.clear();
+ }
+ }
+ last = x;
double y = k2.take() / ((radioK3.isSelected()) ? k3.take() : k1.take());
scanSeries.appendData(x, y);
}
} catch (Exception ex) {
- //showException(ex);
ex.printStackTrace();
}
}
+
void run() throws Exception {
HashMap args = new HashMap();
Double e1 = (Double) spinnerE1.getValue();
@@ -165,7 +181,7 @@ public class EnergyScan extends Panel {
args.put("OFFSET1", (Double) spinnerOffset1.getValue());
args.put("OFFSET2", (Double) spinnerOffset2.getValue());
args.put("RUNTYPE", comboRunType.getSelectedItem().toString());
- args.put("ROUNDS", (Integer) spinnerRounds.getValue());
+ args.put("ROUNDS", (Integer) spinnerRounds.getValue());
buttonAbort.setEnabled(true);
@@ -190,6 +206,7 @@ public class EnergyScan extends Panel {
void startPlot() throws Exception {
PlotDescriptor descriptors = new PlotDescriptor("Energy Scan");
+ //ArrayList plots = getController().plot(new PlotDescriptor[]{descriptors}, Chrono.getTimeStr(System.currentTimeMillis(), "hh:mm:ss"));
ArrayList plots = getController().plot(new PlotDescriptor[]{descriptors}, null);
scanPlot = (LinePlotBase) plots.get(0);
scanSeries = scanPlot.getSeries(0);
@@ -287,7 +304,7 @@ public class EnergyScan extends Panel {
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spinnerE1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerTime, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 84, Short.MAX_VALUE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 82, Short.MAX_VALUE)
.addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING)
@@ -305,7 +322,7 @@ public class EnergyScan extends Panel {
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerRounds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
- .addContainerGap(43, Short.MAX_VALUE))
+ .addContainerGap(41, Short.MAX_VALUE))
);
panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerE1, spinnerTime});
@@ -364,7 +381,7 @@ public class EnergyScan extends Panel {
}
});
- buttonPlot.setText("Plot");
+ buttonPlot.setText("Clear");
buttonPlot.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonPlotActionPerformed(evt);
@@ -381,7 +398,7 @@ public class EnergyScan extends Panel {
.addComponent(buttonPlot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(radioK1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(radioK3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- .addContainerGap(34, Short.MAX_VALUE))
+ .addContainerGap(30, Short.MAX_VALUE))
);
jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {radioK1, radioK3});
@@ -478,8 +495,11 @@ public class EnergyScan extends Panel {
EditorDialog dlgConfig;
private void buttonPlotActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPlotActionPerformed
try {
- startPlot();
- plot();
+ //startPlot();
+ //plot();
+ if (scanSeries!=null){
+ scanSeries.clear();
+ }
} catch (Exception ex) {
showException(ex);
}
diff --git a/script/EnergyScan.py b/script/EnergyScan.py
index 8e32bae..82d37a9 100644
--- a/script/EnergyScan.py
+++ b/script/EnergyScan.py
@@ -71,12 +71,10 @@ wait_channel(OTF_DONE, 1, type = 'i')
for scan_no in range(number_of_scans):
suffix = ("%03d" % fid)
input_file = input_path + "o" + file_prefix + "_" + suffix + ".dat"
- fid = fid + 1
caput(OTF_E1, E1)
caput(OTF_E2, E2)
caput(OTF_TIME, TIME)
- #fid = fid + 1
caput(OTF_FTS,file_prefix)
caput(OTF_FID,fid)
time.sleep(2.0)
@@ -106,6 +104,7 @@ for scan_no in range(number_of_scans):
polswitch = 1
time.sleep(3.0)
+ fid = fid + 1
#close_vg13()