Update psss_panel

This commit is contained in:
2026-01-08 14:17:51 +01:00
parent d14244e1d2
commit 96b4a80566
16 changed files with 1156 additions and 93 deletions

View File

@@ -39,7 +39,8 @@ allprojects {
url = "https://maven.pkg.github.com/paulscherrerinstitute/bsread_java"
}
maven { url "https://maven.scijava.org/content/repositories/adac/" }
//maven { url "https://artifacts.psi.ch/artifactory/libs-snapshots-local/" }
maven { url "https://artifacts.psi.ch/artifactory/libs-snapshots-local/" }
maven { url "https://artifacts.psi.ch/artifactory/releases/" }
maven { url "https://packages.jetbrains.team/maven/p/ij/intellij-dependencies/" }
}

View File

@@ -1,3 +1,3 @@
action.custom-1=rpm
action.custom-1.args=--configure-on-demand -w -x check -x test rpm
action.debug.args=debug --args="-b -d -l -k -g -nbcf -statusbar -size=1000x700 -console_log=SEVERE -m ./src/main/pkg -laf=dark -pipeline_server localhost:8889 -camera_server localhost:8888 -epics_config ch.psi.jcae.ContextFactory.addressList=localhost:54321"
action.debug.args=debug --args="-d -b -l -k -g -nbcf -statusbar -size=1000x700 -cl SEVERE -m ./src/main/pkg -laf dark -pipeline_server localhost:8889 -camera_server localhost:8888 -epics_config ch.psi.jcae.ContextFactory.addressList=localhost:54321"

View File

@@ -1,16 +1,16 @@
psss_fwhm_avg=ch.psi.pshell.epics.ChannelDouble|SARFE10-PSSS059:REL-E-SPREAD|||true
psss_fwhm_avg=ch.psi.pshell.epics.ChannelDouble|SARFE10-PSSS059:FIT-FWHM-RAVG|||true
dispatcher=ch.psi.pshell.bs.Dispatcher|https://dispatcher-api.psi.ch/sf|||
cam_server=ch.psi.pshell.camserver.PipelineSource|sf-daqsync-01:8889|||
energy_machine=ch.psi.pshell.epics.ChannelDouble|SARFE10-PBPG050:ENERGY|||true
cam_server=ch.psi.pshell.bs.PipelineServer|sf-daqsync-01:8889|||
energy_machine=ch.psi.pshell.epics.ProcessVariable|SARUN03-UIND030:FELPHOTENE|||true
psss_energy=ch.psi.pshell.epics.ChannelDouble|SARFE10-PSSS059:ENERGY|||true
psss_spectrum_x=ch.psi.pshell.epics.ChannelDoubleArray|SARFE10-PSSS059:SPECTRUM_X -1 -3|||true
psss_spectrum_y=ch.psi.pshell.epics.ChannelDoubleArray|SARFE10-PSSS059:SPECTRUM_Y -1 -3|||true
psss_center=ch.psi.pshell.epics.ChannelDouble|SARFE10-PSSS059:SPECTRUM_CENTER|||true
psss_fwhm=ch.psi.pshell.epics.ChannelDouble|SARFE10-PSSS059:SPECTRUM_FWHM|||true
psss_center=ch.psi.pshell.epics.ChannelDouble|SARFE10-PSSS059:FIT-COM|||true
psss_fwhm=ch.psi.pshell.epics.ChannelDouble|SARFE10-PSSS059:FIT-FWHM|||true
psss_roi_min=ch.psi.pshell.epics.ChannelInteger|SARFE10-PSSS059:SPC_ROI_YMIN|||true
psss_roi_max=ch.psi.pshell.epics.ChannelInteger|SARFE10-PSSS059:SPC_ROI_YMAX|||true
histo_center=ch.psi.pshell.device.HistogramGenerator|psss_center|||true
histo_fwhm=ch.psi.pshell.device.HistogramGenerator|psss_fwhm|||true
psss_spectrum_y_average=ch.psi.pshell.device.ArrayAverager|psss_spectrum_y|||true
psss_center_average=ch.psi.pshell.device.Averager|psss_center|||true
psss_fwhm_average=ch.psi.pshell.device.Averager|psss_fwhm|||true
psss_fwhm_average=ch.psi.pshell.device.Averager|psss_fwhm|||true

View File

@@ -1,5 +1,5 @@
#Mon Jan 17 16:00:40 CET 2022
spatialCalOffsetY=-50.02549719530852
#Wed Oct 15 10:31:07 CEST 2025
spatialCalOffsetY=-50.04306632213609
spatialCalOffsetX=-50.01953888237593
colormapLogarithmic=false
scale=1.0

View File

@@ -0,0 +1,11 @@
#Thu Jan 08 14:10:14 CET 2026
deadband=NaN
description=null
maxValue=20000.0
minValue=0.0
offset=0.0
precision=3
resolution=NaN
scale=1000.0
sign_bit=0
unit=eV

View File

@@ -1,7 +1,7 @@
#Fri Aug 22 10:56:08 CEST 2025
bins=1000
description=null
max=11200.0
min=11400.0
numberOfSamples=10000
min=11913.881786285565
max=12013.881786285565
precision=-1
description=null
numberOfSamples=10000

View File

@@ -1,7 +1,7 @@
#Fri Aug 22 10:56:08 CEST 2025
bins=1000
description=null
max=40.0
min=0.0
numberOfSamples=10000
max=40.0
precision=-1
description=null
numberOfSamples=10000

View File

@@ -2,5 +2,5 @@
description=null
integrate=false
interval=-1
measures=10
measures=100
precision=-1

View File

