Add AthosScreens

This commit is contained in:
2025-08-15 17:01:15 +02:00
parent 3140f52ee8
commit 3f3cbb6b0b
52 changed files with 6395 additions and 8 deletions

View File

@@ -1 +1,13 @@
description = 'athos-screens'
ext.mainClass = hasProperty('mainClass') ? mainClass : 'ch.psi.pshell.workbench.App'
ext.title = 'AthosScreens'
ext.desc = 'AthosScreens'
ext.ex_options = 'ch.psi.pshell.screenpanel.Options,ch.psi.athos.Options'
ext.deploy_type= 'jar'
dependencies {
implementation 'ch.psi:pshell-workbench:' + version
implementation 'ch.psi:screenpanel:' + version
}
createDefaultTasks(project)

View File

@@ -0,0 +1 @@
action.debug.args=debug --args="-b -d -l -k -n -q -statusbar -persist -console_log=SEVERE -frame_rate=1.1 -p ch.psi.athos.AthosCameras -laf=dark -pipeline_server localhost:8889 -camera_server localhost:8888 ch.psi.jcae.ContextFactory.addressList=localhost:54321"\n

View File

@@ -0,0 +1,7 @@
#!/bin/sh
export PSHELL_EX_OPTIONS=${ex_options}
APP_ARGS_NAME=\$(echo "APP_${app_name}" | tr '[:lower:]' '[:upper:]')_ARGS
APP_ARGS_NAME=\${APP_ARGS_NAME//-/_}
# Run the JAR with all passed arguments
exec pshell-workbench -b -d -l -k -n -q -statusbar -persist -console_log=SEVERE -frame_rate=1.1 -p ${jar_file} \${!APP_ARGS_NAME} "\$@"

View File

@@ -0,0 +1,454 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="viewer" pref="411" max="32767" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="viewer" alignment="0" pref="603" max="32767" attributes="0"/>
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="ch.psi.pshell.screenpanel.CamServerViewer" name="viewer">
<Properties>
<Property name="localFit" type="java.lang.Boolean" value="true"/>
<Property name="pipelineServerUrl" type="java.lang.String" value="localhost:8889"/>
<Property name="showFit" type="boolean" value="false"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel1">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="0" groupAlignment="0" attributes="0">
<Component id="panelRec" linkSize="2" min="-2" max="-2" attributes="0"/>
<Component id="panelData" linkSize="2" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="panelSrvRec" linkSize="2" min="-2" max="-2" 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"/>
<Component id="panelData" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelSrvRec" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelRec" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="panelSrvRec">
<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="Server Data Recording"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="buttonSrvRec" linkSize="5" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="buttonSrvStop" linkSize="5" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="19" max="32767" attributes="0"/>
<Component id="labelSrvRecording" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="20" max="32767" attributes="0"/>
<Component id="buttonSrvOpen" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="scrollListRemFile" alignment="0" pref="336" 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" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="buttonSrvRec" linkSize="7" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="buttonSrvStop" linkSize="7" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="labelSrvRecording" alignment="2" max="32767" attributes="0"/>
<Component id="buttonSrvOpen" linkSize="7" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="scrollListRemFile" min="-2" pref="60" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JToggleButton" name="buttonSrvRec">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;Rec&quot;)" type="code"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Start Data Recording"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonSrvRecActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonSrvStop">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;Stop&quot;)" type="code"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonSrvStopActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonSrvOpen">
<Properties>
<Property name="text" type="java.lang.String" value="Open"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonSrvOpenActionPerformed"/>
</Events>
</Component>
<Container class="javax.swing.JScrollPane" name="scrollListRemFile">
<Properties>
<Property name="horizontalScrollBarPolicy" type="int" value="32"/>
<Property name="verticalScrollBarPolicy" type="int" value="22"/>
<Property name="size" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[275, 0]"/>
</Property>
<Property name="viewportView" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="null"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JList" name="listRemFile">
<Properties>
<Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
<StringArray count="0"/>
</Property>
<Property name="selectionMode" type="int" value="0"/>
</Properties>
<Events>
<EventHandler event="valueChanged" listener="javax.swing.event.ListSelectionListener" parameters="javax.swing.event.ListSelectionEvent" handler="listRemFileValueChanged"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="labelSrvRecording">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Lucida Grande" size="12" style="0"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="ff" type="rgb"/>
</Property>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="RECORDING"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelData">
<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="Data Fields"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" pref="0" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Component id="buttonReset" linkSize="10" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonDataPause" linkSize="10" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="36" max="32767" attributes="0"/>
<Component id="buttonHistogram" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonPlot" 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"/>
<Component id="buttonSelect" linkSize="1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<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="2" attributes="0">
<Component id="buttonDataPause" linkSize="9" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="buttonPlot" linkSize="9" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="buttonReset" linkSize="9" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="buttonHistogram" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="216" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="buttonSelect" linkSize="9" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="table">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
<Table columnCount="2" rowCount="0">
<Column editable="false" title="Name" type="java.lang.String"/>
<Column editable="false" title="Value" type="java.lang.Object"/>
</Table>
</Property>
</Properties>
<Events>
<EventHandler event="mouseReleased" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="tableMouseReleased"/>
<EventHandler event="keyReleased" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="tableKeyReleased"/>
</Events>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="buttonSelect">
<Properties>
<Property name="text" type="java.lang.String" value="Select"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonSelectActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonPlot">
<Properties>
<Property name="text" type="java.lang.String" value="Plot"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonPlotActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JToggleButton" name="buttonDataPause">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;Pause&quot;)" type="code"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Start Data Recording"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonDataPauseActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonReset">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;Reset&quot;)" type="code"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonResetActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonHistogram">
<Properties>
<Property name="text" type="java.lang.String" value="Histo"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonHistogramActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelRec">
<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="Local Data Recording"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="scrollListFile" pref="336" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="buttonRec" linkSize="6" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="buttonStop" linkSize="6" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="22" max="32767" attributes="0"/>
<Component id="labelRecording" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="23" max="32767" attributes="0"/>
<Component id="buttonOpen" min="-2" max="-2" attributes="0"/>
</Group>
</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="2" attributes="0">
<Component id="buttonRec" linkSize="8" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="buttonStop" linkSize="8" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="buttonOpen" linkSize="8" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="labelRecording" alignment="2" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="scrollListFile" min="-2" pref="60" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JToggleButton" name="buttonRec">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;Rec&quot;)" type="code"/>
</Property>
<Property name="toolTipText" type="java.lang.String" value="Start Data Recording"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonRecActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonStop">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;Stop&quot;)" type="code"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonStopActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonOpen">
<Properties>
<Property name="text" type="java.lang.String" value="Open"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonOpenActionPerformed"/>
</Events>
</Component>
<Container class="javax.swing.JScrollPane" name="scrollListFile">
<Properties>
<Property name="horizontalScrollBarPolicy" type="int" value="32"/>
<Property name="verticalScrollBarPolicy" type="int" value="22"/>
<Property name="viewportView" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="null"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JList" name="listFile">
<Properties>
<Property name="model" type="javax.swing.ListModel" editor="org.netbeans.modules.form.editors2.ListModelEditor">
<StringArray count="0"/>
</Property>
<Property name="selectionMode" type="int" value="0"/>
<Property name="size" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor">
<Dimension value="[275, 0]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JLabel" name="labelRecording">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Lucida Grande" size="12" style="0"/>
</Property>
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="ff" type="rgb"/>
</Property>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="text" type="java.lang.String" value="RECORDING"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,87 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<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">
<Component id="jScrollPane1" pref="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace pref="72" max="32767" attributes="0"/>
<Component id="buttonCancel" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonOk" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="72" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jScrollPane1" pref="233" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonOk" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonCancel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="javax.swing.JTable" name="table">
<Properties>
<Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor">
<Table columnCount="2" rowCount="0">
<Column editable="false" title="Name" type="java.lang.String"/>
<Column editable="true" title="Enable" type="java.lang.Boolean"/>
</Table>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="buttonCancel">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCancelActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonOk">
<Properties>
<Property name="text" type="java.lang.String" value="OK"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonOkActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@@ -0,0 +1,214 @@
package ch.psi.athos;
import ch.psi.pshell.camserver.PipelineSource;
import ch.psi.pshell.swing.StandardDialog;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.table.DefaultTableModel;
/**
*
*/
public class DataSelector extends StandardDialog {
final DefaultTableModel model;
List<String> selected = new ArrayList();
/**
* Creates new form DataSelector
*/
public DataSelector(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
model = (DefaultTableModel) table.getModel();
}
public void set(String serverUrl, String pipelineName) throws Exception{
try (PipelineSource server = new PipelineSource("Data pipeline", serverUrl)){
server.initialize();
Map<String, Object> cfg = server.getInstanceConfig(pipelineName);
List<String> include = (List<String>) cfg.get("include");
String cameraName = (String) cfg.get("camera_name");
String instanceName = cameraName + AthosCameras.pipelineSuffixData + "info";
try{
if (!server.getInstances().contains(instanceName)) {
HashMap config = new HashMap<>();
config.put("camera_name", cameraName);
server.createFromConfig(config, instanceName);
}
server.start(instanceName, true);
server.getStream().waitCacheChange(10000);
List<String> ids = server.getStream().getIdentifiers();
Collections.sort(ids);
model.setRowCount(ids.size());
for (int i=0; i< ids.size(); i++){
model.setValueAt(ids.get(i), i, 0);
model.setValueAt(include.contains(ids.get(i)), i, 1);
}
} finally{
server.stop();
}
}
}
public List<String> getEnabled(){
List<String> ret = new ArrayList<>();
for (int i=0; i<model.getRowCount();i++){
if (Boolean.TRUE.equals(model.getValueAt( i, 1))){
ret.add((String) model.getValueAt( i, 0));
}
}
return ret;
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
table = new javax.swing.JTable();
buttonCancel = new javax.swing.JButton();
buttonOk = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
table.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
},
new String [] {
"Name", "Enable"
}
) {
Class[] types = new Class [] {
java.lang.String.class, java.lang.Boolean.class
};
boolean[] canEdit = new boolean [] {
false, true
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
public boolean isCellEditable(int rowIndex, int columnIndex) {
return canEdit [columnIndex];
}
});
jScrollPane1.setViewportView(table);
buttonCancel.setText("Cancel");
buttonCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonCancelActionPerformed(evt);
}
});
buttonOk.setText("OK");
buttonOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonOkActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addContainerGap(72, Short.MAX_VALUE)
.addComponent(buttonCancel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonOk)
.addContainerGap(72, Short.MAX_VALUE))
);
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonCancel, buttonOk});
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonOk)
.addComponent(buttonCancel))
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
this.cancel();
}//GEN-LAST:event_buttonCancelActionPerformed
private void buttonOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonOkActionPerformed
selected.clear();
for (int i=0; i< model.getRowCount(); i++){
if (Boolean.TRUE.equals(model.getValueAt(i, 1))){
selected.add(String.valueOf(model.getValueAt(i, 0)));
}
}
this.accept();
}//GEN-LAST:event_buttonOkActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(DataSelector.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(DataSelector.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(DataSelector.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(DataSelector.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
DataSelector dialog = new DataSelector(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonCancel;
private javax.swing.JButton buttonOk;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTable table;
// End of variables declaration//GEN-END:variables
}

View File

