diff --git a/plugins/HarmonicScan.form b/plugins/HarmonicScan.form
index 47f94f8..b5b483f 100644
--- a/plugins/HarmonicScan.form
+++ b/plugins/HarmonicScan.form
@@ -20,21 +20,24 @@
-
-
+
+
+
-
+
-
-
+
+
+
+
@@ -62,7 +65,7 @@
-
+
@@ -85,9 +88,9 @@
-
+
-
+
@@ -112,20 +115,20 @@
-
+
-
+
-
+
@@ -149,15 +152,17 @@
-
-
-
-
-
-
+
+
+
+
+
+
+
+
@@ -250,5 +255,138 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/plugins/HarmonicScan.java b/plugins/HarmonicScan.java
index f8ecf66..e53c20e 100644
--- a/plugins/HarmonicScan.java
+++ b/plugins/HarmonicScan.java
@@ -3,12 +3,16 @@
*/
import ch.psi.pshell.core.Context.ContextStateException;
+import ch.psi.pshell.epics.Epics;
import ch.psi.pshell.ui.Panel;
+import ch.psi.utils.Chrono;
import ch.psi.utils.State;
import ch.psi.utils.swing.DsvEditor;
import ch.psi.utils.swing.Editor.EditorDialog;
import ch.psi.utils.swing.SwingUtils;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -29,6 +33,11 @@ public class HarmonicScan extends Panel {
@Override
public void onInitialize(int runCount) {
super.onInitialize(runCount);
+ try{
+ setElement();
+ } catch (Exception ex){
+ SwingUtils.showException(this, ex);
+ }
}
@Override
@@ -50,16 +59,20 @@ public class HarmonicScan extends Panel {
return Paths.get(getContext().getSetup().getConfigPath(), "harmonic_scan_energies.properties");
}
+ Path getOffsetTableFile() {
+ return Paths.get(getContext().getSetup().getConfigPath(), "harmonic_scan_offsets.properties");
+ }
+
@Override
public void setEnabled(boolean value) {
buttonExecute.setEnabled(value);
- comboSetup.setEnabled(value);
+ comboElement.setEnabled(value);
comboPolarizarion.setEnabled(value);
buttonConfigure.setEnabled(value);
}
void loadConfig() {
- DefaultComboBoxModel model = (DefaultComboBoxModel) comboSetup.getModel();
+ DefaultComboBoxModel model = (DefaultComboBoxModel) comboElement.getModel();
model.removeAllElements();
try {
for (String line : Files.readAllLines(getEnergyTableFile())) {
@@ -74,16 +87,29 @@ public class HarmonicScan extends Panel {
}
}
- void setElement() throws Exception {
+ void setElement() throws IOException {
Properties prop = new Properties();
prop.load(new FileInputStream(getEnergyTableFile().toFile()));
- String selection = comboSetup.getSelectedItem().toString();
- String val = prop.getProperty(selection);
+ String element = comboElement.getSelectedItem().toString();
+ String val = prop.getProperty(element);
String[] tokens = val.split(" ");
if (tokens.length != 1) {
- throw new Exception("Invalid file format: " + tokens.length);
+ throw new IOException("Invalid file format: " + tokens.length);
}
spinnerEnergy.setValue(Double.valueOf(tokens[0].trim()));
+
+ getOffsetTable();
+ }
+
+ void setPolarizarion() throws IOException {
+ getOffsetTable();
+ }
+
+
+ String getOffsetEntry(){
+ String element = comboElement.getSelectedItem().toString().trim();
+ String polarization = comboPolarizarion.getSelectedItem().toString().trim();
+ return element + "_" + polarization;
}
EditorDialog dlgConfig;
@@ -100,6 +126,41 @@ public class HarmonicScan extends Panel {
showWindow(dlgConfig);
}
+ void getOffsetTable() throws IOException{
+ textLastOffset.setText("");
+ textTimestamp.setText("");
+
+ try{
+ Properties prop = new Properties();
+ prop.load(new FileInputStream(getOffsetTableFile().toFile()));
+ String val = prop.getProperty(getOffsetEntry());
+ if ((val!=null)&& !val.isEmpty()){
+ String[] tokens = val.split(" ");
+ if (tokens.length != 3) {
+ throw new IOException("Invalid file format: " + tokens.length);
+ }
+ textLastOffset.setText(Double.valueOf(tokens[0].trim()).toString());
+ textTimestamp.setText(tokens[1].trim() + " " + tokens[2].trim());
+ }
+ } catch (FileNotFoundException ex){
+
+ }
+ }
+
+ void setOffsetTable(double offset) throws IOException{
+ Properties prop = new Properties();
+ String timestamp = Chrono.getTimeStr(System.currentTimeMillis(), "dd.MM.YY HH:mm") ;
+ prop.setProperty(getOffsetEntry(), offset + " " + timestamp );
+ try (FileOutputStream out = new FileOutputStream(getOffsetTableFile().toFile())) {
+ prop.store(out, null);
+ }
+
+
+ textLastOffset.setText(String.valueOf(offset));
+ textTimestamp.setText(timestamp);
+ }
+
+
void run() throws ContextStateException {
HashMap args = new HashMap();
args.put("ID_ENERGY", (Double) spinnerEnergy.getValue());
@@ -107,7 +168,12 @@ public class HarmonicScan extends Panel {
args.put("STEP", (Double) spinnerStep.getValue());
args.put("MODE ", comboPolarizarion.getSelectedItem().toString());
- runAsync("HarmonicScan", args);
+ runAsync("HarmonicScan", args).handle((ret, ex)-> {
+ if ((ex == null) && (ret!=null)){
+ textScanReturn.setText(String.valueOf(ret));
+ }
+ return ret;
+ });
}
@@ -117,7 +183,7 @@ public class HarmonicScan extends Panel {
buttonGroupPlot = new javax.swing.ButtonGroup();
jPanel1 = new javax.swing.JPanel();
- comboSetup = new javax.swing.JComboBox();
+ comboElement = new javax.swing.JComboBox();
buttonConfigure = new javax.swing.JButton();
jLabel10 = new javax.swing.JLabel();
jLabel11 = new javax.swing.JLabel();
@@ -131,12 +197,23 @@ public class HarmonicScan extends Panel {
jPanel3 = new javax.swing.JPanel();
buttonExecute = new javax.swing.JButton();
buttonAbort = new javax.swing.JButton();
+ jPanel2 = new javax.swing.JPanel();
+ jLabel5 = new javax.swing.JLabel();
+ textLastOffset = new javax.swing.JTextField();
+ textTimestamp = new javax.swing.JTextField();
+ jLabel4 = new javax.swing.JLabel();
+ buttonSet = new javax.swing.JButton();
+ jLabel6 = new javax.swing.JLabel();
+ valueOffset = new ch.psi.pshell.swing.DeviceValuePanel();
+ jLabel7 = new javax.swing.JLabel();
+ textScanReturn = new javax.swing.JTextField();
+ buttonApply = new javax.swing.JButton();
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Setup"));
- comboSetup.addActionListener(new java.awt.event.ActionListener() {
+ comboElement.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
- comboSetupActionPerformed(evt);
+ comboElementActionPerformed(evt);
}
});
@@ -151,7 +228,12 @@ public class HarmonicScan extends Panel {
jLabel11.setText("Polarization:");
- comboPolarizarion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Manual", "CIRC +", "CIRC -", "LINEAR H", "LINEAR V" }));
+ comboPolarizarion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "C+", "C-", "LH", "LV" }));
+ comboPolarizarion.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ comboPolarizarionActionPerformed(evt);
+ }
+ });
jLabel1.setText("Energy");
@@ -176,7 +258,7 @@ public class HarmonicScan extends Panel {
.addComponent(jLabel11, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(comboSetup, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(comboElement, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonConfigure, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(comboPolarizarion, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(80, 80, 80)
@@ -189,19 +271,19 @@ public class HarmonicScan extends Panel {
.addComponent(spinnerHalfwidth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addContainerGap(20, Short.MAX_VALUE))
);
- jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonConfigure, comboPolarizarion, comboSetup});
+ jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonConfigure, comboElement, comboPolarizarion});
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerEnergy, spinnerHalfwidth, spinnerStep});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
- .addContainerGap()
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(comboSetup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(comboElement, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel10)
.addComponent(jLabel1)
.addComponent(spinnerEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
@@ -220,7 +302,7 @@ public class HarmonicScan extends Panel {
.addComponent(comboPolarizarion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(spinnerStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(135, Short.MAX_VALUE))
+ .addGap(150, 150, 150))
);
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Scan Control"));
@@ -260,6 +342,94 @@ public class HarmonicScan extends Panel {
.addContainerGap())
);
+ jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Offset"));
+
+ jLabel5.setText("Timestamp:");
+
+ textLastOffset.setEditable(false);
+ textLastOffset.setHorizontalAlignment(javax.swing.JTextField.CENTER);
+
+ textTimestamp.setEditable(false);
+ textTimestamp.setHorizontalAlignment(javax.swing.JTextField.CENTER);
+
+ jLabel4.setText("Persisted Value:");
+
+ buttonSet.setText("Set");
+ buttonSet.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonSetActionPerformed(evt);
+ }
+ });
+
+ jLabel6.setText("Current:");
+
+ valueOffset.setDeviceName("pol_offset");
+
+ jLabel7.setText("Scan Return:");
+
+ textScanReturn.setEditable(false);
+ textScanReturn.setHorizontalAlignment(javax.swing.JTextField.CENTER);
+
+ buttonApply.setText("Apply");
+ buttonApply.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonApplyActionPerformed(evt);
+ }
+ });
+
+ javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
+ jPanel2.setLayout(jPanel2Layout);
+ jPanel2Layout.setHorizontalGroup(
+ jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel2Layout.createSequentialGroup()
+ .addGap(23, 23, 23)
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(jLabel5)
+ .addComponent(jLabel6)
+ .addComponent(jLabel4)
+ .addComponent(jLabel7))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel2Layout.createSequentialGroup()
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addComponent(textLastOffset, javax.swing.GroupLayout.DEFAULT_SIZE, 140, Short.MAX_VALUE)
+ .addComponent(textTimestamp))
+ .addGap(18, 18, 18)
+ .addComponent(buttonSet))
+ .addComponent(valueOffset, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGroup(jPanel2Layout.createSequentialGroup()
+ .addComponent(textScanReturn, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(18, 18, 18)
+ .addComponent(buttonApply)))
+ .addContainerGap(138, Short.MAX_VALUE))
+ );
+
+ jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonApply, buttonSet});
+
+ jPanel2Layout.setVerticalGroup(
+ jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel2Layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(valueOffset, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(18, 18, 18)
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel4)
+ .addComponent(textLastOffset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(buttonSet))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel5)
+ .addComponent(textTimestamp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(18, 18, 18)
+ .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(textScanReturn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel7)
+ .addComponent(buttonApply))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -268,14 +438,17 @@ public class HarmonicScan extends Panel {
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
- .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 157, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
@@ -283,6 +456,7 @@ public class HarmonicScan extends Panel {
private void buttonExecuteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExecuteActionPerformed
try {
+ textScanReturn.setText("");
run();
} catch (Exception ex) {
SwingUtils.showException(this, ex);
@@ -297,13 +471,13 @@ public class HarmonicScan extends Panel {
}
}//GEN-LAST:event_buttonAbortActionPerformed
- private void comboSetupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboSetupActionPerformed
+ private void comboElementActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboElementActionPerformed
try {
setElement();
} catch (Exception ex) {
SwingUtils.showException(this, ex);
}
- }//GEN-LAST:event_comboSetupActionPerformed
+ }//GEN-LAST:event_comboElementActionPerformed
private void buttonConfigureActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConfigureActionPerformed
try {
@@ -313,22 +487,57 @@ public class HarmonicScan extends Panel {
}
}//GEN-LAST:event_buttonConfigureActionPerformed
+ private void buttonSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetActionPerformed
+
+ try {
+ String ret = SwingUtils.getString(this, "Enter persisted value for " + getOffsetEntry(), textLastOffset.getText());
+ if ((ret!=null) && (!ret.trim().isEmpty()) ){
+ setOffsetTable(Double.valueOf(ret));
+ }
+ } catch (Exception ex) {
+ SwingUtils.showException(this, ex);
+ }
+ }//GEN-LAST:event_buttonSetActionPerformed
+
+ private void comboPolarizarionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboPolarizarionActionPerformed
+ try {
+ setPolarizarion();
+ } catch (Exception ex) {
+ SwingUtils.showException(this, ex);
+ }
+ }//GEN-LAST:event_comboPolarizarionActionPerformed
+
+ private void buttonApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonApplyActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_buttonApplyActionPerformed
+
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonAbort;
+ private javax.swing.JButton buttonApply;
private javax.swing.JButton buttonConfigure;
private javax.swing.JButton buttonExecute;
private javax.swing.ButtonGroup buttonGroupPlot;
+ private javax.swing.JButton buttonSet;
+ private javax.swing.JComboBox comboElement;
private javax.swing.JComboBox comboPolarizarion;
- private javax.swing.JComboBox comboSetup;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
+ private javax.swing.JLabel jLabel4;
+ private javax.swing.JLabel jLabel5;
+ private javax.swing.JLabel jLabel6;
+ private javax.swing.JLabel jLabel7;
private javax.swing.JPanel jPanel1;
+ private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JSpinner spinnerEnergy;
private javax.swing.JSpinner spinnerHalfwidth;
private javax.swing.JSpinner spinnerStep;
+ private javax.swing.JTextField textLastOffset;
+ private javax.swing.JTextField textScanReturn;
+ private javax.swing.JTextField textTimestamp;
+ private ch.psi.pshell.swing.DeviceValuePanel valueOffset;
// End of variables declaration//GEN-END:variables
}
diff --git a/script/HarmonicScan.py b/script/HarmonicScan.py
index 7f4387a..7537c57 100644
--- a/script/HarmonicScan.py
+++ b/script/HarmonicScan.py
@@ -14,35 +14,27 @@ try:
wait_device(energy_done, 1 )
sensors = [signal_i0, signal_tey, 'ca://X07MA-PC-K428:2:getTotalGain', energy]
- if MODE != "Manual":
- POL = MODE
- ALPHA = None
- if MODE == "LINEAR H":
- POL = "LINEAR"
- ALPHA = 0
- elif MODE == "LINEAR V":
- POL = "LINEAR"
- ALPHA = 90
- caput('X07MA-ID:MODE', POL)
- time.sleep(1.0)
- if POL == 'LINEAR':
- caput('X07MA-ID:ALPHA', ALPHA)
- wait_channel('X07MA-ID:DONE', 'DONE', type = 's')
-
+ if MODE =="C+":
+ set_pol_cplus()
+ if MODE =="C-":
+ set_pol_cminus()
+ if MODE == "LH":
+ set_pol_lin(0.0)
+ elif MODE == "LV":
+ set_pol_lin(90.0)
+
else:
sensors = [sin, energy]
- def before(position, scan):
- #wait_device(energy_done, 1 )
- sleep( 0.3 ) # Settling time
-
- #ret = lscan(energy, [signal_i0, signal_tey, 'ca://X07MA-PC-K428:2:getTotalGain', 'ca://X07MA-ID:MODE?type=d', pol_angle, current, energy, pol_offset, 'ca://X07MA-ID-GAP:READ','ca://X07MA-ID-SHIFT:READ'], ID_ENERGY-HALFWIDTH, ID_ENERGY+HALFWIDTH, STEP, before_read = before)
- ret = lscan(energy, sensors, ID_ENERGY-HALFWIDTH, ID_ENERGY+HALFWIDTH, STEP, before_read = before)
+ ret = lscan(energy, sensors, ID_ENERGY-HALFWIDTH, ID_ENERGY+HALFWIDTH, STEP, latency = 0.3)
+
xdata = ret.getPositions(0)
ydata = ret.getReadable(0)
ymin = min(ydata)
- xminmin = xdata[ydata.index(min(ydata))]
- print "Emin=",xminmin,"ymin = ",ymin
+ e0 = xdata[ydata.index(min(ydata))]
+ new_offset =ID_ENERGY – e0 + pol_offset.take()
+
+ set_return(new_offset);
except:
print("Aborting...")