@@ -52,12 +52,17 @@
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<EmptySpace min="-2" pref="21" max="-2" attributes="0"/>
<Component id="jLabel18" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="3" max="-2" attributes="0"/>
<Component id="spinnerAverage" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerAverage" min="-2" max="-2" attributes="0"/>
<Component id="spinnerEnergy" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Component id="history" alignment="0" pref="453" max="32767" attributes="0"/>
<Component id="history" alignment="0" pref="466" max="32767" attributes="0"/>
<Component id="plot" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
@@ -79,6 +84,8 @@
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerAverage" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerEnergy" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel18" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
@@ -97,14 +104,21 @@
<SubComponents>
<Component class="ch.psi.pshell.plot.LinePlotJFree" name="plot">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Dialog" size="14" style="0"/>
</Property>
<Property name="title" type="java.lang.String" value=""/>
</Properties>
</Component>
<Component class="ch.psi.pshell.plot.TimePlotJFree" name="history">
<Properties>
<Property name="durationMillis" type="int" value="1800000"/>
<Property name="focusable" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Average:"/>
<Property name="text" type="java.lang.String" value="Energy:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerAverage">
@@ -127,6 +141,21 @@
<Property name="deviceName" type="java.lang.String" value="histo_fwhm"/>
</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="2000.0" maximum="13000.0" minimum="2000.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spinnerEnergyStateChanged"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel18">
<Properties>
<Property name="text" type="java.lang.String" value="Average:"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel4">
@@ -141,17 +170,18 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="843" max="32767" attributes="0"/>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Component id="renderer" alignment="0" pref="843" max="32767" attributes="0"/>
</Group>
<Component id="jPanel7" max="32767" attributes="0"/>
<Component id="renderer" pref="856" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="432" max="32767" attributes="0"/>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Component id="renderer" alignment="0" pref="432" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="renderer" pref="359" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jPanel7" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -159,6 +189,62 @@
<SubComponents>
<Component class="ch.psi.pshell.imaging.Renderer" name="renderer">
</Component>
<Container class="javax.swing.JPanel" name="jPanel7">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel16" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="registerPanel2" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
<Component id="jLabel17" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="registerPanel3" min="-2" max="-2" attributes="0"/>
<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="2" attributes="0">
<Component id="jLabel16" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="registerPanel2" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="jLabel17" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="registerPanel3" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="ch.psi.pshell.swing.RegisterPanel" name="registerPanel3">
<Properties>
<Property name="deviceName" type="java.lang.String" value="psss_roi_max"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel17">
<Properties>
<Property name="text" type="java.lang.String" value="ROI bottom:"/>
</Properties>
</Component>
<Component class="ch.psi.pshell.swing.RegisterPanel" name="registerPanel2">
<Properties>
<Property name="deviceName" type="java.lang.String" value="psss_roi_min"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel16">
<Properties>
<Property name="text" type="java.lang.String" value="ROI top:"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel3">
@@ -183,7 +269,7 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel2" max="32767" attributes="0"/>
<Component id="plotScan" pref="432" max="32767" attributes="0"/>
<Component id="plotScan" pref="450" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
@@ -200,7 +286,7 @@
<Component id="radioCrystalScan" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="radioCameraScan" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="radioEnergyScan" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="btAbort" alignment="0" pref="213" max="32767" attributes="0"/>
<Component id="btAbort" alignment="0" pref="218" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@@ -709,6 +795,383 @@
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel6">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Control">
<Property name="tabTitle" type="java.lang.String" value="Control"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jPanel8" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="595" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
<Component id="jPanel8" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="265" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel8">
<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="jLabel19" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="discretePositionerSelector2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel15" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel14" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="discretePositionerSelector1" linkSize="12" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="registerPanel1" linkSize="12" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</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="0" attributes="0">
<Component id="discretePositionerSelector1" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="8" max="-2" attributes="0"/>
<Component id="jLabel15" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="discretePositionerSelector2" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="8" max="-2" attributes="0"/>
<Component id="jLabel19" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="registerPanel1" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="jLabel14" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="ch.psi.pshell.swing.DiscretePositionerSelector" name="discretePositionerSelector2">
<Properties>
<Property name="deviceName" type="java.lang.String" value="psss_crystal"/>
</Properties>
</Component>
<Component class="ch.psi.pshell.swing.DiscretePositionerSelector" name="discretePositionerSelector1">
<Properties>
<Property name="deviceName" type="java.lang.String" value="psss_grating"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel14">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Energy:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel15">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Grating:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel19">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Crystal:"/>
</Properties>
</Component>
<Component class="ch.psi.pshell.swing.RegisterPanel" name="registerPanel1">
<Properties>
<Property name="deviceName" type="java.lang.String" value="psss_energy_set"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel9">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Correlation">
<Property name="tabTitle" type="java.lang.String" value="Correlation"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel10" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="plotCorrelation" pref="450" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel10" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="plotCorrelation" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel10">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonStart" min="-2" pref="189" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel26" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel25" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel24" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel21" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel20" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel23" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel27" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="textCorrelation" alignment="0" pref="250" max="32767" attributes="0"/>
<Component id="spinnerWindow" linkSize="13" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="textLinear" alignment="0" pref="250" max="32767" attributes="0"/>
<Component id="textQuadratic" alignment="0" pref="250" max="32767" attributes="0"/>
<Component id="checkLinear" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="checkQuadratic" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="spinnerOffset" linkSize="13" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="26" max="32767" attributes="0"/>
</Group>
<Component id="textDevX" alignment="0" max="32767" attributes="0"/>
<Component id="comboDevY" alignment="0" max="32767" attributes="0"/>
</Group>
</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="jLabel20" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textDevX" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="39" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel21" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="comboDevY" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="40" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel23" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerWindow" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel27" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerOffset" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="checkLinear" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="checkQuadratic" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="21" max="32767" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="textCorrelation" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="jLabel24" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel25" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="textLinear" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel26" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="textQuadratic" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="22" max="32767" attributes="0"/>
<Component id="buttonStart" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="45" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel20">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="X device:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textDevX">
<Properties>
<Property name="text" type="java.lang.String" value="SARFE10-PSSS059:SPECTRUM_Y_SUM"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel21">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Y device:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel23">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Window size:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerWindow">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="50" minimum="3" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonStart">
<Properties>
<Property name="text" type="java.lang.String" value="Start"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonStartActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel24">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="Correlation:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textCorrelation">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel25">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="Liner fit:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textLinear">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel26">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="Quadratric fit:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textQuadratic">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkLinear">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Linear fit"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkQuadratic">
<Properties>
<Property name="text" type="java.lang.String" value="Quadratic fit"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel27">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Pulse ID Offset:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerOffset">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" maximum="50" minimum="-50" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboDevY">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="7">
<StringItem index="0" value="SARFE10-PBPS053:INTENSITY"/>
<StringItem index="1" value="SAROP21-PBPS103:INTENSITY"/>
<StringItem index="2" value="SAROP11-PBPS110:INTENSITY"/>
<StringItem index="3" value="SAROP31-PBPS113:INTENSITY"/>
<StringItem index="4" value="SAROP11-PBPS122:INTENSITY"/>
<StringItem index="5" value="SAROP21-PBPS133:INTENSITY"/>
<StringItem index="6" value="SAROP31-PBPS149:INTENSITY"/>
</StringArray>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
<Component class="ch.psi.pshell.plot.LinePlotJFree" name="plotCorrelation">
<Properties>
<Property name="title" type="java.lang.String" value=""/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>

