Update correlation plot and screen panel

This commit is contained in:
root
2018-07-25 17:14:25 +02:00
parent 82306b88b4
commit b9115c90b8
29 changed files with 1734 additions and 118 deletions
+1
View File
@@ -53,3 +53,4 @@ gsry=ch.psi.pshell.epics.Positioner|SINEG01-MSOL130:ROT_Y_SP SINEG01-MSOL130:ROT
#adc_xh1=ch.psi.pshell.epics.ChannelInteger|SARFE10-PBPG050:HAMP-014-x-h1-DATA-SUM|||true
#adc_yh2=ch.psi.pshell.epics.ChannelInteger|SARFE10-PBPG050:HAMP-011-y-h2-DATA-SUM|||true
#blm_raw_test=ch.psi.pshell.epics.ChannelDoubleArray|SINDI02-DBLM025:LOSS_SIGNAL_RAW|||true
mps_beam_ok=ch.psi.pshell.epics.ChannelInteger|SGE-EMED-LLRF:ALL_OK_L1_MA|||
+1
View File
@@ -8,6 +8,7 @@ ScreenPanel2.java=disabled
ScreenPanel3.java=disabled
SfCamera.java=enabled
WireScan.java=disabled
WireScanCalibration.java=disabled
SchottkyScan.java=disabled
Correlation.java=disabled
Cameras.java=disabled
+10 -8
View File
@@ -1,8 +1,10 @@
#Mon Jun 25 12:57:35 CEST 2018
colormap=Flame
#Wed Jul 25 17:06:36 CEST 2018
\u0000=
\u0000\u0000\u0000\u0000=
colormap=Rainbow
colormapAutomatic=true
colormapMax=4000.0
colormapMin=0.0
colormapMax=6000.0
colormapMin=81.0
flipHorizontally=false
flipVertically=false
grayscale=false
@@ -21,10 +23,10 @@ rotation=0.0
rotationCrop=false
scale=1.0
serverURL=null
spatialCalOffsetX=-938.4756464214289
spatialCalOffsetY=-887.658980452227
spatialCalScaleX=-8.510638192507606
spatialCalScaleY=-8.235816808193258
spatialCalOffsetX=-50.03903200624512
spatialCalOffsetY=-50.048780487804876
spatialCalScaleX=-1.0
spatialCalScaleY=-1.0
spatialCalUnits=null
t=
transpose=false
+7 -7
View File
@@ -1,7 +1,7 @@
#Fri Jun 08 11:47:53 CEST 2018
#Tue Jul 24 05:27:46 CEST 2018
colormap=Flame
colormapAutomatic=true
colormapMax=1000.0
colormapAutomatic=false
colormapMax=2000.0
colormapMin=0.0
flipHorizontally=false
flipVertically=false
@@ -16,9 +16,9 @@ roiY=0
rotation=0.0
rotationCrop=false
scale=1.0
spatialCalOffsetX=-143.6163777820679
spatialCalOffsetY=-118.46093411080528
spatialCalScaleX=-15.559672914702317
spatialCalScaleY=-11.299434661865234
spatialCalOffsetX=88.97726578456339
spatialCalOffsetY=-97.2092928484633
spatialCalScaleX=-0.766283555464311
spatialCalScaleY=-0.7662836119186046
spatialCalUnits=null
transpose=false
+2 -1
View File
@@ -1,4 +1,4 @@
#Thu Jul 13 12:56:15 CEST 2017
#Wed Jul 25 10:35:40 CEST 2018
maxValue=NaN
minValue=NaN
offset=0.0
@@ -6,4 +6,5 @@ precision=-1
resolution=NaN
rotation=false
scale=1.0
sign_bit=0
unit=null
+2 -2
View File
@@ -1,5 +1,5 @@
#Mon Jun 25 14:59:33 CEST 2018
defaultSpeed=707.1067811865476
#Wed Jun 27 13:42:28 CEST 2018
defaultSpeed=6000.0
estbilizationDelay=0
hasEnable=false
homingType=None
+5 -5
View File
@@ -1,4 +1,4 @@
#Mon Jun 04 15:57:42 CEST 2018
#Wed Jul 25 14:36:06 CEST 2018
colormap=Flame
colormapAutomatic=true
colormapMax=NaN
@@ -16,9 +16,9 @@ roiY=0
rotation=0.0
rotationCrop=false
scale=1.0
spatialCalOffsetX=-861.4939970777481
spatialCalOffsetY=-820.4883730911062
spatialCalScaleX=-18.90359092620482
spatialCalScaleY=-19.37984500632817
spatialCalOffsetX=-50.03909304143862
spatialCalOffsetY=-50.048875855327466
spatialCalScaleX=-1.0
spatialCalScaleY=-1.0
spatialCalUnits=mm
transpose=false
+2 -1
View File
@@ -1,8 +1,9 @@
#Thu May 03 16:23:33 CEST 2018
#Fri Jun 29 17:40:53 CEST 2018
maxValue=NaN
minValue=NaN
offset=0.0
precision=1
resolution=NaN
scale=1.0
sign_bit=0
unit=pC
+2 -1
View File
@@ -1,8 +1,9 @@
#Thu May 03 16:25:04 CEST 2018
#Fri Jun 29 17:40:53 CEST 2018
maxValue=NaN
minValue=NaN
offset=0.0
precision=3
resolution=NaN
scale=1.0
sign_bit=0
unit=MeV
+2 -1
View File
@@ -1,4 +1,4 @@
#Tue Jun 13 10:51:13 CEST 2017
#Fri Jun 29 17:40:53 CEST 2018
maxValue=1.0
minValue=-1.0
offset=0.0
@@ -6,4 +6,5 @@ precision=3
resolution=NaN
rotation=false
scale=1.0
sign_bit=0
unit=mrad
+2 -1
View File
@@ -1,4 +1,4 @@
#Tue Jun 13 10:51:13 CEST 2017
#Fri Jun 29 17:40:53 CEST 2018
maxValue=1.0
minValue=-1.0
offset=0.0
@@ -6,4 +6,5 @@ precision=3
resolution=NaN
rotation=false
scale=1.0
sign_bit=0
unit=mrad
+2 -1
View File
@@ -1,4 +1,4 @@
#Tue Jun 13 10:51:13 CEST 2017
#Fri Jun 29 17:40:53 CEST 2018
maxValue=1.0
minValue=-1.0
offset=0.0
@@ -6,4 +6,5 @@ precision=3
resolution=NaN
rotation=false
scale=1.0
sign_bit=0
unit=mm
+2 -1
View File
@@ -1,4 +1,4 @@
#Tue Jun 13 10:51:13 CEST 2017
#Fri Jun 29 17:40:53 CEST 2018
maxValue=1.0
minValue=-1.0
offset=0.0
@@ -6,4 +6,5 @@ precision=3
resolution=NaN
rotation=false
scale=1.0
sign_bit=0
unit=mm
+2 -1
View File
@@ -1,4 +1,4 @@
#Tue Jun 13 10:51:13 CEST 2017
#Fri Jun 29 17:40:53 CEST 2018
maxValue=180.0
minValue=-179.99
offset=0.0
@@ -6,4 +6,5 @@ precision=2
resolution=1.0
rotation=false
scale=1.0
sign_bit=0
unit=DEG
+2 -1
View File
@@ -1,4 +1,4 @@
#Tue Jun 13 10:51:13 CEST 2017
#Fri Jun 29 17:40:53 CEST 2018
maxValue=210.0
minValue=0.0
offset=0.0
@@ -6,4 +6,5 @@ precision=3
resolution=0.02
rotation=false
scale=1.0
sign_bit=0
unit=A
+2 -1
View File
@@ -1,8 +1,9 @@
#Thu May 03 16:25:49 CEST 2018
#Fri Jun 29 17:40:53 CEST 2018
maxValue=NaN
minValue=NaN
offset=0.0
precision=2
resolution=NaN
scale=1.0
sign_bit=0
unit=Hz
+314
View File
@@ -0,0 +1,314 @@
<?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="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="plot" pref="277" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Component id="plot" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="ch.psi.pshell.plot.LinePlotJFree" name="plot">
<Properties>
<Property name="title" type="java.lang.String" value=""/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel1">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonStart" min="-2" pref="189" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel7" linkSize="3" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel6" linkSize="3" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" linkSize="3" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel8" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="checkQuadratic" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonElog" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Component id="textDevY" alignment="0" max="32767" attributes="0"/>
<Component id="textDevX" pref="318" max="32767" attributes="0"/>
<Component id="comboTypeY" min="-2" max="-2" attributes="0"/>
<Component id="comboTypeX" min="-2" max="-2" attributes="0"/>
<Component id="textCorrelation" linkSize="4" alignment="0" pref="250" max="32767" attributes="0"/>
<Component id="spinnerInterval" linkSize="2" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="spinnerWindow" linkSize="2" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="textLinear" linkSize="4" alignment="0" pref="250" max="32767" attributes="0"/>
<Component id="checkLinear" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
<Component id="textPeak" alignment="0" max="32767" attributes="0"/>
<Component id="textQuadratic" linkSize="4" alignment="0" pref="250" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<Component id="textDevX" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="comboTypeX" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<Component id="textDevY" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="5" max="-2" attributes="0"/>
<Component id="comboTypeY" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerInterval" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerWindow" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="checkLinear" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="checkQuadratic" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonElog" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="15" max="32767" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="textCorrelation" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel6" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="textLinear" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel7" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="textQuadratic" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel8" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="textPeak" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="16" max="32767" attributes="0"/>
<Component id="buttonStart" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="45" 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="X device:"/>
</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="Y device:"/>
</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="Interval (s):"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerInterval">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.1" minimum="0.001" 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="Window size:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerWindow">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="50" minimum="3" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonStart">
<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="buttonStartActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="Correlation:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textCorrelation">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="Liner fit:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textLinear">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel7">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="Quadratric fit:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textQuadratic">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkLinear">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Linear fit"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkQuadratic">
<Properties>
<Property name="text" type="java.lang.String" value="Quadratic fit"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboTypeX">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="3">
<StringItem index="0" value="Channel"/>
<StringItem index="1" value="Stream"/>
<StringItem index="2" value="Camera"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboTypeXActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JComboBox" name="comboTypeY">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="3">
<StringItem index="0" value="Channel"/>
<StringItem index="1" value="Stream"/>
<StringItem index="2" value="Camera"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboTypeYActionPerformed"/>
</Events>
</Component>
<Component class="ch.psi.pshell.swing.ChannelSelector" name="textDevX">
<Properties>
<Property name="historySize" type="int" value="20"/>
<Property name="name" type="java.lang.String" value="Correlation_textDevX" noResource="true"/>
</Properties>
</Component>
<Component class="ch.psi.pshell.swing.ChannelSelector" name="textDevY">
<Properties>
<Property name="historySize" type="int" value="20"/>
<Property name="name" type="java.lang.String" value="Correlation_textDevY" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonElog">
<Properties>
<Property name="text" type="java.lang.String" value="ELOG"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonElogActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel8">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="Peak:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textPeak">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>
+583
View File
@@ -0,0 +1,583 @@
/*
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
*/
import ch.psi.pshell.plot.Plot;
import ch.psi.pshell.swing.ChannelSelector;
import ch.psi.pshell.ui.App;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import ch.psi.utils.Chrono;
import ch.psi.utils.swing.SwingUtils;
import ch.psi.utils.swing.SwingUtils.OptionResult;
import ch.psi.utils.swing.SwingUtils.OptionType;
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.HashMap;
import java.util.List;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
/**
*
*/
public class Correlation2 extends Panel {
public Correlation2() {
initComponents();
this.setPersistedComponents(new Component[]{textDevX, textDevY, spinnerInterval, spinnerWindow, comboTypeX, comboTypeY});
plot.getAxis(Plot.AxisId.X).setLabel(null);
plot.getAxis(Plot.AxisId.Y).setLabel(null);
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
super.onInitialize(runCount);
this.startTimer(100, 10);
if (App.hasArgument("dx")) {
textDevX.setText(App.getArgumentValue("dx"));
}
if (App.hasArgument("dy")) {
textDevY.setText(App.getArgumentValue("dy"));
}
try{
if (App.hasArgument("dxtype")) {
comboTypeX.setSelectedIndex(Integer.valueOf(App.getArgumentValue("dxtype")));
}
} catch (Exception ex){
System.err.println(ex.getMessage());
}
try{
if (App.hasArgument("dytype")) {
comboTypeY.setSelectedIndex(Integer.valueOf(App.getArgumentValue("dytype")));
}
} catch (Exception ex){
System.err.println(ex.getMessage());
}
try{
if (App.hasArgument("interval")) {
spinnerInterval.setValue(Double.valueOf(App.getArgumentValue("interval")));
}
} catch (Exception ex){
System.err.println(ex.getMessage());
}
try{
if (App.hasArgument("window")) {
spinnerWindow.setValue(Integer.valueOf(App.getArgumentValue("window")));
}
} catch (Exception ex){
System.err.println(ex.getMessage());
}
comboTypeXActionPerformed(null);
comboTypeYActionPerformed(null);
}
@Override
protected void onTimer(){
if (isRunning()){
updateResults();
}
}
//DecimalFormat formatter = new DecimalFormat("0.##E0");
void updateResults(){
try{
textCorrelation.setText(String.format("%1.4f", Double.valueOf((Double)getContext().getInterpreterVariable("corr"))));
} catch (Exception ex){
textCorrelation.setText("");
}
if (checkLinear.isSelected()){
try{
List pars = (List)getContext().getInterpreterVariable("pars_lin");
//textLinear.setText(String.format("%1.3fx%+1.3f", (Double)(pars.get(1)), (Double)(pars.get(0))));
textLinear.setText(String.format("%1.6gx%+1.6g",pars.get(1), pars.get(0)));
} catch (Exception ex){
textLinear.setText("");
}
}
if (checkQuadratic.isSelected()){
try{
List pars = (List)getContext().getInterpreterVariable("pars_quad");
//textQuadratic.setText(String.format("%1.2fx\u00B2 %+1.2fx%+1.2f", (Double)(pars.get(0)), (Double)(pars.get(1)), (Double)(pars.get(0))));
textQuadratic.setText(String.format("%1.3gx\u00B2%+1.3gx%+1.3g", pars.get(0), pars.get(1), pars.get(0)));
//textQuadratic.setText(formatter.format(pars.get(2))+ formatter.format(pars.get(1)) + formatter.format(pars.get(0)));
} catch (Exception ex){
textQuadratic.setText("");
}
try{
String peak = (String)getContext().getInterpreterVariable("pos_peak");
if (peak!=null){
textPeak.setText(peak + " (max)");
} else {
peak = (String)getContext().getInterpreterVariable("neg_peak");
if (peak!=null){
textPeak.setText(peak + " (min)");
} else {
textPeak.setText("");
}
}
} catch (Exception ex){
textPeak.setText("");
}
}
}
@Override
public void onStateChange(State state, State former) {
buttonStart.setEnabled((state==State.Ready) || (state==State.Busy));
if (isRunning()){
if (state==State.Ready){
buttonStart.setText("Start");
}
} else {
if (state==State.Busy){
buttonStart.setText("Stop");
buttonElog.setEnabled(true);
}
}
textDevX.setEnabled(state==State.Ready);
textDevY.setEnabled(state==State.Ready);
spinnerInterval.setEnabled(state==State.Ready);
spinnerWindow.setEnabled(state==State.Ready);
comboTypeX.setEnabled(state==State.Ready);
comboTypeY.setEnabled(state==State.Ready);
checkLinear.setEnabled(state==State.Ready);
checkQuadratic.setEnabled(state==State.Ready);
if ((former==State.Initializing) && (state == State.Ready)){
if (App.hasArgument("start")) {
buttonStartActionPerformed(null);
}
}
}
boolean isRunning(){
return buttonStart.getText().equals("Stop");
}
@Override
public void onExecutedFile(String fileName, Object result) {
}
//Callback to perform update - in event thread
@Override
protected void doUpdate() {
}
void elog(String logbook, String title, String message, String[] attachments) throws Exception {
String domain = "";
String category = "Info";
String entry = "";
StringBuffer cmd = new StringBuffer();
cmd.append("G_CS_ELOG_add -l \"").append(logbook).append("\" ");
cmd.append("-a \"Author=ScreenPanel\" ");
cmd.append("-a \"Type=pshell\" ");
cmd.append("-a \"Entry=").append(entry).append("\" ");
cmd.append("-a \"Title=").append(title).append("\" ");
cmd.append("-a \"Category=").append(category).append("\" ");
cmd.append("-a \"Domain=").append(domain).append("\" ");
for (String attachment : attachments) {
cmd.append("-f \"").append(attachment).append("\" ");
}
cmd.append("-n 1 ");
cmd.append("\"").append(message).append("\" ");
System.out.println(cmd.toString());
final Process process = Runtime.getRuntime().exec(new String[]{"bash", "-c", cmd.toString()});
new Thread(() -> {
try {
process.waitFor();
int bytes = process.getInputStream().available();
byte[] arr = new byte[bytes];
process.getInputStream().read(arr, 0, bytes);
System.out.println(new String(arr));
bytes = process.getErrorStream().available();
arr = new byte[bytes];
process.getErrorStream().read(arr, 0, bytes);
System.err.println(new String(arr));
} catch (Exception ex) {
System.err.println(ex);
}
}).start();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
plot = new ch.psi.pshell.plot.LinePlotJFree();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
spinnerInterval = new javax.swing.JSpinner();
jLabel4 = new javax.swing.JLabel();
spinnerWindow = new javax.swing.JSpinner();
buttonStart = new javax.swing.JButton();
jLabel5 = new javax.swing.JLabel();
textCorrelation = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
textLinear = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
textQuadratic = new javax.swing.JTextField();
checkLinear = new javax.swing.JCheckBox();
checkQuadratic = new javax.swing.JCheckBox();
comboTypeX = new javax.swing.JComboBox();
comboTypeY = new javax.swing.JComboBox();
textDevX = new ch.psi.pshell.swing.ChannelSelector();
textDevY = new ch.psi.pshell.swing.ChannelSelector();
buttonElog = new javax.swing.JButton();
jLabel8 = new javax.swing.JLabel();
textPeak = new javax.swing.JTextField();
plot.setTitle("");
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel1.setText("X device:");
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel2.setText("Y device:");
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel3.setText("Interval (s):");
spinnerInterval.setModel(new javax.swing.SpinnerNumberModel(Double.valueOf(0.1d), Double.valueOf(0.001d), null, Double.valueOf(1.0d)));
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel4.setText("Window size:");
spinnerWindow.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(50), Integer.valueOf(3), null, Integer.valueOf(1)));
buttonStart.setText("Start");
buttonStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonStartActionPerformed(evt);
}
});
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel5.setText("Correlation:");
textCorrelation.setEditable(false);
textCorrelation.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel6.setText("Liner fit:");
textLinear.setEditable(false);
textLinear.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel7.setText("Quadratric fit:");
textQuadratic.setEditable(false);
textQuadratic.setHorizontalAlignment(javax.swing.JTextField.CENTER);
checkLinear.setSelected(true);
checkLinear.setText("Linear fit");
checkQuadratic.setText("Quadratic fit");
comboTypeX.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Channel", "Stream", "Camera" }));
comboTypeX.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
comboTypeXActionPerformed(evt);
}
});
comboTypeY.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Channel", "Stream", "Camera" }));
comboTypeY.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
comboTypeYActionPerformed(evt);
}
});
textDevX.setHistorySize(20);
textDevX.setName("Correlation_textDevX"); // NOI18N
textDevY.setHistorySize(20);
textDevY.setName("Correlation_textDevY"); // NOI18N
buttonElog.setText("ELOG");
buttonElog.setEnabled(false);
buttonElog.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonElogActionPerformed(evt);
}
});
jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel8.setText("Peak:");
textPeak.setEditable(false);
textPeak.setHorizontalAlignment(javax.swing.JTextField.CENTER);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonStart, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(checkQuadratic)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonElog)
.addContainerGap())
.addComponent(textDevY, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(textDevX, javax.swing.GroupLayout.DEFAULT_SIZE, 318, Short.MAX_VALUE)
.addComponent(comboTypeY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(comboTypeX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(textCorrelation, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(spinnerInterval, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerWindow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(textLinear, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(checkLinear)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(textPeak, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(textQuadratic, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE))))
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3, jLabel4});
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerInterval, spinnerWindow});
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel5, jLabel6, jLabel7});
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {textCorrelation, textLinear, textQuadratic});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(textDevX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(comboTypeX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2)
.addComponent(textDevY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(5, 5, 5)
.addComponent(comboTypeY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(spinnerInterval, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(spinnerWindow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(checkLinear)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(checkQuadratic)
.addComponent(buttonElog))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 15, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(textCorrelation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel6)
.addComponent(textLinear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel7)
.addComponent(textQuadratic, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel8)
.addComponent(textPeak, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 16, Short.MAX_VALUE)
.addComponent(buttonStart)
.addGap(45, 45, 45))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())))
);
}// </editor-fold>//GEN-END:initComponents
private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed
try {
if (isRunning()){
//abort();
//Stooping smootly so displayed variables get updated.
getContext().setInterpreterVariable("stop_exec", true);
Chrono chrono = new Chrono();
while (!chrono.isTimeout(500)){
if (!Boolean.TRUE.equals(getContext().getInterpreterVariable("stop_exec"))){
break;
}
Thread.sleep(1);
}
if (Boolean.TRUE.equals(getContext().getInterpreterVariable("stop_exec"))){
System.out.println("Timeout stopping script - aborting...");
abort();
}
updateResults();
//buttonStart.setText("Start");
} else {
textCorrelation.setText("");
textLinear.setText("");
textQuadratic.setText("");
textPeak.setText("");
HashMap args = new HashMap();
args.put("dx", textDevX.getText());
args.put("dy", textDevY.getText());
args.put("interval", spinnerInterval.getValue());
args.put("window", spinnerWindow.getValue());
args.put("dxtype", comboTypeX.getSelectedIndex());
args.put("dytype", comboTypeY.getSelectedIndex());
args.put("linear_fit", checkLinear.isSelected());
args.put("quadratic_fit", checkQuadratic.isSelected());
args.put("p", plot);
runAsync("Correlation/Correlation2", args).handle((ok, ex) -> {
if (ex != null) {
ex.printStackTrace();
}
return ok;
});
///buttonStart.setText("Stop");
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonStartActionPerformed
private void comboTypeXActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboTypeXActionPerformed
if (comboTypeX.getSelectedIndex()==0){
textDevX.configure(ChannelSelector.Type.Epics, "http://epics-boot-info.psi.ch", "swissfel", 5000);
} else if (comboTypeX.getSelectedIndex()==1){
textDevX.configure(ChannelSelector.Type.DataAPI, "https://data-api.psi.ch/sf", "sf-databuffer", 5000);
} else if (comboTypeX.getSelectedIndex()==2){
textDevX.configure(ChannelSelector.Type.Camera, "sf-daqsync-01:8889", null, 5000);
}
}//GEN-LAST:event_comboTypeXActionPerformed
private void comboTypeYActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboTypeYActionPerformed
if (comboTypeY.getSelectedIndex()==0){
textDevY.configure(ChannelSelector.Type.Epics, "http://epics-boot-info.psi.ch", "swissfel", 5000);
} else if (comboTypeY.getSelectedIndex()==1){
textDevY.configure(ChannelSelector.Type.DataAPI, "https://data-api.psi.ch/sf", "sf-databuffer", 5000);
} else if (comboTypeY.getSelectedIndex()==2){
textDevY.configure(ChannelSelector.Type.Camera, "sf-daqsync-01:8889", null, 5000);
}
}//GEN-LAST:event_comboTypeYActionPerformed
private void buttonElogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonElogActionPerformed
try{
String snapshotFile = getContext().getSetup().expandPath("{context}/correlation_plot.png");
plot.saveSnapshot(snapshotFile, "png");
JPanel panel = new JPanel();
GridBagLayout layout = new GridBagLayout();
layout.columnWidths = new int[]{0, 180}; //Minimum width
layout.rowHeights = new int[]{30, 30, 30}; //Minimum height
panel.setLayout(layout);
JComboBox comboLogbook = new JComboBox(new String[]{"SwissFEL commissioning data", "SwissFEL commissioning"});
JTextField textComment = new JTextField();
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 0;
panel.add(new JLabel("Logbook:"), c);
c.gridy = 1;
panel.add(new JLabel("Comment:"), c);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 1;
panel.add(textComment, c);
c.gridy = 0;
panel.add(comboLogbook, c);
if (SwingUtils.showOption(getTopLevel(), "ELOG", panel, OptionType.OkCancel) == OptionResult.Yes) {
StringBuilder message = new StringBuilder();
message.append("Device X: ").append(String.valueOf(textDevX.getText())).append("\n");
message.append("Device Y: ").append(String.valueOf(textDevY.getText())).append("\n");
message.append("Interval: ").append(String.valueOf(spinnerInterval.getValue())).append("\n");
message.append("Samples: ").append(String.valueOf(spinnerWindow.getValue())).append("\n");
message.append("Correlation: ").append(textCorrelation.getText()).append("\n");
message.append("Linear fit: ").append(textLinear.getText()).append("\n");
message.append("Quadratic fit: ").append(textQuadratic.getText()).append("\n");
message.append("Peak: ").append(textPeak.getText()).append("\n");
message.append("Comment: ").append(textComment.getText()).append("\n");
elog((String) comboLogbook.getSelectedItem(), "Correlation Panel Snapshot", message.toString(), new String[]{snapshotFile});
}
}catch (Exception ex){
showException(ex);
}
}//GEN-LAST:event_buttonElogActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonElog;
private javax.swing.JButton buttonStart;
private javax.swing.JCheckBox checkLinear;
private javax.swing.JCheckBox checkQuadratic;
private javax.swing.JComboBox comboTypeX;
private javax.swing.JComboBox comboTypeY;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JPanel jPanel1;
private ch.psi.pshell.plot.LinePlotJFree plot;
private javax.swing.JSpinner spinnerInterval;
private javax.swing.JSpinner spinnerWindow;
private javax.swing.JTextField textCorrelation;
private ch.psi.pshell.swing.ChannelSelector textDevX;
private ch.psi.pshell.swing.ChannelSelector textDevY;
private javax.swing.JTextField textLinear;
private javax.swing.JTextField textPeak;
private javax.swing.JTextField textQuadratic;
// End of variables declaration//GEN-END:variables
}
+2 -2
View File
@@ -2092,7 +2092,7 @@ public class ScreenPanel3 extends Panel {
}
ArrayList<Frame> frames = new ArrayList<>();
frames.add(frame);
this.saveFrames("camera_snapshot", frames);
this.saveFrames(cameraName + "_camera_snapshot", frames);
//Enforce the same timestamp to data & image files.
snapshotFile = getContext().getExecutionPars().getPath() + ".png";
@@ -2140,7 +2140,7 @@ public class ScreenPanel3 extends Panel {
void saveStack() throws Exception {
synchronized (imageBuffer) {
saveFrames("camera_stack", imageBuffer);
saveFrames(cameraName + "_camera_stack", imageBuffer);
}
SwingUtils.showMessage(getTopLevel(), "Success", "Generated data file:\n" + getContext().getExecutionPars().getPath());
}
+265
View File
@@ -0,0 +1,265 @@
<?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 max="-2" attributes="0"/>
<Component id="panelLeft" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="plot" pref="425" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="panelLeft" max="32767" attributes="0"/>
<Component id="plot" pref="484" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="ch.psi.pshell.plot.LinePlotJFree" name="plot">
<Properties>
<Property name="title" type="java.lang.String" value=""/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="panelLeft">
<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="1" attributes="0">
<Component id="buttonScan" linkSize="2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonAbort" linkSize="2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel8" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel7" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel6" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel2" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel20" linkSize="1" alignment="0" pref="86" max="32767" attributes="0"/>
<Component id="jLabel9" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel10" linkSize="1" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel11" linkSize="1" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="comboWireScanner" alignment="0" max="32767" attributes="0"/>
<Component id="comboWire" alignment="0" max="32767" attributes="0"/>
<Component id="spinnerRangeStart" alignment="0" max="32767" attributes="0"/>
<Component id="spinnerRangeEnd" alignment="0" max="32767" attributes="0"/>
<Component id="spinnerScanPoints" alignment="0" max="32767" attributes="0"/>
<Component id="spinnerSaturation" alignment="0" max="32767" attributes="0"/>
<Component id="spinnerRangeFactor" alignment="0" max="32767" attributes="0"/>
<Component id="spinnerInitialGain" alignment="0" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="comboWireScanner" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel20" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="comboWire" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="70" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel6" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="spinnerRangeStart" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerRangeEnd" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel11" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerInitialGain" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="70" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerScanPoints" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerSaturation" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerRangeFactor" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="78" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonAbort" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonScan" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="43" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonScan">
<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="buttonScanActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JComboBox" name="comboWire">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="X1"/>
<StringItem index="1" value="Y1"/>
<StringItem index="2" value="X2"/>
<StringItem index="3" value="Y2"/>
</StringArray>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel7">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Range End X (&#xb5;m):"/>
</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="Wire:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboWireScanner">
</Component>
<Component class="javax.swing.JLabel" name="jLabel20">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Wire Scanner:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerRangeStart">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="-2000.0" maximum="10000.0" minimum="-10000.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</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="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Range Start (&#xb5;m):"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerRangeEnd">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="2000.0" maximum="10000.0" minimum="-10000.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerScanPoints">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="200.0" maximum="10000.0" minimum="10.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="Scan points:"/>
</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="Saturation:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerSaturation">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="1995.0" maximum="100000.0" minimum="10.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel10">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Range factor:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerRangeFactor">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="6.0" maximum="20.0" minimum="1.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel11">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Initial Gain:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerInitialGain">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.6" maximum="1.1" minimum="0.5" numberType="java.lang.Double" stepSize="0.1" type="number"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>
+309
View File
@@ -0,0 +1,309 @@
/*
* Copyright (c) 2014-2017 Paul Scherrer Institute. All rights reserved.
*/
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.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
/**
*
*/
public class WireScanCalibration extends Panel {
public WireScanCalibration() {
initComponents();
}c.getSetting(
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
try {
startTimer(1000, 10);
DefaultComboBoxModel model = new DefaultComboBoxModel();
eval("run('Devices/Elements')", true);
model.addElement("");
List<String> ret = (List<String>) ((Plugin)this).eval("get_wire_scanners()", true);
for (String scan: ret){
model.addElement(scan);
}
comboWireScanner.setModel(model);
} catch (Exception ex) {
showException(ex);
}
}
//S20CB01-DWSC440:MOTOR_1_HOME.PROC
@Override
public void onStateChange(State state, State former) {
buttonScan.setEnabled(state==State.Ready) ;
buttonAbort.setEnabled(state==State.Busy);
}
@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() {
plot = new ch.psi.pshell.plot.LinePlotJFree();
panelLeft = new javax.swing.JPanel();
buttonScan = new javax.swing.JButton();
comboWire = new javax.swing.JComboBox();
jLabel7 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
comboWireScanner = new javax.swing.JComboBox();
jLabel20 = new javax.swing.JLabel();
spinnerRangeStart = new javax.swing.JSpinner();
buttonAbort = new javax.swing.JButton();
jLabel6 = new javax.swing.JLabel();
spinnerRangeEnd = new javax.swing.JSpinner();
spinnerScanPoints = new javax.swing.JSpinner();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
spinnerSaturation = new javax.swing.JSpinner();
jLabel10 = new javax.swing.JLabel();
spinnerRangeFactor = new javax.swing.JSpinner();
jLabel11 = new javax.swing.JLabel();
spinnerInitialGain = new javax.swing.JSpinner();
plot.setTitle("");
buttonScan.setText("Start");
buttonScan.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonScanActionPerformed(evt);
}
});
comboWire.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "X1", "Y1", "X2", "Y2" }));
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel7.setText("Range End X (µm):");
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel2.setText("Wire:");
jLabel20.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel20.setText("Wire Scanner:");
spinnerRangeStart.setModel(new javax.swing.SpinnerNumberModel(-2000.0d, -10000.0d, 10000.0d, 1.0d));
buttonAbort.setText("Abort");
buttonAbort.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonAbortActionPerformed(evt);
}
});
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel6.setText("Range Start (µm):");
spinnerRangeEnd.setModel(new javax.swing.SpinnerNumberModel(2000.0d, -10000.0d, 10000.0d, 1.0d));
spinnerScanPoints.setModel(new javax.swing.SpinnerNumberModel(200.0d, 10.0d, 10000.0d, 1.0d));
jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel8.setText("Scan points:");
jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel9.setText("Saturation:");
spinnerSaturation.setModel(new javax.swing.SpinnerNumberModel(1995.0d, 10.0d, 100000.0d, 1.0d));
jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel10.setText("Range factor:");
spinnerRangeFactor.setModel(new javax.swing.SpinnerNumberModel(6.0d, 1.0d, 20.0d, 1.0d));
jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel11.setText("Initial Gain:");
spinnerInitialGain.setModel(new javax.swing.SpinnerNumberModel(0.6d, 0.5d, 1.1d, 0.1d));
javax.swing.GroupLayout panelLeftLayout = new javax.swing.GroupLayout(panelLeft);
panelLeft.setLayout(panelLeftLayout);
panelLeftLayout.setHorizontalGroup(
panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelLeftLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelLeftLayout.createSequentialGroup()
.addComponent(buttonScan)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonAbort)
.addContainerGap())
.addGroup(panelLeftLayout.createSequentialGroup()
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel20, javax.swing.GroupLayout.DEFAULT_SIZE, 86, Short.MAX_VALUE)
.addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(comboWireScanner, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboWire, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(spinnerRangeStart)
.addComponent(spinnerRangeEnd)
.addComponent(spinnerScanPoints)
.addComponent(spinnerSaturation)
.addComponent(spinnerRangeFactor)
.addComponent(spinnerInitialGain)))))
);
panelLeftLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel10, jLabel11, jLabel2, jLabel20, jLabel6, jLabel7, jLabel8, jLabel9});
panelLeftLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonAbort, buttonScan});
panelLeftLayout.setVerticalGroup(
panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelLeftLayout.createSequentialGroup()
.addGap(0, 0, 0)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(comboWireScanner, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel20))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(comboWire, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addGap(70, 70, 70)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel6)
.addComponent(spinnerRangeStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(spinnerRangeEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11)
.addComponent(spinnerInitialGain, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(70, 70, 70)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(spinnerScanPoints, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(spinnerSaturation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel10)
.addComponent(spinnerRangeFactor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 78, Short.MAX_VALUE)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonAbort)
.addComponent(buttonScan))
.addGap(43, 43, 43))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(panelLeft, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 425, Short.MAX_VALUE)
.addGap(11, 11, 11))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(panelLeft, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 484, Short.MAX_VALUE))
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
private void buttonScanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonScanActionPerformed
try {
ArrayList parameters = new ArrayList();
parameters.add(comboWireScanner.getSelectedItem().toString());
parameters.add(plot);
parameters.add(comboWire.getSelectedItem().toString());
parameters.add(spinnerRangeStart.getValue());
parameters.add(spinnerRangeEnd.getValue());
parameters.add(spinnerScanPoints.getValue());
parameters.add(spinnerSaturation.getValue());
parameters.add(spinnerRangeFactor.getValue());
parameters.add(spinnerInitialGain.getValue());
runAsync("Diagnostics/WireScanCalibration", parameters).handle((ret, ex) -> {
if (ex != null) {
getLogger().info("Exception executing scan: " + ex);
showException((Exception) ex);
} else {
SwingUtils.showMessage(WireScanCalibration.this, "Success", String.valueOf(ret));
}
return ret;
});
} catch (Exception ex) {
showException(ex);
ex.printStackTrace();
}
}//GEN-LAST:event_buttonScanActionPerformed
private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed
try {
abort();
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonAbortActionPerformed
//String caqtdm = "caqtdm -noMsg -stylefile sfop.qss -attach";
String caqtdm = "caqtdm -noMsg -stylefile sfop.qss";
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonAbort;
private javax.swing.JButton buttonScan;
private javax.swing.JComboBox comboWire;
private javax.swing.JComboBox comboWireScanner;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel panelLeft;
private ch.psi.pshell.plot.LinePlotJFree plot;
private javax.swing.JSpinner spinnerInitialGain;
private javax.swing.JSpinner spinnerRangeEnd;
private javax.swing.JSpinner spinnerRangeFactor;
private javax.swing.JSpinner spinnerRangeStart;
private javax.swing.JSpinner spinnerSaturation;
private javax.swing.JSpinner spinnerScanPoints;
// End of variables declaration//GEN-END:variables
}
+45
View File
@@ -0,0 +1,45 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("x", "SARUN13-DBPM070:X-REF-FB")
A2 = ChannelDouble("y", "SARUN13-DBPM070:Y-REF-FB")
camera_name = "SARBD01-DSCR110"
cam_server.start(camera_name+"_sp1", True) #True for shared pipeline
wait_cam_server_message()
S1 = cam_server.stream.getChild("intensity")
A1.initialize()
A2.initialize()
S1.initialize()
A1_init = A1.read()
A2_init = A2.read()
A1i = A1_init-0.1
A1f = A1_init+0.1
A2i = A2_init-0.1
A2f = A2_init+0.1
nstep = 11
lat = 5.0
nav = 10
def data_ok():
return (mps_beam_ok.read() == 1)
#def before_sample(record, scan):
# while not data_ok():
# time.sleep(1.0)
def after_sample(record, scan):
if not data_ok():
time.sleep(1.0)
record.invalidate()
print "Invalidating record: " + str(record)
try:
S1_averager = create_averager(S1, nav, 0.1)
r = ascan((A1,A2), (S1_averager), (A1i,A2i), (A1f,A2f), (nstep,nstep), latency=lat, after_read = after_sample)
Act1 = r.getPositions(0)
S1mean = [val.mean for val in r.getReadable(0)]
S1rms = [val.stdev for val in r.getReadable(0)]
finally:
A1.write(A1_init)
A1.close()
S1.close()
#S2.close()
+30 -1
View File
@@ -33,7 +33,9 @@ print dy, dytype
corr = None
pars_lin = None
pars_quad = None
pos_peak = None
neg_peak = None
stop_exec = None
bs = TYPE_STREAM in [dxtype, dytype]
@@ -134,7 +136,10 @@ try:
if get_exec_pars().source == CommandSource.ui:
if globals().has_key("marker"):
p.removeMarker(marker)
if globals().has_key("peak_marker"):
p.removeMarker(peak_marker)
marker=None
peak_marker=None
while(True):
@@ -190,6 +195,30 @@ try:
fitted_quad_function = PolynomialFunction(pars_quad)
ax = frange(x1, x2, res, True)
plot_function(p, fitted_quad_function, "Fit Quadratic", ax, color=Color.GREEN)
peak = None
peaks = calculate_peaks(fitted_quad_function, x1, x2, positive=True)
if len(peaks)>0:
peak = peaks[0]
pos_peak = str(round(peak,4))
peak_str = "Positive peak: " + pos_peak
else:
peaks = calculate_peaks(fitted_quad_function, x1, x2, positive=False)
if len(peaks)>0:
peak = peaks[0]
neg_peak = str(round(peak,4))
peak_str = "Negative peak: " + neg_peak
else:
pos_peak = neg_peak = None
if get_exec_pars().source == CommandSource.ui:
if peak_marker is not None:
p.removeMarker(peak_marker)
if peak is not None:
peak_marker = p.addMarker(peak, p.AxisId.X, peak_str, Color(0,128,0))
if stop_exec == True:
stop_exec = False
break
if bs != True:
time.sleep(interval)
finally:
+41 -73
View File
@@ -11,21 +11,23 @@ run("Diagnostics/sig_process_wrapper")
# Arguments and constants
###################################################################################################
ws_prefix = args[0] if is_panel else "SINDI01-DWSC090" #"S10DI01-DWSC010" #"S10CB07-DWSC440" #"SINDI01-DWSC090" \\
plt = args[1] if is_panel else plot(None, title = "Wire Scan Calibration")[0]
ws_wire = args[2] if is_panel else WireScanner.WireX1
cal_range = args[3] if is_panel else True
cal_gain = args[4] if is_panel else True
ws_prefix = args[0] if is_panel else "SINDI01-DWSC090" #"S10DI01-DWSC010" #"S10CB07-DWSC440" #"SINDI01-DWSC090" \\
plt = args[1] if is_panel else plot(None, title = "Wire Scan Calibration")[0]
ws_wire = args[2] if is_panel else WireScanner.WireX1
range_start = args[3] if is_panel else -2000
range_end = args[4] if is_panel else 2000
n_shot = args[5] if is_panel else 200
saturation = args[6] if is_panel else 19950 / 10 #S10DI01-DBLM113:AL1-WS-PMT-GAIN
scan_range_factor = args[7] if is_panel else 6.0
initial_gain = args[8] if is_panel else 0.6
ws_blm = get_wire_scanners_blms(ws_prefix )[0]
#S10DI01-DBLM113:AL1-WS-PMT-GAIN
SATURATION = 19950 / 10
MIN_GAIN, MAX_GAIN = 0.5, 1.1
OPT_STEP = 0.02
SCAN_RANGE_FACTOR = 6.0
DEFAULT_RANGE = [-2000.0, 2000.0]
print "WireScanCalibration parameters: ", ws_prefix, ws_wire, range_start, range_end, n_shot, saturation, scan_range_factor, initial_gain
###################################################################################################
@@ -56,18 +58,15 @@ def set_wire_scan_range(wire, start, end):
# Find COM
###################################################################################################
print "--------------- Find COM --------------- "
set_status("Performing wire scan to find initial COM...")
#2) Set the number of RF shots (N_shot) to be acquired during a single cycle WSC measurement (e.g.,N_shot=50)
n_shot = 200
set_gain(initial_gain)
print "Setting gain=", initial_gain
#3) Set a test scanning range (e.g.,Xmin=-1000,Xmax=+1000um)
x_min, x_max = DEFAULT_RANGE[0], DEFAULT_RANGE[1]
#4) For a given machine repetition-rate (RR), the scan speed is automatically set to WSC_speed=(Xmax- Xmin)*RR/N_shot
#Calculate speed
x_min, x_max = range_start, range_end
rr = get_repetition_rate()
ws_speed = (x_max- x_min)*rr/n_shot
#5) Proceed with a test scan (1 cycle) according to the above defined motor settings
args = [ ws_prefix , ws_wire, [x_min, x_max, x_min, x_max], 1, ws_speed, [], [ws_blm], 10, plt, False,1]
ret = run("Diagnostics/WireScan", args)
[rms_com, rms_sigma, com, sigma, pos_path, path] = ret
@@ -81,27 +80,18 @@ ret = run("Diagnostics/WireScan", args)
print "--------------- Optimize gain --------------- "
#1) Select a BLM to be used in the WSC measurement and enable the WS_START so that it can be extracted out of the MPS and PMT-Gain and attenuation can be adjusted
start_blm_ws(ws_blm, 600.0)
#6) Apply a gauss fit to the obtained WSC profile in order to determine X_CoM and standard deviation (sigma_Gauss)
#7) Move the wire to the X_CoM position and optimize the PMT-Gain so that the time-integral of the BLM voltage reaches a value equal to 90% of the Σsat level
#offset = caget(ws_prefix + ":W1X_U0_SP")
#motor_pos=offset - com * math.sqrt(2)
ws_info = WireScanInfo("ws_info", ws_prefix )
#self.wire_velocity = Channel(self.prefix + ":SCAN_VELO_SP")
motor_pos= ws_info.get_motor_pos(com, ws_wire)
caput(ws_prefix+":MOTOR_1.VAL", motor_pos) #DVAL?
#LOPR:0.5 HOPR:1.1
set_status("Setting motor position to COM...")
caput(ws_prefix+":MOTOR_1.VAL", motor_pos) #DVAL?
print "Starting stream..."
set_status("Creating stream for gain search..." )
st = Stream("blm_stream", dispatcher)
ch = ws_blm + ":B1_LOSS"
st.addScalar(ch, ch, int(100.0 / get_repetition_rate()), 0)
@@ -124,11 +114,12 @@ def get_loss():
start_gain = get_gain()
pos = start_val = get_loss()
loss = get_loss()
target = SATURATION * 0.8
target = saturation * 0.8
print "Start Gain = ", start_gain
print "Start Loss = ", start_val
print "Target = ", target
set_status("Searching gain to match peak losses of " + str(target) + "...")
def change_blm_ws_gain(gain):
set_gain(gain)
@@ -151,35 +142,20 @@ try:
finally:
stop_blm_ws(ws_blm)
"""
if start_val>target:
for pos in frange(start_gain, MIN_GAIN, -OPT_STEP, True):
change_blm_ws_gain(pos)
loss = get_loss()
print "Pos = ", pos, " Loss = ", loss
if loss<=target:
break
stop_blm_ws(ws_blm)
elif start_val<target:
for pos in frange(start_gain, MAX_GAIN, OPT_STEP, True):
change_blm_ws_gain(pos)
loss = get_loss()
print "Pos = ", pos, " Loss = ", loss
if loss>=target:
break
stop_blm_ws(ws_blm)
"""
print "Final Gain = ", pos
print "Final Loss = ", loss
print get_gain()
print get_loss()
#set_gain(0.6)
#set_gain(0.5)
print "Final Gain: ", pos
print "Final Loss: ", loss
result = "Loss value for final gain: " + str(loss) + " - Target value: " + str(target) + "\n"
if loss<target:
result = result + "Cannot reach target value. Setting gain to " + str(pos) + "\n"
else:
result = result + "Optimized gain: " + str(pos) + "\n"
st.close()
write_ws_gain(pos)
time.sleep(1.0)
###################################################################################################
@@ -189,27 +165,19 @@ time.sleep(1.0)
set_exec_pars(reset=True, defaults=True)
print "--------------- Optimize scan range --------------- "
set_status("Performing scan with optimal gain to define optimal range..." )
#caget(ws_blm+":SAT_RAW_SUM")
args = [ ws_prefix , ws_wire, [x_min, x_max, x_min, x_max], 1, ws_speed, [], [ws_blm], 10, plt, False,1]
ret = run("Diagnostics/WireScan", args)
[rms_com, rms_sigma, com, sigma, pos_path, path] = ret
[rms_com, rms_sigma, com, sigma, pos_path, path] = run("Diagnostics/WireScan", args)
x_range_min, x_range_max = com - SCAN_RANGE_FACTOR * sigma, com + SCAN_RANGE_FACTOR * sigma
print "Optimized range = ", x_range_min , " to " , x_range_max
x_range_min, x_range_max = com - scan_range_factor * sigma, com + scan_range_factor * sigma
print "Optimized range: " , x_range_min , " to " , x_range_max
set_wire_scan_range(ws_wire, x_range_min, x_range_max)
result = result + "Optimized range: " + str(x_range_min) + " to " + str(x_range_max)
#Att: caget(ws_blm + ":WS_PMT_ATT_VOLTS")
#8) Optimization of the scan interval: compare (Xmin, Xmax) with (X_CoM-N*sigma_Gauss , X_CoM+N*sigma_Gauss) where N is an integer value: N=5,6.
#9) Increase or decrease Xmin and/or Xmax by 10% and repeat the scan until the conditions [abs(Xmin)-abs(X_CoM- N*sigma_Gauss)]/abs(X_CoM-N*sigma_Gauss)<=0.1 and [abs(Xmax) - abs(X_CoM+N*sigma_Gauss)]/abs(X_CoM+N*sigma_Gauss) <=0.1 is reached
#10)Once condition 9) is reached, the flag: VALID_SCAN should be enabled and a WSC measurement can be performed according to the number of Cycles set in the control-panel and the optimized values of the scan interval and scan speed.
st.close()
set_return(result)
+1
View File
@@ -66,6 +66,7 @@ else:
wait_cam_server_message()
x = cam_server.stream.getChild("x_center_of_mass")
dx = cam_server.stream.getChild("x_rms")
cam_server.setThreshold(750)
#Creating averagers
x_averager = create_averager(x, nb, -1) # -1 event based, waits for the next value
+10 -10
View File
@@ -1,15 +1,15 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Offset", "SARUN11-DBPM070:Y-REF-FB")
S1 = ChannelDouble("Intensity", "SARFE10-PBPG050:HAMP-INTENSITY")
S2 = ChannelDouble("Intensity", "SARFE10-PBPG050:HAMP-INTENSITY")
A1 = ChannelDouble("K", "SARUN12-UIND030:K_SET")
S1 = ChannelDouble("hamp", "SARFE10-PBPG050:HAMP-INTENSITY")
S2 = ChannelDouble("Intensity", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-DS")
A1.initialize()
S1.initialize()
S2.initialize()
A1_init = A1.read()
A1i = A1_init - 0.100
A1f = A1_init + 0.100
nstep = 21
lat = 0.2
A1i = A1_init - 0.020
A1f = A1_init + 0.020
nstep = 11
lat = 10.0
nav = 10
plt = plot(None, title="Output")[0]
plt.clear()
@@ -18,10 +18,10 @@ plt.addSeries(LinePlotErrorSeries("Sensor1", Color.red))
def after_sample(record, scan):
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
S1_averager = create_averager(S1, nav, 0.2)
S2_averager = create_averager(S2, nav, 0.2)
S2_averager.monitored=True
time.sleep(1.0)
time.sleep(3.0)
r = lscan(A1, (S1_averager, S2_averager), A1i, A1f, nstep, latency=lat, after_read = after_sample)
Act1 = r.getPositions(0)
S1mean = [val.mean for val in r.getReadable(0)]
+48
View File
@@ -0,0 +1,48 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("x", "SARUN14-DBPM070:X-REF-FB")
A2 = ChannelDouble("y", "SARUN14-DBPM070:Y-REF-FB")
S1 = ChannelDouble("hamp", "SARFE10-PBPG050:HAMP-INTENSITY")
S2 = ChannelDouble("slow", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-DS")
A1.initialize()
A2.initialize()
S1.initialize()
S2.initialize()
A1_init = A1.read()
A2_init = A2.read()
A1i = A1_init-0.1
A1f = A1_init+0.1
A2i = A2_init-0.1
A2f = A2_init+0.1
nstep = 21
lat = 10.0
nav = 10
plt = plot(None, title="Output")[0]
plt.clear()
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Sensor1", Color.red))
def data_ok():
return (mps_beam_ok.read() == 1)
def after_sample(record, scan):
if not data_ok():
time.sleep(1.0)
record.invalidate()
print "Invalidating record: " + str(record)
else:
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
try:
S1_averager = create_averager(S1, nav, 0.1)
S2_averager = create_averager(S2, nav, 0.1)
S2_averager.monitored=True
r = ascan((A1,A2), (S1_averager, S2_averager), (A1i,A2i), (A1f,A2f), (nstep,nstep), latency=lat, after_read = after_sample)
Act1 = r.getPositions(0)
S1mean = [val.mean for val in r.getReadable(0)]
S1rms = [val.stdev for val in r.getReadable(0)]
S2mean = [val.mean for val in r.getReadable(1)]
S2rmsn = [val.stdev for val in r.getReadable(1)]
finally:
A1.write(A1_init)
A1.close()
S1.close()
S2.close()
+36
View File
@@ -0,0 +1,36 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("x", "SARUN13-DBPM070:X-REF-FB")
A2 = ChannelDouble("y", "SARUN13-DBPM070:Y-REF-FB")
camera_name = "SARBD01-DSCR110"
cam_server.start(camera_name+"_sp1", True) #True for shared pipeline
wait_cam_server_message()
S1 = cam_server.stream.getChild("intensity")
A1.initialize()
A2.initialize()
S1.initialize()
A1_init = A1.read()
A2_init = A2.read()
A1i = A1_init-0.1
A1f = A1_init+0.1
A2i = A2_init-0.1
A2f = A2_init+0.1
nstep = 11
lat = 1.0
nav = 10
plt = plot(None, title="Output")[0]
plt.clear()
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Sensor1", Color.red))
def after_sample(record, scan):
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
try:
S1_averager = create_averager(S1, nav, 0.1)
r = ascan((A1,A2), (S1_averager), (A1i,A2i), (A1f,A2f), (nstep,nstep), latency=lat, after_read = after_sample)
Act1 = r.getPositions(0)
S1mean = [val.mean for val in r.getReadable(0)]
S1rms = [val.stdev for val in r.getReadable(0)]
finally:
A1.write(A1_init)
A1.close()
S1.close()
S2.close()
+4
View File
@@ -0,0 +1,4 @@
xxx = create_device("cs://sf-daqsync-01:8889/SLG-LCAM-C041_sp1?channel=intensity&samples=-10&interval=-1")
add_device(xxx, True)
show_panel(xxx)