Initial Commit

This commit is contained in:
gac-bernina
2021-04-28 09:14:56 +02:00
commit b38c0270ff
93 changed files with 15403 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
#Tue Apr 27 16:22:56 CEST 2021
autoSaveScanData=true
simulation=false
commandExecutionEvents=false
logDaysToLive=50
dataScanSaveOutput=false
userAuthenticator=
logLevelConsole=Off
scanStreamerPort=-1
dataScanSaveScript=false
dataScanSaveSetpoints=false
notifiedTasks=null
parallelInitialization=false
dataTransferPath=null
saveConsoleSessionFiles=false
versionTrackingManual=true
dataTransferMode=null
hostName=null
userManagement=false
instanceName=BE
disableEmbeddedAttributes=false
dataServerPort=-1
hideServerMessages=false
serverPort=8080
versionTrackingEnabled=true
dataPath={data}/{year}_{month}/{date}/{date}_{time}_{name}
serverEnabled=false
dataScanReleaseRecords=false
depthDimension=0
dataScanPreserveTypes=false
logLevel=Info
dataScanFlushRecords=false
logPath={logs}/{date}_{time}
dataLayout=default
disableDataFileLogs=false
sessionHandling=null
terminalEnabled=false
notificationLevel=Off
terminalPort=3579
dataTransferUser=null
createSessionFiles=false
versionTrackingLogin=
versionTrackingRemote=
dataProvider=h5
saveCommandStatistics=false
+16
View File
@@ -0,0 +1,16 @@
dispatcher=ch.psi.pshell.bs.Dispatcher|https://dispatcher-api.psi.ch/sf|||
cam_server=ch.psi.pshell.bs.PipelineServer|sf-daqsync-01:8889|||
cam_n=ch.psi.pshell.imaging.MjpegSource|http://bernina-cam-n/axis-cgi/mjpg/video.cgi reopen||-200|false
cam_s=ch.psi.pshell.imaging.MjpegSource|http://bernina-cam-s/axis-cgi/mjpg/video.cgi reopen||-200|
cam_w=ch.psi.pshell.imaging.MjpegSource|http://bernina-cam-w/axis-cgi/mjpg/video.cgi reopen||-200|
cam_mobile=ch.psi.pshell.imaging.MjpegSource|http://bernina-cam-mobile/axis-cgi/mjpg/video.cgi reopen||-200|
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
+12
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
+9
View File
@@ -0,0 +1,9 @@
#Mon Nov 27 17:25:22 CET 2017
auth=None
from=
host=
port=0
pwd=
smsSuffix=@sms.switch.ch
to=
usr=
+13
View File
@@ -0,0 +1,13 @@
Correlation.java=disabled
ScreenPanel2.java=disabled
ScreenPanel3.java=disabled
ScreenPanel4.java=disabled
ScreenPanel5.java=disabled
ScreenPanel6.java=disabled
PSSS.java=enabled
MonitoringCameras.java=disabled
Chris.java=disabled
SfCamera.java=enabled
ScreenPanel.java=disabled
CameraCalibrationDialog.java=disabled
Inventory.java=disabled
+23
View File
@@ -0,0 +1,23 @@
#Thu Feb 25 14:38:29 CET 2021
sessionsPath={outp}/sessions
scriptPath={home}/script
pluginsPath={home}/plugins
configFileDevices={config}/devices.properties
consoleSessionsPath={sessions}/console
libraryPath={script}; {script}/Lib
configFilePlugins={config}/plugins.properties
contextPath={outp}/context
extensionsPath={home}/extensions
configPath={home}/config
configFileSessions={config}/sessions.properties
userSessionsPath={sessions}/user
dataPath={outp}/data
devicesPath={home}/devices
configFileVariables={config}/variables.properties
configFileSettings={config}/settings.properties
logPath={outp}/log
wwwPath={home}/www
imagesPath={outp}/images
configFile={config}/config.properties
scriptType=py
configFileTasks={config}/tasks.properties
+4
View File
@@ -0,0 +1,4 @@
#Tue Apr 27 16:17:59 CEST 2021
LastRunDate=210415
FileSequentialNumber=81
DaySequentialNumber=0
+25
View File
@@ -0,0 +1,25 @@
#Sat Jun 08 12:02:12 CEST 2019
colormap=Grayscale
colormapAutomatic=false
colormapLogarithmic=false
colormapMax=NaN
colormapMin=NaN
flipHorizontally=false
flipVertically=false
grayscale=false
invert=false
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=-1
roiWidth=-1
roiX=0
roiY=0
rotation=0.0
rotationCrop=false
scale=1.0
spatialCalOffsetX=NaN
spatialCalOffsetY=NaN
spatialCalScaleX=NaN
spatialCalScaleY=NaN
spatialCalUnits=mm
transpose=false
+25
View File
@@ -0,0 +1,25 @@
#Tue Jun 25 21:48:15 CEST 2019
colormap=Grayscale
colormapAutomatic=false
colormapLogarithmic=false
colormapMax=NaN
colormapMin=NaN
flipHorizontally=false
flipVertically=false
grayscale=false
invert=false
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=-1
roiWidth=-1
roiX=0
roiY=0
rotation=0.0
rotationCrop=false
scale=1.0
spatialCalOffsetX=NaN
spatialCalOffsetY=NaN
spatialCalScaleX=NaN
spatialCalScaleY=NaN
spatialCalUnits=mm
transpose=false
+6
View File
@@ -0,0 +1,6 @@
#Fri Feb 26 13:59:45 CET 2021
bins=0
min=NaN
max=NaN
precision=-1
numberOfSamples=0
+32
View File
@@ -0,0 +1,32 @@
#Mon Apr 26 11:55:34 CEST 2021
\u0000\u0000\u0000\u0000=
=0
spatialCalOffsetY=-211.42799182512672
spatialCalOffsetX=-274.41641995560866
colormapLogarithmic=false
scale=1.0
grayscale=false
spatialCalScaleX=-2.0325203289739266
spatialCalScaleY=-2.024291558875032
colormapMax=220.0
Y=0
rescaleOffset=0.0
roiWidth=-1
colormap=Temperature
imageWidth=1280
invert=false
colormapMin=6.0
rotation=0.0
rotationCrop=false
rescaleFactor=1.0
imageHeight=1024
spatialCalUnits=mm
flipVertically=false
roiHeight=-1
flipHorizontally=false
colormapAutomatic=true
roiY=0
roiX=0
transpose=false
regionStartX=1
regionStartY=1
+25
View File
@@ -0,0 +1,25 @@
#Thu Oct 03 04:51:06 CEST 2019
spatialCalOffsetY=-301.6105501758777
spatialCalOffsetX=-234.3556284010104
colormapLogarithmic=false
scale=1.0
grayscale=false
spatialCalScaleX=-0.5345394633098939
spatialCalScaleY=-0.6305263124663254
colormapMax=5000.0
rescaleOffset=0.0
roiWidth=-1
colormap=Grayscale
invert=false
colormapMin=10.0
rotation=0.0
rotationCrop=false
rescaleFactor=1.0
spatialCalUnits=mm
flipVertically=false
roiHeight=-1
flipHorizontally=false
colormapAutomatic=false
roiY=0
roiX=0
transpose=false
+10
View File
@@ -0,0 +1,10 @@
#Wed Feb 26 11:49:58 CET 2020
minValue=NaN
unit=null
offset=0.0
maxValue=NaN
rotation=false
precision=-1
sign_bit=0
scale=1.0
resolution=NaN
+20
View File
@@ -0,0 +1,20 @@
#Fri Feb 19 09:52:28 CET 2021
spatialCalOffsetY=NaN
invert=false
spatialCalOffsetX=NaN
rotation=0.0
rotationCrop=false
scale=1.0
rescaleFactor=1.0
grayscale=false
spatialCalUnits=mm
flipVertically=false
roiHeight=-1
spatialCalScaleX=NaN
spatialCalScaleY=NaN
flipHorizontally=false
roiY=0
roiX=0
rescaleOffset=0.0
transpose=false
roiWidth=-1
+20
View File
@@ -0,0 +1,20 @@
#Fri Feb 19 09:50:36 CET 2021
spatialCalOffsetY=NaN
invert=false
spatialCalOffsetX=NaN
rotation=0.0
rotationCrop=false
scale=1.0
rescaleFactor=1.0
grayscale=false
spatialCalUnits=mm
flipVertically=false
roiHeight=-1
spatialCalScaleX=NaN
spatialCalScaleY=NaN
flipHorizontally=false
roiY=0
roiX=0
rescaleOffset=0.0
transpose=false
roiWidth=-1
+20
View File
@@ -0,0 +1,20 @@
#Fri Feb 19 09:52:28 CET 2021
spatialCalOffsetY=NaN
invert=false
spatialCalOffsetX=NaN
rotation=0.0
rotationCrop=false
scale=1.0
rescaleFactor=1.0
grayscale=false
spatialCalUnits=mm
flipVertically=false
roiHeight=-1
spatialCalScaleX=NaN
spatialCalScaleY=NaN
flipHorizontally=false
roiY=0
roiX=0
rescaleOffset=0.0
transpose=false
roiWidth=-1
+25
View File
@@ -0,0 +1,25 @@
#Thu Feb 25 15:32:21 CET 2021
colormapLogarithmic=false
spatialCalScaleX=-1.0
spatialCalScaleY=-1.0
rescaleOffset=0.0
roiWidth=-1
colormap=Grayscale
invert=false
colormapMin=0.0
rotationCrop=false
roiHeight=-1
colormapAutomatic=false
roiY=0
roiX=0
spatialCalOffsetY=-50.02315886984715
spatialCalOffsetX=-50.01953888237593
scale=1.0
grayscale=false
colormapMax=255.0
rotation=0.0
rescaleFactor=1.0
spatialCalUnits=mm
flipVertically=false
flipHorizontally=false
transpose=false
+20
View File
@@ -0,0 +1,20 @@
#Fri Feb 19 09:52:28 CET 2021
spatialCalOffsetY=NaN
invert=false
spatialCalOffsetX=NaN
rotation=0.0
rotationCrop=false
scale=1.0
rescaleFactor=1.0
grayscale=false
spatialCalUnits=mm
flipVertically=false
roiHeight=-1
spatialCalScaleX=NaN
spatialCalScaleY=NaN
flipHorizontally=false
roiY=0
roiX=0
rescaleOffset=0.0
transpose=false
roiWidth=-1
+13
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
+11
View File
@@ -0,0 +1,11 @@
#Fri Jan 29 16:28:42 CET 2021
motor7=null
motor8=null
motor5=null
motor6=null
precision=-1
positions=Park|Ready|Out|Clear
motor3=null
motor4=null
motor1=0.0|4.0|8.0|0.0
motor2=0.0|5.0|3.0|NaN
+6
View File
@@ -0,0 +1,6 @@
#Tue Apr 27 16:40:07 CEST 2021
bins=100
min=11340.0
max=11260.0
precision=-1
numberOfSamples=100
+6
View File
@@ -0,0 +1,6 @@
#Fri Feb 26 14:09:58 CET 2021
bins=100
min=0.0
max=200.0
precision=-1
numberOfSamples=100
+16
View File
@@ -0,0 +1,16 @@
#Fri Jan 29 16:28:42 CET 2021
offset=0.0
maxValue=10.0
rotation=false
precision=2
scale=1.0
estbilizationDelay=0
maxSpeed=10.0
resolution=NaN
startRetries=1
minValue=-10.0
unit=mm
defaultSpeed=1.0
sign_bit=0
monitorByPosition=false
minSpeed=0.1
+16
View File
@@ -0,0 +1,16 @@
#Fri Jan 29 16:28:42 CET 2021
offset=0.0
maxValue=10.0
rotation=false
precision=2
scale=1.0
estbilizationDelay=0
maxSpeed=10.0
resolution=NaN
startRetries=1
minValue=-10.0
unit=mm
defaultSpeed=1.0
sign_bit=0
monitorByPosition=false
minSpeed=0.1
+10
View File
@@ -0,0 +1,10 @@
#Fri Jan 29 16:28:42 CET 2021
minValue=0.0
unit=mm
offset=0.0
maxValue=1000.0
rotation=false
precision=-1
sign_bit=0
scale=1.0
resolution=NaN
+26
View File
@@ -0,0 +1,26 @@
#Wed Feb 24 15:21:01 CET 2021
spatialCalOffsetY=NaN
spatialCalOffsetX=NaN
colormapLogarithmic=false
scale=1.0
grayscale=false
spatialCalScaleX=NaN
spatialCalScaleY=NaN
colormapMax=NaN
serverURL=localhost\:8889
rescaleOffset=0.0
roiWidth=-1
colormap=Grayscale
invert=false
colormapMin=NaN
rotation=0.0
rotationCrop=false
rescaleFactor=1.0
spatialCalUnits=mm
flipVertically=false
roiHeight=-1
flipHorizontally=false
colormapAutomatic=false
roiY=0
roiX=0
transpose=false
+25
View File
@@ -0,0 +1,25 @@
#Fri Jan 29 16:28:47 CET 2021
spatialCalOffsetY=NaN
spatialCalOffsetX=NaN
colormapLogarithmic=false
scale=1.0
grayscale=false
spatialCalScaleX=NaN
spatialCalScaleY=NaN
colormapMax=NaN
rescaleOffset=0.0
roiWidth=-1
colormap=Temperature
invert=false
colormapMin=NaN
rotation=0.0
rotationCrop=false
rescaleFactor=1.0
spatialCalUnits=mm
flipVertically=false
roiHeight=-1
flipHorizontally=false
colormapAutomatic=true
roiY=0
roiX=0
transpose=false
+25
View File
@@ -0,0 +1,25 @@
#Fri Jan 29 16:28:47 CET 2021
spatialCalOffsetY=NaN
spatialCalOffsetX=NaN
colormapLogarithmic=false
scale=1.0
grayscale=false
spatialCalScaleX=NaN
spatialCalScaleY=NaN
colormapMax=NaN
rescaleOffset=0.0
roiWidth=-1
colormap=Grayscale
invert=false
colormapMin=NaN
rotation=0.0
rotationCrop=false
rescaleFactor=1.0
spatialCalUnits=mm
flipVertically=false
roiHeight=-1
flipHorizontally=false
colormapAutomatic=true
roiY=0
roiX=0
transpose=false
+1
View File
@@ -0,0 +1 @@
/afs/psi.ch/intranet/SF/Applications/config/pshell_op/plugins/CameraCalibrationDialog.java
+43
View File
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="111" max="-2" attributes="0"/>
<Component id="jRadioButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="213" 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 min="-2" pref="49" max="-2" attributes="0"/>
<Component id="jRadioButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="65" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JRadioButton" name="jRadioButton1">
<Properties>
<Property name="text" type="java.lang.String" value="jRadioButton1"/>
</Properties>
</Component>
</SubComponents>
</Form>
+63
View File
@@ -0,0 +1,63 @@
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
/**
*
*/
public class Chris extends Panel {
public Chris() {
initComponents();
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
}
@Override
public void onStateChange(State state, State former) {
}
@Override
public void onExecutedFile(String fileName, Object result) {
}
//Callback to perform update - in event thread
@Override
protected void doUpdate() {
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jRadioButton1 = new javax.swing.JRadioButton();
jRadioButton1.setText("jRadioButton1");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(111, 111, 111)
.addComponent(jRadioButton1)
.addContainerGap(213, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(49, 49, 49)
.addComponent(jRadioButton1)
.addContainerGap(65, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JRadioButton jRadioButton1;
// End of variables declaration//GEN-END:variables
}
+1
View File
@@ -0,0 +1 @@
/afs/psi.ch/intranet/SF/Applications/config/pshell_op/plugins/Correlation.java
+1
View File
@@ -0,0 +1 @@
/afs/psi.ch/intranet/SF/Applications/config/pshell_op/plugins/Inventory.java
+342
View File
@@ -0,0 +1,342 @@
<?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 min="0" pref="0" max="-2" attributes="0"/>
<Component id="panelControls" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="renderer" pref="522" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="panelControls" alignment="0" max="32767" attributes="0"/>
<Component id="renderer" alignment="1" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="ch.psi.pshell.imaging.Renderer" name="renderer">
</Component>
<Container class="javax.swing.JPanel" name="panelControls">
<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="jPanel1" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel2" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel3" alignment="1" 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"/>
<Component id="jPanel3" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="322" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel2">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Move"/>
</Border>
</Property>
</Properties>
<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="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="buttonMoveULeft" linkSize="1" min="-2" pref="40" max="-2" attributes="0"/>
<Component id="buttonMoveDLeft" linkSize="1" alignment="1" min="-2" pref="40" max="-2" attributes="0"/>
</Group>
<Component id="buttonMoveLeft" linkSize="1" min="-2" pref="40" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="buttonMoveDown" linkSize="1" pref="40" max="32767" attributes="0"/>
<Component id="buttonMoveHome" linkSize="1" pref="40" max="32767" attributes="0"/>
<Component id="buttonMoveUp" linkSize="1" alignment="0" pref="40" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="buttonMoveRight" linkSize="1" pref="40" max="32767" attributes="0"/>
<Component id="buttonMoveUReight" linkSize="1" pref="40" max="32767" attributes="0"/>
<Component id="buttonMoveDRight" linkSize="1" alignment="0" min="-2" pref="40" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonMoveUp" linkSize="2" alignment="3" min="-2" pref="40" max="-2" attributes="0"/>
<Component id="buttonMoveUReight" linkSize="2" alignment="3" min="-2" pref="40" max="-2" attributes="0"/>
<Component id="buttonMoveULeft" linkSize="2" alignment="3" min="-2" pref="40" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonMoveLeft" linkSize="2" alignment="3" min="-2" pref="40" max="-2" attributes="0"/>
<Component id="buttonMoveRight" linkSize="2" alignment="3" min="-2" pref="40" max="-2" attributes="0"/>
<Component id="buttonMoveHome" linkSize="2" alignment="3" min="-2" pref="40" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonMoveDown" linkSize="2" alignment="3" min="-2" pref="40" max="-2" attributes="0"/>
<Component id="buttonMoveDLeft" linkSize="2" alignment="3" min="-2" pref="40" max="-2" attributes="0"/>
<Component id="buttonMoveDRight" linkSize="2" alignment="3" min="-2" pref="40" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonMoveLeft">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;arrows/Left&quot;)" type="code"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonMoveLeftActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonMoveDLeft">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;arrows/DLeft&quot;)" type="code"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonMoveDLeftActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonMoveDRight">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;arrows/DRight&quot;)" type="code"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonMoveDRightActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonMoveRight">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;arrows/Right&quot;)" type="code"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonMoveRightActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonMoveUReight">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;arrows/URight&quot;)" type="code"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonMoveUReightActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonMoveHome">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;arrows/Center&quot;)" type="code"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonMoveHomeActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonMoveDown">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;arrows/Down&quot;)" type="code"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonMoveDownActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonMoveULeft">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;arrows/ULeft&quot;)" type="code"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonMoveULeftActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonMoveUp">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;arrows/Up&quot;)" type="code"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonMoveUpActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel1">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Zoom"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonZoomOut" linkSize="3" min="-2" pref="40" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonZooHome" linkSize="3" min="-2" pref="40" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonZoomIn" linkSize="3" min="-2" pref="40" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonZoomOut" alignment="3" min="-2" pref="40" max="-2" attributes="0"/>
<Component id="buttonZoomIn" alignment="3" min="-2" pref="40" max="-2" attributes="0"/>
<Component id="buttonZooHome" alignment="3" min="-2" pref="40" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="buttonZoomOut">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;arrows/Out&quot;)" type="code"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonZoomOutActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonZooHome">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;arrows/Center&quot;)" type="code"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonZooHomeActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonZoomIn">
<Properties>
<Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.RADConnectionPropertyEditor">
<Connection code="getIcon(&quot;arrows/In&quot;)" type="code"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonZoomInActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel3">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Camera"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="comboCameras" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="comboCameras" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JComboBox" name="comboCameras">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboCamerasActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Form>
+474
View File
@@ -0,0 +1,474 @@
import ch.psi.pshell.core.Context;
import ch.psi.pshell.device.GenericDevice;
import ch.psi.pshell.imaging.MjpegSource;
import ch.psi.pshell.imaging.RendererMode;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import ch.psi.utils.Str;
import ch.psi.utils.swing.SwingUtils;
import java.awt.Component;
import java.io.File;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel;
import javax.swing.ImageIcon;
import javax.swing.JButton;
/**
*
*/
public class MonitoringCameras extends Panel {
public MonitoringCameras() {
initComponents();
renderer.setMode(RendererMode.Fit);
updateControls();
}
volatile boolean loadedCommands;
volatile boolean moving;
volatile String currentCamera;
void updateControls(){
boolean isCameraSelected = (currentCamera!=null);
boolean enabled = isCameraSelected && loadedCommands && !moving;
for (Component button : SwingUtils.getComponentsByType(panelControls, JButton.class)){
button.setEnabled(enabled);
}
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
updateControls();
DefaultComboBoxModel model = new DefaultComboBoxModel();
renderer.setDeviceName(null);
for (GenericDevice dev : Context.getInstance().getDevicePool().getAllDevices(MjpegSource.class)){
MjpegSource camera =(MjpegSource) dev;
model.addElement(camera.getName());
}
model.addElement("");
model.setSelectedItem(null);
comboCameras.setModel(model);
currentCamera = null;
comboCameras.requestFocus();
}
@Override
public void onStateChange(State state, State former) {
loadedCommands = false;
if ((state==State.Ready) & (former==State.Initializing)){
try {
this.runAsync("devices/axis.py", true).handle((ret,ex)->{
loadedCommands = true;
updateControls();
return ret;
});
} catch (Context.ContextStateException ex) {
getLogger().log(Level.SEVERE, null, ex);
}
}
}
@Override
public void onExecutedFile(String fileName, Object result) {
}
//Callback to perform update - in event thread
@Override
protected void doUpdate() {
}
void selectCamera(String name){
renderer.clear();
currentCamera = ((name == null)||(name.isBlank()))? null : name;
renderer.setDeviceName(currentCamera);
updateControls();
}
void move(String direction){
try {
moving = true;
updateControls();
String camera = comboCameras.getSelectedItem().toString();
this.evalAsync("axis_move(" + camera + ", '" + direction + "')", true).handle((ret,ex)->{
moving = false;
updateControls();
return ret;
});
} catch (Context.ContextStateException ex) {
getLogger().log(Level.SEVERE, null, ex);
moving = false;
updateControls();
}
}
void zoom(int steps){
try {
moving = true;
updateControls();
String camera = comboCameras.getSelectedItem().toString();
this.evalAsync("axis_rzoom(" + camera + ", " + steps + ")", true).handle((ret,ex)->{
moving = false;
updateControls();
return ret;
});
} catch (Context.ContextStateException ex) {
getLogger().log(Level.SEVERE, null, ex);
moving = false;
updateControls();
}
}
ImageIcon getIcon(String name) {
ImageIcon ret = null;
try {
ret = new ImageIcon(ch.psi.pshell.ui.App.class.getResource("/ch/psi/pshell/ui/" + name + ".png"));
if (ch.psi.utils.swing.MainFrame.isDark()) {
try {
ret = new ImageIcon(ch.psi.pshell.ui.App.class.getResource("/ch/psi/pshell/ui/dark/" + name + ".png"));
} catch (Exception e) {
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return ret;
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
renderer = new ch.psi.pshell.imaging.Renderer();
panelControls = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
buttonMoveLeft = new javax.swing.JButton();
buttonMoveDLeft = new javax.swing.JButton();
buttonMoveDRight = new javax.swing.JButton();
buttonMoveRight = new javax.swing.JButton();
buttonMoveUReight = new javax.swing.JButton();
buttonMoveHome = new javax.swing.JButton();
buttonMoveDown = new javax.swing.JButton();
buttonMoveULeft = new javax.swing.JButton();
buttonMoveUp = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
buttonZoomOut = new javax.swing.JButton();
buttonZooHome = new javax.swing.JButton();
buttonZoomIn = new javax.swing.JButton();
jPanel3 = new javax.swing.JPanel();
comboCameras = new javax.swing.JComboBox<>();
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Move"));
buttonMoveLeft.setIcon(getIcon("arrows/Left"));
buttonMoveLeft.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonMoveLeftActionPerformed(evt);
}
});
buttonMoveDLeft.setIcon(getIcon("arrows/DLeft"));
buttonMoveDLeft.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonMoveDLeftActionPerformed(evt);
}
});
buttonMoveDRight.setIcon(getIcon("arrows/DRight"));
buttonMoveDRight.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonMoveDRightActionPerformed(evt);
}
});
buttonMoveRight.setIcon(getIcon("arrows/Right"));
buttonMoveRight.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonMoveRightActionPerformed(evt);
}
});
buttonMoveUReight.setIcon(getIcon("arrows/URight"));
buttonMoveUReight.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonMoveUReightActionPerformed(evt);
}
});
buttonMoveHome.setIcon(getIcon("arrows/Center"));
buttonMoveHome.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonMoveHomeActionPerformed(evt);
}
});
buttonMoveDown.setIcon(getIcon("arrows/Down"));
buttonMoveDown.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonMoveDownActionPerformed(evt);
}
});
buttonMoveULeft.setIcon(getIcon("arrows/ULeft"));
buttonMoveULeft.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonMoveULeftActionPerformed(evt);
}
});
buttonMoveUp.setIcon(getIcon("arrows/Up"));
buttonMoveUp.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonMoveUpActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(buttonMoveULeft, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonMoveDLeft, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(buttonMoveLeft, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(buttonMoveDown, javax.swing.GroupLayout.DEFAULT_SIZE, 40, Short.MAX_VALUE)
.addComponent(buttonMoveHome, javax.swing.GroupLayout.DEFAULT_SIZE, 40, Short.MAX_VALUE)
.addComponent(buttonMoveUp, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 40, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(buttonMoveRight, javax.swing.GroupLayout.DEFAULT_SIZE, 40, Short.MAX_VALUE)
.addComponent(buttonMoveUReight, javax.swing.GroupLayout.DEFAULT_SIZE, 40, Short.MAX_VALUE)
.addComponent(buttonMoveDRight, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel2Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonMoveDLeft, buttonMoveDRight, buttonMoveDown, buttonMoveHome, buttonMoveLeft, buttonMoveRight, buttonMoveULeft, buttonMoveUReight, buttonMoveUp});
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonMoveUp, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonMoveUReight, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonMoveULeft, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonMoveLeft, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonMoveRight, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonMoveHome, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonMoveDown, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonMoveDLeft, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonMoveDRight, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
jPanel2Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {buttonMoveDLeft, buttonMoveDRight, buttonMoveDown, buttonMoveHome, buttonMoveLeft, buttonMoveRight, buttonMoveULeft, buttonMoveUReight, buttonMoveUp});
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Zoom"));
buttonZoomOut.setIcon(getIcon("arrows/Out"));
buttonZoomOut.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonZoomOutActionPerformed(evt);
}
});
buttonZooHome.setIcon(getIcon("arrows/Center"));
buttonZooHome.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonZooHomeActionPerformed(evt);
}
});
buttonZoomIn.setIcon(getIcon("arrows/In"));
buttonZoomIn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonZoomInActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonZoomOut, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonZooHome, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonZoomIn, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonZooHome, buttonZoomIn, buttonZoomOut});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonZoomOut, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonZoomIn, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonZooHome, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap())
);
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Camera"));
comboCameras.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
comboCamerasActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(comboCameras, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(comboCameras, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
javax.swing.GroupLayout panelControlsLayout = new javax.swing.GroupLayout(panelControls);
panelControls.setLayout(panelControlsLayout);
panelControlsLayout.setHorizontalGroup(
panelControlsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelControlsLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelControlsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap())
);
panelControlsLayout.setVerticalGroup(
panelControlsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelControlsLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(322, Short.MAX_VALUE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, 0)
.addComponent(panelControls, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 522, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(panelControls, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(renderer, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
}// </editor-fold>//GEN-END:initComponents
private void comboCamerasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboCamerasActionPerformed
try{
if (getState().isInitialized()){
Object selection = comboCameras.getSelectedItem();
selectCamera((selection==null) ? null :selection.toString());
}
} catch(Exception ex){
showException(ex);
}
}//GEN-LAST:event_comboCamerasActionPerformed
private void buttonMoveULeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMoveULeftActionPerformed
move("upleft");
}//GEN-LAST:event_buttonMoveULeftActionPerformed
private void buttonMoveUpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMoveUpActionPerformed
move("up");
}//GEN-LAST:event_buttonMoveUpActionPerformed
private void buttonMoveUReightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMoveUReightActionPerformed
move("upright");
}//GEN-LAST:event_buttonMoveUReightActionPerformed
private void buttonMoveLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMoveLeftActionPerformed
move("left");
}//GEN-LAST:event_buttonMoveLeftActionPerformed
private void buttonMoveHomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMoveHomeActionPerformed
move("home");
}//GEN-LAST:event_buttonMoveHomeActionPerformed
private void buttonMoveRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMoveRightActionPerformed
move("right");
}//GEN-LAST:event_buttonMoveRightActionPerformed
private void buttonMoveDLeftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMoveDLeftActionPerformed
move("downleft");
}//GEN-LAST:event_buttonMoveDLeftActionPerformed
private void buttonMoveDownActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMoveDownActionPerformed
move("down");
}//GEN-LAST:event_buttonMoveDownActionPerformed
private void buttonMoveDRightActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMoveDRightActionPerformed
move("downright");
}//GEN-LAST:event_buttonMoveDRightActionPerformed
private void buttonZoomOutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonZoomOutActionPerformed
zoom(-100);
}//GEN-LAST:event_buttonZoomOutActionPerformed
private void buttonZooHomeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonZooHomeActionPerformed
move("home");
}//GEN-LAST:event_buttonZooHomeActionPerformed
private void buttonZoomInActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonZoomInActionPerformed
zoom(100);
}//GEN-LAST:event_buttonZoomInActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonMoveDLeft;
private javax.swing.JButton buttonMoveDRight;
private javax.swing.JButton buttonMoveDown;
private javax.swing.JButton buttonMoveHome;
private javax.swing.JButton buttonMoveLeft;
private javax.swing.JButton buttonMoveRight;
private javax.swing.JButton buttonMoveULeft;
private javax.swing.JButton buttonMoveUReight;
private javax.swing.JButton buttonMoveUp;
private javax.swing.JButton buttonZooHome;
private javax.swing.JButton buttonZoomIn;
private javax.swing.JButton buttonZoomOut;
private javax.swing.JComboBox<String> comboCameras;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel panelControls;
private ch.psi.pshell.imaging.Renderer renderer;
// End of variables declaration//GEN-END:variables
}
+712
View File
@@ -0,0 +1,712 @@
<?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>
</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>
+732
View File
@@ -0,0 +1,732 @@
import ch.psi.pshell.bs.PipelineServer;
import ch.psi.pshell.core.Context;
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.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);
} 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)->{
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));
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 (InterruptedException 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
// 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
}
+1
View File
@@ -0,0 +1 @@
/afs/psi.ch/intranet/SF/Applications/config/pshell_op/plugins/ScreenPanel.java
+1
View File
@@ -0,0 +1 @@
/afs/psi.ch/intranet/SF/Applications/config/pshell_op/plugins/ScreenPanel2.java
+1
View File
@@ -0,0 +1 @@
/afs/psi.ch/intranet/SF/Applications/config/pshell_op/plugins/ScreenPanel3.java
+1
View File
@@ -0,0 +1 @@
/afs/psi.ch/intranet/SF/Applications/config/pshell_op/plugins/ScreenPanel4.java
+4415
View File
File diff suppressed because it is too large Load Diff
+1359
View File
File diff suppressed because it is too large Load Diff
+4554
View File
File diff suppressed because it is too large Load Diff
+1
View File
@@ -0,0 +1 @@
/afs/psi.ch/intranet/SF/Applications/config/pshell_op/plugins/SfCamera.java
+1
View File
@@ -0,0 +1 @@
/afs/psi.ch/intranet/SF/Applications/config/pshell_op/plugins/resources
Binary file not shown.