@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="panelScreen" alignment="1" max="32767" attributes="0"/>
<Component id="panelFilter" alignment="1" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="panelScreen" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="panelFilter" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="panelScreen">
<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="Screen"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="valueScreen" alignment="0" max="32767" attributes="0"/>
<Component id="comboScreen" alignment="0" 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" alignment="1" attributes="0">
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Component id="comboScreen" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="valueScreen" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="ch.psi.pshell.swing.DeviceValuePanel" name="valueScreen">
</Component>
<Component class="javax.swing.JComboBox" name="comboScreen">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboScreenActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelFilter">
<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="Filter"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="valueFilter" alignment="0" max="32767" attributes="0"/>
<Component id="comboFilter" alignment="0" 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" alignment="1" attributes="0">
<EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Component id="comboFilter" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="valueFilter" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="ch.psi.pshell.swing.DeviceValuePanel" name="valueFilter">
</Component>
<Component class="javax.swing.JComboBox" name="comboFilter">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboFilterActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@@ -0,0 +1,268 @@
package ch.psi.athos;
import ch.psi.pshell.device.Device;
import ch.psi.pshell.epics.ChannelInteger;
import ch.psi.pshell.epics.DiscretePositioner;
import ch.psi.pshell.swing.SwingUtils;
import javax.swing.DefaultComboBoxModel;
/**
*
*/
public class HardwarePanel extends javax.swing.JPanel {
DiscretePositioner screen;
DiscretePositioner filter;
Thread devicesInitTask;
public HardwarePanel() {
initComponents();
}
public void onTimer() {
for (Device dev : new Device[]{screen, filter}) {
if (dev != null) {
dev.request();
}
}
}
String cameraName;
public void setCamera(String cameraName) {
setCamera(cameraName, false);
}
public void setCamera(String cameraName, boolean electrons) {
this.cameraName = cameraName;
if ((devicesInitTask != null) && (devicesInitTask.isAlive())) {
devicesInitTask.interrupt();
}
if (screen != null) {
screen.close();
screen = null;
}
if (filter != null) {
filter.close();
filter = null;
}
comboScreen.setModel(new DefaultComboBoxModel());
comboScreen.setEnabled(false);
comboFilter.setModel(new DefaultComboBoxModel());
comboFilter.setEnabled(false);
panelFilter.setVisible(electrons);
panelScreen.setVisible(electrons);
if (cameraName!=null){
if (electrons) {
//Parallelizing initialization
devicesInitTask = new Thread(() -> {
try {
if (cameraName.contains("DSRM")) {
screen = new DiscretePositioner("CurrentScreen", cameraName + ":POSITION_SP", cameraName + ":POSITION");
} else {
screen = new DiscretePositioner("CurrentScreen", cameraName + ":SET_SCREEN1_POS", cameraName + ":GET_SCREEN1_POS");
}
screen.setMonitored(true);
screen.initialize();
DefaultComboBoxModel model = new DefaultComboBoxModel();
for (String pos : screen.getPositions()) {
model.addElement(pos);
}
comboScreen.setModel(model);
comboScreen.setSelectedItem(screen.read());
} catch (Exception ex) {
comboScreen.setModel(new DefaultComboBoxModel());
System.err.println(ex.getMessage());
screen = null;
}
comboScreen.setEnabled(screen != null);
valueScreen.setDevice(screen);
try {
filter = new DiscretePositioner("CurrentFilter", cameraName + ":SET_FILTER", cameraName + ":GET_FILTER");
filter.setMonitored(true);
filter.initialize();
DefaultComboBoxModel model = new DefaultComboBoxModel();
for (String pos : filter.getPositions()) {
model.addElement(pos);
}
comboFilter.setModel(model);
comboFilter.setSelectedItem(filter.read());
} catch (Exception ex) {
System.err.println(ex.getMessage());
filter = null;
}
comboFilter.setEnabled(filter != null);
valueFilter.setDevice(filter);
});
devicesInitTask.start();
}
}
}
public String getCamera() {
return cameraName;
}
public String getScreenValue() {
return String.valueOf(valueScreen.getLabel().getText());
}
public String getFilterValue() {
return String.valueOf(valueFilter.getLabel().getText());
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
panelScreen = new javax.swing.JPanel();
valueScreen = new ch.psi.pshell.swing.DeviceValuePanel();
comboScreen = new javax.swing.JComboBox();
panelFilter = new javax.swing.JPanel();
valueFilter = new ch.psi.pshell.swing.DeviceValuePanel();
comboFilter = new javax.swing.JComboBox();
panelScreen.setBorder(javax.swing.BorderFactory.createTitledBorder("Screen"));
comboScreen.setEnabled(false);
comboScreen.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
comboScreenActionPerformed(evt);
}
});
javax.swing.GroupLayout panelScreenLayout = new javax.swing.GroupLayout(panelScreen);
panelScreen.setLayout(panelScreenLayout);
panelScreenLayout.setHorizontalGroup(
panelScreenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelScreenLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelScreenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(valueScreen, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboScreen, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
panelScreenLayout.setVerticalGroup(
panelScreenLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelScreenLayout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(comboScreen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(valueScreen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
panelFilter.setBorder(javax.swing.BorderFactory.createTitledBorder("Filter"));
comboFilter.setEnabled(false);
comboFilter.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
comboFilterActionPerformed(evt);
}
});
javax.swing.GroupLayout panelFilterLayout = new javax.swing.GroupLayout(panelFilter);
panelFilter.setLayout(panelFilterLayout);
panelFilterLayout.setHorizontalGroup(
panelFilterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelFilterLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelFilterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(valueFilter, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(comboFilter, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
panelFilterLayout.setVerticalGroup(
panelFilterLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelFilterLayout.createSequentialGroup()
.addGap(4, 4, 4)
.addComponent(comboFilter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(valueFilter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.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)
.addComponent(panelScreen, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(panelFilter, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(panelScreen, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(panelFilter, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
}// </editor-fold>//GEN-END:initComponents
private void comboScreenActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboScreenActionPerformed
comboScreen.setEnabled(false);
new Thread(new Runnable() {
@Override
public void run() {
ChannelInteger setpoint = null;
try {
int index = comboScreen.getSelectedIndex();
if (index >= 0) {
if (cameraName.contains("DSRM")) {
setpoint = new ChannelInteger(null, cameraName + ":POSITION_SP");
} else {
setpoint = new ChannelInteger(null, cameraName + ":SET_SCREEN1_POS");
}
setpoint.initialize();
Integer readback = setpoint.read();
if ((readback == null) || (setpoint.read() != index)) {
setpoint.write(index);
}
screen.read();
}
} catch (Exception ex) {
SwingUtils.showException(HardwarePanel.this, ex);
} finally {
comboScreen.setEnabled(true);
if (setpoint != null) {
setpoint.close();
}
}
}
}).start();
}//GEN-LAST:event_comboScreenActionPerformed
private void comboFilterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboFilterActionPerformed
try {
String setpoint = (String) comboFilter.getSelectedItem();
if (setpoint != null) {
if (!setpoint.equals(filter.read())) {
filter.write(setpoint);
}
}
} catch (Exception ex) {
SwingUtils.showException(HardwarePanel.this, ex);
}
}//GEN-LAST:event_comboFilterActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JComboBox comboFilter;
private javax.swing.JComboBox comboScreen;
private javax.swing.JPanel panelFilter;
private javax.swing.JPanel panelScreen;
private ch.psi.pshell.swing.DeviceValuePanel valueFilter;
private ch.psi.pshell.swing.DeviceValuePanel valueScreen;
// End of variables declaration//GEN-END:variables
}

View File

@@ -0,0 +1,15 @@
package ch.psi.athos;
import ch.psi.pshell.app.Option;
/**
*
*/
public enum Options implements Option {
FRAME_RATE;
public static void add(){
FRAME_RATE.add("ft", "Maximum image frame rate");
}
}

View File

@@ -10,6 +10,7 @@ allprojects {
ext.release = '1'
ext.jar_suffix = 'fat'
ext.ex_options= ''
ext.deploy_type= 'java'
repositories {
mavenLocal()
@@ -85,15 +86,18 @@ subprojects {
def app_release = project.ext.release.toString()
def jar_suffix = project.ext.jar_suffix.toString()
def ex_options = project.ext.ex_options
def deploy_type = project.ext.deploy_type
def package_name = project.name
def app_path = '/opt/' + package_name + "/" + app_version
def jar_file_name = app_name + "-" + app_version + "-" + jar_suffix + ".jar";
def jar_file_name = app_name + "-" + app_version + ".jar";
def jar_file_path = app_path + '/lib/' + jar_file_name;
def fat_jar_file_name = app_name + "-" + app_version + "-" + jar_suffix + ".jar";
def fat_jar_file_path = app_path + '/lib/' + fat_jar_file_name;
def main_class = project.mainClass
def sys_bin ='/usr/local/bin/'
def sys_lib ='/usr/local/lib/'
def bin_file_name = "${app_name}-${app_version}"
def java_file_name = main_class + ".java"
def java_file_name = main_class + ".java"
project.tasks.register("rpm", Rpm) {
doFirst {
@@ -104,6 +108,7 @@ subprojects {
}
}
requires 'pshell-workbench'
dependsOn 'jar'
release = app_release
version = app_version
@@ -131,12 +136,19 @@ subprojects {
into app_path
from ('src/main/java') {
//print(java_file_name )
include java_file_name
into 'lib'
fileMode 0644
}
if (deploy_type=='java'){
from ('src/main/java') {
include java_file_name
into 'lib'
fileMode 0644
}
} else if (deploy_type=='jar'){
from ('build/libs') {
include jar_file_name
into 'lib'
fileMode 0644
}
}
from('scripts') {
into 'bin'
@@ -148,6 +160,7 @@ subprojects {
"app_name": app_name,
"app_version": app_version,
"jar_file": jar_file_path,
"fat_jar_file": fat_jar_file_path,
"java_file": app_path + '/lib/' + main_class + ".java",
"ex_options" :ex_options
])

31
correlation/bin/correlation Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
MY_PATH=$(dirname "$0")
export PKG=${MY_PATH}/..
#Check if running as e-account
for i in "$@"
do
case $i in
-pkg=*)
export PKG="${i#*=}"
;;
*) # unknown option
;;
esac
done
/opt/gfa/pshell/pshell \
-version=default \
-py3 \
-m=${PKG} \
-z \
-nbcf=true \
-laf=dark \
-d \
-pini=true \
-clog=WARNING \
-sbar \
$@

View File

@@ -0,0 +1,31 @@
#!/bin/bash
MY_PATH=$(dirname "$0")
export PKG=${MY_PATH}/..
#Check if running as e-account
for i in "$@"
do
case $i in
-pkg=*)
export PKG="${i#*=}"
;;
*) # unknown option
;;
esac
done
/opt/gfa/pshell/pshell \
-version=default \
-z \
-py3 \
-nbcf=true \
-laf=dark \
-pini=true \
-plgp=${PKG}/plugins \
-scpt=${PKG}/script \
-devp=${PKG}/devices \
$@

11
correlation/build.gradle Normal file
View File

@@ -0,0 +1,11 @@
description = 'correlation'
ext.mainClass = hasProperty('mainClass') ? mainClass : 'ch.psi.pshell.workbench.App'
ext.title = 'Correlation'
ext.desc = 'Correlation'
ext.deploy_type= 'pkg'
dependencies {
implementation 'ch.psi:pshell-workbench:' + version
}
createDefaultTasks(project)

View File

@@ -0,0 +1,2 @@
dispatcher=ch.psi.pshell.bs.Dispatcher|https://dispatcher-api.psi.ch/sf|||
cam_server=ch.psi.pshell.bs.PipelineServer|sf-daqsync-01:8889|||

View File

@@ -0,0 +1,12 @@
#Mon Feb 22 20:35:07 CET 2021
ch.psi.jcae.ContextFactory.addressList=
ch.psi.jcae.ContextFactory.serverPort=
ch.psi.jcae.ContextFactory.maxArrayBytes=50000000
ch.psi.jcae.ChannelFactory.retries=1
ch.psi.jcae.ChannelFactory.timeout=1000
ch.psi.jcae.impl.DefaultChannelService.retries=1
ch.psi.jcae.impl.DefaultChannelService.timeout=1000
ch.psi.jcae.ContextFactory.autoAddressList=true
ch.psi.jcae.ContextFactory.useShellVariables=true
ch.psi.jcae.ContextFactory.addLocalBroadcastInterfaces=false
ch.psi.jcae.ContextFactory.maxSendArrayBytes=1000000

View File

@@ -0,0 +1,25 @@
#Mon Aug 21 16:04:52 CEST 2023
spatialCalOffsetY=-26.131980971800004
spatialCalOffsetX=-40.21857787259174
colormapLogarithmic=false
scale=1.0
grayscale=false
spatialCalScaleX=-13.784314431779372
spatialCalScaleY=-13.784313995826063
colormapMax=255.0
rescaleOffset=0.0
roiWidth=-1
colormap=Temperature
invert=false
colormapMin=0.0
rotationCrop=false
rotation=0.0
rescaleFactor=1.0
spatialCalUnits=mm
flipVertically=false
roiHeight=-1
flipHorizontally=false
colormapAutomatic=true
roiY=0
roiX=0
transpose=false

View File

@@ -0,0 +1,14 @@
#Wed May 31 12:25:22 CEST 2023
byteBufferAllocator=false
disableCompression=false
dropIncomplete=false
headerReservingAllocator=false
keepListeningOnStop=false
mappingIncomplete=fill_null
parallelHandlerProcessing=true
sendAwaitFirstMessage=false
sendBuildChannelConfig=at_startup
sendStrategy=complete_all
sendSyncTimeout=0
socketType=DEFAULT
validationInconsistency=keep_as_is

View File

@@ -0,0 +1,331 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="plot" pref="277" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" max="32767" attributes="0"/>
<Group type="102" attributes="0">
<Component id="plot" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="ch.psi.pshell.plot.LinePlotJFree" name="plot">
<Properties>
<Property name="title" type="java.lang.String" value=""/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel1">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel7" linkSize="3" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel6" linkSize="3" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" linkSize="3" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="jLabel8" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="checkAlign" min="-2" max="-2" attributes="0"/>
<Component id="comboTypeY" min="-2" max="-2" attributes="0"/>
<Component id="comboTypeX" min="-2" max="-2" attributes="0"/>
<Component id="textCorrelation" linkSize="4" alignment="0" pref="250" max="32767" attributes="0"/>
<Component id="spinnerInterval" linkSize="2" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="spinnerWindow" linkSize="2" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="textLinear" linkSize="4" alignment="0" pref="250" max="32767" attributes="0"/>
<Component id="checkLinear" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
<Component id="textPeak" alignment="0" max="32767" attributes="0"/>
<Component id="textQuadratic" linkSize="4" alignment="0" pref="250" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace min="0" pref="70" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="textDevX" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="checkQuadratic" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonElog" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="textDevY" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonStart" min="-2" pref="189" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<Component id="textDevX" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="comboTypeX" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<Component id="textDevY" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="5" max="-2" attributes="0"/>
<Component id="comboTypeY" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerInterval" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerWindow" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="checkAlign" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="checkLinear" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="checkQuadratic" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonElog" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="32767" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="textCorrelation" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel6" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="textLinear" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel7" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="textQuadratic" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel8" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="textPeak" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="32767" attributes="0"/>
<Component id="buttonStart" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="33" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="X device:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Y device:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Interval (s):"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerInterval">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.1" minimum="0.001" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Window size:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerWindow">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="50" minimum="3" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonStart">
<Properties>
<Property name="text" type="java.lang.String" value="Start"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonStartActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="Correlation:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textCorrelation">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="Liner fit:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textLinear">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel7">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="Quadratric fit:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textQuadratic">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkLinear">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Linear fit"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkQuadratic">
<Properties>
<Property name="text" type="java.lang.String" value="Quadratic fit"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboTypeX">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="3">
<StringItem index="0" value="Channel"/>
<StringItem index="1" value="Stream"/>
<StringItem index="2" value="Camera"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboTypeXActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JComboBox" name="comboTypeY">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="3">
<StringItem index="0" value="Channel"/>
<StringItem index="1" value="Stream"/>
<StringItem index="2" value="Camera"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboTypeYActionPerformed"/>
</Events>
</Component>
<Component class="ch.psi.pshell.swing.ChannelSelector" name="textDevX">
<Properties>
<Property name="historySize" type="int" value="20"/>
<Property name="name" type="java.lang.String" value="Correlation_textDevX" noResource="true"/>
</Properties>
</Component>
<Component class="ch.psi.pshell.swing.ChannelSelector" name="textDevY">
<Properties>
<Property name="historySize" type="int" value="20"/>
<Property name="name" type="java.lang.String" value="Correlation_textDevY" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonElog">
<Properties>
<Property name="text" type="java.lang.String" value="ELOG"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonElogActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel8">
<Properties>
<Property name="horizontalAlignment" type="int" value="4"/>
<Property name="text" type="java.lang.String" value="Peak:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textPeak">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkAlign">
<Properties>
<Property name="text" type="java.lang.String" value="Align Camera Streams"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@@ -0,0 +1,621 @@
/*
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
*/
import ch.psi.pshell.plot.Plot;
import ch.psi.pshell.swing.ChannelSelector;
import ch.psi.pshell.ui.App;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import ch.psi.utils.Chrono;
import ch.psi.utils.swing.SwingUtils;
import ch.psi.utils.swing.SwingUtils.OptionResult;
import ch.psi.utils.swing.SwingUtils.OptionType;
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.util.HashMap;
import java.util.List;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
/**
*
*/
public class Correlation extends Panel {
public Correlation() {
initComponents();
this.setPersistedComponents(new Component[]{textDevX, textDevY, spinnerInterval, spinnerWindow, comboTypeX, comboTypeY});
plot.getAxis(Plot.AxisId.X).setLabel(null);
plot.getAxis(Plot.AxisId.Y).setLabel(null);
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
if (runCount==0){
super.onInitialize(runCount);
if (App.hasArgument("dx")) {
textDevX.setText(App.getArgumentValue("dx"));
}
if (App.hasArgument("dy")) {
textDevY.setText(App.getArgumentValue("dy"));
}
try{
if (App.hasArgument("dxtype")) {
comboTypeX.setSelectedIndex(Integer.valueOf(App.getArgumentValue("dxtype")));
}
} catch (Exception ex){
System.err.println(ex.getMessage());
}
try{
if (App.hasArgument("dytype")) {
comboTypeY.setSelectedIndex(Integer.valueOf(App.getArgumentValue("dytype")));
}
} catch (Exception ex){
System.err.println(ex.getMessage());
}
try{
if (App.hasArgument("interval")) {
spinnerInterval.setValue(Double.valueOf(App.getArgumentValue("interval")));
}
} catch (Exception ex){
System.err.println(ex.getMessage());
}
try{
if (App.hasArgument("window")) {
spinnerWindow.setValue(Integer.valueOf(App.getArgumentValue("window")));
}
} catch (Exception ex){
System.err.println(ex.getMessage());
}
try{
if (App.hasArgument("align")) {
checkAlign.setSelected(App.getBoolArgumentValue("align"));
}
} catch (Exception ex){
System.err.println(ex.getMessage());
}
try{
if (App.hasArgument("linear")) {
checkLinear.setSelected(App.getBoolArgumentValue("linear"));
}
} catch (Exception ex){
System.err.println(ex.getMessage());
}
try{
if (App.hasArgument("quadratic")) {
checkQuadratic.setSelected(App.getBoolArgumentValue("quadratic"));
}
} catch (Exception ex){
System.err.println(ex.getMessage());
}
}
this.startTimer(100, 10);
comboTypeXActionPerformed(null);
comboTypeYActionPerformed(null);
}
@Override
protected void onTimer(){
if (isRunning()){
updateResults();
}
}
//DecimalFormat formatter = new DecimalFormat("0.##E0");
void updateResults(){
try{
textCorrelation.setText(String.format("%1.4f", Double.valueOf((Double)getContext().getInterpreterVariable("corr"))));
} catch (Exception ex){
textCorrelation.setText("");
}
if (checkLinear.isSelected()){
try{
List pars = (List)getContext().getInterpreterVariable("pars_lin");
//textLinear.setText(String.format("%1.3fx%+1.3f", (Double)(pars.get(1)), (Double)(pars.get(0))));
textLinear.setText(String.format("%1.6gx%+1.6g",pars.get(1), pars.get(0)));
} catch (Exception ex){
textLinear.setText("");
}
}
if (checkQuadratic.isSelected()){
try{
List pars = (List)getContext().getInterpreterVariable("pars_quad");
//textQuadratic.setText(String.format("%1.2fx\u00B2 %+1.2fx%+1.2f", (Double)(pars.get(0)), (Double)(pars.get(1)), (Double)(pars.get(0))));
textQuadratic.setText(String.format("%1.3gx\u00B2%+1.3gx%+1.3g", pars.get(0), pars.get(1), pars.get(0)));
//textQuadratic.setText(formatter.format(pars.get(2))+ formatter.format(pars.get(1)) + formatter.format(pars.get(0)));
} catch (Exception ex){
textQuadratic.setText("");
}
try{
String peak = (String)getContext().getInterpreterVariable("pos_peak");
if (peak!=null){
textPeak.setText(peak + " (max)");
} else {
peak = (String)getContext().getInterpreterVariable("neg_peak");
if (peak!=null){
textPeak.setText(peak + " (min)");
} else {
textPeak.setText("");
}
}
} catch (Exception ex){
textPeak.setText("");
}
}
}
@Override
public void onStateChange(State state, State former) {
buttonStart.setEnabled((state==State.Ready) || (state==State.Busy));
if (isRunning()){
if (state==State.Ready){
buttonStart.setText("Start");
}
} else {
if (state==State.Busy){
buttonStart.setText("Stop");
buttonElog.setEnabled(true);
}
}
textDevX.setEnabled(state==State.Ready);
textDevY.setEnabled(state==State.Ready);
spinnerInterval.setEnabled(state==State.Ready);
spinnerWindow.setEnabled(state==State.Ready);
comboTypeX.setEnabled(state==State.Ready);
comboTypeY.setEnabled(state==State.Ready);
checkLinear.setEnabled(state==State.Ready);
checkQuadratic.setEnabled(state==State.Ready);
if ((former==State.Initializing) && (state == State.Ready)){
if (App.hasArgument("start")) {
buttonStartActionPerformed(null);
}
}
}
boolean isRunning(){
return buttonStart.getText().equals("Stop");
}
@Override
public void onExecutedFile(String fileName, Object result) {
}
//Callback to perform update - in event thread
@Override
protected void doUpdate() {
}
void elog(String logbook, String title, String message, String[] attachments) throws Exception {
String domain = "";
String category = "Info";
String entry = "";
StringBuffer cmd = new StringBuffer();
cmd.append("G_CS_ELOG_add -l \"").append(logbook).append("\" ");
cmd.append("-a \"Author=ScreenPanel\" ");
cmd.append("-a \"Type=pshell\" ");
cmd.append("-a \"Entry=").append(entry).append("\" ");
cmd.append("-a \"Title=").append(title).append("\" ");
cmd.append("-a \"Category=").append(category).append("\" ");
cmd.append("-a \"Domain=").append(domain).append("\" ");
for (String attachment : attachments) {
cmd.append("-f \"").append(attachment).append("\" ");
}
cmd.append("-n 1 ");
cmd.append("\"").append(message).append("\" ");
System.out.println(cmd.toString());
final Process process = Runtime.getRuntime().exec(new String[]{"bash", "-c", cmd.toString()});
new Thread(() -> {
try {
process.waitFor();
int bytes = process.getInputStream().available();
byte[] arr = new byte[bytes];
process.getInputStream().read(arr, 0, bytes);
System.out.println(new String(arr));
bytes = process.getErrorStream().available();
arr = new byte[bytes];
process.getErrorStream().read(arr, 0, bytes);
System.err.println(new String(arr));
} catch (Exception ex) {
System.err.println(ex);
}
}).start();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
plot = new ch.psi.pshell.plot.LinePlotJFree();
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
spinnerInterval = new javax.swing.JSpinner();
jLabel4 = new javax.swing.JLabel();
spinnerWindow = new javax.swing.JSpinner();
buttonStart = new javax.swing.JButton();
jLabel5 = new javax.swing.JLabel();
textCorrelation = new javax.swing.JTextField();
jLabel6 = new javax.swing.JLabel();
textLinear = new javax.swing.JTextField();
jLabel7 = new javax.swing.JLabel();
textQuadratic = new javax.swing.JTextField();
checkLinear = new javax.swing.JCheckBox();
checkQuadratic = new javax.swing.JCheckBox();
comboTypeX = new javax.swing.JComboBox();
comboTypeY = new javax.swing.JComboBox();
textDevX = new ch.psi.pshell.swing.ChannelSelector();
textDevY = new ch.psi.pshell.swing.ChannelSelector();
buttonElog = new javax.swing.JButton();
jLabel8 = new javax.swing.JLabel();
textPeak = new javax.swing.JTextField();
checkAlign = new javax.swing.JCheckBox();
plot.setTitle("");
jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel1.setText("X device:");
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel2.setText("Y device:");
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel3.setText("Interval (s):");
spinnerInterval.setModel(new javax.swing.SpinnerNumberModel(0.1d, 0.001d, null, 1.0d));
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel4.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);
}
});
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel5.setText("Correlation:");
textCorrelation.setEditable(false);
textCorrelation.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel6.setText("Liner fit:");
textLinear.setEditable(false);
textLinear.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel7.setText("Quadratric fit:");
textQuadratic.setEditable(false);
textQuadratic.setHorizontalAlignment(javax.swing.JTextField.CENTER);
checkLinear.setSelected(true);
checkLinear.setText("Linear fit");
checkQuadratic.setText("Quadratic fit");
comboTypeX.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Channel", "Stream", "Camera" }));
comboTypeX.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
comboTypeXActionPerformed(evt);
}
});
comboTypeY.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Channel", "Stream", "Camera" }));
comboTypeY.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
comboTypeYActionPerformed(evt);
}
});
textDevX.setHistorySize(20);
textDevX.setName("Correlation_textDevX"); // NOI18N
textDevY.setHistorySize(20);
textDevY.setName("Correlation_textDevY"); // NOI18N
buttonElog.setText("ELOG");
buttonElog.setEnabled(false);
buttonElog.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonElogActionPerformed(evt);
}
});
jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
jLabel8.setText("Peak:");
textPeak.setEditable(false);
textPeak.setHorizontalAlignment(javax.swing.JTextField.CENTER);
checkAlign.setText("Align Camera Streams");
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()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel4, javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(checkAlign)
.addComponent(comboTypeY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(comboTypeX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(textCorrelation, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(spinnerInterval, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerWindow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(textLinear, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)
.addComponent(checkLinear)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(textPeak, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(textQuadratic, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 250, Short.MAX_VALUE)))
.addGap(0, 70, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(textDevX, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addComponent(checkQuadratic)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonElog))
.addComponent(textDevY, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonStart, javax.swing.GroupLayout.PREFERRED_SIZE, 189, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, Short.MAX_VALUE))
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel1, jLabel2, jLabel3, jLabel4});
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spinnerInterval, spinnerWindow});
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel5, jLabel6, jLabel7});
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {textCorrelation, textLinear, textQuadratic});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(textDevX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(comboTypeX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel2)
.addComponent(textDevY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(5, 5, 5)
.addComponent(comboTypeY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(spinnerInterval, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(spinnerWindow, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(checkAlign)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(checkLinear)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(checkQuadratic)
.addComponent(buttonElog))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(textCorrelation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel6)
.addComponent(textLinear, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel7)
.addComponent(textQuadratic, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel8)
.addComponent(textPeak, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, Short.MAX_VALUE)
.addComponent(buttonStart)
.addGap(33, 33, 33))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 277, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())))
);
}// </editor-fold>//GEN-END:initComponents
private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed
try {
if (isRunning()){
//abort();
//Stooping smootly so displayed variables get updated.
getContext().setInterpreterVariable("stop_exec", true);
Chrono chrono = new Chrono();
while (!chrono.isTimeout(500)){
if (!Boolean.TRUE.equals(getContext().getInterpreterVariable("stop_exec"))){
break;
}
Thread.sleep(1);
}
if (Boolean.TRUE.equals(getContext().getInterpreterVariable("stop_exec"))){
System.out.println("Timeout stopping script - aborting...");
abort();
}
updateResults();
//buttonStart.setText("Start");
} else {
textCorrelation.setText("");
textLinear.setText("");
textQuadratic.setText("");
textPeak.setText("");
HashMap args = new HashMap();
args.put("dx", textDevX.getText());
args.put("dy", textDevY.getText());
args.put("interval", spinnerInterval.getValue());
args.put("window", spinnerWindow.getValue());
args.put("dxtype", comboTypeX.getSelectedIndex());
args.put("dytype", comboTypeY.getSelectedIndex());
args.put("linear_fit", checkLinear.isSelected());
args.put("quadratic_fit", checkQuadratic.isSelected());
args.put("merge_camera_stream", checkAlign.isSelected());
args.put("p", plot);
runAsync("correlation", args).handle((ok, ex) -> {
if (ex != null) {
ex.printStackTrace();
}
return ok;
});
///buttonStart.setText("Stop");
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonStartActionPerformed
private void comboTypeXActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboTypeXActionPerformed
if (comboTypeX.getSelectedIndex()==0){
//textDevX.configure(ChannelSelector.Type.Epics, "http://epics-boot-info.psi.ch", "swissfel", 5000);
textDevX.configure(ChannelSelector.Type.IocInfo,"http://iocinfo.psi.ch/api/v2", "swissfel", 5000);
} else if (comboTypeX.getSelectedIndex()==1){
textDevX.configure(ChannelSelector.Type.DataAPI, "https://data-api.psi.ch/sf", "sf-databuffer", 5000);
} else if (comboTypeX.getSelectedIndex()==2){
textDevX.configure(ChannelSelector.Type.Camera, "sf-daqsync-01:8889", null, 5000);
}
}//GEN-LAST:event_comboTypeXActionPerformed
private void comboTypeYActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboTypeYActionPerformed
if (comboTypeY.getSelectedIndex()==0){
textDevY.configure(ChannelSelector.Type.IocInfo,"http://iocinfo.psi.ch/api/v2", "swissfel", 5000);
} else if (comboTypeY.getSelectedIndex()==1){
textDevY.configure(ChannelSelector.Type.DataAPI, "https://data-api.psi.ch/sf", "sf-databuffer", 5000);
} else if (comboTypeY.getSelectedIndex()==2){
textDevY.configure(ChannelSelector.Type.Camera, "sf-daqsync-01:8889", null, 5000);
}
}//GEN-LAST:event_comboTypeYActionPerformed
private void buttonElogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonElogActionPerformed
try{
String snapshotFile = getContext().getSetup().expandPath("{context}/correlation_plot.png");
plot.saveSnapshot(snapshotFile, "png");
JPanel panel = new JPanel();
GridBagLayout layout = new GridBagLayout();
layout.columnWidths = new int[]{0, 180}; //Minimum width
layout.rowHeights = new int[]{30, 30, 30}; //Minimum height
panel.setLayout(layout);
JComboBox comboLogbook = new JComboBox(new String[]{"SwissFEL commissioning data", "SwissFEL commissioning"});
JTextField textComment = new JTextField();
GridBagConstraints c = new GridBagConstraints();
c.gridx = 0;
c.gridy = 0;
panel.add(new JLabel("Logbook:"), c);
c.gridy = 1;
panel.add(new JLabel("Comment:"), c);
c.fill = GridBagConstraints.HORIZONTAL;
c.gridx = 1;
panel.add(textComment, c);
c.gridy = 0;
panel.add(comboLogbook, c);
if (SwingUtils.showOption(getTopLevel(), "ELOG", panel, OptionType.OkCancel) == OptionResult.Yes) {
StringBuilder message = new StringBuilder();
message.append("Device X: ").append(String.valueOf(textDevX.getText())).append("\n");
message.append("Device Y: ").append(String.valueOf(textDevY.getText())).append("\n");
message.append("Interval: ").append(String.valueOf(spinnerInterval.getValue())).append("\n");
message.append("Samples: ").append(String.valueOf(spinnerWindow.getValue())).append("\n");
message.append("Correlation: ").append(textCorrelation.getText()).append("\n");
message.append("Linear fit: ").append(textLinear.getText()).append("\n");
message.append("Quadratic fit: ").append(textQuadratic.getText()).append("\n");
message.append("Peak: ").append(textPeak.getText()).append("\n");
message.append("Comment: ").append(textComment.getText()).append("\n");
elog((String) comboLogbook.getSelectedItem(), "Correlation Panel Snapshot", message.toString(), new String[]{snapshotFile});
}
}catch (Exception ex){
showException(ex);
}
}//GEN-LAST:event_buttonElogActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonElog;
private javax.swing.JButton buttonStart;
private javax.swing.JCheckBox checkAlign;
private javax.swing.JCheckBox checkLinear;
private javax.swing.JCheckBox checkQuadratic;
private javax.swing.JComboBox comboTypeX;
private javax.swing.JComboBox comboTypeY;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JPanel jPanel1;
private ch.psi.pshell.plot.LinePlotJFree plot;
private javax.swing.JSpinner spinnerInterval;
private javax.swing.JSpinner spinnerWindow;
private javax.swing.JTextField textCorrelation;
private ch.psi.pshell.swing.ChannelSelector textDevX;
private ch.psi.pshell.swing.ChannelSelector textDevY;
private javax.swing.JTextField textLinear;
private javax.swing.JTextField textPeak;
private javax.swing.JTextField textQuadratic;
// End of variables declaration//GEN-END:variables
}

