This commit is contained in:
root
2018-05-15 10:29:52 +02:00
parent 1bcb32c8f2
commit dcdb3ee2ac
76 changed files with 3068 additions and 829 deletions

View File

@@ -1,5 +1,10 @@
dispatcher=ch.psi.pshell.bs.Dispatcher|https://dispatcher-api.psi.ch/sf|||
cam_server=ch.psi.pshell.bs.PipelineServer|sf-daqsync-01:8889|||
charge=ch.psi.pshell.epics.ProcessVariable|SINEG01-DICT215:B1_CHARGE_AVERAGE-OP|||
rep_rate=ch.psi.pshell.epics.ProcessVariable|SIN-TIMAST-TMA:Beam-Appl-Freq-RB|||
destination_B1=ch.psi.pshell.epics.ChannelString|SF-MODE:MODE_B1 false|||
energy_B1=ch.psi.pshell.epics.ProcessVariable|SF-MODE:ENERGY_B1|||
laser=ch.psi.pshell.epics.ChannelString|SLG-LGEN:WHICH_LASER false|||
virtual_accelerator_set=ch.psi.pshell.epics.ChannelDouble|VA-SINBC01-MCRX070:I-SET|||true
virtual_accelerator_read=ch.psi.pshell.epics.ChannelDouble|VA-SINBC01-DBPM100:X1|||true
gun_solenoid=ch.psi.pshell.epics.Positioner|SINEG01-MSOL130:I-SET SINEG01-MSOL130:I-READ|||true
@@ -47,3 +52,4 @@ gsry=ch.psi.pshell.epics.Positioner|SINEG01-MSOL130:ROT_Y_SP SINEG01-MSOL130:ROT
#SINEG01-DBPM340:Q=ch.psi.pshell.device.Averager|SINEG01-DBPM340:Q|||true
#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

View File

@@ -1,4 +1,4 @@
#Mon Mar 05 09:04:33 CET 2018
#Mon Apr 16 16:03:57 CEST 2018
maxValue=360.0
minValue=-360.0
offset=0.0

View File

@@ -1,19 +1,16 @@
#Mon Mar 05 21:23:13 CET 2018
\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
#Tue May 15 09:41:57 CEST 2018
colormap=Flame
colormapAutomatic=true
colormapMax=18000.0
colormapMax=1000.0
colormapMin=0.0
flipHorizontally=false
flipVertically=false
grayscale=false
imageHeight=1200
imageWidth=1246
imageHeight=2160
imageWidth=2560
invert=false
regionStartX=304
regionStartY=8
regionStartX=1
regionStartY=1
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=-1
@@ -23,11 +20,9 @@ roiY=0
rotation=0.0
rotationCrop=false
scale=1.0
serverURL=localhost\:10000
spat=
spatialCalOffsetX=-50.01953888237593
spatialCalOffsetY=-50.02315886984715
spatialCalScaleX=-1.0
spatialCalScaleY=-1.0
spatialCalOffsetX=-430.65350059927124
spatialCalOffsetY=-251.50913468375813
spatialCalScaleX=-15.55967346005889
spatialCalScaleY=-11.299434762455629
spatialCalUnits=null
transpose=false

View File

@@ -0,0 +1,9 @@
#Thu May 03 15:36:18 CEST 2018
maxValue=360.0
minValue=-90.0
offset=0.0
precision=4
resolution=0.1
rotation=true
scale=1.0
unit=deg

View File

@@ -0,0 +1,8 @@
#Tue Apr 24 11:02:49 CEST 2018
maxValue=10.0
minValue=-10.0
offset=0.0
precision=3
resolution=0.007
scale=1.0
unit=A

View File

@@ -0,0 +1,9 @@
#Sat Apr 28 10:49:47 CEST 2018
maxValue=0.0
minValue=0.0
offset=0.0
precision=4
resolution=0.1
rotation=true
scale=1.0
unit=deg

View File

@@ -0,0 +1,9 @@
#Tue Apr 10 14:45:53 CEST 2018
maxValue=360.0
minValue=-360.0
offset=0.0
precision=3
resolution=0.1
rotation=false
scale=1.0
unit=deg

View File

@@ -0,0 +1,9 @@
#Mon Apr 16 16:06:31 CEST 2018
maxValue=360.0
minValue=-360.0
offset=0.0
precision=3
resolution=0.1
rotation=false
scale=1.0
unit=deg

View File

@@ -0,0 +1,9 @@
#Thu Apr 26 17:13:03 CEST 2018
maxValue=360.0
minValue=-90.0
offset=0.0
precision=3
resolution=0.1
rotation=true
scale=1.0
unit=deg

9
devices/Test.properties Normal file
View File

@@ -0,0 +1,9 @@
#Wed Mar 28 15:57:27 CEST 2018
maxValue=NaN
minValue=NaN
offset=0.0
precision=-1
resolution=NaN
rotation=false
scale=1.0
unit=null

View File

@@ -1,14 +1,14 @@
#Mon Feb 19 17:21:23 CET 2018
defaultSpeed=141.4213562373095
#Mon May 14 14:06:13 CEST 2018
defaultSpeed=565.685424949238
estbilizationDelay=0
hasEnable=false
homingType=None
maxSpeed=8000.0
maxValue=51500.0
minSpeed=50.0
minValue=-56100.0
minValue=-56300.0
offset=0.0
precision=2
precision=1
resolution=0.1
rotation=false
scale=1.0

View File

@@ -0,0 +1,4 @@
#Thu Apr 05 14:20:51 CEST 2018
keepListeningOnStop=false
parallelHandlerProcessing=true
socketType=SUB

View File

@@ -1,4 +1,4 @@
#Wed Feb 14 07:23:04 CET 2018
#Mon May 14 18:41:08 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=-797.0771270584523
spatialCalOffsetY=-195.9069772960574
spatialCalScaleX=-18.903591543153755
spatialCalScaleY=-19.379845197810685
spatialCalUnits=mm
transpose=false

View File

@@ -0,0 +1,8 @@
#Thu May 03 16:23:33 CEST 2018
maxValue=NaN
minValue=NaN
offset=0.0
precision=1
resolution=NaN
scale=1.0
unit=pC

View File

@@ -1,8 +1,14 @@
#Fri Jul 14 11:47:17 CEST 2017
#Thu Apr 05 14:20:51 CEST 2018
alignmentRetries=20
disableCompression=false
dropIncomplete=false
keepListeningOnStop=false
mappingIncomplete=fill_null
parallelHandlerProcessing=true
sendAwaitFirstMessage=false
sendBuildChannelConfig=at_startup
sendIncompleteMessages=true
sendStrategy=complete_all
sendSyncTimeout=0
socketType=DEFAULT
validationInconsistency=keep_as_is

View File

@@ -0,0 +1,8 @@
#Thu May 03 16:25:04 CEST 2018
maxValue=NaN
minValue=NaN
offset=0.0
precision=3
resolution=NaN
scale=1.0
unit=MeV

View File

@@ -1,4 +1,4 @@
#Tue Jul 11 15:24:17 CEST 2017
#Wed Mar 28 14:33:20 CEST 2018
defaultSpeed=1.0
estbilizationDelay=0
maxSpeed=10.0
@@ -10,4 +10,5 @@ precision=2
resolution=NaN
rotation=false
scale=1.0
startRetries=1
unit=mm

View File

@@ -1,4 +1,4 @@
#Tue Jul 11 15:24:17 CEST 2017
#Wed Mar 28 14:33:20 CEST 2018
defaultSpeed=1.0
estbilizationDelay=0
maxSpeed=10.0
@@ -10,4 +10,5 @@ precision=2
resolution=NaN
rotation=false
scale=1.0
startRetries=1
unit=mm

View File

@@ -1,4 +1,4 @@
#Mon Dec 18 11:29:15 CET 2017
#Tue Apr 24 11:42:23 CEST 2018
colormap=Flame
colormapAutomatic=true
colormapMax=NaN
@@ -16,8 +16,8 @@ roiY=0
rotation=0.0
rotationCrop=false
scale=1.0
spatialCalOffsetX=-50.03909304143862
spatialCalOffsetY=-50.048875855327466
spatialCalOffsetX=-50.075987841945285
spatialCalOffsetY=-50.10141987829615
spatialCalScaleX=-1.0
spatialCalScaleY=-1.0
spatialCalUnits=mm

View File

@@ -0,0 +1,8 @@
#Thu May 03 16:25:49 CEST 2018
maxValue=NaN
minValue=NaN
offset=0.0
precision=2
resolution=NaN
scale=1.0
unit=Hz

View File

