From a294078e3f7f905321002fbcdd4a1d59f9f35f06 Mon Sep 17 00:00:00 2001 From: X11MA Date: Wed, 2 Dec 2015 18:23:59 +0100 Subject: [PATCH] Creation --- config/config.properties | 26 ++ config/devices.properties | 5 + config/energy_scan.properties | 1 + config/plugins.properties | 2 + config/setup.properties | 19 ++ devices/dp1.properties | 12 + devices/m1.properties | 13 + devices/m2.properties | 13 + devices/src1.properties | 17 ++ devices/src2.properties | 17 ++ plugins/EnergyScan.form | 381 +++++++++++++++++++++++++ plugins/EnergyScan.java | 513 ++++++++++++++++++++++++++++++++++ plugins/Test.form | 88 ++++++ plugins/Test.java | 130 +++++++++ script/EnergyScan.py | 104 +++++++ script/local.groovy | 3 + script/local.js | 4 + script/local.py | 88 ++++++ script/test.py | 59 ++++ 19 files changed, 1495 insertions(+) create mode 100644 config/config.properties create mode 100644 config/devices.properties create mode 100644 config/energy_scan.properties create mode 100644 config/plugins.properties create mode 100644 config/setup.properties create mode 100644 devices/dp1.properties create mode 100644 devices/m1.properties create mode 100644 devices/m2.properties create mode 100644 devices/src1.properties create mode 100644 devices/src2.properties create mode 100644 plugins/EnergyScan.form create mode 100644 plugins/EnergyScan.java create mode 100644 plugins/Test.form create mode 100644 plugins/Test.java create mode 100644 script/EnergyScan.py create mode 100644 script/local.groovy create mode 100644 script/local.js create mode 100644 script/local.py create mode 100644 script/test.py diff --git a/config/config.properties b/config/config.properties new file mode 100644 index 0000000..0991f65 --- /dev/null +++ b/config/config.properties @@ -0,0 +1,26 @@ +#Wed Dec 02 17:36:25 CET 2015 +autoSaveScanData=true +createSessionFiles=false +dataPath={data}/{year}_{month}/{date}/{date}_{time}_{exec} +dataProvider=default +dataScanFlushRecords=true +dataScanStrategy=default +devicePoolFile={config}/devices.properties +deviceUpdateStrategyFile={config}/update.properties +imageSourcesFile={config}/imaging.properties +logDaysToLive=-1 +logLevel=Info +logLevelConsole=Off +logPath={logs}/{date}_{time} +serverEnabled=false +serverPort=8080 +simulation=false +tasksFile={config}/tasks.properties +terminalEnabled=false +terminalPort=3579 +userAuthenticator= +userManagement=false +versionTrackingEnabled=true +versionTrackingLogin= +versionTrackingManual=false +versionTrackingRemote= diff --git a/config/devices.properties b/config/devices.properties new file mode 100644 index 0000000..0a269f7 --- /dev/null +++ b/config/devices.properties @@ -0,0 +1,5 @@ +energy=ch.psi.pshell.epics.ChannelDouble|X11MA-PGM:rbkenergy|Read||true +keithley_1a=ch.psi.pshell.epics.ChannelDouble|X11MA-ES1:CADC1|Read||true +keithley_2a=ch.psi.pshell.epics.ChannelDouble|X11MA-ES1:CADC2|Read||true +keithley_3a=ch.psi.pshell.epics.ChannelDouble|X11MA-ES1:CADC3|Read||true +otf_start=ch.psi.pshell.epics.ChannelInteger|X11MA-OTF:GO|Read||true diff --git a/config/energy_scan.properties b/config/energy_scan.properties new file mode 100644 index 0000000..6dd4591 --- /dev/null +++ b/config/energy_scan.properties @@ -0,0 +1 @@ +Fe=650.0;750.0;2.0;0.0;0.0;0.0;0.0;0.0 diff --git a/config/plugins.properties b/config/plugins.properties new file mode 100644 index 0000000..de28508 --- /dev/null +++ b/config/plugins.properties @@ -0,0 +1,2 @@ +./home/plugins/Test.java=disabled +./home/plugins/EnergyScan.java=enabled diff --git a/config/setup.properties b/config/setup.properties new file mode 100644 index 0000000..f068414 --- /dev/null +++ b/config/setup.properties @@ -0,0 +1,19 @@ +#Tue Oct 27 16:16:33 CET 2015 +configFile={config}/config.properties +configFileDevices={config}/devices.properties +configFileImageSources={config}/imaging.properties +configFilePlugins={config}/plugins.properties +configFileTasks={config}/tasks.properties +configFileUpdateStrategy={config}/update.properties +configPath={home}/config +contextPath={home}/context +dataPath={home}/data +devicesPath={home}/devices +extensionsPath={home}/extensions +libraryPath={script}; {script}/Lib +logPath={home}/log +pluginsPath={home}/plugins +scriptPath={home}/script +scriptType=py +sessionsPath={home}/sessions +wwwPath={home}/www diff --git a/devices/dp1.properties b/devices/dp1.properties new file mode 100644 index 0000000..9d9b9fe --- /dev/null +++ b/devices/dp1.properties @@ -0,0 +1,12 @@ +#Tue Oct 27 16:28:34 CET 2015 +accessType=ReadWrite +motor1=0.0|4.0|8.0|0.0 +motor2=0.0|5.0|3.0|NaN +motor3=null +motor4=null +motor5=null +motor6=null +motor7=null +motor8=null +positions=Park|Ready|Out|Clear +precision=-1 diff --git a/devices/m1.properties b/devices/m1.properties new file mode 100644 index 0000000..15c20d0 --- /dev/null +++ b/devices/m1.properties @@ -0,0 +1,13 @@ +#Tue Oct 27 16:28:34 CET 2015 +accessType=ReadWrite +defaultSpeed=1.0 +estbilizationDelay=0 +maxSpeed=10.0 +maxValue=10.0 +minSpeed=0.1 +minValue=-10.0 +offset=0.0 +precision=2 +resolution=NaN +scale=1.0 +unit=mm diff --git a/devices/m2.properties b/devices/m2.properties new file mode 100644 index 0000000..15c20d0 --- /dev/null +++ b/devices/m2.properties @@ -0,0 +1,13 @@ +#Tue Oct 27 16:28:34 CET 2015 +accessType=ReadWrite +defaultSpeed=1.0 +estbilizationDelay=0 +maxSpeed=10.0 +maxValue=10.0 +minSpeed=0.1 +minValue=-10.0 +offset=0.0 +precision=2 +resolution=NaN +scale=1.0 +unit=mm diff --git a/devices/src1.properties b/devices/src1.properties new file mode 100644 index 0000000..7a9a7c1 --- /dev/null +++ b/devices/src1.properties @@ -0,0 +1,17 @@ +#Tue Oct 27 16:28:34 CET 2015 +colormap=Temperature +colormapAutomatic=true +colormapMax=255.0 +colormapMin=0.0 +dataMonitoring=false +dataPolling=100 +flipHorizontally=false +flipVertically=false +grayscale=false +invert=false +pollingBackground=false +pollingInterval=0 +rescaleFactor=1.0 +rescaleOffset=0.0 +rotation=0.0 +scale=1.0 diff --git a/devices/src2.properties b/devices/src2.properties new file mode 100644 index 0000000..36299ca --- /dev/null +++ b/devices/src2.properties @@ -0,0 +1,17 @@ +#Tue Oct 27 16:28:34 CET 2015 +colormap=Grayscale +colormapAutomatic=true +colormapMax=255.0 +colormapMin=0.0 +dataMonitoring=false +dataPolling=100 +flipHorizontally=false +flipVertically=false +grayscale=false +invert=false +pollingBackground=false +pollingInterval=0 +rescaleFactor=1.0 +rescaleOffset=0.0 +rotation=0.0 +scale=1.0 diff --git a/plugins/EnergyScan.form b/plugins/EnergyScan.form new file mode 100644 index 0000000..5524cdf --- /dev/null +++ b/plugins/EnergyScan.form @@ -0,0 +1,381 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/plugins/EnergyScan.java b/plugins/EnergyScan.java new file mode 100644 index 0000000..1b74e32 --- /dev/null +++ b/plugins/EnergyScan.java @@ -0,0 +1,513 @@ +/* + * 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.ArrayList; +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.data.PlotDescriptor; +import ch.psi.pshell.device.Device; +import ch.psi.pshell.device.DeviceAdapter; +import ch.psi.pshell.epics.ChannelDouble; +import ch.psi.pshell.epics.ChannelDoubleArray; +import ch.psi.pshell.epics.ChannelInteger; +import ch.psi.pshell.plot.LinePlot; +import ch.psi.pshell.plot.LinePlotBase; +import ch.psi.pshell.plot.LinePlotSeries; +import ch.psi.pshell.plot.Plot; +import ch.psi.pshell.ui.Panel; +import java.io.IOException; +import java.util.logging.Logger; + +/** + * + */ +public class EnergyScan extends Panel { + + public EnergyScan() { + initComponents(); + } + + long start; + ChannelDouble k1; + ChannelDouble k2; + ChannelDouble k3; + ChannelDouble energy; + + + double[] offsets = new double[4]; + double energyCache = 0; + + @Override + public void onInitialize(int runCount) { + super.onInitialize(runCount); + + k1 = (ChannelDouble) getController().getDevicePool().getByName("keithley_1a"); + k2 = (ChannelDouble) getController().getDevicePool().getByName("keithley_2a"); + k3 = (ChannelDouble) getController().getDevicePool().getByName("keithley_3a"); + energy= (ChannelDouble) getController().getDevicePool().getByName("energy"); + + for (Device dev :new Device[]{energy}){ + dev.addListener(new DeviceAdapter() { + @Override + public void onValueChanged(Device device, Object value, Object former) { + try { + if (Math.abs(energyCache - ((Double)value)) > 0.1) { + if (radioK3.isSelected()) + k3.update(); + else + k1.update(); + k2.update(); + energyCache = (Double)value; + update(); + } + } catch (Exception ex) { + Logger.getLogger(EnergyScan.class.getName()).log(Level.SEVERE, null, ex); + } + } + }); + } + + start = System.currentTimeMillis(); + + update(); + } + + @Override + public void onStateChange(State state, State former) { + setEnabled(state == State.Ready); + } + + @Override + public void onExecutedFile(String fileName, Object result) { + } + + @Override + protected void doUpdate() { + plot(); + } + + 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(getController().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 = isEnabled() && (comboRunType.getSelectedIndex() == 0); + for (Component c : panelParameters.getComponents()) { + if (!(c instanceof JLabel)) { + c.setEnabled(enabled); + } + } + //spinnerAlpha.setEnabled(enabled && comboMode.getSelectedItem().equals("LINEAR")); + } + + void plot() { + try { + if ((scanPlot != null) && (scanSeries != null) && scanPlot.isShowing() ) { + //if ((scanPlot != null) && (scanSeries != null) && scanPlot.isShowing() && (count != null)) { + double x = energy.take(); + double y = k2.take() / ((radioK3.isSelected()) ? k3.take() : k1.take()); + scanSeries.appendData(x, y); + + } + } catch (Exception ex) { + //showException(ex); + ex.printStackTrace(); + } + } + + + void run() throws Exception { + HashMap args = new HashMap(); + Double e1 = (Double) spinnerE1.getValue(); + 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("PREFIX", textPrefix.getText()); + args.put("RUNTYPE", comboRunType.getSelectedItem().toString()); + + + + buttonAbort.setEnabled(true); + + runAsync("EnergyScan", 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)); + } + } + + void startPlot() throws Exception { + PlotDescriptor descriptors = new PlotDescriptor("Energy Scan"); + ArrayList plots = getController().plot(new PlotDescriptor[]{descriptors}, null); + scanPlot = (LinePlotBase) plots.get(0); + scanSeries = scanPlot.getSeries(0); + } + + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + buttonGroupPlot = 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(); + jLabel9 = new javax.swing.JLabel(); + textPrefix = new javax.swing.JTextField(); + jPanel2 = new javax.swing.JPanel(); + radioK1 = new javax.swing.JRadioButton(); + radioK3 = new javax.swing.JRadioButton(); + buttonPlot = new javax.swing.JButton(); + 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("E1:"); + + spinnerE1.setModel(new javax.swing.SpinnerNumberModel(690.0d, 0.0d, 9999.0d, 1.0d)); + + jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel2.setText("E2:"); + + spinnerE2.setModel(new javax.swing.SpinnerNumberModel(755.0d, 0.0d, 9999.0d, 1.0d)); + + jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel3.setText("Time(min):"); + + spinnerTime.setModel(new javax.swing.SpinnerNumberModel(3.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[] { "+/-" })); + + jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING); + jLabel9.setText("Prefix:"); + + 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.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, 84, Short.MAX_VALUE) + .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING) + .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.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(43, Short.MAX_VALUE)) + .addGroup(panelParametersLayout.createSequentialGroup() + .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel9) + .addComponent(jLabel11)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(comboRunType, javax.swing.GroupLayout.PREFERRED_SIZE, 105, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(textPrefix, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)) + .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}); + + panelParametersLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {comboRunType, textPrefix}); + + 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(18, 18, 18) + .addGroup(panelParametersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel9) + .addComponent(textPrefix)) + .addGap(18, 18, 18) + .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)) + .addContainerGap()) + ); + + jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Plot Options")); + + buttonGroupPlot.add(radioK1); + radioK1.setSelected(true); + radioK1.setText("K1"); + radioK1.setMinimumSize(new java.awt.Dimension(100, 22)); + radioK1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + radioPlotActionPerformed(evt); + } + }); + + buttonGroupPlot.add(radioK3); + radioK3.setText("K3"); + radioK3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + radioPlotActionPerformed(evt); + } + }); + + buttonPlot.setText("Plot"); + buttonPlot.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonPlotActionPerformed(evt); + } + }); + + javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2); + jPanel2.setLayout(jPanel2Layout); + jPanel2Layout.setHorizontalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(buttonPlot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(radioK1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(radioK3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap(34, Short.MAX_VALUE)) + ); + + jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {radioK1, radioK3}); + + jPanel2Layout.setVerticalGroup( + jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup() + .addContainerGap() + .addComponent(radioK1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(radioK3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 129, Short.MAX_VALUE) + .addComponent(buttonPlot) + .addContainerGap()) + ); + + 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(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(buttonAbort, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(buttonExecute, 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() + .addGap(4, 4, 4) + .addComponent(buttonExecute) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .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) + .addGroup(layout.createSequentialGroup() + .addComponent(panelParameters, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jPanel2, 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) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .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)) + ); + + layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jPanel2, panelParameters}); + + }// //GEN-END:initComponents + + private void buttonExecuteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExecuteActionPerformed + try { + startPlot(); + run(); + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_buttonExecuteActionPerformed + + private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed + abort(); + }//GEN-LAST:event_buttonAbortActionPerformed + + EditorDialog dlgConfig; + private void buttonPlotActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPlotActionPerformed + try { + startPlot(); + plot(); + } catch (Exception ex) { + showException(ex); + } + + }//GEN-LAST:event_buttonPlotActionPerformed + + private void radioPlotActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioPlotActionPerformed + plot(); + }//GEN-LAST:event_radioPlotActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton buttonAbort; + private javax.swing.JButton buttonExecute; + private javax.swing.ButtonGroup buttonGroupPlot; + private javax.swing.JButton buttonPlot; + private javax.swing.JComboBox comboRunType; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel11; + private javax.swing.JLabel jLabel13; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel8; + private javax.swing.JLabel jLabel9; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel panelParameters; + 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 spinnerTime; + private javax.swing.JTextField textPrefix; + // End of variables declaration//GEN-END:variables +} diff --git a/plugins/Test.form b/plugins/Test.form new file mode 100644 index 0000000..8d29957 --- /dev/null +++ b/plugins/Test.form @@ -0,0 +1,88 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/plugins/Test.java b/plugins/Test.java new file mode 100644 index 0000000..589638a --- /dev/null +++ b/plugins/Test.java @@ -0,0 +1,130 @@ +/* + * Copyright (c) 2014 Paul Scherrer Institute. All rights reserved. + */ + +import ch.psi.pshell.core.Controller; +import ch.psi.pshell.ui.Panel; +import ch.psi.pshell.ui.Plugin; +import ch.psi.utils.State; +import ch.psi.utils.swing.SwingUtils; +import java.io.IOException; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.script.ScriptException; + +/** + * + */ +public class Test extends Panel { + + public Test() { + initComponents(); + } + + //Overridable callbacks + @Override + public void onInitialize(int runCount) { + + } + + @Override + public void onStateChange(State state, State former) { + + } + + @Override + public void onExecutedFile(String fileName, Object result) { + } + + + //Callback to perform update - in event thread + @Override + protected void doUpdate() { + } + + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + buttonExec = new javax.swing.JButton(); + buttonAbort = new javax.swing.JButton(); + motorPanel1 = new ch.psi.pshell.swing.MotorPanel(); + scriptButton1 = new ch.psi.pshell.swing.ScriptButton(); + + buttonExec.setText("Exec"); + buttonExec.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonExecActionPerformed(evt); + } + }); + + buttonAbort.setText("Abort"); + buttonAbort.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonAbortActionPerformed(evt); + } + }); + + motorPanel1.setDeviceName("m1"); + + scriptButton1.setScript("test"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(66, 66, 66) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(buttonExec) + .addGap(234, 234, 234) + .addComponent(scriptButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(buttonAbort)) + .addContainerGap(262, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addGap(88, 88, 88) + .addComponent(motorPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 0, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(23, 23, 23) + .addComponent(buttonExec)) + .addGroup(layout.createSequentialGroup() + .addGap(32, 32, 32) + .addComponent(scriptButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(buttonAbort) + .addGap(89, 89, 89) + .addComponent(motorPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(175, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + private void buttonExecActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonExecActionPerformed + try { + runAsync("test"); + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_buttonExecActionPerformed + + private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed + try { + abort(); + } catch (Exception ex) { + showException(ex); + } + }//GEN-LAST:event_buttonAbortActionPerformed + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton buttonAbort; + private javax.swing.JButton buttonExec; + private ch.psi.pshell.swing.MotorPanel motorPanel1; + private ch.psi.pshell.swing.ScriptButton scriptButton1; + // End of variables declaration//GEN-END:variables +} diff --git a/script/EnergyScan.py b/script/EnergyScan.py new file mode 100644 index 0000000..b2cd8cb --- /dev/null +++ b/script/EnergyScan.py @@ -0,0 +1,104 @@ +import os +import traceback + + +#Parameters +""" +E1 = 680 +E2 = 750 +TIME = 2 #min +DELAY = 10.0 #s +OFFSET1 = 1.0 #eV +OFFSET2 = -1.0 #eV +PREFIX = 'Data' +RUNTYPE = "+/-" +""" +print "\nStarting energy scan - Parameters: ", +print E1,E2,TIME,DELAY,OFFSET1,OFFSET2,PREFIX,RUNTYPE #,ALPHA + +#fid = caget(OTF_FID, 'i') + +def switchpol(activeID): + global pol_str + if activeID == 1: + caput(OTF_OFF1,OFFSET1) + caput(OTF_OFF2,OFFSET2-40) #detune ID2 + pol_str = "circ +" + elif activeID == 2: + caput(OTF_OFF1,OFFSET1-40) #detune ID1 + caput(OTF_OFF2,OFFSET2) + pol_str = "circ -" + else: + raise Exception("Invalid parameter") + + +pol_str = None +polswitch = 1 + + +input_path = "/sls/X11MA/Data1/public/X11MA/temp/" +output_path = input_path +file_prefix = time.strftime("%y%m%d") + +fid = get_next_fid(input_path, "o" + file_prefix) + +suffix = ("%03d" % fid) +input_file = input_path + "o" + file_prefix + "_" + suffix + ".dat" + + + +#Prepare scan +if RUNTYPE == "+/-": + caput(OTF_MODE1,1) # circ + in ID1 + caput(OTF_MODE2,2) # circ - in ID2 + wait_channel(OTF_DONE, 1, type = 'i') +else: + raise Exception("Invalid run type: " + RUNTYPE) + +switchpol(1) # tune ID1 --> polarization: C+ +time.sleep(1.0) + +wait_channel(OTF_DONE, 1, type = 'i') + + open_vg10() + +for rounds in [1,2]: + caput(OTF_E1, E1) + caput(OTF_E2, E2) + caput(OTF_TIME, TIME) + #fid = fid + 1 + caput(OTF_FTS,file_prefix) + caput(OTF_FID,fid) + time.sleep(2.0) + caput(OTF_ESET, E1) + wait_channel(OTF_DONE, 1, type = 'i') #??? + time.sleep(DELAY) + time.sleep(2.0) + + #Start the OTF scan + caput(OTF_START, 'GO') + + #Wait until scan is done + wait_channel(OTF_START, 'STOP', type = 's') + time.sleep(3.0) + + #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, "Scan " + str(rounds)) + + if polswitch == 1: + switchpol(2) # tune ID2 --> polarization:C- + polswitch = 0 + else: + polswitch = 1 + + time.sleep(3.0) + +close_vg10() + +print "Finished Energy scan" + +print("Success") diff --git a/script/local.groovy b/script/local.groovy new file mode 100644 index 0000000..6cd1527 --- /dev/null +++ b/script/local.groovy @@ -0,0 +1,3 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Deployment specific global definitions - executed after startup.groovy +/////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/script/local.js b/script/local.js new file mode 100644 index 0000000..17db863 --- /dev/null +++ b/script/local.js @@ -0,0 +1,4 @@ +/////////////////////////////////////////////////////////////////////////////////////////////////// +// Deployment specific global definitions - executed after startup.js +/////////////////////////////////////////////////////////////////////////////////////////////////// + diff --git a/script/local.py b/script/local.py new file mode 100644 index 0000000..966d162 --- /dev/null +++ b/script/local.py @@ -0,0 +1,88 @@ +################################################################################################### +# Deployment specific global definitions - executed after startup.py +################################################################################################### + + +OTF_START = "X11MA-OTF:GO" +OTF_E1 = "X11MA-OTF:E1" +OTF_E2 = "X11MA-OTF:E2" +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" +VG10 = "X11MA-EPS-VG10:SET" + + + + +FST = time.strftime("%y%m%d") +FID = 0 + +""" +X11PHS-E:OPT +""" + +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, type): + print "Waiting " + str(name) + " = " + str(value) + cawait(name, value, type = type) + print "Done" + +def convert_file(input_file_name, output_file_name, field = 0, pol = 0, keithley_3 = False): + sep = "\t" + line_sep = "\r\n" + with open(input_file_name) as inp: + lines = inp.readlines() + with open(output_file_name, "wb") as out: + out.write("Energy" + sep + "rbkenergy" + sep + "Mag" + sep + "Pol" + sep + "Io" + sep + "TEY" + sep + "Norm" + 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 + sep + Ecrbk + sep + str(field) + sep + str(pol) + sep + CADC1 + sep + CADC2 + sep + (CADC3 if keithley_3 else NORM) + line_sep) + out.write(" " + Ecrbk + s + Ecrbk + s + str(field) + s + str(pol) + s + CADC1 + s + CADC2 + s + (CADC3 if keithley_3 else NORM) + line_sep) + except: + traceback.print_exc() + +def open_vg10(): + if caget ("X11MA-OP-VG10:OPEN",'i') != 1: + caput(VG10, 0) + time.sleep(0.1) + caput(VG10, 1) + +def close_vg10(): + if caget ("X11MA-OP-VG10:OPEN",'i') == 1: + caput(VG10, 0) + time.sleep(0.1) + caput(VG10, 1) + + +def plot_file(file, ctxt = None): + """ + """ + sep = "\t" + table = Table.load(file, sep, '#') + plots = plot(table, context = ctxt) + + diff --git a/script/test.py b/script/test.py new file mode 100644 index 0000000..2e40e2a --- /dev/null +++ b/script/test.py @@ -0,0 +1,59 @@ +E1 = 710 +E2 = 720 +TIME = 1 #min +DELAY = 10.0 #s +MODE = 'CIRC +' +OFFSET = -9.0 +FOLDER = '2015_04/20150417' +FILE = 'Fe_plus' +OPT = 'PCM+ID1' +ALPHA=0 + + + +print "\nStarting energy scan - Parameters: ", +print E1,E2,TIME,DELAY,MODE ,OFFSET ,FOLDER ,FILE ,ALPHA + +def wait_channel(name, value, type): + print "Waiting " + str(name) + " = " + str(value) + cawait(name, value, type = type) + print "Done" + + +#Prepare scan +caput(OTF_MODE1, MODE) +#TODO: MODE2 +time.sleep(1.0) +if MODE == 'LINEAR': + caput(OTF_ALPHA1, ALPHA) + #TODO: ALPHA2 +#wait_channel('X07MA-ID:DONE', 'DONE', type = 's') +#caput('X07MA-ID:ENERGY-OFFS', OFFSET) #??? +#wait_channel('X07MA-ID:DONE', 'DONE', type = 's') +caput (OTF_OPT, OPT) +caput(OTF_E1, E1) +caput(OTF_E2, E2) +caput(OTF_TIME, TIME) +caput('FOLDER', FOLDER) #???? +#caputq('X07MA-PHS-E:GO.A', E1) +#wait_channel('X07MA-PHS:alldone', '1', type = 's') #??? +time.sleep(0.5) +caput('FILE', FILE) #??? +time.sleep(0.1) +#caput('X07MA-OP-VG13:WT_SET', 'Try open') #??? +#time.sleep(5.0) +#caput('X07MA-OP-VG13:WT_SET', 'Try open') +#time.sleep(DELAY) + +#Start the OTF scan +caput(OTF_START, 'START', type = 's') + +#Wait until scan is done +wait_channel(OTF_START, 'STOP', type = 's') +time.sleep(2.0) +print "Finished Energy scan" + + +#TODO: plot file + +print("Success")