252
correlation/script/correlation.py Executable file
View File

@@ -0,0 +1,252 @@
import math
import sys, traceback
from mathutils import fit_polynomial, PolynomialFunction, calculate_peaks
from plotutils import plot_line, plot_function
from ch.psi.pshell.swing.Shell import getColorStdout
import org.apache.commons.math3.stat.correlation.PearsonsCorrelation as PearsonsCorrelation
try:
import ch.psi.pshell.bs.StreamMerger as StreamMerger
except:
merge_camera_stream = False
TYPE_CHANNEL = 0
TYPE_STREAM = 1
TYPE_CAMERA= 2
INVOKE_PLOT_UPDATES = True
if get_exec_pars().source == CommandSource.ui:
#dx = "SINEG01-DICT215:B1_CHARGE" ; dxtype = TYPE_CHANNEL
dx=get_beam_ok_channel(1) ; dxtype = TYPE_STREAM
#dx = "SLG-LCAM-C042 x_rms" ; dxtype = TYPE_CAMERA
#dy = "SINDI01-RLLE-STA:SLAVE1-DLTIMER" ; dytype = TYPE_CHANNEL
dy = "SATES31-CAMS187-RIXS1_sp intensity" ; dytype = TYPE_CAMERA
#dy=get_beam_ok_channel(2) ; dytype = TYPE_STREAM
interval = 0.01
window = 40
p = plot(None)[0]
linear_fit = True
quadratic_fit = True
merge_camera_stream = True
print dx, dxtype
print dy, dytype
corr = None
pars_lin = None
pars_quad = None
pos_peak = None
neg_peak = None
stop_exec = None
bs = TYPE_STREAM in [dxtype, dytype]
for s in p.getAllSeries():
p.removeSeries(s)
_stream = None
_camname = None
instances = []
def _get_device(d, type):
global _stream, _camname
egu = None
if isinstance(d, basestring):
name = d.strip()
d = None
try:
d = get_device(name)
if d is None:
d = eval(name)
#print name
if d is not None:
if not isinstance(r, Device):
d = None
else:
try:
egu = d.unit
except:
pass
except:
pass
if d is None:
offset = 0
if type==TYPE_STREAM:
if " " in name:
tokens = name.split(" ")
name = tokens[0]
offset = int(tokens[1])
if _stream == None:
_stream = Stream("corr_stream", dispatcher)
instances.append(_stream)
#d = _stream.addScalar(name, name, int(interval*100), offset)
_stream.addScalar(name, name, int(interval*100), offset)
d=name
elif type==TYPE_CHANNEL:
d = Channel(name)
d.set_monitored(True)
elif type==TYPE_CAMERA:
tokens = name.split(" ")
_camname = tokens[0]
field = tokens[1]
return field, ""
else:
raise Exception("Invalid type: " + str(type))
if not isinstance(d, basestring):
instances.append(d)
try:
if type==TYPE_CHANNEL:
egu = caget(name+".EGU",'s')
except:
pass
else:
try:
egu = d.unit
except:
pass
return d, egu
dx, egux = _get_device(dx, dxtype)
dy, eguy = _get_device(dy, dytype)
p.getAxis(p.AxisId.X).setLabel(egux)
p.getAxis(p.AxisId.Y).setLabel(eguy)
merge = False
try:
if _stream != None:
_stream.initialize()
_stream.start(True)
if _camname != None:
shared = _camname.endswith("_sp")
print "Camera: " , _camname, " shared: ", shared
cam_server.start(_camname, shared )
cam_server.stream.waitCacheChange(10000);
_camera_stream = cam_server.stream
if merge_camera_stream:
merge = ((dxtype==TYPE_CAMERA) and (dytype == TYPE_STREAM)) or ((dxtype==TYPE_STREAM) and (dytype == TYPE_CAMERA))
if merge:
print "Merging dispatcher and camera streams"
_merger = StreamMerger("stream", _stream, cam_server.stream)
_merger.monitored=True
_merger.start()
_camera_stream.setBufferCapacity(500)
_stream.setBufferCapacity(500)
instances.append(_merger)
_merger.waitCacheChange(5000)
#print _merger.readables
_camera_stream=_merger
_stream = _merger
if dxtype==TYPE_CAMERA:
dx=_camera_stream.getChild(dx)
if dytype==TYPE_CAMERA:
dy=_camera_stream.getChild(dy)
if dxtype==TYPE_STREAM:
dx=_stream.getChild(dx)
if dytype==TYPE_STREAM:
dy=_stream.getChild(dy)
p.addSeries(LinePlotSeries("Data"))
sd=p.getSeries(0)
sd.setLinesVisible(False)
sd.setPointSize(4)
if get_exec_pars().source == CommandSource.ui:
if globals().has_key("marker"):
p.removeMarker(marker)
if globals().has_key("peak_marker"):
p.removeMarker(peak_marker)
marker=None
peak_marker=None
while(True):
#Sample and plot data
if bs == True:
_stream.waitCacheChange(10000)
#bsdata = list(_stream.take().values())
x=dx.read()
y=dy.read()
def update():
global marker, peak_marker, corr, pars_lin, pars_quad, pos_peak, neg_peak, stop_exec
sd.appendData(x, y)
if len(sd.x) > window:
#Remove First Element
sd.token.remove(0)
ax = sd.x
ay = sd.y
if len(ax)>2:
x1, x2 = min(ax), max(ax)
res = (x2-x1)/100
if x1!=x2:
#Display correlation
corr= PearsonsCorrelation().correlation(to_array(ax,'d'), to_array(ay,'d'))
s = "Correlation=" + str(round(corr,4))
#print s
if get_exec_pars().source == CommandSource.ui:
if marker is not None:
p.removeMarker(marker)
marker = p.addMarker(x2+res, p.AxisId.X, s, p.getBackground())
marker.setLabelPaint(getColorStdout())
if linear_fit:
#Calculate, print and plot linear fit
pars_lin = (a0,a1) = fit_polynomial(ay, ax, 1)
#print "Fit lin a1:" , a1, " a0:",a0
y1 = poly(x1, pars_lin)
y2 = poly(x2, pars_lin)
plot_line(p, x1, y1, x2, y2, width = 2, color = Color.BLUE, name = "Fit Linear")
if quadratic_fit:
#Calculate, print and plot quadratic fit
pars_quad = (a0,a1,a2) = fit_polynomial(ay, ax, 2)
#print "Fit quad a2:" , a2, "a1:" , a1, " a0:",a0
fitted_quad_function = PolynomialFunction(pars_quad)
ax = frange(x1, x2, res, True)
plot_function(p, fitted_quad_function, "Fit Quadratic", ax, color=Color.GREEN)
peak = None
peaks = calculate_peaks(fitted_quad_function, x1, x2, positive=True)
if len(peaks)>0:
peak = peaks[0]
pos_peak = str(round(peak,4))
peak_str = "Positive peak: " + pos_peak
else:
peaks = calculate_peaks(fitted_quad_function, x1, x2, positive=False)
if len(peaks)>0:
peak = peaks[0]
neg_peak = str(round(peak,4))
peak_str = "Negative peak: " + neg_peak
else:
pos_peak = neg_peak = None
if get_exec_pars().source == CommandSource.ui:
if peak_marker is not None:
p.removeMarker(peak_marker)
if peak is not None:
peak_marker = p.addMarker(peak, p.AxisId.X, peak_str, Color(0,128,0))
if INVOKE_PLOT_UPDATES:
invoke(update, False)
else:
update()
if stop_exec == True:
stop_exec = False
break
if bs != True:
time.sleep(interval)
except KeyboardInterrupt:
pass
finally:
for dev in instances:
try:
dev.close()
except:
pass
if _camname != None:
cam_server.stop()