@@ -0,0 +1,465 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Properties>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[737, 445]"/>
</Property>
</Properties>
<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">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="buttonStart" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonAbort" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="15" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="panelScanPars" max="32767" attributes="0"/>
<Component id="panelBeamPars" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel1" max="32767" attributes="0"/>
<Component id="jPanel2" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
<Component id="plot" pref="528" max="32767" attributes="0"/>
<EmptySpace 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 min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="plot" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Component id="panelScanPars" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelBeamPars" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="30" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonStart" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonAbort" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace min="-2" pref="14" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="panelScanPars">
<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 Parameters"/>
</Border>
</Property>
</Properties>
<AccessibilityProperties>
<Property name="AccessibleContext.accessibleDescription" type="java.lang.String" value=""/>
</AccessibilityProperties>
<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="1" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="labelLatency" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Component id="spinnerLatency" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="labelStop" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Component id="spinnerStop" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="labelStart" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Component id="spinnerStart" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="labelSamples" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Component id="spinnerSamples" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="labelStep" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="2" max="-2" attributes="0"/>
<Component id="spinnerStep" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
</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="3" attributes="0">
<Component id="spinnerStart" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelStart" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="spinnerStop" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelStop" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="spinnerStep" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelStep" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="spinnerSamples" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelSamples" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="spinnerLatency" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelLatency" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="labelStart">
<Properties>
<Property name="text" type="java.lang.String" value="Start:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="labelStop">
<Properties>
<Property name="text" type="java.lang.String" value="Stop:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerStep">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="1.0" maximum="10.0" minimum="0.05" numberType="java.lang.Double" stepSize="0.05" type="number"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[64, 20]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="labelStep">
<Properties>
<Property name="text" type="java.lang.String" value="Step size:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerStart">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" maximum="360.0" minimum="-360.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[64, 20]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="labelSamples">
<Properties>
<Property name="text" type="java.lang.String" value="Nb Samples:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerSamples">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="1" maximum="50" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[64, 20]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="labelLatency">
<Properties>
<Property name="text" type="java.lang.String" value="Latency:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerLatency">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.1" maximum="5.0" minimum="0.0" numberType="java.lang.Double" stepSize="0.01" type="number"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[64, 20]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerStop">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="180.0" maximum="360.0" minimum="-360.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
<Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[53, 20]"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[64, 20]"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelBeamPars">
<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="Beam Parameters"/>
</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="labelDispersion" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="labelEnergy" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="spinnerEnergy" pref="73" max="32767" attributes="0"/>
<Component id="spinnerDispersion" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</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="3" attributes="0">
<Component id="spinnerDispersion" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelDispersion" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="spinnerEnergy" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelEnergy" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JSpinner" name="spinnerDispersion">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="-0.387" maximum="10.0" minimum="-10.0" numberType="java.lang.Double" stepSize="0.001" type="number"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[64, 20]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="labelEnergy">
<Properties>
<Property name="text" type="java.lang.String" value="p (MeV/c):"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerEnergy">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="7.1" maximum="10.0" minimum="0.0" numberType="java.lang.Double" stepSize="0.01" type="number"/>
</Property>
<Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[64, 20]"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="labelDispersion">
<Properties>
<Property name="text" type="java.lang.String" value="Disp. (m):"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="ch.psi.pshell.plot.LinePlotJFree" name="plot">
<Properties>
<Property name="title" type="java.lang.String" value=""/>
</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.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>
<Container class="javax.swing.JPanel" name="jPanel1">
<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="Set RF Phase"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonPhaseSet" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="textRefPhase" min="-2" pref="69" max="-2" attributes="0"/>
<EmptySpace 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="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textRefPhase" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="buttonPhaseSet" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Ref phase:"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonPhaseSet">
<Properties>
<Property name="text" type="java.lang.String" value="Set"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonPhaseSetActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="textRefPhase">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</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="Set Laser Delay "/>
</Border>
</Property>
</Properties>
<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="buttonSetDelay" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="textOffset" min="-2" pref="69" max="-2" attributes="0"/>
<EmptySpace 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="3" attributes="0">
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textOffset" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="buttonSetDelay" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="Offset:"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonSetDelay">
<Properties>
<Property name="text" type="java.lang.String" value="Set"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonSetDelayActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JTextField" name="textOffset">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@@ -0,0 +1,483 @@
/*
* Copyright (c) 2014-2017 Paul Scherrer Institute. All rights reserved.
*/
import ch.psi.pshell.plot.LinePlot;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import ch.psi.utils.swing.SwingUtils;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JSpinner;
/**
*
*/
public class GunEnergyScanNew extends Panel {
public GunEnergyScanNew() {
initComponents();
setPersistedComponents(SwingUtils.getComponentsByType(panelScanPars, JSpinner.class));
plot.setStyle(LinePlot.Style.ErrorY);
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
}
@Override
public void onStateChange(State state, State former) {
buttonAbort.setEnabled(state.isProcessing());
boolean enabled = (state == State.Ready);
buttonStart.setEnabled(enabled);
spinnerStart.setEnabled(enabled);
spinnerStop.setEnabled(enabled);
spinnerStep.setEnabled(enabled);
spinnerSamples.setEnabled(enabled);
spinnerLatency.setEnabled(enabled);
spinnerDispersion.setEnabled(enabled);
spinnerEnergy.setEnabled(enabled);
buttonPhaseSet.setEnabled(enabled && !textRefPhase.getText().trim().isEmpty());
buttonSetDelay.setEnabled(enabled && !textOffset.getText().trim().isEmpty());
}
@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() {
panelScanPars = new javax.swing.JPanel();
labelStart = new javax.swing.JLabel();
labelStop = new javax.swing.JLabel();
spinnerStep = new javax.swing.JSpinner();
labelStep = new javax.swing.JLabel();
spinnerStart = new javax.swing.JSpinner();
labelSamples = new javax.swing.JLabel();
spinnerSamples = new javax.swing.JSpinner();
labelLatency = new javax.swing.JLabel();
spinnerLatency = new javax.swing.JSpinner();
spinnerStop = new javax.swing.JSpinner();
panelBeamPars = new javax.swing.JPanel();
spinnerDispersion = new javax.swing.JSpinner();
labelEnergy = new javax.swing.JLabel();
spinnerEnergy = new javax.swing.JSpinner();
labelDispersion = new javax.swing.JLabel();
plot = new ch.psi.pshell.plot.LinePlotJFree();
buttonStart = new javax.swing.JButton();
buttonAbort = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
buttonPhaseSet = new javax.swing.JButton();
textRefPhase = new javax.swing.JTextField();
jPanel2 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
buttonSetDelay = new javax.swing.JButton();
textOffset = new javax.swing.JTextField();
setPreferredSize(new java.awt.Dimension(737, 445));
panelScanPars.setBorder(javax.swing.BorderFactory.createTitledBorder("Scan Parameters"));
labelStart.setText("Start:");
labelStop.setText("Stop:");
spinnerStep.setModel(new javax.swing.SpinnerNumberModel(1.0d, 0.05d, 10.0d, 0.05d));
spinnerStep.setPreferredSize(new java.awt.Dimension(64, 20));
labelStep.setText("Step size:");
spinnerStart.setModel(new javax.swing.SpinnerNumberModel(0.0d, -360.0d, 360.0d, 1.0d));
spinnerStart.setPreferredSize(new java.awt.Dimension(64, 20));
labelSamples.setText("Nb Samples:");
spinnerSamples.setModel(new javax.swing.SpinnerNumberModel(1, 1, 50, 1));
spinnerSamples.setPreferredSize(new java.awt.Dimension(64, 20));
labelLatency.setText("Latency:");
spinnerLatency.setModel(new javax.swing.SpinnerNumberModel(0.1d, 0.0d, 5.0d, 0.01d));
spinnerLatency.setPreferredSize(new java.awt.Dimension(64, 20));
spinnerStop.setModel(new javax.swing.SpinnerNumberModel(180.0d, -360.0d, 360.0d, 1.0d));
spinnerStop.setMinimumSize(new java.awt.Dimension(53, 20));
spinnerStop.setPreferredSize(new java.awt.Dimension(64, 20));
javax.swing.GroupLayout panelScanParsLayout = new javax.swing.GroupLayout(panelScanPars);
panelScanPars.setLayout(panelScanParsLayout);
panelScanParsLayout.setHorizontalGroup(
panelScanParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelScanParsLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelScanParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(panelScanParsLayout.createSequentialGroup()
.addComponent(labelLatency)
.addGap(2, 2, 2)
.addComponent(spinnerLatency, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(panelScanParsLayout.createSequentialGroup()
.addComponent(labelStop)
.addGap(2, 2, 2)
.addComponent(spinnerStop, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(panelScanParsLayout.createSequentialGroup()
.addComponent(labelStart)
.addGap(2, 2, 2)
.addComponent(spinnerStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(panelScanParsLayout.createSequentialGroup()
.addComponent(labelSamples)
.addGap(2, 2, 2)
.addComponent(spinnerSamples, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(panelScanParsLayout.createSequentialGroup()
.addComponent(labelStep)
.addGap(2, 2, 2)
.addComponent(spinnerStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
panelScanParsLayout.setVerticalGroup(
panelScanParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelScanParsLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelScanParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spinnerStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelStart))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelScanParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spinnerStop, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelStop))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelScanParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spinnerStep, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelStep))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelScanParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spinnerSamples, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelSamples))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelScanParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spinnerLatency, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelLatency))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
panelBeamPars.setBorder(javax.swing.BorderFactory.createTitledBorder("Beam Parameters"));
spinnerDispersion.setModel(new javax.swing.SpinnerNumberModel(-0.387d, -10.0d, 10.0d, 0.001d));
spinnerDispersion.setPreferredSize(new java.awt.Dimension(64, 20));
labelEnergy.setText("p (MeV/c):");
spinnerEnergy.setModel(new javax.swing.SpinnerNumberModel(7.1d, 0.0d, 10.0d, 0.01d));
spinnerEnergy.setPreferredSize(new java.awt.Dimension(64, 20));
labelDispersion.setText("Disp. (m):");
javax.swing.GroupLayout panelBeamParsLayout = new javax.swing.GroupLayout(panelBeamPars);
panelBeamPars.setLayout(panelBeamParsLayout);
panelBeamParsLayout.setHorizontalGroup(
panelBeamParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelBeamParsLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(panelBeamParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(labelDispersion, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(labelEnergy))
.addGap(4, 4, 4)
.addGroup(panelBeamParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(spinnerEnergy, javax.swing.GroupLayout.DEFAULT_SIZE, 73, Short.MAX_VALUE)
.addComponent(spinnerDispersion, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
panelBeamParsLayout.setVerticalGroup(
panelBeamParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelBeamParsLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelBeamParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spinnerDispersion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelDispersion))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelBeamParsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spinnerEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(labelEnergy))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
plot.setTitle("");
buttonStart.setText("Start");
buttonStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonStartActionPerformed(evt);
}
});
buttonAbort.setText("Abort");
buttonAbort.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonAbortActionPerformed(evt);
}
});
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Set RF Phase"));
jLabel1.setText("Ref phase:");
buttonPhaseSet.setText("Set");
buttonPhaseSet.setEnabled(false);
buttonPhaseSet.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonPhaseSetActionPerformed(evt);
}
});
textRefPhase.setEditable(false);
textRefPhase.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(buttonPhaseSet)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textRefPhase, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(textRefPhase, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(buttonPhaseSet)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Set Laser Delay "));
jLabel2.setText("Offset:");
buttonSetDelay.setText("Set");
buttonSetDelay.setEnabled(false);
buttonSetDelay.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonSetDelayActionPerformed(evt);
}
});
textOffset.setEditable(false);
textOffset.setHorizontalAlignment(javax.swing.JTextField.CENTER);
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(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonSetDelay)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textOffset, javax.swing.GroupLayout.PREFERRED_SIZE, 69, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(textOffset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(buttonSetDelay)
.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()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(buttonStart)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonAbort)
.addGap(15, 15, 15))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(panelScanPars, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(panelBeamPars, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 528, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(panelScanPars, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelBeamPars, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonStart)
.addComponent(buttonAbort))))
.addGap(14, 14, 14))
);
panelScanPars.getAccessibleContext().setAccessibleDescription("");
}// </editor-fold>//GEN-END:initComponents
private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed
textRefPhase.setText("");
ArrayList parameters = new ArrayList();
parameters.add(spinnerStart.getValue());
parameters.add(spinnerStop.getValue());
parameters.add(spinnerStep.getValue());
parameters.add(spinnerSamples.getValue());
parameters.add(spinnerLatency.getValue());
parameters.add((Double) spinnerDispersion.getValue());
parameters.add((Double) spinnerEnergy.getValue());
parameters.add(plot);
try {
runAsync("RFscan/GunEnergyScanNew", parameters).handle((ret, ex) -> {
if (ex != null) {
getLogger().info("Exception executing scan: " + ex);
showException((Exception) ex);
} else {
List list = (List)ret;
try{
double phase = ((Number)list.get(0)).doubleValue();
double offset = ((Number)list.get(1)).doubleValue();
textRefPhase.setText(String.format("%1.2f",phase));
textOffset.setText(String.format("%1.2f",offset));
buttonPhaseSet.setEnabled(true);
buttonSetDelay.setEnabled(true);
} catch (Exception e) {
showException(e);
}
}
return ret;
});
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonStartActionPerformed
private void buttonAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonAbortActionPerformed
try {
abort();
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonAbortActionPerformed
private void buttonPhaseSetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPhaseSetActionPerformed
try {
if (!textRefPhase.getText().isEmpty()){
Double phase = Double.parseDouble(textRefPhase.getText());
ArrayList parameters = new ArrayList();
parameters.add(phase);
parameters.add(plot);
try {
//How to get a callback on the end of execution
runAsync("RFscan/GunEnergyScanRfSetNew", parameters).handle((ret, ex) -> {
if (ex != null) {
getLogger().info("Exception executing scan: " + ex);
showException((Exception) ex);
}
return ret;
});
} catch (Exception ex) {
showException(ex);
}
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonPhaseSetActionPerformed
private void buttonSetDelayActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetDelayActionPerformed
try {
if (!textOffset.getText().isEmpty()){
Double offset = Double.parseDouble(textOffset.getText());
ArrayList parameters = new ArrayList();
parameters.add(offset);
parameters.add(plot);
try {
//How to get a callback on the end of execution
runAsync("RFscan/GunEnergyScanLasSetNew", parameters).handle((ret, ex) -> {
if (ex != null) {
getLogger().info("Exception executing scan: " + ex);
showException((Exception) ex);
}
return ret;
});
} catch (Exception ex) {
showException(ex);
}
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonSetDelayActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonAbort;
private javax.swing.JButton buttonPhaseSet;
private javax.swing.JButton buttonSetDelay;
private javax.swing.JButton buttonStart;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JLabel labelDispersion;
private javax.swing.JLabel labelEnergy;
private javax.swing.JLabel labelLatency;
private javax.swing.JLabel labelSamples;
private javax.swing.JLabel labelStart;
private javax.swing.JLabel labelStep;
private javax.swing.JLabel labelStop;
private javax.swing.JPanel panelBeamPars;
private javax.swing.JPanel panelScanPars;
private ch.psi.pshell.plot.LinePlotJFree plot;
private javax.swing.JSpinner spinnerDispersion;
private javax.swing.JSpinner spinnerEnergy;
private javax.swing.JSpinner spinnerLatency;
private javax.swing.JSpinner spinnerSamples;
private javax.swing.JSpinner spinnerStart;
private javax.swing.JSpinner spinnerStep;
private javax.swing.JSpinner spinnerStop;
private javax.swing.JTextField textOffset;
private javax.swing.JTextField textRefPhase;
// End of variables declaration//GEN-END:variables
}

View File

@@ -27,6 +27,7 @@ public class GunSolenoidAlignment extends Panel {
}
boolean running;
/*
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
@@ -43,6 +44,7 @@ public class GunSolenoidAlignment extends Panel {
}
}
}
*/
@Override
public void onStateChange(State state, State former) {

View File

@@ -25,6 +25,7 @@ public class LaserGunAlignment extends Panel {
boolean running;
//Overridable callbacks
/*
@Override
public void onInitialize(int runCount) {
if (runCount==0){
@@ -40,6 +41,7 @@ public class LaserGunAlignment extends Panel {
}
}
}
*/
@Override
public void onStateChange(State state, State former) {

View File

@@ -186,7 +186,9 @@ public class ScreenPanel2 extends Panel {
Arrays.fill(gX2, Double.NaN);
try {
double x = getServerDoubleArray("gr_x_axis", cache)[0];
System.arraycopy(x_fit_gauss_function, 0, gX2, (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageX(x) : x), x_fit_gauss_function.length);
gr_size_x = x_fit_gauss_function.length;
gr_pos_x = (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageX(x) : x);
System.arraycopy(x_fit_gauss_function, 0, gX2, gr_pos_x , gr_size_x);
} catch (Exception ex) {
}
x_fit_gauss_function = gX2;
@@ -194,7 +196,9 @@ public class ScreenPanel2 extends Panel {
Arrays.fill(gY2, Double.NaN);
try {
double y = getServerDoubleArray("gr_y_axis", cache)[0];
System.arraycopy(y_fit_gauss_function, 0, gY2, (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageY(y) : y), y_fit_gauss_function.length);
gr_size_y = y_fit_gauss_function.length;
gr_pos_y = (int) ((renderer.getCalibration() != null) ? renderer.getCalibration().convertToImageY(y) : y);
System.arraycopy(y_fit_gauss_function, 0, gY2, gr_pos_y, y_fit_gauss_function.length);
} catch (Exception ex) {
}
y_fit_gauss_function = gY2;
@@ -225,6 +229,10 @@ public class ScreenPanel2 extends Panel {
public double[] x_fit_gauss_function;
public double[] y_profile;
public double[] y_fit_gauss_function;
public int gr_size_x;
public int gr_pos_x;
public int gr_size_y;
public int gr_pos_y;
public PointDouble[] sliceCenters;
public StreamValue cache;
}
@@ -1229,58 +1237,73 @@ public class ScreenPanel2 extends Panel {
sliceCenters = id.sliceCenters;
profileSize /= 4;
if (pX != null) {
int[] x = Arr.indexesInt(pX.length);
int[] y = new int[pX.length];
int[] p = new int[pX.length];
if (pX != null) {
int[] xp = Arr.indexesInt(pX.length);
int[] xg = xp;
int[] yp = new int[pX.length];
int[] yg = new int[pX.length];
List<Double> l = Arrays.asList((Double[]) Convert.toWrapperArray(pX));
Double min = Collections.min(l);
Double max = Collections.max(l);
double minPlot = min;
double rangePlot = max - min;
for (int i = 0; i < x.length; i++) {
double minProfile = Collections.min(l);
double maxProfile = Collections.max(l);
double rangeProfile = maxProfile - minProfile;
double minGauss = minProfile;
double rangeGauss = rangeProfile;
//If not good region, range of profile and fit are similar so save this calcultion
if (goodRegion && id.gr_size_x>0){
l = Arrays.asList( (Double[]) Convert.toWrapperArray(Arrays.copyOfRange(gX, id.gr_pos_x, id.gr_pos_x + id.gr_size_x)));
minGauss = Collections.min(l);
rangeGauss = Collections.max(l) - minGauss;
}
for (int i = 0; i < xp.length; i++) {
if (gX != null) {
y[i] = (int) (height - 1 - (((gX[i] - minPlot) / rangePlot) * profileSize));
yg[i] = (int) (height - 1 - (((gX[i] - minGauss) / rangeGauss) * profileSize));
}
p[i] = (int) (height - 1 - (((pX[i] - minPlot) / rangePlot) * profileSize));
yp[i] = (int) (height - 1 - (((pX[i] - minProfile) / rangeProfile) * profileSize));
}
if (goodRegion) {
for (int i = 0; i < x.length; i++) {
y[i] = (Double.isNaN(gX[i])) ? 100000 : y[i];
}
if (goodRegion && id.gr_size_x>0){
xg = Arrays.copyOfRange(xg, id.gr_pos_x, id.gr_pos_x + id.gr_size_x);
yg = Arrays.copyOfRange(yg, id.gr_pos_x, id.gr_pos_x + id.gr_size_x);
}
vgaussian = new Overlays.Polyline(penFit, x, y);
vprofile = new Overlays.Polyline(renderer.getPenProfile(), x, p);
vgaussian = new Overlays.Polyline(penFit, xg, yg);
vprofile = new Overlays.Polyline(renderer.getPenProfile(), xp, yp);
}
if (pY != null) {
int[] y = Arr.indexesInt(pY.length);
int[] x = new int[pY.length];
int[] p = new int[pY.length];
int[] xp = new int[pY.length];
int[] xg = new int[pY.length];
int[] yp = Arr.indexesInt(pY.length);
int[] yg = yp;
List<Double> l = Arrays.asList((Double[]) Convert.toWrapperArray(pY));
Double min = Collections.min(l);
Double max = Collections.max(l);
double minPlot = min;
double rangePlot = max - min;
double minProfile = Collections.min(l);
double maxProfile = Collections.max(l);
double rangeProfile = maxProfile - minProfile;
double minGauss = minProfile;
double rangeGauss = rangeProfile;
//If not good region, range of profile and fit are similar so save this calcultion
if (goodRegion && id.gr_size_y>0){
l = Arrays.asList( (Double[]) Convert.toWrapperArray(Arrays.copyOfRange(gY, id.gr_pos_y, id.gr_pos_y + id.gr_size_y)));
minGauss = Collections.min(l);
rangeGauss = Collections.max(l) - minGauss;
}
for (int i = 0; i < x.length; i++) {
for (int i = 0; i < xp.length; i++) {
if (gY != null) {
x[i] = (int) (((gY[i] - minPlot) / rangePlot) * profileSize);
xg[i] = (int) (((gY[i] - minGauss) / rangeGauss) * profileSize);
}
p[i] = (int) (((pY[i] - minPlot) / rangePlot) * profileSize);
xp[i] = (int) (((pY[i] - minProfile) / rangeProfile) * profileSize);
}
if (goodRegion) {
for (int i = 0; i < x.length; i++) {
x[i] = (Double.isNaN(gY[i])) ? -1 : x[i];
}
if (goodRegion && id.gr_size_x>0){
xg = Arrays.copyOfRange(xg, id.gr_pos_y, id.gr_pos_y + id.gr_size_y);
yg = Arrays.copyOfRange(yg, id.gr_pos_y, id.gr_pos_y + id.gr_size_y);
}
hgaussian = new Overlays.Polyline(penFit, x, y);
hprofile = new Overlays.Polyline(renderer.getPenProfile(), p, y);
hgaussian = new Overlays.Polyline(penFit, xg, yg);
hprofile = new Overlays.Polyline(renderer.getPenProfile(), xp, yp);
}
} catch (Exception ex) {
System.err.println(ex.getMessage());
@@ -2120,6 +2143,16 @@ public class ScreenPanel2 extends Panel {
} catch (Exception ex) {
dataTableModel.addRow(new Object[]{"Stream", ex.getMessage()});
}
try {
dataTableModel.addRow(new Object[]{"PID", value.getPulseId()});
} catch (Exception ex) {
dataTableModel.addRow(new Object[]{"PID", ex.getMessage()});
}
try {
dataTableModel.addRow(new Object[]{"Timestamp", value.getTimestamp()});
} catch (Exception ex) {
dataTableModel.addRow(new Object[]{"Timestamp", ex.getMessage()});
}
Collections.sort(ids);
for (String id : ids) {
dataTableModel.addRow(new Object[]{id, ""});
@@ -2127,7 +2160,7 @@ public class ScreenPanel2 extends Panel {
}
Frame frame = getCurrentFrame();
if ((frame != null) && (frame.cache!=null)){
for (int i = 2; i < dataTableModel.getRowCount(); i++) {
for (int i = 4; i < dataTableModel.getRowCount(); i++) {
String id = String.valueOf(dataTableModel.getValueAt(i, 0));
//Object obj = server.getValue(id);
Object obj = frame.cache.getValue(id);
@@ -3071,7 +3104,8 @@ public class ScreenPanel2 extends Panel {
ColormapSource source = (ColormapSource) camera;
Color colorReticule = new Color(16, 16, 16);
Color colorMarker = new Color(128, 128, 128);
source.getConfig().colormap = (Colormap) comboColormap.getSelectedItem();
Colormap colormap = (Colormap) comboColormap.getSelectedItem();
source.getConfig().colormap = (colormap==null) ? Colormap.Flame: colormap;
switch (source.getConfig().colormap) {
case Grayscale:
case Inverted:

View File

@@ -70,9 +70,66 @@
<Component id="jLabel8" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" linkSize="1" alignment="1" max="32767" attributes="0"/>
<Component id="jLabel20" linkSize="1" alignment="1" min="-2" pref="86" max="-2" attributes="0"/>
<Component id="jLabel21" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="spinnerBunch" linkSize="8" alignment="0" min="-2" pref="104" max="-2" attributes="0"/>
<Component id="spinnerVel" linkSize="8" alignment="0" min="-2" pref="104" max="-2" attributes="0"/>
<Component id="spinnerStartX" linkSize="8" alignment="0" max="32767" attributes="0"/>
<Component id="spinnerStartY" linkSize="8" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="labelEndY" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel7" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel9" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel19" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="spinnerCycles" linkSize="7" alignment="0" max="32767" attributes="0"/>
<Component id="spinnerBackground" linkSize="7" alignment="0" min="-2" pref="104" max="-2" attributes="0"/>
<Component id="spinnerEndX" linkSize="7" alignment="0" max="32767" attributes="0"/>
<Component id="spinnerEndY" linkSize="7" alignment="0" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="buttonPark" linkSize="2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonParkAll" linkSize="2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonMoveStart" linkSize="2" min="-2" max="-2" attributes="0"/>
</Group>
<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="checkSaveRaw" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonAbort" linkSize="2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<EmptySpace min="98" pref="98" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="panelStatus" min="-2" pref="324" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="comboBlm3" alignment="0" max="32767" attributes="0"/>
<Component id="comboBlm2" alignment="0" max="32767" attributes="0"/>
<Component id="comboBlm1" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="buttonRaw1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="buttonRaw2" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="buttonRaw3" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="comboBpm2" alignment="0" max="32767" attributes="0"/>
<Component id="comboBpm1" max="32767" attributes="0"/>
<Component id="comboBpm3" alignment="0" max="32767" attributes="0"/>
<Component id="comboScanType" max="32767" attributes="0"/>
<Component id="comboWireScanner" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="panelPosition" linkSize="4" alignment="0" min="-2" pref="90" max="-2" attributes="0"/>
@@ -93,75 +150,8 @@
<Component id="buttonMotorPanel" linkSize="3" alignment="0" max="32767" attributes="0"/>
</Group>
</Group>
<Component id="comboWireScanner" alignment="0" max="32767" attributes="0"/>
<Component id="comboScanType" max="32767" attributes="0"/>
<Component id="comboBpm3" alignment="0" max="32767" attributes="0"/>
<Component id="comboBpm1" max="32767" attributes="0"/>
<Component id="comboBpm2" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="spinnerStartY" linkSize="8" max="32767" attributes="0"/>
<Component id="panelStatus" min="-2" pref="324" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="16" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="spinnerVel" linkSize="8" min="-2" pref="104" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel9" linkSize="1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="spinnerStartX" linkSize="8" max="32767" attributes="0"/>
<EmptySpace type="separate" max="32767" attributes="0"/>
<Component id="jLabel7" linkSize="1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel19" min="-2" max="-2" attributes="0"/>
<Component id="labelEndY" linkSize="1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace min="-2" pref="8" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="spinnerEndX" linkSize="7" alignment="1" max="32767" attributes="0"/>
<Component id="spinnerEndY" linkSize="7" alignment="1" max="32767" attributes="0"/>
<Component id="spinnerBackground" linkSize="7" alignment="1" min="-2" pref="104" max="-2" attributes="0"/>
<Component id="spinnerCycles" linkSize="7" alignment="1" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="comboBlm3" alignment="0" max="32767" attributes="0"/>
<Component id="comboBlm2" alignment="0" max="32767" attributes="0"/>
<Component id="comboBlm1" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="buttonRaw1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="buttonRaw2" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="buttonRaw3" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="buttonPark" linkSize="2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonParkAll" linkSize="2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonMoveStart" linkSize="2" min="-2" max="-2" attributes="0"/>
</Group>
<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="checkSaveRaw" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonAbort" linkSize="2" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
@@ -187,26 +177,28 @@
<Component id="spinnerCycles" linkSize="10" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="103" alignment="0" groupAlignment="3" attributes="0">
<Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel9" linkSize="12" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerVel" linkSize="9" alignment="3" min="-2" pref="20" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="spinnerBackground" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel19" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel19" linkSize="12" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerBunch" linkSize="9" alignment="3" min="-2" pref="20" max="-2" attributes="0"/>
<Component id="jLabel21" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel6" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="jLabel7" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="jLabel7" linkSize="12" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="spinnerEndX" linkSize="10" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="spinnerStartX" linkSize="9" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="spinnerStartY" linkSize="9" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelEndY" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelEndY" linkSize="12" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerEndY" linkSize="10" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="labelStartY" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
@@ -623,6 +615,19 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonScannerPanelActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel21">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Bunch:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerBunch">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="1" maximum="2" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>

View File

@@ -168,6 +168,8 @@ public class WireScan extends Panel {
spinnerEndX.setEnabled(spinnerStartX.isEnabled());
spinnerStartY.setEnabled(validWireScan && isY());
spinnerEndY.setEnabled(spinnerStartY.isEnabled());
spinnerBunch.setEnabled(validWireScan);
spinnerBackground.setEnabled(validWireScan);
updateRawButtons();
}
@@ -380,6 +382,8 @@ public class WireScan extends Panel {
buttonRaw3 = new javax.swing.JButton();
jLabel18 = new javax.swing.JLabel();
buttonScannerPanel = new javax.swing.JButton();
jLabel21 = new javax.swing.JLabel();
spinnerBunch = new javax.swing.JSpinner();
plot.setTitle("");
@@ -577,6 +581,11 @@ public class WireScan extends Panel {
}
});
jLabel21.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel21.setText("Bunch:");
spinnerBunch.setModel(new javax.swing.SpinnerNumberModel(1, 1, 2, 1));
javax.swing.GroupLayout panelLeftLayout = new javax.swing.GroupLayout(panelLeft);
panelLeft.setLayout(panelLeftLayout);
panelLeftLayout.setHorizontalGroup(
@@ -601,9 +610,57 @@ public class WireScan extends Panel {
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel20, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel20, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel21, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spinnerBunch, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerVel, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerStartX)
.addComponent(spinnerStartY))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(labelEndY)
.addComponent(jLabel7)
.addComponent(jLabel9)
.addComponent(jLabel19))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spinnerCycles)
.addComponent(spinnerBackground, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerEndX)
.addComponent(spinnerEndY)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelLeftLayout.createSequentialGroup()
.addComponent(buttonPark)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonParkAll)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonMoveStart))
.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(checkSaveRaw)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonAbort))
.addGroup(panelLeftLayout.createSequentialGroup()
.addGap(98, 98, 98)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(panelStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(panelLeftLayout.createSequentialGroup()
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(comboBlm3, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboBlm2, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboBlm1, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(buttonRaw1, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(buttonRaw2, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(buttonRaw3, javax.swing.GroupLayout.Alignment.TRAILING)))
.addComponent(comboBpm2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboBpm1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboBpm3, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboScanType, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboWireScanner, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(panelLeftLayout.createSequentialGroup()
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(panelPosition, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
@@ -619,64 +676,11 @@ public class WireScan extends Panel {
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(buttonHoming, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonScannerPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonMotorPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addComponent(comboWireScanner, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboScanType, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboBpm3, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboBpm1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboBpm2, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(panelLeftLayout.createSequentialGroup()
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spinnerStartY)
.addComponent(panelStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 324, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 16, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelLeftLayout.createSequentialGroup()
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(panelLeftLayout.createSequentialGroup()
.addComponent(spinnerVel, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel9))
.addGroup(panelLeftLayout.createSequentialGroup()
.addComponent(spinnerStartX)
.addGap(18, 18, Short.MAX_VALUE)
.addComponent(jLabel7))
.addGroup(panelLeftLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel19)
.addComponent(labelEndY))))
.addGap(8, 8, 8)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spinnerEndX, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(spinnerEndY, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(spinnerBackground, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerCycles, javax.swing.GroupLayout.Alignment.TRAILING)))
.addGroup(panelLeftLayout.createSequentialGroup()
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(comboBlm3, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboBlm2, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboBlm1, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(buttonRaw1, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(buttonRaw2, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(buttonRaw3, javax.swing.GroupLayout.Alignment.TRAILING)))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelLeftLayout.createSequentialGroup()
.addComponent(buttonPark)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonParkAll)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonMoveStart))
.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(checkSaveRaw)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonAbort)))
.addComponent(buttonMotorPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))))
.addGap(0, 0, 0))
);
panelLeftLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel10, jLabel11, jLabel13, jLabel14, jLabel15, jLabel16, jLabel17, jLabel18, jLabel2, jLabel20, jLabel3, jLabel4, jLabel5, jLabel6, jLabel7, jLabel8, jLabel9, labelEndY, labelStartY});
panelLeftLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel10, jLabel11, jLabel13, jLabel14, jLabel15, jLabel16, jLabel17, jLabel18, jLabel19, jLabel2, jLabel20, jLabel21, jLabel3, jLabel4, jLabel5, jLabel6, jLabel7, jLabel8, jLabel9, labelEndY, labelStartY});
panelLeftLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonAbort, buttonMoveStart, buttonPark, buttonParkAll, buttonScan});
@@ -686,7 +690,7 @@ public class WireScan extends Panel {
panelLeftLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerBackground, spinnerCycles, spinnerEndX, spinnerEndY});
panelLeftLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerStartX, spinnerStartY, spinnerVel});
panelLeftLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerBunch, spinnerStartX, spinnerStartY, spinnerVel});
panelLeftLayout.setVerticalGroup(
panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -710,7 +714,9 @@ public class WireScan extends Panel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spinnerBackground, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel19))
.addComponent(jLabel19)
.addComponent(spinnerBunch, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel21))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelLeftLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel6)
@@ -790,12 +796,14 @@ public class WireScan extends Panel {
panelLeftLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {labelPosX, labelPosY, panelPosition});
panelLeftLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {spinnerStartX, spinnerStartY, spinnerVel});
panelLeftLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {spinnerBunch, spinnerStartX, spinnerStartY, spinnerVel});
panelLeftLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {spinnerCycles, spinnerEndX, spinnerEndY});
panelLeftLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {panelRepRate, panelStatus});
panelLeftLayout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {jLabel19, jLabel7, jLabel9, labelEndY});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -950,6 +958,7 @@ public class WireScan extends Panel {
parameters.add(spinnerBackground.getValue());
parameters.add(plot);
parameters.add(checkSaveRaw.isSelected());
parameters.add(spinnerBunch.getValue());
runAsync("Diagnostics/WireScan", parameters).handle((ret, ex) -> {
if (ex != null) {
@@ -1113,6 +1122,7 @@ public class WireScan extends Panel {
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
@@ -1131,6 +1141,7 @@ public class WireScan extends Panel {
private ch.psi.pshell.swing.DeviceValuePanel panelStatus;
private ch.psi.pshell.plot.LinePlotJFree plot;
private javax.swing.JSpinner spinnerBackground;
private javax.swing.JSpinner spinnerBunch;
private javax.swing.JSpinner spinnerCycles;
private javax.swing.JSpinner spinnerEndX;
private javax.swing.JSpinner spinnerEndY;

View File

@@ -13,7 +13,7 @@ import datetime
do_elog = True
dry_run = False
is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before callin "run"
camera_name = "SINEG01-DSCR190"
camera_name = "simulation" if dry_run else "SINEG01-DSCR190"
bpm_name = "SINEG01-DBPM340"
use_good_region=False
magnets = ["SINEG01-MCRX120","SINEG01-MCRY120",

View File

@@ -14,7 +14,7 @@ import datetime
do_elog = True
dry_run = False
is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before callin "run"
camera_name = "SINEG01-DSCR190"
camera_name = "simulation" if dry_run else "SINEG01-DSCR190"
bpm_name = "SINEG01-DBPM340"
use_good_region=False
magnets = ["SINEG01-MCRX120","SINEG01-MCRY120",

View File

@@ -115,7 +115,10 @@ try:
_stream.initialize()
_stream.start(True)
if _camname != None:
cam_server.start(_camname )
shared = _camname.endswith("_sp1")
print "Camera: " , _camname, " shared: ", shared
cam_server.start(_camname, shared )
cam_server.stream.waitCacheChange(10000);
if dxtype==TYPE_CAMERA:
dx=cam_server.stream.getChild(dx)

View File

@@ -299,3 +299,46 @@ def get_camera_type(camera_name):
return "UNKNOWN"
###################################################################################################
## BLMs in WS MODE
###################################################################################################
def start_blm_ws(blm, duration=10.0):
caput(blm+ ":WS_SCAN_DURATION", duration)
caput(blm + ":WS_START.PROC", 1)
def stop_blm_ws(blm):
caput(blm + ":WS_STOP.PROC", 1)
def set_blm_ws_gain(blm, gain):
caput(blm + ":WS_PMT_GAIN_VOLTS", 1)
def get_blm_ws_gain(blm, gain):
caget(blm + ":WS_PMT_GAIN_VOLTS")
def set_blm_ws_att(blm, att):
caput(blm + ":WS_PMT_ATT_VOLTS", 1)
def get_blm_ws_att(blm, att):
"""
string 0: Reference
string 1: "2 dB"
string 2: 4 dB
string 3: 6 dB
string 4: 8 dB
string 5: 10 dB
string 6: 12 dB
string 7: 14 dB
string 8: 16 dB
string 9: 18 dB
string 10: 20 dB
string 11: 22 dB
string 12: 24 dB
string 13: 26 dB
string 14: 28 dB
string 15: 30 dB
"""
caget(blm + ":WS_PMT_ATT_VOLTS", 'i')

View File

@@ -69,7 +69,40 @@ class WireScanInfo(DeviceBase):
w2y = (pos_motor - self.home_offsets[3]) / (math.sqrt(2))
return [w1x, w1y, w2x, w2y]
def is_valid(self):
return caget(self.prefix + ":VALID", 'i')==1
def _get_channel(self, bunch, wire, name):
return self.prefix + ":B" + str(int(bunch)) + "_" + wire.upper() + "_" + name
def set_out_com(self, bunch, wire, value):
caput(self._get_channel(bunch, wire, "CENTER_OF_MASS"), float(value))
def set_out_rms(self, bunch, wire, value):
caput(self._get_channel(bunch, wire, "RMS"), float(value))
def set_out_amp(self, bunch, wire, value):
caput(self._get_channel(bunch, wire, "FIT_AMPLITUDE"), float(value))
def set_out_mean(self, bunch, wire, value):
caput(self._get_channel(bunch, wire, "FIT_MEAN"), float(value))
def set_out_off(self, bunch, wire, value):
caput(self._get_channel(bunch, wire, "FIT_OFFSET"), float(value))
def set_out_sigma(self, bunch, wire, value):
caput(self._get_channel(bunch, wire, "FIT_STANDARD_DEVIATION"), float(value))
def set_out_pos(self, bunch, wire, value):
caput(self._get_channel(bunch, wire, "POSITION"), to_array(value, 'd'))
def set_out_samples(self, bunch, wire, value):
caput(self._get_channel(bunch, wire, "AMPLITUDE"), to_array(value, 'd'))
def set_out_gauss(self, bunch, wire, value):
caput(self._get_channel(bunch, wire, "FIT_GAUSS_FUNCTION"), to_array(value, 'd'))
def new_scan_info_device(name, prefix):
return WireScanInfo(name, prefix)

View File

@@ -2,14 +2,16 @@ import ch.psi.pshell.epics.ControlledVariable as ControlledVariable
#This scan is dedicated to scan either one parameter (e.g. a quadrupole) and take a certain amount of images at every location
CAMERA = "SARCL01-DSCR170" #Specify the camera we want to use
#CAMERA = "SINDI02-DLAC055"
QUADRUPOLE = "S20SY01-MQUA080" # quadrupole for the scan with S10DI01-DSCR020: S10CB02-MQUA230
#CAMERA = "SINBC02-DSRM310"
#QUADRUPOLE = "S20SY01-MQUA080" # quadrupole for the scan with S10DI01-DSCR020: S10CB02-MQUA230
QUADRUPOLE = "S10BC01-MQUA100"
CHARGE_BPM = "SARCL01-DBPM120:Q1" #reading out the charge also
CHARGE_ICT = "S10DI01-DICT025:B1_CHARGE-OP" #reading out the charge also
RANGE = (0.382,8.382) #range for the quadrupole
#RANGE = None #if range None, just NUM_IMAGES are recorded
STEPS = 50 #step size for the quadrupole scan range
#RANGE = (6.226,7.226) #range for the quadrupole
RANGE = None #if range None, just NUM_IMAGES are recorded
STEPS = 20 # number of steps for the quadrupole scan range (scan will take STEPS+1 measurements)
SETTLING_TIME = 0.1
NUM_IMAGES = 10 #number of images for every step
NUM_IMAGES = 50 #number of images for every step
print cam_server.cameras
cam_server.start(CAMERA + "_sp1", True)

View File

@@ -2,8 +2,8 @@ import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
dry_run = False
do_elog = True
base_name = "SARBD01-DICT599" # SINEG01-DICT009 S10DI01-DICT113 SARMA01-DICT482 SARBD01-DICT599
dev_name = "SARBD01-DICT030" # SINEG01-DICT215 S10DI01-DICT025 SARMA01-DICT090 SARBD01-DICT030
base_name = "SARMA01-DICT482" # SINEG01-DICT009 S10DI01-DICT113 SARMA01-DICT482 SARBD01-DICT599
dev_name = "SARMA01-DICT090" # SINEG01-DICT215 S10DI01-DICT025 SARMA01-DICT090 SARBD01-DICT030
run("CPython/wrapper")
@@ -22,10 +22,10 @@ V.initialize()
t0 = t.read()
start = 3
stop = 10
start = 4
stop = 12
step = 0.1
nb = 4
nb = 10
lat = 0.150
plt = plot(None, title="Output")[0]

View File

@@ -20,8 +20,8 @@ V.initialize()
t0 = t.read()
start = 1001.020
stop = 1001.060
start = 1001.035
stop = 1001.050
step = 0.002
nb = 4
lat = 0.150

View File

@@ -1,27 +1,40 @@
import traceback
is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before callin "run"
has_args = get_exec_pars().source != CommandSource.ui #Must be checked before callin "run"
is_script = get_exec_pars().source == CommandSource.script
run("Devices/Elements")
run("Devices/WireScanner")
run("Diagnostics/sig_process_wrapper")
BPM_SENSORS = [("x","X1"), ("y","Y1"), ("q","Q1")] #(logic name sufix, channel sufix)
#Paramter parsing
prefix = args[0] if is_panel else "S30CB09-DWSC440" #"SINDI01-DWSC090"
scan_type = args[1] if is_panel else WireScanner.WireX1
scan_range = args[2] if is_panel else [-200, 200, -200, 200]
cycles = args[3] if is_panel else 3
velocity = args[4] if is_panel else 200
bpms = args[5] if is_panel else get_wire_scanners_bpms(prefix)
blms = args[6] if is_panel else get_wire_scanners_blms(prefix)
bkgrd = args[7] if is_panel else 10
plt = args[8] if is_panel else plot(None, title = "Wire Scan")[0]
save_raw = args[9] if is_panel else False
do_elog = False if (plt is None) else (True if is_panel else True)
print "WireScan parameters: ", prefix, scan_type, scan_range, cycles, velocity, bpms, blms, bkgrd
prefix = args[0] if has_args else "S10DI01-DWSC010" #"S10CB07-DWSC440" #"SINDI01-DWSC090"
scan_type = args[1] if has_args else WireScanner.WireX1
scan_range = args[2] if has_args else [-1000, 1000, -1000, 1000]
cycles = args[3] if has_args else 2
velocity = args[4] if has_args else 200
bpms = args[5] if has_args else [] #get_wire_scanners_bpms(prefix)
blms = args[6] if has_args else get_wire_scanners_blms(prefix)
bkgrd = args[7] if has_args else 10
plt = args[8] if has_args else plot(None, title = "Wire Scan")[0]
save_raw = args[9] if has_args else False
bunch = args[10] if has_args else 1
do_elog = True if (is_panel and (not is_script) and (plt is not None)) else False
print is_panel, do_elog
print "WireScan parameters: ", prefix, scan_type, scan_range, cycles, velocity, bpms, blms, bkgrd, bunch
SET_BLM_WS_MODE = True
SET_BLM_WS_SETTLING_TIME = 2.0
SET_BLM_WS_BS_READBACK_TIMEOUT = 10000 #ms
#TODO: configure biggerCAJ buffer size and set back to 10000
SAMPLE_CHANNEL_SIZE = 2049 #10000
SAMPLE_CHANNEL_EMPTY_VALUE = 0.0
BPM_SENSORS = [("x","X"+str(bunch)), ("y","Y"+str(bunch)), ("q","Q"+str(bunch))] #(logic name suffix, channel suffix)
#Plot setup
if plt is not None:
@@ -43,8 +56,9 @@ scanner = WireScanner(prefix, scan_range, cycles, velocity, True)
channels = [("m_pos", scanner.motor_bs_readback.get_name()),
("cur_cycle", scanner.curr_cycl.get_name()),
("scanning", scanner.status_channels[0].get_name())]
for i in range (len(blms)):
channels.append (("blm" + str(i+1), blms[i] + ":B1_LOSS"))
channels.append (("blm" + str(i+1), blms[i] + ":B" + str(bunch) + "_LOSS"))
if plt is not None:
series = LinePlotSeries(blms[i], None, min(i+1, 2))
plt.addSeries(series)
@@ -55,6 +69,9 @@ for i in range (len(blms)):
for i in range (len(bpms)):
for sensor in BPM_SENSORS:
channels.append (("bpm" + str(i+1) + "_" + sensor[0], bpms[i] + ":" + sensor[1]))
if SET_BLM_WS_MODE and (len(blms)>0):
channels.append(("blm1_ws_mode", blms[0] + ":WS_RUNNING"))
#Metadata
set_attribute("/", "Wire Scanner", prefix)
@@ -66,6 +83,7 @@ set_attribute("/", "Wire Velocity", velocity)
set_attribute("/", "Background Measures", bkgrd)
set_attribute("/", "BPMs", bpms)
set_attribute("/", "BLMs", blms)
set_attribute("/", "Bunch", bunch)
filename = get_exec_pars().path
@@ -75,7 +93,10 @@ filename = get_exec_pars().path
print "Starting stream..."
st = Stream("pulse_id", dispatcher)
for c in channels:
st.addScalar(c[0], c[1], int(100.0 / get_repetition_rate()), 0)
if c[1].endswith("LOSS_SIGNAL_RAW"):
st.addWaveform(c[0], c[1], int(100.0 / get_repetition_rate()), 0)
else:
st.addScalar(c[0], c[1], int(100.0 / get_repetition_rate()), 0)
st.initialize()
st.start()
st.waitCacheChange(10000) #Wait stream be running before starting scan
@@ -91,7 +112,7 @@ class Timestamp(Readable):
#Pseudo-device returning the wire position
class w_pos(Readable):
def read(self):
return scanner.get_sel_wire_pos(st.getChildren()[0].take())
return scanner.get_sel_wire_pos(st.getChild("m_pos").take())
#End of scan checking
scan_complete, cur_cycle, wire = None, None, None
@@ -117,27 +138,29 @@ def check_end_scan(record, scan):
def do_background():
#Store Background
if bkgrd>0:
scanner.park(wait=True)
scanner.park(wait=True)
set_exec_pars(group = "background")
r = mscan (st, st.getReadables()[4:], bkgrd)
for i in range(len(r.getReadables())):
d = r.getReadable(i)
path = get_exec_pars().group + "/"+ r.getReadables()[i].name
set_attribute(path, "Mean", mean(d))
set_attribute(path, "Sigma", stdev(d) )
try:
path = get_exec_pars().group + "/"+ r.getReadables()[i].name
set_attribute(path, "Mean", mean(d))
set_attribute(path, "Sigma", stdev(d) )
except:
pass
#Scan
def do_scan(index):
global scan_complete, cur_cycle, wire
wire = "y" if (index==1) or (scan_type in [WireScanner.WireY1, WireScanner.WireY2]) else "x"
set_exec_pars(group=wire+"_{count}", reset=True)
scanner.set_selection(get_scan_selection(scan_type, index))
scanner.set_selection(get_scan_selection(scan_type, index))
if plt is not None:
if wire == "x":
if wire == "x":
plt.getAxis(plt.AxisId.X).setRange(scan_range[0], scan_range[1])
else:
plt.getAxis(plt.AxisId.X).setRange(scan_range[2], scan_range[3])
plt.getAxis(plt.AxisId.X).setRange(scan_range[2], scan_range[3])
scanner.init(wait=True)
scanner.curr_cycl.write(0)
scan_complete=False
@@ -147,7 +170,7 @@ def do_scan(index):
for s in plt.getAllSeries():
s.clear()
plt.removeMarker(None)
try:
try:
scanner.scan() #scanner.waitState(State.Busy, 60000) Not needed as stream filter will make the wait
st.getChild("scanning").waitValue(1.0, 10000)
#print st.getValues()
@@ -183,30 +206,37 @@ msg = ""
ret = []
def calculate():
global msg
stats = []
stats, samples_val, samples_pos = [], [],[]
for i in range(len(blms)):
msg += "Wire " + wire + " - BLM " + str(i+1) + ":\n"
try:
bg = get_attributes("background/blm" + str(i+1))["Mean"] if bkgrd>0 else 0.0
samples = [[], [], [], []]
samples = [[], [], [], [], [], []]
for cycle in range (cycles):
pos_path = wire+"_" + ("%04d" % (cycle+1)) + "/w_pos"
pos = load_data(pos_path)
path = wire+"_" + ("%04d" % (cycle+1)) + "/blm" + str(i+1)
data = load_data(path)
sp = blm_remove_spikes(data)
sp = data #blm_remove_spikes(data)
sig = sp if bg is None else [v-bg for v in sp]
[rms_com, rms_sigma] = profile_rms_stats(pos, sig,noise_std=0, n_sigma=3.5)
set_attribute(path, "RMS COM", float("nan") if (rms_com is None) else rms_com)
set_attribute(path, "RMS Sigma", float("nan") if (rms_sigma is None) else rms_sigma)
#print [com, rms]
[off, amp, com, sigma] = profile_gauss_stats(pos, sig, off=None, amp=None, com=None, sigma=None)
set_attribute(path, "Gauss COM", float("nan") if (com is None) else com)
set_attribute(path, "Gauss Sigma", float("nan") if (sigma is None) else sigma)
#[rms_com, rms_sigma] = profile_rms_stats(pos, sig,noise_std=0, n_sigma=3.5)
[rms_com, rms_sigma] = profile_rms_stats_with_estimate(pos, sig, com_estimate = com, window_size = sigma * 3.5)
set_attribute(path, "RMS COM", float("nan") if (rms_com is None) else rms_com)
set_attribute(path, "RMS Sigma", float("nan") if (rms_sigma is None) else rms_sigma)
if i==0: #Write channels for BLM 1
samples_val.extend(sig)
samples_pos.extend(pos)
samples[0].append(rms_com);samples[1].append(rms_sigma);samples[2].append(com);samples[3].append(sigma)
samples[0].append(rms_com);samples[1].append(rms_sigma);
samples[2].append(com);samples[3].append(sigma);samples[4].append(amp);samples[5].append(off)
#print [off, amp, com, sigma]
#from mathutils import Gaussian
@@ -227,19 +257,71 @@ def calculate():
msg += " RMS Sigma: " + "%.4f" % stats[i][1][0] + " +- " + "%.4f" % stats[i][1][1] + "\n"
msg += " Gauss COM: " + "%.4f" % stats[i][2][0] + " +- " + "%.4f" % stats[i][2][1] + "\n"
msg += " Gauss Sigma: " + "%.4f" % stats[i][3][0] + " +- " + "%.4f" % stats[i][3][1] + "\n"
if i==0: #Write channels for BLM 1
scanner.set_out_com(bunch,wire,stats[i][0][0])
scanner.set_out_rms(bunch,wire,stats[i][1][0])
scanner.set_out_mean(bunch,wire,stats[i][2][0])
scanner.set_out_sigma(bunch,wire,stats[i][3][0] )
scanner.set_out_amp(bunch,wire,stats[i][4][0])
scanner.set_out_off(bunch,wire,stats[i][5][0])
if len(samples_pos) > SAMPLE_CHANNEL_SIZE:
samples_pos = samples_pos[0:SAMPLE_CHANNEL_SIZE]
else:
samples_pos += [SAMPLE_CHANNEL_EMPTY_VALUE] * (SAMPLE_CHANNEL_SIZE - len(samples_pos))
if len(samples_val) > SAMPLE_CHANNEL_SIZE:
samples_val = samples_pos[0:SAMPLE_CHANNEL_SIZE]
else:
samples_val += [SAMPLE_CHANNEL_EMPTY_VALUE] * (SAMPLE_CHANNEL_SIZE - len(samples_val))
scanner.set_out_pos(bunch,wire,samples_pos)
scanner.set_out_samples(bunch,wire,samples_val)
try:
gauss = Gaussian(stats[i][4][0], stats[i][2][0], stats[i][3][0])
gauss = [gauss.value(v)+stats[i][5][0] for v in samples_pos]
except:
traceback.print_exc()
gauss = [0.0] * SAMPLE_CHANNEL_SIZE
scanner.set_out_gauss(bunch,wire,gauss)
except Exception, e:
print >> sys.stderr, traceback.format_exc()
msg += str(e)+ "\n"
def get_scan_time():
global bkgrd, scan_type, scan_range, velocity
_range = 0
if not scan_type in [WireScanner.WireY1, WireScanner.WireY2]:
_range += abs(scan_range[0] - scan_range[1]) #X SCAN
if not scan_type in [WireScanner.WireX1, WireScanner.WireX2]:
_range += abs(scan_range[2] - scan_range[3]) #Y SCAN
ret = _range / velocity
ret += 2.0 #ACC/DEC
ret += bkgrd * (1.0/get_repetition_rate()) #BACK
print "Scan time = " + str(ret),
ret = ret * 2.0 + 10.0 #Tolernces
print "; with tolerance = " + str(ret),
return ret
print "Starting scan..."
try:
if SET_BLM_WS_MODE and len(blms)>0:
start_blm_ws(blms[0], get_scan_time())
#TODO: Wait for stream variable indicate bllm is in ws mode
print "Waiting for WS mode..."
#time.sleep(SET_BLM_WS_SETTLING_TIME)
st.getChild("blm1_ws_mode").waitValue(1, SET_BLM_WS_BS_READBACK_TIMEOUT)
print "Reading background..."
do_background()
st.setFilter(scanner.curr_cycl.get_name() + ">0") #scanner.status_channels[0].get_name() + ">0" not used because we must the transition to know when the finished
print "Executing scan 1..."
do_scan(0)
if scan_type in [WireScanner.Set1, WireScanner.Set2]:
print "Executing scan 2..."
do_scan(1)
finally:
if SET_BLM_WS_MODE and len(blms)>0:
stop_blm_ws(blms[0])
print "Closing scanner"
scanner.close()
print "Closing stream"
@@ -259,6 +341,7 @@ if do_elog:
log_msg = log_msg + "\nBackground Measures: " + str(bkgrd)
log_msg = log_msg + "\nBPMs: " + str(bpms)
log_msg = log_msg + "\nBLMs: " + str(blms)
log_msg = log_msg + "\nBunch: " + str(bunch)
log_msg = log_msg + "\n" + msg
elog("Wire Scan", log_msg, snapshots)

View File

@@ -0,0 +1,267 @@
import traceback
is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before callin "run"
run("Devices/Elements")
run("Devices/WireScanner")
run("Diagnostics/sig_process_wrapper")
BPM_SENSORS = [("x","X1"), ("y","Y1"), ("q","Q1")] #(logic name sufix, channel sufix)
#Paramter parsing
prefix = args[0] if is_panel else "S30CB09-DWSC440" #"SINDI01-DWSC090"
scan_type = args[1] if is_panel else WireScanner.WireX1
scan_range = args[2] if is_panel else [-200, 200, -200, 200]
cycles = args[3] if is_panel else 3
velocity = args[4] if is_panel else 200
bpms = args[5] if is_panel else get_wire_scanners_bpms(prefix)
blms = args[6] if is_panel else get_wire_scanners_blms(prefix)
bkgrd = args[7] if is_panel else 10
plt = args[8] if is_panel else plot(None, title = "Wire Scan")[0]
save_raw = args[9] if is_panel else False
do_elog = False if (plt is None) else (True if is_panel else True)
print "WireScan parameters: ", prefix, scan_type, scan_range, cycles, velocity, bpms, blms, bkgrd
#Plot setup
if plt is not None:
plt.clear()
plt.removeMarker(None)
plt.getAxis(plt.AxisId.X).setLabel("Position");
plt.getAxis(plt.AxisId.Y).setLabel("");
plt.getAxis(plt.AxisId.Y2).setLabel("");
plt.setLegendVisible(True);
snapshots = []
#Creating WireScanner object
print "Creating scanner..."
if prefix not in get_wire_scanners():
raise Exception("Invalid wire scan: " + prefix)
scanner = WireScanner(prefix, scan_range, cycles, velocity, True)
#List of stream channels
channels = [("m_pos", scanner.motor_bs_readback.get_name()),
("cur_cycle", scanner.curr_cycl.get_name()),
("scanning", scanner.status_channels[0].get_name())]
for i in range (len(blms)):
channels.append (("blm" + str(i+1), blms[i] + ":B1_LOSS"))
if plt is not None:
series = LinePlotSeries(blms[i], None, min(i+1, 2))
plt.addSeries(series)
series.setLinesVisible(False)
series.setPointSize(2)
if save_raw:
channels.append (("blm" + str(i+1) + "_raw" , blms[i] + ":LOSS_SIGNAL_RAW"))
for i in range (len(bpms)):
for sensor in BPM_SENSORS:
channels.append (("bpm" + str(i+1) + "_" + sensor[0], bpms[i] + ":" + sensor[1]))
#Metadata
set_attribute("/", "Wire Scanner", prefix)
set_attribute("/", "Scan Type", scan_type)
set_attribute("/", "Range", scan_range)
set_attribute("/", "Cycles", cycles)
set_attribute("/", "Motor Velocity", velocity*math.sqrt(2))
set_attribute("/", "Wire Velocity", velocity)
set_attribute("/", "Background Measures", bkgrd)
set_attribute("/", "BPMs", bpms)
set_attribute("/", "BLMs", blms)
filename = get_exec_pars().path
#Stream creation
print "Starting stream..."
st = Stream("pulse_id", dispatcher)
for c in channels:
st.addScalar(c[0], c[1], int(100.0 / get_repetition_rate()), 0)
st.initialize()
st.start()
st.waitCacheChange(10000) #Wait stream be running before starting scan
class Timestamp(Readable):
def read(self):
return st.getTimestamp()
#Pseudo-device returning the wire position
class w_pos(Readable):
def read(self):
return scanner.get_sel_wire_pos(st.getChildren()[0].take())
#End of scan checking
scan_complete, cur_cycle, wire = None, None, None
def check_end_scan(record, scan):
global scan_complete,cur_cycle
if record[4]<1:
print "Data aquisition completed"
scan_complete=True
scan.abort()
record.cancel() #So it won't be saved
else:
position = record[0]
if record[3] != cur_cycle:
cur_cycle = record[3]
get_context().dataManager.splitScanData(scan)
#if plt is not None: for s in plt.getAllSeries(): s.clear()
if plt is not None:
for i in range (len(blms)):
plt.getSeries(i).appendData(position, record[5 + i])
#Process background
def do_background():
#Store Background
if bkgrd>0:
scanner.park(wait=True)
set_exec_pars(group = "background")
r = mscan (st, st.getReadables()[4:], bkgrd)
for i in range(len(r.getReadables())):
d = r.getReadable(i)
path = get_exec_pars().group + "/"+ r.getReadables()[i].name
set_attribute(path, "Mean", mean(d))
set_attribute(path, "Sigma", stdev(d) )
#Scan
def do_scan(index):
global scan_complete, cur_cycle, wire
wire = "y" if (index==1) or (scan_type in [WireScanner.WireY1, WireScanner.WireY2]) else "x"
set_exec_pars(group=wire+"_{count}", reset=True)
scanner.set_selection(get_scan_selection(scan_type, index))
if plt is not None:
if wire == "x":
plt.getAxis(plt.AxisId.X).setRange(scan_range[0], scan_range[1])
else:
plt.getAxis(plt.AxisId.X).setRange(scan_range[2], scan_range[3])
scanner.init(wait=True)
scanner.curr_cycl.write(0)
scan_complete=False
cur_cycle = 1.0
if plt is not None:
for s in plt.getAllSeries():
s.clear()
plt.removeMarker(None)
try:
scanner.scan() #scanner.waitState(State.Busy, 60000) Not needed as stream filter will make the wait
st.getChild("scanning").waitValue(1.0, 10000)
#print st.getValues()
#TODO: Check what the problem is
#mscan (st, [w_pos(),] + st.getReadables() + [Timestamp(),], -1, -1, take_initial = True, after_read = check_end_scan)
l=[w_pos()] ; l.extend(st.getReadables()); l.append(Timestamp())
mscan (st, l, -1, -1, take_initial = True, after_read = check_end_scan)
#tscan([w_pos()] + st.getReadables() + [Timestamp(),], 10, 0.5)
except:
print sys.exc_info()[1]
if not scanner.isReady():
print "Aborting scan"
scanner.abort()
if not scan_complete:
raise
finally:
#Combining data of multiple series
#s=plt.getSeries(0)
#indexes = sorted(range(len(s.x)),key=lambda x:s.x[x])
#x,y = [s.x[x] for x in indexes], [s.y[x] for x in indexes]
#plot(y, xdata = x)
calculate()
img_file = os.path.abspath(filename + "_" + get_exec_pars().group[0:1] + ".png")
time.sleep(0.1) #Give some time to plot finish (async)
if plt is not None:
plt.saveSnapshot(img_file, "png")
snapshots.append(img_file)
msg = ""
ret = []
def calculate():
global msg
stats = []
for i in range(len(blms)):
msg += "Wire " + wire + " - BLM " + str(i+1) + ":\n"
try:
bg = get_attributes("background/blm" + str(i+1))["Mean"] if bkgrd>0 else 0.0
samples = [[], [], [], []]
for cycle in range (cycles):
pos_path = wire+"_" + ("%04d" % (cycle+1)) + "/w_pos"
pos = load_data(pos_path)
path = wire+"_" + ("%04d" % (cycle+1)) + "/blm" + str(i+1)
data = load_data(path)
sp = blm_remove_spikes(data)
sig = sp if bg is None else [v-bg for v in sp]
[rms_com, rms_sigma] = profile_rms_stats(pos, sig,noise_std=0, n_sigma=3.5)
set_attribute(path, "RMS COM", float("nan") if (rms_com is None) else rms_com)
set_attribute(path, "RMS Sigma", float("nan") if (rms_sigma is None) else rms_sigma)
#print [com, rms]
[off, amp, com, sigma] = profile_gauss_stats(pos, sig, off=None, amp=None, com=None, sigma=None)
set_attribute(path, "Gauss COM", float("nan") if (com is None) else com)
set_attribute(path, "Gauss Sigma", float("nan") if (sigma is None) else sigma)
samples[0].append(rms_com);samples[1].append(rms_sigma);samples[2].append(com);samples[3].append(sigma)
#print [off, amp, com, sigma]
#from mathutils import Gaussian
#g = Gaussian(amp, com, sigma)
#gauss = [g.value(v)+off for v in pos]
#plot([data, sp, sig, gauss], ["data", "sp", "signal", "gauss", ], xdata = pos, title="Fit blm" + str(i+1) + " - " + str(cycle+1))
ret.extend([rms_com, rms_sigma, com, sigma, get_exec_pars().path + "|"+ pos_path, get_exec_pars().path + "|"+ path])
stats.append([])
for sample in samples:
sample = [v for v in sample if v is not None]
stats[i].append( (mean(sample), stdev(sample)) if len(sample)>0 else (float("nan"), float("nan")) )
if plt is not None:
plt.addMarker(stats[i][2][0], None, "Gcom=" + "%.2f" % stats[i][2][0], plt.getSeries(i).color)
plt.addMarker(stats[i][0][0], None, "Rcom=" + "%.2f" % stats[i][0][0], plt.getSeries(i).color.brighter())
msg += " RMS COM: " + "%.4f" % stats[i][0][0] + " +- " +"%.4f" % stats[i][0][1] + "\n" #unichr(0x03C3) + "="
msg += " RMS Sigma: " + "%.4f" % stats[i][1][0] + " +- " + "%.4f" % stats[i][1][1] + "\n"
msg += " Gauss COM: " + "%.4f" % stats[i][2][0] + " +- " + "%.4f" % stats[i][2][1] + "\n"
msg += " Gauss Sigma: " + "%.4f" % stats[i][3][0] + " +- " + "%.4f" % stats[i][3][1] + "\n"
except Exception, e:
print >> sys.stderr, traceback.format_exc()
msg += str(e)+ "\n"
print "Starting scan..."
try:
do_background()
st.setFilter(scanner.curr_cycl.get_name() + ">0") #scanner.status_channels[0].get_name() + ">0" not used because we must the transition to know when the finished
do_scan(0)
if scan_type in [WireScanner.Set1, WireScanner.Set2]:
do_scan(1)
finally:
print "Closing scanner"
scanner.close()
print "Closing stream"
st.close()
print msg
# save the entry in the logbook
if do_elog:
if get_option("Generated data file:\n" + filename +"\n\n" + msg + "\n\n" + "Save to ELOG?", "YesNo") == "Yes":
log_msg = "Data file: " + filename
log_msg = log_msg + "\nWire Scanner: " + prefix
log_msg = log_msg + "\nScan Type: " + str(scan_type)
log_msg = log_msg + "\nRange: " + str(scan_range)
log_msg = log_msg + "\nCycles: " + str(cycles)
log_msg = log_msg + "\nWire Velocity: " + str(velocity)
log_msg = log_msg + "\nBackground Measures: " + str(bkgrd)
log_msg = log_msg + "\nBPMs: " + str(bpms)
log_msg = log_msg + "\nBLMs: " + str(blms)
log_msg = log_msg + "\n" + msg
elog("Wire Scan", log_msg, snapshots)
set_exec_pars(open=False)
set_return(ret)

View File

@@ -0,0 +1,302 @@
import traceback
is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before callin "run"
run("Devices/Elements")
run("Devices/WireScanner")
run("Diagnostics/sig_process_wrapper")
#Paramter parsing
prefix = args[0] if is_panel else "S10CB07-DWSC440" #"SINDI01-DWSC090"
scan_type = args[1] if is_panel else WireScanner.WireX1
scan_range = args[2] if is_panel else [-200, 200, -200, 200]
cycles = args[3] if is_panel else 2
velocity = args[4] if is_panel else 200
bpms = args[5] if is_panel else get_wire_scanners_bpms(prefix)
blms = args[6] if is_panel else get_wire_scanners_blms(prefix)
bkgrd = args[7] if is_panel else 5
plt = args[8] if is_panel else plot(None, title = "Wire Scan")[0]
save_raw = args[9] if is_panel else True
bunch = args[10] if is_panel else 1
do_elog = False if (plt is None) else (True if is_panel else True)
print "WireScan parameters: ", prefix, scan_type, scan_range, cycles, velocity, bpms, blms, bkgrd, bunch
SET_BLM_WS_MODE = False
SET_BLM_WS_SETTLING_TIME = 2.0
BPM_SENSORS = [("x","X"+str(bunch)), ("y","Y"+str(bunch)), ("q","Q"+str(bunch))] #(logic name suffix, channel suffix)
#Plot setup
if plt is not None:
plt.clear()
plt.removeMarker(None)
plt.getAxis(plt.AxisId.X).setLabel("Position");
plt.getAxis(plt.AxisId.Y).setLabel("");
plt.getAxis(plt.AxisId.Y2).setLabel("");
plt.setLegendVisible(True);
snapshots = []
#Creating WireScanner object
print "Creating scanner..."
if prefix not in get_wire_scanners():
raise Exception("Invalid wire scan: " + prefix)
scanner = WireScanner(prefix, scan_range, cycles, velocity, True)
#List of stream channels
channels = [("m_pos", scanner.motor_bs_readback.get_name()),
("cur_cycle", scanner.curr_cycl.get_name()),
("scanning", scanner.status_channels[0].get_name())]
for i in range (len(blms)):
channels.append (("blm" + str(i+1), blms[i] + ":B" + str(bunch) + "_LOSS"))
if plt is not None:
series = LinePlotSeries(blms[i], None, min(i+1, 2))
plt.addSeries(series)
series.setLinesVisible(False)
series.setPointSize(2)
if save_raw:
channels.append (("blm" + str(i+1) + "_raw" , blms[i] + ":LOSS_SIGNAL_RAW"))
for i in range (len(bpms)):
for sensor in BPM_SENSORS:
channels.append (("bpm" + str(i+1) + "_" + sensor[0], bpms[i] + ":" + sensor[1]))
#Metadata
set_attribute("/", "Wire Scanner", prefix)
set_attribute("/", "Scan Type", scan_type)
set_attribute("/", "Range", scan_range)
set_attribute("/", "Cycles", cycles)
set_attribute("/", "Motor Velocity", velocity*math.sqrt(2))
set_attribute("/", "Wire Velocity", velocity)
set_attribute("/", "Background Measures", bkgrd)
set_attribute("/", "BPMs", bpms)
set_attribute("/", "BLMs", blms)
set_attribute("/", "Bunch", bunch)
filename = get_exec_pars().path
#Stream creation
print "Starting stream..."
st = Stream("pulse_id", dispatcher)
for c in channels:
if c[1].endswith("LOSS_SIGNAL_RAW"):
st.addWaveform(c[0], c[1], int(100.0 / get_repetition_rate()), 0)
else:
st.addScalar(c[0], c[1], int(100.0 / get_repetition_rate()), 0)
st.initialize()
st.start()
st.waitCacheChange(10000) #Wait stream be running before starting scan
class Timestamp(Readable):
def read(self):
return st.getTimestamp()
#Pseudo-device returning the wire position
class w_pos(Readable):
def read(self):
return scanner.get_sel_wire_pos(st.getChild("m_pos").take())
#End of scan checking
scan_complete, cur_cycle, wire = None, None, None
def check_end_scan(record, scan):
global scan_complete,cur_cycle
if record[4]<1:
print "Data aquisition completed"
scan_complete=True
scan.abort()
record.cancel() #So it won't be saved
else:
position = record[0]
if record[3] != cur_cycle:
cur_cycle = record[3]
get_context().dataManager.splitScanData(scan)
#if plt is not None: for s in plt.getAllSeries(): s.clear()
if plt is not None:
for i in range (len(blms)):
plt.getSeries(i).appendData(position, record[5 + i])
#Process background
def do_background():
#Store Background
if bkgrd>0:
scanner.park(wait=True)
set_exec_pars(group = "background")
r = mscan (st, st.getReadables()[4:], bkgrd)
for i in range(len(r.getReadables())):
d = r.getReadable(i)
try:
path = get_exec_pars().group + "/"+ r.getReadables()[i].name
set_attribute(path, "Mean", mean(d))
set_attribute(path, "Sigma", stdev(d) )
except:
pass
#Scan
def do_scan(index):
global scan_complete, cur_cycle, wire
wire = "y" if (index==1) or (scan_type in [WireScanner.WireY1, WireScanner.WireY2]) else "x"
set_exec_pars(group=wire+"_{count}", reset=True)
scanner.set_selection(get_scan_selection(scan_type, index))
if plt is not None:
if wire == "x":
plt.getAxis(plt.AxisId.X).setRange(scan_range[0], scan_range[1])
else:
plt.getAxis(plt.AxisId.X).setRange(scan_range[2], scan_range[3])
scanner.init(wait=True)
scanner.curr_cycl.write(0)
scan_complete=False
cur_cycle = 1.0
if plt is not None:
for s in plt.getAllSeries():
s.clear()
plt.removeMarker(None)
try:
scanner.scan() #scanner.waitState(State.Busy, 60000) Not needed as stream filter will make the wait
st.getChild("scanning").waitValue(1.0, 10000)
#print st.getValues()
#TODO: Check what the problem is
#mscan (st, [w_pos(),] + st.getReadables() + [Timestamp(),], -1, -1, take_initial = True, after_read = check_end_scan)
l=[w_pos()] ; l.extend(st.getReadables()); l.append(Timestamp())
mscan (st, l, -1, -1, take_initial = True, after_read = check_end_scan)
#tscan([w_pos()] + st.getReadables() + [Timestamp(),], 10, 0.5)
except:
print sys.exc_info()[1]
if not scanner.isReady():
print "Aborting scan"
scanner.abort()
if not scan_complete:
raise
finally:
#Combining data of multiple series
#s=plt.getSeries(0)
#indexes = sorted(range(len(s.x)),key=lambda x:s.x[x])
#x,y = [s.x[x] for x in indexes], [s.y[x] for x in indexes]
#plot(y, xdata = x)
calculate()
img_file = os.path.abspath(filename + "_" + get_exec_pars().group[0:1] + ".png")
time.sleep(0.1) #Give some time to plot finish (async)
if plt is not None:
plt.saveSnapshot(img_file, "png")
snapshots.append(img_file)
msg = ""
ret = []
def calculate():
global msg
stats = []
for i in range(len(blms)):
msg += "Wire " + wire + " - BLM " + str(i+1) + ":\n"
try:
bg = get_attributes("background/blm" + str(i+1))["Mean"] if bkgrd>0 else 0.0
samples = [[], [], [], []]
for cycle in range (cycles):
pos_path = wire+"_" + ("%04d" % (cycle+1)) + "/w_pos"
pos = load_data(pos_path)
path = wire+"_" + ("%04d" % (cycle+1)) + "/blm" + str(i+1)
data = load_data(path)
sp = data #blm_remove_spikes(data)
sig = sp if bg is None else [v-bg for v in sp]
#print [com, rms]
[off, amp, com, sigma] = profile_gauss_stats(pos, sig, off=None, amp=None, com=None, sigma=None)
set_attribute(path, "Gauss COM", float("nan") if (com is None) else com)
set_attribute(path, "Gauss Sigma", float("nan") if (sigma is None) else sigma)
#[rms_com, rms_sigma] = profile_rms_stats(pos, sig,noise_std=0, n_sigma=3.5)
[rms_com, rms_sigma] = profile_rms_stats_with_estimate(pos, sig, com_estimate = com, window_size = sigma * 3.5)
set_attribute(path, "RMS COM", float("nan") if (rms_com is None) else rms_com)
set_attribute(path, "RMS Sigma", float("nan") if (rms_sigma is None) else rms_sigma)
samples[0].append(rms_com);samples[1].append(rms_sigma);samples[2].append(com);samples[3].append(sigma)
#print [off, amp, com, sigma]
#from mathutils import Gaussian
#g = Gaussian(amp, com, sigma)
#gauss = [g.value(v)+off for v in pos]
#plot([data, sp, sig, gauss], ["data", "sp", "signal", "gauss", ], xdata = pos, title="Fit blm" + str(i+1) + " - " + str(cycle+1))
ret.extend([rms_com, rms_sigma, com, sigma, get_exec_pars().path + "|"+ pos_path, get_exec_pars().path + "|"+ path])
stats.append([])
for sample in samples:
sample = [v for v in sample if v is not None]
stats[i].append( (mean(sample), stdev(sample)) if len(sample)>0 else (float("nan"), float("nan")) )
if plt is not None:
plt.addMarker(stats[i][2][0], None, "Gcom=" + "%.2f" % stats[i][2][0], plt.getSeries(i).color)
plt.addMarker(stats[i][0][0], None, "Rcom=" + "%.2f" % stats[i][0][0], plt.getSeries(i).color.brighter())
msg += " RMS COM: " + "%.4f" % stats[i][0][0] + " +- " +"%.4f" % stats[i][0][1] + "\n" #unichr(0x03C3) + "="
msg += " RMS Sigma: " + "%.4f" % stats[i][1][0] + " +- " + "%.4f" % stats[i][1][1] + "\n"
msg += " Gauss COM: " + "%.4f" % stats[i][2][0] + " +- " + "%.4f" % stats[i][2][1] + "\n"
msg += " Gauss Sigma: " + "%.4f" % stats[i][3][0] + " +- " + "%.4f" % stats[i][3][1] + "\n"
except Exception, e:
print >> sys.stderr, traceback.format_exc()
msg += str(e)+ "\n"
def get_scan_time():
global bkgrd, scan_type, scan_range, velocity
_range = 0
if not scan_type in [WireScanner.WireY1, WireScanner.WireY2]:
_range += abs(scan_range[0] - scan_range[1]) #X SCAN
if not scan_type in [WireScanner.WireX1, WireScanner.WireX2]:
_range += abs(scan_range[2] - scan_range[3]) #Y SCAN
ret = _range / velocity
ret += 2.0 #ACC/DEC
ret += bkgrd * (1.0/get_repetition_rate()) #BACK
print "Scan time = " + str(ret),
ret = ret * 2.0 + 10.0 #Tolernces
print "; with tolerance = " + str(ret),
return ret
print "Starting scan..."
try:
if SET_BLM_WS_MODE and len(blms)>0:
start_blm_ws(blms[0], get_scan_time())
#TODO: Wait for stream variable indicate bllm is in ws mode
time.sleep(SET_BLM_WS_SETTLING_TIME)
do_background()
st.setFilter(scanner.curr_cycl.get_name() + ">0") #scanner.status_channels[0].get_name() + ">0" not used because we must the transition to know when the finished
do_scan(0)
if scan_type in [WireScanner.Set1, WireScanner.Set2]:
do_scan(1)
finally:
if SET_BLM_WS_MODE and len(blms)>0:
stop_blm_ws(blms[0])
print "Closing scanner"
scanner.close()
print "Closing stream"
st.close()
print msg
# save the entry in the logbook
if do_elog:
if get_option("Generated data file:\n" + filename +"\n\n" + msg + "\n\n" + "Save to ELOG?", "YesNo") == "Yes":
log_msg = "Data file: " + filename
log_msg = log_msg + "\nWire Scanner: " + prefix
log_msg = log_msg + "\nScan Type: " + str(scan_type)
log_msg = log_msg + "\nRange: " + str(scan_range)
log_msg = log_msg + "\nCycles: " + str(cycles)
log_msg = log_msg + "\nWire Velocity: " + str(velocity)
log_msg = log_msg + "\nBackground Measures: " + str(bkgrd)
log_msg = log_msg + "\nBPMs: " + str(bpms)
log_msg = log_msg + "\nBLMs: " + str(blms)
log_msg = log_msg + "\nBunch: " + str(bunch)
log_msg = log_msg + "\n" + msg
elog("Wire Scan", log_msg, snapshots)
set_exec_pars(open=False)
set_return(ret)

View File

@@ -0,0 +1,109 @@
import traceback
is_panel = get_exec_pars().source != CommandSource.ui #Must be checked before callin "run"
run("Devices/Elements")
run("Devices/WireScanner")
run("Diagnostics/sig_process_wrapper")
ws_prefix = args[0] if is_panel else "S10DI01-DWSC010" #"S10CB07-DWSC440" #"SINDI01-DWSC090" \\
plt = args[1] if is_panel else plot(None, title = "Wire Scan Calibration")[0]
ws_blm = get_wire_scanners_blms(ws_prefix )[0]
#S10DI01-DBLM113:AL1-WS-PMT-GAIN
SATURATION = 1000
OPT_STEP = 0.01
#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 = 50
#3) Set a test scanning range (e.g.,Xmin=-1000,Xmax=+1000um)
x_min, x_max = -1000.0, 1000.0
#4) For a given machine repetition-rate (RR), the scan speed is automatically set to WSC_speed=(Xmax- Xmin)*RR/N_shot
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 , WireScanner.WireX1, [x_min, x_max, x_min, x_max], 1, ws_speed, [], [ws_blm], 10, plt, False,1]
ret = run("Diagnostics/WireScan", args)
#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)
[rms_com, rms_sigma, com, sigma, pos_path, path] = ret
#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)
caput(ws_prefix+":MOTOR_1.VAL", motor_pos) #DVAL?
#LOPR:0.5 HOPR:1.1
def get_gain():
return caget(ws_blm + ":WS_PMT_GAIN_VOLTS")
def set_gain(val):
caput(ws_blm + ":WS_PMT_GAIN_VOLTS", float(val))
print "Starting stream..."
st = Stream("blm_stream", dispatcher)
ch = ws_blm + ":B1_LOSS"
st.addScalar(ch, ch, int(100.0 / get_repetition_rate()), 0)
st.initialize()
st.start()
st.waitCacheChange(10000) #Wait stream be running before starting scan
def get_loss():
return st.getValue(ch)
start_gain = get_gain()
pos = start_val = get_loss()
loss = get_loss()
target = SATURATION * 0.9
print "Start Gain = ", start_gain
print "Start Loss = ", start_val
print "Target = ", target
if start_val>target:
for pos in range(start_val, target, -OPT_STEP):
set_gain(pos)
loss = get_loss()
if loss<=target:
break
elif start_val<target:
for pos in range(start_val, target, OPT_STEP):
set_gain(pos)
loss = get_loss()
if loss()>=target:
break
print "Final Gain = ", pos
print "Final Loss = ", loss
print get_gain()
print get_loss()
#set_gain(0.6)
#set_gain(0.5)
#caget(ws_blm+":SAT_RAW_SUM")
#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()

View File

@@ -0,0 +1,14 @@
run("Devices/Elements")
for scanner in get_wire_scanners():
try:
if caget(scanner + ":MOTOR_1_HOMED",'i') != 1:
print scanner + " is not homed"
else:
pos = caget(scanner + ":MOTOR_1.RBV", 's')
if (caget(scanner + ":WIRE_SP", 'i') != 0) or (caget(scanner + ":INIT_DONE", 'i') != 1):
print scanner + " is not parked - pos: " + pos + " - Parking..."
else:
print scanner + " is parked - pos: " + pos
except:
print "Error accessing: " + scanner

View File

@@ -103,7 +103,7 @@ def remove_beam_jitter(pos: np.ndarray, bpm1: np.ndarray, bpm2: np.ndarray, d_b1
# Profile statistics ####
def profile_gauss_stats(x, y, off=None, amp=None, com=None, sigma=None):
def profile_gauss_stats(x, y, off=None, amp=None, com=None, sigma=None, with_offset=True):
if off is None:
off = y.min() # good enough starting point for offset
@@ -118,8 +118,14 @@ def profile_gauss_stats(x, y, off=None, amp=None, com=None, sigma=None):
surface = np.trapz((y-off), x=x)
sigma = surface / (amp * np.sqrt(2 * np.pi))
try:
popt, pcov = scipy.optimize.curve_fit(gauss_fn, x, y, p0=[off, amp, com, sigma], method='lm')
popt[3] = abs(popt[3]) # sigma should be returned as positive
#popt, pcov = scipy.optimize.curve_fit(gauss_fn, x, y, p0=[off, amp, com, sigma], method='lm')
#CHANGED BY GOBBO
if with_offset:
popt, pcov = scipy.optimize.curve_fit(gauss_fn, x, y, p0=[off, amp, com, sigma])
popt[3] = abs(popt[3]) # sigma should be returned as positive
else:
popt, pcov = scipy.optimize.curve_fit(gauss_fn_no_offset, x, y, p0=[amp, com, sigma])
popt[2] = abs(popt[2]) # sigma should be returned as positive
except Exception as e:
print("Gauss fitting not successful.\n" + str(e))
popt = [off, amp, com, abs(sigma)]
@@ -130,6 +136,9 @@ def profile_gauss_stats(x, y, off=None, amp=None, com=None, sigma=None):
def gauss_fn(x, a, b, c, d):
return a + b * np.exp(-(np.power((x - c), 2) / (2 * np.power(d, 2))))
def gauss_fn_no_offset(x, b, c, d):
return b * np.exp(-(np.power((x - c), 2) / (2 * np.power(d, 2))))
def profile_rms_stats(x, y, noise_std=0, n_sigma=3.5):
"""
@@ -212,6 +221,49 @@ def profile_rms_stats(x, y, noise_std=0, n_sigma=3.5):
else:
return None, None
def profile_rms_stats_with_estimate(x, y, com_estimate, window_size):
"""
Does the center of mass and RMS calculation on given profile.
:param x: data of x axis (wire position)
:param y: data of y axis (blm current)
:param noise_std: standard deviation of noise
:param n_sigma: multiplication of window size (n_sigma*sigma) where sigma is first estimation of sigma
:return: rms of signal
"""
window_size
if x.shape == y.shape:
# Windowing the signal
# Define direction of scan
if x[0] < x[-1]: # increasing position
low_boundary = np.argmax(x >= com_estimate - window_size)-1
high_boundary = np.argmax(x >= com_estimate +window_size)-1
else: # decreasing position
high_boundary = np.argmax(x <= com_estimate- window_size)-1
low_boundary = np.argmax(x <= com_estimate +window_size)-1
if high_boundary <= 0:
high_boundary = x.size
if low_boundary < 0:
low_boundary = 0
if (high_boundary-low_boundary) < 4:
print("RMS calculation not successful. Resolution to low.\n")
return None, None
# Calculate final RMS and centroid on ROI data
if high_boundary == x.size:
com, rms = com_rms(x[low_boundary:], y[low_boundary:])
else:
com, rms = com_rms(x[low_boundary:high_boundary], y[low_boundary:high_boundary])
return com, rms
else:
return None, None
def com_rms(x, y):
# Centre of mass and rms

View File

@@ -20,12 +20,14 @@ def remove_beam_jitter(pos, bpm1, bpm2, d_b1_w=1, d_w_b2=1):
ret = call_jep(MODULE, "remove_beam_jitter", [to_npa(pos),to_npa(bpm1), to_npa(bpm2), d_b1_w, d_w_b2 ])
return ret if ret is None or is_list(ret) else ret.data
def profile_gauss_stats(x, y, off=None, amp=None, com=None, sigma=None):
ret = call_jep(MODULE, "profile_gauss_stats", [to_npa(x), to_npa(y), off, amp, com, sigma])
def profile_gauss_stats(x, y, off=None, amp=None, com=None, sigma=None, with_offset = True):
ret = call_jep(MODULE, "profile_gauss_stats", [to_npa(x), to_npa(y), off, amp, com, sigma, with_offset])
return ret if ret is None or is_list(ret) else ret.data
def profile_rms_stats(x, y, noise_std=0, n_sigma=3.5):
return call_jep(MODULE, "profile_rms_stats", [to_npa(x), to_npa(y), noise_std, n_sigma])
def profile_rms_stats_with_estimate(x, y, com_estimate, window_size):
return call_jep(MODULE, "profile_rms_stats_with_estimate", [to_npa(x), to_npa(y), com_estimate, window_size])

View File

@@ -1,9 +0,0 @@
Eph1 = 2365
Eph2 = 2150
undlist = (SARUN03,SARUN04,SARUN05,SARUN06,SARUN07,SARUN08,SARUN09,SARUN10,SARUN11,SARUN12,SARUN13,SARUN14,SARUN15)
for und in undlist
K1 = caget(und + "-RSYS:SET-SCAN-START")
K2 = SQRT(2*(Eph1/Eph2*(1+0.5*K1^2)-1))

View File

@@ -1,10 +1,11 @@
import ch.psi.pshell.epics.Positioner as Positioner
#import ch.psi.pshell.epics.Camtool as Camtool
dry_run = False
do_elog = True
is_panel = get_exec_pars().source != CommandSource.ui #must be check before run
USE_SCREEN_PANEL = True
run("CPython/wrapper")
#Parameters
@@ -18,10 +19,10 @@ if is_panel:
p0 = args[6]
plt = args[7]
else:
start = 44.0
stop = 65.0
step = 1.0
nb = 3
start = 85.0
stop = 95.0
step = 0.5
nb = 20
lat = 0.3
disp = -0.387
p0 = 7.1
@@ -43,10 +44,10 @@ plt.setLegendVisible(True)
#Creating Phase positioner
if dry_run:
phase = Positioner("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE-SIM", "SINEG01-RSYS:SET-BEAM-PHASE-SIM")
phase = Positioner("SINEG01-RSYS:SET-BEAM-PHASE-SIM", "SINEG01-RSYS:SET-BEAM-PHASE-SIM", "SINEG01-RSYS:SET-BEAM-PHASE-SIM")
camera_name = "simulation"
else:
phase = Positioner("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:GET-BEAM-PHASE")
phase = Positioner("SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:GET-BEAM-PHASE")
camera_name = "SINBD01-DSCR010"
phase.config.minValue = -360.0
phase.config.maxValue = 360.0
@@ -58,10 +59,11 @@ phase.initialize()
phase0 = phase.read()
#Camera setup
cam_server.start(camera_name)
if USE_SCREEN_PANEL:
cam_server.start(camera_name+"_sp1", True) #True for shared pipeline
else:
cam_server.start(camera_name)
wait_cam_server_message()
#x = cam_server.stream.getChild("x_fit_mean")
#dx = cam_server.stream.getChild("x_fit_standard_deviation")
x = cam_server.stream.getChild("x_center_of_mass")
dx = cam_server.stream.getChild("x_rms")
@@ -88,7 +90,6 @@ try:
finally:
phase.write(phase0)
phase.close()
#camtool.stop() # stops camtool but does not close it camtool is a global object
cam_server.stop() # stops cam_server but does not close it cam_server is a global object
ph = r.getPositions(0)
@@ -99,9 +100,9 @@ dp = [abs(A) * val.mean for val in r.getReadable(1)]
try:
i_max = p.index(max(p))
i_min = dp.index(min(dp))
min_i, max_i = max(i_max-8, 0), min(i_max+6, len(p))
min_i, max_i = max(i_max-8, 0), min(i_max+8, len(p))
(ph_p_max, p_max, ph_p_fit, p_fit, p_R2) = extremum(ph[min_i:max_i], p[min_i:max_i])
min_i, max_i = max(i_min-8, 0), min(i_min+6, len(dp))
min_i, max_i = max(i_min-8, 0), min(i_min+8, len(dp))
(ph_dp_min, dp_min, ph_dp_fit, dp_fit, dp_R2) = extremum(ph[min_i:max_i], dp[min_i:max_i])
plt.addSeries(LinePlotErrorSeries("Momentum Fit", plt.getSeries(0).color))
plt.addSeries(LinePlotErrorSeries("Momentum Spread Fit", plt.getSeries(1).color, 2))
@@ -115,14 +116,14 @@ except:
raise Exception("Fit failure")
#Saving metadata
save_dataset(get_exec_pars().group + "/p", p)
set_attribute(get_exec_pars().group + "/p", "p max", p_max)
set_attribute(get_exec_pars().group + "/p", "p max phase", ph_p_max)
set_attribute(get_exec_pars().group + "/p", "p fit R2", p_R2)
save_dataset(get_exec_pars().group + "/dp", dp)
set_attribute(get_exec_pars().group + "/dp", "dp min", dp_min)
set_attribute(get_exec_pars().group + "/dp", "dp min phase", ph_dp_min)
set_attribute(get_exec_pars().group + "/dp", "dp fit R2", dp_R2)
save_dataset(get_exec_pars().group + "/processed/p", p)
set_attribute(get_exec_pars().group + "/processed/p", "p max", p_max)
set_attribute(get_exec_pars().group + "/processed/p", "p max phase", ph_p_max)
set_attribute(get_exec_pars().group + "/processed/p", "p fit R2", p_R2)
save_dataset(get_exec_pars().group + "/processed/dp", dp)
set_attribute(get_exec_pars().group + "/processed/dp", "dp min", dp_min)
set_attribute(get_exec_pars().group + "/processed/dp", "dp min phase", ph_dp_min)
set_attribute(get_exec_pars().group + "/processed/dp", "dp fit R2", dp_R2)
#Elog entry
if do_elog:

View File

@@ -0,0 +1,37 @@
dry_run = False
do_elog = True
if get_exec_pars().source == CommandSource.ui:
las_offset_deg = 0.0
plt = None
else:
las_offset_deg = args[0]
plt = args[1]
cur_las_delay = 0.0
if Laser == "Alcor":
cur_las_delay = caget("SLGOS01-TSPL-ALC:CURR_DELTA_T")
elif Laser == "Jaguar":
cur_las_delay = caget("SLGJG-TSPL-JAG:CURR_DELTA_T")
new_las_delay = cur_las_delay - 333.467 * las_offset_deg / 360.0
if not dry_run:
if Laser == "Alcor":
caput("SLGOS01-TSPL-ALC:NEW_DELTA_T" , new_las_delay )
caput("SLGOS01-TSPL-ALC:SET_NEW_PHASE.PROC" , 1 )
elif Laser == "Jaguar":
caput("SLGJG-TSPL-JAG:NEW_DELTA_T" , new_las_delay )
caput("SLGJG-TSPL-JAG:SET_NEW_PHASE.PROC" , 1 )
if do_elog:
title = "Set laser delay"
log_msg = ""
if Laser == "Alcor":
log_msg = "SLGOS01-TSPL-ALC:NEW_DELTA_T: %0.4f" % new_las_delay + " ps (was %0.2f" % cur_las_delay + " ps)\n"
elif Laser == "Jaguar":
log_msg = "SLGJG-TSPL-JAG:NEW_DELTA_T: %0.4f" % new_las_delay + " ps (was %0.2f" % cur_las_delay + " ps)\n"
attachments = []
if plt is not None:
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
file_name = os.path.abspath(get_context().setup.getContextPath() + "/GunEnergyScanLasSet.png")
plt.saveSnapshot(file_name , "png")
attachments = [file_name]
elog(title, log_msg, attachments)
show_message("Success setting laser delay")

View File

@@ -0,0 +1,163 @@
import ch.psi.pshell.epics.Positioner as Positioner
dry_run = False
do_elog = True
set_exec_pars(layout="sf")
is_panel = get_exec_pars().source != CommandSource.ui #must be check before run
USE_SCREEN_PANEL = True
run("CPython/wrapper")
#Parameters
if is_panel:
start = args[0]
stop = args[1]
step = args[2]
nb = int(args[3])
lat = args[4]
disp = args[5]
p0 = args[6]
plt = args[7]
else:
start = 85.0
stop = 95.0
step = 0.5
nb = 3
lat = 0.15
disp = -0.387
p0 = 7.1
plt = plot(None, title="Output")[0]
A = p0 / disp / 1e6
B = p0
#Plot setup
plt.clear()
plt.removeMarker(None)
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Momentum", Color.red))
plt.addSeries(LinePlotErrorSeries("Momentum Spread", Color.yellow, 2))
plt.getAxis(plt.AxisId.X).setLabel("Gun Beam Phase (deg)")
plt.getAxis(plt.AxisId.Y).setLabel("Momentum (MeV/c)")
plt.getAxis(plt.AxisId.Y2).setLabel("Momentum Spread (MeV/c)")
plt.setLegendVisible(True)
#Creating Phase positioner
if dry_run:
phase = Positioner("Gun Phase", "SINEG01-RSYS:SET-BEAM-PHASE-SIM", "SINEG01-RSYS:SET-BEAM-PHASE-SIM")
camera_name = "simulation"
else:
phase = Positioner("Gun Phase", "SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:GET-BEAM-PHASE")
camera_name = "SINBD01-DSCR010"
phase.config.minValue = -90.0
phase.config.maxValue = 360.0
phase.config.precision = 4
phase.config.resolution = 0.1
phase.config.rotation = True
phase.config.save()
phase.initialize()
phase0 = phase.read() % 360
#Camera setup
if USE_SCREEN_PANEL:
cam_server.start(camera_name+"_sp1", True) #True for shared pipeline
else:
cam_server.start(camera_name)
wait_cam_server_message()
x = cam_server.stream.getChild("x_center_of_mass")
dx = cam_server.stream.getChild("x_rms")
#Creating averagers
x_averager = create_averager(x, nb, -1) # -1 event based, waits for the next value
dx_averager = create_averager(dx, nb, -1)
dx_averager.monitored = True # not blocking, will return last nb values
#Record callback: uptate of output plot
def after_sample(record, scan):
global A, B, plt
x_pos_mean, x_pos_stdev = record.values[0].mean, record.values[0].stdev
x_width_mean, x_width_stdev = record.values[1].mean, record.values[1].stdev
p_mean, p_stdev = A * x_pos_mean + B, abs(A) * x_pos_stdev
dp_mean, dp_stdev = abs(A) * x_width_mean, abs(A) * x_width_stdev
phase = ((record.positions[0] + 90) % 360) - 90 if start < 0 else record.positions[0]
plt.getSeries(0).appendData(phase, p_mean, p_stdev)
plt.getSeries(1).appendData(phase, dp_mean, dp_stdev)
#The scan loop
try:
phase.write(start)
time.sleep(2.0)
r = lscan(phase, [x_averager, dx_averager], start, stop, step , latency=lat, after_read = after_sample)
finally:
phase.write(phase0)
phase.close()
cam_server.stop() # stops cam_server but does not close it cam_server is a global object
ph = r.getPositions(0)
if start < 0:
ph = [((val + 90) % 360) -90 for val in ph ]
p = [A * val.mean + B for val in r.getReadable(0)]
dp = [abs(A) * val.mean for val in r.getReadable(1)]
#Fitting and plotting
try:
i_max = p.index(max(p))
i_min = dp.index(min(dp))
min_i, max_i = max(i_max-8, 0), min(i_max+8, len(p))
(ph_p_max, p_max, ph_p_fit, p_fit, p_R2) = extremum(ph[min_i:max_i], p[min_i:max_i])
min_i, max_i = max(i_min-8, 0), min(i_min+8, len(dp))
(ph_dp_min, dp_min, ph_dp_fit, dp_fit, dp_R2) = extremum(ph[min_i:max_i], dp[min_i:max_i])
plt.addSeries(LinePlotErrorSeries("Momentum Fit", plt.getSeries(0).color))
plt.addSeries(LinePlotErrorSeries("Momentum Spread Fit", plt.getSeries(1).color, 2))
plt.getSeries(2).setData(ph_p_fit, p_fit)
plt.getSeries(3).setData(ph_dp_fit, dp_fit)
plt.getSeries(2).setPointsVisible(False)
plt.getSeries(3).setPointsVisible(False)
plt.addMarker(ph_p_max, plt.AxisId.X, "%3.2f" % ph_p_max, plt.getSeries(0).color)
plt.addMarker(ph_dp_min, plt.AxisId.X, "%3.2f" % ph_dp_min, plt.getSeries(1).color)
except:
raise Exception("Fit failure")
# Calculating laser offset in ps
las_offset_deg = ph_dp_min - 90.0
#Saving metadata
save_dataset( "scan 1/processed/p" , p )
set_attribute( "scan 1/processed/p" , "p max" , p_max )
set_attribute( "scan 1/processed/p" , "p max phase" , ph_p_max )
set_attribute( "scan 1/processed/p" , "p fit R2" , p_R2 )
set_attribute( "scan 1/processed/p" , "Unit" , "MeV" )
save_dataset( "scan 1/processed/dp" , dp )
set_attribute( "scan 1/processed/dp" , "dp min" , dp_min )
set_attribute( "scan 1/processed/dp" , "dp min phase" , ph_dp_min )
set_attribute( "scan 1/processed/dp" , "dp fit R2" , dp_R2 )
set_attribute( "scan 1/processed/dp" , "Unit" , "MeV" )
#Elog entry
if do_elog:
if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes":
title = "Gun Energy Scan"
Laser = str(caget("SLG-LGEN:WHICH_LASER"))
log_msg = "Data file: " + get_exec_pars().path + "\n\n"
log_msg = log_msg + "Laser: " + Laser + "\n"
if Laser == "Alcor":
log_msg = log_msg + "Energy plate Alcor: %0.2f" % caget("SLGTH01-LMRM-M074:MOT.RBV") + " deg \n"
elif Laser == "Jaguar":
log_msg = log_msg + "Energy plate Jaguar: %0.2f" % caget("SLGJG-LMRM-M031:MOT.RBV") + " deg \n"
elif Laser == "Both":
log_msg = log_msg + "Energy plate Alcor: %0.2f" % caget("SLGTH01-LMRM-M074:MOT.RBV") + " deg \n"
log_msg = log_msg + "Energy plate Jaguar: %0.2f" % caget("SLGJG-LMRM-M031:MOT.RBV") + " deg \n"
if caget("SLGTV-LMTO-M053:MOT-ACT-POS") == "IRIS":
log_msg = log_msg + "Collimator: IRIS %0.2f" % caget("SLGTV-LAPP:SIZE-GET") + " mm \n"
else:
log_msg = log_msg + "Collimator: " + str(caget("SLGTV-LMTO-M053:MOT-ACT-POS")) + "\n"
log_msg = log_msg + "Charge: %0.2f" % caget("SINEG01-DICT215:B1_CHARGE-OP") + " pC at %0.2f" % phase0 + " deg beam phase\n"
log_msg = log_msg + "p-max: %0.2f" % p_max + " MeV/c at %0.2f" % ph_p_max + " deg beam phase\n"
log_msg = log_msg + "dp-min: %0.4f" % dp_min + " MeV/c at %0.2f" % ph_dp_min + " deg beam phase\n"
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
file_name = os.path.abspath(get_context().setup.getContextPath() + "/GunEnergyScanPlot.png")
plt.saveSnapshot(file_name , "png")
elog(title, log_msg, [file_name,])
set_return([ph_dp_min, las_offset_deg])

View File

@@ -1,24 +1,25 @@
dry_run = True
dry_run = False
do_elog = True
if get_exec_pars().source == CommandSource.ui:
bph_ref_user = 19.0
plt = None
bph_ref_user = 90.0
plt = None
else:
bph_ref_user = args[0]
plt = args[1]
phaseOffset_old = caget("SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE")
phaseOffset_new = 90 - bph_ref_user + phaseOffset_old
bph_ref_user = args[0]
plt = args[1]
phase_offset_old = caget("SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE")
phase_offset_new = 90 - bph_ref_user + phase_offset_old
if not dry_run:
caput("SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE", phaseOffset_new)
caput("SINEG01-RSYS:CMD-LOAD-CALIB-BEAM", 1)
caput("SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE" , phase_offset_new )
caput("SINEG01-RSYS:CMD-LOAD-CALIB-BEAM" , 1 )
if do_elog:
log_msg = "SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE: %0.2f" % phase_offset_new + " deg (was %0.2f" % phase_offset_old + " deg)\n"
title = "Set gun phase"
log_msg = "SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE: %0.2f" % phase_offset_new + " deg (was %0.2f" % phase_offset_old + " deg)\n"
attachments = []
if plt is not None:
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
file_name = os.path.abspath(get_context().setup.getContextPath() + "/GunEnergyScanSet.png")
file_name = os.path.abspath(get_context().setup.getContextPath() + "/GunEnergyScanRfSet.png")
plt.saveSnapshot(file_name , "png")
attachments = [file_name]
elog("Set gun phase", log_msg, attachments)
elog(title, log_msg, attachments)
show_message("Success setting phase reference")

View File

@@ -3,12 +3,14 @@ import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
dry_run = False
do_elog = True
set_exec_pars(layout="sf")
is_panel = get_exec_pars().source != CommandSource.ui
if is_panel:
station = args[0]
bpm_ch = args[1]
else:
station = "STEST01"
station = "SINSB01"
bpm_ch = "SINBC02-DBPM140"
start = caget(station + "-RSYS:SET-SCAN-START")
stop = caget(station + "-RSYS:SET-SCAN-STOP")
@@ -22,7 +24,7 @@ def mbnd(bpm_ch):
'SINLH02-DBPM240': 'SINLH02-MBND100',
'SINBC02-DBPM140': 'SINBC02-MBND100',
'SINBC02-DBPM320': 'SINBC02-MBND100',
'S10DI01-DBPM020': 'S10DI01-MBND100',
'S10BD01-DBPM020': 'S10DI01-MBND100',
'S10BC02-DBPM140': 'S10BC02-MBND100',
'S10BC02-DBPM320': 'S10BC02-MBND100',
'SARCL02-DBPM110': 'SARCL02-MBND100',
@@ -39,17 +41,17 @@ phase = Positioner("Phase", station + "-RSYS:SET-VSUM-PHASE", station + "-RSYS:
phase.config.minValue =-90.0
phase.config.maxValue = 360.0
phase.config.precision = 4
phase.config.rotation = True
phase.config.resolution = 0.1
phase.config.rotation = True
phase.initialize()
V = ChannelDouble("Amplitude Readback", station + "-RSYS:GET-VSUM-AMPLT")
P = ChannelDouble("Power Readback", station + "-RSYS:GET-KLY-POWER")
V = ChannelDouble(station + " Amplitude", station + "-RSYS:GET-VSUM-AMPLT")
P = ChannelDouble(station + " Klystron Power", station + "-RSYS:GET-KLY-POWER-GATED")
V.initialize()
P.initialize()
if dry_run:
x = ChannelDouble("BPM-X", bpm_ch + ":X1-SIMU")
x = ChannelDouble("BPM-X averager", bpm_ch + ":X1-SIMU")
else:
x = ChannelDouble("BPM-X", bpm_ch + ":X1")
x = ChannelDouble("BPM-X averager", bpm_ch + ":X1")
x.initialize()
phase0 = phase.read() % 360
caput(station + "-RSYS:GET-FIT-PHASE-ARRAY", to_array([0.0],'d'))
@@ -120,21 +122,19 @@ caput(station + "-RSYS:SET-VSUM-AMPLT-SCALE-CALC", amplitude_scale)
caput(station + "-RSYS:SET-VOLT-POWER-SCALE-CALC", power_scale)
#Saving metadata
save_dataset (get_exec_pars().group + "/Station" , station )
save_dataset (get_exec_pars().group + "/Energy" , energy )
save_dataset (get_exec_pars().group + "/Energy gain" , fit_amplitude )
save_dataset (get_exec_pars().group + "/On-crest VS-phase" , ph_crest )
save_dataset (get_exec_pars().group + "/VS-phase offset" , phase_offset )
save_dataset (get_exec_pars().group + "/Amplitude scale" , amplitude_scale )
save_dataset (get_exec_pars().group + "/Power scale" , power_scale )
set_attribute(get_exec_pars().group + "/Energy" , "Unit", "MeV" )
set_attribute(get_exec_pars().group + "/Energy gain" , "Unit", "MeV" )
set_attribute(get_exec_pars().group + "/On-crest VS-phase" , "Unit", "deg" )
set_attribute(get_exec_pars().group + "/VS-phase offset" , "Unit", "deg" )
set_attribute(get_exec_pars().group + "/Amplitude scale" , "Unit", "MV" )
set_attribute(get_exec_pars().group + "/Power scale" , "Unit", "MW/MV^2" )
set_attribute(get_exec_pars().group + "/Phase" , "Unit", "deg" )
set_attribute(get_exec_pars().group + "/BPM-X averager" , "Unit", "mm" )
save_dataset ("experiment/Station" , station )
save_dataset ("scan 1/processed/Energy" , energy )
save_dataset ("scan 1/processed/Energy gain" , fit_amplitude )
save_dataset ("scan 1/processed/On-crest VS-phase" , ph_crest )
save_dataset ("scan 1/processed/VS-phase offset" , phase_offset )
save_dataset ("scan 1/processed/Amplitude scale" , amplitude_scale )
save_dataset ("scan 1/processed/Power scale" , power_scale )
set_attribute("scan 1/processed/Energy" , "Unit", "MeV" )
set_attribute("scan 1/processed/Energy gain" , "Unit", "MeV" )
set_attribute("scan 1/processed/On-crest VS-phase" , "Unit", "deg" )
set_attribute("scan 1/processed/VS-phase offset" , "Unit", "deg" )
set_attribute("scan 1/processed/Amplitude scale" , "Unit", "MV" )
set_attribute("scan 1/processed/Power scale" , "Unit", "MW/MV^2" )
#Elog entry
if do_elog:

35
script/Scan.py Normal file
View File

@@ -0,0 +1,35 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Current", "S20SY02-MKDC050:I-SET")
S1 = ChannelDouble("x1", "S20SY02-DBPM080:X1")
S2 = ChannelDouble("y1", "S20SY02-DBPM080:Y1")
A1.initialize()
S1.initialize()
S2.initialize()
A1_init = A1.read()
A1i = -2.0
A1f = 2.0
nstep = 21
lat = 0.21
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, lat)
S2_averager = create_averager(S2, nav, lat)
S2_averager.monitored=True
time.sleep(10.0)
r = lscan(A1, (S1_averager, S2_averager), A1i, A1f, nstep, latency=5.0, 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()

35
script/Scan2.py Normal file
View File

@@ -0,0 +1,35 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("delay", "S20SY02-MKAC020:TCS-Pul0-TDELAY-K")
S1 = ChannelDouble("x1", "S20SY02-DBPM080:X1")
S2 = ChannelDouble("y1", "S20SY02-DBPM080:Y1")
A1.initialize()
S1.initialize()
S2.initialize()
A1_init = A1.read()
A1i = 489.837
A1f = 409.837
step = 2.2408963585434175
lat = 0.21
nav = 5
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, lat)
S2_averager = create_averager(S2, nav, lat)
S2_averager.monitored=True
time.sleep(1.0)
r = lscan(A1, (S1_averager, S2_averager), A1i, A1f, step, latency=0.5, 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()

View File

@@ -5,9 +5,9 @@ import ch.psi.pshell.imaging.Colormap as Colormap
if get_exec_pars().source == CommandSource.ui:
camera_name = "SARBD02-DSCR050" # "SLG-LCAM-C041_sp"
#camera_name = "SARBD02-DSCR050" # "SLG-LCAM-C041_sp"
#camera_name = "SARBD02-DSCR050_sp" # "SLG-LCAM-C041_sp"
#camera_name = "simulation_sp" # "SLG-LCAM-C041_sp"
camera_name = "simulation_sp" # "SLG-LCAM-C041_sp"
shared = False
images = 1
interval = -1

View File

@@ -0,0 +1,29 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Actuator1", "SARUN07-UIND030:I-SET")
#S1 = ChannelDouble("Sensor1", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
S1 = ChannelDouble("Sensor1", "SARFE10-PBPG050:HAMP-INTENSITY-CAL")
A1.initialize()
S1.initialize()
A1_init = A1.read()
A1i = -1.0
A1f = 1.2
nstep = 22
lat = 0.11
nav = 50
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, lat)
time.sleep(1.0)
r = lscan(A1, S1_averager, A1i, A1f, nstep, latency=2.0, 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()

View File

@@ -0,0 +1,35 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Current", "SARUN15-UIND030:I-SET")
S1 = ChannelDouble("energy per pulse", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
S2 = ChannelDouble("HAMP", "SARFE10-PBPG050:HAMP-INTENSITY-CAL")
A1.initialize()
S1.initialize()
S2.initialize()
A1_init = A1.read()
A1i = -0.5
A1f = 1.5
nstep = 20
lat = 0.11
nav = 50
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, lat)
S2_averager = create_averager(S2, nav, lat)
S2_averager.monitored=True
time.sleep(10.0)
r = lscan(A1, (S1_averager, S2_averager), A1i, A1f, nstep, latency=5.0, 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()

View File

@@ -0,0 +1,44 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Gap", "SARUN03-UPHS060:GAP")
A1 = ChannelDouble("Gap", "SARUN03-UPHS060:GAP")
S1 = ChannelDouble("energy per pulse", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
S2 = ChannelDouble("HAMP", "SARFE10-PBPG050:HAMP-INTENSITY-CAL")
A1.initialize()
S1.initialize()
S2.initialize()
A1_init = A1.read()
A1i = -0.5
A1f = 1.5
nstep = 20
lat = 0.11
nav = 50
plt = plot(None, title="Output")[0]
plt.clear()
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Sensor1", Color.red))
def before(position, scan):
caput(GAP + ":GO", 1)
start = time.time()
while abs(readout.read() - GAP.read()) > TOLERANCE:
time.sleep(0.1)
if time.time() - start > TIMEOUT:
raise Exception ("Timeout waiting gap change")
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)
S2_averager.monitored=True
time.sleep(10.0)
r = lscan(A1, (S1_averager, S2_averager), A1i, A1f, nstep, latency=5.0, 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()

View File

@@ -0,0 +1,16 @@
Eph1 = 2.165# actual photon energy
Eph2 = 2.185 # desired photon energy
# beam on-delay during change!
undlist = ("SARUN03","SARUN04","SARUN05","SARUN06","SARUN07","SARUN08","SARUN09","SARUN10","SARUN11","SARUN12","SARUN13","SARUN14","SARUN15")
for und in undlist:
K1 = caget(und + "-UIND030:K_SET")
K2 = ((Eph1 / Eph2 * (K1**2 + 2) - 2))**0.5
print K1,K2
caput(und + "-UIND030:K_SET", 0.07)
time.sleep(10.0)
caput(und + "-UIND030:K_SET", K2)
print "finished"

View File

@@ -0,0 +1,31 @@
Eph1 = 2.165 # actual photon energy
Eph2 = 2.185 # desired photon energy
do_elog = False
undlist = ("SARUN03","SARUN04","SARUN05","SARUN06","SARUN07","SARUN08","SARUN09","SARUN10","SARUN11","SARUN12","SARUN13","SARUN14","SARUN15")
K1, K2 = {}, {}
for und in undlist:
K = caget(und + "-UIND030:K_SET")
K1[und] = K
K2[und] = ((Eph1 / Eph2 * (K**2 + 2) - 2))**0.5
# set laser on-delay
caput("SIN-TIMAST-TMA:Beam-Las-Delay-Sel",1)
caput("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC",1)
if Eph2 < Eph1 :
for und in undlist: caput(und + "-UIND030:K_SET", 0.07)
time.sleep(40.0)
for und in undlist: caput(und + "-UIND030:K_SET", K2[und])
time.sleep(40.0)
# set laser on-beam
caput("SIN-TIMAST-TMA:Beam-Las-Delay-Sel",0)
caput("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC",1)
#Elog entry
if do_elog:
title = "Wavelength change"
log_msg = "Old photon energy: %0.2f" % Eph1 + " kev\n"
log_msg = log_msg + "New photon energy: %0.2f" % Eph2 + " keV\n"
attachments = none
elog(title, log_msg, attachments)

View File

@@ -8,11 +8,22 @@ from mathutils import PolynomialFunction, Gaussian, HarmonicOscillator
import java.awt.Color as Color
###################################################################################################
# Layout setup
###################################################################################################
import ch.psi.pshell.data.LayoutSF as LayoutSF
LayoutSF.setExperimentArguments([charge, laser, rep_rate, destination_B1, energy_B1])
###################################################################################################
# Machine utilities
###################################################################################################
LASER_SETTLING_TIME = 3.0
def laser_on():
@@ -58,7 +69,12 @@ def is_timing_ok():
def get_repetition_rate():
return caget("SIN-TIMAST-TMA:Evt-15-Freq-I")
def ws_status():
"""
Display status of all wire scanners
"""
run("Diagnostics/WireScannersStatus")
###################################################################################################
# Maths utilities

View File

@@ -0,0 +1,99 @@
import mathutils
from mathutils import *
from plotutils import *
#f = "2018/03/12/20180312_231754_WireScan.h5|"
#f = "2018/03/12/20180312_233008_WireScan.h5|"
f = "2018/03/12/20180312_234230_WireScan.h5|"
#p = f + "/x_000"
p = f + "/y_000"
def gd(i):
global p
return load_data(p+str(i)+"/blm1")
def gt(i):
global p
return load_data(p+str(i)+"/Time")
def gp(i):
global p
return load_data(p+str(i)+"/w_pos")
def bg(i):
global f
return load_data(f+"/background/blm" + str(i))
def bga(blm):
global f
return get_attributes(f+"/background/blm" + str(blm))["Mean"]
def sig(i):
bg = bga(1)
ret = gd(i)
#ret = blm_remove_spikes(ret)
ret = [v-bg for v in ret]
return ret
epsilon = 1e-10
def make_monotonic(x):
for i in range(len(x)-1):
if x[i+1]<= x[i]:
x[i+1] = x[i] + epsilon
return x
x = [x1,x2,x3,x4,x5,x6]= [gp(1), gp(2), gp(3), gp(4), gp(5), gp(6)]
#plot(x, ["1", "2", "3", "4", "5", "6"], xdata = x)
s = [s1, s1, s3, s4, s5, s6] = [sig(1), sig(2), sig(3), sig(4), sig(5), sig(6)]
p=plot(s, ["1", "2", "3", "4", "5", "6"], xdata = x)
#print call_jep(MODULE, "profile_rms_stats", [to_npa(x), to_npa(y), 0, 3.5])
run("Diagnostics/sig_process_wrapper")
print "------------------ Gauss ---------------------------"
sum_mean=0.0
sum_sigma=0.0
sum_norm=0.0
mathutils.MAX_EVALUATIONS = mathutils.MAX_EVALUATIONS*10
for i in range(6):
[off, amp, com, sigma] = profile_gauss_stats(x[i], s[i], off=None, amp=None, com=None, sigma=None)
#[amp, com, sigma] = profile_gauss_stats(x[i], s[i], off=None, amp=None, com=None, sigma=None, with_offset=False)
"""
if i%2 == 0:
(amp, com, sigma) = fit_gaussian(s[i], make_monotonic(x[i]))
else :
(amp, com, sigma) = fit_gaussian(s[i][::-1], make_monotonic(x[i][::-1]))
"""
#print "Pass " , (i+1) ,": " , [off, amp, com, sigma]
sum_mean = sum_mean + com
sum_sigma = sum_sigma + sigma
sum_norm = sum_norm + amp
plot_function(p[i], Gaussian(amp, com, sigma), "Fit",x[i], show_points = False, show_lines = True, color = Color.BLUE)
ave_mean, ave_sigma = sum_mean/6, sum_sigma/6
print "Average: mean=" , ave_mean, ave_sigma
print "------------------ RMS ---------------------------"
sum_com=0.0
sum_sigma=0.0
for i in range(6):
#[rms_com, rms_sigma] = profile_rms_stats(x[i], s[i],noise_std=0, n_sigma=3.5)
[off, amp, com, sigma] = profile_gauss_stats(x[i], s[i], off=None, amp=None, com=None, sigma=None)
[rms_com, rms_sigma] = profile_rms_stats_with_estimate(x[i], s[i], com_estimate = com, window_size = sigma *3.5)
print "Pass " , (i+1) ,": " , [rms_com, rms_sigma]
sum_com = sum_com+ rms_com
sum_sigma = sum_sigma + rms_sigma
print "Average: mean=" , sum_com/6, " sigma=", sum_sigma/6

View File

@@ -1,172 +0,0 @@
import ch.psi.pshell.epics.Positioner as Positioner
from mathutils import PolynomialFunction
dry_run = True
do_elog = True
is_panel = get_exec_pars().source != CommandSource.ui #must be check before run
def quadfit(xdata, ydata):
"""
Quadratic fit
"""
p = (a0, a1, a2) = fit_polynomial(ydata, xdata, 2)
f = PolynomialFunction(p)
if a1 != 0:
x_ext = -a1 / (2 * a0)
y_ext = f.value(x_ext)
else:
x_ext = None
y_ext = None
yhat = [f.value(val) for val in xdata]
ybar = sum(ydata)/len(ydata)
ssreg = sum([(val - ybar)**2 for val in yhat])
sstot = sum([(val - ybar)**2 for val in ydata])
R2 = ssreg / sstot
x1 = min(xdata)
x2 = max(xdata)
x_fit = frange(x1, x2, (x2-x1)/100, True)
y_fit = [f.value(val) for val in x_fit]
return (p, x_ext, y_ext, R2, x_fit, y_fit)
#Parameters
if is_panel:
start = args[0]
stop = args[1]
step = args[2]
nb = int(args[3])
lat = args[4]
disp = args[5]
p0 = args[6]
plt = args[7]
else:
start = 44.0
stop = 65.0
step = 1.0
nb = 3
lat = 0.3
disp = -0.387
p0 = 7.1
plt = plot(None, title="Output")[0]
A = p0 / disp / 1e6
B = p0
#Plot setup
plt.clear()
plt.removeMarker(None)
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Momentum", Color.red))
plt.addSeries(LinePlotErrorSeries("Momentum Spread", Color.yellow, 2))
plt.getAxis(plt.AxisId.X).setLabel("Gun Beam Phase (deg)")
plt.getAxis(plt.AxisId.Y).setLabel("Momentum (MeV/c)")
plt.getAxis(plt.AxisId.Y2).setLabel("Momentum Spread (MeV/c)")
plt.setLegendVisible(True)
#Creating Phase positioner
if dry_run:
phase = Positioner("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE-SIM", "SINEG01-RSYS:SET-BEAM-PHASE-SIM")
camera_name = "simulation"
else:
phase = Positioner("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:GET-BEAM-PHASE")
camera_name = "SINBD01-DSCR010"
phase.config.minValue = -360.0
phase.config.maxValue = 360.0
phase.config.precision = 3
phase.config.resolution = 0.1
phase.config.rotation = False
phase.config.save()
phase.initialize()
phase0 = phase.read()
#Camera setup
cam_server.start(camera_name)
wait_cam_server_message()
x = cam_server.stream.getChild("x_fit_mean")
dx = cam_server.stream.getChild("x_fit_standard_deviation")
#Creating averagers
x_averager = create_averager(x, nb, -1) # -1 event based, waits for the next value
dx_averager = create_averager(dx, nb, -1)
dx_averager.monitored = True # not blocking, will return last nb values
#Record callback: uptate of output plot
def after_sample(record, scan):
global A, B, plt
x_pos_mean, x_pos_stdev = record.values[0].mean, record.values[0].stdev
x_width_mean, x_width_stdev = record.values[1].mean, record.values[1].stdev
p_mean, p_stdev = A * x_pos_mean + B, abs(A) * x_pos_stdev
dp_mean, dp_stdev = abs(A) * x_width_mean, abs(A) * x_width_stdev
plt.getSeries(0).appendData(record.positions[0], p_mean, p_stdev)
plt.getSeries(1).appendData(record.positions[0], dp_mean, dp_stdev)
#The scan loop
try:
phase.write(start)
time.sleep(2.0)
r = lscan(phase, [x_averager, dx_averager], start, stop, step , latency=lat, after_read = after_sample)
finally:
phase.write(phase0)
phase.close()
cam_server.stop() # stops cam_server but does not close it cam_server is a global object
ph = r.getPositions(0)
p = [A * val.mean + B for val in r.getReadable(0)]
dp = [abs(A) * val.mean for val in r.getReadable(1)]
#Fitting and plotting
try:
i_max = p.index(max(p))
i_min = dp.index(min(dp))
a,b = max(i_max-5, 0), min(i_max+6, len(p))
Xdat = ph[a:b]
Ydat = p[a:b]
(p_poly, ph_p_max, p_max, p_R2, ph_p_fit, p_fit) = quadfit(Xdat, Ydat)
a,b = max(i_min-5, 0), min(i_min+6, len(dp))
Xdat = ph[a:b]
Ydat = dp[a:b]
(dp_poly, ph_dp_min, dp_min, dp_R2, ph_dp_fit, dp_fit) = quadfit(Xdat, Ydat)
plt.addSeries(LinePlotErrorSeries("Momentum Fit", plt.getSeries(0).color))
plt.addSeries(LinePlotErrorSeries("Momentum Spread Fit", plt.getSeries(1).color, 2))
plt.getSeries(2).setData(ph_p_fit, p_fit)
plt.getSeries(3).setData(ph_dp_fit, dp_fit)
plt.getSeries(2).setPointsVisible(False)
plt.getSeries(3).setPointsVisible(False)
plt.addMarker(ph_p_max, plt.AxisId.X, "%3.2f" % ph_p_max, plt.getSeries(0).color)
plt.addMarker(ph_dp_min, plt.AxisId.X, "%3.2f" % ph_dp_min, plt.getSeries(1).color)
except:
raise Exception("Fit failure")
#Setting the return value
set_return([ph_dp_min])
#Saving metadata
save_dataset(get_exec_pars().group + "/p", p)
set_attribute(get_exec_pars().group + "/p", "p max", p_max)
set_attribute(get_exec_pars().group + "/p", "p max phase", ph_p_max)
set_attribute(get_exec_pars().group + "/p", "p fit R2", p_R2)
save_dataset(get_exec_pars().group + "/dp", dp)
set_attribute(get_exec_pars().group + "/dp", "dp min", dp_min)
set_attribute(get_exec_pars().group + "/dp", "dp min phase", ph_dp_min)
set_attribute(get_exec_pars().group + "/dp", "dp fit R2", dp_R2)
#Elog entry
if do_elog:
if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes":
Laser = str(caget("SLGTV-LMTO-M055:MOT-KNOWN-POS"))
log_msg = "Data file: " + get_exec_pars().path + "\n\n"
log_msg = log_msg + "Laser: " + Laser + "\n"
if Laser == "Alcor":
log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGTH01-LMRM-M074:MOT.RBV") + " deg \n"
else:
log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGJG-LMRM-M031:MOT.RBV") + " deg \n"
if caget("SLGTV-LMTO-M053:MOT-ACT-POS") == "IRIS":
log_msg = log_msg + "Collimator: IRIS %0.2f" % caget("SLGTV-LAPP:SIZE-GET") + " mm \n"
else:
log_msg = log_msg + "Collimator: " + str(caget("SLGTV-LMTO-M053:MOT-ACT-POS")) + "\n"
log_msg = log_msg + "Charge: %0.2f" % caget("SINEG01-DICT215:B1_CHARGE-OP") + " pC at %0.2f" % phase0 + " deg beam phase\n"
log_msg = log_msg + "p-max: %0.2f" % p_max + " MeV/c at %0.2f" % ph_p_max + " deg beam phase\n"
log_msg = log_msg + "dp-min: %0.2f" % dp_min + " MeV/c at %0.2f" % ph_dp_min + " deg beam phase\n"
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
file_name = os.path.abspath(get_context().setup.getContextPath() + "/GunEnergyScanPlot.png")
plt.saveSnapshot(file_name , "png")
elog("Gun Energy Scan", log_msg, [file_name,])

View File

@@ -1,140 +0,0 @@
import ch.psi.pshell.epics.Positioner as Positioner
import ch.psi.pshell.epics.Camtool as Camtool
dry_run = False
do_elog = True
is_panel = get_exec_pars().source != CommandSource.ui #must be check before run
run("CPython/wrapper")
#Parameters
if is_panel:
start = args[0]
stop = args[1]
step = args[2]
nb = int(args[3])
lat = args[4]
disp = args[5]
p0 = args[6]
plt = args[7]
else:
start = 44.0
stop = 65.0
step = 1.0
nb = 3
lat = 0.3
disp = -0.387
p0 = 7.1
plt = plot(None, title="Output")[0]
A = p0 / disp / 1e6
B = p0
#Plot setup
plt.clear()
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Momentum"))
plt.addSeries(LinePlotErrorSeries("Momentum Spread", None, 2))
plt.getAxis(plt.AxisId.X).setLabel("Gun Beam Phase (deg)")
plt.getAxis(plt.AxisId.Y).setLabel("Momentum (MeV/c)")
plt.getAxis(plt.AxisId.Y2).setLabel("Momentum Spread (MeV/c)")
plt.setLegendVisible(True)
#Creating Phase positioner
if dry_run:
phase = Positioner("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE-SIM", "SINEG01-RSYS:SET-BEAM-PHASE-SIM")
camera_name = "simulation"
else:
phase = Positioner("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:GET-BEAM-PHASE")
camera_name = "SINBD01-DSCR010"
phase.config.minValue = -360.0
phase.config.maxValue = 360.0
phase.config.precision = 3
phase.config.resolution = 0.1
phase.config.rotation = False
phase.config.save()
phase.initialize()
phase0 = phase.read()
#Camera setup
cam_server.start(camera_name)
wait_cam_server_message()
x = cam_server.stream.getChild("x_fit_mean")
dx = cam_server.stream.getChild("x_fit_standard_deviation")
#Creating averagers
x_averager = create_averager(x, nb, -1) # -1 event based, waits for the next value
dx_averager = create_averager(dx, nb, -1)
dx_averager.monitored = True # not blocking, will return last nb values
#Record callback: uptate of output plot
def after_sample(record, scan):
global A, B, plt
x_pos_mean, x_pos_stdev = record.values[0].mean, record.values[0].stdev
x_width_mean, x_width_stdev = record.values[1].mean, record.values[1].stdev
p_mean, p_stdev = A * x_pos_mean + B, abs(A) * x_pos_stdev
dp_mean, dp_stdev = abs(A) * x_width_mean, abs(A) * x_width_stdev
plt.getSeries(0).appendData(record.positions[0], p_mean, p_stdev)
plt.getSeries(1).appendData(record.positions[0], dp_mean, dp_stdev)
#The scan loop
try:
phase.write(start)
time.sleep(1.0)
r = lscan(phase, [x_averager, dx_averager], start, stop, step , latency=lat, after_read = after_sample)
finally:
phase.write(phase0)
phase.close()
cam_server.stop() # stops cam_server but does not close it cam_server is a global object
ph = r.getPositions(0)
p = [A * val.mean + B for val in r.getReadable(0)]
dp = [abs(A) * val.mean for val in r.getReadable(1)]
#Fitting and plotting
try:
i_max = p.index(max(p))
i_min = dp.index(min(dp))
min_i, max_i = max(i_max-5, 0), min(i_max+6, len(p))
(ph_p_max, p_max, ph_p_fit, p_fit) = extremum(ph[min_i:max_i], p[min_i:max_i])
min_i, max_i = max(i_min-5, 0), min(i_min+6, len(dp))
(ph_dp_min, dp_min, ph_dp_fit, dp_fit) = extremum(ph[min_i:max_i], dp[min_i:max_i])
plt.addSeries(LinePlotErrorSeries("Momentum Fit", plt.getSeries(0).color))
plt.addSeries(LinePlotErrorSeries("Momentum Spread Fit", plt.getSeries(1).color, 2))
plt.getSeries(2).setData(ph_p_fit, p_fit)
plt.getSeries(3).setData(ph_dp_fit, dp_fit)
plt.getSeries(2).setPointsVisible(False)
plt.getSeries(3).setPointsVisible(False)
plt.addMarker(ph_p_max, plt.AxisId.X, "%3.2f" % ph_p_max, plt.getSeries(0).color)
plt.addMarker(ph_dp_min, plt.AxisId.X, "%3.2f" % ph_dp_min, plt.getSeries(1).color)
except:
raise Exception("Fit failure")
#Saving metadata
save_dataset(get_exec_pars().group + "/p", p)
set_attribute(get_exec_pars().group + "/p", "ph_p_max", ph_p_max)
set_attribute(get_exec_pars().group + "/p", "p_max", p_max)
save_dataset(get_exec_pars().group + "/dp", dp)
set_attribute(get_exec_pars().group + "/dp", "ph_dp_min", ph_dp_min)
set_attribute(get_exec_pars().group + "/dp", "dp_min", dp_min)
#Elog entry
if do_elog:
if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes":
Laser = str(caget("SLGTV-LMTO-M055:MOT-KNOWN-POS"))
log_msg = "Data file: " + get_exec_pars().path + "\n\n"
log_msg = log_msg + "Laser: " + Laser + "\n"
if Laser == "Alcor":
log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGTH01-LMRM-M074:MOT.RBV") + " deg \n"
else:
log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGJG-LMRM-M031:MOT.RBV") + " deg \n"
if caget("SLGTV-LMTO-M053:MOT-ACT-POS") == "IRIS":
log_msg = log_msg + "Collimator: IRIS %0.2f" % caget("SLGTV-LAPP:SIZE-GET") + " mm \n"
else:
log_msg = log_msg + "Collimator: " + str(caget("SLGTV-LMTO-M053:MOT-ACT-POS")) + "\n"
log_msg = log_msg + "Charge: %0.2f" % caget("SINEG01-DICT215:B1_CHARGE-OP") + " pC at %0.2f" % phase0 + " deg beam phase\n"
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
file_name = os.path.abspath(get_context().setup.getContextPath() + "/GunEnergyScanPlot.png")
plt.saveSnapshot(file_name , "png")
elog("Gun Energy Scan", log_msg, [file_name,])

View File

@@ -0,0 +1,21 @@
SAMPLES = 20
TOLERANCE = 0.01
TIMEOUT = 10.0
intensity = ChannelDouble("intensity", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
intensity.initialize()
gap = Channel(GAP + ":GAP_SP", alias = "gap")
readout = Channel(GAP + ":GAP")
av = create_averager(intensity, SAMPLES, interval = -1, name = None)
def before(position, scan):
caput(GAP + ":GO", 1)
start = time.time()
while abs(readout.read() - gap.read()) > TOLERANCE:
time.sleep(0.1)
if time.time() - start > TIMEOUT:
raise Exception ("Timeout waiting gap change")
ret = lscan (gap, av, 17.5, 19.5, 40, latency=10.0, before_read=before)

1
script/test/Test2D.py Normal file
View File

@@ -0,0 +1 @@
ascan([Test, 'ca://SWISSFEL-STYLE-GUIDE:AMPLITUDE-SIN'], ['ca://SWISSFEL-STYLE-GUIDE:SIGNAL1?monitored=true&samples=4&interval=-1', 'ca://SWISSFEL-STYLE-GUIDE:SIGNAL2?monitored=true'], [0.0, 10.0], [4.0, 20.0], [1, 1.0], latency=0.5, relative=False, passes=1, zigzag=True, name='Test2DScan2', layout='sf')

View File

@@ -0,0 +1 @@
[ "Multidimensional", [ [ "Channel", " SWISSFEL-STYLE-GUIDE:AMPLITUDE-SIN", 12.0, 14.0, 1.0 ], [ "Channel", "SWISSFEL-STYLE-GUIDE:SET-PRESSURE", 0.09, 0.1, 0.001 ] ], [ [ "CamServer", "http://sf-daqsync-01:8889/SARBD02-DSCR050_sp1?channel=gr_intensity", 3, -1.0, "Enabled" ], [ "CamServer", "http://sf-daqsync-01:8889/SARBD02-DSCR050_sp1?channel=intensity", 1, 0, "Enabled" ], [ "CamServer", "http://sf-daqsync-01:8889/SARBD02-DSCR050_sp1?channel=y_profile", 1, -1.0, "Line" ] ], false, [ ], "", 10, 0.0, 0.2, false, false, true, true, "TestScanEditor", "", "SF", " ", 0, null, null, "Positioner", false ]

View File

@@ -0,0 +1 @@
[ "Multidimensional", [ [ "Device", "Test", 0.0, 4.0, 1 ], [ "Channel", "SWISSFEL-STYLE-GUIDE:AMPLITUDE-SIN", 10.0, 20.0, 1.0 ] ], [ [ "Channel", "SWISSFEL-STYLE-GUIDE:SIGNAL1?monitored=true", 4, -1.0, "Enabled" ], [ "Channel", "SWISSFEL-STYLE-GUIDE:SIGNAL2?monitored=true", 1, 0, "Enabled" ] ], false, [ ], "", 1, 1.0, 0.5, false, true, true, true, "", "", "SF", " ", 0, null, null, "Sensor 2", false ]

View File

@@ -0,0 +1 @@
[ "Change event series", [ ], [ [ "Channel", "SINEG01-RSYS:GET-BEAM-PHASE?monitored=true", 5, -1.0, "Enabled" ] ], false, [ ], "", 10, 0.0, 0.0, false, false, true, true, "", "", "Default", "h5", 0, null, null, "Positioner", false ]

View File

@@ -0,0 +1,10 @@
import ch.psi.pshell.epics.ChannelDoubleArray as ChannelDoubleArray
d = ChannelDoubleArray("test", "SINLH02-DBLM230:LOSS_SIGNAL_RAW", -1, False)
add_device(d,True)
print len(test.read())

View File

@@ -0,0 +1 @@
[ "Change event series", [ ], [ [ "Channel", "SINLH02-DBLM230:LOSS_SIGNAL_RAW?monitored=True", 2, -1.0, "Enabled" ] ], true, [ ], "", 10, 0.0, 0.5, false, true, true, true, "", "", "SF", "", 0, null, null, "Time", false ]

View File

@@ -0,0 +1 @@
[ "Change event series", [ ], [ [ "Channel", "SWISSFEL-STYLE-GUIDE:SIGNAL2?monitored=true", 1, -1.0, "Enabled" ], [ "Channel", "SWISSFEL-STYLE-GUIDE:SIGNAL1", 1, 0, "Enabled" ] ], false, [ ], "", 10, 0.0, 0.5, false, true, false, true, "", "", "SF", "", 0, null, null, "Positioner", false ]

19
script/test/TestyArrOp.py Normal file
View File

@@ -0,0 +1,19 @@
def create_device(url, parent=None):
"""Create a device form a definition string(see URLDevice)
Args:
url(str or list of string): the device definition string (or list of strings)
parent(bool, optional): parent device
Returns:
The created device (or list of devices)
"""
return ch.psi.pshell.core.UrlDevice.create(url, parent)
devices = create_device(["ca://SINDI02-DBLM025:LOSS_SIGNAL_RAW?monitored=true&op=sum" ]) #SINDI02-DBLM025:LOSS_SIGNAL_RAW
try:
mscan([], devices , 10, -1, persist=False) #ar is ony updated on read
#tscan( devices , 5, 0.1)
finally:
devices[0].parent.close()

View File

@@ -0,0 +1,58 @@
#ws = "SARUN20-DWSC010"
#ws = "SINDI01-DWSC090"
#ws = "SARMA02-DWSC060"
#ws = "S10DI01-DWSC010"
ws = "SARMA02-DWSC060"
print caget(ws + ":VALID")
print "COM:" , caget(ws + ":B1_X_CENTER_OF_MASS")
print "RMS:" , caget(ws + ":B1_X_RMS")
print "AMP:" , caget(ws + ":B1_X_FIT_AMPLITUDE")
print "MEAN:" , caget(ws + ":B1_X_FIT_MEAN")
print "OFF:" , caget(ws + ":B1_X_FIT_OFFSET")
print "SIGMA:" , caget(ws + ":B1_X_FIT_STANDARD_DEVIATION")
plot([caget(ws + ":B1_X_AMPLITUDE"), caget(ws + ":B1_X_FIT_GAUSS_FUNCTION")], ["data", "fit"], xdata = caget(ws + ":B1_X_POSITION"))
"""
print caget(ws + ":B1_Y_CENTER_OF_MASS")
print caget(ws + ":B1_Y_RMS")
print caget(ws + ":B1_Y_FIT_AMPLITUDE")
print caget(ws + ":B1_Y_FIT_MEAN")
print caget(ws + ":B1_Y_FIT_OFFSET")
print caget(ws + ":B1_Y_FIT_STANDARD_DEVIATION")
print len(caget(ws + ":B1_Y_POSITION"))
print len(caget(ws + ":B1_Y_AMPLITUDE"))
print caget(ws + ":B2_X_CENTER_OF_MASS")
print caget(ws + ":B2_X_RMS")
print caget(ws + ":B2_X_FIT_AMPLITUDE")
print caget(ws + ":B2_X_FIT_MEAN")
print caget(ws + ":B2_X_FIT_OFFSET")
print caget(ws + ":B2_X_FIT_STANDARD_DEVIATION")
print len(caget(ws + ":B2_X_POSITION"))
print len(caget(ws + ":B2_X_AMPLITUDE"))
print caget(ws + ":B2_Y_CENTER_OF_MASS")
print caget(ws + ":B2_Y_RMS")
print caget(ws + ":B2_Y_FIT_AMPLITUDE")
print caget(ws + ":B2_Y_FIT_MEAN")
print caget(ws + ":B2_Y_FIT_OFFSET")
print caget(ws + ":B2_Y_FIT_STANDARD_DEVIATION")
print len(caget(ws + ":B2_Y_POSITION"))
print len(caget(ws + ":B2_Y_AMPLITUDE"))
"""
#print len(caget(ws + ":B1_X_FIT_GAUSS_FUNCTION"))
#print len(caget(ws + ":B1_Y_FIT_GAUSS_FUNCTION"))
#print len(caget(ws + ":B2_X_FIT_GAUSS_FUNCTION"))
#print len(caget(ws + ":B2_Y_FIT_GAUSS_FUNCTION"))

View File

@@ -0,0 +1,20 @@
run("Devices/WireScanner")
#ws = "SARUN20-DWSC010"
ws = "S10DI01-DWSC010"
dev = WireScanInfo("wscn", ws)
print dev.is_valid()
dev.set_out_com(1,'x',1)
dev.set_out_rms(1,'x',2)
dev.set_out_amp(1,'x',3)
dev.set_out_mean(1,'x',4)
dev.set_out_off(1,'x',5)
dev.set_out_sigma(1,'x',6)
dev.set_out_pos(1,'x',[1,2,3])
dev.set_out_samples(1,'x',[4,5,6])
dev.set_out_gauss(1,'x',[7,8,9])

View File

@@ -1,149 +0,0 @@
import ch.psi.pshell.epics.Positioner as Positioner
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
dry_run = True
do_elog = False
is_panel = get_exec_pars().source != CommandSource.ui
if is_panel:
station = args[0]
bpm_ch = args[1]
else:
station = "STEST01"
bpm_ch = "SINBC02-DBPM140"
start = caget(station + "-RSYS:SET-SCAN-START")
stop = caget(station + "-RSYS:SET-SCAN-STOP")
step = caget(station + "-RSYS:SET-SCAN-STEP")
lat = caget(station + "-RSYS:SET-SCAN-WAIT-TIME")
nb = caget(station + "-RSYS:SET-NUM-AVERAGE")
disp = caget(bpm_ch + ":DISPERSION-OP")
def mbnd(bpm_ch):
return {
'SINLH02-DBPM210': 'SINLH02-MBND100',
'SINLH02-DBPM240': 'SINLH02-MBND100',
'SINBC02-DBPM140': 'SINBC02-MBND100',
'SINBC02-DBPM320': 'SINBC02-MBND100',
'S10DI01-DBPM020': 'S10DI01-MBND100',
'S10BC02-DBPM140': 'S10BC02-MBND100',
'S10BC02-DBPM320': 'S10BC02-MBND100',
'SARCL02-DBPM110': 'SARCL02-MBND100',
'SARCL02-DBPM220': 'SARCL02-MBND100',
'SARCL02-DBPM260': 'SARCL02-MBND100',
'SARCL02-DBPM330': 'SARCL02-MBND100',
'SARCL02-DBPM470': 'SARCL02-MBND100'
}[bpm_ch]
p0 = caget(mbnd(bpm_ch) + ":P-READ")
energy0 = p0 - 0.511
A = energy0 / (disp * 1000)
B = energy0
phase = Positioner("Phase", station + "-RSYS:SET-VSUM-PHASE", station + "-RSYS:GET-VSUM-PHASE")
phase.config.minValue =-90.0
phase.config.maxValue = 360.0
phase.config.precision = 4
phase.config.rotation = True
phase.config.resolution = 0.1
phase.initialize()
V = ChannelDouble("Amplitude Readback", station + "-RSYS:GET-VSUM-AMPLT")
P = ChannelDouble("Power Readback", station + "-RSYS:GET-KLY-POWER")
V.initialize()
P.initialize()
if dry_run:
x = ChannelDouble("BPM-X", bpm_ch + ":X1-SIMU")
else:
x = ChannelDouble("BPM-X", bpm_ch + ":X1")
x.initialize()
phase0 = phase.read() % 360
caput(station + "-RSYS:GET-FIT-PHASE-ARRAY", to_array([0.0],'d'))
caput(station + "-RSYS:GET-FIT-ENERGY-ARRAY", to_array([0.0],'d'))
caput(station + "-RSYS:GET-ONCREST-VSUM-PHASE", float('nan'))
caput(station + "-RSYS:GET-ONCREST-VSUM-AMPLT", float('nan'))
caput(station + "-RSYS:GET-ONCREST-E-GAIN", float('nan'))
caput(station + "-RSYS:GET-ONCREST-KLY-POWER", float('nan'))
#update the plot dynamically
arr_phase,arr_energy = [],[]
def after(rec):
global A, B
arr_phase.append(rec.positions[0])
arr_energy.append(A * rec.values[0].mean + B)
caput(station + "-RSYS:GET-PHASE-ARRAY", to_array(arr_phase, 'd'))
caput(station + "-RSYS:GET-ENERGY-ARRAY", to_array(arr_energy,'d'))
#scan and plot
try:
phase.write(start)
time.sleep(1.0)
x_averager = create_averager(x, nb, lat)
r = lscan(phase, x_averager, start, stop, step, latency=lat, after_read = after)
rf_phase = r.getPositions(0)
if start < 0:
rf_phase = [((ph + 90) % 360) -90 for ph in rf_phase ]
energy = [A * val.mean + B for val in r.getReadable(0)]
caput(station + "-RSYS:GET-ENERGY-ARRAY", to_array(energy, 'd'))
caput(station + "-RSYS:GET-PHASE-ARRAY", to_array(rf_phase,'d'))
try:
run("CPython/wrapper")
(fit_amplitude, fit_phase_deg, fit_offset, ph_crest, fit_x, fit_y) = hfitoff(energy , rf_phase)
except:
raise Exception("Fit failure")
plt = plot(None,name="phase scan")[0]
if plt is not None:
plt.getSeries(0).setData(to_array(rf_phase,'d'), to_array(energy,'d'))
plt.getSeries(0).setPointSize(6)
plt.getSeries(0).setLinesVisible(False)
plt.addSeries(LinePlotSeries("fit"))
plt.getSeries(1).setData(fit_x, fit_y)
plt.getSeries(1).setPointsVisible(False)
plt.setLegendVisible(True)
ph_crest = ph_crest % 360
phase.write(ph_crest)
time.sleep(lat)
Ampl = V.read()
Power = P.read()
caput(station + "-RSYS:GET-ONCREST-VSUM-PHASE", ph_crest)
caput(station + "-RSYS:GET-ONCREST-E-GAIN", fit_amplitude)
caput(station + "-RSYS:GET-ONCREST-VSUM-AMPLT", Ampl)
caput(station + "-RSYS:GET-ONCREST-KLY-POWER", Power)
caput(station + "-RSYS:GET-FIT-PHASE-ARRAY", fit_x)
caput(station + "-RSYS:GET-FIT-ENERGY-ARRAY", fit_y)
finally:
phase.write(phase0)
phase.close()
V.close()
P.close()
x.close()
phase_corr = caget(station + "-RSYS:GET-VSUM-PHASE-OFFSET-CORR")
phase_offset = 90.0 - ph_crest - phase_corr
amplitude_scale = fit_amplitude / Ampl if Ampl != 0 else 0.0
power_scale = Power / fit_amplitude**2 if fit_amplitude != 0 else 0.0
caput(station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE-CALC", phase_offset)
caput(station + "-RSYS:SET-VSUM-AMPLT-SCALE-CALC", amplitude_scale)
caput(station + "-RSYS:SET-VOLT-POWER-SCALE-CALC", power_scale)
#Saving metadata
save_dataset (get_exec_pars().group + "/Station" , station )
save_dataset (get_exec_pars().group + "/Energy" , energy )
save_dataset (get_exec_pars().group + "/Energy gain" , fit_amplitude )
save_dataset (get_exec_pars().group + "/On-crest VS-phase" , ph_crest )
save_dataset (get_exec_pars().group + "/VS-phase offset" , phase_offset )
save_dataset (get_exec_pars().group + "/Amplitude scale" , amplitude_scale )
save_dataset (get_exec_pars().group + "/Power scale" , power_scale )
set_attribute(get_exec_pars().group + "/Energy" , "Unit", "MeV" )
set_attribute(get_exec_pars().group + "/Energy gain" , "Unit", "MeV" )
set_attribute(get_exec_pars().group + "/On-crest VS-phase" , "Unit", "deg" )
set_attribute(get_exec_pars().group + "/VS-phase offset" , "Unit", "deg" )
set_attribute(get_exec_pars().group + "/Amplitude scale" , "Unit", "MV" )
set_attribute(get_exec_pars().group + "/Power scale" , "Unit", "MW/MV^2" )
set_attribute(get_exec_pars().group + "/Phase" , "Unit", "deg" )
set_attribute(get_exec_pars().group + "/BPM-X averager" , "Unit", "mm" )
#Elog entry
if do_elog:
title = "Phase scan " + station
log_msg = "Data file: " + get_exec_pars().path + "\n"
log_msg = log_msg + "On-crest VS phase: %0.2f" % ph_crest + " deg \n"
log_msg = log_msg + "Energy gain: %0.3f" % fit_amplitude + " MeV \n"
log_msg = log_msg + "VS-phase offset: %0.2f" % phase_offset + " deg \n"
log_msg = log_msg + "Amplitude scale: %0.3f" % amplitude_scale + " MV \n"
log_msg = log_msg + "Power scale: %0.6f" % power_scale + " MW/MV^2"
attachments = get_plot_snapshots(size=(600,400))
elog(title, log_msg, attachments)

View File

@@ -1,40 +0,0 @@
do_elog = False
if get_exec_pars().source == CommandSource.ui:
station = "STEST01"
else:
station = args[0]
phase_set = caget(station + "-RSYS:PHASE-SET")
ampli_set = caget(station + "-RSYS:AMPLT-SET")
power_set = caget(station + "-RSYS:POWER-SET")
n = 0
if (phase_set == 'True'):
phase_offset = caget(station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE-CALC")
phase_offset_old = caget(station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE")
caput(station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE", phase_offset)
print phase_set
n = n + 1
if (ampli_set == 'True'):
amplitude_scale = caget(station + "-RSYS:SET-VSUM-AMPLT-SCALE-CALC")
amplitude_scale_old = caget(station + "-RSYS:SET-VSUM-AMPLT-SCALE")
caput(station + "-RSYS:SET-VSUM-AMPLT-SCALE", amplitude_scale)
print ampli_set
n = n + 1
if (power_set == 'True'):
power_scale = caget(station + "-RSYS:SET-VOLT-POWER-SCALE-CALC")
power_scale_old = caget(station + "-RSYS:SET-VOLT-POWER-SCALE")
caput(station + "-RSYS:SET-VOLT-POWER-SCALE", power_scale)
print power_set
n = n + 1
caput(station + "-RSYS:CMD-LOAD-CALIB-BEAM", 1)
if do_elog == True and n > 0:
title = "Set RF calibration:" + station
log_msg = ""
if (phase_set == 'True'): log_msg = log_msg + station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE: %0.2f" % phase_offset + " deg (was %0.2f" % phase_offset_old + " deg)\n"
if (ampli_set == 'True'): log_msg = log_msg + station + "-RSYS:SET-VSUM-AMPLT-SCALE: %0.3f" % amplitude_scale + " MV (was %0.3f" % amplitude_scale_old + " MV)\n"
if (power_set == 'True'): log_msg = log_msg + station + "-RSYS:SET-VOLT-POWER-SCALE: %0.5f" % power_scale + " MW/MV^2 (was %0.5f" % power_scale_old + " MW/MV^2)"
attachments = []
elog(title, log_msg, attachments)

View File

@@ -0,0 +1,34 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Actuator1", "SINEG01-RSYS:SET-BEAM-PHASE-SIM")
S1 = ChannelDouble("Sensor1", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
S2 = ChannelDouble("Sensor2", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-DS")
A1.initialize()
S1.initialize()
S2.initialize()
A1_init = A1.read()
A1i = -10.0
A1f = 150.0
nstep = 10
lat = 0.150
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, lat)
S2_averager = create_averager(S2, nav, lat)
S2_averager.monitored=True
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)]
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()

View File

@@ -0,0 +1,28 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Actuator1", "SARUN07-UIND030:I-SET")
S1 = ChannelDouble("Sensor1", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
A1.initialize()
S1.initialize()
A1_init = A1.read()
A1i = -1.0
A1f = 1.2
nstep = 22
lat = 0.11
nav = 50
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, lat)
time.sleep(1.0)
r = lscan(A1, S1_averager, A1i, A1f, nstep, latency=2.0, 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()

View File

@@ -1,8 +1,8 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Actuator1", "SINEG01-RSYS:SET-BEAM-PHASE-SIM")
A2 = ChannelDouble("Actuator2", "SINEG01-RSYS:SET-BEAM-PHASE-SIM")
S1 = ChannelDouble("Sensor1", "SINEG01-DICT215:B1_CHARGE-SIM")
S2 = ChannelDouble("Sensor2", "SINEG01-RSYS:SET-VSUM-PHASE-SIM")
S1 = ChannelDouble("Sensor1", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
S2 = ChannelDouble("Sensor2", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-DS")
A1.initialize()
A2.initialize()
S1.initialize()