View File

@@ -1,7 +1,12 @@
import ch.psi.pshell.device.Device;
import ch.psi.pshell.device.DeviceListener;
import ch.psi.pshell.camserver.PipelineSource;
import ch.psi.pshell.framework.Context;
import ch.psi.pshell.framework.Panel;
import ch.psi.pshell.device.Register;
import ch.psi.pshell.epics.ChannelDouble;
import ch.psi.pshell.framework.App;
import ch.psi.pshell.framework.Setup;
import ch.psi.pshell.imaging.RendererMode;
import ch.psi.pshell.plot.Plot;
import ch.psi.pshell.plot.LinePlotJFree;
@@ -9,10 +14,12 @@ import ch.psi.pshell.utils.Convert;
import ch.psi.pshell.utils.State;
import ch.psi.pshell.utils.Str;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Font;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -25,12 +32,29 @@ public class PSSS extends Panel {
PipelineSource pipelineServer;
volatile boolean updatingPlot;
volatile boolean updatingImage;
volatile boolean updatingDevices;
Color PLOT_BACKGROUND =Color.WHITE;
final Font TICK_LABEL_FONT = new Font("Arial", 0, 14);
public PSSS() {
initComponents();
plot.getAxis(Plot.AxisId.X).setLabel(null);
plot.getAxis(Plot.AxisId.Y).setLabel(null);
if (App.getBoolAdditionalArgumentValue("pltb")){
PLOT_BACKGROUND = null;
}
renderer.setMode(RendererMode.Stretch);
plot.setPlotBackgroundColor(PLOT_BACKGROUND);
history.setPlotBackgroundColor(PLOT_BACKGROUND);
histogramGeneratorPanelCenter.getPlot().setPlotBackgroundColor(PLOT_BACKGROUND);
histogramGeneratorFwhm.getPlot().setPlotBackgroundColor(PLOT_BACKGROUND);
plot.setTickLabelFont(TICK_LABEL_FONT);
history.setTickLabelFont(TICK_LABEL_FONT);
histogramGeneratorPanelCenter.getPlot().setTickLabelFont(TICK_LABEL_FONT);
histogramGeneratorFwhm.getPlot().setTickLabelFont(TICK_LABEL_FONT);
plotCorrelation.getAxis(Plot.AxisId.X).setLabel(null);
plotCorrelation.getAxis(Plot.AxisId.Y).setLabel(null);
}
//Overridable callbacks
@@ -46,8 +70,9 @@ public class PSSS extends Panel {
pipelineServer = (PipelineSource) getDevice("cam_server");
((LinePlotJFree)histogramGeneratorPanelCenter.getPlot()).setLegendVisible(true);
((LinePlotJFree)histogramGeneratorFwhm.getPlot()).setLegendVisible(true);
histogramGeneratorPanelCenter.getPlot().getAxis(Plot.AxisId.Y).setRange(0, 100);
histogramGeneratorFwhm.getPlot().getAxis(Plot.AxisId.Y).setRange(0, 100);
//histogramGeneratorPanelCenter.getPlot().getAxis(Plot.AxisId.Y).setRange(0, 100);
//histogramGeneratorFwhm.getPlot().getAxis(Plot.AxisId.Y).setRange(0, 100);
//setImageEnabled(true);
tabStateChanged(null);
@@ -62,6 +87,19 @@ public class PSSS extends Panel {
getLogger().warning("Error reading energy_machine");
}
this.getDevice("psss_energy").addListener(new DeviceListener() {
@Override
public void onCacheChanged(Device device, Object value, Object former, long timestamp, boolean valueChange) {
updatingDevices=true;
try{
spinnerEnergy.setValue((Double) value);
} catch (Exception ex){
getLogger().log(Level.WARNING, null, ex);
} finally{
updatingDevices=false;
}
}
});
} catch (Exception ex) {
getLogger().log(Level.WARNING, null, ex);
@@ -77,6 +115,31 @@ public class PSSS extends Panel {
radioCrystalScan.setEnabled(state == State.Ready);
radioCameraScan.setEnabled(state == State.Ready);
this.btAbort.setEnabled(state.isRunning());
buttonStart.setEnabled((state==State.Ready) || (state==State.Busy));
if (isRunningCorrelation()){
if (state==State.Ready){
buttonStart.setText("Start");
}
} else {
if (state==State.Busy){
buttonStart.setText("Stop");
}
}
textDevX.setEnabled(state==State.Ready);
comboDevY.setEnabled(state==State.Ready);
spinnerWindow.setEnabled(state==State.Ready);
spinnerOffset.setEnabled(state==State.Ready);
checkLinear.setEnabled(state==State.Ready);
checkQuadratic.setEnabled(state==State.Ready);
if ((former==State.Initializing) && (state == State.Ready)){
if (Setup.getStartArg()) {
buttonStartActionPerformed(null);
}
}
}
@Override
@@ -103,6 +166,10 @@ public class PSSS extends Panel {
});
}
}
if (isRunningCorrelation()){
updateResults();
}
} catch (Exception ex) {
getLogger().log(Level.WARNING, null, ex);
}
@@ -144,6 +211,42 @@ public class PSSS extends Panel {
}
}
void updateResults(){
try{
textCorrelation.setText(String.format("%1.4f", (Double)getGlobalVar("corr")));
} catch (Exception ex){
textCorrelation.setText("");
}
if (checkLinear.isSelected()){
try{
List pars = (List)getGlobalVar("pars_lin");
//textLinear.setText(String.format("%1.3fx%+1.3f", (Double)(pars.get(1)), (Double)(pars.get(0))));
textLinear.setText(String.format("%1.6gx%+1.6g",pars.get(1), pars.get(0)));
} catch (Exception ex){
textLinear.setText("");
}
}
if (checkQuadratic.isSelected()){
try{
List pars = (List)getGlobalVar("pars_quad");
//textQuadratic.setText(String.format("%1.2fx\u00B2 %+1.2fx%+1.2f", (Double)(pars.get(0)), (Double)(pars.get(1)), (Double)(pars.get(0))));
textQuadratic.setText(String.format("%1.3gx\u00B2%+1.3gx%+1.3g", pars.get(0), pars.get(1), pars.get(0)));
//textQuadratic.setText(formatter.format(pars.get(2))+ formatter.format(pars.get(1)) + formatter.format(pars.get(0)));
} catch (Exception ex){
textQuadratic.setText("");
}
}
}
boolean isRunningCorrelation(){
return buttonStart.getText().equals("Stop");
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
@@ -157,8 +260,15 @@ public class PSSS extends Panel {
spinnerAverage = new javax.swing.JSpinner();
histogramGeneratorPanelCenter = new ch.psi.pshell.swing.HistogramGeneratorPanel();
histogramGeneratorFwhm = new ch.psi.pshell.swing.HistogramGeneratorPanel();
spinnerEnergy = new javax.swing.JSpinner();
jLabel18 = new javax.swing.JLabel();
jPanel4 = new javax.swing.JPanel();
renderer = new ch.psi.pshell.imaging.Renderer();
jPanel7 = new javax.swing.JPanel();
registerPanel3 = new ch.psi.pshell.swing.RegisterPanel();
jLabel17 = new javax.swing.JLabel();
registerPanel2 = new ch.psi.pshell.swing.RegisterPanel();
jLabel16 = new javax.swing.JLabel();
jPanel3 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
btAbort = new javax.swing.JButton();
@@ -198,6 +308,34 @@ public class PSSS extends Panel {
spShotsCr = new javax.swing.JSpinner();
btStartCr = new javax.swing.JButton();
plotScan = new ch.psi.pshell.plot.LinePlotJFree();
jPanel6 = new javax.swing.JPanel();
jPanel8 = new javax.swing.JPanel();
discretePositionerSelector2 = new ch.psi.pshell.swing.DiscretePositionerSelector();
discretePositionerSelector1 = new ch.psi.pshell.swing.DiscretePositionerSelector();
jLabel14 = new javax.swing.JLabel();
jLabel15 = new javax.swing.JLabel();
jLabel19 = new javax.swing.JLabel();
registerPanel1 = new ch.psi.pshell.swing.RegisterPanel();
jPanel9 = new javax.swing.JPanel();
jPanel10 = new javax.swing.JPanel();
jLabel20 = new javax.swing.JLabel();
textDevX = new javax.swing.JTextField();
jLabel21 = new javax.swing.JLabel();
jLabel23 = new javax.swing.JLabel();
spinnerWindow = new javax.swing.JSpinner();
buttonStart = new javax.swing.JButton();
jLabel24 = new javax.swing.JLabel();
textCorrelation = new javax.swing.JTextField();
jLabel25 = new javax.swing.JLabel();
textLinear = new javax.swing.JTextField();
jLabel26 = new javax.swing.JLabel();
textQuadratic = new javax.swing.JTextField();
checkLinear = new javax.swing.JCheckBox();
checkQuadratic = new javax.swing.JCheckBox();
jLabel27 = new javax.swing.JLabel();
spinnerOffset = new javax.swing.JSpinner();
comboDevY = new javax.swing.JComboBox<>();
plotCorrelation = new ch.psi.pshell.plot.LinePlotJFree();
tab.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
@@ -205,9 +343,13 @@ public class PSSS extends Panel {
}
});
plot.setFont(new java.awt.Font("Dialog", 0, 14)); // NOI18N
plot.setTitle("");
jLabel1.setText("Average:");
history.setDurationMillis(1800000);
history.setFocusable(false);
jLabel1.setText("Energy:");
spinnerAverage.setModel(new javax.swing.SpinnerNumberModel(1, 1, 100, 1));
spinnerAverage.addChangeListener(new javax.swing.event.ChangeListener() {
@@ -220,6 +362,15 @@ public class PSSS extends Panel {
histogramGeneratorFwhm.setDeviceName("histo_fwhm");
spinnerEnergy.setModel(new javax.swing.SpinnerNumberModel(2000.0d, 2000.0d, 13000.0d, 1.0d));
spinnerEnergy.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spinnerEnergyStateChanged(evt);
}
});
jLabel18.setText("Average:");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
@@ -227,11 +378,16 @@ public class PSSS extends Panel {
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGap(21, 21, 21)
.addComponent(jLabel18)
.addGap(3, 3, 3)
.addComponent(spinnerAverage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(26, 26, 26)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerAverage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(history, javax.swing.GroupLayout.DEFAULT_SIZE, 453, Short.MAX_VALUE)
.addComponent(spinnerEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
.addComponent(history, javax.swing.GroupLayout.DEFAULT_SIZE, 466, Short.MAX_VALUE)
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@@ -247,7 +403,9 @@ public class PSSS extends Panel {
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(spinnerAverage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(spinnerAverage, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerEnergy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel18))
.addGap(6, 6, 6)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(histogramGeneratorPanelCenter, javax.swing.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
@@ -260,19 +418,56 @@ public class PSSS extends Panel {
tab.addTab("Spectrum", jPanel1);
registerPanel3.setDeviceName("psss_roi_max");
jLabel17.setText("ROI bottom:");
registerPanel2.setDeviceName("psss_roi_min");
jLabel16.setText("ROI top:");
javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
jPanel7.setLayout(jPanel7Layout);
jPanel7Layout.setHorizontalGroup(
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel7Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel16)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(registerPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(28, 28, 28)
.addComponent(jLabel17)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(registerPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel7Layout.setVerticalGroup(
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel7Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel16)
.addComponent(registerPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel17)
.addComponent(registerPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
jPanel4.setLayout(jPanel4Layout);
jPanel4Layout.setHorizontalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 843, Short.MAX_VALUE)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 843, Short.MAX_VALUE))
.addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 856, Short.MAX_VALUE)
);
jPanel4Layout.setVerticalGroup(
jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 432, Short.MAX_VALUE)
.addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 432, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
.addContainerGap()
.addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 359, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
tab.addTab("Camera", jPanel4);
@@ -595,7 +790,7 @@ public class PSSS extends Panel {
.addComponent(radioCrystalScan)
.addComponent(radioCameraScan)
.addComponent(radioEnergyScan)
.addComponent(btAbort, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE))
.addComponent(btAbort, javax.swing.GroupLayout.DEFAULT_SIZE, 218, Short.MAX_VALUE))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
@@ -628,11 +823,241 @@ public class PSSS extends Panel {
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(plotScan, javax.swing.GroupLayout.DEFAULT_SIZE, 432, Short.MAX_VALUE)
.addComponent(plotScan, javax.swing.GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE)
);
tab.addTab("Alignment", jPanel3);
discretePositionerSelector2.setDeviceName("psss_crystal");
discretePositionerSelector1.setDeviceName("psss_grating");
jLabel14.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel14.setText("Energy:");
jLabel15.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel15.setText("Grating:");
jLabel19.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel19.setText("Crystal:");
registerPanel1.setDeviceName("psss_energy_set");
javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
jPanel8.setLayout(jPanel8Layout);
jPanel8Layout.setHorizontalGroup(
jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel8Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel8Layout.createSequentialGroup()
.addComponent(jLabel19)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(discretePositionerSelector2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel8Layout.createSequentialGroup()
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel15, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel14, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(discretePositionerSelector1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(registerPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap())
);
jPanel8Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {discretePositionerSelector1, registerPanel1});
jPanel8Layout.setVerticalGroup(
jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel8Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(discretePositionerSelector1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel8Layout.createSequentialGroup()
.addGap(8, 8, 8)
.addComponent(jLabel15)))
.addGap(18, 18, 18)
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(discretePositionerSelector2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel8Layout.createSequentialGroup()
.addGap(8, 8, 8)
.addComponent(jLabel19)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(registerPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel14))
.addContainerGap())
);
javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
jPanel6.setLayout(jPanel6Layout);
jPanel6Layout.setHorizontalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel6Layout.createSequentialGroup()
.addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 595, Short.MAX_VALUE))
);
jPanel6Layout.setVerticalGroup(
jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel6Layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(jPanel8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(265, Short.MAX_VALUE))
);
tab.addTab("Control", jPanel6);
jLabel20.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel20.setText("X device:");
textDevX.setText("SARFE10-PSSS059:SPECTRUM_Y_SUM");
jLabel21.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel21.setText("Y device:");
jLabel23.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel23.setText("Window size:");
spinnerWindow.setModel(new javax.swing.SpinnerNumberModel(50, 3, null, 1));
buttonStart.setText("Start");
buttonStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonStartActionPerformed(evt);
}
});
jLabel24.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel24.setText("Correlation:");
textCorrelation.setEditable(false);
textCorrelation.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jLabel25.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel25.setText("Liner fit:");
textLinear.setEditable(false);
textLinear.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jLabel26.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel26.setText("Quadratric fit:");
textQuadratic.setEditable(false);
textQuadratic.setHorizontalAlignment(javax.swing.JTextField.CENTER);
checkLinear.setSelected(true);
checkLinear.setText("Linear fit");
checkQuadratic.setText("Quadratic fit");
jLabel27.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel27.setText("Pulse ID Offset:");
spinnerOffset.setModel(new javax.swing.SpinnerNumberModel(0, -50, 50, 1));
comboDevY.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "SARFE10-PBPS053:INTENSITY", "SAROP21-PBPS103:INTENSITY", "SAROP11-PBPS110:INTENSITY", "SAROP31-PBPS113:INTENSITY", "SAROP11-PBPS122:INTENSITY", "SAROP21-PBPS133:INTENSITY", "SAROP31-PBPS149:INTENSITY" }));
javax.swing.GroupLayout jPanel10Layout = new javax.swing.GroupLayout(jPanel10);
jPanel10.setLayout(jPanel10Layout);
jPanel10Layout.setHorizontalGroup(
jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel10Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonStart, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel10Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel26, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel25, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel24, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel21, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel20, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel23, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel27, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel10Layout.createSequentialGroup()
.addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(textCorrelation, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(spinnerWindow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(textLinear, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(textQuadratic, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(checkLinear)
.addComponent(checkQuadratic)
.addComponent(spinnerOffset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
.addComponent(textDevX)
.addComponent(comboDevY, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
);
jPanel10Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerOffset, spinnerWindow});
jPanel10Layout.setVerticalGroup(
jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel10Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel20)
.addComponent(textDevX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(39, 39, 39)
.addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel21)
.addComponent(comboDevY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(40, 40, 40)
.addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel23)
.addComponent(spinnerWindow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel27)
.addComponent(spinnerOffset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(checkLinear)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(checkQuadratic)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
.addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(textCorrelation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel24))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel25)
.addComponent(textLinear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel10Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel26)
.addComponent(textQuadratic, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 22, Short.MAX_VALUE)
.addComponent(buttonStart)
.addGap(45, 45, 45))
);
plotCorrelation.setTitle("");
javax.swing.GroupLayout jPanel9Layout = new javax.swing.GroupLayout(jPanel9);
jPanel9.setLayout(jPanel9Layout);
jPanel9Layout.setHorizontalGroup(
jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel9Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel10, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(plotCorrelation, javax.swing.GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE))
);
jPanel9Layout.setVerticalGroup(
jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel9Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel9Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel9Layout.createSequentialGroup()
.addComponent(plotCorrelation, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())))
);
tab.addTab("Correlation", jPanel9);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
@@ -705,12 +1130,64 @@ public class PSSS extends Panel {
}
}//GEN-LAST:event_spinnerAverageStateChanged
private void spinnerEnergyStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerEnergyStateChanged
try {
if (!updatingDevices){
Register dev = (Register) getDevice("psss_energy_set");
dev.writeAsync((Double)spinnerEnergy.getValue());
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_spinnerEnergyStateChanged
private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed
try {
if (isRunningCorrelation()){
abort();
updateResults();
//buttonStart.setText("Start");
} else {
textCorrelation.setText("");
textLinear.setText("");
textQuadratic.setText("");
HashMap args = new HashMap();
args.put("dx", textDevX.getText());
args.put("dy", comboDevY.getSelectedItem());
args.put("window", spinnerWindow.getValue());
args.put("offset", spinnerOffset.getValue());
args.put("linear_fit", checkLinear.isSelected());
args.put("quadratic_fit", checkQuadratic.isSelected());
args.put("p", plotCorrelation);
runAsync("psss/Correlation", args).handle((ok, ex) -> {
if (ex != null) {
ex.printStackTrace();
}
return ok;
});
///buttonStart.setText("Stop");
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonStartActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btAbort;
private javax.swing.JButton btStartCam;
private javax.swing.JButton btStartCr;
private javax.swing.JButton btStartEn;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JButton buttonStart;
private javax.swing.JCheckBox checkLinear;
private javax.swing.JCheckBox checkQuadratic;
private javax.swing.JComboBox<String> comboDevY;
private ch.psi.pshell.swing.DiscretePositionerSelector discretePositionerSelector1;
private ch.psi.pshell.swing.DiscretePositionerSelector discretePositionerSelector2;
private ch.psi.pshell.swing.HistogramGeneratorPanel histogramGeneratorFwhm;
private ch.psi.pshell.swing.HistogramGeneratorPanel histogramGeneratorPanelCenter;
private ch.psi.pshell.plot.TimePlotJFree history;
@@ -719,7 +1196,20 @@ public class PSSS extends Panel {
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel15;
private javax.swing.JLabel jLabel16;
private javax.swing.JLabel jLabel17;
private javax.swing.JLabel jLabel18;
private javax.swing.JLabel jLabel19;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel20;
private javax.swing.JLabel jLabel21;
private javax.swing.JLabel jLabel23;
private javax.swing.JLabel jLabel24;
private javax.swing.JLabel jLabel25;
private javax.swing.JLabel jLabel26;
private javax.swing.JLabel jLabel27;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
@@ -728,19 +1218,28 @@ public class PSSS extends Panel {
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel10;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
private javax.swing.JPanel jPanel6;
private javax.swing.JPanel jPanel7;
private javax.swing.JPanel jPanel8;
private javax.swing.JPanel jPanel9;
private javax.swing.JPanel panelCameraScan;
private javax.swing.JPanel panelCrystalScan;
private javax.swing.JPanel panelEnergyScan;
private javax.swing.JPanel panelScan;
private ch.psi.pshell.plot.LinePlotJFree plot;
private ch.psi.pshell.plot.LinePlotJFree plotCorrelation;
private ch.psi.pshell.plot.LinePlotJFree plotScan;
private javax.swing.JRadioButton radioCameraScan;
private javax.swing.JRadioButton radioCrystalScan;
private javax.swing.JRadioButton radioEnergyScan;
private ch.psi.pshell.swing.RegisterPanel registerPanel1;
private ch.psi.pshell.swing.RegisterPanel registerPanel2;
private ch.psi.pshell.swing.RegisterPanel registerPanel3;
private ch.psi.pshell.imaging.Renderer renderer;
private javax.swing.JSpinner spFromCam;
private javax.swing.JSpinner spFromCr;
@@ -755,6 +1254,13 @@ public class PSSS extends Panel {
private javax.swing.JSpinner spToCr;
private javax.swing.JSpinner spToEn;
private javax.swing.JSpinner spinnerAverage;
private javax.swing.JSpinner spinnerEnergy;
private javax.swing.JSpinner spinnerOffset;
private javax.swing.JSpinner spinnerWindow;
private javax.swing.JTabbedPane tab;
private javax.swing.JTextField textCorrelation;
private javax.swing.JTextField textDevX;
private javax.swing.JTextField textLinear;
private javax.swing.JTextField textQuadratic;
// End of variables declaration//GEN-END:variables
}

View File

@@ -15,11 +15,8 @@ def fit_energy(e_from, e_to, steps, num_shots, data):
popt,pcov = curve_fit(gaus,energy_range,centre_line_out,p0=[1,energy_range[np.argmax(centre_line_out)],energy_range.mean()*1e-3,1e3*num_shots])
except:
raise Exception('Fit failed: spectrum might not be near scan range center \n' + str(sys.exc_info()[1]))
#print('Fit failed: spectrum might not be near scan range center')
#return None
max_ind = np.argmax(centre_line_out)
max_photon_energy=energy_range[max_ind]
print(max_photon_energy)
return popt, centre_line_out

View File

@@ -8,6 +8,7 @@ from mathutils import PolynomialFunction, Gaussian, HarmonicOscillator, Gaussian
from plotutils import plot_function, plot_data
import java.awt.Color as Color
from jeputils import import_py
run("psss/psss")
###################################################################################################
@@ -145,6 +146,54 @@ def plot_gauss_fit(xdata, ydata, gauss_pars=None, p=None, title = "Data"):
p.addMarker(mean_value, None, "Mean=" + str(round(mean_value,2)), Color.LIGHT_GRAY)
return p,(amp, mean_value, sigma)
###################################################################################################
# Devices
###################################################################################################
class PSSSEnergySet(RegisterBase):
def doRead(self):
return psss_energy.read()
def doWrite(self, val):
if not is_dry_run():
psss_energy.write(val)
exec_cpython("/ioc/modules/qt/PSSS_motion.py", args = ["-m1", "SARFE10-PSSS059"])
# python / ioc / modules / qt / PSSS_motion.py - m1 SARFE10 - PSSS059
time.sleep(1)
add_device(PSSSEnergySet("psss_energy_set"), True)
psss_energy_set.alias = "energy"
psss_energy_set.polling=1000
class PSSSGratingSet(DiscretePositioner):
def doWrite(self, val):
if not is_dry_run():
super(PSSSGratingSet, self).doWrite(val)
#caput(psss_grating.getSetpoint().getChannelName(), val)
#self.setCache(val)
exec_cpython("/ioc/modules/qt/PSSS_motion.py", args = ["-m3", "SARFE10-PSSS059"])
# python / ioc / modules / qt / PSSS_motion.py - m1 SARFE10 - PSSS059
time.sleep(1)
add_device(PSSSGratingSet("psss_grating", "SARFE10-PSSS055:GRATING_SP"), True)
psss_grating.alias = "grating"
psss_grating.monitored=True
class PSSSCrystalSet(DiscretePositioner):
def doWrite(self, val):
if not is_dry_run():
super(PSSSCrystalSet, self).doWrite(val)
#caput(psss_grating.getSetpoint().getChannelName(), val)
#self.setCache(val)
exec_cpython("/ioc/modules/qt/PSSS_motion.py", args = ["-m2", "SARFE10-PSSS059"])
# python / ioc / modules / qt / PSSS_motion.py - m1 SARFE10 - PSSS059
time.sleep(1)
add_device(PSSSCrystalSet("psss_crystal", "SARFE10-PSSS059:CRYSTAL_SP"), True)
psss_crystal.alias = "grating"
psss_crystal.monitored=True
###################################################################################################
# Tools
###################################################################################################
@@ -181,4 +230,22 @@ def elog(title, message, attachments = [], author = None, category = "Info", dom
try:
return int(out[out.find("ID=") +3 : ])
except:
print out
print out
from collections import OrderedDict
class LimitedSizeDict(OrderedDict):
def __init__(self, *args, **kwds):
self.size_limit = kwds.pop("size_limit", None)
OrderedDict.__init__(self, *args, **kwds)
self._check_size_limit()
def __setitem__(self, key, value):
OrderedDict.__setitem__(self, key, value)
self._check_size_limit()
def _check_size_limit(self):
if self.size_limit is not None:
while len(self) > self.size_limit:
self.popitem(last=False)

View File

@@ -10,6 +10,9 @@ if get_exec_pars().source == CommandSource.ui:
STEPS = 20
NUM_SHOTS= 10 #100
PLOT=None
import_py("cpython/psss","get_signal_centre")
p = plot(None, title="Data")[0] if (PLOT is None) else PLOT
p.clear()
p.removeMarker(None)
@@ -17,8 +20,6 @@ p.setLegendVisible(True)
p.addSeries(LinePlotSeries("PSSS Spectrum Average"))
run("cpython/wrapper")
if not is_dry_run():
cam_x=Channel("SARFE10-PSSS059:MOTOR_X5.VAL", name="cam_x")
else:
@@ -37,7 +38,7 @@ def after_read(record, scan):
r = lscan(cam_x, (av, av_samples), RANGE_FROM, RANGE_TO, STEPS, latency=0.0, after_read = after_read, save=False)
average, samples, cam_range = r.getReadable(0), r.getReadable(1), r.getPositions(0)
signal_centre, projection = get_signal_centre(samples, cam_range)
signal_centre, projection = get_signal_centre(to_array(samples, 'd') , to_array(cam_range, 'd') )
#Set max position
cam_x.write(signal_centre)

View File

@@ -10,6 +10,9 @@ if get_exec_pars().source == CommandSource.ui:
STEPS = 10 #20
NUM_SHOTS= 10 # 100
PLOT=None
import_py("cpython/psss","fit_crystal_height")
# get current camera ROIs and then set to max for scan
roi_min = psss_roi_min.read()
roi_max = psss_roi_max.read()
@@ -22,8 +25,6 @@ p.removeMarker(None)
p.setLegendVisible(True)
p.addSeries(LinePlotSeries("PSSS Spectrum Average"))
run("cpython/wrapper")
#Setup and functions setup¶
#if not is_dry_run(): # C.arrell commented out 20.01.21
@@ -47,7 +48,8 @@ r = lscan(xstal_height, (av, av_samples), RANGE_FROM, RANGE_TO, STEPS, latency=2
average, samples, xstal_range = r.getReadable(0), r.getReadable(1), r.getPositions(0)
#return maxium position
[amp, mean_val, sigma, offset], projection = fit_crystal_height(RANGE_FROM, RANGE_TO, STEPS+1, samples)
data = to_array(samples, 'd')
[amp, mean_val, sigma, offset], projection = fit_crystal_height(RANGE_FROM, RANGE_TO, STEPS+1, data)
print(mean_val)
if not (RANGE_FROM < mean_val < RANGE_TO or RANGE_TO < mean_val < RANGE_FROM):

View File

@@ -14,6 +14,9 @@ if get_exec_pars().source == CommandSource.ui:
STEPS = 5 #60
NUM_SHOTS= 10 #100
PLOT=None
import_py("cpython/psss","fit_energy")
p = plot(None, title="Data")[0] if (PLOT is None) else PLOT
p.clear()
p.removeMarker(None)
@@ -24,7 +27,6 @@ if RANGE_OFF is not None:
RANGE_FROM = energy_machine.read()-RANGE_OFF
RANGE_TO = energy_machine.read()+RANGE_OFF
run("cpython/wrapper")
# get current camera ROIs and then set to max for scan
roi_min = psss_roi_min.read()
@@ -32,20 +34,6 @@ roi_max = psss_roi_max.read()
psss_roi_min.write(1)
psss_roi_max.write(2000)
#Scan and take data
class PSSS_energy(Writable):
def write(self, value):
#if not is_dry_run():
psss_energy.write(value)
exec_cpython("/ioc/modules/qt/PSSS_motion.py", args = ["-m1", "SARFE10-PSSS059"])
# python / ioc / modules / qt / PSSS_motion.py - m1 SARFE10 - PSSS059
time.sleep(1)
print(value)
en = PSSS_energy()
en.alias = "energy"
av = create_averager(psss_spectrum_y, NUM_SHOTS, interval=-1, name="spectrum_average")
av_samples = av.samples
av_samples.alias = "spectrum_samples"
@@ -53,26 +41,44 @@ av_samples.alias = "spectrum_samples"
def after_read(record, scan):
p.getSeries(0).setData(psss_spectrum_x.take(), record[av])
p.setTitle("Energy = %1.3f" %(record[en]))
p.setTitle("Energy = %1.3f" %(record[psss_energy_set]))
r = lscan(en, (av, av_samples), RANGE_FROM, RANGE_TO, STEPS, latency=0.0, after_read = after_read, save=False )
r = lscan(psss_energy_set, (av, av_samples), RANGE_FROM, RANGE_TO, STEPS, latency=0.0, after_read = after_read, save=False )
average, samples, energy_range = r.getReadable(0), r.getReadable(1), r.getPositions(0)
# return ROI to inital value
psss_roi_min.write(roi_min)
psss_roi_max.write(roi_max)
[amp, mean_val, sigma, offset],centre_line_out = fit_energy(RANGE_FROM, RANGE_TO, STEPS+1, NUM_SHOTS, samples)
data=to_array(samples, 'd')
intensity= [sum(x) for x in average]
max_index=intensity.index(max(intensity))
max_val = energy_range[max_index]
mean_val=None
print "Maximum value: ", max_val
if not (RANGE_FROM < mean_val < RANGE_TO or RANGE_TO < mean_val < RANGE_FROM):
raise Exception ("Invalid fit mean: " + str(mean_val))
try:
[amp, mv, sigma, offset],centre_line_out = fit_energy(RANGE_FROM, RANGE_TO, STEPS+1, NUM_SHOTS, data)
if not (RANGE_FROM < mean_val < RANGE_TO or RANGE_TO < mean_val < RANGE_FROM):
#raise Exception ("Invalid fit mean: " + str(mean_val))
show_message("Fit error - Using maximum value instead at: " + str(max_val), "Fit Error")
else:
mean_val = mv
except Exception as e:
show_message("Fit error - Using maximum value instead at: " + str(max_val) + "\n" + str(e), "Fit Error")
except:
show_message("Fit error - Using maximum value instead at: " + str(max_val))
print "Fit value: ", mean_val
#If invalid fit uses maximum value
if mean_val is None:
mean_val = max_val
measured_offset = energy_machine.read() - mean_val
#Set fitted energy
print "measured offset", measured_offset
en.write(mean_val)
psss_energy_set.write(mean_val)
p.clear()

View File

@@ -1,3 +1,7 @@
import org.jfree.chart.ui.RectangleAnchor as RectangleAnchor
import org.jfree.chart.ui.TextAnchor as TextAnchor
import ch.psi.pshell.imaging.Overlay as Overlay
import ch.psi.pshell.plot.RangeSelectionPlot as RangeSelectionPlot
from collections import deque
PSSS_CAMERA_NAME = "SARFE10-PSSS059";
@@ -61,8 +65,8 @@ def plot_psss(p, h=None, average = None):
# Setup figures
if p.getNumberOfSeries()==0:
p.addSeries(LinePlotSeries("spectrum"))
p.addSeries(LinePlotSeries("average"))
p.addSeries(LinePlotSeries("spectrum", Color.RED))
p.addSeries(LinePlotSeries("average", Color.BLUE))
p.setLegendVisible(True)
p.getAxis(LinePlot.AxisId.X)
p.getAxis(LinePlot.AxisId.X).setLabel("Energy [eV]")
@@ -71,8 +75,8 @@ def plot_psss(p, h=None, average = None):
paint = RangeSelectionPlot().getSelectionColor() #p.chart.getBackgroundPaint()
m=p.addIntervalMarker(0,0, None,"", paint)
m.setLabelAnchor(RectangleAnchor.BOTTOM)
m.alpha=0.2
m.setLabelPaint(Color.WHITE)
m.alpha=0.4
m.setLabelPaint(Color.BLACK)
else:
m = p.getMarkers()[0]
@@ -106,21 +110,26 @@ def plot_psss(p, h=None, average = None):
center=center.doubleValue()
fwhm=fwhm.doubleValue()
m.startValue, m.endValue = center - fwhm/2, center + fwhm/2
m.label = str(center)
m.label = "%1.3f" % (center,)
if h:
if h.getNumberOfSeries()==0:
h.addSeries(TimePlotSeries("centre"))
h.addSeries(TimePlotSeries("Energy spread SS",2))
h.addSeries(TimePlotSeries("Energy spread cum avg",2))
h.addSeries(TimePlotSeries("Energy spread SS",Color.RED, 2))
h.addSeries(TimePlotSeries("Energy spread cum avg", Color.BLUE, 2))
h.addSeries(TimePlotSeries("centre", Color.GREEN.darker(), 1))
h.setLegendVisible(True)
h.setTimeAxisLabel("")
h.getAxis(Timeplot.AxisId.Y1).setLabel("Central energy [eV]")
#h.getAxis(TimePlot.AxisId.Y1).setLabel("Central energy [eV]")
histo_center.config.min = center - 50
histo_center.config.max = center + 50
histo_center.config.save()
per_mil = (fwhm/center)*1e3
per_mil_avg = psss_fwhm_avg.take()
h.getSeries(0).appendData(center)
h.getSeries(1).appendData(per_mil)
h.getSeries(2).appendData(per_mil_avg)
h.getSeries(0).appendData(per_mil)
h.getSeries(1).appendData(per_mil_avg)
h.getSeries(2).appendData(center)
return center,fwhm
ovmin, ovmax, ovavg = None, None, None
@@ -155,7 +164,7 @@ def enable_psss_image(enabled, renderer):
cam_server.config.colormap=Colormap.Temperature
cam_server.start(PSSS_CAMERA_NAME + "_sp", True)
cam_server.start(PSSS_CAMERA_NAME + "_sp", PSSS_CAMERA_NAME + "_sp1")
#ovmin, ovmax= Overlays.Crosshairs(renderer.getPenMarker(), Dimension(-1,1)), \
# Overlays.Crosshairs(renderer.getPenMarker(), Dimension(-1,1))
ovmin, ovmax= Overlays.Line(renderer.getPenMarker()), Overlays.Line(renderer.getPenMarker())
@@ -181,4 +190,4 @@ def get_psss_averaging():
def set_psss_averaging(measures):
psss_spectrum_y_average.config.measures=measures
psss_center_average.config.measures=measures
psss_fwhm_average.config.measures=measures
psss_fwhm_average.config.measures=measures