10
persplot/build.gradle Normal file
View File

@@ -0,0 +1,10 @@
description = 'persplot'
ext.mainClass = hasProperty('mainClass') ? mainClass : 'ch.psi.pshell.workbench.App'
ext.title = 'PersPlot'
ext.desc = 'PersPlot'
dependencies {
implementation 'ch.psi:pshell-workbench:' + version
}
createDefaultTasks(project)

View File

@@ -0,0 +1 @@
action.debug.args=debug --args="-b -d -l -k -n -q -console_log=SEVERE -p PersistencePlot -laf=dark -epics_config ch.psi.jcae.ContextFactory.addressList=localhost:54321"

11
persplot/persplot Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/bash
/opt/gfa/pshell/pshell \
-z -sbar -clog=INFO -d -q -n \
-p=/opt/gfa/pshell/apps/persplot/PersistencePlot.java \
-laf=dark \
-last \
${1+"$@"}
~

View File

@@ -0,0 +1,6 @@
#!/bin/sh
APP_ARGS_NAME=\$(echo "APP_${app_name}" | tr '[:lower:]' '[:upper:]')_ARGS
APP_ARGS_NAME=\${APP_ARGS_NAME//-/_}
# Run the JAR with all passed arguments
exec pshell-workbench -b -d -l -k -n -q -console_log=SEVERE -p ${java_file} \${!APP_ARGS_NAME} "\$@"

View File

@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="plot" alignment="1" pref="508" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="channelSelector" max="32767" attributes="0"/>
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
<Component id="buttonStart" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="buttonStop" linkSize="1" min="-2" 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="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel1" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="channelSelector" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="buttonStart" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="buttonStop" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="plot" pref="341" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="ch.psi.pshell.plot.LinePlotJFree" name="plot">
</Component>
<Component class="ch.psi.pshell.swing.ChannelSelector" name="channelSelector">
<Properties>
<Property name="historySize" type="int" value="20"/>
<Property name="name" type="java.lang.String" value="Correlation_textDevX" noResource="true"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonStart">
<Properties>
<Property name="text" type="java.lang.String" value="Start"/>
<Property name="enabled" type="boolean" value="false"/>
</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="buttonStop">
<Properties>
<Property name="text" type="java.lang.String" value="Stop"/>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonStopActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Channel:"/>
</Properties>
</Component>
</SubComponents>
</Form>

View File

@@ -0,0 +1,279 @@
import ch.psi.pshell.device.Device;
import ch.psi.pshell.device.DeviceListener;
import static ch.psi.pshell.device.Record.SIZE_VALID;
import static ch.psi.pshell.device.Record.UNDEFINED_PRECISION;
import ch.psi.pshell.epics.ChannelDoubleArray;
import ch.psi.pshell.framework.App;
import ch.psi.pshell.framework.Panel;
import ch.psi.pshell.plot.LinePlotSeries;
import ch.psi.pshell.plot.Plot;
import ch.psi.pshell.swing.ChannelSelector;
import ch.psi.pshell.utils.State;
import java.awt.Color;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.SwingUtilities;
/**
*
*/
public class PersistencePlot extends Panel{
ChannelDoubleArray channel;
LinePlotSeries series;
LinePlotSeries seriesMax;
LinePlotSeries seriesMin;
boolean started;
double[] max;
double[] min;
double[] last;
boolean permanent;
public PersistencePlot() {
initComponents();
plot.setTitle(null);
plot.getAxis(Plot.AxisId.X).setLabel(null);
plot.getAxis(Plot.AxisId.Y).setLabel(null);
plot.setLegendVisible(true);
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
channelSelector.configure(ChannelSelector.Type.Epics, "http://epics-boot-info.psi.ch", "sls", 3000);
if (App.hasArgument("channel")){
channelSelector.setText(App.getArgumentValue("channel"));
}
if (App.hasArgument("start")){
buttonStartActionPerformed(null);
}
startTimer(500);
}
@Override
public void onStateChange(State state, State former) {
updateButtons();
}
@Override
public void onExecutedFile(String fileName, Object result) {
}
//Callback to perform update - in event thread
@Override
protected void doUpdate() {
}
final Object lock = new Object();
volatile boolean updated;
@Override
protected void onTimer() {
if (started){
synchronized(lock){
if (updated){
series.setData(last);
seriesMax.setData(max);
seriesMin.setData(min);
if (permanent){
//LinePlotSeries series = new LinePlotSeries("", Color.RED.darker().darker());
//plot.addSeries(series);
//series.setPointsVisible(false);
}
updated = false;
}
}
}
}
void updateButtons(){
boolean initialized = getState().isInitialized();
buttonStart.setEnabled(initialized && !started);
buttonStop.setEnabled(initialized && started);
channelSelector.setEnabled(initialized && !started);
}
final DeviceListener deviceListener = new DeviceListener() {
@Override
public void onCacheChanged(Device device, Object value, Object former, long timestamp, boolean valueChange) {
try{
onData((double[]) value);
} catch (Exception ex){
Logger.getLogger(PersistencePlot.class.getName()).log(Level.WARNING, null, ex);
}
}
};
void onData(double[] data){
if (data.length!=last.length){
stop();
showMessage("Error", "Waveforme size changed: stopping plot");
}
synchronized(lock){
for (int i=0; i< data.length;i++){
double value = data[i];
if (value>max[i]){
max[i]=value;
}
if (value<min[i]){
min[i]=value;
}
}
last=data;
updated = true;
}
}
void start(String channelName){
stop();
clear();
try {
series = new LinePlotSeries(channelName, Color.RED.darker().darker());
seriesMax = new LinePlotSeries(channelName + " max", Color.RED);
seriesMin = new LinePlotSeries(channelName + " min", Color.RED.darker());
plot.addSeries(series);
plot.addSeries(seriesMax);
plot.addSeries(seriesMin);
series.setPointsVisible(false);
channel = new ChannelDoubleArray(channelName, channelName,UNDEFINED_PRECISION, SIZE_VALID);
channel.initialize();
last = channel.read();
max = new double[last.length];
min = new double[last.length];
System.arraycopy(last, 0, max, 0, last.length);
System.arraycopy(last, 0, min, 0, last.length);
channel.setMonitored(true);
channel.addListener(deviceListener);
onData(last);
started = true;
} catch (Exception ex) {
Logger.getLogger(PersistencePlot.class.getName()).warning("Error starting plot: " + ex.getMessage());
} finally{
updateButtons();
}
}
void stop(){
try{
if (started){
if (channel != null){
channel.removeListener(deviceListener);
if (SwingUtilities.isEventDispatchThread()){
channel.close();
} else {
SwingUtilities.invokeLater(()->{
channel.close();
});
}
}
}
} finally{
started = false;
updateButtons();
}
}
void clear(){
try {
plot.clear();
} catch (Exception ex) {
Logger.getLogger(PersistencePlot.class.getName()).log(Level.WARNING, null, ex);
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
plot = new ch.psi.pshell.plot.LinePlotJFree();
channelSelector = new ch.psi.pshell.swing.ChannelSelector();
buttonStart = new javax.swing.JButton();
buttonStop = new javax.swing.JButton();
jLabel1 = new javax.swing.JLabel();
channelSelector.setHistorySize(20);
channelSelector.setName("Correlation_textDevX"); // NOI18N
buttonStart.setText("Start");
buttonStart.setEnabled(false);
buttonStart.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonStartActionPerformed(evt);
}
});
buttonStop.setText("Stop");
buttonStop.setEnabled(false);
buttonStop.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonStopActionPerformed(evt);
}
});
jLabel1.setText("Channel:");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(plot, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 508, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(channelSelector, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(buttonStart)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonStop)
.addContainerGap())
);
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonStart, buttonStop});
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel1)
.addComponent(channelSelector, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonStart)
.addComponent(buttonStop))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, 341, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void buttonStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStartActionPerformed
try{
//setChannel( "ALIRF-A1-KLYDCP10:REF-POWER");
start(channelSelector.getText());
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonStartActionPerformed
private void buttonStopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonStopActionPerformed
try{
stop();
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonStopActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonStart;
private javax.swing.JButton buttonStop;
private ch.psi.pshell.swing.ChannelSelector channelSelector;
private javax.swing.JLabel jLabel1;
private ch.psi.pshell.plot.LinePlotJFree plot;
// End of variables declaration//GEN-END:variables
}

View File

@@ -0,0 +1,31 @@
#!/bin/bash
MY_PATH=$(dirname "$0")
export PKG=${MY_PATH}/..
#Check if running as e-account
for i in "$@"
do
case $i in
-pkg=*)
export PKG="${i#*=}"
;;
*) # unknown option
;;
esac
done
/opt/gfa/pshell/pshell \
-version=default \
-py3 \
-m=${PKG} \
-z \
-nbcf=true \
-laf=dark \
-d \
-pini=true \
-clog=WARNING \
-sbar \
$@

