Jun 2024
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#Tue Oct 31 13:01:30 CET 2023
|
||||
#Mon Jun 10 10:43:14 CEST 2024
|
||||
XScanAppendSuffix=true
|
||||
XScanCrlogicAbortable=true
|
||||
XScanCrlogicChannel=null
|
||||
@@ -20,6 +20,7 @@ dataScanReleaseRecords=false
|
||||
dataScanSaveOutput=false
|
||||
dataScanSaveScript=false
|
||||
dataScanSaveSetpoints=true
|
||||
dataScanSaveTimestamps=false
|
||||
dataServerPort=5573
|
||||
dataTransferHost=
|
||||
dataTransferMode=Off
|
||||
@@ -46,10 +47,11 @@ noBytecodeFiles=false
|
||||
notificationLevel=User
|
||||
notifiedTasks=Test1,TestDate, xxx
|
||||
parallelInitialization=false
|
||||
pythonHome={home}/cpython
|
||||
saveCommandStatistics=true
|
||||
saveConsoleSessionFiles=false
|
||||
scanStreamerPort=5563
|
||||
serverEnabled=true
|
||||
serverEnabled=false
|
||||
serverPort=8080
|
||||
sessionHandling=On
|
||||
simulation=false
|
||||
|
||||
@@ -23,7 +23,7 @@ pip=ch.psi.pshell.camserver.PipelineStream|localhost:8889 simulation_sp|||true
|
||||
#rr=RotationReadback|TESTIOC:TESTCALCOUT:Output|||true
|
||||
#rp=ch.psi.pshell.epics.Positioner|TESTIOC:TESTCALCOUT:Input null rr|||
|
||||
#webcam=ch.psi.pshell.webcam.Webcam|:2|||true
|
||||
deting=ch.psi.pshell.imaging.CameraSource|det||-500|
|
||||
#deting=ch.psi.pshell.imaging.CameraSource|det||-500|
|
||||
#PiezoRoll1=ch.psi.pshell.epics.ControlledVariable|"TESTIOC:TESTCALCOUT:Input" TESTIOC:TESTCALCOUT:Output false|||true
|
||||
#$ser=ch.psi.pshell.serial.TcpDevice||||
|
||||
#$beam_ok=ch.psi.pshell.epics.ChannelString|CHANNEL|||
|
||||
@@ -92,6 +92,7 @@ slit=ch.psi.pshell.device.Slit|motor motor2|||
|
||||
#$vhq4=ch.psi.pshell.epics.Vhq4|T-MMDV5|||
|
||||
#$ps=PowerSupply|T-MMDV5|||
|
||||
pe=ch.psi.pshell.epics.Positioner|"TESTIOC:TESTCALCOUT:Input" TESTIOC:TESTCALCOUT:Output|||true
|
||||
pe2=ch.psi.pshell.device.DummyPositioner||||true
|
||||
cv=ch.psi.pshell.epics.ControlledVariable|TESTIOC:TESTCALCOUT:Input TESTIOC:TESTCALCOUT:Output|||true
|
||||
#detector=ch.psi.pshell.detector.DetectorBase|http://127.0.0.1:8090/|||
|
||||
#serial=ch.psi.pshell.serial.SerialPortDevice||||
|
||||
@@ -129,7 +130,7 @@ gamma=ch.psi.pshell.device.DummyMotor||||true
|
||||
eta=ch.psi.pshell.device.DummyMotor||||true
|
||||
chi=ch.psi.pshell.device.DummyMotor||||true
|
||||
phi=ch.psi.pshell.device.DummyMotor||||true
|
||||
#sixc=ch.psi.pshell.device.MotorGroupBase|mu delta gamma eta chi phi|||
|
||||
sixc=ch.psi.pshell.device.MotorGroupBase|mu delta gamma eta chi phi|||
|
||||
#fivec=ch.psi.pshell.device.MotorGroupBase|delta gamma eta chi phi|||
|
||||
#fourc=ch.psi.pshell.device.MotorGroupBase|delta eta chi phi|||
|
||||
fourcv=ch.psi.pshell.device.MotorGroupBase|mu delta gamma eta|||
|
||||
|
||||
@@ -3,28 +3,33 @@
|
||||
"crystal": "['cubic', 1, 1, 1, 90.0, 90.0, 90.0]",
|
||||
"reflist": {
|
||||
"1": {
|
||||
"tag": null,
|
||||
"hkl": "[1.0, 0.0, 0.0]",
|
||||
"pos": "[0, 1.0, 0.0, 0.0, 0.0, 0.0]",
|
||||
"energy": 12.39842,
|
||||
"time": "2020-07-15T15:45:37.924000"
|
||||
},
|
||||
"2": {
|
||||
"tag": null,
|
||||
"tag": "None",
|
||||
"hkl": "[0.0, 1.0, 0.0]",
|
||||
"pos": "[0, 60, 0, 30, 0, 90]",
|
||||
"energy": 12.39842,
|
||||
"time": "2020-07-15T15:45:37.960000"
|
||||
"time": "2023-11-03T14:09:46.383000"
|
||||
},
|
||||
"2": {
|
||||
"tag": "None",
|
||||
"hkl": "[1.0, 0.0, 0.0]",
|
||||
"pos": "[0.0, 1.0, 0.0, 0.0, 0.0, 0.0]",
|
||||
"energy": 20.0,
|
||||
"time": "2023-11-03T14:09:46.375000"
|
||||
}
|
||||
},
|
||||
"orientlist": {},
|
||||
"tau": 0,
|
||||
"sigma": 0,
|
||||
"reference": {
|
||||
"n_hkl_configured": null,
|
||||
"n_phi_configured": "[0.0, 0.0, 1.0]"
|
||||
},
|
||||
"u": null,
|
||||
"u": [
|
||||
"1.0, 0.0, 0.0",
|
||||
"0.0, 1.0, 0.0",
|
||||
"0.0, 0.0, 1.0"
|
||||
],
|
||||
"ub": null,
|
||||
"or0": 1,
|
||||
"or1": 2
|
||||
"or0": null,
|
||||
"or1": null
|
||||
}
|
||||
@@ -1,3 +1,7 @@
|
||||
Scan.java=disabled
|
||||
Redis.java=disabled
|
||||
DemoScan.java=disabled
|
||||
X.java=disabled
|
||||
sc.java=disabled
|
||||
Regine.java=disabled
|
||||
ScreenPanel11.java=disabled
|
||||
|
||||
@@ -65,10 +65,10 @@
|
||||
"hideScanPanel" : false,
|
||||
"hideOutputPanel" : false,
|
||||
"showXScanFileBrowser" : true,
|
||||
"showQueueBrowser" : true,
|
||||
"showQueueBrowser" : false,
|
||||
"backgroundRendering" : false,
|
||||
"showImageStatusBar" : true,
|
||||
"persistRendererWindows" : false,
|
||||
"persistRendererWindows" : true,
|
||||
"defaultRendererColormap" : "Grayscale",
|
||||
"linePlot" : "ch.psi.pshell.plot.LinePlotJFree",
|
||||
"matrixPlot" : "ch.psi.pshell.plot.MatrixPlotJFree",
|
||||
@@ -127,10 +127,7 @@
|
||||
"deviceClassName" : "ch.psi.pshell.camserver.CamServerService",
|
||||
"panelClassName" : "ch.psi.pshell.swing.CamServerServicePanel"
|
||||
}, {
|
||||
"deviceClassName" : "ch.psi.pshell.device.ReadonlyRegister$ReadonlyRegisterArray",
|
||||
"panelClassName" : "ch.psi.pshell.swing.DeviceValueChart"
|
||||
}, {
|
||||
"deviceClassName" : "ch.psi.pshell.device.ReadonlyRegister$ReadonlyRegisterMatrix",
|
||||
"deviceClassName" : "ch.psi.pshell.device.ReadonlyRegister",
|
||||
"panelClassName" : "ch.psi.pshell.swing.DeviceValueChart"
|
||||
} ],
|
||||
"scriptPopupDialog" : "Exception"
|
||||
|
||||
@@ -1,3 +1,2 @@
|
||||
#Mon Apr 03 15:43:39 CEST 2023
|
||||
CurrentSession=177
|
||||
#Fri Nov 03 13:49:20 CET 2023
|
||||
SessionCounter=177
|
||||
|
||||
@@ -1,27 +1,28 @@
|
||||
#Fri Jun 10 11:48:34 CEST 2022
|
||||
scriptPath={home}/script
|
||||
sessionsPath={outp}/sessions
|
||||
configFileDevices={config}/devices.properties
|
||||
xscanPath={script}/test
|
||||
queuePath={script}/queues
|
||||
extensionsPath={home}/extensions
|
||||
configFileUpdateStrategy={config}/update.properties
|
||||
configPath={home}/config
|
||||
configFileSessions={config}/sessions.properties
|
||||
userSessionsPath={sessions}/user
|
||||
dataPath={outp}/data
|
||||
configFileVariables={config}/variables.properties
|
||||
logPath={outp}/log
|
||||
wwwPath={home}/www
|
||||
#Wed Mar 20 10:42:57 CET 2024
|
||||
cPythonPath={home}/cpython
|
||||
configFile={config}/config.properties
|
||||
configFileTasks={config}/tasks.properties
|
||||
configFileDevices={config}/devices.properties
|
||||
configFileImageSources={config}/imaging.properties
|
||||
pluginsPath={home}/plugins
|
||||
consoleSessionsPath={sessions}/console
|
||||
libraryPath={script}; {script}/Lib; src/main/assembly/script/tutorial; {script}/imaging
|
||||
configFilePlugins={config}/plugins.properties
|
||||
contextPath={outp}/context
|
||||
devicesPath={home}/devices
|
||||
configFileSessions={config}/sessions.properties
|
||||
configFileSettings={config}/settings.properties
|
||||
imagesPath={outp}/images
|
||||
configFileTasks={config}/tasks.properties
|
||||
configFileUpdateStrategy={config}/update.properties
|
||||
configFileVariables={config}/variables.properties
|
||||
configPath={home}/config
|
||||
consoleSessionsPath={sessions}/console
|
||||
contextPath={outp}/context
|
||||
dataPath={outp}/data
|
||||
devicesPath={home}/devices
|
||||
extensionsPath={home}/extensions
|
||||
imagesPath={data}
|
||||
libraryPath={script}; {script}/Lib; src/main/assembly/script/tutorial; {script}/imaging
|
||||
logPath={outp}/log
|
||||
pluginsPath={home}/plugins
|
||||
queuePath={script}/queues
|
||||
scriptPath={home}/script
|
||||
scriptType=py
|
||||
sessionsPath={outp}/sessions
|
||||
userSessionsPath={sessions}/user
|
||||
wwwPath={home}/www
|
||||
xscanPath={script}/test
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#Fri Sep 29 09:45:06 CEST 2023
|
||||
#Mon Jun 10 09:15:34 CEST 2024
|
||||
CurrentSession=122
|
||||
DaySequentialNumber=26
|
||||
FileSequentialNumber=5986
|
||||
LastRunDate=230929
|
||||
DaySequentialNumber=1
|
||||
FileSequentialNumber=6920
|
||||
LastRunDate=240610
|
||||
SessionCounter=127
|
||||
xxx=[1, 2, 3, 4]
|
||||
|
||||
20
devices/20240314_115334_console_0000.tiff.properties
Normal file
20
devices/20240314_115334_console_0000.tiff.properties
Normal file
@@ -0,0 +1,20 @@
|
||||
#Thu Mar 14 11:53:42 CET 2024
|
||||
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
|
||||
@@ -1,8 +1,8 @@
|
||||
#Tue Oct 31 10:08:05 CET 2023
|
||||
#Thu Mar 21 16:43:31 CET 2024
|
||||
colormap=Flame
|
||||
colormapAutomatic=true
|
||||
colormapLogarithmic=false
|
||||
colormapMax=9814.0
|
||||
colormapMax=1628.0
|
||||
colormapMin=0.0
|
||||
custom=12345
|
||||
flipHorizontally=false
|
||||
@@ -23,9 +23,9 @@ rotation=0.0
|
||||
rotationCrop=false
|
||||
scale=1.0
|
||||
serverURL=http\://gfa-lc6-64\:8889
|
||||
spatialCalOffsetX=-638.5965043983313
|
||||
spatialCalOffsetY=-485.427166868422
|
||||
spatialCalScaleX=-35.21126791588346
|
||||
spatialCalScaleY=-48.38709170854271
|
||||
spatialCalOffsetX=-198.999999289148
|
||||
spatialCalOffsetY=-98.99999627491977
|
||||
spatialCalScaleX=-7.518797014727082
|
||||
spatialCalScaleY=-8.542713216994429
|
||||
spatialCalUnits=mm
|
||||
transpose=false
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#Thu Sep 21 16:17:46 CEST 2023
|
||||
#Mon Feb 19 10:54:19 CET 2024
|
||||
colormap=Flame
|
||||
colormapAutomatic=true
|
||||
colormapLogarithmic=false
|
||||
@@ -18,9 +18,9 @@ roiY=0
|
||||
rotation=0.0
|
||||
rotationCrop=false
|
||||
scale=1.0
|
||||
spatialCalOffsetX=-640.2010477461916
|
||||
spatialCalOffsetY=-487.87880023403306
|
||||
spatialCalScaleX=-35.2112662923995
|
||||
spatialCalScaleY=-48.387093592171716
|
||||
spatialCalOffsetX=-199.49874674479167
|
||||
spatialCalOffsetY=-99.3311027678703
|
||||
spatialCalScaleX=-7.518796992481203
|
||||
spatialCalScaleY=-8.542712973910431
|
||||
spatialCalUnits=mm
|
||||
transpose=false
|
||||
|
||||
20
devices/data2_0000.tiff.properties
Normal file
20
devices/data2_0000.tiff.properties
Normal file
@@ -0,0 +1,20 @@
|
||||
#Thu Mar 14 17:31:59 CET 2024
|
||||
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
|
||||
20
devices/data3.tiff.properties
Normal file
20
devices/data3.tiff.properties
Normal file
@@ -0,0 +1,20 @@
|
||||
#Thu Mar 14 18:00:17 CET 2024
|
||||
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
|
||||
20
devices/data3_0000.tiff.properties
Normal file
20
devices/data3_0000.tiff.properties
Normal file
@@ -0,0 +1,20 @@
|
||||
#Thu Mar 14 17:28:53 CET 2024
|
||||
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
|
||||
20
devices/det image_0000.tiff.properties
Normal file
20
devices/det image_0000.tiff.properties
Normal file
@@ -0,0 +1,20 @@
|
||||
#Thu Mar 14 09:17:36 CET 2024
|
||||
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
|
||||
20
devices/det image_0001.tiff.properties
Normal file
20
devices/det image_0001.tiff.properties
Normal file
@@ -0,0 +1,20 @@
|
||||
#Thu Mar 14 09:17:39 CET 2024
|
||||
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
|
||||
20
devices/det image_0002.tiff.properties
Normal file
20
devices/det image_0002.tiff.properties
Normal file
@@ -0,0 +1,20 @@
|
||||
#Thu Mar 14 09:17:38 CET 2024
|
||||
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
|
||||
20
devices/det image_0005.tiff.properties
Normal file
20
devices/det image_0005.tiff.properties
Normal file
@@ -0,0 +1,20 @@
|
||||
#Thu Mar 14 14:26:27 CET 2024
|
||||
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
|
||||
20
devices/det image_0006.tiff.properties
Normal file
20
devices/det image_0006.tiff.properties
Normal file
@@ -0,0 +1,20 @@
|
||||
#Thu Mar 14 14:33:28 CET 2024
|
||||
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
|
||||
20
devices/det image_combined.tiff.properties
Normal file
20
devices/det image_combined.tiff.properties
Normal file
@@ -0,0 +1,20 @@
|
||||
#Thu Mar 14 15:39:17 CET 2024
|
||||
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
|
||||
@@ -1,4 +1,5 @@
|
||||
#Wed Aug 15 09:55:09 CEST 2018
|
||||
#Fri Nov 03 14:09:46 CET 2023
|
||||
description=null
|
||||
maxValue=10.0
|
||||
minValue=-10.0
|
||||
offset=0.0
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
#Wed Apr 18 09:33:05 CEST 2018
|
||||
#Fri Nov 03 14:09:46 CET 2023
|
||||
description=null
|
||||
precision=4
|
||||
|
||||
17
devices/im1.properties
Normal file
17
devices/im1.properties
Normal file
@@ -0,0 +1,17 @@
|
||||
#Tue Nov 07 09:47:37 CET 2023
|
||||
defaultSpeed=NaN
|
||||
description=null
|
||||
estbilizationDelay=0
|
||||
maxSpeed=NaN
|
||||
maxValue=NaN
|
||||
minSpeed=NaN
|
||||
minValue=NaN
|
||||
monitorByPosition=false
|
||||
offset=0.0
|
||||
precision=-1
|
||||
resolution=NaN
|
||||
rotation=false
|
||||
scale=1.0
|
||||
sign_bit=0
|
||||
startRetries=1
|
||||
unit=null
|
||||
@@ -1,4 +1,5 @@
|
||||
#Wed Aug 15 09:55:09 CEST 2018
|
||||
#Fri Nov 03 14:09:46 CET 2023
|
||||
description=null
|
||||
maxValue=10.0
|
||||
minValue=-10.0
|
||||
offset=0.0
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#Wed Aug 15 09:55:09 CEST 2018
|
||||
#Fri Nov 03 14:09:46 CET 2023
|
||||
description=null
|
||||
maxValue=10.0
|
||||
minValue=-10.0
|
||||
offset=0.0
|
||||
|
||||
11
devices/pe2.properties
Normal file
11
devices/pe2.properties
Normal file
@@ -0,0 +1,11 @@
|
||||
#Wed Jan 17 16:52:10 CET 2024
|
||||
description=null
|
||||
maxValue=NaN
|
||||
minValue=NaN
|
||||
offset=0.0
|
||||
precision=-1
|
||||
resolution=NaN
|
||||
rotation=false
|
||||
scale=1.0
|
||||
sign_bit=0
|
||||
unit=null
|
||||
@@ -1,10 +1,11 @@
|
||||
#Fri Jul 24 14:51:57 CEST 2020
|
||||
minValue=-1000.0
|
||||
unit=mm
|
||||
offset=0.0
|
||||
#Fri Nov 03 13:50:52 CET 2023
|
||||
description=null
|
||||
maxValue=1000.0
|
||||
minValue=-1000.0
|
||||
offset=0.0
|
||||
precision=5
|
||||
rotation=false
|
||||
sign_bit=0
|
||||
scale=1.0
|
||||
resolution=Infinity
|
||||
rotation=false
|
||||
scale=1.0
|
||||
sign_bit=0
|
||||
unit=mm
|
||||
|
||||
20
devices/scan 1output.tiff.properties
Normal file
20
devices/scan 1output.tiff.properties
Normal file
@@ -0,0 +1,20 @@
|
||||
#Thu Mar 14 15:32:22 CET 2024
|
||||
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
|
||||
@@ -1,4 +1,5 @@
|
||||
#Thu Aug 02 17:12:34 CEST 2018
|
||||
#Thu Jan 18 14:16:35 CET 2024
|
||||
description=null
|
||||
maxValue=NaN
|
||||
minValue=NaN
|
||||
offset=0.0
|
||||
|
||||
20
devices/stack_0000.tiff.properties
Normal file
20
devices/stack_0000.tiff.properties
Normal file
@@ -0,0 +1,20 @@
|
||||
#Thu Mar 14 17:04:25 CET 2024
|
||||
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
|
||||
20
devices/stack_0001.tiff.properties
Normal file
20
devices/stack_0001.tiff.properties
Normal file
@@ -0,0 +1,20 @@
|
||||
#Thu Mar 14 17:16:21 CET 2024
|
||||
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
|
||||
@@ -1,5 +1,14 @@
|
||||
#Fri Jun 22 09:13:00 CEST 2018
|
||||
#Wed Mar 13 10:00:19 CET 2024
|
||||
add_float=null
|
||||
att_bool=null
|
||||
att_float=null
|
||||
att_int=null
|
||||
att_test=null
|
||||
b=false
|
||||
boolval=null
|
||||
d=1.0
|
||||
floatval=null
|
||||
i=5
|
||||
intval=null
|
||||
s=Test5
|
||||
strval=null
|
||||
|
||||
11
devices/test_positioner.properties
Normal file
11
devices/test_positioner.properties
Normal file
@@ -0,0 +1,11 @@
|
||||
#Thu Nov 02 08:59:26 CET 2023
|
||||
description=null
|
||||
maxValue=100.0
|
||||
minValue=-100.0
|
||||
offset=0.0
|
||||
precision=2
|
||||
resolution=NaN
|
||||
rotation=false
|
||||
scale=1.0
|
||||
sign_bit=0
|
||||
unit=null
|
||||
5
devices/testdev.properties
Normal file
5
devices/testdev.properties
Normal file
@@ -0,0 +1,5 @@
|
||||
#Wed Mar 13 10:00:36 CET 2024
|
||||
boolval=true
|
||||
floatval=1.0
|
||||
intval=1
|
||||
strval=Test
|
||||
20
devices/tst.tiff.properties
Normal file
20
devices/tst.tiff.properties
Normal file
@@ -0,0 +1,20 @@
|
||||
#Thu Feb 29 15:35:28 CET 2024
|
||||
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
|
||||
115
plugins/DemoScan.form
Normal file
115
plugins/DemoScan.form
Normal file
@@ -0,0 +1,115 @@
|
||||
<?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" attributes="0">
|
||||
<EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="spStart" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="spEnd" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="Steps" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="spSteps" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="plot" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="21" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spStart" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="21" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spEnd" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="21" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="Steps" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spSteps" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Component id="plot" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Start:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="spStart">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||
<SpinnerModel initial="0.0" maximum="10.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="spEnd">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||
<SpinnerModel initial="0.5" maximum="10.0" minimum="0.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="End:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="spSteps">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||
<SpinnerModel initial="10" maximum="10" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="Steps">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Steps:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="ch.psi.pshell.plot.LinePlotJFree" name="plot">
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
163
plugins/DemoScan.java
Normal file
163
plugins/DemoScan.java
Normal file
@@ -0,0 +1,163 @@
|
||||
|
||||
import ch.psi.pshell.ui.ScriptProcessor;
|
||||
import ch.psi.pshell.ui.Task;
|
||||
import ch.psi.utils.State;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class DemoScan extends ScriptProcessor {
|
||||
|
||||
public DemoScan() {
|
||||
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) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTaskFinished(Task task) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTimer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLoaded() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onUnloaded() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStartingExecution(Map<String, Object> args) throws Exception{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishedExecution(Map<String, Object> args, Object ret, Throwable t) throws Exception{
|
||||
}
|
||||
|
||||
|
||||
//Invoked by 'update()' to update components in the event thread
|
||||
@Override
|
||||
protected void doUpdate() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getScript(){
|
||||
//TODO
|
||||
return "DemoScan";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getArgs(){
|
||||
Map<String, Object> ret = new HashMap<>();
|
||||
ret.put("START", spStart.getValue());
|
||||
ret.put("END", spEnd.getValue());
|
||||
ret.put("STEPS", spSteps.getValue());
|
||||
ret.put("PLOT", plot);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
spStart = new javax.swing.JSpinner();
|
||||
spEnd = new javax.swing.JSpinner();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
spSteps = new javax.swing.JSpinner();
|
||||
Steps = new javax.swing.JLabel();
|
||||
plot = new ch.psi.pshell.plot.LinePlotJFree();
|
||||
|
||||
jLabel1.setText("Start:");
|
||||
|
||||
spStart.setModel(new javax.swing.SpinnerNumberModel(0.0d, 0.0d, 10.0d, 1.0d));
|
||||
|
||||
spEnd.setModel(new javax.swing.SpinnerNumberModel(0.5d, 0.0d, 10.0d, 1.0d));
|
||||
|
||||
jLabel2.setText("End:");
|
||||
|
||||
spSteps.setModel(new javax.swing.SpinnerNumberModel(10, 0, 10, 1));
|
||||
|
||||
Steps.setText("Steps:");
|
||||
|
||||
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(25, 25, 25)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(spStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel2)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(spEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(Steps)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(spSteps, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(21, 21, 21)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(spStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(21, 21, 21)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel2)
|
||||
.addComponent(spEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(21, 21, 21)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(Steps)
|
||||
.addComponent(spSteps, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JLabel Steps;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private ch.psi.pshell.plot.LinePlotJFree plot;
|
||||
private javax.swing.JSpinner spEnd;
|
||||
private javax.swing.JSpinner spStart;
|
||||
private javax.swing.JSpinner spSteps;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
@@ -22,11 +22,11 @@
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="scriptButton2" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" alignment="0" groupAlignment="1" max="-2" attributes="0">
|
||||
<Group type="103" alignment="0" groupAlignment="1" attributes="0">
|
||||
<Component id="jSpinner1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="motorPanel2" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jSpinner2" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
@@ -40,9 +40,21 @@
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jButton2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="219" max="-2" attributes="0"/>
|
||||
<Component id="jSpinner3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
|
||||
<Component id="pvp" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="line" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="6" pref="6" max="-2" attributes="0"/>
|
||||
<Component id="time" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
@@ -57,13 +69,9 @@
|
||||
<Component id="scriptButton1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="line" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace min="6" pref="6" max="-2" attributes="0"/>
|
||||
<Component id="time" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="dvc" min="-2" pref="342" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
@@ -72,34 +80,47 @@
|
||||
</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="motorPanel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="scriptButton2" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jSpinner1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jSpinner2" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jSpinner3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="motorPanel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="scriptButton2" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jSpinner1" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jSpinner2" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jSpinner3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="21" max="-2" attributes="0"/>
|
||||
<Component id="jRadioButton1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jRadioButton2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="buttonExecShellCmd" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="pvp" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace min="-2" pref="21" max="-2" attributes="0"/>
|
||||
<Component id="jRadioButton1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="line" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jRadioButton2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="buttonExecShellCmd" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Component id="time" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="dvc" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="panelSetp" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="panelRbck" linkSize="1" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
@@ -108,12 +129,6 @@
|
||||
<Component id="scriptButton1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="line" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="time" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="12" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
@@ -209,5 +224,18 @@
|
||||
<Property name="name" type="java.lang.String" value="TESTIOC:TESTCALCOUT:Input" noResource="true"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Container class="ch.psi.pshell.swing.DeviceValueChart" name="dvc">
|
||||
<Properties>
|
||||
<Property name="deviceName" type="java.lang.String" value="sin"/>
|
||||
</Properties>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignBorderLayout"/>
|
||||
</Container>
|
||||
<Component class="ch.psi.pshell.swing.ProcessVariablePanel" name="pvp">
|
||||
<Properties>
|
||||
<Property name="deviceName" type="java.lang.String" value="motor"/>
|
||||
<Property name="showStop" type="boolean" value="false"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
||||
@@ -81,6 +81,16 @@ public class PanelPlugin extends Panel {
|
||||
time = new ch.psi.pshell.plot.TimePlotJFree();
|
||||
panelSetp = new ch.psi.pshell.swing.RegisterPanel();
|
||||
panelRbck = new ch.psi.pshell.swing.DeviceValuePanel();
|
||||
try {
|
||||
dvc = new ch.psi.pshell.swing.DeviceValueChart();
|
||||
} catch (java.lang.ClassNotFoundException e1) {
|
||||
e1.printStackTrace();
|
||||
} catch (java.lang.InstantiationException e2) {
|
||||
e2.printStackTrace();
|
||||
} catch (java.lang.IllegalAccessException e3) {
|
||||
e3.printStackTrace();
|
||||
}
|
||||
pvp = new ch.psi.pshell.swing.ProcessVariablePanel();
|
||||
|
||||
motorPanel2.setDeviceName("m1");
|
||||
|
||||
@@ -119,6 +129,11 @@ public class PanelPlugin extends Panel {
|
||||
|
||||
panelRbck.setName("TESTIOC:TESTCALCOUT:Input"); // NOI18N
|
||||
|
||||
dvc.setDeviceName("sin");
|
||||
|
||||
pvp.setDeviceName("motor");
|
||||
pvp.setShowStop(false);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
@@ -129,7 +144,7 @@ public class PanelPlugin extends Panel {
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(scriptButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(motorPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
@@ -141,8 +156,17 @@ public class PanelPlugin extends Panel {
|
||||
.addComponent(jRadioButton1)))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jButton2)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(jSpinner3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))))
|
||||
.addGap(219, 219, 219)
|
||||
.addComponent(jSpinner3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
|
||||
.addGap(6, 6, 6)
|
||||
.addComponent(pvp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(line, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(6, 6, 6)
|
||||
.addComponent(time, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(86, 86, 86)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
@@ -150,51 +174,53 @@ public class PanelPlugin extends Panel {
|
||||
.addComponent(panelSetp, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(panelRbck, javax.swing.GroupLayout.PREFERRED_SIZE, 82, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(scriptButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(line, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(scriptButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(6, 6, 6)
|
||||
.addComponent(time, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap()
|
||||
.addComponent(dvc, javax.swing.GroupLayout.PREFERRED_SIZE, 342, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(motorPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(scriptButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jSpinner3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(21, 21, 21)
|
||||
.addComponent(jRadioButton1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jRadioButton2)
|
||||
.addContainerGap()
|
||||
.addComponent(motorPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(buttonExecShellCmd)
|
||||
.addComponent(jButton2))))
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(scriptButton2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jSpinner1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jSpinner2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jSpinner3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(21, 21, 21)
|
||||
.addComponent(jRadioButton1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jRadioButton2)
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(buttonExecShellCmd)
|
||||
.addComponent(jButton2))))
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(pvp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(line, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(time, 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(dvc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(panelSetp, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(panelRbck, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(44, 44, 44)
|
||||
.addComponent(scriptButton1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(25, 25, 25))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(line, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(time, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGap(0, 12, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {panelRbck, panelSetp});
|
||||
@@ -225,6 +251,7 @@ public class PanelPlugin extends Panel {
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton buttonExecShellCmd;
|
||||
private javax.swing.ButtonGroup buttonGroup1;
|
||||
private ch.psi.pshell.swing.DeviceValueChart dvc;
|
||||
private javax.swing.JButton jButton2;
|
||||
private javax.swing.JRadioButton jRadioButton1;
|
||||
private javax.swing.JRadioButton jRadioButton2;
|
||||
@@ -235,6 +262,7 @@ public class PanelPlugin extends Panel {
|
||||
private ch.psi.pshell.swing.MotorPanel motorPanel2;
|
||||
private ch.psi.pshell.swing.DeviceValuePanel panelRbck;
|
||||
private ch.psi.pshell.swing.RegisterPanel panelSetp;
|
||||
private ch.psi.pshell.swing.ProcessVariablePanel pvp;
|
||||
private ch.psi.pshell.swing.ScriptButton scriptButton1;
|
||||
private ch.psi.pshell.swing.ScriptButton scriptButton2;
|
||||
private ch.psi.pshell.plot.TimePlotJFree time;
|
||||
|
||||
115
plugins/Scan.form
Normal file
115
plugins/Scan.form
Normal file
@@ -0,0 +1,115 @@
|
||||
<?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="54" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="spSteps" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="spEnd" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="spStart" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace min="-2" pref="47" max="-2" attributes="0"/>
|
||||
<Component id="plot" 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="18" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="spStart" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<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="spEnd" 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="spSteps" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace min="-2" pref="7" max="-2" attributes="0"/>
|
||||
<Component id="plot" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Start:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="spStart">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||
<SpinnerModel initial="0.0" maximum="10.0" minimum="-10.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="spEnd">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||
<SpinnerModel initial="0.5" maximum="10.0" minimum="-10.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel2">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="End:"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JSpinner" name="spSteps">
|
||||
<Properties>
|
||||
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
|
||||
<SpinnerModel initial="10" maximum="100" minimum="1" numberType="java.lang.Integer" stepSize="1" type="number"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="jLabel3">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Steps"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="ch.psi.pshell.plot.LinePlotJFree" name="plot">
|
||||
<Properties>
|
||||
<Property name="title" type="java.lang.String" value=""/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
162
plugins/Scan.java
Normal file
162
plugins/Scan.java
Normal file
@@ -0,0 +1,162 @@
|
||||
|
||||
import ch.psi.pshell.ui.ScriptProcessor;
|
||||
import ch.psi.pshell.ui.Task;
|
||||
import ch.psi.utils.State;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class Scan extends ScriptProcessor {
|
||||
|
||||
public Scan() {
|
||||
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) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTaskFinished(Task task) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTimer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLoaded() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onUnloaded() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStartingExecution(Map<String, Object> args) throws Exception{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishedExecution(Map<String, Object> args, Object ret, Throwable t) throws Exception{
|
||||
}
|
||||
|
||||
|
||||
//Invoked by 'update()' to update components in the event thread
|
||||
@Override
|
||||
protected void doUpdate() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getScript(){
|
||||
return ("DemoScan");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getArgs(){
|
||||
Map<String, Object> ret = new HashMap();
|
||||
ret.put("START", spStart.getValue());
|
||||
ret.put("END", spEnd.getValue());
|
||||
ret.put("STEPS", spSteps.getValue());
|
||||
ret.put("PLOT", plot);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
spStart = new javax.swing.JSpinner();
|
||||
spEnd = new javax.swing.JSpinner();
|
||||
jLabel2 = new javax.swing.JLabel();
|
||||
spSteps = new javax.swing.JSpinner();
|
||||
jLabel3 = new javax.swing.JLabel();
|
||||
plot = new ch.psi.pshell.plot.LinePlotJFree();
|
||||
|
||||
jLabel1.setText("Start:");
|
||||
|
||||
spStart.setModel(new javax.swing.SpinnerNumberModel(0.0d, -10.0d, 10.0d, 1.0d));
|
||||
|
||||
spEnd.setModel(new javax.swing.SpinnerNumberModel(0.5d, -10.0d, 10.0d, 1.0d));
|
||||
|
||||
jLabel2.setText("End:");
|
||||
|
||||
spSteps.setModel(new javax.swing.SpinnerNumberModel(10, 1, 100, 1));
|
||||
|
||||
jLabel3.setText("Steps");
|
||||
|
||||
plot.setTitle("");
|
||||
|
||||
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(54, 54, 54)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel3)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(spSteps, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel2)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(spEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(spStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
||||
.addGap(47, 47, 47)
|
||||
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addGap(18, 18, 18)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel1)
|
||||
.addComponent(spStart, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel2)
|
||||
.addComponent(spEnd, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(jLabel3)
|
||||
.addComponent(spSteps, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
|
||||
.addGap(7, 7, 7)
|
||||
.addComponent(plot, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JLabel jLabel3;
|
||||
private ch.psi.pshell.plot.LinePlotJFree plot;
|
||||
private javax.swing.JSpinner spEnd;
|
||||
private javax.swing.JSpinner spStart;
|
||||
private javax.swing.JSpinner spSteps;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
28
plugins/X.form
Normal file
28
plugins/X.form
Normal file
@@ -0,0 +1,28 @@
|
||||
<?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">
|
||||
<EmptySpace min="0" pref="303" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<EmptySpace min="0" pref="176" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
</Form>
|
||||
98
plugins/X.java
Normal file
98
plugins/X.java
Normal file
@@ -0,0 +1,98 @@
|
||||
|
||||
import ch.psi.pshell.ui.ScriptProcessor;
|
||||
import ch.psi.pshell.ui.Task;
|
||||
import ch.psi.utils.State;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class X extends ScriptProcessor {
|
||||
|
||||
public static final String SCRIPT_NAME = "X";
|
||||
|
||||
public X() {
|
||||
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) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTaskFinished(Task task) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTimer() {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLoaded() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onUnloaded() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStartingExecution(Map<String, Object> args) throws Exception{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishedExecution(Map<String, Object> args, Object ret, Throwable t) throws Exception{
|
||||
}
|
||||
|
||||
|
||||
//Invoked by 'update()' to update components in the event thread
|
||||
@Override
|
||||
protected void doUpdate() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getScript(){
|
||||
return SCRIPT_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getArgs(){
|
||||
Map<String, Object> ret = new HashMap<>();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 303, Short.MAX_VALUE)
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGap(0, 176, Short.MAX_VALUE)
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
BIN
script/.DS_Store
vendored
BIN
script/.DS_Store
vendored
Binary file not shown.
@@ -1,4 +1,4 @@
|
||||
#BYTE waveform: OK
|
||||
#BYTE waveform: OK
|
||||
# field(FTVL, 'BYTE')
|
||||
caput("TESTIOC:TESTBA:MyBA", "foo")
|
||||
print caget("TESTIOC:TESTBA:MyBA")
|
||||
|
||||
64
script/DemoScan.py
Normal file
64
script/DemoScan.py
Normal file
@@ -0,0 +1,64 @@
|
||||
# Run detached as:
|
||||
# pshell -p=DemoScan.java -d -sbar -tbar -l -dplt
|
||||
from mathutils import fit_harmonic, HarmonicOscillator
|
||||
|
||||
|
||||
if get_exec_pars().innerArgs is None:
|
||||
print 1
|
||||
START = 0.0
|
||||
END = 0.400
|
||||
STEPS = 10
|
||||
PLOT = None
|
||||
if PLOT is None:
|
||||
PLOT = plot(None,title="HFit")[0]
|
||||
PLOT.clear()
|
||||
|
||||
sd = lscan(inp, (sin,out,arr), START, END, STEPS, 0.1)
|
||||
|
||||
|
||||
ydata = sd[sin]
|
||||
xdata = sd[inp]
|
||||
|
||||
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 = 0.01
|
||||
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)
|
||||
|
||||
|
||||
PLOT.addSeries(LinePlotSeries("data"))
|
||||
PLOT.addSeries(LinePlotSeries("fit"))
|
||||
PLOT.getSeries(0).setData(xdata, ydata)
|
||||
PLOT.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
|
||||
PLOT.addMarker(m, None, "Fit="+str(round(m ,2)), Color.MAGENTA.darker())
|
||||
valid_fit = True
|
||||
else:
|
||||
print "max = ",max_x
|
||||
PLOT.addMarker(max_x, None, "Max="+str(round(max_x ,2)), Color.MAGENTA.darker())
|
||||
valid_fit = False
|
||||
|
||||
set_return([amplitude, angular_frequency, phase, valid_fit, m])
|
||||
|
||||
102
script/DemoScans.py
Normal file
102
script/DemoScans.py
Normal file
@@ -0,0 +1,102 @@
|
||||
DETS = (sin,arr, image.getDataMatrix())
|
||||
|
||||
s1 = tscan(DETS, 10, 0.1)
|
||||
|
||||
s2 = lscan(motor, DETS, -2.0, 2.0, 10, latency=0.2, relative=True, print_scan=True)
|
||||
print s2[motor]
|
||||
print s2["sin"]
|
||||
|
||||
s3 = lscan(pe, DETS, 0.0, 10.0, 10, latency=0.1, passes=4, zigzag=True)
|
||||
|
||||
|
||||
s4 = ascan((motor,pe), DETS, (0.0,0.0), (2.0,1.0), (8,8), latency=0.1, zigzag=True)
|
||||
|
||||
vector = [ 1, 3, 5, 10, 25, 40, 45, 47, 49]
|
||||
s5 = vscan(pe, DETS, vector, False, latency=0.5, print_scan=True)
|
||||
|
||||
def spiral_gen(radius, step, resolution=.1, angle=0.0, origin=[0.0, 0.0]):
|
||||
d = 0.0
|
||||
while d * math.hypot(math.cos(angle), math.sin(angle)) < radius:
|
||||
pos=[ origin[0] + d * math.cos(angle), \
|
||||
origin[1] + d * math.sin(angle) ]
|
||||
yield(pos)
|
||||
d+=step
|
||||
angle+=resolution
|
||||
s6 = vscan((pe,pe2),(sin),spiral_gen(10, 0.1), latency=0.1, range = [-10.0,10.0, -10.0, 10.0])
|
||||
|
||||
|
||||
s7 = rscan(pe, DETS, [(0,5,5), (10,15,20), (20,25,5)] , 0.1)
|
||||
|
||||
s8 = cscan(motor, DETS, -2.0, 2.0 , steps=10, relative=True)
|
||||
|
||||
motor.moveRelAsync(3.0)
|
||||
mscan(motor.readback, DETS, -1, 2.0, async=False)
|
||||
|
||||
|
||||
#Scan Callbacks
|
||||
def before_read(position, scan):
|
||||
outi.write(1)
|
||||
outi.write(0)
|
||||
print "In position: " + str(position[0]) + ", " + str(position[1])
|
||||
|
||||
def after_read(rec, scan):
|
||||
print "Aquired frame %i: at %f, %f: %f" % (rec.index, rec[pe], rec["pe2"], rec[DETS[0]])
|
||||
|
||||
s9= lscan((pe,pe2), (DETS), (0,0), (4,8), steps=20, latency = 0.01, before_read=before_read, after_read=after_read)
|
||||
|
||||
|
||||
|
||||
#Setting attributes to the scan group
|
||||
path = get_exec_pars().scanPath
|
||||
set_attribute(path, "AttrString", "Value")
|
||||
set_attribute(path, "AttrInteger", 1)
|
||||
set_attribute(path, "AttrDouble", 2.0)
|
||||
set_attribute(path, "AttrBoolean", True)
|
||||
|
||||
|
||||
#Manipulating sampled data
|
||||
s10= lscan(pe, DETS, 0, 40, 40, 0.01, False)
|
||||
s11= lscan(pe, DETS, 0, 40, 40, 0.01, False)
|
||||
from operator import add
|
||||
result = map(add, s10[sin], s11[sin])
|
||||
plot(result)
|
||||
|
||||
|
||||
|
||||
#Pseudo-devices
|
||||
class Clock(Readable):
|
||||
def read(self):
|
||||
return time.clock()
|
||||
|
||||
class PseudoSensor(Readable):
|
||||
def read(self):
|
||||
v = arr.take() #Gets the CACHED waveform
|
||||
return reduce(lambda x, y: x + y, v) / len(v)
|
||||
|
||||
class PseudoPositioner(Writable):
|
||||
def write(self,pos):
|
||||
print "Step = " + str(pos)
|
||||
|
||||
clock=Clock()
|
||||
averager=PseudoSensor()
|
||||
positioner=PseudoPositioner()
|
||||
|
||||
s12 = lscan(positioner,(sin, averager,clock),0, 40,20,0.1)
|
||||
|
||||
|
||||
#Resampling
|
||||
index=0
|
||||
def after_read(rec):
|
||||
if rec[pe2] < 0:
|
||||
time.sleep(1.0)
|
||||
rec.invalidate()
|
||||
s13 = lscan(pe, DETS+(pe2,), 0.0, 0.4, 10, 1.0, after_read=after_read)
|
||||
|
||||
|
||||
|
||||
#Averaging
|
||||
av = create_averager(sin, 3, 0.1)
|
||||
res= lscan(pe, (av, av.samples), 0, 20, 10)
|
||||
|
||||
|
||||
|
||||
24
script/TeztTiff.py
Normal file
24
script/TeztTiff.py
Normal file
@@ -0,0 +1,24 @@
|
||||
DETECTORS = (sin,det.dataMatrix)
|
||||
|
||||
#lscan(m1, DETECTORS, 1, 3, 10, before_read=trigger_detector)
|
||||
|
||||
#Pseudo motor for my motor functions, e.g. move_sim_x
|
||||
#Detector = PEEMCAM
|
||||
|
||||
class MyMotor(Writable):
|
||||
def write(self, pos):
|
||||
#m1.move(pos)
|
||||
move_sim_x(pos)
|
||||
|
||||
my_motor=MyMotor()
|
||||
|
||||
vector = [ [1,1] , [1,2] , [1,3] , [1,4] ,
|
||||
[1.5,2.5] ,
|
||||
[2,1] , [2,2] , [2,3] , [2,4] ,
|
||||
[2.5,2.5] ,
|
||||
[3,1] , [3,2] , [3,3] , [3,4] ]
|
||||
|
||||
r3 = vscan((my_motor,m2),DETECTORS, vector, False, 0.1, title = "2D Vector")
|
||||
|
||||
|
||||
plot(r3[sin])
|
||||
3
script/cpy/Ophyd.py
Normal file
3
script/cpy/Ophyd.py
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
|
||||
tscan(Ophyd(det1), 10, 0.1)
|
||||
33
script/cpy/TestDevListener.py
Normal file
33
script/cpy/TestDevListener.py
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
class DeviceListener():
|
||||
def __init__(self, name=None):
|
||||
self.name = name
|
||||
self.proxy=jproxy(self, ['ch.psi.pshell.device.DeviceListener'])
|
||||
|
||||
def get_proxy(self):
|
||||
return self.proxy
|
||||
|
||||
def onStateChanged(self, device, state, former):
|
||||
raise Exception ("Not implemented")
|
||||
|
||||
def onValueChanged(self, device, value, former):
|
||||
raise Exception ("Not implemented")
|
||||
|
||||
def onValueChanging(self, device, value, former):
|
||||
raise Exception ("Not implemented")
|
||||
|
||||
def onCacheChanged(self, device, value, former, timestamp, valueChange):
|
||||
raise Exception ("Not implemented")
|
||||
|
||||
|
||||
class Listener (DeviceListener):
|
||||
def __init__(self):
|
||||
DeviceListener.__init__(self)
|
||||
|
||||
def onValueChanged(self, device, value, former):
|
||||
print (value)
|
||||
|
||||
listener = DeviceListener()
|
||||
sin.addListener(listener)
|
||||
sin.removeListener(listener)
|
||||
|
||||
29
script/cpy/TestMatplotlib.py
Normal file
29
script/cpy/TestMatplotlib.py
Normal file
@@ -0,0 +1,29 @@
|
||||
print ("Starting...")
|
||||
import matplotlib
|
||||
from ch.psi.pshell.imaging import Utils as ImagingUtils
|
||||
#matplotlib.use('TkAgg')
|
||||
matplotlib.use('Agg')
|
||||
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
fig, ax = plt.subplots()
|
||||
|
||||
fruits = ['apple', 'blueberry', 'cherry', 'orange']
|
||||
counts = [40, 100, 30, 55]
|
||||
bar_labels = ['red', 'blue', '_red', 'orange']
|
||||
bar_colors = ['tab:red', 'tab:blue', 'tab:red', 'tab:orange']
|
||||
|
||||
ax.bar(fruits, counts, label=bar_labels, color=bar_colors)
|
||||
|
||||
ax.set_ylabel('fruit supply')
|
||||
ax.set_title('Fruit supply by kind and color')
|
||||
ax.legend(title='Fruit color')
|
||||
|
||||
|
||||
f = expand_path("{images}/output.png")
|
||||
plt.savefig(f)
|
||||
img = ImagingUtils.newImage(f)
|
||||
show_panel(img, "tst")
|
||||
|
||||
|
||||
print ("Done")
|
||||
94
script/cpy/TestOphydWrapper.py
Normal file
94
script/cpy/TestOphydWrapper.py
Normal file
@@ -0,0 +1,94 @@
|
||||
|
||||
class ReaderWrapper():
|
||||
def __init__(self, dev):
|
||||
self.dev=dev
|
||||
self.name=dev.getName()
|
||||
self.parent = None
|
||||
try:
|
||||
self.source = self.dev.getChannelName()
|
||||
except:
|
||||
self.source = "Unknown"
|
||||
try:
|
||||
try:
|
||||
self.shape = [self.dev.getHeight(), self.dev.getWidth()]
|
||||
self.shape_str = "["+str(self.shape[0])+"]"+"["+str(self.shape[1])+"]"
|
||||
except:
|
||||
self.shape = [self.dev.getSize()]
|
||||
self.shape_str = "["+str(self.shape[0])+"]"
|
||||
except:
|
||||
self.shape = []
|
||||
self.shape_str=""
|
||||
try:
|
||||
self.precision = self.dev.getPrecision()
|
||||
except:
|
||||
self.precision = None
|
||||
|
||||
try:
|
||||
v = self.dev.take()
|
||||
if v is None: raise Exception("")
|
||||
except:
|
||||
v = self.dev.read()
|
||||
if type(v) is str:
|
||||
self.dtype = 'string'
|
||||
elif type(v) is int:
|
||||
self.dtype = 'integer'
|
||||
elif type(v) is bool:
|
||||
self.dtype = 'boolean'
|
||||
else:
|
||||
#try:
|
||||
# len(v)
|
||||
# self.dtype = 'array'
|
||||
#except:
|
||||
# self.dtype = 'number'
|
||||
self.dtype = 'number'
|
||||
|
||||
|
||||
self.description = {self.name: { \
|
||||
'dtype':self.dtype , \
|
||||
'shape': self.shape, \
|
||||
'source': self.source, \
|
||||
'precision': self.precision \
|
||||
}}
|
||||
|
||||
self.cfg_description = {"shape_str":{"dtype":"string", 'shape':(len(self.shape_str),), "source":""}, }
|
||||
self.configuration = {"shape_str":{"value":self.shape_str, "timestamp":time.time()}}
|
||||
self.name = self.name+self.shape_str
|
||||
|
||||
def read(self):
|
||||
if is_main_thread():
|
||||
value = self.dev.read()
|
||||
else:
|
||||
global __return__,__exception__
|
||||
__return__ = __exception__ = None
|
||||
handler.queue.append(("read", (self.dev)))
|
||||
while (__return__ is None) and (__exception__ is None):
|
||||
time.sleep(0.01)
|
||||
if __exception__ is not None:
|
||||
raise __exception__
|
||||
value=__return__
|
||||
if True: #Lself.dtype == "array":
|
||||
value = numpy.array(value)
|
||||
return {self.name:{"value":value, "timestamp":time.time()}}
|
||||
|
||||
def describe(self):
|
||||
self.description = {self.name: { \
|
||||
'dtype':self.dtype , \
|
||||
'shape': self.shape, \
|
||||
'source': self.source, \
|
||||
'precision': self.precision \
|
||||
}}
|
||||
return self.description
|
||||
|
||||
def describe_configuration(self):
|
||||
#print(3)
|
||||
return self.cfg_description
|
||||
|
||||
def read_configuration(self):
|
||||
#print(4)
|
||||
return self.configuration
|
||||
|
||||
|
||||
det4=ReaderWrapper(get_device("arr"))
|
||||
dets = [det4,]
|
||||
|
||||
RE(count(dets, num=5, delay=0.5))
|
||||
6
script/cpy/TestStream.py
Normal file
6
script/cpy/TestStream.py
Normal file
@@ -0,0 +1,6 @@
|
||||
add_device(Stream("st1", dispatcher), True)
|
||||
st1.start()
|
||||
show_panel(st1)
|
||||
|
||||
|
||||
|
||||
97
script/cpy/TestToArray.py
Normal file
97
script/cpy/TestToArray.py
Normal file
@@ -0,0 +1,97 @@
|
||||
def to_array(obj, type = None, primitive = True):
|
||||
"""Convert Python list to Java array.
|
||||
|
||||
Args:
|
||||
obj(list): Original data.
|
||||
type(str): array type 'b' = byte, 'h' = short, 'i' = int, 'l' = long, 'f' = float, 'd' = double,
|
||||
'c' = char, 'z' = boolean, 's' = String, 'o' = Object
|
||||
Returns:
|
||||
Java array.
|
||||
"""
|
||||
if obj is None:
|
||||
return None
|
||||
if type is None:
|
||||
type = 'o'
|
||||
enforceArrayType=False
|
||||
else:
|
||||
enforceArrayType=True
|
||||
if type[0] == '[':
|
||||
type = type[1:]
|
||||
element_type = ScriptUtils.getPrimitiveType(type) if primitive else ScriptUtils.getType(type)
|
||||
|
||||
def convert_1d_array(obj):
|
||||
if type == 'c':
|
||||
ret = reflect.Array.newInstance(element_type,len(obj))
|
||||
for i in range(len(obj)): ret[i] = chr(obj[i])
|
||||
return ret
|
||||
if type == 'z':
|
||||
ret = reflect.Array.newInstance(element_type,len(obj))
|
||||
for i in range(len(obj)):
|
||||
ret[i]= True if obj[i] else False
|
||||
return ret
|
||||
if type == 'o':
|
||||
ret = reflect.Array.newInstance(element_type,len(obj))
|
||||
for i in range(len(obj)):
|
||||
ret[i]= obj[i]
|
||||
return ret
|
||||
if type == "s":
|
||||
return Convert.toStringArray(obj)
|
||||
if primitive:
|
||||
ret = Convert.wrapperArrayToPrimitiveArray(obj, element_type)
|
||||
else:
|
||||
ret = reflect.Array.newInstance(element_type,len(obj))
|
||||
for i in range(len(obj)): ret[i] = Convert.toType(obj[i],element_type)
|
||||
return ret
|
||||
|
||||
if is_array(obj):
|
||||
if enforceArrayType:
|
||||
if Arr.getComponentType(obj) != element_type:
|
||||
rank = Arr.getRank(obj)
|
||||
if (rank== 1):
|
||||
obj=convert_1d_array(obj)
|
||||
elif (rank>1):
|
||||
pars, aux = [element_type], obj
|
||||
for i in range(rank):
|
||||
pars.append(len(aux))
|
||||
aux = aux[0]
|
||||
#TODO: OVERLOADING BUG
|
||||
#ret = reflect.Array.newInstance(*pars)
|
||||
ret = Arr.newInstance(*pars)
|
||||
for i in range(len(obj)):
|
||||
ret[i]=to_array(obj[i], type)
|
||||
obj = ret
|
||||
elif is_list(obj):
|
||||
if type=='o':
|
||||
ret = reflect.Array.newInstance(element_type, len(obj))
|
||||
for i in range (len(obj)):
|
||||
if is_list(obj[i]) or is_array(obj[i]):
|
||||
ret[i] = to_array(obj[i],type)
|
||||
else:
|
||||
ret[i] = obj[i]
|
||||
obj=ret
|
||||
elif len(obj)>0 and (is_list(obj[0]) or is_array(obj[0])):
|
||||
pars, aux = [element_type], obj
|
||||
while len(aux)>0 and (is_list(aux[0]) or is_array(aux[0])):
|
||||
pars.append(len(aux))
|
||||
aux = aux[0]
|
||||
pars.append(0)
|
||||
#ret = reflect.Array.newInstance(*pars)
|
||||
ret = Arr.newInstance(*pars)
|
||||
for i in range(len(obj)):
|
||||
ret[i]=to_array(obj[i], type)
|
||||
obj=ret
|
||||
else:
|
||||
obj= convert_1d_array(obj)
|
||||
return obj
|
||||
|
||||
|
||||
import random
|
||||
ret = []
|
||||
for i in range (10):
|
||||
ret.append(random.random())
|
||||
|
||||
try:
|
||||
a1 = to_array(ret,'d')
|
||||
print (a1)
|
||||
except:
|
||||
traceback.print_exc()
|
||||
@@ -9,12 +9,18 @@ motor.delay = 1.1 # simulate slow motor movement
|
||||
|
||||
|
||||
ch1 = EpicsSignal("TESTIOC:TESTSINUS:SinCalc")
|
||||
#TODO: DEmonstrate use of waveform and areadetector (Manual scan setup with the indexes in name)
|
||||
#TODO: Demonstrate use of waveform and areadetector (Manual scan setup with the indexes in name)
|
||||
#ch2 = EpicsSignal("TESTIOC:TESTWF2:MyWF", name="arr[10]")
|
||||
#ch3 = EpicsSignal("TESTIOC:TESTWF2:MyWF", name="img[3][2]")det3=ReaderWrapper(sin)
|
||||
"""
|
||||
|
||||
dets = [det1, det2]
|
||||
|
||||
det4=ReaderWrapper(arr)
|
||||
det5=ReaderWrapper(get_device("det").getDataMatrix() )
|
||||
dets = [det1, det2, ch1, det3, det4, det5] #TODO: fix formatting for arrays
|
||||
dets = [det1, det2, ch1, det3]
|
||||
|
||||
RE(count(dets, num=5, delay=0.5))
|
||||
RE(scan(dets, motor, 0, 1, 5))
|
||||
RE(rel_scan(dets, motor, -1, 1, 10))
|
||||
@@ -23,8 +29,6 @@ RE(grid_scan(dets, motor1, -1.5, 1.5, 3, motor2, -0.1, 0.1, 5))
|
||||
RE(list_grid_scan(dets, motor1, [1, 1, 2, 3, 5], motor2, [25, 16, 9]))
|
||||
|
||||
|
||||
det4=ReaderWrapper(arr)
|
||||
det5=ReaderWrapper(get_device("det").getDataMatrix() )
|
||||
m1=MoverWrapper(get_device("motor"))
|
||||
dets = [det1, det2, ch1, det3, det4, det5]
|
||||
|
||||
RE(scan(dets, m1, 0, 1, 5))
|
||||
|
||||
@@ -178,9 +178,7 @@ def on_abort(parent_thread):
|
||||
print ("Abort command: Run Engine pause request")
|
||||
RE.request_pause()
|
||||
return
|
||||
tid=parent_thread.ident
|
||||
exception = KeyboardInterrupt
|
||||
ctypes.pythonapi.PyThreadState_SetAsyncExc(ctypes.c_long(tid), ctypes.py_object(exception))
|
||||
_default_abort(parent_thread)
|
||||
|
||||
def on_close(parent_thread):
|
||||
on_abort(parent_thread)
|
||||
@@ -399,13 +397,7 @@ class ReaderWrapper():
|
||||
self.precision = self.dev.getPrecision()
|
||||
except:
|
||||
self.precision = None
|
||||
self.description = {self.name: { \
|
||||
'dtype':'number', \
|
||||
'shape': self.shape, \
|
||||
'source': self.source, \
|
||||
'precision': self.precision \
|
||||
}}
|
||||
|
||||
self.dtype = 'number'
|
||||
self.cfg_description = {"shape_str":{"dtype":"string", 'shape':(len(self.shape_str),), "source":""}, }
|
||||
self.configuration = {"shape_str":{"value":self.shape_str, "timestamp":time.time()}}
|
||||
self.name = self.name+self.shape_str
|
||||
@@ -422,7 +414,13 @@ class ReaderWrapper():
|
||||
raise __exception__
|
||||
return {self.name:{"value":__return__, "timestamp":time.time()}}
|
||||
|
||||
def describe(self):
|
||||
def describe(self):
|
||||
self.description = {self.name: { \
|
||||
'dtype':self.dtype , \
|
||||
'shape': self.shape, \
|
||||
'source': self.source, \
|
||||
'precision': self.precision \
|
||||
}}
|
||||
return self.description
|
||||
|
||||
def describe_configuration(self):
|
||||
@@ -470,6 +468,26 @@ class MoverWrapper(ReaderWrapper):
|
||||
self.dev.stop()
|
||||
|
||||
|
||||
#Wraps an Ophyd device as a Readable, so can be used in *scan commands
|
||||
class Ophyd(Readable):
|
||||
def __init__(self, dev):
|
||||
for k in dev.describe().keys():
|
||||
Nameable.__init__(self, k, Readable.__interfaces__ )
|
||||
break
|
||||
self.dev=dev
|
||||
|
||||
def read(self):
|
||||
v = self.dev.read()
|
||||
if (v is None) or (len(v)==0):
|
||||
return None
|
||||
v = v[self.getName()]
|
||||
try:
|
||||
timestamp = int(v["timestamp"]*1000)
|
||||
except:
|
||||
timestamp = time.time()
|
||||
ret = TimestampedValue (v["value"], timestamp)
|
||||
return ret
|
||||
|
||||
|
||||
RE = RunEngine({}, during_task=EventProcessingTask())
|
||||
if CAN_PAUSE:
|
||||
|
||||
8
script/cpython/Ophyd.py
Normal file
8
script/cpython/Ophyd.py
Normal file
@@ -0,0 +1,8 @@
|
||||
from ophyd.sim import det1, det2, det3, det4, det, motor, motor1, motor2, motor3,img, sig, direct_img, pseudo1x3
|
||||
from ophyd import Signal
|
||||
from ophyd.signal import EpicsSignal
|
||||
|
||||
|
||||
|
||||
def read(name):
|
||||
return globals()[name].read()
|
||||
79
script/cpython/TestData.py
Normal file
79
script/cpython/TestData.py
Normal file
@@ -0,0 +1,79 @@
|
||||
###################################################################################################
|
||||
#Data Manipulation: Using the data access API to generate and retrieve data
|
||||
###################################################################################################
|
||||
|
||||
|
||||
#Creating a 1D dataset from an array
|
||||
|
||||
path="group/data1"
|
||||
data1d = [1.0, 2.0, 3.0, 4.0, 5.0]
|
||||
save_dataset(path, data1d)
|
||||
#Reading ii back
|
||||
read =load_data(path)
|
||||
print (list(read))
|
||||
assert data1d==list(read)
|
||||
plot(read)
|
||||
|
||||
#Creating a 2D dataset from an array with some attributes
|
||||
data2d = [ [1.0, 2.0, 3.0, 4.0, 5.0], [2.0, 3.0, 4.0, 5.0, 6.0, ], [3.0, 4.0, 5.0, 6.0, 7.0]]
|
||||
path="group/data2"
|
||||
save_dataset(path, data2d)
|
||||
set_attribute(path, "AttrString", "Value")
|
||||
set_attribute(path, "AttrInteger", 1)
|
||||
set_attribute(path, "AttrDouble", 2.0)
|
||||
set_attribute(path, "AttrBoolean", True)
|
||||
#Reading it back
|
||||
read =load_data(path)
|
||||
print ([list(a) for a in read])
|
||||
plot(read)
|
||||
|
||||
#Creating a 3D dataset from an array
|
||||
data3d = [ [ [1,2,3,4,5], [2,3,4,5,6], [3,4,5,6,7]], [ [3,2,3,4,5], [4,3,4,5,6], [5,4,5,6,7]]]
|
||||
path="group/data3"
|
||||
save_dataset(path, data3d)
|
||||
#Reading it back
|
||||
read =load_data(path,0)
|
||||
print ([list(a) for a in read])
|
||||
read =load_data(path,1)
|
||||
print ([list(a) for a in read])
|
||||
|
||||
#Creating a INT dataset adding elements one by one
|
||||
path = "group/data4"
|
||||
create_dataset(path, 'i')
|
||||
for i in range(10):
|
||||
append_dataset(path,i)
|
||||
|
||||
|
||||
#Creating a 2D data FLOAT dataset adding lines one by one
|
||||
path = "group/data5"
|
||||
create_dataset(path, 'd', False, (0,0))
|
||||
for row in data2d:
|
||||
append_dataset(path, row)
|
||||
|
||||
|
||||
#Creating a Table (compund type)
|
||||
path = "group/data6"
|
||||
names = ["a", "b", "c", "d"]
|
||||
table_types = ["d", "d", "d", "[d"]
|
||||
lenghts = [0,0,0,5]
|
||||
table = [ [1,2,3,[0,1,2,3,4]],
|
||||
[2,3,4,[3,4,5,6,7]],
|
||||
[3,4,5,[6,7,8,9,4]] ]
|
||||
create_table(path, names, table_types, lenghts)
|
||||
for row in table:
|
||||
append_table(path, row)
|
||||
flush_data()
|
||||
#Read it back
|
||||
read =load_data(path)
|
||||
print (read)
|
||||
|
||||
|
||||
#Writing scalars (datasets with rank 0)
|
||||
save_dataset("group/val1", 1)
|
||||
save_dataset("group/val2", 3.14)
|
||||
save_dataset("group/val3", "test")
|
||||
print (load_data("group/val1"))
|
||||
print (load_data("group/val2"))
|
||||
print (load_data("group/val3"))
|
||||
|
||||
|
||||
27
script/cpython/TestInterrupt.py
Normal file
27
script/cpython/TestInterrupt.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import threading
|
||||
from threading import Thread
|
||||
from _thread import interrupt_main
|
||||
import sys
|
||||
|
||||
# task executed in a new thread
|
||||
def task():
|
||||
# block for a moment
|
||||
sleep(3)
|
||||
# interrupt the main thread
|
||||
print('Interrupting main thread now')
|
||||
interrupt_main()
|
||||
|
||||
# start the new thread
|
||||
thread = Thread(target=task)
|
||||
thread.start()
|
||||
|
||||
print(threading.current_thread() == threading.main_thread())
|
||||
# handle being interrupted
|
||||
try:
|
||||
# wait around
|
||||
while True:
|
||||
print('Main thread waiting...')
|
||||
sleep(0.5)
|
||||
except KeyboardInterrupt:
|
||||
# terminate main thread
|
||||
print('Main interrupted! Exiting.')
|
||||
@@ -27,4 +27,10 @@ def gfitoff(x, y, off=None, amp=None, com=None, sigma=None):
|
||||
|
||||
|
||||
def gauss_fn(x, a, b, c, d):
|
||||
return a + b * np.exp(-(np.power((x - c), 2) / (2 * np.power(d, 2))))
|
||||
return a + b * np.exp(-(np.power((x - c), 2) / (2 * np.power(d, 2))))
|
||||
"""
|
||||
x=np.array([-200.30429237268825, -200.2650700434188, -200.22115208318002, -199.9457671375377, -199.86345548879072, -199.85213073174933, -199.35687977133284, -199.13811861090275, -197.97304970346386, -197.2952215624348, -195.09076092936948, -192.92276048970703, -191.96871876227698, -189.49577852322938, -187.9652790409825, -183.63756456925222, -180.04899765472996, -178.43839623242422, -174.07311671294445, -172.0410133577918, -165.90824309893102, -160.99771795989466, -159.30176653939253, -154.27688897558514, -152.0854103810786, -145.75652847587313, -140.80843828908465, -139.23982133191495, -134.27073891256106, -132.12649284133064, -125.95947209775511, -121.00309550337462, -119.26736932643232, -114.2706655484383, -112.07393889578914, -105.72295990367157, -100.8088439880125, -99.2034906238494, -94.30042325164636, -92.15010048151461, -85.92203653534293, -81.03913275494665, -79.27412793784428, -74.33487658582118, -72.06274362408762, -65.76562628131825, -60.91255356825276, -59.20334389560392, -54.33286972659312, -52.19387171350535, -45.94978737932291, -41.03014719193582, -39.301602568238906, -34.35572209014114, -32.04464301272608, -25.8221033382824, -20.922074315528747, -19.21590299233186, -14.31090212502093, -12.217203140101386, -5.9283722049240435, -0.9863587170369246, 0.7408048387279834, 5.71126832601389, 7.972628957879352, 14.204559894256546, 19.11839959633025, 20.8218087836657, 25.678748486941828, 27.822718344586864, 34.062659474970715, 38.9745656819391, 40.77409719734158, 45.72080631619803, 47.974156754056835, 54.23453768983539, 59.12020360609568, 60.77306570712026, 65.70734521458867, 67.8344660434617, 74.03187028154134, 78.96532114824849, 80.76070945985495, 85.74802197591286, 87.9140889204674, 94.18082276873524, 99.25790470037091, 100.68454787413205, 105.7213026221542, 107.79483801526698, 113.99555681638138, 119.0707052529143, 120.72715813056156, 125.77551384921307, 127.91257836719551, 134.2011330887875, 139.23043006997628, 140.71673537840158, 145.76288138835983, 147.80216629676042, 154.06420451405637, 159.0846626604798, 160.76183155710717, 165.73699067536242, 167.9265357747636, 173.96705069576544, 178.2522282751915, 179.9042617354548, 183.54586165856657, 185.23269803071796, 189.41678143751972, 191.87149157986588, 192.8741468985015, 195.0241934550453, 195.966634211846, 197.9821647518146, 198.99006812859284, 199.33202054855676, 199.91897441965887, 200.11536227958896, 200.22280936469997, 200.25181179127208])
|
||||
y=np.array([11.0, 6.0, 8.0, 5.0, 11.0, 7.0, 18.0, 11.0, 12.0, 10.0, 8.0, 6.0, 16.0, 4.0, 12.0, 9.0, 15.0, 14.0, 8.0, 20.0, 15.0, 8.0, 9.0, 11.0, 13.0, 12.0, 13.0, 15.0, 13.0, 20.0, 10.0, 7.0, 17.0, 11.0, 20.0, 13.0, 13.0, 23.0, 14.0, 10.0, 17.0, 15.0, 20.0, 16.0, 14.0, 13.0, 18.0, 22.0, 9.0, 20.0, 12.0, 14.0, 17.0, 19.0, 14.0, 14.0, 23.0, 19.0, 15.0, 20.0, 20.0, 21.0, 20.0, 23.0, 22.0, 15.0, 10.0, 17.0, 21.0, 15.0, 23.0, 23.0, 25.0, 18.0, 16.0, 21.0, 22.0, 16.0, 16.0, 14.0, 19.0, 20.0, 18.0, 20.0, 23.0, 13.0, 16.0, 20.0, 25.0, 15.0, 15.0, 17.0, 22.0, 26.0, 19.0, 30.0, 25.0, 17.0, 17.0, 23.0, 16.0, 27.0, 21.0, 21.0, 26.0, 27.0, 21.0, 17.0, 20.0, 20.0, 21.0, 19.0, 25.0, 19.0, 13.0, 23.0, 20.0, 20.0, 18.0, 20.0, 19.0, 25.0])
|
||||
[off, amp, com, sigma] = gfitoff(x, y, off=None, amp=None, com=None, sigma=None)
|
||||
print ([off, amp, com, sigma])
|
||||
"""
|
||||
@@ -19,14 +19,39 @@ def test():
|
||||
return np.ones(5)
|
||||
|
||||
|
||||
def test2(name, x=None, y=None):
|
||||
def test2(name, x=None, y=None, **kwargs):
|
||||
print (name,x,y)
|
||||
ret = y*x
|
||||
print (ret)
|
||||
print(kwargs.get("z", 0.0))
|
||||
return ret
|
||||
|
||||
def add(x,y,z):
|
||||
return x+y+z
|
||||
|
||||
def read_dev(dev):
|
||||
return dev.read()
|
||||
return dev.read()
|
||||
|
||||
|
||||
|
||||
def print_dict(d):
|
||||
for k in d.keys():
|
||||
print (k, d[k])
|
||||
ret = {}
|
||||
ret.update(d)
|
||||
return ret
|
||||
|
||||
def get_tuple():
|
||||
return (1,2,3)
|
||||
|
||||
#x=np.array([0,1,2,3,4,5,6,7,8,9])
|
||||
#y=np.array([1,2,3,6,9,6,3,2,1,0])
|
||||
#print( linfit(x,y) )
|
||||
|
||||
|
||||
#x=(0,1,2,3,4,5,6,7,8,9)
|
||||
#y=(1,2,3,6,9,6,3,2,1,0)
|
||||
#print( linfit(x,y) )
|
||||
|
||||
|
||||
#print_dict({"a":1, "b":2})
|
||||
@@ -1,14 +1,19 @@
|
||||
from jeputils import import_py
|
||||
import matplotlib
|
||||
matplotlib.use('TkAgg')
|
||||
|
||||
import_py("cpython/gfitoff", "gfitoff")
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from mathutils import Gaussian
|
||||
x=to_array([-200.30429237268825, -200.2650700434188, -200.22115208318002, -199.9457671375377, -199.86345548879072, -199.85213073174933, -199.35687977133284, -199.13811861090275, -197.97304970346386, -197.2952215624348, -195.09076092936948, -192.92276048970703, -191.96871876227698, -189.49577852322938, -187.9652790409825, -183.63756456925222, -180.04899765472996, -178.43839623242422, -174.07311671294445, -172.0410133577918, -165.90824309893102, -160.99771795989466, -159.30176653939253, -154.27688897558514, -152.0854103810786, -145.75652847587313, -140.80843828908465, -139.23982133191495, -134.27073891256106, -132.12649284133064, -125.95947209775511, -121.00309550337462, -119.26736932643232, -114.2706655484383, -112.07393889578914, -105.72295990367157, -100.8088439880125, -99.2034906238494, -94.30042325164636, -92.15010048151461, -85.92203653534293, -81.03913275494665, -79.27412793784428, -74.33487658582118, -72.06274362408762, -65.76562628131825, -60.91255356825276, -59.20334389560392, -54.33286972659312, -52.19387171350535, -45.94978737932291, -41.03014719193582, -39.301602568238906, -34.35572209014114, -32.04464301272608, -25.8221033382824, -20.922074315528747, -19.21590299233186, -14.31090212502093, -12.217203140101386, -5.9283722049240435, -0.9863587170369246, 0.7408048387279834, 5.71126832601389, 7.972628957879352, 14.204559894256546, 19.11839959633025, 20.8218087836657, 25.678748486941828, 27.822718344586864, 34.062659474970715, 38.9745656819391, 40.77409719734158, 45.72080631619803, 47.974156754056835, 54.23453768983539, 59.12020360609568, 60.77306570712026, 65.70734521458867, 67.8344660434617, 74.03187028154134, 78.96532114824849, 80.76070945985495, 85.74802197591286, 87.9140889204674, 94.18082276873524, 99.25790470037091, 100.68454787413205, 105.7213026221542, 107.79483801526698, 113.99555681638138, 119.0707052529143, 120.72715813056156, 125.77551384921307, 127.91257836719551, 134.2011330887875, 139.23043006997628, 140.71673537840158, 145.76288138835983, 147.80216629676042, 154.06420451405637, 159.0846626604798, 160.76183155710717, 165.73699067536242, 167.9265357747636, 173.96705069576544, 178.2522282751915, 179.9042617354548, 183.54586165856657, 185.23269803071796, 189.41678143751972, 191.87149157986588, 192.8741468985015, 195.0241934550453, 195.966634211846, 197.9821647518146, 198.99006812859284, 199.33202054855676, 199.91897441965887, 200.11536227958896, 200.22280936469997, 200.25181179127208],'d')
|
||||
y=to_array([11.0, 6.0, 8.0, 5.0, 11.0, 7.0, 18.0, 11.0, 12.0, 10.0, 8.0, 6.0, 16.0, 4.0, 12.0, 9.0, 15.0, 14.0, 8.0, 20.0, 15.0, 8.0, 9.0, 11.0, 13.0, 12.0, 13.0, 15.0, 13.0, 20.0, 10.0, 7.0, 17.0, 11.0, 20.0, 13.0, 13.0, 23.0, 14.0, 10.0, 17.0, 15.0, 20.0, 16.0, 14.0, 13.0, 18.0, 22.0, 9.0, 20.0, 12.0, 14.0, 17.0, 19.0, 14.0, 14.0, 23.0, 19.0, 15.0, 20.0, 20.0, 21.0, 20.0, 23.0, 22.0, 15.0, 10.0, 17.0, 21.0, 15.0, 23.0, 23.0, 25.0, 18.0, 16.0, 21.0, 22.0, 16.0, 16.0, 14.0, 19.0, 20.0, 18.0, 20.0, 23.0, 13.0, 16.0, 20.0, 25.0, 15.0, 15.0, 17.0, 22.0, 26.0, 19.0, 30.0, 25.0, 17.0, 17.0, 23.0, 16.0, 27.0, 21.0, 21.0, 26.0, 27.0, 21.0, 17.0, 20.0, 20.0, 21.0, 19.0, 25.0, 19.0, 13.0, 23.0, 20.0, 20.0, 18.0, 20.0, 19.0, 25.0],'d')
|
||||
[off, amp, com, sigma] = gfitoff(x, y, off=None, amp=None, com=None, sigma=None)
|
||||
print "Fit: ", [off, amp, com, sigma]
|
||||
g = Gaussian(amp, com, sigma)
|
||||
plot([y, [g.value(i)+off for i in x]], ["data", "fit"], xdata = x)
|
||||
fig, ax = plt.subplots()
|
||||
|
||||
fruits = ['apple', 'blueberry', 'cherry', 'orange']
|
||||
counts = [40, 100, 30, 55]
|
||||
bar_labels = ['red', 'blue', '_red', 'orange']
|
||||
bar_colors = ['tab:red', 'tab:blue', 'tab:red', 'tab:orange']
|
||||
|
||||
ax.bar(fruits, counts, label=bar_labels, color=bar_colors)
|
||||
|
||||
ax.set_ylabel('fruit supply')
|
||||
ax.set_title('Fruit supply by kind and color')
|
||||
ax.legend(title='Fruit color')
|
||||
|
||||
plt.show()
|
||||
@@ -125,7 +125,7 @@ def on_session_finished(id):
|
||||
###################################################################################################
|
||||
# Image filters
|
||||
###################################################################################################
|
||||
|
||||
"""
|
||||
class DataFilter(Filter.DataFilter):
|
||||
def process(self, data):
|
||||
data=data.copy()
|
||||
@@ -148,7 +148,7 @@ image.addListener(image_filter)
|
||||
add_device(image_filter, True)
|
||||
|
||||
image.refresh()
|
||||
|
||||
"""
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,11 @@ class DevConfig(DeviceConfig):
|
||||
|
||||
class Dev(DeviceBase):
|
||||
def __init__(self, name):
|
||||
#DeviceBase.__init__(self, name, DevConfig())
|
||||
DeviceBase.__init__(self, name, DeviceConfig({"i":1, "d":1.0, "b":True, "s": "Test"}))
|
||||
raise Exception("test ex")
|
||||
add_device(Dev("test_cfg"), True)
|
||||
DeviceBase.__init__(self, name, DeviceConfig({"intval":1, "floatval":1.0, "boolval":True, "strval": "Test"}))
|
||||
add_device(Dev("testdev"), True)
|
||||
|
||||
print testdev.config
|
||||
print testdev.config.getValue("intval")
|
||||
print testdev.config.getValue("floatval")
|
||||
print testdev.config.getValue("boolval")
|
||||
print testdev.config.getValue("strval")
|
||||
|
||||
24
script/test/TestCombineImage.py
Normal file
24
script/test/TestCombineImage.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from ijutils import *
|
||||
|
||||
|
||||
def get_file(index):
|
||||
scan = "/Users/gobbo_a/dev/pshell/config/home/data/2024_03/20240319/20240319_105604_TeztTiff/scan 1/"
|
||||
return scan + ("det image_%04d.tiff" % (index))
|
||||
|
||||
imgs_per_row=3
|
||||
imgs_per_col=2
|
||||
|
||||
images = []
|
||||
for i in range(6):
|
||||
images.append(get_file(i))
|
||||
|
||||
composite =create_composite_image(images[0], imgs_per_row, imgs_per_col)
|
||||
display_composite_image(composite)
|
||||
|
||||
p=None
|
||||
for i in range(len(images)):
|
||||
x,y = i%imgs_per_row, i/imgs_per_row
|
||||
append_composite_image(composite, images[i], x, y)
|
||||
display_composite_image(composite)
|
||||
time.sleep(0.5)
|
||||
|
||||
22
script/test/TestDataAPI.py
Normal file
22
script/test/TestDataAPI.py
Normal file
@@ -0,0 +1,22 @@
|
||||
baseurl = "https://data-api.psi.ch/sf"
|
||||
filename = "/Users/gobbo_a/dev/back/test.h5"
|
||||
channels = ["SARFE10-PSSS059:FIT-COM", "S10BC01-DBPM010:Q1"]
|
||||
start = "2023-12-10T08:50:00.000Z" #args.start.astimezone(pytz.timezone('UTC')).strftime("%Y-%m-%dT%H:%M:%S.%fZ") # isoformat() # "2019-12-13T09:00:00.000000000Z"
|
||||
end = "2023-12-10T08:50:05.000Z" # args.end.astimezone(pytz.timezone('UTC')).strftime("%Y-%m-%dT%H:%M:%S.%fZ") # .isoformat() # "2019-12-13T09:00:00.100000000Z"
|
||||
|
||||
|
||||
api = DataAPI(baseurl)
|
||||
ret = api.queryData(channels, start, end)
|
||||
print ret
|
||||
|
||||
channel_data = ret[0]["data"]
|
||||
y1=[v["value"] for v in channel_data]
|
||||
x1=[v["globalSeconds"] for v in channel_data]
|
||||
|
||||
|
||||
channel_data = ret[1]["data"]
|
||||
y2=[v["value"] for v in channel_data]
|
||||
x2=[v["globalSeconds"] for v in channel_data]
|
||||
|
||||
|
||||
plot([y1, y2], channels, xdata=[x1, x2])
|
||||
@@ -3,8 +3,9 @@ from jeputils import import_py
|
||||
import_py("CPython/linfit", "linfit")
|
||||
import_py("CPython/gfitoff", "gfitoff")
|
||||
|
||||
x=[0,1,2,3,4,5,6,7,8,9]
|
||||
y=[1,2,3,6,9,6,3,2,1,0]
|
||||
x=to_array([0,1,2,3,4,5,6,7,8,9], 'd')
|
||||
y=to_array([1,2,3,6,9,6,3,2,1,0], 'd')
|
||||
|
||||
(p, x_fit, y_fit, R2) = linfit(x,y)
|
||||
#print "Fit: ", (p, x_fit, y_fit, R2)
|
||||
plot((y,y_fit), name=("data", "fit"),xdata=(x,x_fit))
|
||||
|
||||
267
script/test/TestJEP2.py
Normal file
267
script/test/TestJEP2.py
Normal file
@@ -0,0 +1,267 @@
|
||||
###################################################################################################
|
||||
# Facade to JEP: Embedded Python
|
||||
###################################################################################################
|
||||
|
||||
#Matplotlib won't work out of the box because it's default backend (Qt) uses signals, which only works in
|
||||
#the main thread. Ideally should find a fix, in order to mark the running thread as the main.
|
||||
#As a workaround, one can use the Tk backend:
|
||||
#
|
||||
#import matplotlib
|
||||
#matplotlib.use('TkAgg')
|
||||
|
||||
|
||||
#In principle just add JEP jar and library to the extensions folder.
|
||||
#
|
||||
#Alternatively on Linux:
|
||||
# Python 2:
|
||||
# - Add <python home>/lib/python3.X/site-packages/jep to LD_LIBRARY_PATH
|
||||
# - Add <python home>/lib/python3.X/site-packages/jep/jep-X.X.X.jar to the class path
|
||||
#
|
||||
#Python3:
|
||||
# - Add JEP library folder to LD_LIBRARY_PATH
|
||||
# - If using OpenJDK, add also python <python home>/lib folder to LD_LIBRARY_PATH
|
||||
# - Set LD_PRELOAD=<python home>/lib/libpython3.5m.so
|
||||
|
||||
|
||||
import sys
|
||||
import os
|
||||
import jep.Jep
|
||||
import jep.SharedInterpreter
|
||||
import jep.NDArray
|
||||
import java.lang.Thread
|
||||
import org.python.core.PyArray as PyArray
|
||||
import java.lang.String as String
|
||||
import java.util.List
|
||||
import java.util.Map
|
||||
import java.util.HashMap
|
||||
import ch.psi.pshell.scripting.ScriptUtils as ScriptUtils
|
||||
|
||||
|
||||
from startup import to_array, get_context, _get_caller, Convert, Arr
|
||||
|
||||
__jep = {}
|
||||
|
||||
def __get_jep():
|
||||
t = java.lang.Thread.currentThread()
|
||||
if not t in __jep:
|
||||
init_jep()
|
||||
return __jep[t]
|
||||
|
||||
def __close_jep():
|
||||
t = java.lang.Thread.currentThread()
|
||||
if t in __jep:
|
||||
__jep[t].close()
|
||||
|
||||
def init_jep():
|
||||
#TODO: Should do it but generates errors
|
||||
#__close_jep()
|
||||
j = jep.SharedInterpreter()
|
||||
try:
|
||||
#Faster, but statements must be complete
|
||||
j.setInteractive(False)
|
||||
except:
|
||||
pass # Removed in 4.2
|
||||
__jep[java.lang.Thread.currentThread()] = j
|
||||
j.eval("import sys")
|
||||
#sys.argv is not present in JEP and may be needed for certain modules (as Tkinter)
|
||||
j.eval("sys.argv = ['PShell']");
|
||||
#Add standard script path to python path
|
||||
j.eval("sys.path.append('" + get_context().setup.getScriptPath() + "')")
|
||||
|
||||
#Redirect stdout
|
||||
j.eval("class JepStdout:\n" +
|
||||
" def write(self, str):\n" +
|
||||
" self.str += str\n" +
|
||||
" def clear(self):\n" +
|
||||
" self.str = ''\n" +
|
||||
" def flush(self):\n" +
|
||||
" pass\n")
|
||||
j.eval("sys.stdout=JepStdout()");
|
||||
j.eval("sys.stderr=JepStdout()");
|
||||
j.eval("sys.stdout.clear()")
|
||||
j.eval("sys.stderr.clear()")
|
||||
|
||||
#Import reload on Python 3
|
||||
j.eval("try:\n" +
|
||||
" reload # Python 2.7\n" +
|
||||
"except NameError:\n" +
|
||||
" try:\n" +
|
||||
" from importlib import reload # Python 3.4+\n" +
|
||||
" except ImportError:\n" +
|
||||
" from imp import reload # Python 3.0 - 3.3\n")
|
||||
|
||||
def __print_stdout():
|
||||
j=__get_jep()
|
||||
output = None
|
||||
err = None
|
||||
try:
|
||||
output = j.getValue("sys.stdout.str")
|
||||
err = j.getValue("sys.stderr.str")
|
||||
j.eval("sys.stdout.clear()")
|
||||
j.eval("sys.stderr.clear()")
|
||||
except:
|
||||
pass
|
||||
if (output is not None) and len(output)>0:
|
||||
print output
|
||||
if (err is not None) and len(err)>0:
|
||||
print >> sys.stderr, err
|
||||
|
||||
def run_jep(script_name, vars = {}):
|
||||
global __jep
|
||||
script = get_context().scriptManager.library.resolveFile(script_name)
|
||||
if script is None :
|
||||
script= os.path.abspath(script_name)
|
||||
j=__get_jep()
|
||||
|
||||
for v in vars:
|
||||
j.set(v, vars[v])
|
||||
try:
|
||||
j.runScript(script)
|
||||
finally:
|
||||
__print_stdout()
|
||||
|
||||
def eval_jep(line):
|
||||
j=__get_jep()
|
||||
try:
|
||||
j.eval(line)
|
||||
finally:
|
||||
__print_stdout()
|
||||
|
||||
def set_jep(var, value):
|
||||
j=__get_jep()
|
||||
j.set(var, value)
|
||||
|
||||
def get_jep(var):
|
||||
j=__get_jep()
|
||||
return j.getValue(var)
|
||||
|
||||
def call_jep(module, function, args = [], kwargs = {}, reload=False):
|
||||
j=__get_jep()
|
||||
if "/" in module:
|
||||
script = get_context().scriptManager.library.resolveFile(module)
|
||||
if "\\" in script:
|
||||
#Windows paths
|
||||
module_path = script[0:script.rfind("\\")]
|
||||
module = script[script.rfind("\\")+1:]
|
||||
else:
|
||||
#Linux paths
|
||||
module_path = script[0:script.rfind("/")]
|
||||
module = script[script.rfind("/")+1:]
|
||||
eval_jep("import sys")
|
||||
eval_jep("sys.path.append('" + module_path + "')")
|
||||
if module.endswith(".py"):
|
||||
module = module[0:-3]
|
||||
|
||||
f = module+"_" + function+"_"+str(j.hashCode())
|
||||
try:
|
||||
if reload:
|
||||
eval_jep("import " + module)
|
||||
eval_jep("_=reload(" + module+")")
|
||||
eval_jep("from " + module + " import " + function + " as " + f)
|
||||
if (kwargs is not None) and (len(kwargs)>0):
|
||||
#invoke with kwargs only available in JEP>3.8
|
||||
hm=java.util.HashMap()
|
||||
hm.update(kwargs)
|
||||
#The only way to get the overloaded method...
|
||||
m = j.getClass().getMethod("invoke", [String, ScriptUtils.getType("[o"), java.util.Map])
|
||||
ret = m.invoke(j, [f, to_array(args,'o'), hm])
|
||||
else:
|
||||
ret = j.invoke(f, args)
|
||||
finally:
|
||||
__print_stdout()
|
||||
return ret
|
||||
|
||||
#Converts pythonlist or Java array to numpy array
|
||||
def to_npa(data, dimensions = None, type = None):
|
||||
if (not isinstance(data, PyArray)) or (type is not None):
|
||||
data = to_array(data,'d' if type is None else type)
|
||||
if dimensions is None:
|
||||
return jep.NDArray(data)
|
||||
return jep.NDArray(data, dimensions)
|
||||
|
||||
#recursivelly converts all NumPy arrays to Java arrys
|
||||
def rec_from_npa(obj):
|
||||
if isinstance(obj, jep.NDArray):
|
||||
ret = obj.data
|
||||
if len(obj.dimensions)>1:
|
||||
ret=Convert.reshape(ret, obj.dimensions)
|
||||
return ret
|
||||
if isinstance(obj, java.util.List) or isinstance(obj,tuple) or isinstance(obj,list):
|
||||
ret=[]
|
||||
for i in range(len(obj)):
|
||||
ret.append(rec_from_npa(obj[i]))
|
||||
if isinstance(obj,tuple):
|
||||
return type(ret)
|
||||
return ret
|
||||
if isinstance(obj, java.util.Map) or isinstance(obj,dict):
|
||||
ret = {} if isinstance(obj,dict) else java.util.HashMap()
|
||||
for k in obj.keys():
|
||||
ret[k] = rec_from_npa(obj[k])
|
||||
return ret
|
||||
return obj
|
||||
|
||||
#recursivelly converts all Java arrays to NumPy arrys
|
||||
def rec_to_npa(obj):
|
||||
if isinstance(obj, PyArray):
|
||||
dimensions = Arr.getShape(obj)
|
||||
if len(dimensions)>1:
|
||||
obj = Convert.flatten(obj)
|
||||
return to_npa(obj, dimensions = dimensions)
|
||||
if isinstance(obj, java.util.List) or isinstance(obj,tuple) or isinstance(obj,list):
|
||||
ret=[]
|
||||
for i in range(len(obj)):
|
||||
ret.append(rec_to_npa(obj[i]))
|
||||
if isinstance(obj,tuple):
|
||||
return tuple(ret)
|
||||
return ret
|
||||
if isinstance(obj, java.util.Map) or isinstance(obj,dict):
|
||||
ret = {} if isinstance(obj,dict) else java.util.HashMap()
|
||||
for k in obj.keys():
|
||||
ret[k] = rec_to_npa(obj[k])
|
||||
return ret
|
||||
return obj
|
||||
|
||||
def call_py(module, function, reload_function, *args, **kwargs):
|
||||
"""
|
||||
Calls a CPython function recursively crecursively converting Java arrays in arguments to NumPy,
|
||||
and NumPy arrays in return values to Java arrays.
|
||||
"""
|
||||
ret = call_jep(module, function, rec_to_npa(args), rec_to_npa(kwargs), reload=reload_function)
|
||||
return rec_from_npa(ret)
|
||||
|
||||
def import_py(module, function):
|
||||
"""
|
||||
Adds a CPython function to globals, creating a wrapper call to JEP, with
|
||||
recurvive convertion of Java arrays in arguments to NumPy arrays,
|
||||
and NumPy arrays in return values to Java arrays.
|
||||
"""
|
||||
def jep_wrapper(*args, **kwargs):
|
||||
reload_function = jep_wrapper.reload
|
||||
jep_wrapper.reload = False
|
||||
print module, function, reload_function
|
||||
return call_py(module, function, reload_function, *args, **kwargs)
|
||||
jep_wrapper.reload=True
|
||||
_get_caller().f_globals[function] = jep_wrapper
|
||||
return jep_wrapper
|
||||
|
||||
|
||||
|
||||
import_py("CPython/linfit", "linfit")
|
||||
import_py("CPython/gfitoff", "gfitoff")
|
||||
|
||||
x=[0,1,2,3,4,5,6,7,8,9]
|
||||
y=[1,2,3,6,9,6,3,2,1,0]
|
||||
(p, x_fit, y_fit, R2) = linfit(x,y)
|
||||
#print "Fit: ", (p, x_fit, y_fit, R2)
|
||||
plot((y,y_fit), name=("data", "fit"),xdata=(x,x_fit))
|
||||
|
||||
|
||||
from mathutils import Gaussian
|
||||
x=to_array([-200.30429237268825, -200.2650700434188, -200.22115208318002, -199.9457671375377, -199.86345548879072, -199.85213073174933, -199.35687977133284, -199.13811861090275, -197.97304970346386, -197.2952215624348, -195.09076092936948, -192.92276048970703, -191.96871876227698, -189.49577852322938, -187.9652790409825, -183.63756456925222, -180.04899765472996, -178.43839623242422, -174.07311671294445, -172.0410133577918, -165.90824309893102, -160.99771795989466, -159.30176653939253, -154.27688897558514, -152.0854103810786, -145.75652847587313, -140.80843828908465, -139.23982133191495, -134.27073891256106, -132.12649284133064, -125.95947209775511, -121.00309550337462, -119.26736932643232, -114.2706655484383, -112.07393889578914, -105.72295990367157, -100.8088439880125, -99.2034906238494, -94.30042325164636, -92.15010048151461, -85.92203653534293, -81.03913275494665, -79.27412793784428, -74.33487658582118, -72.06274362408762, -65.76562628131825, -60.91255356825276, -59.20334389560392, -54.33286972659312, -52.19387171350535, -45.94978737932291, -41.03014719193582, -39.301602568238906, -34.35572209014114, -32.04464301272608, -25.8221033382824, -20.922074315528747, -19.21590299233186, -14.31090212502093, -12.217203140101386, -5.9283722049240435, -0.9863587170369246, 0.7408048387279834, 5.71126832601389, 7.972628957879352, 14.204559894256546, 19.11839959633025, 20.8218087836657, 25.678748486941828, 27.822718344586864, 34.062659474970715, 38.9745656819391, 40.77409719734158, 45.72080631619803, 47.974156754056835, 54.23453768983539, 59.12020360609568, 60.77306570712026, 65.70734521458867, 67.8344660434617, 74.03187028154134, 78.96532114824849, 80.76070945985495, 85.74802197591286, 87.9140889204674, 94.18082276873524, 99.25790470037091, 100.68454787413205, 105.7213026221542, 107.79483801526698, 113.99555681638138, 119.0707052529143, 120.72715813056156, 125.77551384921307, 127.91257836719551, 134.2011330887875, 139.23043006997628, 140.71673537840158, 145.76288138835983, 147.80216629676042, 154.06420451405637, 159.0846626604798, 160.76183155710717, 165.73699067536242, 167.9265357747636, 173.96705069576544, 178.2522282751915, 179.9042617354548, 183.54586165856657, 185.23269803071796, 189.41678143751972, 191.87149157986588, 192.8741468985015, 195.0241934550453, 195.966634211846, 197.9821647518146, 198.99006812859284, 199.33202054855676, 199.91897441965887, 200.11536227958896, 200.22280936469997, 200.25181179127208],'d')
|
||||
y=to_array([11.0, 6.0, 8.0, 5.0, 11.0, 7.0, 18.0, 11.0, 12.0, 10.0, 8.0, 6.0, 16.0, 4.0, 12.0, 9.0, 15.0, 14.0, 8.0, 20.0, 15.0, 8.0, 9.0, 11.0, 13.0, 12.0, 13.0, 15.0, 13.0, 20.0, 10.0, 7.0, 17.0, 11.0, 20.0, 13.0, 13.0, 23.0, 14.0, 10.0, 17.0, 15.0, 20.0, 16.0, 14.0, 13.0, 18.0, 22.0, 9.0, 20.0, 12.0, 14.0, 17.0, 19.0, 14.0, 14.0, 23.0, 19.0, 15.0, 20.0, 20.0, 21.0, 20.0, 23.0, 22.0, 15.0, 10.0, 17.0, 21.0, 15.0, 23.0, 23.0, 25.0, 18.0, 16.0, 21.0, 22.0, 16.0, 16.0, 14.0, 19.0, 20.0, 18.0, 20.0, 23.0, 13.0, 16.0, 20.0, 25.0, 15.0, 15.0, 17.0, 22.0, 26.0, 19.0, 30.0, 25.0, 17.0, 17.0, 23.0, 16.0, 27.0, 21.0, 21.0, 26.0, 27.0, 21.0, 17.0, 20.0, 20.0, 21.0, 19.0, 25.0, 19.0, 13.0, 23.0, 20.0, 20.0, 18.0, 20.0, 19.0, 25.0],'d')
|
||||
[off, amp, com, sigma] = gfitoff(x, y, off=None, amp=None, com=None, sigma=None)
|
||||
#print "Fit: ", [off, amp, com, sigma]
|
||||
g = Gaussian(amp, com, sigma)
|
||||
plot([y, [g.value(i)+off for i in x]], ["data", "fit"], xdata = x)
|
||||
|
||||
|
||||
28
script/test/TestOphyd.py
Normal file
28
script/test/TestOphyd.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from jeputils import *
|
||||
|
||||
read_ophyd = import_py("CPython/Ophyd", "read")
|
||||
|
||||
|
||||
class Ophyd(Readable):
|
||||
def __init__(self, name):
|
||||
self.dev=name
|
||||
|
||||
def getName(self):
|
||||
return self.dev
|
||||
|
||||
def read(self):
|
||||
v = read_ophyd(self.name)
|
||||
if (v is None) or (len(v)==0):
|
||||
return None
|
||||
v = v[self.name]
|
||||
try:
|
||||
timestamp = int(v["timestamp"]*1000)
|
||||
except:
|
||||
timestamp = time.time()
|
||||
ret = TimestampedValue (v["value"], timestamp)
|
||||
return ret
|
||||
|
||||
|
||||
dets = [Ophyd("det1"), Ophyd("det2")]
|
||||
|
||||
tscan(dets, 10, 0.1)
|
||||
@@ -18,8 +18,7 @@
|
||||
<script>import time
|
||||
def process(x):
|
||||
time.sleep(0.1)
|
||||
#print "==>" + str(x.getValue())
|
||||
</script>
|
||||
#print "==>" + str(x.getValue())</script>
|
||||
</action>
|
||||
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTCALCOUT:Output" id="id348623"/>
|
||||
<detector xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ScalarDetector" name="TESTIOC:TESTSINUS:SinCalc" id="id367393"/>
|
||||
|
||||
@@ -24,6 +24,6 @@ def process():
|
||||
</dimension>
|
||||
</scan>
|
||||
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlot" x="id278043" y="id348623 id367393"/>
|
||||
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlotArray" y="id278043" z="id980818" type="3D"/>
|
||||
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="MatrixPlotArray" y="id278043" z="id980818" type="2D"/>
|
||||
<visualization xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="LinePlotArray" y="id980818" maxSeries="2" offset="3" size="5"/>
|
||||
</configuration>
|
||||
|
||||
19
script/test/test_append_tiff.py
Normal file
19
script/test/test_append_tiff.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import javax.imageio.ImageIO as ImageIO
|
||||
|
||||
def get_file(index):
|
||||
scan = "/Users/gobbo_a/dev/pshell/config/home/data/2024_03/20240314/20240314_141635_console/scan 1/"
|
||||
return scan + ("det image_%04d.tiff" % (index))
|
||||
|
||||
images = []
|
||||
for i in range(4):
|
||||
filename = get_file(i)
|
||||
images.append(ImageIO.read(File(filename)))
|
||||
|
||||
combinedImage = BufferedImage(400, 200, BufferedImage.TYPE_INT_RGB);
|
||||
g = combinedImage.getGraphics();
|
||||
g.drawImage(images[0], 0, 0, None);
|
||||
g.drawImage(images[1], 200, 0, None);
|
||||
g.drawImage(images[2], 0, 100, None);
|
||||
g.drawImage(images[3], 200, 100, None);
|
||||
|
||||
ImageIO.write(combinedImage, "TIFF", File(get_file(5)));
|
||||
35
script/test/test_append_tiff2.py
Normal file
35
script/test/test_append_tiff2.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from ijutils import *
|
||||
|
||||
def get_file(index):
|
||||
scan = "/Users/gobbo_a/dev/pshell/config/home/data/2024_03/20240319/20240319_105604_TeztTiff/scan 1/"
|
||||
return scan + ("det image_%04d.tiff" % (index))
|
||||
|
||||
imgs_per_row=2
|
||||
imgs_per_col=2
|
||||
|
||||
images = []
|
||||
for i in range(4):
|
||||
filename = get_file(i)
|
||||
images.append(ImagePlus(filename))
|
||||
|
||||
proc=images[0].getProcessor()
|
||||
combined_image = ImagePlus("Combined Image", proc.createProcessor(proc.getWidth()*imgs_per_row, imgs_per_col * proc.getHeight()))
|
||||
|
||||
p=None
|
||||
for i in range(len(images)):
|
||||
proc = images[i].getProcessor()
|
||||
x,y = i%imgs_per_row, i/imgs_per_row
|
||||
combined_image.getProcessor().insert(proc, x * proc.getWidth(), y * proc.getHeight())
|
||||
|
||||
data = Convert.transpose(get_ip_array(combined_image))
|
||||
if p is None:
|
||||
p=plot(data, title="Combined")[0]
|
||||
else:
|
||||
p.getSeries(0).setData(data)
|
||||
time.sleep(1.0)
|
||||
|
||||
#plot(Convert.transpose(get_ip_array(combined_image)))
|
||||
#save_image(combined_image, get_file(6), "tiff")
|
||||
|
||||
|
||||
|
||||
78
script/test/test_direct_tiff_data.py
Normal file
78
script/test/test_direct_tiff_data.py
Normal file
@@ -0,0 +1,78 @@
|
||||
###################################################################################################
|
||||
#Data Manipulation: Using the data access API to generate and retrieve data
|
||||
###################################################################################################
|
||||
|
||||
|
||||
#Creating a 1D dataset from an array
|
||||
path="group/data1"
|
||||
data1d = [1.0, 2.0, 3.0, 4.0, 5.0]
|
||||
save_dataset(path, data1d)
|
||||
#Reading ii back
|
||||
read =load_data(path)
|
||||
print read.tolist()
|
||||
assert data1d==read.tolist()
|
||||
plot(read)
|
||||
|
||||
#Creating a 2D dataset from an array with some attributes
|
||||
data2d = [ [1.0, 2.0, 3.0, 4.0, 5.0], [2.0, 3.0, 4.0, 5.0, 6.0, ], [3.0, 4.0, 5.0, 6.0, 7.0]]
|
||||
path="group/data2"
|
||||
save_dataset(path, data2d)
|
||||
set_attribute(path, "AttrString", "Value")
|
||||
set_attribute(path, "AttrInteger", 1)
|
||||
set_attribute(path, "AttrDouble", 2.0)
|
||||
set_attribute(path, "AttrBoolean", True)
|
||||
#Reading it back
|
||||
read =load_data(path)
|
||||
print read.tolist()
|
||||
plot(read)
|
||||
|
||||
#Creating a 3D dataset from an array
|
||||
data3d = [ [ [1,2,3,4,5], [2,3,4,5,6], [3,4,5,6,7]], [ [3,2,3,4,5], [4,3,4,5,6], [5,4,5,6,7]]]
|
||||
path="group/data3"
|
||||
save_dataset(path, data3d)
|
||||
#Reading it back
|
||||
read =load_data(path,0)
|
||||
print read.tolist()
|
||||
read =load_data(path,1)
|
||||
print read.tolist()
|
||||
|
||||
#Creating a INT dataset adding elements one by one
|
||||
path = "group/data4"
|
||||
create_dataset(path, 'i')
|
||||
for i in range(10):
|
||||
append_dataset(path,i)
|
||||
|
||||
|
||||
#Creating a 2D data FLOAT dataset adding lines one by one
|
||||
path = "group/data5"
|
||||
create_dataset(path, 'd', False, (0,0))
|
||||
for row in data2d:
|
||||
append_dataset(path, row)
|
||||
|
||||
|
||||
#Creating a Table (compund type)
|
||||
path = "group/data6"
|
||||
names = ["a", "b", "c", "d"]
|
||||
table_types = ["d", "d", "d", "[d"]
|
||||
lenghts = [0,0,0,5]
|
||||
table = [ [1,2,3,[0,1,2,3,4]],
|
||||
[2,3,4,[3,4,5,6,7]],
|
||||
[3,4,5,[6,7,8,9,4]] ]
|
||||
create_table(path, names, table_types, lenghts)
|
||||
for row in table:
|
||||
append_table(path, row)
|
||||
flush_data()
|
||||
#Read it back
|
||||
read =load_data(path)
|
||||
print read
|
||||
|
||||
|
||||
#Writing scalars (datasets with rank 0)
|
||||
save_dataset("group/val1", 1)
|
||||
save_dataset("group/val2", 3.14)
|
||||
save_dataset("group/val3", "test")
|
||||
print load_data("group/val1")
|
||||
print load_data("group/val2")
|
||||
print load_data("group/val3")
|
||||
|
||||
|
||||
27
script/test/test_metadata.py
Normal file
27
script/test/test_metadata.py
Normal file
@@ -0,0 +1,27 @@
|
||||
from ijutils import *
|
||||
|
||||
|
||||
def before_read(position, scan):
|
||||
ProviderTIFF.setMetadata({"index": scan.recordIndex})
|
||||
|
||||
|
||||
num_images = 4
|
||||
r=tscan((sin, det.dataMatrix), num_images, 0.1, before_read=before_read)
|
||||
|
||||
data_folder = expand_path("{data}/" + r.path.replace(" | ", "/"))
|
||||
|
||||
imgs_per_row=2
|
||||
imgs_per_col=num_images/2
|
||||
|
||||
combined_image = None
|
||||
for i in range(num_images):
|
||||
filename = data_folder + ("/%s_%04d.tiff" % (det.dataMatrix.getName(),i,))
|
||||
img = ImagePlus(filename)
|
||||
proc=img.getProcessor()
|
||||
if not combined_image:
|
||||
combined_image = ImagePlus("Combined Image", proc.createProcessor(proc.getWidth()*imgs_per_row, imgs_per_col * proc.getHeight()))
|
||||
x,y = i%imgs_per_row, i/imgs_per_row
|
||||
combined_image.getProcessor().insert(proc, x * proc.getWidth(), y * proc.getHeight())
|
||||
|
||||
filename = data_folder + ("/%s_combined.tiff" % (det.dataMatrix.getName(),))
|
||||
save_image(combined_image, filename, "tiff", metadata={"index": -1})
|
||||
27
script/test/test_positioner.py
Normal file
27
script/test/test_positioner.py
Normal file
@@ -0,0 +1,27 @@
|
||||
class Test (PositionerBase):
|
||||
def __init__(self, name):
|
||||
PositionerBase.__init__(self, name, PositionerConfig())
|
||||
self.rbk = 0.0
|
||||
self.stp = 0.0
|
||||
self.moving = False
|
||||
|
||||
def doRead(self):
|
||||
return self.stp
|
||||
|
||||
def doWrite(self, value):
|
||||
if value!=self.stp:
|
||||
self.stp=value
|
||||
self.moving = True
|
||||
|
||||
def doReadReadback(self):
|
||||
if self.moving:
|
||||
off = self.stp - self.rbk
|
||||
if abs(off)<=1:
|
||||
self.rbk = self.stp
|
||||
self.moving = False
|
||||
else:
|
||||
self.rbk = self.rbk +1.0 if (self.stp > self.rbk) else self.rbk -1.0
|
||||
return self.rbk
|
||||
|
||||
add_device(Test("test_positioner"), True)
|
||||
test_positioner.polling=1000
|
||||
@@ -3,17 +3,20 @@ url="tcp://localhost:9999"
|
||||
|
||||
st1 = Stream("st1", url, SocketType.PULL)
|
||||
#st1.parent.config.headerReservingAllocator = True
|
||||
st1.parent.config.analizeHeader = False
|
||||
|
||||
|
||||
st1.initialize()
|
||||
st1.start()
|
||||
st1.waitCacheChange(60000)
|
||||
|
||||
|
||||
#show_panel(st1)
|
||||
|
||||
|
||||
add_device(st1)
|
||||
try:
|
||||
bscan (st1, 5, 5, save=False)
|
||||
#bscan (st1, 5, 5, save=False)
|
||||
#show_panel(st1)
|
||||
pass
|
||||
finally:
|
||||
st1.close()
|
||||
#p.close()
|
||||
#st1.close()
|
||||
pass
|
||||
|
||||
|
||||
|
||||
|
||||
16
script/test/test_tiff_3d.py
Normal file
16
script/test/test_tiff_3d.py
Normal file
@@ -0,0 +1,16 @@
|
||||
"""
|
||||
data3d = [ [ [1,2,3,4,5], [2,3,4,5,6], [3,4,5,6,7]], [ [3,2,3,4,5], [4,3,4,5,6], [5,4,5,6,7]]]
|
||||
path="group/data3"
|
||||
save_dataset(path, data3d)
|
||||
#Reading it back
|
||||
read =load_data(path,0)
|
||||
print read.tolist()
|
||||
read =load_data(path,1)
|
||||
print read.tolist()
|
||||
|
||||
"""
|
||||
|
||||
#Creating a 2D dataset from an array with some attributes
|
||||
data2d = [ [1.0, 2.0, 3.0, 4.0, 5.0], [2.0, 3.0, 4.0, 5.0, 6.0, ], [3.0, 4.0, 5.0, 6.0, 7.0]]
|
||||
path="group/data2"
|
||||
save_dataset(path, data2d)
|
||||
299
script/tst_jep.py
Normal file
299
script/tst_jep.py
Normal file
@@ -0,0 +1,299 @@
|
||||
###################################################################################################
|
||||
# Facade to JEP: Embedded Python
|
||||
###################################################################################################
|
||||
|
||||
#Matplotlib won't work out of the box because it's default backend (Qt) uses signals, which only works in
|
||||
#the main thread. Ideally should find a fix, in order to mark the running thread as the main.
|
||||
#As a workaround, one can use the Tk backend:
|
||||
#
|
||||
#import matplotlib
|
||||
#matplotlib.use('TkAgg')
|
||||
|
||||
|
||||
#In principle just add JEP jar and library to the extensions folder.
|
||||
#
|
||||
#Alternatively on Linux:
|
||||
# Python 2:
|
||||
# - Add <python home>/lib/python3.X/site-packages/jep to LD_LIBRARY_PATH
|
||||
# - Add <python home>/lib/python3.X/site-packages/jep/jep-X.X.X.jar to the class path
|
||||
#
|
||||
#Python3:
|
||||
# - Add JEP library folder to LD_LIBRARY_PATH
|
||||
# - If using OpenJDK, add also python <python home>/lib folder to LD_LIBRARY_PATH
|
||||
# - Set LD_PRELOAD=<python home>/lib/libpython3.5m.so
|
||||
|
||||
|
||||
import sys
|
||||
import os
|
||||
import jep.Jep
|
||||
import jep.SharedInterpreter
|
||||
import jep.NDArray
|
||||
import java.lang.Thread
|
||||
import org.python.core.PyArray as PyArray
|
||||
import java.lang.String as String
|
||||
import java.util.List
|
||||
import java.util.Map
|
||||
import java.util.HashMap
|
||||
import java.util.ArrayList
|
||||
import java.util.Collections
|
||||
import ch.psi.pshell.scripting.ScriptUtils as ScriptUtils
|
||||
|
||||
|
||||
from startup import to_array, get_context, _get_caller, Convert, Arr
|
||||
|
||||
__jep = {}
|
||||
|
||||
def __get_jep():
|
||||
t = java.lang.Thread.currentThread()
|
||||
if not t in __jep:
|
||||
init_jep()
|
||||
return __jep[t]
|
||||
|
||||
def __close_jep():
|
||||
t = java.lang.Thread.currentThread()
|
||||
if t in __jep:
|
||||
__jep[t].close()
|
||||
|
||||
def init_jep():
|
||||
#TODO: Should do it but generates errors
|
||||
#__close_jep()
|
||||
j = jep.SharedInterpreter()
|
||||
try:
|
||||
#Faster, but statements must be complete
|
||||
j.setInteractive(False)
|
||||
except:
|
||||
pass # Removed in 4.2
|
||||
__jep[java.lang.Thread.currentThread()] = j
|
||||
j.eval("import sys")
|
||||
#sys.argv is not present in JEP and may be needed for certain modules (as Tkinter)
|
||||
j.eval("sys.argv = ['PShell']");
|
||||
#Add standard script path to python path
|
||||
j.eval("sys.path.append('" + get_context().setup.getScriptPath() + "')")
|
||||
|
||||
#Redirect stdout
|
||||
j.eval("class JepStdout:\n" +
|
||||
" def write(self, str):\n" +
|
||||
" self.str += str\n" +
|
||||
" def clear(self):\n" +
|
||||
" self.str = ''\n" +
|
||||
" def flush(self):\n" +
|
||||
" pass\n")
|
||||
j.eval("sys.stdout=JepStdout()");
|
||||
j.eval("sys.stderr=JepStdout()");
|
||||
j.eval("sys.stdout.clear()")
|
||||
j.eval("sys.stderr.clear()")
|
||||
|
||||
#Import reload on Python 3
|
||||
j.eval("try:\n" +
|
||||
" reload # Python 2.7\n" +
|
||||
"except NameError:\n" +
|
||||
" try:\n" +
|
||||
" from importlib import reload # Python 3.4+\n" +
|
||||
" except ImportError:\n" +
|
||||
" from imp import reload # Python 3.0 - 3.3\n")
|
||||
|
||||
def __print_stdout():
|
||||
j=__get_jep()
|
||||
output = None
|
||||
err = None
|
||||
try:
|
||||
output = j.getValue("sys.stdout.str")
|
||||
err = j.getValue("sys.stderr.str")
|
||||
j.eval("sys.stdout.clear()")
|
||||
j.eval("sys.stderr.clear()")
|
||||
except:
|
||||
pass
|
||||
if (output is not None) and len(output)>0:
|
||||
print output
|
||||
if (err is not None) and len(err)>0:
|
||||
print >> sys.stderr, err
|
||||
|
||||
def run_jep(script_name, vars = {}):
|
||||
global __jep
|
||||
script = get_context().scriptManager.library.resolveFile(script_name)
|
||||
if script is None :
|
||||
script= os.path.abspath(script_name)
|
||||
j=__get_jep()
|
||||
|
||||
for v in vars:
|
||||
j.set(v, vars[v])
|
||||
try:
|
||||
j.runScript(script)
|
||||
finally:
|
||||
__print_stdout()
|
||||
|
||||
def eval_jep(line):
|
||||
j=__get_jep()
|
||||
try:
|
||||
j.eval(line)
|
||||
finally:
|
||||
__print_stdout()
|
||||
|
||||
def set_jep(var, value):
|
||||
j=__get_jep()
|
||||
j.set(var, value)
|
||||
|
||||
def get_jep(var):
|
||||
j=__get_jep()
|
||||
return j.getValue(var)
|
||||
|
||||
def call_jep(module, function, args = [], kwargs = {}, reload=False):
|
||||
j=__get_jep()
|
||||
if isinstance(args, java.util.List):
|
||||
args=list(args)
|
||||
|
||||
if "/" in module:
|
||||
script = get_context().scriptManager.library.resolveFile(module)
|
||||
if "\\" in script:
|
||||
#Windows paths
|
||||
module_path = script[0:script.rfind("\\")]
|
||||
module = script[script.rfind("\\")+1:]
|
||||
else:
|
||||
#Linux paths
|
||||
module_path = script[0:script.rfind("/")]
|
||||
module = script[script.rfind("/")+1:]
|
||||
eval_jep("import sys")
|
||||
eval_jep("sys.path.append('" + module_path + "')")
|
||||
if module.endswith(".py"):
|
||||
module = module[0:-3]
|
||||
|
||||
f = module+"_" + function+"_"+str(j.hashCode())
|
||||
try:
|
||||
if reload:
|
||||
eval_jep("import " + module)
|
||||
eval_jep("_=reload(" + module+")")
|
||||
eval_jep("from " + module + " import " + function + " as " + f)
|
||||
if (kwargs is not None) and (len(kwargs)>0):
|
||||
#invoke with kwargs only available in JEP>3.8
|
||||
hm=java.util.HashMap()
|
||||
hm.update(kwargs)
|
||||
#The only way to get the overloaded method...
|
||||
m = j.getClass().getMethod("invoke", [String, ScriptUtils.getType("[o"), java.util.Map])
|
||||
ret = m.invoke(j, [f, to_array(args,'o'), hm])
|
||||
else:
|
||||
ret = j.invoke(f, args)
|
||||
finally:
|
||||
__print_stdout()
|
||||
return ret
|
||||
|
||||
#Converts pythonlist or Java array to numpy array
|
||||
def to_npa(data, dimensions = None, type = None):
|
||||
if (not isinstance(data, PyArray)) or (type is not None):
|
||||
data = to_array(data,'d' if type is None else type)
|
||||
if dimensions is None:
|
||||
return jep.NDArray(data)
|
||||
return jep.NDArray(data, dimensions)
|
||||
|
||||
#recursivelly converts all NumPy arrays to Java arrys
|
||||
def rec_from_npa(obj):
|
||||
ret = obj
|
||||
if isinstance(obj, jep.NDArray):
|
||||
ret = obj.data
|
||||
if len(obj.dimensions)>1:
|
||||
ret=Convert.reshape(ret, obj.dimensions)
|
||||
elif isinstance(obj, java.util.List) or isinstance(obj,tuple) or isinstance(obj,list):
|
||||
ret=[]
|
||||
for i in range(len(obj)):
|
||||
ret.append(rec_from_npa(obj[i]))
|
||||
#if isinstance(obj,tuple) or obj.getClass().getSimpleName().startswith("Unmodifiable"): #TODO: Is it a good check for immutability?
|
||||
# ret=tuple(ret)
|
||||
elif isinstance(obj, java.util.Map) or isinstance(obj,dict):
|
||||
ret = {}
|
||||
for k in obj.keys():
|
||||
ret[k] = rec_from_npa(obj[k])
|
||||
return ret
|
||||
|
||||
#recursivelly converts all Java arrays to NumPy arrays
|
||||
def rec_to_npa(obj):
|
||||
ret = obj
|
||||
if isinstance(obj, PyArray):
|
||||
dimensions = Arr.getShape(obj)
|
||||
if len(dimensions)>1:
|
||||
obj = Convert.flatten(obj)
|
||||
ret = to_npa(obj, dimensions = dimensions)
|
||||
elif isinstance(obj, java.util.List) or isinstance(obj,tuple) or isinstance(obj,list):
|
||||
ret = java.util.ArrayList()
|
||||
for i in range(len(obj)):
|
||||
ret.add(rec_to_npa(obj[i]))
|
||||
#if isinstance(obj,tuple):
|
||||
# ret = java.util.Collections.unmodifiableList(ret);
|
||||
elif isinstance(obj, java.util.Map) or isinstance(obj,dict):
|
||||
ret = java.util.HashMap()
|
||||
for k in obj.keys():
|
||||
ret[k] = rec_to_npa(obj[k])
|
||||
return ret
|
||||
|
||||
def call_py(module, function, reload_function, *args, **kwargs):
|
||||
"""
|
||||
Calls a CPython function recursively converting Java arrays in arguments to NumPy,
|
||||
and NumPy arrays in return values to Java arrays.
|
||||
"""
|
||||
ret = call_jep(module, function, rec_to_npa(args), rec_to_npa(kwargs), reload=reload_function)
|
||||
return rec_from_npa(ret)
|
||||
|
||||
def import_py(module, function):
|
||||
"""
|
||||
Adds a CPython function to globals, creating a wrapper call to JEP, with
|
||||
recurvive convertion of Java arrays in arguments to NumPy arrays,
|
||||
and NumPy arrays in return values to Java arrays.
|
||||
"""
|
||||
def jep_wrapper(*args, **kwargs):
|
||||
reload_function = jep_wrapper.reload
|
||||
jep_wrapper.reload = False
|
||||
return call_py(module, function, reload_function, *args, **kwargs)
|
||||
jep_wrapper.reload=True
|
||||
_get_caller().f_globals[function] = jep_wrapper
|
||||
return jep_wrapper
|
||||
|
||||
|
||||
"""
|
||||
eval_jep("from java.lang import System")
|
||||
eval_jep("s = 'Hello World'");
|
||||
eval_jep("System.out.println(s)")
|
||||
eval_jep("print(s)")
|
||||
eval_jep("print(s[1:-1])")
|
||||
eval_jep("import numpy")
|
||||
|
||||
r1=call_jep("numpy", "ones", [5])
|
||||
r2=run_jep("cpython/gfitoff")
|
||||
"""
|
||||
|
||||
"""
|
||||
import_py("CPython/gfitoff", "gfitoff")
|
||||
from mathutils import Gaussian
|
||||
x=to_array([-200.30429237268825, -200.2650700434188, -200.22115208318002, -199.9457671375377, -199.86345548879072, -199.85213073174933, -199.35687977133284, -199.13811861090275, -197.97304970346386, -197.2952215624348, -195.09076092936948, -192.92276048970703, -191.96871876227698, -189.49577852322938, -187.9652790409825, -183.63756456925222, -180.04899765472996, -178.43839623242422, -174.07311671294445, -172.0410133577918, -165.90824309893102, -160.99771795989466, -159.30176653939253, -154.27688897558514, -152.0854103810786, -145.75652847587313, -140.80843828908465, -139.23982133191495, -134.27073891256106, -132.12649284133064, -125.95947209775511, -121.00309550337462, -119.26736932643232, -114.2706655484383, -112.07393889578914, -105.72295990367157, -100.8088439880125, -99.2034906238494, -94.30042325164636, -92.15010048151461, -85.92203653534293, -81.03913275494665, -79.27412793784428, -74.33487658582118, -72.06274362408762, -65.76562628131825, -60.91255356825276, -59.20334389560392, -54.33286972659312, -52.19387171350535, -45.94978737932291, -41.03014719193582, -39.301602568238906, -34.35572209014114, -32.04464301272608, -25.8221033382824, -20.922074315528747, -19.21590299233186, -14.31090212502093, -12.217203140101386, -5.9283722049240435, -0.9863587170369246, 0.7408048387279834, 5.71126832601389, 7.972628957879352, 14.204559894256546, 19.11839959633025, 20.8218087836657, 25.678748486941828, 27.822718344586864, 34.062659474970715, 38.9745656819391, 40.77409719734158, 45.72080631619803, 47.974156754056835, 54.23453768983539, 59.12020360609568, 60.77306570712026, 65.70734521458867, 67.8344660434617, 74.03187028154134, 78.96532114824849, 80.76070945985495, 85.74802197591286, 87.9140889204674, 94.18082276873524, 99.25790470037091, 100.68454787413205, 105.7213026221542, 107.79483801526698, 113.99555681638138, 119.0707052529143, 120.72715813056156, 125.77551384921307, 127.91257836719551, 134.2011330887875, 139.23043006997628, 140.71673537840158, 145.76288138835983, 147.80216629676042, 154.06420451405637, 159.0846626604798, 160.76183155710717, 165.73699067536242, 167.9265357747636, 173.96705069576544, 178.2522282751915, 179.9042617354548, 183.54586165856657, 185.23269803071796, 189.41678143751972, 191.87149157986588, 192.8741468985015, 195.0241934550453, 195.966634211846, 197.9821647518146, 198.99006812859284, 199.33202054855676, 199.91897441965887, 200.11536227958896, 200.22280936469997, 200.25181179127208],'d')
|
||||
y=to_array([11.0, 6.0, 8.0, 5.0, 11.0, 7.0, 18.0, 11.0, 12.0, 10.0, 8.0, 6.0, 16.0, 4.0, 12.0, 9.0, 15.0, 14.0, 8.0, 20.0, 15.0, 8.0, 9.0, 11.0, 13.0, 12.0, 13.0, 15.0, 13.0, 20.0, 10.0, 7.0, 17.0, 11.0, 20.0, 13.0, 13.0, 23.0, 14.0, 10.0, 17.0, 15.0, 20.0, 16.0, 14.0, 13.0, 18.0, 22.0, 9.0, 20.0, 12.0, 14.0, 17.0, 19.0, 14.0, 14.0, 23.0, 19.0, 15.0, 20.0, 20.0, 21.0, 20.0, 23.0, 22.0, 15.0, 10.0, 17.0, 21.0, 15.0, 23.0, 23.0, 25.0, 18.0, 16.0, 21.0, 22.0, 16.0, 16.0, 14.0, 19.0, 20.0, 18.0, 20.0, 23.0, 13.0, 16.0, 20.0, 25.0, 15.0, 15.0, 17.0, 22.0, 26.0, 19.0, 30.0, 25.0, 17.0, 17.0, 23.0, 16.0, 27.0, 21.0, 21.0, 26.0, 27.0, 21.0, 17.0, 20.0, 20.0, 21.0, 19.0, 25.0, 19.0, 13.0, 23.0, 20.0, 20.0, 18.0, 20.0, 19.0, 25.0],'d')
|
||||
[off, amp, com, sigma] = gfitoff(x, y, off=None, amp=None, com=None, sigma=None)
|
||||
#print "Fit: ", [off, amp, com, sigma]
|
||||
g = Gaussian(amp, com, sigma)
|
||||
|
||||
plot([y, [g.value(i)+off for i in x]], ["data", "fit"], xdata = x)
|
||||
"""
|
||||
|
||||
|
||||
import_py("CPython/linfit", "linfit")
|
||||
import_py("CPython/linfit", "print_dict")
|
||||
import_py("CPython/linfit", "get_tuple")
|
||||
import_py("CPython/linfit", "test2")
|
||||
|
||||
#x=to_array([0,1,2,3,4,5,6,7,8,9], 'd')
|
||||
#y=to_array([1,2,3,6,9,6,3,2,1,0], 'd')
|
||||
|
||||
x=[0,1,2,3,4,5,6,7,8,9]
|
||||
y=[1,2,3,6,9,6,3,2,1,0]
|
||||
|
||||
x=(0,1,2,3,4,5,6,7,8,9)
|
||||
y=(1,2,3,6,9,6,3,2,1,0)
|
||||
|
||||
a=java.util.ArrayList()
|
||||
for i in x:
|
||||
a.add(i)
|
||||
(p, x_fit, y_fit, R2) = linfit(x,y)
|
||||
print "Fit: ", (p, x_fit, y_fit, R2)
|
||||
plot((y,y_fit), name=("data", "fit"),xdata=(x,x_fit))
|
||||
print("-----")
|
||||
t=get_tuple()
|
||||
|
||||
d={"a":1, "b":2}
|
||||
r=print_dict(d)
|
||||
|
||||
Reference in New Issue
Block a user