After

Width:  |  Height:  |  Size: 640 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 306 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 328 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 172 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 614 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 609 B

BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 500 B

+196
View File
@@ -0,0 +1,196 @@
import math
import sys, traceback
from mathutils import fit_polynomial, PolynomialFunction
from plotutils import plot_line, plot_function
from ch.psi.pshell.swing.Shell import STDOUT_COLOR
import org.apache.commons.math3.stat.correlation.PearsonsCorrelation as PearsonsCorrelation
import ch.psi.pshell.bs.PipelineServer as PipelineServer
TYPE_CHANNEL = 0
TYPE_STREAM = 1
TYPE_CAMERA= 2
if get_exec_pars().source == CommandSource.ui:
dx = "SINDI01-RLLE-STA:SLAVE1-CPUTIMER"
#dx = "SLG-LCAM-C042 x_rms"
dxtype = TYPE_STREAM
dxtype = TYPE_CHANNEL
#dxtype = TYPE_CAMERA
#dy = "SINDI01-RLLE-STA:SLAVE1-DLTIMER"
dy = "SLG-LCAM-C042 y_rms"
dytype = TYPE_STREAM
dytype = TYPE_CHANNEL
dytype = TYPE_CAMERA
interval = 0.10
window = 40
p = plot(None)[0]
linear_fit = True
quadratic_fit = True
#print dx, dxtype
#print dy, dytype
corr = None
pars_lin = None
pars_quad = 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)
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:
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)
try:
if _stream != None:
_stream.initialize()
_stream.start(True)
if _camname != None:
shared = _camname.endswith("_sp1")
print "Camera: " , _camname, " shared: ", shared
cam_server.start(_camname, shared )
cam_server.stream.waitCacheChange(10000);
if dxtype==TYPE_CAMERA:
dx=cam_server.stream.getChild(dx)
if dytype==TYPE_CAMERA:
dy=cam_server.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)
marker=None
while(True):
#Sample and plot data
if bs == True:
_stream.waitValueNot(_stream.take(), 10000)
bsdata = list(_stream.take().values)
if dxtype==TYPE_CHANNEL:
x=dx.read()
elif dxtype==TYPE_STREAM:
x=bsdata.pop(0)
elif dxtype==TYPE_CAMERA:
x=dx.read()
if dytype==TYPE_CHANNEL:
y=dy.read()
elif dytype==TYPE_STREAM:
y=bsdata.pop(0)
elif dytype==TYPE_CAMERA:
y=dy.read()
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(STDOUT_COLOR)
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)
if bs != True:
time.sleep(interval)
finally:
for dev in instances:
dev.close()
+54
View File
@@ -0,0 +1,54 @@
###################################################################################################
# Example creating error plots
###################################################################################################
[py, px, pxy]=plot([None,None,None],["y","x", "xy"])
#Y error plot
py.setStyle(py.Style.ErrorY)
py.setLegendVisible(True)
sy1 = LinePlotErrorSeries("F1")
py.addSeries(sy1)
sy1.appendData(1.0, 10.0, 9.0, 11.0)
sy1.appendData(10.0, 6.1, 4.34, 7.54)
sy1.appendData(17.8, 4.5, 3.1, 5.8)
#One can define error instead of min/max (appendData(x, y, error))
sy2 = LinePlotErrorSeries("F2")
py.addSeries(sy2)
sy2.setLinesVisible(False)
sy2.appendData(3.0, 7.0, 2.0);
sy2.appendData(13.0, 13.0, 2.0);
sy2.appendData(24.0, 16.1, 1.0);
#X error plot
px.setStyle(px.Style.ErrorX)
px.setLegendVisible(True)
sx = LinePlotErrorSeries("F3")
px.addSeries(sx)
sx.appendData(1.0, 10.0, 0.5, 1.5)
sx.appendData(10.0, 6.1, 9.0, 10.3)
sx.appendData(17.8, 4.5, 17.0, 18.0)
#One can define error instead of min/max (appendData(x, y, error))
sx2 = LinePlotErrorSeries("F4")
px.addSeries(sx2)
sx2.setLinesVisible(False)
sx2.appendData(1.0, 3.0, 1.0)
sx2.appendData(10.0, 5.1, 1.0)
sx2.appendData(17.8, 7.5, 0.5)
#XY error plot
pxy.setStyle(pxy.Style.ErrorXY)
pxy.setLegendVisible(True)
sxy = LinePlotErrorSeries("F5")
pxy.addSeries(sxy)
sxy.appendData(1.0,0.5,1.5, 10.0, 9.0, 11.0)
sxy.appendData(10.0,9.0, 11.0, 6.1, 4.34, 7.54)
sxy.appendData(17.8, 17.0, 18.0, 4.5, 3.1, 5.8)
#One can define error instead of min/max (appendData(x, y, errorX, errorY))
sxy2 = LinePlotErrorSeries("F6")
pxy.addSeries(sxy2)
sxy2.appendData(3.0, 7.0, 0.5, 4.0);
sxy2.appendData(13.0, 13.0, 0.5, 3.0);
sxy2.appendData(24.0, 16.1, 0.2, 2.0);
+1
View File
@@ -0,0 +1 @@
[ "Linear", [ [ "Channel", "SLAAR21-LMOT-M552:MOT.VAL", 322.0, 323.0, 0.1 ] ], [ [ "Channel", "ELCOMAT:X ", 100, 0, "Enabled" ], [ "Channel", "ELCOMAT:Y", 100, 0, "Enabled" ] ], false, [ ], "", 1, 1.0, 0.0, false, false, true, true, "global_delay-stage", "", " ", "h5", 0, null, null, "Positioner", false, true ]
+39
View File
@@ -0,0 +1,39 @@
###################################################################################################
# Use of HardwareScan
###################################################################################################
import ch.psi.pshell.crlogic.CrlogicPositioner as CrlogicPositioner
import ch.psi.pshell.crlogic.CrlogicSensor as CrlogicSensor
#sc1.stop()
#sc1.setOneShot()
#sc1.channels[0].setPreset(False)
#sc1.channels[0].setPresetValue(0)
#sc1.start()
config = {}
config["class"] = "ch.psi.pshell.crlogic.CrlogicScan"
config["prefix"] = "MTEST-HW3-CRL"
config["ioc"] = "MTEST-VME-HW3.psi.ch"
config["integrationTime"] = 0.01
config["additionalBacklash"] = 0.0
pos = CrlogicPositioner("CrlogicPositioner", "MTEST-HW3:MOT1", None);
sensors = [
CrlogicSensor("Trigger0", "TRIGGER0"),
CrlogicSensor("Trigger1", "TRIGGER1"),
CrlogicSensor("Scaler0", "SCALER0", True),
CrlogicSensor("Scaler1", "SCALER1", True),
CrlogicSensor("Timestamp", "TIMESTAMP"),
]
pos.initialize()
pos.move(0.0)
try:
r1 = hscan(config, pos, sensors,0.0, 10.0, 0.1,1, False)
finally:
pos.close()
+13
View File
@@ -0,0 +1,13 @@
###################################################################################################
# Demonstrate the use of Line Scan: one or multiple positioners move together linearly.
###################################################################################################
#Execute the scan: 100 steps, a1 from 0 to 40
r1 = lscan(ao1, (ai1,ai2,wf1), 0, 40, 100, 0.01)
#Steps of size 1.0, a1 from 0 to 40
#r2 = lscan(ao1, (ai1,ai2,wf1), 0, 40, 1.0, 0.01)
#2 positioners moving together in 10 steps. Also sampling an image:
#r3 = lscan((ao1,ao2), (ai1,ai2,wf1,im1), (0, 0), (40, 100), 4, 0.01)
+50
View File
@@ -0,0 +1,50 @@
###################################################################################################
# Demonstrate the use of Monitor Scan: sampling based on device change event
###################################################################################################
#Simulating async devices:
ai1.setPolling(50)
ai2.setPolling(50)
#Execute the scan: 25 samples
r1 = mscan(ai1, [ai1], 25)
#Execute the scan: 50 samples, with a timeout of 2s, including a second device, which cache is sampled
r2 = mscan(ai1, [ai1, ai2], 50, 2.0)
#Execute the scan: sampling for 5s, an undefined number of sample
r3 = mscan(ai1, [ai1, ai2], -1, 5.0)
#If a non-cached sensor access is needed, scan must be started in sync mode, but records may then be lost.
#In this example ai1 is cached (the trigger always is), wf1 is not, and ai2 is.
r4 = mscan(ai1, [ai1, wf1, ai2.cache], -1, 5.0, async = False)
# Scanning a set of sensors based on a software trigger, using mscan
import random
class Trigger(ReadonlyRegisterBase):
def doRead(self):
return None
trigger = Trigger()
trigger.initialize()
def scan():
mscan(trigger, [ai1, ai2], 10)
scan_task = fork(scan)
time.sleep(0.5)
for i in range(10):
trigger.update()
time.sleep(random.random()/5)
ret = join(scan_task)
#Restoring the device state
ai1.setPolling(0)
ai2.setPolling(0)
+43
View File
@@ -0,0 +1,43 @@
scan_from = -1.7
scan_to = -1.0
steps = 10
motor = 'ca://SARFE10-PSSS059:MOTOR_Y3.VAL'
title = "PSSS crystal height scan"
size = caget('SARFE10-PSSS059:SPECTRUM_X.NORD','i')
sx = caget('SARFE10-PSSS059:SPECTRUM_X', size = size)
sy = create_device('ca://SARFE10-PSSS059:SPECTRUM_Y?samples=10&interval=10&size='+str(size))
class SpectrumY(ReadableArray, ReadableCalibratedArray):
def read(self):
return sy.read()
def getSize(self):
return size
def getCalibration(self):
return ArrayCalibration((sx[-1]-sx[0])/max(len(sx), 1), sx[0])
calibrated_sensor = SpectrumY()
r1 = lscan(motor, calibrated_sensor, start =scan_from, end = scan_to ,steps = steps, title=title)
#def getCrystal(crystal):
# xstal = crystal.read()
# if xstal == "None":
# Crystal_type = "None"
# elseif xstal == "Si(111)R155 4-5.5 keV"
# Crystal_type = "Si(220)R145"
# 2 Si(220)R75 5.5-8 keV
# 3 Si(220)R145 8-10.25 keV
# 4 Si(220)R200 10.25-13 keV
# 5 Si(333)R155
# return xstal
#print(getCrystal(crystal))
#motor = 'ca://SARFE10-PSSS059:MOTOR_Y3.VAL'
#title = "PSSS crystal height scan"
#sensor = ['ca://SARFE10-PSSS059:SPECTRUM_Y?samples=10&interval=10']
#scan_from = -1.7
#scan_to = -1.0
#steps = 10
#r1 = lscan(motor, sensor, start =scan_from, end = scan_to, [0.01], title=title)
#r1 = lscan(motor, sensor, start =scan_from, end = scan_to ,steps = steps, title=title)
+186
View File
@@ -0,0 +1,186 @@
import random
####################################################################################################
# Simulated Devices
####################################################################################################
class AnalogOutput(RegisterBase):
def doRead(self):
return self.val if hasattr(self, 'val') else 0.0
def doWrite(self, val):
self.val = val
class AnalogInput(ReadonlyRegisterBase):
def doRead(self):
time.sleep(0.001)
self.val = to_array(self.calc(), 'd')
return self.val
class Waveform(ReadonlyRegisterBase, ReadonlyRegisterArray):
def doRead(self):
time.sleep(0.001)
self.val = to_array(self.calc(), 'd')
return self.val
class Image(ReadonlyRegisterBase, ReadonlyRegisterMatrix):
def doRead(self):
time.sleep(0.001)
self.val = to_array(self.calc(), 'd')
return self.val
def getWidth(self):
return len(self.take(-1)[0])
def getHeight(self):
return len(self.take(-1))
class Random(AnalogInput):
def calc(self):
return random.random()
class SinusoidSample(AnalogInput):
def calc(self):
self.x = self.x + 0.1 if hasattr(self, 'x') else 0.0
noise = (random.random() - 0.5) / 10.0
return math.sin(self.x) + noise
class SinusoidTime(AnalogInput):
def calc(self):
noise = (random.random() - 0.5) / 10.0
return math.sin(time.time()) + noise
class SinusoidWaveform(Waveform):
def calc(self):
ret = []
x = random.random()
for i in range (20):
ret.append(math.sin(x))
x = x + 0.1
return ret
class SinusoidImage(Image):
def calc(self):
(width, height) = (200, 100)
ret = []
x = random.random();
base = []
for i in range (width):
base.append( math.sin(x))
x = x + 0.05
for i in range (height):
noise = (random.random() - 0.5)/5.0
ret.append([x+noise for x in base])
return ret
#Defintion
add_device(DummyMotor("m1"), True)
add_device(DummyMotor("m2"), True)
add_device(DummyRegister("reg1",3), True)
add_device(AnalogOutput("ao1"), True)
add_device(AnalogOutput("ao2"), True)
add_device(SinusoidSample("ai1"), True)
add_device(SinusoidTime("ai2"), True)
add_device(Random("ai3"), True)
add_device(SinusoidWaveform("wf1"), True)
add_device(SinusoidImage("im1"), True)
add_device(DummyPositioner("p1"),True)
add_device(MotorGroupBase("mg1", m1, m2), True)
add_device(MotorGroupDiscretePositioner("dp1", mg1), True)
#Initial Configuration
if p1.config.unit is None:
p1.config.minValue = 0.0 #Not persisted
p1.config.maxValue = 1000.0
p1.config.unit = "mm"
p1.config.save()
p1.initialize()
if dp1.config.positions is None:
dp1.config.positions = ["Park","Ready","Out","Clear"]
dp1.config.motor1 = ["0.0","4.0","8.0" ,"0.0"]
dp1.config.motor2 = ["0.0","5.0","3.0" ,"NaN"]
dp1.config.save()
dp1.initialize()
#Update
m1.setMonitored(True)
m2.setMonitored(True)
####################################################################################################
# Simple Readable / Writable objects can be created and used in scans
####################################################################################################
class WritableScalar(Writable):
def write(self, value):
pass
class ReadableScalar(Readable):
def read(self):
return random.random()
class ReadableWaveform(ReadableArray):
def getSize(self):
return 20
def read(self):
ret = []
for i in range (self.getSize()):
ret.append(random.random())
return ret
class ReadableImage(ReadableMatrix):
def read(self):
ret = []
for i in range (self.getHeight()):
ret.append([random.random()] * self.getWidth())
return to_array(ret, 'd')
def getWidth(self):
return 80
def getHeight(self):
return 40
ws1 = WritableScalar()
rs1 = ReadableScalar()
rw1 = ReadableWaveform()
ri1 = ReadableImage()
####################################################################################################
# Imaging
####################################################################################################
configured = os.path.exists(Device.getConfigFileName("src1"))
add_device(RegisterMatrixSource("src1", im1), True)
add_device(RegisterMatrixSource("src2", ri1), True)
src1.polling = 100
src2.polling = 100
#Some configuration for so the imaging will work out of the box
if not configured:
import ch.psi.pshell.imaging.Colormap
src1.config.colormapAutomatic = True
src1.config.colormap = ch.psi.pshell.imaging.Colormap.Temperature
src1.config.save()
src2.config.colormapAutomatic = True
src2.config.save()
+1
View File
@@ -0,0 +1 @@
lscan(['ca://SLAAR21-LMOT-M523:MOTOR_1.VAL'], ['ca://ELCOMAT:X?monitored=true&samples=10', 'ca://ELCOMAT:Y?monitored=true&samples=10'], [180.0], [270.0], [0.1], latency=0.0, relative=False, passes=1, zigzag=False, keep=False, name='global_delay_stage_long', provider='h5')
Executable
+1
View File
@@ -0,0 +1 @@
[ "Linear", [ [ "Channel", "SLAAR21-LMOT-M521:MOTOR_1.VAL", 165.0, 167.0, 0.25 ] ], [ [ "Channel", "SLAAR21-LSCP1-FNS:CH5:VAL_GET", 400, 0.04, "Enabled" ] ], false, [ ], "", 1, 1.0, 0.0, false, false, true, true, "/photonics/home/gac-bernina/BBOtest/EnergyScan002", "", " ", " ", 0, null, null, "Positioner", false, true ]
+25
View File
@@ -0,0 +1,25 @@
import ch.psi.pshell.device.HistogramGenerator as HistogramGenerator
CAMERA_NAME = "SARES20-PROF141-M1"
CHANNEL = "intensity"
cam_server.start(CAMERA_NAME + "_sp", CAMERA_NAME + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
dev = cam_server.stream.getChild(CHANNEL)
add_device(dev, True) #To see it in Device panel
samples = 100
range_min, range_max = float('nan'),float('nan')
bins = 100
hist = HistogramGenerator(CAMERA_NAME + "_" + CHANNEL + "_histogram", dev, samples, range_min, range_max, bins)
hist.monitored=True
add_device(hist, True)
show_panel(hist)
hist.config.bins = 100
hist.config.min = float('nan')
hist.config.max = float('nan')
hist.config.numberOfSamples = 1000
+65
View File
@@ -0,0 +1,65 @@
import ch.psi.pshell.device.HistogramGenerator as HistogramGenerator
CAMERA_NAME = "SAROP21-PPRM138"
cam_server.start(CAMERA_NAME + "_sp", CAMERA_NAME + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
CHANNEL = "intensity"
dev = cam_server.stream.getChild(CHANNEL)
add_device(dev, True) #To see it in Device panel
samples = 100
range_min, range_max = float('nan'),float('nan')
bins = 100
hist = HistogramGenerator(CAMERA_NAME + "_" + CHANNEL + "_histogram", dev, samples, range_min, range_max, bins)
hist.monitored=True
add_device(hist, True)
show_panel(hist)
hist.config.bins = 100
hist.config.min = float('nan')
hist.config.max = float('nan')
hist.config.numberOfSamples = 1000
CHANNEL = "x_fit_mean"
dev = cam_server.stream.getChild(CHANNEL)
add_device(dev, True) #To see it in Device panel
samples = 100
range_min, range_max = float('nan'),float('nan')
bins = 100
hist = HistogramGenerator(CAMERA_NAME + "_" + CHANNEL + "_histogram", dev, samples, range_min, range_max, bins)
hist.monitored=True
add_device(hist, True)
show_panel(hist)
hist.config.bins = 100
hist.config.min = float('nan')
hist.config.max = float('nan')
hist.config.numberOfSamples = 1000
CHANNEL = "y_fit_mean"
dev = cam_server.stream.getChild(CHANNEL)
add_device(dev, True) #To see it in Device panel
samples = 100
range_min, range_max = float('nan'),float('nan')
bins = 100
hist = HistogramGenerator(CAMERA_NAME + "_" + CHANNEL + "_histogram", dev, samples, range_min, range_max, bins)
hist.monitored=True
add_device(hist, True)
show_panel(hist)
hist.config.bins = 100
hist.config.min = float('nan')
hist.config.max = float('nan')
hist.config.numberOfSamples = 1000
+45
View File
@@ -0,0 +1,45 @@
import ch.psi.utils.swing.SwingUtils as SwingUtils
import ch.psi.pshell.device.HistogramGenerator as HistogramGenerator
import ch.psi.pshell.swing.HistogramGeneratorPanel as HistogramGeneratorPanel
from collections import OrderedDict
import javax.swing.border.TitledBorder as TitledBorder
import javax.swing.JPanel as JPanel
import javax.swing.BoxLayout as BoxLayout
import java.awt.Dimension as Dimension
CHANNELS = ["intensity",
"x_fit_mean",
"y_fit_mean",
"x_fit_standard_deviation",
"y_fit_standard_deviation",
]
samples = 2000
range_min, range_max = float('nan'),float('nan')
bins = 100
panels = OrderedDict()
cam_server.start(CAMERA_NAME + "_sp", CAMERA_NAME + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
for channel in CHANNELS:
dev = cam_server.stream.getChild(channel)
hist = HistogramGenerator(CAMERA_NAME + ":" + channel, dev, samples, range_min, range_max, bins)
hist.monitored=True
add_device(hist, True)
pn = HistogramGeneratorPanel()
pn.border=TitledBorder(hist.name)
pn.setShowTitle(True)
pn.setDevice(hist)
pn.setPreferredSize(Dimension(800,150))
panels[hist.name]=pn
pn = JPanel()
pn.layout = BoxLayout(pn, BoxLayout.Y_AXIS)
for k in panels.keys():
pn.add(panels[k])
dlg = SwingUtils.showDialog(None, CAMERA_NAME , None, pn)
while(True):
time.sleep(1)
@@ -0,0 +1,47 @@
import ch.psi.utils.swing.SwingUtils as SwingUtils
import ch.psi.pshell.device.HistogramGenerator as HistogramGenerator
import ch.psi.pshell.swing.HistogramGeneratorPanel as HistogramGeneratorPanel
from collections import OrderedDict
import javax.swing.border.TitledBorder as TitledBorder
import javax.swing.JPanel as JPanel
import javax.swing.BoxLayout as BoxLayout
import java.awt.Dimension as Dimension
CHANNELS = ["intensity",
"x_fit_mean",
"y_fit_mean",
"x_fit_standard_deviation",
"y_fit_standard_deviation",
]
samples = 2000
range_min, range_max = float('nan'),float('nan')
bins = 100
panels = OrderedDict()
CAMERA_NAME='SAROP21-PPRM138'
cam_server.start(CAMERA_NAME + "_sp", CAMERA_NAME + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
for channel in CHANNELS:
dev = cam_server.stream.getChild(channel)
hist = HistogramGenerator(CAMERA_NAME + ":" + channel, dev, samples, range_min, range_max, bins)
hist.monitored=True
add_device(hist, True)
pn = HistogramGeneratorPanel()
pn.border=TitledBorder(hist.name)
pn.setShowTitle(True)
pn.setDevice(hist)
pn.setPreferredSize(Dimension(800,150))
panels[hist.name]=pn
pn = JPanel()
pn.layout = BoxLayout(pn, BoxLayout.Y_AXIS)
for k in panels.keys():
pn.add(panels[k])
dlg = SwingUtils.showDialog(None, CAMERA_NAME , None, pn)
while(True):
time.sleep(1)
+65
View File
@@ -0,0 +1,65 @@
import ch.psi.pshell.device.HistogramGenerator as HistogramGenerator
#CAMERA_NAME = "SAROP21-PPRM102"
CAMERA_NAME = "SAROP21-PPRM138"
cam_server.start(CAMERA_NAME + "_sp", CAMERA_NAME + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
CHANNEL = "intensity"
dev = cam_server.stream.getChild(CHANNEL)
add_device(dev, True) #To see it in Device panel
samples = 100
range_min, range_max = float('nan'),float('nan')
bins = 100
hist = HistogramGenerator(CAMERA_NAME + "_" + CHANNEL + "_histogram", dev, samples, range_min, range_max, bins)
hist.monitored=True
add_device(hist, True)
show_panel(hist)
hist.config.bins = 100
hist.config.min = float('nan')
hist.config.max = float('nan')
hist.config.numberOfSamples = 1000
CHANNEL = "x_fit_mean"
dev = cam_server.stream.getChild(CHANNEL)
add_device(dev, True) #To see it in Device panel
samples = 100
range_min, range_max = float('nan'),float('nan')
bins = 100
hist = HistogramGenerator(CAMERA_NAME + "_" + CHANNEL + "_histogram", dev, samples, range_min, range_max, bins)
hist.monitored=True
add_device(hist, True)
show_panel(hist)
hist.config.bins = 100
hist.config.min = float('nan')
hist.config.max = float('nan')
hist.config.numberOfSamples = 1000
CHANNEL = "y_fit_mean"
dev = cam_server.stream.getChild(CHANNEL)
add_device(dev, True) #To see it in Device panel
samples = 100
range_min, range_max = float('nan'),float('nan')
bins = 100
hist = HistogramGenerator(CAMERA_NAME + "_" + CHANNEL + "_histogram", dev, samples, range_min, range_max, bins)
hist.monitored=True
add_device(hist, True)
show_panel(hist)
hist.config.bins = 100
hist.config.min = float('nan')
hist.config.max = float('nan')
hist.config.numberOfSamples = 1000
+46
View File
@@ -0,0 +1,46 @@
import ch.psi.pshell.device.HistogramGenerator as HistogramGenerator
CAMERA_NAME = "SARES20-PROF142-M1"
cam_server.start(CAMERA_NAME + "_sp", CAMERA_NAME + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
CHANNEL = "x_fit_standard_deviation"
dev = cam_server.stream.getChild(CHANNEL)
add_device(dev, True) #To see it in Device panel
samples = 100
range_min, range_max = float('nan'),float('nan')
bins = 100
hist = HistogramGenerator(CAMERA_NAME + "_" + CHANNEL + "_histogram", dev, samples, range_min, range_max, bins)
hist.monitored=True
add_device(hist, True)
show_panel(hist)
hist.config.bins = 100
hist.config.min = float('nan')
hist.config.max = float('nan')
hist.config.numberOfSamples = 1000
CHANNEL = "y_fit_standard_deviation"
dev = cam_server.stream.getChild(CHANNEL)
add_device(dev, True) #To see it in Device panel
samples = 100
range_min, range_max = float('nan'),float('nan')
bins = 100
hist = HistogramGenerator(CAMERA_NAME + "_" + CHANNEL + "_histogram", dev, samples, range_min, range_max, bins)
hist.monitored=True
add_device(hist, True)
show_panel(hist)
hist.config.bins = 100
hist.config.min = float('nan')
hist.config.max = float('nan')
hist.config.numberOfSamples = 1000
+41
View File
@@ -0,0 +1,41 @@
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
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)
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,100])
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
+32
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)
+36
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
+27
View File
@@ -0,0 +1,27 @@
import requests
def axis_exec(camera, cmd):
if is_string(camera):
camera = get_device(camera)
url = camera.url
s="axis-cgi/"
ctrl_url = url[0:url.find(s) + len(s)] + "com/ptz.cgi?"
cmd_url=ctrl_url+cmd
response = requests.get(url=cmd_url)
if 200<=response.status_code<300:
return response.text.strip()
raise Exception(response.text)
def axis_move(camera, direction):
direction=str(direction)
if direction not in ("home", "up", "down", "left", "right", "upleft", "upright", "downleft", "downright", "stop"):
raise Exception("Invalid direction: " + direction)
return axis_exec(camera, "move="+direction)
def axis_rzoom(camera, steps):
steps= int(steps)
if steps<-9999 or steps>9999:
raise Exception("Invalid relative zoom steps: " + str(steps))
return axis_exec(camera, "rzoom="+str(steps))
+3
View File
@@ -0,0 +1,3 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// Deployment specific global definitions - executed after startup.groovy
///////////////////////////////////////////////////////////////////////////////////////////////////
+4
View File
@@ -0,0 +1,4 @@
///////////////////////////////////////////////////////////////////////////////////////////////////
// Deployment specific global definitions - executed after startup.js
///////////////////////////////////////////////////////////////////////////////////////////////////
+222
View File
@@ -0,0 +1,222 @@
###################################################################################################
# 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
###################################################################################################
# Pseudo-devices
###################################################################################################
###################################################################################################
# Camera server
###################################################################################################
def wait_cam_server_message(number_messages = 1, timeout = 10000):
for i in range (number_messages):
if not cam_server.stream.waitCacheChange(timeout):
raise Exception("Timeout receiving from camera server")
def get_cam_server_stats(number_images=1, async = True, interval=-1, good_region = False):
ret = []
wait_cam_server_message()
prefix = "gr_" if good_region else ""
for ident in [prefix+"x_center_of_mass", prefix+"y_center_of_mass", prefix+"x_rms", prefix+"y_rms"]:
child = cam_server.stream.getChild(ident)
av = create_averager(child, number_images, interval)
av.monitored = async
ret.append(av)
return ret
def wait_cam_server_background(background, timeout = 10000):
start = time.time()
while True:
processing_parameters = cam_server.getProcessingParameters()
if (processing_parameters is not None) and (str(background) == processing_parameters["image_background"]):
return
if (time.time()-start) > timeout/1000:
raise Exception("Timeout waiting for camera server background: " + str(background))
time.sleep(0.01)
+63
View File
@@ -0,0 +1,63 @@
#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.setLegendVisible(True)
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
r = lscan(cam_x, (av, av_samples), RANGE_FROM, RANGE_TO, STEPS, latency=0.0, 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")
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)
+72
View File
@@ -0,0 +1,72 @@
###############################################################################
#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
if PLOT:
PLOT.clear()
run("cpython/wrapper")
#Setup and functions setup¶
if not is_dry_run():
xstal_height=Channel("ARFE10-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
r = lscan(xstal_height, (av, av_samples), RANGE_FROM, RANGE_TO, STEPS, latency=2.0, 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)
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()
#Plots
"""
plt.figure(figsize=[10,5])
plt.subplot(121)
plt.title('PSSS scan of crystal height')
plt.pcolormesh(energy_axis, xstal_range, Scan_spec.mean(axis=1),cmap='CMRmap')
plt.xlim([energy_axis[0],energy_axis[-1]])
plt.ylim([xstal_range[0], xstal_range[-1]])
plt.xlabel('PSSS energy axis')
plt.ylabel('Set crystal position [mm] \n'+PSSS_xstal_height_name[0:-4])
plt.subplot(122)
plt.plot(projection,xstal_range,linewidth = 2, color = 'orange',label ='projected signal')
plt.plot(gaus(xstal_range_fit,*popt),xstal_range_fit,'r:',label='fit')
plt.ylim([xstal_range[0], xstal_range[-1]])
plt.title('Signal max at %.3f [mm] (from fit)'%popt[1])
plt.xticks([])
plt.legend()
plt.grid(True)
"""
plot_gauss_fit(xstal_range, projection, gauss_pars=(offset, amp, mean_val, sigma), p=PLOT, title = "Data")
set_return(mean_val)
+89
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
if RANGE_OFF is not None:
RANGE_FROM = energy_machine.read()-RANGE_OFF
RANGE_TO = energy_machine.read()+RANGE_OFF
run("cpython/wrapper")
if PLOT:
PLOT.clear()
#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"
r = lscan(en, (av, av_samples), RANGE_FROM, RANGE_TO, STEPS, latency=0.0, save=False )
average, samples, energy_range = r.getReadable(0), r.getReadable(1), r.getPositions(0)
[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)
#Plot
"""
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')
plt.plot(gaus(Energy_range_fit,*popt),Energy_range_fit,'r:',label='fit')
plt.xticks([])
plt.legend()
plt.grid(True)
"""
plot_gauss_fit(energy_range, centre_line_out, gauss_pars=(offset, amp, mean_val, sigma), p=PLOT, title = "Data")
set_return(mean_val)
+149
View File
@@ -0,0 +1,149 @@
import org.jfree.ui.RectangleAnchor as RectangleAnchor
import org.jfree.ui.TextAnchor as TextAnchor
import ch.psi.pshell.imaging.Overlay as Overlay
import ch.psi.pshell.plot.RangeSelectionPlot as RangeSelectionPlot
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 = 1):
"""
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).
if p.getNumberOfSeries()==0:
p.addSeries(LinePlotSeries("spectrum"))
p.addSeries(LinePlotSeries("average"))
p.setLegendVisible(True)
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, center,fwhm = get_psss_data(average)
if (x is None) or (y is None):
p.getSeries(1).clear()
else:
p.getSeries(1).setData(x,y)
x,y, _,_ = get_psss_data(1)
if (x is None) or (y is None):
p.getSeries(0).clear()
else:
p.getSeries(0).setData(x,y)
if (center!= None) and (fwhm!=None):
m.startValue, m.endValue = center - fwhm, center + fwhm
m.label = str(center)
if h:
if h.getNumberOfSeries()==0:
h.addSeries(TimePlotSeries("center"))
h.addSeries(TimePlotSeries("fwhm",2))
h.setLegendVisible(True)
h.setTimeAxisLabel("")
h.getSeries(0).appendData(center)
h.getSeries(1).appendData(fwhm)
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", PSSS_CAMERA_NAME + "_sp1")
#ovmin, ovmax= Overlays.Crosshairs(renderer.getPenMarker(), Dimension(-1,1)), \
# Overlays.Crosshairs(renderer.getPenMarker(), Dimension(-1,1))
ovmin, ovmax= Overlays.Line(renderer.getPenMarker()), Overlays.Line(renderer.getPenMarker())
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])
+25
View File
@@ -0,0 +1,25 @@
import ch.psi.pshell.device.HistogramGenerator as HistogramGenerator
CAMERA_NAME = "SARES20-PROF141-M1"
CHANNEL = "intensity"
cam_server.start(CAMERA_NAME + "_sp", CAMERA_NAME + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
dev = cam_server.stream.getChild(CHANNEL)
add_device(dev, True) #To see it in Device panel
samples = 100
range_min, range_max = float('nan'),float('nan')
bins = 100
hist = HistogramGenerator(CAMERA_NAME + "_" + CHANNEL + "_histogram", dev, samples, range_min, range_max, bins)
hist.monitored=True
add_device(hist, True)
show_panel(hist)
hist.config.bins = 100
hist.config.min = float('nan')
hist.config.max = float('nan')
hist.config.numberOfSamples = 100
+23
View File
@@ -0,0 +1,23 @@
import ch.psi.pshell.device.HistogramGenerator as HistogramGenerator
CAMERA_NAMES = ["SARES20-PROF141-M1"]
CHANNELS = ["intensity", "x_center_of_mass"]
samples = 100
range_min, range_max = float('nan'),float('nan')
bins = 100
for camera_name in CAMERA_NAMES:
cam_server.start(camera_name + "_sp", camera_name + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
for channel in CHANNELS:
dev = cam_server.stream.getChild(channel)
hist = HistogramGenerator(camera_name + "_" + channel + "_histogram", dev, samples, range_min, range_max, bins)
hist.monitored=True
add_device(hist, True)
show_panel(hist)
while(True):
time.sleep(1)
+50
View File
@@ -0,0 +1,50 @@
import ch.psi.utils.swing.SwingUtils as SwingUtils
import ch.psi.pshell.device.HistogramGenerator as HistogramGenerator
import ch.psi.pshell.swing.HistogramGeneratorPanel as HistogramGeneratorPanel
from collections import OrderedDict
import javax.swing.border.TitledBorder as TitledBorder
import javax.swing.JPanel as JPanel
import javax.swing.BoxLayout as BoxLayout
import java.awt.Dimension as Dimension
CAMERA_NAMES = ["SARES20-PROF141-M1"]
CHANNELS = ["intensity",
"x_center_of_mass",
"x_fwhm",
"x_rms",
"x_fit_amplitude",
"x_fit_mean",
"x_fit_offset",
"x_fit_standard_deviation",
"x_profile"
]
samples = 100
range_min, range_max = float('nan'),float('nan')
bins = 100
panels = OrderedDict()
for camera_name in CAMERA_NAMES:
cam_server.start(camera_name + "_sp", camera_name + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
for channel in CHANNELS:
dev = cam_server.stream.getChild(channel)
hist = HistogramGenerator(camera_name + ":" + channel, dev, samples, range_min, range_max, bins)
hist.monitored=True
add_device(hist, True)
pn = HistogramGeneratorPanel()
pn.border=TitledBorder(hist.name)
pn.setShowTitle(True)
pn.setDevice(hist)
pn.setPreferredSize(Dimension(800,150))
panels[hist.name]=pn
pn = JPanel()
pn.layout = BoxLayout(pn, BoxLayout.Y_AXIS)
for k in panels.keys():
pn.add(panels[k])
dlg = SwingUtils.showDialog(None, "Histograms", None, pn)
while(True):
time.sleep(1)
+49
View File
@@ -0,0 +1,49 @@
import ch.psi.utils.swing.SwingUtils as SwingUtils
import ch.psi.pshell.device.HistogramGenerator as HistogramGenerator
import ch.psi.pshell.swing.HistogramGeneratorPanel as HistogramGeneratorPanel
from collections import OrderedDict
import javax.swing.border.TitledBorder as TitledBorder
import javax.swing.JPanel as JPanel
import javax.swing.BoxLayout as BoxLayout
import java.awt.Dimension as Dimension
CHANNELS = ["intensity",
"x_center_of_mass",
"x_fwhm",
"x_rms",
"x_fit_amplitude",
"x_fit_mean",
"x_fit_offset",
"x_fit_standard_deviation",
"x_profile"
]
samples = 100
range_min, range_max = float('nan'),float('nan')
bins = 100
panels = OrderedDict()
cam_server.start(CAMERA_NAME + "_sp", CAMERA_NAME + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
for channel in CHANNELS:
dev = cam_server.stream.getChild(channel)
hist = HistogramGenerator(CAMERA_NAME + ":" + channel, dev, samples, range_min, range_max, bins)
hist.monitored=True
add_device(hist, True)
pn = HistogramGeneratorPanel()
pn.border=TitledBorder(hist.name)
pn.setShowTitle(True)
pn.setDevice(hist)
pn.setPreferredSize(Dimension(800,150))
panels[hist.name]=pn
pn = JPanel()
pn.layout = BoxLayout(pn, BoxLayout.Y_AXIS)
for k in panels.keys():
pn.add(panels[k])
dlg = SwingUtils.showDialog(None, CAMERA_NAME , None, pn)
while(True):
time.sleep(1)
+143
View File
@@ -0,0 +1,143 @@
"""
"""
if get_exec_pars().source == CommandSource.ui:
PREFIX = "SLAAR-LBSTREAM1"
if not "VERBOSE" in globals():
VERBOSE = True
if not "TIME_INTERVAL" in globals():
TIME_INTERVAL = 1.0
if PREFIX[-1] != ":":
PREFIX = PREFIX + ":"
def get_channel_list():
ch=[]
try:
for i in range(20):
v= caget(PREFIX + "NAME" + str(i+1))
if v.strip()=="":
break
ch.append(str(v.strip()))
except:
pass
return ch
def ack_channel_list(channel_list):
try:
s=""
for c in channel_list:
s=s+c+"\n"
s=s+"\x00"
caput(PREFIX + "PACK_LIST",[ord(c) for c in s])
except:
pass
def start_stream(channel_list):
try:
print "Starting stream"
if len(channel_list)==0:
raise Exception ("No channel defined")
st = Stream("pulse_id", dispatcher)
for c in channel_list:
st.addScalar(c, c, 1, 0)
st.initialize()
st.start()
st.waitCacheChange(10000) #Wait stream be running before starting scan
if st.take() is None:
raise Exception("Error initializing data stream")
print "Stream started"
except:
st=None
print sys.exc_info()[1]
finally:
ack_channel_list(channel_list)
return st
def stop_stream(st):
try:
if st:
st.close()
st=None
print "Stream closed"
except:
print sys.exc_info()[1]
finally:
ack_channel_list([])
#def on_start_change(val):
# fork(start_stream if (val==1) else stop_stream)
#start = Channel(PREFIX + "START_STOP", type = 'i', monitored = True, callback=on_start_change)
t0=None
def handle_message(msg, channel_list, buf):
global t0
if t0 is None:
t0 = time.time()
now=time.time()
num_channels = len(channel_list)
size_buffer= 300 #int((len(buf)-100)/(len(channel_list)+1))
index = int(buf[2])*(num_channels+1) + 10
buf[index] = msg.pulseId
index = index+1
for v in msg.values():
buf[index] = v
index = index+1
buf[2] = buf[2]+1
if (now >= (t0 + TIME_INTERVAL)) or (buf[2] == size_buffer):
buf[0] = msg.pulseId
buf[1]= num_channels
buf[3]= buf[2]-1
if VERBOSE:
print to_list(buf[0:4])
buf[2] = 0
t0 = time.time()
return True
return False
def run():
channel_list = []
st=None
start = Channel(PREFIX + "START_STOP", type = 'i')
outp = Channel(PREFIX + "PACK_DATA", type = '[d')
buf = to_array([0]*outp.get_size(),'d')
buf[2]= 0
try:
while True:
started = (start.get()==1)
if started and not st:
print "Started"
channel_list=get_channel_list()
print "Channel list: ", channel_list
st = start_stream(channel_list)
class StreamListener (DeviceListener):
def onValueChanged(self, device, value, former):
if handle_message(value, channel_list, buf):
outp.putq(buf)
listener = StreamListener()
st.addListener(listener)
elif st and not started:
print "Stopped"
channel_list=[]
stop_stream(st)
st = None
"""
if st:
st.waitCacheChange(0)
if handle_message(st.take(), channel_list, buf):
outp.putq(buf)
time.sleep(0.001)
else:
time.sleep(0.1)
"""
time.sleep(0.1)
finally:
stop_stream(st)
if outp: outp.close()
if start: start.close()
+2
View File
@@ -0,0 +1,2 @@
import sys
print (sys.argv)
+42
View File
@@ -0,0 +1,42 @@
if get_exec_pars().source == CommandSource.ui:
E_OFF = None
E_FROM = 7200
E_TO = 7340
STEPS = 10
NUM_SHOTS= 3
PLOT=None
run("cpython/wrapper")
class Positioner(Writable):
def write(self, value):
pass
av = create_averager(psss_spectrum_y,NUM_SHOTS,interval=-1,name="spectrum_average")
av_samples = av.samples
av_samples.alias = "spectrum_samples"
sensors = (av, av_samples)
#r=tscan(sensors, STEPS, 0.1)
r=lscan(Positioner(),sensors, 10, 10+STEPS, STEPS)
average, samples, pos_range= r.getReadable(0), r.getReadable(1), r.getPositions(0)
#[amp, mean_val, sigma, offset],ydata = fit_energy(E_FROM, E_TO, STEPS +1, NUM_SHOTS, samples)
#[amp, mean_val, sigma, offset],ydata = fit_crystal_height(E_FROM, E_TO, STEPS+1, samples)
#if (mean_val<= E_FROM) or (mean_val>= E_TO):
# raise Exception ("Invalid fit mean: " + str(mean_val))
signal_centre, ydata = get_signal_centre(samples, pos_range)
#plot_gauss_fit(pos_range, ydata, gauss_pars=(offset, amp, mean_val, sigma), p=PLOT, title = "Data")
#plot_gauss_fit(pos_range, ydata, gauss_pars=None, p=PLOT, title = "Data")
#PLOT.clear()
#plot_data(PLOT, ydata, "Data", xdata=pos_range, show_points = True, color=Color.BLUE)
+11
View File
@@ -0,0 +1,11 @@
import org.jfree.ui.RectangleAnchor as RectangleAnchor
import org.jfree.ui.TextAnchor as TextAnchor
p=plot(None)[0]
m1=p.addMarker(0,None,"",Color.WHITE)
m2=p.addMarker(0,None,"",Color.WHITE)
m2.setLabelAnchor(RectangleAnchor.TOP)
while True:
p.getSeries(0).setData(psss_spectrum_x.take(), psss_spectrum_y.take())
m1.value, m2.value = psss_center.take() - psss_fwhm.take(),psss_center.take() + psss_fwhm.take()
m2.label = str(psss_center.take())
time.sleep(1.0)
+13
View File
@@ -0,0 +1,13 @@
p=plot(None)[0]
while True:
plot_psss(p)
time.sleep(1.0)
+17
View File
@@ -0,0 +1,17 @@
import ch.psi.pshell.device.HistogramGenerator as HistogramGenerator
cam_server.start("SARES20-PROF141-M1_sp", "SARES20-PROF141-M1_sp1")
channels = ["intensity",
"x_center_of_mass",
"x_fwhm",
"x_rms",
"x_fit_amplitude",
"x_fit_mean",
"x_fit_offset",
"x_fit_standard_deviation",
"x_profile"
]
for channel in channels:
dev = cam_server.stream.getChild(channel)
add_device(dev, True)
+43
View File
@@ -0,0 +1,43 @@
import ch.psi.pshell.bs.DispatcherConfig.Incomplete as Incomplete
channels = ["SAROP11-PBPS117:INTENSITY", \
"SAROP11-PBPS117:XPOS", \
"SAROP11-PBPS117:YPOS", \
"SLG-LSCP2-FNS:CH0:VAL_GET", \
"SINEG01-DBPM340:Q1", \
"SINEG01-DBPM340:X1", \
"SINEG01-DBPM340:Y1", \
"SINEG01-DBPM340:Q2", \
"S20SY02-DBPM150:Q1", \
"SINEG01-DBPM340:X2", \
"SINEG01-DBPM340:Y2", \
"SLG-LSCP2-FNS:CH0:VAL_GET"]
channels = [ \
"SINEG01-DBPM340:X2", \
"S20SY02-DBPM150:Q1", \
"SLG-LSCP2-FNS:CH0:VAL_GET" \
]
#channels = ["SLG-LSCP2-FNS:CH0:VAL_GET"]
dispatcher.config.mappingIncomplete=None
dispatcher.config.mappingIncomplete = Incomplete.fill_null
#dispatcher.config.mappingIncomplete = Incomplete.provide_as_is
#dispatcher.config.mappingIncomplete = Incomplete.drop
s1 = Stream("s1", dispatcher)
s1.initialize()
for c in channels:
s1.addScalar(c,c, 1, 0)
s1.addScalar("SINEG01-DBPM340:Q2","SINEG01-DBPM340:Q2", 1, 0)
add_device(s1, True)
s1.start()
s1.waitCacheChange(5000)
for i in range(20):
print s1.take().keys(), s1.take().values()
s1.waitCacheChange(5000)
#ret = bscan (s1, 20, None, save=False)
+163
View File
@@ -0,0 +1,163 @@
"""
Run as:
pshell_be -l -test -c -f="users/edwin/correlation_stream.py" -args="PREFIX:'SLAAR-LBSTREAM1'"
or with additional parameters:
pshell_be -l -test -c -f="users/edwin/correlation_stream.py" -args="PREFIX:'SLAAR-LBSTREAM1',VERBOSE:False,TIME_INTERVAL:2.0"
"""
if not "PREFIX" in globals():
PREFIX = "SLAAR-LBSTREAM1"
if not "VERBOSE" in globals():
VERBOSE = False
if not "TIME_INTERVAL" in globals():
TIME_INTERVAL = 1.0
EMPTY_VALUE = 1112223330
if PREFIX[-1] != ":":
PREFIX = PREFIX + ":"
def get_channel_list():
ch=[]
try:
for i in range(20):
v= caget(PREFIX + "NAME" + str(i+1))
if v.strip()=="":
break
ch.append(str(v.strip()))
except:
pass
return ch
def ack_channel_list(channel_list):
try:
s=""
for c in channel_list:
s=s+c+"\n"
s=s+"\x00"
caput(PREFIX + "PACK_LIST",[ord(c) for c in s])
except:
pass
def start_stream(channel_list):
try:
st=None
print "Starting stream"
if len(channel_list)==0:
raise Exception ("No channel defined")
st = Stream("pulse_id", dispatcher)
for c in channel_list:
st.addScalar(c, c, 1, 0)
st.initialize()
st.start()
st.waitCacheChange(10000) #Wait stream be running before starting scan
if st.take() is None:
raise Exception("Error initializing data stream")
ack_channel_list(channel_list)
print "Stream started"
except:
stop_stream(st)
st=None
print sys.exc_info()[1]
return st
def stop_stream(st):
try:
if st:
st.close()
st=None
print "Stream closed"
except:
print sys.exc_info()[1]
finally:
ack_channel_list([])
#def on_start_change(val):
# fork(start_stream if (val==1) else stop_stream)
#start = Channel(PREFIX + "START_STOP", type = 'i', monitored = True, callback=on_start_change)
t0=None
pid=None
def handle_message(msg, channel_list, buf):
global t0, pid
if t0 is None:
t0 = time.time()
now=time.time()
num_channels = len(channel_list)
size_buffer= 300 #int((len(buf)-100)/(len(channel_list)+1))
buf[0] = msg.pulseId
buf[1] = num_channels
buf[4] = EMPTY_VALUE
#if (pid is not None) and ((pid+1) != msg.pulseId):
# print "Missing pid: ", (pid+1)
pid = msg.pulseId
#Count
if buf[2] < size_buffer:
buf[2] = buf[2]+1
#Index
buf[3] = buf[3]+1
if buf[3] == size_buffer:
buf[3]=0
index = int(buf[3])*(num_channels+1) + 10
buf[index] = msg.pulseId
index = index+1
for v in msg.values():
buf[index] = EMPTY_VALUE if ((v is None) or (math.isnan(v)))else v
index = index+1
if now >= (t0 + TIME_INTERVAL):
if VERBOSE:
print to_list(buf[0:5])
t0 = time.time()
return True
return False
def run():
channel_list = []
st=None
start = Channel(PREFIX + "START_STOP", type = 'i')
outp = Channel(PREFIX + "PACK_DATA", type = '[d')
buf = to_array([0]*outp.get_size(),'d')
buf[2] = 0
buf[3]= -1
try:
while True:
started = (start.get()==1)
if started and not st:
print "Started"
channel_list=get_channel_list()
print "Channel list: ", channel_list
st = start_stream(channel_list)
if st is not None:
class StreamListener (DeviceListener):
def onValueChanged(self, device, value, former):
if handle_message(value, channel_list, buf):
outp.putq(buf)
listener = StreamListener()
st.addListener(listener)
elif st and not started:
print "Stopped"
channel_list=[]
stop_stream(st)
st = None
"""
if st:
st.waitCacheChange(0)
if handle_message(st.take(), channel_list, buf):
outp.putq(buf)
time.sleep(0.001)
else:
time.sleep(0.1)
"""
time.sleep(0.1)
finally:
stop_stream(st)
if outp: outp.close()
if start: start.close()
if __name__ == "__main__":
run()