View File

@@ -0,0 +1,33 @@
#!/bin/bash
MY_PATH=$(dirname "$0")
export PKG=${MY_PATH}/..
#Check if running as e-account
for i in "$@"
do
case $i in
-pkg=*)
export PKG="${i#*=}"
;;
*) # unknown option
;;
esac
done
/opt/gfa/pshell/pshell \
-version=default \
-z \
-py3 \
-nbcf=true \
-laf=dark \
-pini=true \
-plgp=${PKG}/plugins \
-scpt=${PKG}/script \
-devp=${PKG}/devices \
-pool=${PKG}/config/devices.properties \
-p=Correlation.java \
$@

View File

@@ -0,0 +1,16 @@
psss_fwhm_avg=ch.psi.pshell.epics.ChannelDouble|SARFE10-PSSS059:REL-E-SPREAD|||true
dispatcher=ch.psi.pshell.bs.Dispatcher|https://dispatcher-api.psi.ch/sf|||
cam_server=ch.psi.pshell.bs.PipelineServer|sf-daqsync-01:8889|||
energy_machine=ch.psi.pshell.epics.ChannelDouble|SARFE10-PBPG050:ENERGY|||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_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

View File

@@ -0,0 +1,12 @@
#Mon Feb 22 20:35:07 CET 2021
ch.psi.jcae.ContextFactory.addressList=
ch.psi.jcae.ContextFactory.serverPort=
ch.psi.jcae.ContextFactory.maxArrayBytes=50000000
ch.psi.jcae.ChannelFactory.retries=1
ch.psi.jcae.ChannelFactory.timeout=1250
ch.psi.jcae.impl.DefaultChannelService.retries=4
ch.psi.jcae.impl.DefaultChannelService.timeout=1000
ch.psi.jcae.ContextFactory.autoAddressList=true
ch.psi.jcae.ContextFactory.useShellVariables=true
ch.psi.jcae.ContextFactory.addLocalBroadcastInterfaces=false
ch.psi.jcae.ContextFactory.maxSendArrayBytes=1000000

View File

@@ -0,0 +1,25 @@
#Mon Jan 17 16:00:40 CET 2022
spatialCalOffsetY=-50.02549719530852
spatialCalOffsetX=-50.01953888237593
colormapLogarithmic=false
scale=1.0
grayscale=false
spatialCalScaleX=-1.0
spatialCalScaleY=-1.0
colormapMax=255.0
rescaleOffset=0.0
roiWidth=-1
colormap=Temperature
invert=false
colormapMin=0.0
rotationCrop=false
rotation=0.0
rescaleFactor=1.0
spatialCalUnits=mm
flipVertically=false
roiHeight=-1
flipHorizontally=false
colormapAutomatic=true
roiY=0
roiX=0
transpose=false

View File

@@ -0,0 +1,13 @@
#Wed Jun 03 18:45:57 CEST 2020
sendStrategy=complete_all
dropIncomplete=false
keepListeningOnStop=false
disableCompression=false
parallelHandlerProcessing=true
sendBuildChannelConfig=at_startup
sendAwaitFirstMessage=false
socketType=DEFAULT
validationInconsistency=keep_as_is
byteBufferAllocator=false
mappingIncomplete=fill_null
sendSyncTimeout=0

View File

@@ -0,0 +1,6 @@
#Tue Jun 15 11:03:15 CEST 2021
bins=1000
min=11400.0
max=11200.0
precision=-1
numberOfSamples=10000

View File

@@ -0,0 +1,6 @@
#Fri Apr 30 07:45:13 CEST 2021
bins=1000
min=0.0
max=40.0
precision=-1
numberOfSamples=10000

View File

@@ -0,0 +1,4 @@
#Mon May 03 09:21:35 CEST 2021
measures=10
precision=-1
interval=-1

View File

@@ -0,0 +1,4 @@
#Mon May 03 09:21:52 CEST 2021
measures=10
precision=-1
interval=-1

View File

@@ -0,0 +1,5 @@
#Mon May 03 09:15:04 CEST 2021
measures=10
precision=-1
interval=-1
integrate=false

View File

