diff --git a/config/config.properties b/config/config.properties
index 0f0fa95..c1605ae 100644
--- a/config/config.properties
+++ b/config/config.properties
@@ -1,4 +1,4 @@
-#Wed Mar 06 10:25:41 CET 2019
+#Tue Mar 19 08:24:54 CET 2019
autoSaveScanData=true
commandExecutionEvents=false
createSessionFiles=false
@@ -12,6 +12,7 @@ dataServerPort=-1
depthDimension=0
devicePoolFile={config}/devices.properties
deviceUpdateStrategyFile={config}/update.properties
+hideServerMessages=false
hostName=null
imageSourcesFile={config}/imaging.properties
instanceName=
diff --git a/plugins/DelayScanBase.form b/plugins/DelayScanBase.form
new file mode 100644
index 0000000..84fb992
--- /dev/null
+++ b/plugins/DelayScanBase.form
@@ -0,0 +1,429 @@
+
+
+
diff --git a/plugins/DelayScanBase.java b/plugins/DelayScanBase.java
new file mode 100644
index 0000000..998da70
--- /dev/null
+++ b/plugins/DelayScanBase.java
@@ -0,0 +1,449 @@
+/*
+ * Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
+ */
+
+import java.awt.Component;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.logging.Level;
+import javax.swing.JLabel;
+import ch.psi.utils.State;
+import ch.psi.utils.swing.Editor.EditorDialog;
+import ch.psi.pshell.plot.LinePlotBase;
+import ch.psi.pshell.plot.LinePlotSeries;
+import ch.psi.pshell.ui.Panel;
+import java.util.logging.Logger;
+
+
+/**
+ *
+ */
+public class DelayScanBase extends Panel {
+
+ public DelayScanBase() {
+ initComponents();
+ }
+
+ double energyCache = 0;
+ boolean restart;
+
+ @Override
+ public void onStateChange(State state, State former) {
+ setEnabled(state == State.Ready);
+ }
+
+ @Override
+ public void onExecutedFile(String fileName, Object result) {
+ }
+
+ boolean otf;
+
+ void stopScan() {
+ try {
+ getLogger().info("Stopping scan");
+ evalAsync("caput('START', 'STOP')");
+ } catch (Exception ex) {
+ getLogger().log(Level.WARNING, null, ex);
+ }
+ }
+
+ Path getConfigFile() {
+ return Paths.get(getContext().getSetup().getConfigPath(), "energy_scan.properties");
+ }
+
+ LinePlotBase scanPlot;
+ LinePlotSeries scanSeries;
+
+ @Override
+ public void setEnabled(boolean value) {
+ super.setEnabled(value);
+ buttonExecute.setEnabled(value);
+ //buttonPlot.setEnabled(value);
+ checkParameterControls();
+ }
+
+ void checkParameterControls() {
+ boolean enabled;
+ enabled = isEnabled();
+ for (Component c : panelParameters.getComponents()) {
+ if (!(c instanceof JLabel)) {
+ c.setEnabled(enabled);
+ }
+ }
+
+ //spinnerAlpha.setEnabled(enabled && comboMode.getSelectedItem().equals("LINEAR"));
+ }
+
+ double last = 0;
+
+ void run() throws Exception {
+ HashMap args = new HashMap();
+ args.put("START",(Double) spinnerStart.getValue());
+ args.put("DELAY", (Double) spinnerDelay.getValue());
+ args.put("END", (Double) spinnerEnd.getValue());
+ args.put("FINEDELAY", (Double) spinnerFineDelay.getValue());
+ args.put("STEP", (Double) spinnerSize.getValue());
+ args.put("OFFSET1", (Double) spinnerOffset1.getValue());
+ args.put("OFFSET2", (Double) spinnerOffset2.getValue());
+ args.put("ACQTIME", (Double) spinnerAcqTime.getValue());
+ args.put("ENERGIES", jTextField1.getText());
+ args.put("RUNTYPE", comboRunType.getSelectedItem().toString());
+ args.put("ROUNDS", (Integer) spinnerRounds.getValue());
+ args.put("PATH", jTextField2.getText());
+
+ buttonAbort.setEnabled(true);
+
+ runAsync("DelayScan", args).handle((ok, ex) -> {
+ try {
+ buttonAbort.setEnabled(false);
+ if (ex != null) {
+ throw ex;
+ } else {
+ }
+ } catch (Throwable t) {
+ getLogger().log(Level.WARNING, null, ex);
+ //showException((Exception)ex);
+ }
+ return ok;
+ });
+ }
+
+ @SuppressWarnings("unchecked")
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ buttonGroupPlot = new javax.swing.ButtonGroup();
+ buttonGroup1 = new javax.swing.ButtonGroup();
+ panelParameters = new javax.swing.JPanel();
+ jLabel1 = new javax.swing.JLabel();
+ spinnerStart = new javax.swing.JSpinner();
+ jLabel2 = new javax.swing.JLabel();
+ spinnerDelay = new javax.swing.JSpinner();
+ jLabel3 = new javax.swing.JLabel();
+ spinnerEnd = new javax.swing.JSpinner();
+ jLabel4 = new javax.swing.JLabel();
+ spinnerFineDelay = new javax.swing.JSpinner();
+ jLabel8 = new javax.swing.JLabel();
+ spinnerSize = new javax.swing.JSpinner();
+ jLabel13 = new javax.swing.JLabel();
+ spinnerOffset2 = new javax.swing.JSpinner();
+ jTextField1 = new javax.swing.JTextField();
+ jLabel16 = new javax.swing.JLabel();
+ jLabel17 = new javax.swing.JLabel();
+ jLabel11 = new javax.swing.JLabel();
+ comboRunType = new javax.swing.JComboBox();
+ spinnerRounds = new javax.swing.JSpinner();
+ jLabel5 = new javax.swing.JLabel();
+ spinnerOffset1 = new javax.swing.JSpinner();
+ spinnerAcqTime = new javax.swing.JSpinner();
+ jLabel18 = new javax.swing.JLabel();
+ jPanel3 = new javax.swing.JPanel();
+ buttonExecute = new javax.swing.JButton();
+ buttonAbort = new javax.swing.JButton();
+ panelSetup = new javax.swing.JPanel();
+ jLabel10 = new javax.swing.JLabel();
+ jTextField2 = new javax.swing.JTextField();
+
+ panelParameters.setBorder(javax.swing.BorderFactory.createTitledBorder("Parameters"));
+
+ jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel1.setText("Delay start (ns):");
+
+ spinnerStart.setModel(new javax.swing.SpinnerNumberModel(Double.valueOf(0.0d), null, null, Double.valueOf(1.0d)));
+
+ jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel2.setText("LPP delay at t=0");
+
+ spinnerDelay.setModel(new javax.swing.SpinnerNumberModel(Double.valueOf(0.0d), null, null, Double.valueOf(1.0d)));
+
+ jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel3.setText("Delay end (ns):");
+
+ spinnerEnd.setModel(new javax.swing.SpinnerNumberModel(Double.valueOf(50.0d), null, null, Double.valueOf(1.0d)));
+
+ jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel4.setText("LPP fine delay at t=0");
+
+ spinnerFineDelay.setModel(new javax.swing.SpinnerNumberModel(10.0d, 0.0d, 600.0d, 1.0d));
+
+ jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel8.setText("Step size (ns):");
+
+ spinnerSize.setModel(new javax.swing.SpinnerNumberModel(Double.valueOf(1.0d), null, null, Double.valueOf(1.0d)));
+
+ jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel13.setText("Offset2:");
+
+ spinnerOffset2.setModel(new javax.swing.SpinnerNumberModel(0.0d, -20.0d, 20.0d, 1.0d));
+
+ jTextField1.setText("800, 780");
+ jTextField1.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jTextField1ActionPerformed(evt);
+ }
+ });
+
+ jLabel16.setText("Energies:");
+
+ jLabel17.setText("Offset1:");
+
+ jLabel11.setText("Run Type:");
+
+ comboRunType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "+/-", "+,-", "+", "-", "LH/LV", "LH,LV", "LH", "LV" }));
+
+ spinnerRounds.setModel(new javax.swing.SpinnerNumberModel(1, 1, 10, 1));
+
+ jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel5.setText("Nb of repetitions:");
+
+ spinnerOffset1.setModel(new javax.swing.SpinnerNumberModel(0.0d, -20.0d, 20.0d, 1.0d));
+
+ spinnerAcqTime.setModel(new javax.swing.SpinnerNumberModel(0.0d, -20.0d, 20.0d, 1.0d));
+
+ jLabel18.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel18.setText("Acquisition time (s):");
+
+ javax.swing.GroupLayout panelParametersLayout = new javax.swing.GroupLayout(panelParameters);
+ panelParameters.setLayout(panelParametersLayout);
+ panelParametersLayout.setHorizontalGroup(
+ panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelParametersLayout.createSequentialGroup()
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addGroup(panelParametersLayout.createSequentialGroup()
+ .addComponent(jLabel16)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jLabel11)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(comboRunType, javax.swing.GroupLayout.PREFERRED_SIZE, 58, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panelParametersLayout.createSequentialGroup()
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelParametersLayout.createSequentialGroup()
+ .addComponent(jLabel17)
+ .addGap(6, 6, 6)
+ .addComponent(spinnerOffset1, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(22, 22, 22)
+ .addComponent(jLabel13)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(spinnerOffset2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(panelParametersLayout.createSequentialGroup()
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jLabel1)
+ .addComponent(jLabel3)
+ .addComponent(jLabel8))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(spinnerSize, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(spinnerEnd, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(spinnerStart, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(jLabel4)
+ .addComponent(jLabel2)
+ .addComponent(jLabel18))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
+ .addComponent(spinnerAcqTime, javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(spinnerFineDelay, javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(spinnerDelay))
+ .addGap(0, 0, Short.MAX_VALUE))
+ .addGroup(javax.swing.GroupLayout.Alignment.LEADING, panelParametersLayout.createSequentialGroup()
+ .addComponent(jLabel5)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(spinnerRounds)))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
+ panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel2, jLabel4});
+
+ panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerOffset2, spinnerRounds});
+
+ panelParametersLayout.setVerticalGroup(
+ panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelParametersLayout.createSequentialGroup()
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel1)
+ .addComponent(spinnerStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel2)
+ .addComponent(spinnerDelay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel3)
+ .addComponent(spinnerEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel4)
+ .addComponent(spinnerFineDelay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel8)
+ .addComponent(spinnerSize)
+ .addComponent(jLabel18)
+ .addComponent(spinnerAcqTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel11)
+ .addComponent(comboRunType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel16)
+ .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(spinnerRounds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel5))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel17)
+ .addComponent(spinnerOffset1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel13)
+ .addComponent(spinnerOffset2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ );
+
+ jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Scan Control"));
+
+ buttonExecute.setText("Start");
+ buttonExecute.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonExecuteActionPerformed(evt);
+ }
+ });
+
+ buttonAbort.setText("Abort");
+ buttonAbort.setEnabled(false);
+ buttonAbort.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonAbortActionPerformed(evt);
+ }
+ });
+
+ javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
+ jPanel3.setLayout(jPanel3Layout);
+ jPanel3Layout.setHorizontalGroup(
+ jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel3Layout.createSequentialGroup()
+ .addGap(115, 115, 115)
+ .addComponent(buttonExecute, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(49, 49, 49)
+ .addComponent(buttonAbort, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+ jPanel3Layout.setVerticalGroup(
+ jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(buttonExecute)
+ .addComponent(buttonAbort))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
+ panelSetup.setBorder(javax.swing.BorderFactory.createTitledBorder("Setup"));
+
+ jLabel10.setText("Saving path");
+
+ jTextField2.setText("/sls/X11MA/data/X11MA/Desktop/");
+ jTextField2.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jTextField2ActionPerformed(evt);
+ }
+ });
+
+ javax.swing.GroupLayout panelSetupLayout = new javax.swing.GroupLayout(panelSetup);
+ panelSetup.setLayout(panelSetupLayout);
+ panelSetupLayout.setHorizontalGroup(
+ panelSetupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelSetupLayout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(jLabel10)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jTextField2))
+ );
+ panelSetupLayout.setVerticalGroup(
+ panelSetupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelSetupLayout.createSequentialGroup()
+ .addGap(7, 7, 7)
+ .addGroup(panelSetupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel10)
+ .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addContainerGap(17, Short.MAX_VALUE))
+ );
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(panelParameters, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(panelSetup, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(panelParameters, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(panelSetup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+ }// //GEN-END:initComponents
+
+ private void buttonExecuteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExecuteActionPerformed
+ try {
+ run();
+ } catch (Exception ex) {
+ showException(ex);
+ }
+ }//GEN-LAST:event_buttonExecuteActionPerformed
+
+ private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed
+ try {
+ abort();
+ } catch (InterruptedException ex) {
+ Logger.getLogger(DelayScan.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }//GEN-LAST:event_buttonAbortActionPerformed
+
+ private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_jTextField1ActionPerformed
+
+ private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_jTextField2ActionPerformed
+
+ EditorDialog dlgConfig;
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton buttonAbort;
+ private javax.swing.JButton buttonExecute;
+ private javax.swing.ButtonGroup buttonGroup1;
+ private javax.swing.ButtonGroup buttonGroupPlot;
+ private javax.swing.JComboBox comboRunType;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel10;
+ private javax.swing.JLabel jLabel11;
+ private javax.swing.JLabel jLabel13;
+ private javax.swing.JLabel jLabel16;
+ private javax.swing.JLabel jLabel17;
+ private javax.swing.JLabel jLabel18;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JLabel jLabel3;
+ private javax.swing.JLabel jLabel4;
+ private javax.swing.JLabel jLabel5;
+ private javax.swing.JLabel jLabel8;
+ private javax.swing.JPanel jPanel3;
+ private javax.swing.JTextField jTextField1;
+ private javax.swing.JTextField jTextField2;
+ private javax.swing.JPanel panelParameters;
+ private javax.swing.JPanel panelSetup;
+ private javax.swing.JSpinner spinnerAcqTime;
+ private javax.swing.JSpinner spinnerDelay;
+ private javax.swing.JSpinner spinnerEnd;
+ private javax.swing.JSpinner spinnerFineDelay;
+ private javax.swing.JSpinner spinnerOffset1;
+ private javax.swing.JSpinner spinnerOffset2;
+ private javax.swing.JSpinner spinnerRounds;
+ private javax.swing.JSpinner spinnerSize;
+ private javax.swing.JSpinner spinnerStart;
+ // End of variables declaration//GEN-END:variables
+}
diff --git a/plugins/EnergyScan.form b/plugins/EnergyScan.form
index 43771bc..82dd9eb 100644
--- a/plugins/EnergyScan.form
+++ b/plugins/EnergyScan.form
@@ -694,9 +694,6 @@
-
-
-
@@ -708,9 +705,6 @@
-
-
-
@@ -726,9 +720,6 @@
-
-
-
diff --git a/plugins/EnergyScanBase.form b/plugins/EnergyScanBase.form
new file mode 100644
index 0000000..2e7c82a
--- /dev/null
+++ b/plugins/EnergyScanBase.form
@@ -0,0 +1,423 @@
+
+
+
diff --git a/plugins/EnergyScanBase.java b/plugins/EnergyScanBase.java
new file mode 100644
index 0000000..5341a88
--- /dev/null
+++ b/plugins/EnergyScanBase.java
@@ -0,0 +1,463 @@
+/*
+ * Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
+ */
+
+import java.awt.Component;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.logging.Level;
+import javax.swing.JLabel;
+import ch.psi.utils.State;
+import ch.psi.utils.swing.Editor.EditorDialog;
+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 java.util.logging.Logger;
+
+/**
+ *
+ */
+public class EnergyScanBase extends Panel {
+
+ public EnergyScanBase() {
+ initComponents();
+ }
+
+ double energyCache = 0;
+ boolean restart;
+
+ @Override
+ public void onInitialize(int runCount) {
+ super.onInitialize(runCount);
+ }
+
+ @Override
+ public void onStateChange(State state, State former) {
+ setEnabled(state == State.Ready);
+ }
+
+ @Override
+ public void onExecutedFile(String fileName, Object result) {
+ }
+
+ boolean otf;
+
+ void stopScan() {
+ try {
+ getLogger().info("Stopping scan");
+ evalAsync("caput('START', 'STOP')");
+ } catch (Exception ex) {
+ getLogger().log(Level.WARNING, null, ex);
+ }
+ }
+
+ Path getConfigFile() {
+ return Paths.get(getContext().getSetup().getConfigPath(), "energy_scan.properties");
+ }
+
+ LinePlotBase scanPlot;
+ LinePlotSeries scanSeries;
+
+ @Override
+ public void setEnabled(boolean value) {
+ super.setEnabled(value);
+ buttonExecute.setEnabled(value);
+ //buttonPlot.setEnabled(value);
+ checkParameterControls();
+ }
+
+ void checkParameterControls() {
+ boolean enabled;
+ enabled = isEnabled();
+ for (Component c : panelParameters.getComponents()) {
+ if (!(c instanceof JLabel)) {
+ c.setEnabled(enabled);
+ }
+ }
+ for (Component c : panelSetup.getComponents()) {
+ if (!(c instanceof JLabel)) {
+ c.setEnabled(enabled);
+ }
+ }
+
+ //spinnerAlpha.setEnabled(enabled && comboMode.getSelectedItem().equals("LINEAR"));
+ }
+
+ double last = 0;
+
+ void run() throws Exception {
+ HashMap args = new HashMap();
+ Double e1 = (Double) spinnerE1.getValue();
+ Double e2 = (Double) spinnerE2.getValue();
+ args.put("E1", e1);
+ args.put("E2", e2);
+ args.put("TIME", (Double) spinnerTime.getValue());
+ args.put("DELAY", (Double) spinnerDelay.getValue());
+ 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("PLOT_TYPE", radioK1.isSelected() ? 1 : 2);
+ args.put("PATH", jTextField2.getText());
+
+
+ buttonAbort.setEnabled(true);
+
+ runAsync("EnergyScanBasic", args).handle((ok, ex) -> {
+ try {
+ buttonAbort.setEnabled(false);
+ if (ex != null) {
+ throw ex;
+ } else {
+ }
+ } catch (Throwable t) {
+ getLogger().log(Level.WARNING, null, ex);
+ //showException((Exception)ex);
+ }
+ return ok;
+ });
+
+ if (scanPlot != null) {
+ scanPlot.getAxis(Plot.AxisId.X).setRange(Math.min(e1, e2), Math.max(e1, e2));
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ buttonGroupPlot = new javax.swing.ButtonGroup();
+ buttonGroup1 = new javax.swing.ButtonGroup();
+ buttonGroup2 = new javax.swing.ButtonGroup();
+ panelParameters = new javax.swing.JPanel();
+ jLabel1 = new javax.swing.JLabel();
+ spinnerE1 = new javax.swing.JSpinner();
+ jLabel2 = new javax.swing.JLabel();
+ spinnerE2 = new javax.swing.JSpinner();
+ jLabel3 = new javax.swing.JLabel();
+ spinnerTime = new javax.swing.JSpinner();
+ jLabel4 = new javax.swing.JLabel();
+ spinnerDelay = new javax.swing.JSpinner();
+ jLabel8 = new javax.swing.JLabel();
+ spinnerOffset1 = new javax.swing.JSpinner();
+ jLabel13 = new javax.swing.JLabel();
+ spinnerOffset2 = new javax.swing.JSpinner();
+ jLabel11 = new javax.swing.JLabel();
+ comboRunType = new javax.swing.JComboBox();
+ jLabel5 = new javax.swing.JLabel();
+ spinnerRounds = new javax.swing.JSpinner();
+ jLabel12 = new javax.swing.JLabel();
+ radioK1 = new javax.swing.JRadioButton();
+ radioK3 = new javax.swing.JRadioButton();
+ panelSetup = new javax.swing.JPanel();
+ jLabel10 = new javax.swing.JLabel();
+ jTextField2 = new javax.swing.JTextField();
+ jPanel3 = new javax.swing.JPanel();
+ buttonExecute = new javax.swing.JButton();
+ buttonAbort = new javax.swing.JButton();
+
+ panelParameters.setBorder(javax.swing.BorderFactory.createTitledBorder("Parameters"));
+
+ jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel1.setText("E start:");
+ jLabel1.setToolTipText("");
+
+ spinnerE1.setModel(new javax.swing.SpinnerNumberModel(680.0d, 0.0d, 9999.0d, 1.0d));
+
+ jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel2.setText("E end:");
+ jLabel2.setToolTipText("");
+
+ spinnerE2.setModel(new javax.swing.SpinnerNumberModel(750.0d, 0.0d, 9999.0d, 1.0d));
+
+ jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel3.setText("Time(min):");
+
+ spinnerTime.setModel(new javax.swing.SpinnerNumberModel(2.0d, 0.0d, 60.0d, 1.0d));
+
+ jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel4.setText("Delay(s):");
+
+ spinnerDelay.setModel(new javax.swing.SpinnerNumberModel(10.0d, 0.0d, 600.0d, 1.0d));
+
+ jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel8.setText("Offset1:");
+
+ spinnerOffset1.setModel(new javax.swing.SpinnerNumberModel(0.0d, -20.0d, 20.0d, 1.0d));
+
+ jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel13.setText("Offset2:");
+
+ spinnerOffset2.setModel(new javax.swing.SpinnerNumberModel(0.0d, -20.0d, 20.0d, 1.0d));
+
+ jLabel11.setText("Run Type:");
+
+ comboRunType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "+/-", "+", "-", "LH/LV", "LH", "LV" }));
+
+ jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel5.setText("Nb of repetitions");
+ jLabel5.setToolTipText("");
+
+ spinnerRounds.setModel(new javax.swing.SpinnerNumberModel(1, 1, 10, 1));
+
+ jLabel12.setText("Plot Type:");
+
+ buttonGroupPlot.add(radioK1);
+ radioK1.setText("K2 / K1");
+ radioK1.setMinimumSize(new java.awt.Dimension(100, 22));
+ radioK1.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ radioK1ActionPerformed(evt);
+ }
+ });
+
+ buttonGroupPlot.add(radioK3);
+ radioK3.setText("K2 / K3");
+
+ javax.swing.GroupLayout panelParametersLayout = new javax.swing.GroupLayout(panelParameters);
+ panelParameters.setLayout(panelParametersLayout);
+ panelParametersLayout.setHorizontalGroup(
+ panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelParametersLayout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelParametersLayout.createSequentialGroup()
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelParametersLayout.createSequentialGroup()
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addGroup(panelParametersLayout.createSequentialGroup()
+ .addComponent(jLabel8)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(spinnerOffset1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(panelParametersLayout.createSequentialGroup()
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .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, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
+ .addGroup(panelParametersLayout.createSequentialGroup()
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(jLabel13, javax.swing.GroupLayout.Alignment.TRAILING))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(spinnerE2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(spinnerDelay, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addComponent(spinnerOffset2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
+ .addGroup(panelParametersLayout.createSequentialGroup()
+ .addComponent(jLabel11)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(comboRunType, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 68, Short.MAX_VALUE)
+ .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(67, Short.MAX_VALUE))
+ .addGroup(panelParametersLayout.createSequentialGroup()
+ .addComponent(jLabel12)
+ .addGap(18, 18, 18)
+ .addComponent(radioK1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addGap(18, 18, 18)
+ .addComponent(radioK3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
+ );
+
+ panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerE1, spinnerTime});
+
+ panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel2, jLabel4, jLabel8});
+
+ panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerDelay, spinnerE2, spinnerOffset1, spinnerOffset2, spinnerRounds});
+
+ panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {radioK1, radioK3});
+
+ panelParametersLayout.setVerticalGroup(
+ panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelParametersLayout.createSequentialGroup()
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel1)
+ .addComponent(spinnerE1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel2)
+ .addComponent(spinnerE2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel3)
+ .addComponent(spinnerTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel4)
+ .addComponent(spinnerDelay, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel8)
+ .addComponent(spinnerOffset1)
+ .addComponent(jLabel13)
+ .addComponent(spinnerOffset2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(35, 35, 35)
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(comboRunType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel11)
+ .addComponent(jLabel5)
+ .addComponent(spinnerRounds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGap(20, 20, 20)
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel12)
+ .addComponent(radioK1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(radioK3))
+ .addContainerGap())
+ );
+
+ panelSetup.setBorder(javax.swing.BorderFactory.createTitledBorder("Setup"));
+
+ jLabel10.setText("Saving path");
+
+ jTextField2.setText("/sls/X11MA/data/X11MA/Desktop/");
+ jTextField2.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ jTextField2ActionPerformed(evt);
+ }
+ });
+
+ javax.swing.GroupLayout panelSetupLayout = new javax.swing.GroupLayout(panelSetup);
+ panelSetup.setLayout(panelSetupLayout);
+ panelSetupLayout.setHorizontalGroup(
+ panelSetupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelSetupLayout.createSequentialGroup()
+ .addContainerGap()
+ .addComponent(jLabel10)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jTextField2))
+ );
+ panelSetupLayout.setVerticalGroup(
+ panelSetupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelSetupLayout.createSequentialGroup()
+ .addGap(7, 7, 7)
+ .addGroup(panelSetupLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel10)
+ .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
+ jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Scan Control"));
+
+ buttonExecute.setText("Start");
+ buttonExecute.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonExecuteActionPerformed(evt);
+ }
+ });
+
+ buttonAbort.setText("Abort");
+ buttonAbort.setEnabled(false);
+ buttonAbort.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonAbortActionPerformed(evt);
+ }
+ });
+
+ javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
+ jPanel3.setLayout(jPanel3Layout);
+ jPanel3Layout.setHorizontalGroup(
+ jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel3Layout.createSequentialGroup()
+ .addGap(38, 38, 38)
+ .addComponent(buttonExecute, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(48, 48, 48)
+ .addComponent(buttonAbort, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+ jPanel3Layout.setVerticalGroup(
+ jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(buttonExecute)
+ .addComponent(buttonAbort))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(panelParameters, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addGroup(layout.createSequentialGroup()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(panelSetup, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ .addGap(0, 0, 0))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGap(16, 16, 16)
+ .addComponent(panelParameters, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
+ .addComponent(panelSetup, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap())
+ );
+ }// //GEN-END:initComponents
+
+ private void radioK1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioK1ActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_radioK1ActionPerformed
+
+ private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed
+ try {
+ abort();
+ } catch (InterruptedException ex) {
+ Logger.getLogger(EnergyScan.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }//GEN-LAST:event_buttonAbortActionPerformed
+
+ private void buttonExecuteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExecuteActionPerformed
+ try {
+ run();
+ } catch (Exception ex) {
+ showException(ex);
+ }
+ }//GEN-LAST:event_buttonExecuteActionPerformed
+
+ private void jTextField2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField2ActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_jTextField2ActionPerformed
+
+ EditorDialog dlgConfig;
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton buttonAbort;
+ private javax.swing.JButton buttonExecute;
+ private javax.swing.ButtonGroup buttonGroup1;
+ private javax.swing.ButtonGroup buttonGroup2;
+ private javax.swing.ButtonGroup buttonGroupPlot;
+ private javax.swing.JComboBox comboRunType;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel10;
+ private javax.swing.JLabel jLabel11;
+ private javax.swing.JLabel jLabel12;
+ private javax.swing.JLabel jLabel13;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JLabel jLabel3;
+ private javax.swing.JLabel jLabel4;
+ private javax.swing.JLabel jLabel5;
+ private javax.swing.JLabel jLabel8;
+ private javax.swing.JPanel jPanel3;
+ private javax.swing.JTextField jTextField2;
+ private javax.swing.JPanel panelParameters;
+ private javax.swing.JPanel panelSetup;
+ private javax.swing.JRadioButton radioK1;
+ private javax.swing.JRadioButton radioK3;
+ private javax.swing.JSpinner spinnerDelay;
+ private javax.swing.JSpinner spinnerE1;
+ private javax.swing.JSpinner spinnerE2;
+ private javax.swing.JSpinner spinnerOffset1;
+ private javax.swing.JSpinner spinnerOffset2;
+ private javax.swing.JSpinner spinnerRounds;
+ private javax.swing.JSpinner spinnerTime;
+ // End of variables declaration//GEN-END:variables
+}
diff --git a/plugins/OTFScanBase.form b/plugins/OTFScanBase.form
new file mode 100644
index 0000000..07a34c4
--- /dev/null
+++ b/plugins/OTFScanBase.form
@@ -0,0 +1,238 @@
+
+
+
diff --git a/plugins/OTFScanBase.java b/plugins/OTFScanBase.java
new file mode 100644
index 0000000..0984e3a
--- /dev/null
+++ b/plugins/OTFScanBase.java
@@ -0,0 +1,313 @@
+/*
+ * Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
+ */
+
+import java.awt.Component;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.logging.Level;
+import javax.swing.JLabel;
+import ch.psi.utils.State;
+import ch.psi.utils.swing.Editor.EditorDialog;
+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 java.util.logging.Logger;
+
+/**
+ *
+ */
+public class OTFScanBase extends Panel {
+
+ public OTFScanBase() {
+ initComponents();
+ }
+
+ double energyCache = 0;
+ boolean restart;
+
+ @Override
+ public void onInitialize(int runCount) {
+ super.onInitialize(runCount);
+ }
+
+ @Override
+ public void onStateChange(State state, State former) {
+ setEnabled(state == State.Ready);
+ }
+
+ @Override
+ public void onExecutedFile(String fileName, Object result) {
+ }
+
+ boolean otf;
+
+ void stopScan() {
+ try {
+ getLogger().info("Stopping scan");
+ evalAsync("caput('START', 'STOP')");
+ } catch (Exception ex) {
+ getLogger().log(Level.WARNING, null, ex);
+ }
+ }
+
+ Path getConfigFile() {
+ return Paths.get(getContext().getSetup().getConfigPath(), "energy_scan.properties");
+ }
+
+ LinePlotBase scanPlot;
+ LinePlotSeries scanSeries;
+
+ @Override
+ public void setEnabled(boolean value) {
+ super.setEnabled(value);
+ buttonExecute.setEnabled(value);
+ //buttonPlot.setEnabled(value);
+ checkParameterControls();
+ }
+
+ void checkParameterControls() {
+ boolean enabled;
+ enabled = isEnabled();
+ for (Component c : panelParameters.getComponents()) {
+ if (!(c instanceof JLabel)) {
+ c.setEnabled(enabled);
+ }
+ }
+ //spinnerAlpha.setEnabled(enabled && comboMode.getSelectedItem().equals("LINEAR"));
+ }
+
+ double last = 0;
+
+ void run() throws Exception {
+ HashMap args = new HashMap();
+ Double e1 = (Double) spinnerE1.getValue();
+ Double e2 = (Double) spinnerE2.getValue();
+ args.put("E1", e1);
+ args.put("E2", e2);
+ args.put("TIME", (Double) spinnerTime.getValue());
+
+
+ buttonAbort.setEnabled(true);
+
+ runAsync("OTFScanBasic", args).handle((ok, ex) -> {
+ try {
+ buttonAbort.setEnabled(false);
+ if (ex != null) {
+ throw ex;
+ } else {
+ }
+ } catch (Throwable t) {
+ getLogger().log(Level.WARNING, null, ex);
+ //showException((Exception)ex);
+ }
+ return ok;
+ });
+
+ if (scanPlot != null) {
+ scanPlot.getAxis(Plot.AxisId.X).setRange(Math.min(e1, e2), Math.max(e1, e2));
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ // //GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ buttonGroupPlot = new javax.swing.ButtonGroup();
+ buttonGroup1 = new javax.swing.ButtonGroup();
+ buttonGroup2 = new javax.swing.ButtonGroup();
+ panelParameters = new javax.swing.JPanel();
+ jLabel1 = new javax.swing.JLabel();
+ spinnerE1 = new javax.swing.JSpinner();
+ jLabel2 = new javax.swing.JLabel();
+ spinnerE2 = new javax.swing.JSpinner();
+ jLabel3 = new javax.swing.JLabel();
+ spinnerTime = new javax.swing.JSpinner();
+ jLabel12 = new javax.swing.JLabel();
+ radioK1 = new javax.swing.JRadioButton();
+ radioK3 = new javax.swing.JRadioButton();
+ jPanel3 = new javax.swing.JPanel();
+ buttonExecute = new javax.swing.JButton();
+ buttonAbort = new javax.swing.JButton();
+
+ panelParameters.setBorder(javax.swing.BorderFactory.createTitledBorder("Parameters"));
+
+ jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel1.setText("E start:");
+ jLabel1.setToolTipText("");
+
+ spinnerE1.setModel(new javax.swing.SpinnerNumberModel(680.0d, 0.0d, 9999.0d, 1.0d));
+
+ jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel2.setText("E end:");
+ jLabel2.setToolTipText("");
+
+ spinnerE2.setModel(new javax.swing.SpinnerNumberModel(750.0d, 0.0d, 9999.0d, 1.0d));
+
+ jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
+ jLabel3.setText("Time(min):");
+
+ spinnerTime.setModel(new javax.swing.SpinnerNumberModel(2.0d, 0.0d, 60.0d, 1.0d));
+
+ jLabel12.setText("Plot Type:");
+
+ buttonGroupPlot.add(radioK1);
+ radioK1.setText("K2 / K1");
+ radioK1.setMinimumSize(new java.awt.Dimension(100, 22));
+ radioK1.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ radioK1ActionPerformed(evt);
+ }
+ });
+
+ buttonGroupPlot.add(radioK3);
+ radioK3.setText("K2 / K3");
+
+ javax.swing.GroupLayout panelParametersLayout = new javax.swing.GroupLayout(panelParameters);
+ panelParameters.setLayout(panelParametersLayout);
+ panelParametersLayout.setHorizontalGroup(
+ panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelParametersLayout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
+ .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .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, 20, Short.MAX_VALUE)
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelParametersLayout.createSequentialGroup()
+ .addComponent(jLabel2)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(spinnerE2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelParametersLayout.createSequentialGroup()
+ .addComponent(jLabel12)
+ .addGap(18, 18, 18)
+ .addComponent(radioK1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addGap(18, 18, 18)
+ .addComponent(radioK3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
+ .addContainerGap(39, Short.MAX_VALUE))
+ );
+
+ panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerE1, spinnerTime});
+
+ panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {radioK1, radioK3});
+
+ panelParametersLayout.setVerticalGroup(
+ panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(panelParametersLayout.createSequentialGroup()
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel1)
+ .addComponent(spinnerE1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(jLabel2)
+ .addComponent(spinnerE2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel3)
+ .addComponent(spinnerTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(jLabel12)
+ .addComponent(radioK1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addComponent(radioK3))))
+ );
+
+ jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Scan Control"));
+
+ buttonExecute.setText("Start");
+ buttonExecute.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonExecuteActionPerformed(evt);
+ }
+ });
+
+ buttonAbort.setText("Abort");
+ buttonAbort.setEnabled(false);
+ buttonAbort.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ buttonAbortActionPerformed(evt);
+ }
+ });
+
+ javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
+ jPanel3.setLayout(jPanel3Layout);
+ jPanel3Layout.setHorizontalGroup(
+ jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(jPanel3Layout.createSequentialGroup()
+ .addGap(106, 106, 106)
+ .addComponent(buttonExecute, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(48, 48, 48)
+ .addComponent(buttonAbort, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+ jPanel3Layout.setVerticalGroup(
+ jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
+ .addComponent(buttonExecute)
+ .addComponent(buttonAbort))
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+
+ javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
+ this.setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addComponent(panelParameters, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ .addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGap(16, 16, 16)
+ .addComponent(panelParameters, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
+ );
+ }// //GEN-END:initComponents
+
+ private void radioK1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioK1ActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_radioK1ActionPerformed
+
+ private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed
+ try {
+ abort();
+ } catch (InterruptedException ex) {
+ Logger.getLogger(EnergyScan.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }//GEN-LAST:event_buttonAbortActionPerformed
+
+ private void buttonExecuteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExecuteActionPerformed
+ try {
+ run();
+ } catch (Exception ex) {
+ showException(ex);
+ }
+ }//GEN-LAST:event_buttonExecuteActionPerformed
+
+ EditorDialog dlgConfig;
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton buttonAbort;
+ private javax.swing.JButton buttonExecute;
+ private javax.swing.ButtonGroup buttonGroup1;
+ private javax.swing.ButtonGroup buttonGroup2;
+ private javax.swing.ButtonGroup buttonGroupPlot;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel12;
+ private javax.swing.JLabel jLabel2;
+ private javax.swing.JLabel jLabel3;
+ private javax.swing.JPanel jPanel3;
+ private javax.swing.JPanel panelParameters;
+ private javax.swing.JRadioButton radioK1;
+ private javax.swing.JRadioButton radioK3;
+ private javax.swing.JSpinner spinnerE1;
+ private javax.swing.JSpinner spinnerE2;
+ private javax.swing.JSpinner spinnerTime;
+ // End of variables declaration//GEN-END:variables
+}
diff --git a/script/EnergyScan.py~ b/script/EnergyScan.py~
deleted file mode 100644
index 4a4813f..0000000
--- a/script/EnergyScan.py~
+++ /dev/null
@@ -1,180 +0,0 @@
-import os
-import traceback
-
-file_prefix = time.strftime("%y%m%d")
-input_path = "/sls/X11MA/Data1/public/X11MA/temp/"+file_prefix+"/"
-output_path = input_path #+file_prefix+"/" #"/sls/X11MA/Data1/public/e10989/"+file_prefix+"/"
-
-
-#Parameters
-"""
-E1 = 680
-E2 = 750
-TIME = 2 #min
-DELAY = 10.0 #s
-OFFSET1 = 1.0 #eV
-OFFSET2 = -1.0 #eV
-PREFIX = 'Data'
-RUNTYPE = "+/-"
-ROUNDS = 1
-PLOT_TYPE = 1
-"""
-print "\nStarting energy scan - Parameters: ",
-print E1,E2,TIME,DELAY,OFFSET1,OFFSET2,RUNTYPE,ALPHA1,ALPHA2
-
-
-###############################################################################
-# Plotting
-###############################################################################
-
-running = False
-quit_plot = False
-
-def _startPlot(type):
- global running, quit_plot
- print "Starting plot: type " + str(type)
- quit_plot = False
- running = True
- p = plot(None,name="")[0]
- p.addSeries(LinePlotSeries("Energy"))
- s= p.getSeries(1)
- cur = 0
- while running:
- try:
- if otf_start.read() == 0:
- break
- e = energy.read()
- if (abs(e-cur)) > 0.1:
- v = keithley_2a.read() / ((keithley_1a if (type==1) else keithley_3a).read() )
- p.getSeries(1).appendData(e,v)
- cur = e
- time.sleep(0.2)
- except:
- pass
- quit_plot = True
- print "Done Plotting"
-
-
-def startPlot(type = 1):
- ret = fork((_startPlot,(type,)),)
-
-def stopPlot():
- global running, quit_plot
- running = False
- while quit_plot==False:
- time.sleep(0.001)
-
-###############################################################################
-
-
-def switchpol(activeID, runtype):
- global pol_str
- if activeID == 1:
- caput(OTF_OFF1,OFFSET1)
- caput(OTF_OFF2,OFFSET2-40) #detune ID2
- if runtype in ["+/-", "+"]:
- pol_str = "circ +"
- elif runtype in ["LH/LV", "LH"]:
- pol_str = "Lin. Horizontal"
- elif activeID == 2:
- caput(OTF_OFF1,OFFSET1-40) #detune ID1
- caput(OTF_OFF2,OFFSET2)
- if runtype in ["+/-", "-"]:
- pol_str = "circ -"
- elif runtype in ["LH/LV", "LV"]:
- pol_str = "Lin. Vertical"
- else:
- raise Exception("Invalid parameter")
-
-
-pol_str = None
-polswitch = 1
-
-fid = get_next_fid(input_path, "o" + file_prefix)
-
-
-
-#Prepare scan
-number_of_scans = 1
-if RUNTYPE in ["+/-", "+" , "-"]:
- caput(OTF_MODE1,1) # circ + in ID1
- caput(OTF_MODE2,2) # circ - in ID2
- wait_channel(OTF_DONE, 1, type = 'i')
- if RUNTYPE == "+/-":
- number_of_scans = 2 * ROUNDS
- else:
- number_of_scans = ROUNDS
-elif RUNTYPE in ["LH/LV", "LH", "LV"]:
- caput(OTF_MODE1,0)
- caput(OTF_MODE2,0)
- wait_channel(OTF_DONE, 1, type = 'i')
- caput(OTF_ALPHA1, 0.0) # LH in ID1
- caput(OTF_ALPHA2, 90.0) # LV in ID2
- wait_channel(OTF_DONE, 1, type = 'i')
- if RUNTYPE == "LH/LV":
- number_of_scans = 2 * ROUNDS
- else:
- number_of_scans = ROUNDS
-else:
- raise Exception("Invalid run type: " + RUNTYPE)
-
-if RUNTYPE in ["-", "LV"]:
- switchpol(2, RUNTYPE) # tune ID2 --> polarization: C- or LV
- polswitch = 0
-elif RUNTYPE in ["+/-", "+", "LH/LV", "LH"]:
- switchpol(1, RUNTYPE) # tune ID1 --> polarization: C+ or LH
-time.sleep(1.0)
-
-wait_channel(OTF_DONE, 1, type = 'i')
-
-open_vg13()
-
-for scan_no in range(number_of_scans):
- suffix = ("%03d" % fid)
- input_file = input_path + "o" + file_prefix + "_" + suffix + ".dat"
-
- caput(OTF_E1, E1)
- caput(OTF_E2, E2)
- caput(OTF_TIME, TIME)
- caput(OTF_FTS,file_prefix)
- caput(OTF_FID,fid)
- time.sleep(2.0)
- caput(OTF_ESET, E1)
- wait_channel(OTF_DONE, 1, type = 'i') #???
- time.sleep(DELAY)
- time.sleep(2.0)
-
- startPlot(PLOT_TYPE)
- #Start the OTF scan
- caput(OTF_START, 'GO')
-
- #Wait until scan is done
- wait_channel(OTF_START, 'STOP', type = 's')
- time.sleep(3.0)
- stopPlot()
-
- #Convert file
- output_file = output_path+"os"+file_prefix+"_" + suffix + ".dat"
-
- print("Converting data file: " + output_file);
- convert_file(input_file, output_file, pol_str)
- plot_file(output_file, file_prefix+"_" + suffix) #"Scan " + str(scan_no+1))
-
- if RUNTYPE in ["+/-", "LH/LV"]:
- if polswitch == 1:
- switchpol(2, RUNTYPE) # tune ID2 --> polarization: C- or LV
- polswitch = 0
- else:
- polswitch = 1
- switchpol(1, RUNTYPE) # tune ID1 --> polarization: C+ or LH
- else:
- raise Exception("running in one polarization mode, no switching")
-
- time.sleep(3.0)
- fid = fid + 1
-
-close_vg13()
-
-print "Finished Energy scan"
-
-print("Success")
diff --git a/script/Juraj/E_scan.py b/script/Juraj/E_scan.py
index 2637125..4b95b47 100644
--- a/script/Juraj/E_scan.py
+++ b/script/Juraj/E_scan.py
@@ -1,5 +1,5 @@
file_prefix = time.strftime("%Y%m%d")
-# CHANGE THE PATH IN THE OTH
+# CHANGE THE PATH IN THE OTF
input_path = "/sls/X11MA/data/X11MA/slsbl/x11ma/e17208/Data1/20180904/"
@@ -214,4 +214,4 @@ for scan_no in range(number_of_scans):
caput(OTF_ESET, E1)
close_vg13()
-print "Successfully Finished Energy scan"
\ No newline at end of file
+print "Successfully Finished Energy scan"
diff --git a/script/local.py b/script/local.py
index 718126b..c087567 100644
--- a/script/local.py
+++ b/script/local.py
@@ -1,7 +1,8 @@
###################################################################################################
# Deployment specific global definitions - executed after startup.py
###################################################################################################
-
+
+NO_BEAM_CHECK = False # setting this to true disables the waiting for the beam before starting energy or hyst scan
OTF_START = "X11MA-OTF:GO"
OTF_E1 = "X11MA-OTF:E1"
@@ -10,16 +11,14 @@ OTF_TIME = "X11MA-OTF:TIME"
OTF_FID = "X11MA-OTF:FID"
OTF_FTS = "X11MA-OTF:FTSTAMP"
OTF_FILE = "X11MA-OTF:FNAME"
-OTF_MODE1 = "X11MA-ID1:MODE"
-OTF_MODE2 = "X11MA-ID2:MODE"
-OTF_ALPHA1 = "X11MA-ID1:ALPHA"
-OTF_ALPHA2 = "X11MA-ID2:ALPHA"
-OTF_OFF1 = "X11MA-ID1:ENERGY-OFFS"
-OTF_OFF2 = "X11MA-ID2:ENERGY-OFFS"
-OTF_OPT = "X11PHS-E:OPT"
-OTF_ERBK = "X11MA-PGM:CERBK"
-OTF_DONE = "X11MA-PHS:ALL-DONE"
-OTF_ESET = "X11MA-PHS:E_SP"
+ID1_MODE = "X11MA-ID1:MODE"
+ID2_MODE = "X11MA-ID2:MODE"
+ID1_ALPHA = "X11MA-ID1:ALPHA"
+ID2_ALPHA = "X11MA-ID2:ALPHA"
+ID1_OFF = "X11MA-ID1:ENERGY-OFFS"
+ID2_OFF = "X11MA-ID2:ENERGY-OFFS"
+ALL_DONE = "X11MA-PHS:ALL-DONE"
+ENERGY_SP = "X11MA-PHS:E_SP"
VG10_SET = "X11MA-EPS-VG10:SET"
VG10_GET = "X11MA-OP-VG10:OPEN"
VG11_SET = "X11MA-EPS-VG11:SET"
@@ -37,14 +36,6 @@ TIME_DELAY_COMPLETE = "X11MA-ES2-scan1.SMSG"
TBT_MAG = "X11MA-LSCI632:MFIELD"
MAG="X11MA-XMCD:Ireadout"
-
-FST = time.strftime("%y%m%d")
-FID = 0
-
-"""
-X11PHS-E:OPT
-"""
-
def get_next_fid(folder, prefix):
try:
import glob
@@ -58,25 +49,7 @@ def get_next_fid(folder, prefix):
def wait_channel(name, value, timeout =None, type='s'):
print "Waiting " + str(name) + " = " + str(value)
cawait(name, value, timeout = timeout, type=type)
- print "Done"
-
-def convert_file(input_file_name, output_file_name):
- sep = "\t"
- line_sep = "\r\n"
- field = caget('X11MA-XMCD:Ireadout')
- with open(input_file_name) as inp:
- lines = inp.readlines()
- with open(output_file_name, "wb") as out:
- out.write("Energy" + sep + "Io" + sep + "CADC2" + sep + "CADC3" + sep + "Mag" + line_sep)
- s = sep + " " #File format has a space before numeric values
- for line in lines[1:]:
- line = line.strip()
- if line=="": break
- try:
- (Ecrbk,CADC1, CADC2, NORM, CADC3, CADC4, MCurr, cffrbk, ID1Erbk, ID2Erbk, vTime) = line.split(" ")
- out.write(Ecrbk + s + CADC1 + s + CADC2 + s + CADC3 + s + str(field) +line_sep)
- except:
- traceback.print_exc()
+ print "Done"
def open_vg10():
if caget (VG10_GET,'i') != 1:
@@ -133,4 +106,20 @@ def plot_file(file, ctxt = None):
table = Table.load(file, sep, '#')
plots = plot(table, title = ctxt)
+def has_beam():
+ """
+ """
+ return beam_status.readback.read() !="Machine Down"
+
+def wait_beam():
+ """
+ """
+ print "Waiting for beam... ",
+ while not has_beam():
+ if maintenance_mode:
+ print "Maintenence mode: disregarding beam state"
+ return
+ sleep(0.1)
+ print "Beam OK."
+
diff --git a/script/local.py~ b/script/local.py~
index 429e4bd..56bb292 100644
--- a/script/local.py~
+++ b/script/local.py~
@@ -10,18 +10,115 @@ OTF_TIME = "X11MA-OTF:TIME"
OTF_FID = "X11MA-OTF:FID"
OTF_FTS = "X11MA-OTF:FTSTAMP"
OTF_FILE = "X11MA-OTF:FNAME"
-OTF_MODE1 = "X11MA-ID1:MODE"
-OTF_MODE2 = "X11MA-ID2:MODE"
-OTF_ALPHA1 = "X11MA-ID1:ALPHA"
-OTF_ALPHA2 = "X11MA-ID2:ALPHA"
-OTF_OFF1 = "X11MA-ID2:ENERGY-OFFS"
-OTF_OFF2 = "X11MA-ID2:ENERGY-OFFS"
-OTF_OPT = "X11PHS-E:OPT"
-OTF_ERBK = "X11MA-PGM:CERBK"
-OTF_DONE = "X11MA-PHS:ALL-DONE"
-OTF_ESET = "X11MA-PHS:E_SP"
-VG10 = "X11MA-EPS-VG10:SET"
-
-
-"""
-"""X11PHS-E:OPT
+ID1_MODE = "X11MA-ID1:MODE"
+ID2_MODE = "X11MA-ID2:MODE"
+ID1_ALPHA = "X11MA-ID1:ALPHA"
+ID2_ALPHA = "X11MA-ID2:ALPHA"
+ID1_OFF = "X11MA-ID1:ENERGY-OFFS"
+ID2_OFF = "X11MA-ID2:ENERGY-OFFS"
+ALL_DONE = "X11MA-PHS:ALL-DONE"
+ENERGY_SP = "X11MA-PHS:E_SP"
+VG10_SET = "X11MA-EPS-VG10:SET"
+VG10_GET = "X11MA-OP-VG10:OPEN"
+VG11_SET = "X11MA-EPS-VG11:SET"
+VG11_GET = "X11MA-OP-VG11:OPEN"
+VG12_SET = "X11MA-EPS-VG12:SET"
+VG12_GET = "X11MA-OP-VG12:OPEN"
+VG13_SET = "X11MA-EPS-VG13:SET"
+VG13_GET = "X11MA-OP-VG13:OPEN"
+LPP_DELAY = "X11MA-ES2-4CHT:SET2-DELAY"
+LPP_FINE_DELAY = "X11MA-ES2-4CHT:SET2-FINE"
+TIME_DELAY_SET = "X11MA-ES2:Theta-New.A"
+TIME_DELAY_VAL = "X11MA-ES2:Theta-Cur.VAL"
+TIME_DELAY_START = "X11MA-ES2:SCAN-START"
+TIME_DELAY_COMPLETE = "X11MA-ES2-scan1.SMSG"
+TBT_MAG = "X11MA-LSCI632:MFIELD"
+MAG="X11MA-XMCD:Ireadout"
+
+def get_next_fid(folder, prefix):
+ try:
+ import glob
+ files = glob.glob(folder + prefix + '*_*.dat')
+ last = max(files)
+ index = int (last[last.rfind('_')+1 : last.rfind('.')]) + 1
+ return index
+ except:
+ return 0
+
+def wait_channel(name, value, timeout =None, type='s'):
+ print "Waiting " + str(name) + " = " + str(value)
+ cawait(name, value, timeout = timeout, type=type)
+ print "Done"
+
+def open_vg10():
+ if caget (VG10_GET,'i') != 1:
+ caput(VG10_SET, 0)
+ time.sleep(0.1)
+ caput(VG10_SET, 1)
+
+def close_vg10():
+ if caget (VG10_GET,'i') == 1:
+ caput(VG10_SET, 0)
+ time.sleep(0.1)
+ caput(VG10_SET, 1)
+
+def open_vg11():
+ if caget (VG11_GET,'i') != 1:
+ caput(VG11_SET, 0)
+ time.sleep(0.1)
+ caput(VG11_SET, 1)
+
+def close_vg11():
+ if caget (VG11_GET,'i') == 1:
+ caput(VG11_SET, 0)
+ time.sleep(0.1)
+ caput(VG11_SET, 1)
+
+def open_vg12():
+ if caget (VG12_GET,'i') != 1:
+ caput(VG12_SET, 0)
+ time.sleep(0.1)
+ caput(VG12_SET, 1)
+
+def close_vg12():
+ if caget (VG12_GET,'i') == 1:
+ caput(VG12_SET, 0)
+ time.sleep(0.1)
+ caput(VG12_SET, 1)
+
+def open_vg13():
+ if caget (VG13_GET,'i') != 1:
+ caput(VG13_SET, 0)
+ time.sleep(0.1)
+ caput(VG13_SET, 1)
+
+def close_vg13():
+ if caget (VG13_GET,'i') == 1:
+ caput(VG13_SET, 0)
+ time.sleep(0.1)
+ caput(VG13_SET, 1)
+
+def plot_file(file, ctxt = None):
+ """
+ """
+ sep = "\t"
+ table = Table.load(file, sep, '#')
+ plots = plot(table, title = ctxt)
+
+def has_beam():
+ """
+ """
+ return beam_status.readback.read() !="Machine Down"
+
+def wait_beam():
+ """
+ """
+ print "Waiting for beam... ",
+ while not has_beam():
+ if maintenance_mode:
+ print "Maintenence mode: disregarding beam state"
+ return
+ sleep(0.1)
+ print "Beam OK."
+
+
diff --git a/script/AreaScan.py b/script/old_scripts/AreaScan.py
similarity index 100%
rename from script/AreaScan.py
rename to script/old_scripts/AreaScan.py
diff --git a/script/DataManipulation.py b/script/old_scripts/DataManipulation.py
similarity index 100%
rename from script/DataManipulation.py
rename to script/old_scripts/DataManipulation.py
diff --git a/script/DelayScan.py b/script/old_scripts/DelayScan.py
similarity index 100%
rename from script/DelayScan.py
rename to script/old_scripts/DelayScan.py
diff --git a/script/Electric_field_loop.py b/script/old_scripts/Electric_field_loop.py
similarity index 100%
rename from script/Electric_field_loop.py
rename to script/old_scripts/Electric_field_loop.py
diff --git a/script/Electric_field_loop2.py b/script/old_scripts/Electric_field_loop2.py
similarity index 100%
rename from script/Electric_field_loop2.py
rename to script/old_scripts/Electric_field_loop2.py
diff --git a/script/Electric_field_loop3.py b/script/old_scripts/Electric_field_loop3.py
similarity index 100%
rename from script/Electric_field_loop3.py
rename to script/old_scripts/Electric_field_loop3.py
diff --git a/script/Electric_field_loop4.py b/script/old_scripts/Electric_field_loop4.py
similarity index 100%
rename from script/Electric_field_loop4.py
rename to script/old_scripts/Electric_field_loop4.py
diff --git a/script/Electric_field_twoval.py b/script/old_scripts/Electric_field_twoval.py
similarity index 100%
rename from script/Electric_field_twoval.py
rename to script/old_scripts/Electric_field_twoval.py
diff --git a/script/EnergyMultiScan.py b/script/old_scripts/EnergyMultiScan.py
similarity index 100%
rename from script/EnergyMultiScan.py
rename to script/old_scripts/EnergyMultiScan.py
diff --git a/script/EnergyScan-backup_170520.py b/script/old_scripts/EnergyScan-backup_170520.py
similarity index 100%
rename from script/EnergyScan-backup_170520.py
rename to script/old_scripts/EnergyScan-backup_170520.py
diff --git a/script/EnergyScan-beforeThread.py b/script/old_scripts/EnergyScan-beforeThread.py
similarity index 100%
rename from script/EnergyScan-beforeThread.py
rename to script/old_scripts/EnergyScan-beforeThread.py
diff --git a/script/EnergyScan-withThreading.py b/script/old_scripts/EnergyScan-withThreading.py
similarity index 100%
rename from script/EnergyScan-withThreading.py
rename to script/old_scripts/EnergyScan-withThreading.py
diff --git a/script/EnergyScan.py b/script/old_scripts/EnergyScan.py
similarity index 100%
rename from script/EnergyScan.py
rename to script/old_scripts/EnergyScan.py
diff --git a/script/EnergyScan1.py b/script/old_scripts/EnergyScan1.py
similarity index 100%
rename from script/EnergyScan1.py
rename to script/old_scripts/EnergyScan1.py
diff --git a/script/EnergyScanID1onl.py b/script/old_scripts/EnergyScanID1onl.py
similarity index 100%
rename from script/EnergyScanID1onl.py
rename to script/old_scripts/EnergyScanID1onl.py
diff --git a/script/EnergyScanID1only.py b/script/old_scripts/EnergyScanID1only.py
similarity index 100%
rename from script/EnergyScanID1only.py
rename to script/old_scripts/EnergyScanID1only.py
diff --git a/script/EnergyScanID2andID2only.py b/script/old_scripts/EnergyScanID2andID2only.py
similarity index 100%
rename from script/EnergyScanID2andID2only.py
rename to script/old_scripts/EnergyScanID2andID2only.py
diff --git a/script/EnergyScanID2only.py b/script/old_scripts/EnergyScanID2only.py
similarity index 100%
rename from script/EnergyScanID2only.py
rename to script/old_scripts/EnergyScanID2only.py
diff --git a/script/EnergyScanID2only_XMLD.py b/script/old_scripts/EnergyScanID2only_XMLD.py
similarity index 100%
rename from script/EnergyScanID2only_XMLD.py
rename to script/old_scripts/EnergyScanID2only_XMLD.py
diff --git a/script/EnergyScanID2only_juraj.py b/script/old_scripts/EnergyScanID2only_juraj.py
similarity index 100%
rename from script/EnergyScanID2only_juraj.py
rename to script/old_scripts/EnergyScanID2only_juraj.py
diff --git a/script/EnergyScanTransmission.py b/script/old_scripts/EnergyScanTransmission.py
similarity index 100%
rename from script/EnergyScanTransmission.py
rename to script/old_scripts/EnergyScanTransmission.py
diff --git a/script/EnergyScanXtreme.py b/script/old_scripts/EnergyScanXtreme.py
similarity index 100%
rename from script/EnergyScanXtreme.py
rename to script/old_scripts/EnergyScanXtreme.py
diff --git a/script/EnergyScan_TBT.py b/script/old_scripts/EnergyScan_TBT.py
similarity index 100%
rename from script/EnergyScan_TBT.py
rename to script/old_scripts/EnergyScan_TBT.py
diff --git a/script/EnergyScan_backup.py b/script/old_scripts/EnergyScan_backup.py
similarity index 100%
rename from script/EnergyScan_backup.py
rename to script/old_scripts/EnergyScan_backup.py
diff --git a/script/EnergyScan_backup_160208.py b/script/old_scripts/EnergyScan_backup_160208.py
similarity index 100%
rename from script/EnergyScan_backup_160208.py
rename to script/old_scripts/EnergyScan_backup_160208.py
diff --git a/script/Extreme.py b/script/old_scripts/Extreme.py
similarity index 100%
rename from script/Extreme.py
rename to script/old_scripts/Extreme.py
diff --git a/script/MultiScan.py b/script/old_scripts/MultiScan.py
similarity index 100%
rename from script/MultiScan.py
rename to script/old_scripts/MultiScan.py
diff --git a/script/PolSwitch.py b/script/old_scripts/PolSwitch.py
similarity index 100%
rename from script/PolSwitch.py
rename to script/old_scripts/PolSwitch.py
diff --git a/script/SetOffsets.py b/script/old_scripts/SetOffsets.py
similarity index 100%
rename from script/SetOffsets.py
rename to script/old_scripts/SetOffsets.py
diff --git a/script/Vinayak_prot.py b/script/old_scripts/Vinayak_prot.py
similarity index 100%
rename from script/Vinayak_prot.py
rename to script/old_scripts/Vinayak_prot.py
diff --git a/script/backup_Delay_scan.py b/script/old_scripts/backup_Delay_scan.py
similarity index 100%
rename from script/backup_Delay_scan.py
rename to script/old_scripts/backup_Delay_scan.py
diff --git a/script/field_sweepID2_Jaianth.py b/script/old_scripts/field_sweepID2_Jaianth.py
similarity index 100%
rename from script/field_sweepID2_Jaianth.py
rename to script/old_scripts/field_sweepID2_Jaianth.py
diff --git a/script/harmonic_ID1.xml b/script/old_scripts/harmonic_ID1.xml
similarity index 100%
rename from script/harmonic_ID1.xml
rename to script/old_scripts/harmonic_ID1.xml
diff --git a/script/harmonic_ID2.xml b/script/old_scripts/harmonic_ID2.xml
similarity index 100%
rename from script/harmonic_ID2.xml
rename to script/old_scripts/harmonic_ID2.xml
diff --git a/script/harmonic_xtreme.xml b/script/old_scripts/harmonic_xtreme.xml
similarity index 100%
rename from script/harmonic_xtreme.xml
rename to script/old_scripts/harmonic_xtreme.xml
diff --git a/script/localXtreme.py b/script/old_scripts/localXtreme.py
similarity index 100%
rename from script/localXtreme.py
rename to script/old_scripts/localXtreme.py
diff --git a/script/scan_horizontal_infocus2.xml b/script/old_scripts/scan_horizontal_infocus2.xml
similarity index 100%
rename from script/scan_horizontal_infocus2.xml
rename to script/old_scripts/scan_horizontal_infocus2.xml
diff --git a/script/scan_horizontal_outfocus.xml b/script/old_scripts/scan_horizontal_outfocus.xml
similarity index 100%
rename from script/scan_horizontal_outfocus.xml
rename to script/old_scripts/scan_horizontal_outfocus.xml
diff --git a/script/scan_vertical.xml b/script/old_scripts/scan_vertical.xml
similarity index 100%
rename from script/scan_vertical.xml
rename to script/old_scripts/scan_vertical.xml
diff --git a/script/test.py b/script/old_scripts/test.py
similarity index 100%
rename from script/test.py
rename to script/old_scripts/test.py
diff --git a/script/test2.py b/script/old_scripts/test2.py
similarity index 100%
rename from script/test2.py
rename to script/old_scripts/test2.py
diff --git a/script/test_field.py b/script/old_scripts/test_field.py
similarity index 100%
rename from script/test_field.py
rename to script/old_scripts/test_field.py
diff --git a/script/xas_0H_juraj.py b/script/old_scripts/xas_0H_juraj.py
similarity index 100%
rename from script/xas_0H_juraj.py
rename to script/old_scripts/xas_0H_juraj.py
diff --git a/script/templates/AreaScan.py b/script/templates/AreaScan.py
new file mode 100644
index 0000000..50f86b3
--- /dev/null
+++ b/script/templates/AreaScan.py
@@ -0,0 +1,27 @@
+###################################################################################################
+# Area Scan: Multiple positioners, each one is one dimension.
+###################################################################################################
+
+# Scan parameters
+Y_start = -1.0
+Z_start = 10.60
+Y_end = 1.0
+Z_end = 12.6
+Y_steps = 32
+Z_steps = 32
+# NPLC (integration time) value for the Keithleys
+NPLC=10
+
+caput('X11MA-KEI10:NPLC', NPLC)
+caput('X11MA-KEI11:NPLC', NPLC)
+caput('X11MA-KEI12:NPLC', NPLC)
+
+# move Y and Z motors to start position
+TRY.write(Y_start)
+TRZ.write(Z_start)
+
+time.sleep(5)
+
+# run the area scan
+r1 = ascan((TRY,TRZ), (Keithley_1_raw,Keithley_2_raw,Keithley_3_raw), (Y_start,Z_start), (Y_end,Z_end), (Y_steps-1,Z_steps-1), 1.0, False, 1, True)
+
diff --git a/script/templates/DelayScanBasic.py b/script/templates/DelayScanBasic.py
new file mode 100644
index 0000000..6e863c5
--- /dev/null
+++ b/script/templates/DelayScanBasic.py
@@ -0,0 +1,126 @@
+
+print "\nStarting delay scan - Parameters: ",
+print START,END,STEP,ENERGIES,ROUNDS, RUNTYPE
+
+run("utils")
+polswitch = 1
+
+####################### Set Delay and fine delay function #####################
+LPP_DELAY_NEW = 0
+LPP_FINE_DELAY_NEW = 0
+
+
+def Convert_LPP_Delays(NewDelay):
+ global LPP_DELAY_NEW, LPP_FINE_DELAY_NEW
+ LPP_DELAY_NEW = math.trunc(((-NewDelay*100.0+DELAY*(1E9/SLS_freq.read())*100+FINEDELAY)/100.0)/(1E9/SLS_freq.read()))
+ LPP_FINE_DELAY_NEW = math.trunc(-NewDelay*100.0+DELAY*1E9/SLS_freq.read()*100+FINEDELAY-LPP_DELAY_NEW*(1E9/SLS_freq.read()*100.0))
+
+def Timing(New_Time):
+ caput (TIME_DELAY_SET, New_Time)
+ caput (TIME_DELAY_START, 1)
+ Convert_LPP_Delays(New_Time)
+ caput (LPP_DELAY, LPP_DELAY_NEW)
+ caput (LPP_FINE_DELAY, LPP_FINE_DELAY_NEW)
+ wait_channel(TIME_DELAY_COMPLETE, 'SCAN Complete', timeout=10+abs((caget(TIME_DELAY_SET, type='d')-caget(TIME_DELAY_VAL, type='d')))*10)
+
+##################### Setting filenames #######################################
+
+file_prefix = time.strftime("%y%m%d")
+sep = "\t"
+line_sep = "\r\n"
+
+input_path = PATH
+output_path = input_path
+
+###############################################################################
+#Prepare scan
+###############################################################################
+
+x=ENERGIES
+y = []
+x=x.split(',')
+for i in x:
+ y.append(float(i))
+
+caput ("X11PHS-E:OPT","PGM+ID1+ID2")
+
+if RUNTYPE in ["+/-", "+", "-"]:
+ caput(ID1_MODE,1) # circ + in ID1
+ caput(ID2_MODE,2) # circ - in ID2
+ wait_channel(All_DONE, 1, type = 'i')
+ if RUNTYPE == "+/-":
+ number_of_scans = 2 * ROUNDS
+ else:
+ number_of_scans = ROUNDS
+elif RUNTYPE in ["LH/LV", "LH", "LV"]:
+ caput(ID1_MODE,0)
+ caput(ID2_MODE,0)
+ wait_channel(ALL_DONE, 1, type = 'i')
+ caput(ID1_ALPHA, 0.0) # LH in ID1
+ caput(ID2_ALPHA, 90.0) # LV in ID2
+ wait_channel(ALL_DONE, 1, type = 'i')
+ if RUNTYPE == "LH/LV":
+ number_of_scans = 2 * ROUNDS
+ else:
+ number_of_scans = ROUNDS
+else:
+ raise Exception("Invalid run type: " + RUNTYPE)
+
+if RUNTYPE in ["-", "LV"]:
+ switchpol(2, RUNTYPE) # tune ID2 --> polarization: C- or LV
+ polswitch = 0
+elif RUNTYPE in ["+/-", "+", "LH/LV", "LH"]:
+ switchpol(1, RUNTYPE) # tune ID1 --> polarization: C+ or LH
+time.sleep(1.0)
+
+caput (TIME_DELAY_SET, START)
+caput (TIME_DELAY_START, 1)
+if START == 0:
+ caput (LPP_DELAY, DELAY)
+ caput (LPP_FINE_DELAY, FINEDELAY)
+ wait_channel(TIME_DELAY_COMPLETE, 'SCAN Complete', timeout= 10)
+else:
+ Convert_LPP_Delays(caget(TIME_DELAY_SET, type='d'))
+ caput (LPP_DELAY, LPP_DELAY_NEW)
+ caput (LPP_FINE_DELAY, LPP_FINE_DELAY_NEW)
+ wait_channel(TIME_DELAY_COMPLETE, 'SCAN Complete', timeout= abs((caget(TIME_DELAY_SET, type='d')-caget(TIME_DELAY_VAL, type='d')))*10)
+
+###############################################################################
+#DAQ function
+###############################################################################
+
+def Daq():
+ # Your Data Aquisition function
+
+
+###############################################################################
+# Scanning
+###############################################################################
+
+
+for scan_no in range(number_of_scans):
+
+ print "Running polarisation " + str(scan_no+1) + " out of " + str(number_of_scans)
+
+ Delay_Time = START
+ while Delay_Time <= END:
+ Timing(Delay_Time)
+ for en in y:
+ caput(ENERGY_SP,en)
+ wait_channel(ALL_DONE, 1, type = 'i')
+ Daq(Delay_Time)
+ Delay_Time += STEP
+
+ print "Finished polarisation " + str(scan_no+1) + " out of " + str(number_of_scans)
+ if RUNTYPE in ["+/-", "LH/LV"]:
+ if polswitch == 1:
+ switchpol(2, RUNTYPE) # tune ID2 --> polarization: C- or LV
+ polswitch = 0
+ else:
+ polswitch = 1
+ switchpol(1, RUNTYPE) # tune ID1 --> polarization: C+ or LH
+ else:
+ print "running in one polarization mode"
+
+print "Finished Delay scan"
+
diff --git a/script/templates/EnergyScan.py b/script/templates/EnergyScan.py
new file mode 100644
index 0000000..6bb11ca
--- /dev/null
+++ b/script/templates/EnergyScan.py
@@ -0,0 +1,210 @@
+#Script imported and adopted from: XTREME beamline
+
+#Parameters
+"""
+E1 = 710
+E2 = 720
+TIME = 1 #min
+DELAY = 10.0 #s
+MODE = 'CIRC +'
+OFFSET = -9.0
+FOLDER = '2015_04/20150417'
+FILE = 'Fe_plus'
+ALPHA=0
+"""
+
+
+count.initialize()
+data.initialize()
+fdata.initialize()
+idata.initialize()
+edata.initialize()
+
+p=None
+def start_plot():
+ global p
+ p = plot([None, None, None,None, None], ["TEY", "TFY", "TEYraw", "TFYraw", "I0"])
+
+def update_plot():
+ global p
+ c = count.take()
+ if c is None:
+ for i in range(len(p)):
+ p[i].getSeries(0).clear()
+ else:
+ data.setSize(c)
+ fdata.setSize(c)
+ idata.setSize(c)
+ edata.setSize(c)
+ teyr= data.read()
+ tfyr= fdata.read()
+ i0 = idata.read()
+ x = edata.read()
+ #from operator import truediv
+ l = lambda x,y: (0.0 if (y==0.0) else x/y) #truediv
+ tey=map(l, teyr, i0)
+ tfy=map(l, tfyr, i0)
+ p[0].getSeries(0).setData(x, to_array(tey,'d'))
+ p[1].getSeries(0).setData(x, to_array(tfy,'d'))
+ p[2].getSeries(0).setData(x, to_array(teyr,'d'))
+ p[3].getSeries(0).setData(x, to_array(tfyr,'d'))
+ p[4].getSeries(0).setData(x, to_array(i0,'d'))
+
+
+print "\nStart energy scan..."
+
+if MODE == "LINEAR":
+ print E1,"eV ->",E2,"eV,",TIME,"min duration,",DELAY,"sec delay,",str(MODE),str(ALPHA),"deg"
+else:
+ print E1,"eV ->",E2,"eV,",TIME,"min duration,",DELAY,"sec delay,",str(MODE)
+
+start = time.localtime()
+
+folder = os.path.expanduser("~/Data1/") + FOLDER + "/";
+
+#print "folder = ",folder
+
+def getNewestFile():
+ global folder
+ import glob
+ try:
+# print glob.glob(folder+'/*.txt')
+# print max(glob.glob(folder+'/*.txt'), key=os.path.getctime)
+ return max(glob.glob(folder+'/*.txt'), key=os.path.getctime)
+ except:
+ return None
+newest = getNewestFile()
+
+#print "newest = ",newest
+
+#Pre-actions
+if NO_BEAM_CHECK == False:
+ wait_beam()
+
+
+if MODE is not None:
+ pol_mode.write(MODE) #caput('X07MA-ID:MODE', MODE) #TODO: CAPUT
+# time.sleep(0.5) #TODO: Needed?
+ if MODE == 'LINEAR':
+ if ALPHA is not None:
+ pol_angle.write(ALPHA) #TODO: CAPUT
+# time.sleep(0.5)
+ #wait_device(pol_done, "DONE") #TODO: NEEDED?
+if OFFSET is not None:
+ pol_offset.write(OFFSET) #TODO: CAPUT
+# time.sleep(0.5)
+ #wait_device(pol_done, "DONE")
+
+wait_device(pol_done, "DONE") # added 10/02/2017 to try avoid taper error. CP
+
+#################
+"""
+print "Moving down energy in steps."
+
+while True:
+ en = caget("X07MA-PGM:CERBK")
+ if en > 350.0:
+ estep = 20.0
+ else:
+ estep = 5.0
+
+ if abs(en - E1) < estep:
+ estep = abs(en - E1)
+
+ if en > float(E1):
+ set_energy( en - estep )
+ else:
+ break
+
+print "It is done."
+############
+"""
+energy.write(float(E1)) # added 10/02/2017 to try avoid taper error. CP
+
+#wait_device(energy_done, 1) # added 10/02/2017 to try avoid taper error. CP. Removed in 17/03 because often script was hanging at this point
+
+caput('E1', E1)
+#print "caput E1" #add for debug
+caput('E2', E2)
+#print "caput E2" #add for debug
+caput('TIME', TIME)
+#print "caput TIME" #add for debug
+caput('FOLDER', FOLDER)
+#print "caput FOLDER" #add for debug
+#set_energy (E1)
+caput('FILE', FILE)
+#print "caput FILE" #add for debug
+time.sleep(0.1)
+
+#open_valve()
+#open_valve(0.0) #TODO: WHY WRITING AGAIN???
+#print "before delay" #add for debug
+time.sleep(DELAY)
+#print "after delay" #add for debug
+
+#print 'ldfkj;fjk'
+#if WAIT_STABLE_TEMPERATURE == True:
+# wait_temp()
+
+caput('START', '1')
+#print "caput START" #add for debug
+
+try:
+ write_logs()
+
+ waiting = True
+ def plot_task():
+ global waiting
+ pos=count.take()
+ start_plot()
+ #print "start_plot" # added for debug
+ while waiting:
+ if count.take() != pos:
+ update_plot()
+ pos = count.take()
+ time.sleep(2.0)
+
+ ret = fork(plot_task)
+ try:
+ print "Scanning...",
+ #Post-actions
+ wait_channel('START', 'STOP', type = 's')
+ after_sample() #To call check_id_error()
+ time.sleep(2.0)
+ print "Finished Energy scan."
+ finally:
+ waiting = False
+ join(ret)
+ #print "Joined "
+
+ #File convertion
+ #newName = folder + time.strftime("%Y%m%d_%H%M%S_", start) + FILE + "_0000.txt";
+ newName = folder + time.strftime("%Y%m%d_%H%M_", start) + FILE + "_0000.txt";
+ name = getNewestFile()
+
+ #print "newest file:"
+ #print name
+ #print "newest variable"
+ #print newest
+
+ if name == newest:#TODO: WHY WRITING AGAIN???
+ print "Risk of overwriting. " + name + " same as " + newest
+ raise Exception("Data file not created.")
+
+ if not os.path.isfile(name):
+ raise Exception("Data file not found: " + name)
+
+ convert_file(name, newName)
+ log("Created data file: " + newName)
+ #plot_file(newName)
+ #print("Success")
+ #"PlotDomain", "Ecrbk"
+except:
+ print("Aborting...")
+ while caget('START') == 'START':
+ caput('START', '0')
+ time.sleep(0.1)
+ #if get_exec_pars().source != CommandSource.plugin:
+ # show_message(str(ex))
+ raise
+
diff --git a/script/templates/EnergyScanBasic.py b/script/templates/EnergyScanBasic.py
new file mode 100644
index 0000000..bf3ce16
--- /dev/null
+++ b/script/templates/EnergyScanBasic.py
@@ -0,0 +1,140 @@
+"""
+Example Parameters
+
+ROUNDS = 1
+E1 = 634
+E2 = 665
+TIME = 2
+DELAY = 3
+
+PLOT_TYPE = 1
+OFFSET1 = -2.0 #eV
+OFFSET2 = -2.9 #eV
+RUNTYPE = "+/-"
+"""
+print "\nStarting energy scan - Parameters: ",
+print E1,E2,TIME,ROUNDS,RUNTYPE
+
+
+run("utils")
+
+polswitch = 1
+
+##################### Setting filenames #######################################
+
+file_prefix = time.strftime("%Y%m%d")
+fid = get_next_fid(input_path, "o" + file_prefix)
+sep = "\t"
+line_sep = "\r\n"
+
+# CHANGE THE PATH IN THE OTF
+input_path = PATH
+output_path = input_path
+
+###############################################################################
+#Prepare scan
+###############################################################################
+
+caput ("X11PHS-E:OPT","PGM+ID1+ID2")
+
+if RUNTYPE in ["+/-", "+", "-"]:
+ caput(ID1_MODE,1) # circ + in ID1
+ caput(ID2_MODE,2) # circ - in ID2
+ wait_channel(ALL_DONE, 1, type = 'i')
+ if RUNTYPE == "+/-":
+ number_of_scans = 2 * ROUNDS
+ else:
+ number_of_scans = ROUNDS
+elif RUNTYPE in ["LH/LV", "LH", "LV"]:
+ caput(ID1_MODE,0)
+ caput(ID2_MODE,0)
+ wait_channel(ALL_DONE, 1, type = 'i')
+ caput(ID1_ALPHA, 0.0) # LH in ID1
+ caput(ID2_ALPHA, 90.0) # LV in ID2
+ wait_channel(ALL_DONE, 1, type = 'i')
+ if RUNTYPE == "LH/LV":
+ number_of_scans = 2 * ROUNDS
+ else:
+ number_of_scans = ROUNDS
+else:
+ raise Exception("Invalid run type: " + RUNTYPE)
+
+if RUNTYPE in ["-", "LV"]:
+ switchpol(2, RUNTYPE) # tune ID2 --> polarization: C- or LV
+ polswitch = 0
+elif RUNTYPE in ["+/-", "+", "LH/LV", "LH"]:
+ switchpol(1, RUNTYPE) # tune ID1 --> polarization: C+ or LH
+time.sleep(1.0)
+
+wait_channel(ALL_DONE, 1, type = 'i')
+
+open_vg10()
+time.sleep(0.5)
+open_vg11()
+time.sleep(0.5)
+open_vg12()
+time.sleep(0.5)
+open_vg13()
+
+###############################################################################
+#Main scan loop
+###############################################################################
+
+for scan_no in range(number_of_scans):
+
+ suffix = ("%03d" % fid)
+ input_file = input_path + "o" + file_prefix + "_" + suffix + ".dat"
+
+ caput(OTF_E1, E1)
+ caput(OTF_E2, E2)
+ caput(OTF_TIME, TIME)
+ caput(OTF_FTS,file_prefix)
+ caput(OTF_FID,fid)
+
+ caput(ENERGY_SP, E1)
+ wait_channel(ALL_DONE, 1, type = 'i')
+ time.sleep(DELAY)
+ startPlot(PLOT_TYPE)
+
+ otf_start.write(1)
+ time.sleep(1.0)
+ print "Running scan " + str(scan_no+1) + " out of " + str(number_of_scans)
+ try:
+ otf_start.waitValue(0, (15 + int(TIME*60)) *1000)
+ except:
+ print "******** OTF STOP TIMEOUT **********"
+ otf_start.write(0)
+ finally:
+ stopPlot()
+
+ time.sleep(1.0)
+
+ #Convert file
+ output_file = output_path + "os" + file_prefix + "_" + suffix + ".dat"
+ print("Converting data file: " + output_file);
+ convert_file(input_file, output_file)
+ plot_file(output_file, file_prefix+"_" + suffix) #"comment to supress plot
+ print "Finished scan " + str(scan_no+1) + " out of " + str(number_of_scans) + " with polarisation: " + get_pol_str()
+
+
+ if RUNTYPE in ["+/-", "LH/LV"]:
+ if polswitch == 1:
+ switchpol(2, RUNTYPE) # tune ID2 --> polarization: C- or LV
+ polswitch = 0
+ else:
+ polswitch = 1
+ switchpol(1, RUNTYPE) # tune ID1 --> polarization: C+ or LH
+ else:
+ print "running in one polarization mode, no switching"
+
+ time.sleep(3.0)
+ fid = fid + 1
+
+###############################################################################
+#Finishing scan
+###############################################################################
+
+caput(ENERGY_SP, E1)
+close_vg13()
+
+print "Successfully Finished Energy scan"
diff --git a/script/templates/OTFScanBasic.py b/script/templates/OTFScanBasic.py
new file mode 100644
index 0000000..2d514c4
--- /dev/null
+++ b/script/templates/OTFScanBasic.py
@@ -0,0 +1,67 @@
+"""
+Example Parameters
+
+E1 = 634
+E2 = 665
+TIME = 2
+PLOT_TYPE = 1
+
+"""
+print "\nStarting energy scan - Parameters: ",
+print E1,E2,TIME
+
+
+run("utils")
+
+###############################################################################
+#Prepare scan
+###############################################################################
+
+file_prefix = time.strftime("%Y%m%d")
+
+open_vg10()
+time.sleep(0.5)
+open_vg11()
+time.sleep(0.5)
+open_vg12()
+time.sleep(0.5)
+open_vg13()
+
+###############################################################################
+#Main scan loop
+###############################################################################
+
+
+caput(OTF_E1, E1)
+caput(OTF_E2, E2)
+caput(OTF_TIME, TIME)
+caput(OTF_FTS,file_prefix)
+ #caput(OTF_FID,fid)
+
+caput(ENERGY_SP, E1)
+wait_channel(ALL_DONE, 1, type = 'i')
+startPlot(PLOT_TYPE)
+
+otf_start.write(1)
+time.sleep(1.0)
+print "Running OTF scan"
+try:
+ otf_start.waitValue(0, (15 + int(TIME*60)) *1000)
+except:
+ print "******** OTF STOP TIMEOUT **********"
+ otf_start.write(0)
+finally:
+ stopPlot()
+
+time.sleep(1.0)
+
+plot_file(input_file) #"comment to supress plot
+
+###############################################################################
+#Finishing scan
+###############################################################################
+
+caput(ENERGY_SP, E1)
+close_vg13()
+
+print "Successfully Finished OTF scan"
diff --git a/script/utils.py b/script/utils.py
new file mode 100644
index 0000000..4fe3338
--- /dev/null
+++ b/script/utils.py
@@ -0,0 +1,91 @@
+
+##################### Convert_File function #############################
+
+def convert_file(input_file_name, output_file_name):
+ sep = "\t"
+ line_sep = "\r\n"
+ field = caget('X11MA-XMCD:Ireadout')
+ with open(input_file_name) as inp:
+ lines = inp.readlines()
+ with open(output_file_name, "wb") as out:
+ out.write("Energy" + sep + "Io" + sep + "CADC2" + sep + "CADC3" + sep + "Mag" + line_sep)
+ s = sep + " " #File format has a space before numeric values
+ for line in lines[1:]:
+ line = line.strip()
+ if line=="": break
+ try:
+ (Ecrbk,CADC1, CADC2, NORM, CADC3, CADC4, MCurr, cffrbk, ID1Erbk, ID2Erbk, vTime) = line.split(" ")
+ out.write(Ecrbk + s + CADC1 + s + CADC2 + s + CADC3 + s + str(field) +line_sep)
+ except:
+ traceback.print_exc()
+
+##################### Plotting function #############################
+
+task = None
+running = False
+
+
+def _startPlot(type):
+ global running
+ sep = "\t"
+ line_sep = "\r\n"
+ print "Starting plot: type " + str(type)
+ running = True
+ p = plot(None,name="Energy")[0]
+ s = p.getSeries(0)
+ cur = 0
+ time.sleep(3.0)
+ t_start = time.time()
+ t_end = time.time() + TIME*60.0
+ while running:
+ try:
+ if (otf_start.read() == 0 or time.time() > t_end):
+ break
+ e = energy.read()
+
+ if (abs(e-cur)) > 0.1:
+ v = abs((keithley_2a.read() / ((keithley_1a if (type==1) else keithley_3a).read() )))
+ s.appendData(e,v)
+ cur = e
+ except:
+ pass
+ print "Done Plotting"
+
+def startPlot(type = 1):
+ global task
+ task = fork((_startPlot,(type,)),)
+
+def stopPlot():
+ global task, running
+ running = False
+ ret = join(task)
+
+
+##################### Switch Polarization function #############################
+
+
+def switchpol(activeID, runtype):
+ global pol_str
+ if activeID == 1:
+ caput(ID1_OFF,OFFSET1)
+ caput(ID2_OFF,OFFSET2-40) #detune ID2
+ if runtype in ["+/-", "+"]:
+ pol_str = "circ +"
+ elif runtype in ["LH/LV", "LH"]:
+ pol_str = "Lin. Horizontal"
+ elif activeID == 2:
+ caput(ID1_OFF,OFFSET1-40) #detune ID1
+ caput(ID2_OFF,OFFSET2)
+ if runtype in ["+/-", "-"]:
+ pol_str = "circ -"
+ elif runtype in ["LH/LV", "LV"]:
+ pol_str = "Lin. Vertical"
+ else:
+ raise Exception("Invalid parameter")
+
+pol_str = None
+
+def get_pol_str():
+ return pol_str
+
+