This commit is contained in:
X11MA
2015-12-02 18:23:59 +01:00
commit a294078e3f
19 changed files with 1495 additions and 0 deletions

26
config/config.properties Normal file
View File

@@ -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=

View File

@@ -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

View File

@@ -0,0 +1 @@
Fe=650.0;750.0;2.0;0.0;0.0;0.0;0.0;0.0

View File

@@ -0,0 +1,2 @@
./home/plugins/Test.java=disabled
./home/plugins/EnergyScan.java=enabled

19
config/setup.properties Normal file
View File

@@ -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

12
devices/dp1.properties Normal file
View File

@@ -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

13
devices/m1.properties Normal file
View File

@@ -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

13
devices/m2.properties Normal file
View File

@@ -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

17
devices/src1.properties Normal file
View File

@@ -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

17
devices/src2.properties Normal file
View File

@@ -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

381
plugins/EnergyScan.form Normal file
View File

@@ -0,0 +1,381 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<NonVisualComponents>
<Component class="javax.swing.ButtonGroup" name="buttonGroupPlot">
</Component>
</NonVisualComponents>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="panelParameters" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jPanel2" max="32767" attributes="0"/>
</Group>
<Component id="jPanel3" alignment="1" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="16" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel2" linkSize="12" max="-2" attributes="0"/>
<Component id="panelParameters" linkSize="12" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="panelParameters">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Parameters"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel8" linkSize="4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerOffset1" linkSize="5" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel3" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="spinnerE1" linkSize="2" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="spinnerTime" linkSize="2" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace pref="84" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel4" linkSize="4" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" linkSize="4" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel13" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="spinnerE2" linkSize="5" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="spinnerDelay" linkSize="5" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="spinnerOffset2" linkSize="5" alignment="1" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="43" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel9" min="-2" max="-2" attributes="0"/>
<Component id="jLabel11" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="comboRunType" linkSize="14" min="-2" pref="105" max="-2" attributes="0"/>
<Component id="textPrefix" linkSize="14" min="-2" pref="94" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerE1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerE2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerTime" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerDelay" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerOffset1" alignment="3" max="32767" attributes="0"/>
<Component id="jLabel13" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerOffset2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textPrefix" alignment="3" max="32767" attributes="0"/>
</Group>
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="comboRunType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel11" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="E1:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerE1">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="690.0" maximum="9999.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="E2:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerE2">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="755.0" maximum="9999.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Time(min):"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerTime">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="3.0" maximum="60.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Delay(s):"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerDelay">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="10.0" maximum="600.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel8">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Offset1:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerOffset1">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" maximum="20.0" minimum="-20.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel13">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Offset2:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerOffset2">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" maximum="20.0" minimum="-20.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel11">
<Properties>
<Property name="text" type="java.lang.String" value="Run Type:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboRunType">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="1">
<StringItem index="0" value="+/-"/>
</StringArray>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel9">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Prefix:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textPrefix">
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel2">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Plot Options"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="buttonPlot" max="32767" attributes="0"/>
<Component id="radioK1" linkSize="7" alignment="0" max="32767" attributes="0"/>
<Component id="radioK3" linkSize="7" max="32767" attributes="0"/>
</Group>
<EmptySpace pref="34" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="radioK1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="radioK3" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="129" max="32767" attributes="0"/>
<Component id="buttonPlot" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JRadioButton" name="radioK1">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroupPlot"/>
</Property>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="K1"/>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[100, 22]"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="radioPlotActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JRadioButton" name="radioK3">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroupPlot"/>
</Property>
<Property name="text" type="java.lang.String" value="K3"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="radioPlotActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonPlot">
<Properties>
<Property name="text" type="java.lang.String" value="Plot"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonPlotActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel3">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Scan Control"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="buttonAbort" min="-2" pref="100" max="-2" attributes="0"/>
<Component id="buttonExecute" min="-2" pref="100" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Component id="buttonExecute" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonAbort" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonExecute">
<Properties>
<Property name="text" type="java.lang.String" value="Start"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonExecuteActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonAbort">
<Properties>
<Property name="text" type="java.lang.String" value="Abort"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonAbortActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

513
plugins/EnergyScan.java Normal file
View File

@@ -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<LinePlot> plots = getController().plot(new PlotDescriptor[]{descriptors}, null);
scanPlot = (LinePlotBase) plots.get(0);
scanSeries = scanPlot.getSeries(0);
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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});
}// </editor-fold>//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
}

88
plugins/Test.form Normal file
View File

@@ -0,0 +1,88 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="66" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="buttonExec" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="234" max="-2" attributes="0"/>
<Component id="scriptButton1" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="buttonAbort" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="262" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="88" max="-2" attributes="0"/>
<Component id="motorPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="23" max="-2" attributes="0"/>
<Component id="buttonExec" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="32" max="-2" attributes="0"/>
<Component id="scriptButton1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonAbort" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="89" max="-2" attributes="0"/>
<Component id="motorPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="175" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonExec">
<Properties>
<Property name="text" type="java.lang.String" value="Exec"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonExecActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonAbort">
<Properties>
<Property name="text" type="java.lang.String" value="Abort"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonAbortActionPerformed"/>
</Events>
</Component>
<Component class="ch.psi.pshell.swing.MotorPanel" name="motorPanel1">
<Properties>
<Property name="deviceName" type="java.lang.String" value="m1"/>
</Properties>
</Component>
<Component class="ch.psi.pshell.swing.ScriptButton" name="scriptButton1">
<Properties>
<Property name="script" type="java.lang.String" value="test"/>
</Properties>
</Component>
</SubComponents>
</Form>

130
plugins/Test.java Normal file
View File

@@ -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")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//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))
);
}// </editor-fold>//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
}

104
script/EnergyScan.py Normal file
View File

@@ -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")

3
script/local.groovy Normal file
View File

@@ -0,0 +1,3 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// Deployment specific global definitions - executed after startup.groovy
///////////////////////////////////////////////////////////////////////////////////////////////////

4
script/local.js Normal file
View File

@@ -0,0 +1,4 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// Deployment specific global definitions - executed after startup.js
///////////////////////////////////////////////////////////////////////////////////////////////////

88
script/local.py Normal file
View File

@@ -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)

59
script/test.py Normal file
View File

@@ -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")