@@ -0,0 +1,715 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<NonVisualComponents>
<Component class="javax.swing.ButtonGroup" name="buttonGroup1">
</Component>
</NonVisualComponents>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="tab" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="tab" alignment="1" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JTabbedPane" name="tab">
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="tabStateChanged"/>
</Events>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel1">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Spectrum">
<Property name="tabTitle" type="java.lang.String" value="Spectrum"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace 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"/>
</Group>
<Component id="history" alignment="0" pref="453" max="32767" attributes="0"/>
<Component id="plot" alignment="0" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="12" pref="12" max="-2" attributes="0"/>
<Component id="histogramGeneratorFwhm" min="-2" pref="372" max="-2" attributes="0"/>
</Group>
<Component id="histogramGeneratorPanelCenter" alignment="0" min="-2" pref="372" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" 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="spinnerAverage" 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">
<Component id="histogramGeneratorPanelCenter" alignment="0" pref="194" max="32767" attributes="0"/>
<Component id="plot" alignment="0" pref="0" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="history" pref="194" max="32767" attributes="0"/>
<Component id="histogramGeneratorFwhm" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="ch.psi.pshell.plot.LinePlotJFree" name="plot">
<Properties>
<Property name="title" type="java.lang.String" value=""/>
</Properties>
</Component>
<Component class="ch.psi.pshell.plot.TimePlotJFree" name="history">
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Average:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerAverage">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="1" maximum="100" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spinnerAverageStateChanged"/>
</Events>
</Component>
<Component class="ch.psi.pshell.swing.HistogramGeneratorPanel" name="histogramGeneratorPanelCenter">
<Properties>
<Property name="deviceName" type="java.lang.String" value="histo_center"/>
</Properties>
</Component>
<Component class="ch.psi.pshell.swing.HistogramGeneratorPanel" name="histogramGeneratorFwhm">
<Properties>
<Property name="deviceName" type="java.lang.String" value="histo_fwhm"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel4">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Camera">
<Property name="tabTitle" type="java.lang.String" value="Camera"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<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>
</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>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="ch.psi.pshell.imaging.Renderer" name="renderer">
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel3">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Alignment">
<Property name="tabTitle" type="java.lang.String" value="Alignment"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
<Component id="plotScan" pref="614" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<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"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel2">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="jPanel5" alignment="0" max="32767" attributes="0"/>
<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"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
<Component id="radioEnergyScan" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="radioCameraScan" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="radioCrystalScan" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jPanel5" max="32767" attributes="0"/>
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Component id="btAbort" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="btAbort">
<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="btAbortActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JRadioButton" name="radioEnergyScan">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup1"/>
</Property>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Energy Scan"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="radioEnergyScanActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JRadioButton" name="radioCameraScan">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup1"/>
</Property>
<Property name="text" type="java.lang.String" value="Camera Scan"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="radioCameraScanActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JRadioButton" name="radioCrystalScan">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttonGroup1"/>
</Property>
<Property name="text" type="java.lang.String" value="Crystal Height Scan"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="radioCrystalScanActionPerformed"/>
</Events>
</Component>
<Container class="javax.swing.JPanel" name="jPanel5">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="panelScan" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="panelScan" max="32767" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="panelScan">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignCardLayout"/>
<SubComponents>
<Container class="javax.swing.JPanel" name="panelEnergyScan">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription">
<CardConstraints cardName="energy"/>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel7" linkSize="7" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spToEn" linkSize="8" min="-2" pref="80" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel6" linkSize="7" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spFromEn" linkSize="8" min="-2" pref="80" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel8" linkSize="7" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spStepsEn" linkSize="8" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel9" linkSize="7" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spShotsEn" linkSize="8" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Component id="btStartEn" alignment="1" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spFromEn" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spToEn" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spStepsEn" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spShotsEn" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Component id="btStartEn" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JSpinner" name="spFromEn">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="7200.0" maximum="20000.0" minimum="1.0" numberType="java.lang.Double" stepSize="10.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Range From:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel7">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Range To:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spToEn">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="7340.0" maximum="20000.0" minimum="1.0" numberType="java.lang.Double" stepSize="10.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spStepsEn">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="20" maximum="1000" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel8">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Steps:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel9">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Num Shots:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spShotsEn">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="100" maximum="1000" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="btStartEn">
<Properties>
<Property name="text" type="java.lang.String" value="Start Energy Scan"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btStartEnActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelCameraScan">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription">
<CardConstraints cardName="camera"/>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel11" linkSize="10" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spToCam" linkSize="11" min="-2" pref="80" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel10" linkSize="10" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spFromCam" linkSize="11" min="-2" pref="80" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel12" linkSize="10" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spStepsCam" linkSize="11" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel13" linkSize="10" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spShotsCam" linkSize="11" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Component id="btStartCam" alignment="0" max="32767" attributes="0"/>
</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="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spFromCam" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel11" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spToCam" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel12" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spStepsCam" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel13" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spShotsCam" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Component id="btStartCam" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel10">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Range From:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spFromCam">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="-17.0" maximum="30.0" minimum="-30.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel11">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Range To:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spToCam">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="-11.0" maximum="30.0" minimum="-30.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel12">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Steps:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spStepsCam">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="20" maximum="1000" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel13">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Num Shots:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spShotsCam">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="100" maximum="1000" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="btStartCam">
<Properties>
<Property name="text" type="java.lang.String" value="Start Camera Scan"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btStartCamActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="panelCrystalScan">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignCardLayout" value="org.netbeans.modules.form.compat2.layouts.DesignCardLayout$CardConstraintsDescription">
<CardConstraints cardName="crystal"/>
</Constraint>
</Constraints>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel3" linkSize="6" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spToCr" linkSize="9" min="-2" pref="80" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel2" linkSize="6" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spFromCr" linkSize="9" min="-2" pref="80" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel4" linkSize="6" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spStepsCr" linkSize="9" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel5" linkSize="6" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spShotsCr" linkSize="9" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Component id="btStartCr" alignment="0" max="32767" attributes="0"/>
</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="spFromCr" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spToCr" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spStepsCr" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spShotsCr" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Component id="btStartCr" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Range From:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spFromCr">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="-0.8" maximum="10.0" minimum="-10.0" numberType="java.lang.Double" stepSize="0.1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Range To:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spToCr">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="-1.7" maximum="10.0" minimum="-10.0" numberType="java.lang.Double" stepSize="0.1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Steps:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spStepsCr">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="20" maximum="1000" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Num Shots:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spShotsCr">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="100" maximum="1000" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="btStartCr">
<Properties>
<Property name="text" type="java.lang.String" value="Start Crystal Height Scan"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btStartCrActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>
<Component class="ch.psi.pshell.plot.LinePlotJFree" name="plotScan">
<Properties>
<Property name="title" type="java.lang.String" value=""/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@@ -0,0 +1,760 @@
import ch.psi.pshell.bs.PipelineServer;
import ch.psi.pshell.core.Context;
import ch.psi.pshell.epics.ChannelDouble;
import ch.psi.pshell.imaging.RendererMode;
import ch.psi.pshell.plot.Plot;
import ch.psi.pshell.plot.LinePlotJFree;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.Convert;
import ch.psi.utils.State;
import ch.psi.utils.Str;
import java.awt.CardLayout;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
*
*/
public class PSSS extends Panel {
final String CAMERA_NAME = "SARFE10-PSSS059";
PipelineServer pipelineServer;
volatile boolean updatingPlot;
volatile boolean updatingImage;
public PSSS() {
initComponents();
plot.getAxis(Plot.AxisId.X).setLabel(null);
plot.getAxis(Plot.AxisId.Y).setLabel(null);
renderer.setMode(RendererMode.Stretch);
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
startTimer(1000);
try {
setGlobalVar("PSSS_PLOT", plot);
setGlobalVar("HISTORY_PLOT", history);
setGlobalVar("PSSS_RENDERER", renderer);
pipelineServer = (PipelineServer) 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);
//setImageEnabled(true);
tabStateChanged(null);
spinnerAverage.setValue(( (Number) eval("get_psss_averaging()", true)).intValue());
try{
Double energy = (((ChannelDouble)getDevice("energy_machine")).take(-1));
energy=Convert.roundDouble(energy, 0);
spFromEn.setValue(energy-150);
spToEn.setValue(energy+150);
} catch (Exception ex) {
getLogger().warning("Error reading energy_machine");
}
} catch (Exception ex) {
getLogger().log(Level.WARNING, null, ex);
}
}
@Override
public void onStateChange(State state, State former) {
this.btStartCr.setEnabled(state == State.Ready);
this.btStartEn.setEnabled(state == State.Ready);
this.btStartCam.setEnabled(state == State.Ready);
radioEnergyScan.setEnabled(state == State.Ready);
radioCrystalScan.setEnabled(state == State.Ready);
radioCameraScan.setEnabled(state == State.Ready);
this.btAbort.setEnabled(state.isRunning());
}
@Override
public void onExecutedFile(String fileName, Object result) {
}
@Override
public void onTimer() {
try {
if (!updatingPlot){
updatingPlot = true;
//evalAsync("plot_psss(PSSS_PLOT, HISTORY_PLOT, " + spinnerAverage.getValue() + ")", true).handle((ret,ex)->{
evalAsync("plot_psss(PSSS_PLOT, HISTORY_PLOT)", true).handle((ret,ex)->{
updatingPlot = false;
return ret;
});
}
if (isImageEnabled()){
if (!updatingImage){
updatingImage = true;
evalAsync("update_psss_image(PSSS_RENDERER)", true).handle((ret,ex)->{
updatingImage = false;
return ret;
});
}
}
} catch (Exception ex) {
getLogger().log(Level.WARNING, null, ex);
}
}
//Callback to perform update - in event thread
@Override
protected void doUpdate() {
}
void setImageEnabled(boolean enabled){
try{
imageEnabled = enabled;
evalAsync("enable_psss_image(" + Str.capitalizeFirst(String.valueOf(enabled)) + ", PSSS_RENDERER)", true);
} catch (Exception ex) {
getLogger().log(Level.WARNING, null, ex);
}
}
volatile boolean imageEnabled;
boolean isImageEnabled(){
return imageEnabled;
}
void runScan(String name, Map args){
try {
args.put("PLOT", plotScan);
this.runAsync(name, args).handle((ret,ex)->{
if (ex!=null){
if (!getContext().isAborted()){
showException((Exception)ex);
}
}
return ret;
});
} catch (Context.ContextStateException ex) {
showException(ex);
}
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
tab = new javax.swing.JTabbedPane();
jPanel1 = new javax.swing.JPanel();
plot = new ch.psi.pshell.plot.LinePlotJFree();
history = new ch.psi.pshell.plot.TimePlotJFree();
jLabel1 = new javax.swing.JLabel();
spinnerAverage = new javax.swing.JSpinner();
histogramGeneratorPanelCenter = new ch.psi.pshell.swing.HistogramGeneratorPanel();
histogramGeneratorFwhm = new ch.psi.pshell.swing.HistogramGeneratorPanel();
jPanel4 = new javax.swing.JPanel();
renderer = new ch.psi.pshell.imaging.Renderer();
jPanel3 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
btAbort = new javax.swing.JButton();
radioEnergyScan = new javax.swing.JRadioButton();
radioCameraScan = new javax.swing.JRadioButton();
radioCrystalScan = new javax.swing.JRadioButton();
jPanel5 = new javax.swing.JPanel();
panelScan = new javax.swing.JPanel();
panelEnergyScan = new javax.swing.JPanel();
spFromEn = new javax.swing.JSpinner();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
spToEn = new javax.swing.JSpinner();
spStepsEn = new javax.swing.JSpinner();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
spShotsEn = new javax.swing.JSpinner();
btStartEn = new javax.swing.JButton();
panelCameraScan = new javax.swing.JPanel();
jLabel10 = new javax.swing.JLabel();
spFromCam = new javax.swing.JSpinner();
jLabel11 = new javax.swing.JLabel();
spToCam = new javax.swing.JSpinner();
jLabel12 = new javax.swing.JLabel();
spStepsCam = new javax.swing.JSpinner();
jLabel13 = new javax.swing.JLabel();
spShotsCam = new javax.swing.JSpinner();
btStartCam = new javax.swing.JButton();
panelCrystalScan = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
spFromCr = new javax.swing.JSpinner();
jLabel3 = new javax.swing.JLabel();
spToCr = new javax.swing.JSpinner();
jLabel4 = new javax.swing.JLabel();
spStepsCr = new javax.swing.JSpinner();
jLabel5 = new javax.swing.JLabel();
spShotsCr = new javax.swing.JSpinner();
btStartCr = new javax.swing.JButton();
plotScan = new ch.psi.pshell.plot.LinePlotJFree();
tab.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
tabStateChanged(evt);
}
});
plot.setTitle("");
jLabel1.setText("Average:");
spinnerAverage.setModel(new javax.swing.SpinnerNumberModel(1, 1, 100, 1));
spinnerAverage.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spinnerAverageStateChanged(evt);
}
});
histogramGeneratorPanelCenter.setDeviceName("histo_center");
histogramGeneratorFwhm.setDeviceName("histo_fwhm");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.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(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)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(12, 12, 12)
.addComponent(histogramGeneratorFwhm, javax.swing.GroupLayout.PREFERRED_SIZE, 372, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(histogramGeneratorPanelCenter, javax.swing.GroupLayout.PREFERRED_SIZE, 372, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(0, 0, 0))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.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))
.addGap(6, 6, 6)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(histogramGeneratorPanelCenter, javax.swing.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
.addComponent(plot, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(history, javax.swing.GroupLayout.DEFAULT_SIZE, 194, Short.MAX_VALUE)
.addComponent(histogramGeneratorFwhm, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)))
);
tab.addTab("Spectrum", jPanel1);
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))
);
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))
);
tab.addTab("Camera", jPanel4);
btAbort.setText("Abort");
btAbort.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btAbortActionPerformed(evt);
}
});
buttonGroup1.add(radioEnergyScan);
radioEnergyScan.setSelected(true);
radioEnergyScan.setText("Energy Scan");
radioEnergyScan.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
radioEnergyScanActionPerformed(evt);
}
});
buttonGroup1.add(radioCameraScan);
radioCameraScan.setText("Camera Scan");
radioCameraScan.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
radioCameraScanActionPerformed(evt);
}
});
buttonGroup1.add(radioCrystalScan);
radioCrystalScan.setText("Crystal Height Scan");
radioCrystalScan.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
radioCrystalScanActionPerformed(evt);
}
});
panelScan.setLayout(new java.awt.CardLayout());
spFromEn.setModel(new javax.swing.SpinnerNumberModel(7200.0d, 1.0d, 20000.0d, 10.0d));
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel6.setText("Range From:");
jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel7.setText("Range To:");
spToEn.setModel(new javax.swing.SpinnerNumberModel(7340.0d, 1.0d, 20000.0d, 10.0d));
spStepsEn.setModel(new javax.swing.SpinnerNumberModel(20, 1, 1000, 1));
jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel8.setText("Steps:");
jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel9.setText("Num Shots:");
spShotsEn.setModel(new javax.swing.SpinnerNumberModel(100, 1, 1000, 1));
btStartEn.setText("Start Energy Scan");
btStartEn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btStartEnActionPerformed(evt);
}
});
javax.swing.GroupLayout panelEnergyScanLayout = new javax.swing.GroupLayout(panelEnergyScan);
panelEnergyScan.setLayout(panelEnergyScanLayout);
panelEnergyScanLayout.setHorizontalGroup(
panelEnergyScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelEnergyScanLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(panelEnergyScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelEnergyScanLayout.createSequentialGroup()
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spToEn, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(panelEnergyScanLayout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spFromEn, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(panelEnergyScanLayout.createSequentialGroup()
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spStepsEn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(panelEnergyScanLayout.createSequentialGroup()
.addComponent(jLabel9)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spShotsEn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
.addComponent(btStartEn, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
panelEnergyScanLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel6, jLabel7, jLabel8, jLabel9});
panelEnergyScanLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spFromEn, spShotsEn, spStepsEn, spToEn});
panelEnergyScanLayout.setVerticalGroup(
panelEnergyScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelEnergyScanLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelEnergyScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(spFromEn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelEnergyScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel7)
.addComponent(spToEn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelEnergyScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel8)
.addComponent(spStepsEn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelEnergyScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel9)
.addComponent(spShotsEn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btStartEn)
.addContainerGap())
);
panelScan.add(panelEnergyScan, "energy");
jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel10.setText("Range From:");
spFromCam.setModel(new javax.swing.SpinnerNumberModel(-17.0d, -30.0d, 30.0d, 1.0d));
jLabel11.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel11.setText("Range To:");
spToCam.setModel(new javax.swing.SpinnerNumberModel(-11.0d, -30.0d, 30.0d, 1.0d));
jLabel12.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel12.setText("Steps:");
spStepsCam.setModel(new javax.swing.SpinnerNumberModel(20, 1, 1000, 1));
jLabel13.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel13.setText("Num Shots:");
spShotsCam.setModel(new javax.swing.SpinnerNumberModel(100, 1, 1000, 1));
btStartCam.setText("Start Camera Scan");
btStartCam.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btStartCamActionPerformed(evt);
}
});
javax.swing.GroupLayout panelCameraScanLayout = new javax.swing.GroupLayout(panelCameraScan);
panelCameraScan.setLayout(panelCameraScanLayout);
panelCameraScanLayout.setHorizontalGroup(
panelCameraScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelCameraScanLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelCameraScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelCameraScanLayout.createSequentialGroup()
.addComponent(jLabel11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spToCam, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(panelCameraScanLayout.createSequentialGroup()
.addComponent(jLabel10)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spFromCam, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(panelCameraScanLayout.createSequentialGroup()
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spStepsCam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(panelCameraScanLayout.createSequentialGroup()
.addComponent(jLabel13)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spShotsCam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(btStartCam, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
panelCameraScanLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel10, jLabel11, jLabel12, jLabel13});
panelCameraScanLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spFromCam, spShotsCam, spStepsCam, spToCam});
panelCameraScanLayout.setVerticalGroup(
panelCameraScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelCameraScanLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelCameraScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel10)
.addComponent(spFromCam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelCameraScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11)
.addComponent(spToCam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelCameraScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel12)
.addComponent(spStepsCam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelCameraScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel13)
.addComponent(spShotsCam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btStartCam)
.addContainerGap())
);
panelScan.add(panelCameraScan, "camera");
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel2.setText("Range From:");
spFromCr.setModel(new javax.swing.SpinnerNumberModel(-0.8d, -10.0d, 10.0d, 0.1d));
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel3.setText("Range To:");
spToCr.setModel(new javax.swing.SpinnerNumberModel(-1.7d, -10.0d, 10.0d, 0.1d));
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel4.setText("Steps:");
spStepsCr.setModel(new javax.swing.SpinnerNumberModel(20, 1, 1000, 1));
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel5.setText("Num Shots:");
spShotsCr.setModel(new javax.swing.SpinnerNumberModel(100, 1, 1000, 1));
btStartCr.setText("Start Crystal Height Scan");
btStartCr.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btStartCrActionPerformed(evt);
}
});
javax.swing.GroupLayout panelCrystalScanLayout = new javax.swing.GroupLayout(panelCrystalScan);
panelCrystalScan.setLayout(panelCrystalScanLayout);
panelCrystalScanLayout.setHorizontalGroup(
panelCrystalScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelCrystalScanLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelCrystalScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelCrystalScanLayout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spToCr, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(panelCrystalScanLayout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spFromCr, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(panelCrystalScanLayout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spStepsCr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(panelCrystalScanLayout.createSequentialGroup()
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spShotsCr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(btStartCr, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
panelCrystalScanLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel2, jLabel3, jLabel4, jLabel5});
panelCrystalScanLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {spFromCr, spShotsCr, spStepsCr, spToCr});
panelCrystalScanLayout.setVerticalGroup(
panelCrystalScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelCrystalScanLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelCrystalScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(spFromCr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelCrystalScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(spToCr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelCrystalScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(spStepsCr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(panelCrystalScanLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(spShotsCr, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(btStartCr)
.addContainerGap())
);
panelScan.add(panelCrystalScan, "crystal");
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(panelScan, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)))
);
jPanel5Layout.setVerticalGroup(
jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel5Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(panelScan, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGap(0, 0, 0)))
);
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(12, 12, 12)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(radioCrystalScan)
.addComponent(radioCameraScan)
.addComponent(radioEnergyScan)
.addComponent(btAbort, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(radioEnergyScan)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(radioCameraScan)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(radioCrystalScan)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(btAbort)
.addContainerGap())
);
plotScan.setTitle("");
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 0)
.addComponent(plotScan, javax.swing.GroupLayout.DEFAULT_SIZE, 614, Short.MAX_VALUE))
);
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)
);
tab.addTab("Alignment", jPanel3);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tab)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(tab, javax.swing.GroupLayout.Alignment.TRAILING)
);
}// </editor-fold>//GEN-END:initComponents
private void tabStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_tabStateChanged
setImageEnabled(tab.getSelectedIndex()==1);
}//GEN-LAST:event_tabStateChanged
private void btAbortActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btAbortActionPerformed
try {
abort();
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_btAbortActionPerformed
private void btStartCrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btStartCrActionPerformed
Map args = new HashMap();
args.put("RANGE_FROM", spFromCr.getValue());
args.put("RANGE_TO", spToCr.getValue());
args.put("STEPS", spStepsCr.getValue());
args.put("NUM_SHOTS", spShotsCr.getValue());
runScan("psss/CrystalHeightScan",args);
}//GEN-LAST:event_btStartCrActionPerformed
private void btStartCamActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btStartCamActionPerformed
Map args = new HashMap();
args.put("RANGE_FROM", spFromCam.getValue());
args.put("RANGE_TO", spToCam.getValue());
args.put("STEPS", spStepsCam.getValue());
args.put("NUM_SHOTS", spShotsCam.getValue());
runScan("psss/CameraScan",args);
}//GEN-LAST:event_btStartCamActionPerformed
private void btStartEnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btStartEnActionPerformed
Map args = new HashMap();
args.put("RANGE_OFF", null);
args.put("RANGE_FROM", spFromEn.getValue());
args.put("RANGE_TO", spToEn.getValue());
args.put("STEPS", spStepsEn.getValue());
args.put("NUM_SHOTS", spShotsEn.getValue());
runScan("psss/EnergyScan",args);
}//GEN-LAST:event_btStartEnActionPerformed
private void radioEnergyScanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioEnergyScanActionPerformed
((CardLayout)panelScan.getLayout()).show(panelScan, "energy");
}//GEN-LAST:event_radioEnergyScanActionPerformed
private void radioCameraScanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioCameraScanActionPerformed
((CardLayout)panelScan.getLayout()).show(panelScan, "camera");
}//GEN-LAST:event_radioCameraScanActionPerformed
private void radioCrystalScanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_radioCrystalScanActionPerformed
((CardLayout)panelScan.getLayout()).show(panelScan, "crystal");
}//GEN-LAST:event_radioCrystalScanActionPerformed
private void spinnerAverageStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spinnerAverageStateChanged
try {
eval("set_psss_averaging(" + spinnerAverage.getValue() + ")", true);
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_spinnerAverageStateChanged
// 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 ch.psi.pshell.swing.HistogramGeneratorPanel histogramGeneratorFwhm;
private ch.psi.pshell.swing.HistogramGeneratorPanel histogramGeneratorPanelCenter;
private ch.psi.pshell.plot.TimePlotJFree history;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel4;
private javax.swing.JPanel jPanel5;
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 plotScan;
private javax.swing.JRadioButton radioCameraScan;
private javax.swing.JRadioButton radioCrystalScan;
private javax.swing.JRadioButton radioEnergyScan;
private ch.psi.pshell.imaging.Renderer renderer;
private javax.swing.JSpinner spFromCam;
private javax.swing.JSpinner spFromCr;
private javax.swing.JSpinner spFromEn;
private javax.swing.JSpinner spShotsCam;
private javax.swing.JSpinner spShotsCr;
private javax.swing.JSpinner spShotsEn;
private javax.swing.JSpinner spStepsCam;
private javax.swing.JSpinner spStepsCr;
private javax.swing.JSpinner spStepsEn;
private javax.swing.JSpinner spToCam;
private javax.swing.JSpinner spToCr;
private javax.swing.JSpinner spToEn;
private javax.swing.JSpinner spinnerAverage;
private javax.swing.JTabbedPane tab;
// End of variables declaration//GEN-END:variables
}

