Closedown
This commit is contained in:
+41
-33
@@ -2,6 +2,7 @@
|
||||
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
|
||||
*/
|
||||
|
||||
import ch.psi.pshell.core.Controller;
|
||||
import ch.psi.pshell.dev.Device;
|
||||
import ch.psi.pshell.dev.DeviceListener;
|
||||
import ch.psi.pshell.epics.Scienta;
|
||||
@@ -148,33 +149,39 @@ public class XPSSpectrum extends Panel {
|
||||
}
|
||||
}
|
||||
};
|
||||
public final String STEP_VAR = "xps_spectrum_step";
|
||||
public final String CURRERNT_RANGE_VAR = "cur_range";
|
||||
public final String CURRERNT_ITERATION_VAR = "cur_iteration";
|
||||
int currentScanIndex ;
|
||||
RangeSelection[] scanRanges;
|
||||
|
||||
Task monitoringTask = new Task() {
|
||||
@Override
|
||||
protected Object execute() throws Exception {
|
||||
Object index = XPSSpectrum.this.eval(STEP_VAR, true);
|
||||
if ((index!=null) && (index instanceof Integer) && ((Integer)index > 0)){
|
||||
int scanIndex = ((Integer)index)-1;
|
||||
Object index = XPSSpectrum.this.eval(CURRERNT_RANGE_VAR, true);
|
||||
if ((index!=null) && (index instanceof Integer) && ((Integer)index >= 0)){
|
||||
int scanIndex = (Integer)index;
|
||||
if (scanIndex!=currentScanIndex){
|
||||
buttonSkip.setEnabled(true);
|
||||
}
|
||||
currentScanIndex = scanIndex;
|
||||
|
||||
buttonSkip.setVisible((scanRanges.length>1) && (currentScanIndex < (scanRanges.length-1)));
|
||||
|
||||
RangeSelection range = rangeSelectionPanel.getRangesOrdered()[scanIndex];
|
||||
for (int row = 0; row< rangeSelectionPanel.getTable().getRowCount(); row++){
|
||||
if (range.equals((Double)rangeSelectionPanel.getTable().getValueAt(row, 0), (Double)rangeSelectionPanel.getTable().getValueAt(row, 2))){
|
||||
rangeSelectionPanel.getTable().setRowSelectionInterval(row, row);
|
||||
break;
|
||||
}
|
||||
if (row == (rangeSelectionPanel.getTable().getRowCount()-1)){
|
||||
rangeSelectionPanel.getTable().clearSelection();
|
||||
}
|
||||
}
|
||||
int current_iteration = (Integer) XPSSpectrum.this.eval(CURRERNT_ITERATION_VAR, true);
|
||||
int iterations = (Integer)scanRanges[currentScanIndex].getVars()[2];
|
||||
|
||||
buttonSkip.setVisible((iterations>1) && (current_iteration < (iterations-1)));
|
||||
|
||||
if (detailedScan){
|
||||
RangeSelection range = rangeSelectionPanel.getRangesOrdered()[scanIndex];
|
||||
for (int row = 0; row< rangeSelectionPanel.getTable().getRowCount(); row++){
|
||||
if (range.equals((Double)rangeSelectionPanel.getTable().getValueAt(row, 0), (Double)rangeSelectionPanel.getTable().getValueAt(row, 2))){
|
||||
rangeSelectionPanel.getTable().setRowSelectionInterval(row, row);
|
||||
break;
|
||||
}
|
||||
if (row == (rangeSelectionPanel.getTable().getRowCount()-1)){
|
||||
rangeSelectionPanel.getTable().clearSelection();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rangeSelectionPanel.getTable().clearSelection();
|
||||
}
|
||||
@@ -183,6 +190,17 @@ public class XPSSpectrum extends Panel {
|
||||
}
|
||||
};
|
||||
|
||||
void start() throws Controller.ControllerStateException{
|
||||
HashMap<String, Object> args = new HashMap<>();
|
||||
args.put("ranges", scanRanges);
|
||||
args.put("pass_energy", Integer.valueOf(comboPass.getSelectedItem().toString()));
|
||||
|
||||
currentScanIndex = -1;
|
||||
runAsync("XPSSpectrum", args);
|
||||
monitoringTask.schedule(100, 500);
|
||||
running = true;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
@@ -472,20 +490,15 @@ public class XPSSpectrum extends Panel {
|
||||
|
||||
private void buttonInitialScanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonInitialScanActionPerformed
|
||||
try {
|
||||
//getApp().startTask(task);
|
||||
HashMap<String, Object> args = new HashMap<>();
|
||||
rangeSelectionPanel.clear();
|
||||
detailedScan = false;
|
||||
|
||||
RangeSelection initialRange = new RangeSelection(valueLow.getValue(),valueHigh.getValue());
|
||||
int iterations = (int)valueIterations.getValue();
|
||||
initialRange.setVars(new Object[]{valueSize.getValue(),valueTime.getValue(),iterations});
|
||||
scanRanges = new RangeSelection[]{initialRange};
|
||||
args.put("ranges", scanRanges);
|
||||
args.put("pass_energy", Integer.valueOf(comboPass.getSelectedItem().toString()));
|
||||
|
||||
rangeSelectionPanel.clear();
|
||||
detailedScan = false;
|
||||
currentScanIndex = -1;
|
||||
runAsync("XPSSpectrum", args);
|
||||
running = true;
|
||||
start();
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
@@ -494,15 +507,10 @@ public class XPSSpectrum extends Panel {
|
||||
|
||||
private void buttonDetailedScanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDetailedScanActionPerformed
|
||||
try {
|
||||
scanRanges = rangeSelectionPanel.getRangesOrdered();
|
||||
HashMap<String, Object> args = new HashMap<>();
|
||||
args.put("ranges", scanRanges);
|
||||
args.put("pass_energy", Integer.valueOf(comboPass.getSelectedItem().toString()));
|
||||
detailedScan = true;
|
||||
currentScanIndex = -1;
|
||||
runAsync("XPSSpectrum", args);
|
||||
monitoringTask.schedule(100, 500);
|
||||
running = true;
|
||||
scanRanges = rangeSelectionPanel.getRangesOrdered();
|
||||
|
||||
start();
|
||||
} catch (Exception ex) {
|
||||
showException(ex);
|
||||
}
|
||||
|
||||
+20
-17
@@ -6,6 +6,9 @@
|
||||
|
||||
from ch.psi.pshell.data.ScanPersistenceStrategyDefault import ATTR_WRITABLE_DIMENSION as ATTR_WRITABLE_DIMENSION
|
||||
|
||||
cur_range = 0
|
||||
cur_iteration = 0
|
||||
|
||||
if scienta.acquisitionMode == scienta.AcquisitionMode.Fixed:
|
||||
scienta.acquisitionMode = scienta.AcquisitionMode.Swept
|
||||
ret=[]
|
||||
@@ -14,20 +17,19 @@ ret=[]
|
||||
#Global arguments
|
||||
scienta.passEnergy = pass_energy
|
||||
|
||||
xps_spectrum_step = 0
|
||||
names=[]
|
||||
for i in range(len(ranges)):
|
||||
names.append(str(ranges[i]))
|
||||
plots = plot(None, names)
|
||||
try:
|
||||
for i in range(len(ranges)):
|
||||
skip_iteration = False
|
||||
xps_spectrum_step = xps_spectrum_step+1
|
||||
scienta.lowEnergy.put(ranges[i].min)
|
||||
scienta.highEnergy.put(ranges[i].max)
|
||||
for cur_range in range(len(ranges)):
|
||||
cur_iteration = 0
|
||||
skip_iteration = False
|
||||
scienta.lowEnergy.put(ranges[cur_range].min)
|
||||
scienta.highEnergy.put(ranges[cur_range].max)
|
||||
scienta.update()
|
||||
|
||||
vars = ranges[i].vars
|
||||
vars = ranges[cur_range].vars
|
||||
scienta.stepTime.write(vars[0])
|
||||
scienta.stepSize.write(vars[1])
|
||||
scienta.setIterations(1)
|
||||
@@ -35,7 +37,8 @@ try:
|
||||
#iterations done in script
|
||||
xdata = None
|
||||
ydata = None
|
||||
for j in range(vars[2]):
|
||||
for cur_iteration in range(vars[2]):
|
||||
plots[cur_range].setTitle(str(ranges[cur_range]) + " - iteration " + str(cur_iteration+1))
|
||||
trig_scienta()
|
||||
spectrum_array = scienta.spectrum.read()
|
||||
if ydata is None:
|
||||
@@ -45,29 +48,29 @@ try:
|
||||
ydata[k] = ydata[k] + spectrum_array[k]
|
||||
if xdata is None:
|
||||
xdata = scienta.spectrumX
|
||||
plots[i].getSeries(0).setData(xdata, ydata)
|
||||
plots[cur_range].getSeries(0).setData(xdata, ydata)
|
||||
if skip_iteration:
|
||||
break
|
||||
plots[i].setTitle(str(ranges[i]) + " - iteration " + str(j+1))
|
||||
break
|
||||
|
||||
plots[i].setTitle(str(ranges[i]))
|
||||
plots[cur_range].setTitle(str(ranges[cur_range]))
|
||||
ret.append((xdata, ydata))
|
||||
|
||||
data1d = [1,2,3,4,5]
|
||||
path="scan" + str(i+1) + "/"
|
||||
path="scan" + str(cur_range+1) + "/"
|
||||
save_dataset(path + "spectrum", ydata)
|
||||
save_dataset(path + "channels", xdata)
|
||||
set_attribute(path + "channels", ATTR_WRITABLE_DIMENSION, 1)
|
||||
set_attribute(path, "Range Low", ranges[i].min)
|
||||
set_attribute(path, "Range High", ranges[i].max)
|
||||
set_attribute(path, "Range Low", ranges[cur_range].min)
|
||||
set_attribute(path, "Range High", ranges[cur_range].max)
|
||||
set_attribute(path, "Step Time",vars[0])
|
||||
set_attribute(path, "Step Size",vars[1])
|
||||
set_attribute(path, "Pass Energy",pass_energy)
|
||||
set_attribute(path, "Iterations",j+1)
|
||||
set_attribute(path, "Iterations",cur_iteration+1)
|
||||
|
||||
|
||||
finally:
|
||||
xps_spectrum_step = 0
|
||||
cur_range = 0
|
||||
if not scienta.isReady():
|
||||
scienta.stop()
|
||||
scienta.update()
|
||||
set_return(to_array(ret,'o'))
|
||||
Reference in New Issue
Block a user