View File

@@ -0,0 +1,45 @@
import numpy as np
from scipy.optimize import curve_fit
import sys
def gaus(x, a, x0, sigma, offset):
return offset + a * np.exp(-(x - x0) ** 2 / (2 * sigma ** 2))
#Return [amp, mean_val, sigma, offset]
def fit_energy(e_from, e_to, steps, num_shots, data):
energy_range = np.linspace(e_from, e_to, steps)
energy_range_fit = np.linspace(energy_range[0], energy_range[-1], len(energy_range)*10)
centre_line_out = data[:,:,int(data.shape[2]/2)].mean(axis=1)
try:
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
#Return [amp, mean_val, sigma, offset]
def fit_crystal_height(xstal_from, xstal_to, steps, data):
xstal_range = np.linspace(xstal_from, xstal_to, steps)
projection = data.mean(axis=1).mean(axis=1)
offset = np.mean(projection[0:100])
signal_centre = xstal_range[np.argmax(projection)]
xstal_range_fit = np.linspace(xstal_range[0], xstal_range[-1], len(xstal_range)*10)
try:
popt,pcov = curve_fit(gaus,xstal_range,projection,p0=[100,signal_centre,-0.2,offset])
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
return popt, projection
def get_signal_centre(data, data_range):
projection = data.mean(axis=1).mean(axis=1)
signal_centre = data_range[np.argmax(projection)]
return signal_centre, projection

View File

@@ -0,0 +1,32 @@
import numpy as np
import matplotlib.pyplot as plt
def gaus(x, a, x0, sigma, offset):
return offset + a * np.exp(-(x - x0) ** 2 / (2 * sigma ** 2))
def plot_energy(E_from, E_to, steps, Scan_spec, popt, measured_offset):
Energy_range = np.linspace(E_from, E_to, steps)
centre_line_out = Scan_spec[:,:,int(Scan_spec.shape[2]/2)].mean(axis=1)
Energy_range_fit = np.linspace(Energy_range[0], Energy_range[-1], len(Energy_range)*10)
plt.figure(figsize=[10,5])
plt.subplot(121)
plt.title('PSSS scan of set photon energy')
plt.pcolormesh(np.arange(0,Scan_spec.shape[2]), Energy_range, Scan_spec.mean(axis=1),cmap='CMRmap')
plt.vlines(int(Scan_spec.shape[2]/2), Energy_range[0], Energy_range[-1],linestyles='--', colors='orange')
plt.xlim([0,Scan_spec.shape[2]])
plt.xlabel('Camera pixel')
plt.ylabel('Set PSSS energy [eV] \n SARFE10-PSSS059:ENERGY')
plt.subplot(122)
plt.title('At camera centre pixel %1i \nCalibrated energy = %.1f [eV]\n Offset from machine = %.1f [eV]'%(int(Scan_spec.shape[2]/2),popt[1],measured_offset))
plt.plot(centre_line_out,Energy_range,linewidth = 2, color = 'orange',label ='measured')
try:
plt.plot(gaus(Energy_range_fit,*popt),Energy_range_fit,'r:',label='fit')
except:
pass
plt.xticks([])
plt.legend()
plt.grid(True)

View File

@@ -0,0 +1,36 @@
from jeputils import *
RELOAD_CPYTHON = not App.isDetached()
def fit_energy(e_from, e_to, steps, num_shots, data):
data = to_array(data, 'd')
dims = [len(data), len(data[0]), len(data[0][0])]
data = Convert.flatten(data)
arr = to_npa(data, dims)
popt, centre_line_out = call_jep("cpython/psss", "fit_energy", [e_from, e_to, steps, num_shots, arr], reload=RELOAD_CPYTHON)
return popt.getData(), centre_line_out.getData()
def fit_crystal_height(xstal_from, xstal_to, steps, data):
data = to_array(data, 'd')
dims = [len(data), len(data[0]), len(data[0][0])]
data = Convert.flatten(data)
arr = to_npa(data, dims)
popt, projection = call_jep("cpython/psss", "fit_crystal_height", [xstal_from, xstal_to, steps, arr], reload=RELOAD_CPYTHON)
return popt.getData(), projection.getData()
def get_signal_centre(data, data_range):
data = to_array(data, 'd')
dims = [len(data), len(data[0]), len(data[0][0])]
data = Convert.flatten(data)
arr = to_npa(data, dims)
data_range = to_npa(to_array(data_range, 'd'))
signal_centre, projection = call_jep("cpython/psss", "get_signal_centre", [arr, data_range], reload=RELOAD_CPYTHON)
return signal_centre, projection.getData()
def plot_energy(e_from, e_to, steps, data, popt, measured_offset):
data = to_array(data, 'd')
dims = [len(data), len(data[0]), len(data[0][0])]
data = Convert.flatten(data)
arr = to_npa(data, dims)
ret = call_jep("cpython/psss_plot", "plot_energy", [e_from, e_to, steps, arr, popt, measured_offset], reload=RELOAD_CPYTHON)
return ret

View File

@@ -0,0 +1,184 @@
###################################################################################################
# Deployment specific global definitions - executed after startup.py
###################################################################################################
from mathutils import estimate_peak_indexes, fit_gaussians, create_fit_point_list
from mathutils import fit_polynomial,fit_gaussian, fit_harmonic, calculate_peaks, fit_gaussian_offset
from mathutils import PolynomialFunction, Gaussian, HarmonicOscillator, GaussianOffset
from plotutils import plot_function, plot_data
import java.awt.Color as Color
run("psss/psss")
###################################################################################################
# DRY RUN
###################################################################################################
def set_dry_run(value):
global dry_run
dry_run = value
def is_dry_run():
if "dry_run" in globals():
return True if dry_run else False
return False
###################################################################################################
# Machine utilities
###################################################################################################
def is_laser_on():
return (caget ("SIN-TIMAST-TMA:Beam-Las-Delay-Sel",'d') == 0 )
def is_timing_ok():
return caget("SIN-TIMAST-TMA:SOS-COUNT-CHECK") == 0
def get_repetition_rate():
return caget("SIN-TIMAST-TMA:Evt-15-Freq-I")
###################################################################################################
# Shortcut to maths utilities
###################################################################################################
def gfit(ydata, xdata = None):
"""
Gaussian fit
"""
if xdata is None:
xdata = frange(0, len(ydata), 1)
#ydata = to_list(ydata)
#xdata = to_list(xdata)
max_y= max(ydata)
index_max = ydata.index(max_y)
max_x= xdata[index_max]
print "Max index:" + str(index_max),
print " x:" + str(max_x),
print " y:" + str(max_y)
gaussians = fit_gaussians(ydata, xdata, [index_max,])
(norm, mean, sigma) = gaussians[0]
p = plot([ydata],["data"],[xdata], title="Fit" )[0]
fitted_gaussian_function = Gaussian(norm, mean, sigma)
scale_x = [float(min(xdata)), float(max(xdata)) ]
points = max((len(xdata)+1), 100)
resolution = (scale_x[1]-scale_x[0]) / points
fit_y = []
fit_x = frange(scale_x[0],scale_x[1],resolution, True)
for x in fit_x:
fit_y.append(fitted_gaussian_function.value(x))
p.addSeries(LinePlotSeries("fit"))
p.getSeries(1).setData(fit_x, fit_y)
if abs(mean - xdata[index_max]) < ((scale_x[0] + scale_x[1])/2):
print "Mean -> " + str(mean)
p.addMarker(mean, None, "Mean="+str(round(norm,2)), Color.MAGENTA.darker())
return (norm, mean, sigma)
else:
p.addMarker(max_x, None, "Max="+str(round(max_x,2)), Color.GRAY)
print "Invalid gaussian fit: " + str(mean)
return (None, None, None)
def hfit(ydata, xdata = None):
"""
Harmonic fit
"""
if xdata is None:
xdata = frange(0, len(ydata), 1)
max_y= max(ydata)
index_max = ydata.index(max_y)
max_x= xdata[index_max]
start,end = min(xdata), max(xdata)
(amplitude, angular_frequency, phase) = fit_harmonic(ydata, xdata)
fitted_harmonic_function = HarmonicOscillator(amplitude, angular_frequency, phase)
print "amplitude = ", amplitude
print "angular frequency = ", angular_frequency
print "phase = ", phase
f = angular_frequency/ (2* math.pi)
print "frequency = ", f
resolution = 4.00 # 1.00
fit_y = []
for x in frange(start,end,resolution, True):
fit_y.append(fitted_harmonic_function.value(x))
fit_x = frange(start, end+resolution, resolution)
p = plot(ydata,"data", xdata, title="HFit")[0]
p.addSeries(LinePlotSeries("fit"))
p.getSeries(1).setData(fit_x, fit_y)
#m = (phase + math.pi)/ angular_frequency
m = -phase / angular_frequency
if (m<start):
m+=(1.0/f)
if start <=m <=end:
print "fit = ", m
p.addMarker(m, None, "Fit="+str(round(m ,2)), Color.MAGENTA.darker())
return (amplitude, angular_frequency, phase, True, m, fit_x, fit_y)
else:
print "max = ",max_x
p.addMarker(max_x, None, "Max="+str(round(max_x ,2)), Color.MAGENTA.darker())
return (amplitude, angular_frequency, phase, False, max_x, fit_x, fit_y)
def plot_gauss_fit(xdata, ydata, gauss_pars=None, p=None, title = "Data"):
if gauss_pars is None:
gauss_pars= fit_gaussian_offset(ydata, xdata, None)
(offset, amp, mean_value, sigma) = gauss_pars
print "Gauss plot: ", (offset, amp, mean_value, sigma)
fitted_gaussian_function = GaussianOffset(offset, amp, mean_value, abs(sigma))
if p is None:
p = plot(None, title=title)[0]
p.clear()
plot_data(p, ydata, title, xdata=xdata, show_points = True, color=Color.BLUE)
fit_range = frange(xdata[0],xdata[-1],float(xdata[1]-xdata[0])/100, True)
plot_function(p, fitted_gaussian_function, "Gauss", fit_range, show_points=False, color=Color.RED)
p.setLegendVisible(True)
p.addMarker(mean_value, None, "Mean=" + str(round(mean_value,2)), Color.LIGHT_GRAY)
return p,(amp, mean_value, sigma)
###################################################################################################
# Tools
###################################################################################################
def elog(title, message, attachments = [], author = None, category = "Info", domain = "", logbook = "Bernina", encoding=1):
"""
Add entry to ELOG.
"""
if author is None:
author = "pshell" #get_context().user.name
typ = "pshell"
entry = ""
cmd = 'G_CS_ELOG_add -l "' + logbook + '" '
cmd = cmd + '-a "Author=' + author + '" '
cmd = cmd + '-a "Type=' + typ + '" '
cmd = cmd + '-a "Entry=' + entry + '" '
cmd = cmd + '-a "Title=' + title + '" '
cmd = cmd + '-a "Category=' + category + '" '
cmd = cmd + '-a "Domain=' + domain + '" '
for attachment in attachments:
cmd = cmd + '-f "' + attachment + '" '
cmd = cmd + '-n ' + str(encoding)
cmd = cmd + ' "' + message + '"'
#print cmd
#os.system (cmd)
#print os.popen(cmd).read()
import subprocess
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
(out, err) = proc.communicate()
if (err is not None) and err!="":
raise Exception(err)
print out
try:
return int(out[out.find("ID=") +3 : ])
except:
print out

View File

@@ -0,0 +1,73 @@
#Scan the PSSS camera position
#Purpose:
#To set or confirm the camera is positioned with the measured spectrum in the centre of the spectral integration window
#If running from editor
if get_exec_pars().source == CommandSource.ui:
#User inputs - define travel range of camera
RANGE_FROM = -17
RANGE_TO = -11
STEPS = 20
NUM_SHOTS= 10 #100
PLOT=None
p = plot(None, title="Data")[0] if (PLOT is None) else PLOT
p.clear()
p.removeMarker(None)
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:
cam_x=DummyRegister("cam_x")
av = create_averager(psss_spectrum_y, NUM_SHOTS, interval=-1, name="spectrum_average")
av_samples = av.samples
av_samples.alias = "spectrum_samples"
#Scan and take data
def after_read(record, scan):
p.getSeries(0).setData(psss_spectrum_x.take(), record[av])
p.setTitle("Cam X = %1.3f" %(record[cam_x]))
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)
#Set max position
cam_x.write(signal_centre)
cam_x.close()
"""
plt.figure(figsize=[10,5])
plt.subplot(121)
plt.title('PSSS scan of camera position')
plt.pcolormesh(np.arange(0,Scan_spec.shape[2]), Cam_range, Scan_spec.mean(axis=1),cmap='CMRmap')
plt.xlim([0,Scan_spec.shape[2]])
plt.xlabel('Camera pixel dispersive direction')
plt.ylabel('Set PSSS cam_x _pos [mm] \n'+PSSS_cam_x_PV_name[0:-4])
plt.subplot(122)
plt.plot(projection,Cam_range,linewidth = 2, color = 'orange',label ='projected signal')
plt.title('Spectrum centred at %.1f [mm] (from signal max) \n trace should have hard edges'%signal_centre)
plt.xticks([])
plt.legend()
plt.grid(True)
"""
#PLOT.clear()
#plot_data(PLOT, projection, "Data", xdata=cam_range, show_points = True, color=Color.BLUE)
#p,pars = plot_gauss_fit(cam_range, projection, gauss_pars=None, p=PLOT, title = "Data")
p.clear()
p.setTitle("")
plot_data(p, projection, "Projection", xdata=cam_range, show_points = True, color=Color.BLUE)
p.addMarker(signal_centre, None, "Signal Centre=" + str(round(signal_centre,2)), Color.LIGHT_GRAY)
set_return(signal_centre)

View File

@@ -0,0 +1,73 @@
###############################################################################
#Scan the PSSS crystal height
#Purpose:
#The PSSS signal level is very sensitive to the crystal height. This script will scan the height and set the position to the maximum signal
if get_exec_pars().source == CommandSource.ui:
#User inputs - define travel range of camera
RANGE_FROM = -0.8
RANGE_TO = -1.7
STEPS = 10 #20
NUM_SHOTS= 10 # 100
PLOT=None
# get current camera ROIs and then set to max for scan
roi_min = psss_roi_min.read()
roi_max = psss_roi_max.read()
psss_roi_min.write(1)
psss_roi_max.write(2000)
p = plot(None, title="Data")[0] if (PLOT is None) else PLOT
p.clear()
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
xstal_height=Channel("SARFE10-PSSS059:MOTOR_Y3.VAL", name="xstal_height")
#else:
# xstal_height=DummyRegister("xstal_height")
av = create_averager(psss_spectrum_y, NUM_SHOTS, interval=-1, name="spectrum_average")
av_samples = av.samples
av_samples.alias = "spectrum_samples"
#Scan and take data
def after_read(record, scan):
p.getSeries(0).setData(psss_spectrum_x.take(), record[av])
p.setTitle("Xtal Height = %1.3f" %(record[xstal_height]))
r = lscan(xstal_height, (av, av_samples), RANGE_FROM, RANGE_TO, STEPS, latency=2.0, after_read = after_read, save=False)
#User inputs - define travel range of crystal
#It is unlikely these values need to be changed
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)
print(mean_val)
if not (RANGE_FROM < mean_val < RANGE_TO or RANGE_TO < mean_val < RANGE_FROM):
raise Exception ("Invalid fit mean: " + str(mean_val))
#Set max position
#Cell below will push the maximum position to the xstal height
xstal_height.write(mean_val)
xstal_height.close()
# return ROI to inital value
psss_roi_min.write(roi_min)
psss_roi_max.write(roi_max)
#Plots
p.clear()
p.setTitle("")
plot_gauss_fit(xstal_range, projection, gauss_pars=(offset, amp, mean_val, sigma), p=p, title = "Data")
set_return(mean_val)

View File

@@ -0,0 +1,89 @@
###############################################################################
#Scan the PSSS photon energy
#Purpose: To find and centre the PSSS photon energy so the measured spectrum is centred on the camera chip
#PARAMETERS
#User inputs - define energy range to scan below by running the appropiate cell
#Below is for a large scan range assuming offset from machine upto $\pm$ 300 eV
#If running from editor
if get_exec_pars().source == CommandSource.ui:
RANGE_OFF = None
RANGE_FROM = 11100
RANGE_TO = 11300
STEPS = 5 #60
NUM_SHOTS= 10 #100
PLOT=None
p = plot(None, title="Data")[0] if (PLOT is None) else PLOT
p.clear()
p.removeMarker(None)
p.setLegendVisible(True)
p.addSeries(LinePlotSeries("PSSS Spectrum Average"))
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()
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"
def after_read(record, scan):
p.getSeries(0).setData(psss_spectrum_x.take(), record[av])
p.setTitle("Energy = %1.3f" %(record[en]))
r = lscan(en, (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)
if not (RANGE_FROM < mean_val < RANGE_TO or RANGE_TO < mean_val < RANGE_FROM):
raise Exception ("Invalid fit mean: " + str(mean_val))
measured_offset = energy_machine.read() - mean_val
#Set fitted energy
print "measured offset", measured_offset
en.write(mean_val)
p.clear()
p.setTitle("")
plot_gauss_fit(energy_range, centre_line_out, gauss_pars=(offset, amp, mean_val, sigma), p=PLOT, title = "Data")
set_return(mean_val)

View File

@@ -0,0 +1,184 @@
from collections import deque
PSSS_CAMERA_NAME = "SARFE10-PSSS059";
def integrate_arrays(arrays):
if arrays is None or (len(arrays)==0):
return None
ret = arrays[0]
for a in arrays[1:]:
ret=arradd(ret, a)
return ret
def average_arrays(arrays):
ret = integrate_arrays(arrays)
if ret is not None:
s=len(arrays)
ret = [x/s for x in ret]
return ret
def get_psss_data(average=1):
ax,ay,ac,af=[],[],[],[]
x = psss_spectrum_x.take()
for i in range(average):
y = psss_spectrum_y.take()
center,fwhm = psss_center.take(), psss_fwhm.take()
if average==1:
return x,y,center,fwhm
#ax.append(x)
ay.append(y)
ac.append(center)
af.append(fwhm)
if i < (average-1):
psss_spectrum_y.waitCacheChange(2000)
#psss_center.waitCacheChange(1)
#psss_fwhm.waitCacheChange(1)
#x=average_arrays(ax)
y=average_arrays(ay)
center=mean(ac)
fwhm=mean(af)
return x,y,center,fwhm
def plot_psss(p, h=None, average = None):
"""
if len(p.getMarkers())==0:
m1=p.addMarker(0,None,"",Color.WHITE)
m2=p.addMarker(0,None,"",Color.WHITE)
m2.setLabelAnchor(RectangleAnchor.TOP)
else:
m1,m2 = p.getMarkers()
"""
#Manipulate axis (use PSSS_PLOT for the global object):
#p.getAxis(LinePlot.AxisId.X).
# Setup queues
if p.getNumberOfSeries()==0:
center_queue = deque(maxlen=100)
fwhm_queue = deque(maxlen=100)
# Setup figures
if p.getNumberOfSeries()==0:
p.addSeries(LinePlotSeries("spectrum"))
p.addSeries(LinePlotSeries("average"))
p.setLegendVisible(True)
p.getAxis(LinePlot.AxisId.X)
p.getAxis(LinePlot.AxisId.X).setLabel("Energy [eV]")
p.getAxis(LinePlot.AxisId.Y).setLabel("Sum counts")
if len(p.getMarkers())==0:
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)
else:
m = p.getMarkers()[0]
x,y, = psss_spectrum_x.take(), psss_spectrum_y.take()
# update spectral plot
if (x is None) or (y is None):
p.getSeries(0).clear()
else:
p.getSeries(0).setData(x,y)
if (x is None) or (y is None):
p.getSeries(0).clear()
else:
p.getSeries(0).setData(x,y)
if average is not None:
print "Average: ", average
x,y, center,fwhm = get_psss_data(average)
else:
y = psss_spectrum_y_average.take()
center = psss_center_average.take()
fwhm = psss_fwhm_average.take()
if (x is None) or (y is None):
p.getSeries(1).clear()
else:
p.getSeries(1).setData(x,y)
if (center!= None) and (fwhm!=None):
center=center.doubleValue()
fwhm=fwhm.doubleValue()
m.startValue, m.endValue = center - fwhm/2, center + fwhm/2
m.label = str(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.setLegendVisible(True)
h.setTimeAxisLabel("")
h.getAxis(Timeplot.AxisId.Y1).setLabel("Central energy [eV]")
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)
return center,fwhm
ovmin, ovmax, ovavg = None, None, None
def update_psss_image(renderer):
global ovmin, ovmax
#if ovmin: ovmin.update(Point(0,psss_roi_min.take()))
#if ovmax: ovmax.update(Point(0,psss_roi_max.take()))
width=psss_spectrum_x.size
if ovmin: ovmin.update(Point(0,psss_roi_min.take()), Point(width, psss_roi_min.take()))
if ovmax: ovmax.update(Point(0,psss_roi_max.take()), Point(width, psss_roi_max.take()))
try:
data = renderer.data
av = "%1.2f" %(data.integrate(False)/data.width/data.height)
except:
av = ""
if ovavg: ovavg.update(av)
def enable_psss_image(enabled, renderer):
global ovmin, ovmax, ovavg
try:
if (enabled):
#Start or connect to ScreenPanel pipeline
renderer.setDevice(cam_server)
renderer.setProfile(renderer.Profile.Both)
renderer.setShowProfileLimits(False)
#Changing colormap
#print Colormap.values() #Check values
cam_server.config.colormap=Colormap.Temperature
cam_server.start(PSSS_CAMERA_NAME + "_sp", True)
#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())
ovavg = Overlays.Text(Pen(java.awt.Color.GREEN.darker()), "", \
java.awt.Font("Verdana", java.awt.Font.PLAIN, 12), java.awt.Point(-50,20))
ovavg.fixed=True
ovavg.anchor=Overlay.ANCHOR_IMAGE_TOP_RIGHT
renderer.addOverlays([ovmin, ovmax, ovavg])
update_psss_image(renderer)
else:
ovmin, ovmax, ovavg = None, None, None
renderer.setDevice(None)
renderer.clearOverlays()
cam_server.stop()
except:
log(sys.exc_info()[1])
def get_psss_averaging():
return psss_spectrum_y_average.config.measures
def set_psss_averaging(measures):
psss_spectrum_y_average.config.measures=measures
psss_center_average.config.measures=measures
psss_fwhm_average.config.measures=measures

View File

@@ -1 +1,11 @@
description = 'psss-panel'
ext.mainClass = hasProperty('mainClass') ? mainClass : 'ch.psi.pshell.workbench.App'
ext.title = 'PSSS Panel'
ext.desc = 'PSSS panel'
ext.deploy_type= 'pkg'
dependencies {
implementation 'ch.psi:pshell-workbench:' + version
}
createDefaultTasks(project)

View File

@@ -3,6 +3,7 @@ ext.mainClass = hasProperty('mainClass') ? mainClass : 'ch.psi.pshell.workbench.
ext.title = 'ScreenPanel'
ext.desc = 'ScreenPanel customization for SwissFEL cameras'
ext.ex_options = 'ch.psi.pshell.screenpanel.Options'
ext.deploy_type= 'java'
dependencies {
implementation 'ch.psi:pshell-workbench:' + version

View File

@@ -3,6 +3,7 @@ ext.mainClass = hasProperty('mainClass') ? mainClass : 'ch.psi.pshell.workbench.
ext.title = 'ScreenPanel'
ext.desc = 'ScreenPanel customization for SLS cameras'
ext.ex_options = 'ch.psi.pshell.screenpanel.Options'
ext.deploy_type= 'java'
dependencies {
implementation 'ch.psi:pshell-workbench:' + version

View File

@@ -4,4 +4,6 @@ include ':screenpanel-sls'
include ':screenpanel-sf'
include ':athos-screens'
include ':psss-panel'
include ':persplot'
include ':correlation'