This commit is contained in:
gobbo_a
2026-02-09 15:06:52 +01:00
parent 4f6a49c538
commit f841fbc0ea
163 changed files with 576 additions and 49654 deletions

View File

@@ -1,90 +1,87 @@
#Tue Oct 28 16:49:26 CET 2025
#Wed Jan 14 14:03:24 CET 2026
autoSaveScanData=true
simulation=false
dataScanAutoSave=true
xscanCrlogicChannel=null
dataScanSaveOutput=false
scanPreserveTypes=false
userAuthenticator=
dataScanStrategy=default
dataScanSaveScript=false
notifiedTasks=null
parallelInitialization=false
fdaSerialization=false
consoleJournal=false
scanDataRelease=false
dataTransferPath=null
scanStreamingPort=-1
saveConsoleSessionFiles=false
xscanAppendSuffix=true
devicePoolFile={config}/devices.properties
hostName=
disableEmbeddedAttributes=false
scanSaveTimestamps=false
commandTimeToLive=600000
serverPort=8090
versionTrackingEnabled=true
dataPath={data}/{year}/{month}/{day}/{date}_{time}_{name}
serverEnabled=false
depthDimension=0
logLevel=Fine
dataLayout=sf
disableDataFileLogs=false
dataScanSaveTimestamps=false
sessionHandling=Off
deviceUpdateStrategyFile={config}/update.properties
terminalEnabled=false
notificationLevel=Off
terminalPort=3579
commandQueueSize=-1
dataTransferUser=null
xscanContinuousUpdate=false
scanLazyTableCreation=false
versionTrackingLogin=
noBytecodeFiles=false
scanSaveMeta=true
versionTrackingRemote=https\://gitea.psi.ch/pshell_config/sf-op.git
scanAutoSave=true
dataScanLazyTableCreation=false
pythonHome=
xscanMoveTimeout=600
commandStatistics=false
serverHostName=null
commandExecutionEvents=false
logDaysToLive=30
xscanCrlogicSimulated=false
dataDepthDimension=0
logLevelConsole=Off
filePermissionsConfig=Default
scanStreamerPort=-1
dataEmbeddedAttributes=false
dataScanSaveSetpoints=false
scanSaveLogs=true
serverCommandsHidden=false
versionTrackingManual=true
dataTransferMode=Off
userManagement=false
instanceName=OP
dataServerPort=-1
notificationTasks=
hideServerMessages=false
scanReleaseRecords=false
scanDefaultTag=null
dataScanReleaseRecords=false
dataScanPreserveTypes=false
dataScanFlushRecords=false
filePermissionsLogs=Public
logPath={logs}/{date}_{time}
filePermissionsScripts=Public
xscanCrlogicPrefix=null
dataFormat=null
dataScanSaveLogs=true
tasksFile={config}/tasks.properties
filePermissionsData=Default
xscanCrlogicAbortable=true
commandQueueSize=-1
commandStatistics=false
commandTimeToLive=600000
consoleJournal=false
createSessionFiles=false
dataScanStreamerPort=-1
scanFlushRecords=false
dataProvider=default
xscanCrlogicIoc=null
dataDepthDimension=0
dataEmbeddedAttributes=false
dataFormat=default
dataLayout=sf
dataPath={data}/{year}/{month}/{day}/{date}_{time}_{name}
dataProvider=null
dataScanFlushRecords=false
dataScanLazyTableCreation=false
dataScanPreserveTypes=false
dataScanReleaseRecords=false
dataScanSaveOutput=false
dataScanSaveScript=false
dataScanSaveSetpoints=false
dataScanSaveTimestamps=false
dataServerPort=-1
dataTransferMode=Off
dataTransferPath=null
dataTransferUser=null
dataTruncate=true
depthDimension=0
devicePoolFile={config}/devices.properties
deviceUpdateStrategyFile={config}/update.properties
disableDataFileLogs=false
disableEmbeddedAttributes=false
fdaSerialization=false
filePermissionsConfig=Default
filePermissionsData=Default
filePermissionsLogs=Public
filePermissionsScripts=Public
hideServerMessages=false
hostName=null
instanceName=OP
logDaysToLive=30
logLevel=Fine
logLevelConsole=Off
logPath={logs}/{date}_{time}.{mode}
noBytecodeFiles=false
notificationLevel=Off
notificationTasks=
notifiedTasks=
parallelInitialization=false
pythonHome=
pythonNoBytecodeFiles=false
saveCommandStatistics=false
saveConsoleSessionFiles=false
scanAutoSave=true
scanDefaultTag="scan_{index}%d"
scanFlushRecords=false
scanLazyTableCreation=false
scanPreserveTypes=false
scanReleaseRecords=false
scanSaveLogs=true
scanSaveMeta=true
scanSaveTimestamps=false
scanStreamerPort=-1
serverCommandsHidden=false
serverEnabled=false
serverHostName=
serverHttps=false
serverPort=8090
sessionHandling=Off
simulation=false
tasksFile={config}/tasks.properties
terminalEnabled=false
terminalPort=3579
userAuthenticator=
userManagement=false
versionTrackingEnabled=true
versionTrackingLogin=
versionTrackingManual=true
versionTrackingRemote=https\://gitea.psi.ch/pshell_config/sf-op.git
xscanAppendSuffix=true
xscanContinuousUpdate=false
xscanCrlogicAbortable=true
xscanCrlogicChannel=null
xscanCrlogicIoc=null
xscanCrlogicPrefix=null
xscanCrlogicSimulated=false
xscanMoveTimeout=600

View File

@@ -1,5 +1,5 @@
dispatcher=ch.psi.pshell.bs.Dispatcher|https://dispatcher-api.psi.ch/sf|||
cam_server=ch.psi.pshell.bs.PipelineServer|sf-daqsync-01:8889|||
cam_server=ch.psi.pshell.camserver.PipelineSource|sf-daqsync-01:8889|||
charge=ch.psi.pshell.epics.ProcessVariable|SINEG01-DICT215:B1_CHARGE_AVERAGE-OP|||
rep_rate_bunch_1=ch.psi.pshell.epics.ProcessVariable|SIN-TIMAST-TMA:Bunch-1-Appl-Freq-RB|||
rep_rate_bunch_2=ch.psi.pshell.epics.ProcessVariable|SIN-TIMAST-TMA:Bunch-2-Appl-Freq-RB|||

View File

@@ -56,8 +56,7 @@
"scanPlotDisabled" : false,
"scanTableDisabled" : false,
"cachedDataPanel" : false,
"dataExtensions" : "",
"dataSubFiles" : "",
"dataVisibleFiles" : "",
"hideFileName" : false,
"showEmergencyStop" : false,
"showHomingButtons" : false,

BIN
config/sounds/KDE_Beep_Honk.wav Executable file

Binary file not shown.

View File

@@ -1,4 +1,4 @@
#Thu Dec 11 15:41:25 CET 2025
LastRunDate=251211
FileSequentialNumber=16000
DaySequentialNumber=17
#Mon Feb 09 14:27:51 CET 2026
DaySequentialNumber=13
FileSequentialNumber=16297
LastRunDate=260209

View File

@@ -8,4 +8,4 @@ rotation=true
sign_bit=0
scale=1.0
description=null
resolution=0.5
deadband=0.5

View File

@@ -1,47 +1,47 @@
#Mon Dec 15 10:58:09 CET 2025
\u0000\u0000\u0000=
\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
#Mon Feb 09 12:41:25 CET 2026
\u0000=
\u0000\u0000=
\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000=
colormapLogarithmic=false
spatialCalScaleX=-6.67596435546875
spatialCalScaleY=-6.5573768833705355
serverURL=null
rescaleOffset=0.0
roiWidth=-1
1=
colormap=Flame
colormapAutomatic=false
colormapLogarithmic=false
colormapMax=4000.0
colormapMin=80.0
flipHorizontally=false
flipVertically=false
grayscale=false
imageHeight=1680
imageWidth=1744
invert=false
colormapMin=100.0
rotationCrop=false
1=
roiHeight=-1
colormapAutomatic=true
roiY=0
roiX=0
spatialCalOffsetY=-312.00000361676905
spatialCalOffsetX=298.0
scale=1.0
regionStart=
grayscale=false
rtY=1
colormapMax=30000.0
spat=
rotation=0.0
rescaleFactor=1.0
imageHeight=1680
spatialCalUnits=null
flipVertically=false
r=
t=
flipHorizontally=false
transpose=false
regionStart=
regionStartX=433
regionStartY=241
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=-1
roiWidth=-1
roiX=0
roiY=0
rotation=0.0
rotationCrop=false
rtY=1
scale=1.0
serverURL=null
spat=
spatialCalOffsetX=-393.0000004567311
spatialCalOffsetY=-1023.999980257793
spatialCalScaleX=-8.737659395658053
spatialCalScaleY=-8.834898165327527
spatialCalUnits=null
t=
transpose=false

View File

@@ -7,7 +7,7 @@ scale=1.0
description=null
estbilizationDelay=0
maxSpeed=1.0
resolution=8.0E-4
deadband=8.0E-4
homingType=None
startRetries=1
minValue=130.0

View File

@@ -7,7 +7,7 @@ minSpeed=0.1
minValue=-10.0
offset=0.0
precision=2
resolution=NaN
deadband=NaN
rotation=false
scale=1.0
unit=mm

View File

@@ -3,6 +3,6 @@ maxValue=NaN
minValue=NaN
offset=0.0
precision=-1
resolution=NaN
deadband=NaN
scale=1.0
unit=null

View File

@@ -8,4 +8,4 @@ rotation=true
sign_bit=0
scale=1.0
description=null
resolution=0.5
deadband=0.5

View File

@@ -7,7 +7,7 @@ minSpeed=NaN
minValue=NaN
offset=0.0
precision=-1
resolution=NaN
deadband=NaN
rotation=false
scale=1.0
unit=null

View File

@@ -8,4 +8,4 @@ rotation=false
sign_bit=0
scale=1.0
description=null
resolution=0.01
deadband=0.01

View File

@@ -3,6 +3,6 @@ maxValue=10.0
minValue=-10.0
offset=0.0
precision=3
resolution=0.007
deadband=0.007
scale=1.0
unit=A

View File

@@ -3,6 +3,6 @@ maxValue=10.0
minValue=-10.0
offset=0.0
precision=3
resolution=0.007
deadband=0.007
scale=1.0
unit=A

View File

@@ -3,6 +3,6 @@ maxValue=10.0
minValue=-10.0
offset=0.0
precision=3
resolution=0.007
deadband=0.007
scale=1.0
unit=A

View File

@@ -7,4 +7,4 @@ rotation=false
precision=-1
sign_bit=0
scale=1.0
resolution=NaN
deadband=NaN

View File

@@ -3,7 +3,7 @@ maxValue=0.0
minValue=0.0
offset=0.0
precision=4
resolution=0.1
deadband=0.1
rotation=true
scale=1.0
unit=deg

View File

@@ -3,6 +3,6 @@ maxValue=10.0
minValue=-10.0
offset=0.0
precision=3
resolution=0.007
deadband=0.007
scale=1.0
unit=A

View File

@@ -3,6 +3,6 @@ maxValue=10.0
minValue=-10.0
offset=0.0
precision=3
resolution=0.007
deadband=0.007
scale=1.0
unit=null

View File

@@ -3,6 +3,6 @@ maxValue=10.0
minValue=-10.0
offset=0.0
precision=3
resolution=0.007
deadband=0.007
scale=1.0
unit=A

View File

@@ -3,6 +3,6 @@ maxValue=10.0
minValue=-10.0
offset=0.0
precision=3
resolution=0.007
deadband=0.007
scale=1.0
unit=null

View File

@@ -3,6 +3,6 @@ maxValue=5.0
minValue=-5.0
offset=0.0
precision=3
resolution=NaN
deadband=NaN
scale=1.0
unit=A

View File

@@ -3,6 +3,6 @@ maxValue=5.0
minValue=-5.0
offset=0.0
precision=3
resolution=NaN
deadband=NaN
scale=1.0
unit=A

View File

@@ -3,6 +3,6 @@ maxValue=5.0
minValue=-5.0
offset=0.0
precision=3
resolution=NaN
deadband=NaN
scale=1.0
unit=A

View File

@@ -3,6 +3,6 @@ maxValue=5.0
minValue=-5.0
offset=0.0
precision=3
resolution=NaN
deadband=NaN
scale=1.0
unit=A

View File

@@ -3,6 +3,6 @@ maxValue=NaN
minValue=NaN
offset=0.0
precision=-1
resolution=NaN
deadband=NaN
scale=1.0
unit=null

View File

@@ -3,7 +3,7 @@ maxValue=360.0
minValue=-360.0
offset=0.0
precision=3
resolution=0.1
deadband=0.1
rotation=false
scale=1.0
unit=deg

View File

@@ -3,7 +3,7 @@ maxValue=360.0
minValue=-360.0
offset=0.0
precision=3
resolution=0.1
deadband=0.1
rotation=false
scale=1.0
unit=deg

View File

@@ -3,7 +3,7 @@ maxValue=360.0
minValue=0.0
offset=0.0
precision=3
resolution=NaN
deadband=NaN
rotation=false
scale=1.0
unit=Degree

View File

@@ -3,7 +3,7 @@ maxValue=360.0
minValue=-90.0
offset=0.0
precision=3
resolution=0.1
deadband=0.1
rotation=true
scale=1.0
unit=deg

View File

@@ -7,7 +7,7 @@ minSpeed=0.1
minValue=-10.0
offset=0.0
precision=2
resolution=NaN
deadband=NaN
rotation=false
scale=1.0
unit=mm

View File

@@ -8,4 +8,4 @@ precision=4
sign_bit=0
scale=1.0
description=Dest. beam phase
resolution=0.05
deadband=0.05

View File

@@ -3,7 +3,7 @@ maxValue=NaN
minValue=NaN
offset=0.0
precision=-1
resolution=NaN
deadband=NaN
rotation=false
scale=1.0
unit=null

View File

@@ -3,7 +3,7 @@ offset=0.0
maxValue=210.0
precision=1
scale=1.0
resolution=NaN
deadband=NaN
minValue=0.0
unit=A
sign_bit=0

View File

@@ -4,7 +4,7 @@ maxValue=210.0
rotation=false
precision=1
scale=1.0
resolution=NaN
deadband=NaN
minValue=0.0
unit=A
sign_bit=0

View File

@@ -8,4 +8,4 @@ rotation=false
sign_bit=0
scale=1.0
description=null
resolution=NaN
deadband=NaN

View File

@@ -1,19 +1,19 @@
#Thu Dec 11 15:41:25 CET 2025
#Sat Feb 07 18:10:03 CET 2026
deadband=0.1
defaultSpeed=2000.0
description=PPMAC motor record
estbilizationDelay=0
hasEnable=false
homingType=None
maxSpeed=2000.0
maxValue=51500.0
minSpeed=5.0
minValue=-66903.0
monitorByPosition=false
offset=0.0
maxValue=68500.0
precision=1
rotation=false
scale=1.0
description=PPMAC motor record
estbilizationDelay=0
maxSpeed=2000.0
resolution=0.1
homingType=None
startRetries=1
minValue=-70000.0
unit=um
defaultSpeed=2000.0
hasEnable=false
sign_bit=0
monitorByPosition=false
minSpeed=5.0
startRetries=1
unit=um

View File

@@ -3,6 +3,6 @@ maxValue=360.0
minValue=0.0
offset=0.0
precision=3
resolution=NaN
deadband=NaN
scale=1.0
unit=Degree

View File

@@ -3,6 +3,6 @@ maxValue=NaN
minValue=NaN
offset=0.0
precision=-1
resolution=NaN
deadband=NaN
scale=1.0
unit=null

View File

@@ -1,25 +1,26 @@
#Fri Oct 03 16:35:45 CEST 2025
spatialCalOffsetY=-795.999998704586
spatialCalOffsetX=-873.9999719532899
colormapLogarithmic=false
scale=1.0
grayscale=false
spatialCalScaleX=-20.775623700157773
spatialCalScaleY=-21.55172349612865
colormapMax=NaN
rescaleOffset=0.0
roiWidth=-1
#Sun Feb 08 08:34:51 CET 2026
colormap=Flame
invert=false
colormapAutomatic=true
colormapLogarithmic=false
colormapMax=NaN
colormapMin=NaN
flipHorizontally=false
flipVertically=false
grayscale=false
invert=false
rescaleFactor=1.0
rescaleOffset=0.0
roiHeight=-1
roiWidth=-1
roiX=0
roiY=0
rotation=0.0
rotationCrop=false
rescaleFactor=1.0
scale=1.0
serverURL=null
spatialCalOffsetX=-861.0000211619925
spatialCalOffsetY=-829.0000262816876
spatialCalScaleX=-18.90359092620482
spatialCalScaleY=-19.607842977590828
spatialCalUnits=mm
flipVertically=false
roiHeight=-1
flipHorizontally=false
colormapAutomatic=true
roiY=0
roiX=0
transpose=false

View File

@@ -1,4 +1,4 @@
#Tue Aug 16 16:27:15 CEST 2022
#Wed Jan 07 13:30:45 CET 2026
minValue=NaN
unit=pC
offset=0.0
@@ -7,4 +7,5 @@ precision=1
sign_bit=0
scale=1.0
description=null
deadband=NaN
resolution=NaN

View File

@@ -3,6 +3,6 @@ maxValue=360.0
minValue=0.0
offset=0.0
precision=3
resolution=NaN
deadband=NaN
scale=1.0
unit=Degree

View File

@@ -1,4 +1,4 @@
#Tue Aug 16 16:27:15 CEST 2022
#Wed Jan 07 13:30:45 CET 2026
minValue=NaN
unit=MeV
offset=0.0
@@ -7,4 +7,5 @@ precision=3
sign_bit=0
scale=1.0
description=null
deadband=NaN
resolution=NaN

View File

@@ -3,7 +3,7 @@ maxValue=NaN
minValue=NaN
offset=0.0
precision=3
resolution=NaN
deadband=NaN
scale=1.0
sign_bit=0
unit=MeV

View File

@@ -3,6 +3,6 @@ maxValue=NaN
minValue=NaN
offset=0.0
precision=-1
resolution=NaN
deadband=NaN
scale=1.0
unit=null

View File

@@ -3,6 +3,6 @@ maxValue=NaN
minValue=NaN
offset=0.0
precision=-1
resolution=NaN
deadband=NaN
scale=1.0
unit=null

View File

@@ -3,6 +3,6 @@ maxValue=NaN
minValue=NaN
offset=0.0
precision=-1
resolution=NaN
deadband=NaN
scale=1.0
unit=null

View File

@@ -8,4 +8,4 @@ rotation=false
sign_bit=0
scale=1.0
description=null
resolution=NaN
deadband=NaN

View File

@@ -8,4 +8,4 @@ rotation=false
sign_bit=0
scale=1.0
description=null
resolution=NaN
deadband=NaN

View File

@@ -8,4 +8,4 @@ rotation=false
sign_bit=0
scale=1.0
description=null
resolution=NaN
deadband=NaN

View File

@@ -8,4 +8,4 @@ rotation=false
sign_bit=0
scale=1.0
description=null
resolution=NaN
deadband=NaN

View File

@@ -1,4 +1,4 @@
#Tue Aug 16 16:27:15 CEST 2022
#Wed Jan 07 13:30:45 CET 2026
minValue=-179.99
unit=DEG
offset=0.0
@@ -8,4 +8,5 @@ rotation=false
sign_bit=0
scale=1.0
description=null
resolution=1.0
deadband=1.0
resolution=NaN

View File

@@ -3,6 +3,6 @@ maxValue=210.0
minValue=0.0
offset=0.0
precision=3
resolution=NaN
deadband=NaN
scale=1.0
unit=A

View File

@@ -1,4 +1,4 @@
#Tue Aug 16 16:27:15 CEST 2022
#Wed Jan 07 13:30:45 CET 2026
minValue=0.0
unit=A
offset=0.0
@@ -8,4 +8,5 @@ rotation=false
sign_bit=0
scale=1.0
description=null
resolution=0.02
deadband=0.02
resolution=NaN

View File

@@ -7,4 +7,4 @@ rotation=false
precision=3
sign_bit=0
scale=1.0
resolution=0.1
deadband=0.1

View File

@@ -7,4 +7,4 @@ rotation=false
precision=3
sign_bit=0
scale=1.0
resolution=NaN
deadband=NaN

View File

@@ -7,4 +7,4 @@ rotation=false
precision=3
sign_bit=0
scale=1.0
resolution=NaN
deadband=NaN

View File

@@ -7,4 +7,4 @@ rotation=false
precision=3
sign_bit=0
scale=1.0
resolution=NaN
deadband=NaN

View File

@@ -7,7 +7,7 @@ scale=1.0
description=null
estbilizationDelay=0
maxSpeed=10.0
resolution=NaN
deadband=NaN
startRetries=1
minValue=-10.0
unit=mm

View File

@@ -7,7 +7,7 @@ scale=1.0
description=null
estbilizationDelay=0
maxSpeed=10.0
resolution=NaN
deadband=NaN
startRetries=1
minValue=-10.0
unit=mm

View File

@@ -7,6 +7,6 @@ minSpeed=0.1
minValue=-10.0
offset=0.0
precision=2
resolution=NaN
deadband=NaN
scale=1.0
unit=mm

View File

@@ -7,6 +7,6 @@ minSpeed=0.1
minValue=-10.0
offset=0.0
precision=2
resolution=NaN
deadband=NaN
scale=1.0
unit=mm

View File

@@ -8,4 +8,4 @@ rotation=false
sign_bit=0
scale=1.0
description=null
resolution=NaN
deadband=NaN

View File

@@ -9,7 +9,7 @@ minSpeed=NaN
minValue=-0.6
offset=0.0
precision=3
resolution=0.02
deadband=0.02
rotation=false
scale=1.0
unit=mm

View File

@@ -9,7 +9,7 @@ minSpeed=NaN
minValue=-1.4
offset=0.0
precision=3
resolution=0.02
deadband=0.02
rotation=false
scale=1.0
unit=mm

View File

@@ -7,4 +7,4 @@ precision=3
rotation=false
sign_bit=0
scale=1.0
resolution=NaN
deadband=NaN

View File

@@ -1,9 +1,10 @@
#Thu Sep 27 07:12:39 CEST 2018
#Tue Dec 16 10:03:37 CET 2025
deadband=NaN
description=null
maxValue=NaN
minValue=NaN
offset=0.0
precision=-1
resolution=NaN
rotation=false
scale=1.0
sign_bit=0

View File

@@ -3,6 +3,6 @@ maxValue=0.0
minValue=0.0
offset=0.0
precision=3
resolution=0.01
deadband=0.01
scale=1.0
unit=Degree

View File

@@ -7,4 +7,4 @@ rotation=false
precision=3
sign_bit=0
scale=1.0
resolution=NaN
deadband=NaN

View File

@@ -3,7 +3,7 @@ maxValue=NaN
minValue=NaN
offset=0.0
precision=2
resolution=NaN
deadband=NaN
scale=1.0
sign_bit=0
unit=Hz

View File

@@ -1,4 +1,4 @@
#Tue Aug 16 16:29:34 CEST 2022
#Wed Jan 07 13:30:45 CET 2026
minValue=0.0
unit=Hz
offset=0.0
@@ -7,4 +7,5 @@ precision=2
sign_bit=0
scale=1.0
description=null
deadband=NaN
resolution=NaN

View File

@@ -1,4 +1,4 @@
#Tue Aug 16 16:29:34 CEST 2022
#Wed Jan 07 13:30:45 CET 2026
minValue=0.0
unit=Hz
offset=0.0
@@ -7,4 +7,5 @@ precision=2
sign_bit=0
scale=1.0
description=null
deadband=NaN
resolution=NaN

View File

@@ -3,7 +3,7 @@ maxValue=NaN
minValue=NaN
offset=0.0
precision=-1
resolution=NaN
deadband=NaN
rotation=false
scale=1.0
unit=null

View File

@@ -3,7 +3,7 @@ maxValue=NaN
minValue=NaN
offset=0.0
precision=-1
resolution=NaN
deadband=NaN
rotation=false
scale=1.0
sign_bit=0

View File

@@ -1,12 +0,0 @@
FROM docker.psi.ch:5000/busybox_java
#COPY ./pshell-1.7.0-fat.jar /pshell/
RUN cd /
RUN mkdir pshell
RUN cd /pshell
RUN wget -O /pshell/pshell-1.7.0-fat.jar http://artifacts.psi.ch/artifactory/releases/ch/psi/pshell/1.7.0/pshell-1.7.0-fat.jar --no-check-certificate
#RUN ls /pshell
#COPY ./home/ /pshell/home/
EXPOSE 5000-10000
CMD ls -al /pshell/home/log; while true; do echo "Starting";java -Djava.awt.headless=true -jar /pshell/pshell-1.7.0-fat.jar -v -home=/pshell/home -clog=FINE; done

View File

@@ -1,6 +0,0 @@
#!/bin/bash
VERSION=1.7.0
docker build --no-cache=true -t docker.psi.ch:5000/pshell_server .
docker tag docker.psi.ch:5000/pshell_server docker.psi.ch:5000/pshell_server:$VERSION
docker push docker.psi.ch:5000/pshell_server:$VERSION
docker push docker.psi.ch:5000/pshell_server

View File

@@ -1,3 +0,0 @@
#!/bin/bash
docker run --network="host" --name pshellsrv -v /home/gobbo/docker/home:/pshell/home -v /etc/timezone:/etc/timezone:ro -v /etc/localtime:/etc/localtime:ro docker.psi.ch:5000/pshell_server &

View File

@@ -1,3 +0,0 @@
#!/bin/bash
docker stop pshellsrv
docker rm pshellsrv

View File

@@ -1,7 +0,0 @@
#!/bin/bash
wget -O ./pshell-1.7.0-fat.jar http://artifacts.psi.ch/artifactory/releases/ch/psi/pshell/1.7.0/pshell-1.7.0-fat.jar --no-check-certificate
java -jar ./pshell-1.7.0-fat.jar -o -dlaf
rm ./pshell-1.7.0-fat.jar

View File

@@ -84,7 +84,7 @@
<Component id="plot22" max="32767" attributes="0"/>
<Component id="plot21" max="32767" attributes="0"/>
</Group>
<EmptySpace min="0" pref="3" max="32767" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="panelScanPars" min="-2" max="-2" attributes="0"/>

View File

@@ -2,20 +2,16 @@
* Copyright (c) 2014-2017 Paul Scherrer Institute. All rights reserved.
*/
import ch.psi.pshell.core.Context;
import ch.psi.pshell.plot.LinePlot;
import ch.psi.pshell.plot.LinePlotSeries;
import ch.psi.pshell.ui.Panel;
import ch.psi.pshell.ui.App;
import ch.psi.pshell.ui.AppListener;
import ch.psi.utils.State;
import ch.psi.utils.swing.SwingUtils;
import java.awt.Color;
import ch.psi.pshell.framework.App;
import ch.psi.pshell.app.AppListener;
import ch.psi.pshell.framework.Panel;
import ch.psi.pshell.utils.State;
import ch.psi.pshell.swing.SwingUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.script.ScriptException;
import javax.swing.JSpinner;
/**

View File

@@ -1,545 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="2"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" max="32767" attributes="0"/>
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel2" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel3" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="buttonCancel" linkSize="2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="buttonApply" linkSize="2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="buttonOk" linkSize="2" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel3" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonOk" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonCancel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonApply" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace 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="Calibrate the camera moving the line overlays to the reference marks."/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel1">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Calibration"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel2" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerTop" min="-2" pref="80" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerRefWidth" min="-2" pref="80" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel8" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerBottom" min="-2" pref="80" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerRefHeight" min="-2" pref="80" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel10" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerRight" min="-2" pref="80" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel6" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerAngleVer" min="-2" pref="80" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel9" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerLeft" min="-2" pref="80" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerAngleHor" min="-2" pref="80" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="9" max="-2" attributes="0"/>
<Component id="ckCalibrationEnabled" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonFetch" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerRefWidth" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerTop" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerRefHeight" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerBottom" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerAngleHor" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerLeft" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerAngleVer" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerRight" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="12" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonFetch" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="ckCalibrationEnabled" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Reference marker height (um):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Horizontal camera angle (deg):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Vertical camera angle (deg):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Reference marker width (um):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Top (px):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel8">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Botton (px):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel9">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Left (px):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel10">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Right (px):"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerAngleHor">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" maximum="360.0" minimum="-360.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="calibrationSpinnerChanged"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerAngleVer">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" maximum="360.0" minimum="-360.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="calibrationSpinnerChanged"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerRefWidth">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="30000.0" maximum="500000.0" minimum="1.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="calibrationSpinnerChanged"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerRefHeight">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="30000.0" maximum="500000.0" minimum="1.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="calibrationSpinnerChanged"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerTop">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" maximum="10000" minimum="-10000" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="calibrationSpinnerChanged"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerBottom">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" maximum="10000" minimum="-10000" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="calibrationSpinnerChanged"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerLeft">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" maximum="10000" minimum="-10000" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="calibrationSpinnerChanged"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerRight">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" maximum="10000" minimum="-10000" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="calibrationSpinnerChanged"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonFetch">
<Properties>
<Property name="text" type="java.lang.String" value="Fetch from Inventory"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonFetchActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="ckCalibrationEnabled">
<Properties>
<Property name="text" type="java.lang.String" value="Enabled"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel2">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Transformations"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="checkMirrorX" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="comboRotation" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="checkMirrorY" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="0" groupAlignment="3" attributes="0">
<Component id="comboRotation" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="checkMirrorX" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="checkMirrorY" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JCheckBox" name="checkMirrorX">
<Properties>
<Property name="text" type="java.lang.String" value="Mirror X"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkMirrorY">
<Properties>
<Property name="text" type="java.lang.String" value="Mirror Y"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboRotation">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="0"/>
<StringItem index="1" value="270"/>
<StringItem index="2" value="180"/>
<StringItem index="3" value="90"/>
</StringArray>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel7">
<Properties>
<Property name="text" type="java.lang.String" value="Rotation: "/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel3">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Results"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="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="1" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel12" linkSize="3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="textOriginY" min="-2" pref="100" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel11" linkSize="3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="textOriginX" min="-2" pref="100" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel13" linkSize="4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="textPixelSizeY" min="-2" pref="100" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel14" linkSize="4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="textPixelSizeX" min="-2" pref="100" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel14" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textPixelSizeX" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel13" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textPixelSizeY" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel11" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textOriginX" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel12" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textOriginY" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel11">
<Properties>
<Property name="text" type="java.lang.String" value="Origin X (px):"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textOriginX">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel12">
<Properties>
<Property name="text" type="java.lang.String" value="Origin Y (px):"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textOriginY">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel13">
<Properties>
<Property name="text" type="java.lang.String" value="Y pixel size (um/px):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel14">
<Properties>
<Property name="text" type="java.lang.String" value="X pixel size (um/px):"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textPixelSizeX">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textPixelSizeY">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="buttonOk">
<Properties>
<Property name="text" type="java.lang.String" value="Ok"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonOkActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonCancel">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCancelActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonApply">
<Properties>
<Property name="text" type="java.lang.String" value="Apply"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonApplyActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@@ -1,726 +0,0 @@
import ch.psi.utils.swing.StandardDialog;
import ch.psi.utils.swing.SwingUtils;
import ch.psi.pshell.bs.CameraServer;
import ch.psi.pshell.imaging.Overlay;
import ch.psi.pshell.imaging.Overlays;
import ch.psi.pshell.imaging.Pen;
import ch.psi.pshell.imaging.Renderer;
import ch.psi.pshell.imaging.RendererListener;
import ch.psi.pshell.imaging.RendererMode;
import ch.psi.pshell.ui.App;
import ch.psi.utils.Convert;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Point;
import java.awt.Rectangle;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.JDialog;
/*
*/
/**
*
*/
public class CameraCalibrationDialog extends StandardDialog {
CameraServer server;
Renderer renderer;
String cameraName;
Overlay[] calibrationOverlays;
Pen pen = new Pen(new Color(128, 0, 128), 1, Pen.LineStyle.solid);
Overlays.Crosshairs ovTop = new Overlays.Crosshairs(pen, new Dimension(-1, 1));
Overlays.Crosshairs ovBottom = new Overlays.Crosshairs(pen, new Dimension(-1, 1));
Overlays.Crosshairs ovLeft = new Overlays.Crosshairs(pen, new Dimension(1, -1));
Overlays.Crosshairs ovRight = new Overlays.Crosshairs(pen, new Dimension(1, -1));
/**
*
* {
* name=SINEG01-DSCR350,
* prefix=SINEG01-DSCR350,
* mirror_x=true,
* mirror_y=true,
* rotate=0,
* calibration={
* horizontal_camera_angle=0,
* vertical_camera_angle=0
* reference_marker_width=16000.0,
* reference_marker_height=16000.0,
* reference_marker=[120, 245, 1251, 1504],
* },
* }
*/
public CameraCalibrationDialog(Frame parent, String cameraName, Renderer renderer) throws IOException {
super(parent, cameraName, false);
initComponents();
if (App.hasArgument("cam_srv_url")) {
this.server = new CameraServer("Camera Server", App.getArgumentValue("cam_srv_url"));
} else {
this.server = new CameraServer("Camera Server");
}
this.cameraName = cameraName;
this.renderer = renderer;
Map<String, Object> config = server.getConfig(cameraName);
Map<String, Object> calibration = (Map<String, Object>) config.get("camera_calibration");
List<Integer> refMarker = null;
System.out.println("Current config: " + config);
checkMirrorX.setSelected((config.get("mirror_x") ==null) ? Boolean.FALSE: (Boolean)config.get("mirror_x"));
checkMirrorY.setSelected((config.get("mirror_y") ==null) ? Boolean.FALSE: (Boolean)config.get("mirror_y"));
comboRotation.setSelectedIndex((config.get("rotate") == null) ? 0 :(Integer) (config.get("rotate")));
ckCalibrationEnabled.setSelected(calibration!=null);
if (calibration!=null){
spinnerRefWidth.setValue(((Number)calibration.get("reference_marker_width")).doubleValue());
spinnerRefHeight.setValue(((Number)calibration.get("reference_marker_height")).doubleValue());
spinnerAngleHor.setValue(((Number)calibration.get("angle_horizontal")).doubleValue());
spinnerAngleVer.setValue(((Number)calibration.get("angle_vertical")).doubleValue());
refMarker = ((List)calibration.get("reference_marker"));
if (refMarker.size()==4){
spinnerLeft.setValue(refMarker.get(0));
spinnerTop.setValue(refMarker.get(1));
spinnerRight.setValue(refMarker.get(2));
spinnerBottom.setValue(refMarker.get(3));
}
}
updateResults();
renderer.setMode(RendererMode.Fit);
calibrationOverlays = new Overlay[]{ovTop, ovBottom, ovLeft, ovRight};
for (Overlay ov : calibrationOverlays){
ov.setMovable(true);
}
renderer.addOverlays(calibrationOverlays);
try{
Rectangle r = new Rectangle();
ovLeft.update(new Point(Math.max(refMarker.get(0), 0), 0));
ovTop.update(new Point(0, Math.max(refMarker.get(1), 0)));
ovRight.update(new Point(Math.max(refMarker.get(2), 0), 0));
ovBottom.update(new Point(0, Math.max(refMarker.get(3),0)));
} catch (Exception ex){
SwingUtils.invokeDelayed(() -> {
Dimension size = renderer.getImageSize();
ovTop.update(new Point(0, size.height/8));
ovBottom.update(new Point(0, 7*size.height/8));
ovLeft.update(new Point(size.width/8, 0));
ovRight.update(new Point(7*size.width/8, 0));
}, 500);
}
renderer.addListener(new RendererListener(){
@Override
public void onMoveFinished(Renderer renderer, Overlay overlay) {
if (overlay==ovTop){
spinnerTop.setValue(ovTop.getPosition().y);
} else if (overlay==ovBottom){
spinnerBottom.setValue(ovBottom.getPosition().y);
} else if (overlay==ovLeft){
spinnerLeft.setValue(ovLeft.getPosition().x);
} else if (overlay==ovRight){
spinnerRight.setValue(ovRight.getPosition().x);
}
}
});
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
pack();
}
@Override
protected void onClosed() {
renderer.removeOverlays(calibrationOverlays);
calibrationOverlays = null;
server.close();
}
void updateResults(){
try{
int left = (Integer)spinnerLeft.getValue();
int right = (Integer)spinnerRight.getValue();
int top = (Integer)spinnerTop.getValue();
int bottom = (Integer)spinnerBottom.getValue();
double width = (Double)spinnerRefWidth.getValue();
double height = (Double)spinnerRefHeight.getValue();
double angleHor = (Double)spinnerAngleHor.getValue();
double angleVer = (Double)spinnerAngleVer.getValue();
double pixelHor = width * Math.cos(Math.toRadians(angleHor)) /Math.abs(right-left);
double pixelVer = height * Math.cos(Math.toRadians(angleVer)) /Math.abs(bottom-top);
textOriginX.setText(String.valueOf((left+right)/2));
textOriginY.setText(String.valueOf((top+bottom)/2));
textPixelSizeX.setText(String.valueOf(Convert.roundDouble(pixelHor, 2)));
textPixelSizeY.setText(String.valueOf(Convert.roundDouble(pixelVer, 2)));
ovLeft.update(new Point(Math.max(left, 0), 0));
ovTop.update(new Point(0, Math.max(top, 0)));
ovRight.update(new Point(Math.max(right, 0), 0));
ovBottom.update(new Point(0, Math.max(bottom,0)));
renderer.refresh();
} catch (Exception ex){
SwingUtils.showException(this, ex);
}
}
public static void main(String args[]) throws Exception {
//String cameraName = "SINEG01-DSCR190";
String cameraName = "SATSY02-DSCR220" ;
//java.awt.EventQueue.invokeLater(() -> {
Renderer renderer = new Renderer();
JDialog dlgRenderer = SwingUtils.showDialog(null, cameraName, new Dimension(600,400), renderer);
CameraCalibrationDialog dialog = new CameraCalibrationDialog(null, cameraName, renderer);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
dlgRenderer.setVisible(false);
System.exit(0);
}
});
SwingUtils.centerComponent(null, dialog);
dialog.setVisible(true);
// });
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
spinnerAngleHor = new javax.swing.JSpinner();
spinnerAngleVer = new javax.swing.JSpinner();
spinnerRefWidth = new javax.swing.JSpinner();
spinnerRefHeight = new javax.swing.JSpinner();
spinnerTop = new javax.swing.JSpinner();
spinnerBottom = new javax.swing.JSpinner();
spinnerLeft = new javax.swing.JSpinner();
spinnerRight = new javax.swing.JSpinner();
buttonFetch = new javax.swing.JButton();
ckCalibrationEnabled = new javax.swing.JCheckBox();
jPanel2 = new javax.swing.JPanel();
checkMirrorX = new javax.swing.JCheckBox();
checkMirrorY = new javax.swing.JCheckBox();
comboRotation = new javax.swing.JComboBox();
jLabel7 = new javax.swing.JLabel();
jPanel3 = new javax.swing.JPanel();
jLabel11 = new javax.swing.JLabel();
textOriginX = new javax.swing.JTextField();
jLabel12 = new javax.swing.JLabel();
textOriginY = new javax.swing.JTextField();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
textPixelSizeX = new javax.swing.JTextField();
textPixelSizeY = new javax.swing.JTextField();
buttonOk = new javax.swing.JButton();
buttonCancel = new javax.swing.JButton();
buttonApply = new javax.swing.JButton();
jLabel1.setText("Calibrate the camera moving the line overlays to the reference marks.");
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Calibration"));
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel4.setText("Reference marker height (um):");
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel5.setText("Horizontal camera angle (deg):");
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel6.setText("Vertical camera angle (deg):");
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel3.setText("Reference marker width (um):");
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel2.setText("Top (px):");
jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel8.setText("Botton (px):");
jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel9.setText("Left (px):");
jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel10.setText("Right (px):");
spinnerAngleHor.setModel(new javax.swing.SpinnerNumberModel(0.0d, -360.0d, 360.0d, 1.0d));
spinnerAngleHor.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
calibrationSpinnerChanged(evt);
}
});
spinnerAngleVer.setModel(new javax.swing.SpinnerNumberModel(0.0d, -360.0d, 360.0d, 1.0d));
spinnerAngleVer.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
calibrationSpinnerChanged(evt);
}
});
spinnerRefWidth.setModel(new javax.swing.SpinnerNumberModel(30000.0d, 1.0d, 500000.0d, 1.0d));
spinnerRefWidth.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
calibrationSpinnerChanged(evt);
}
});
spinnerRefHeight.setModel(new javax.swing.SpinnerNumberModel(30000.0d, 1.0d, 500000.0d, 1.0d));
spinnerRefHeight.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
calibrationSpinnerChanged(evt);
}
});
spinnerTop.setModel(new javax.swing.SpinnerNumberModel(0, -10000, 10000, 1));
spinnerTop.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
calibrationSpinnerChanged(evt);
}
});
spinnerBottom.setModel(new javax.swing.SpinnerNumberModel(0, -10000, 10000, 1));
spinnerBottom.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
calibrationSpinnerChanged(evt);
}
});
spinnerLeft.setModel(new javax.swing.SpinnerNumberModel(0, -10000, 10000, 1));
spinnerLeft.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
calibrationSpinnerChanged(evt);
}
});
spinnerRight.setModel(new javax.swing.SpinnerNumberModel(0, -10000, 10000, 1));
spinnerRight.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
calibrationSpinnerChanged(evt);
}
});
buttonFetch.setText("Fetch from Inventory");
buttonFetch.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonFetchActionPerformed(evt);
}
});
ckCalibrationEnabled.setText("Enabled");
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerTop, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerRefWidth, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerBottom, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerRefHeight, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jLabel10)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerRight, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerAngleVer, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jLabel9)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerLeft, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerAngleHor, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGap(9, 9, 9)
.addComponent(ckCalibrationEnabled)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonFetch)))
.addContainerGap())
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel10, jLabel2, jLabel8, jLabel9});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jLabel2)
.addComponent(spinnerRefWidth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerTop, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(jLabel8)
.addComponent(spinnerRefHeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerBottom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(jLabel9)
.addComponent(spinnerAngleHor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerLeft, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(jLabel10)
.addComponent(spinnerAngleVer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerRight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonFetch)
.addComponent(ckCalibrationEnabled))
.addContainerGap())
);
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Transformations"));
checkMirrorX.setText("Mirror X");
checkMirrorY.setText("Mirror Y");
comboRotation.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "270", "180", "90" }));
jLabel7.setText("Rotation: ");
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(checkMirrorX)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(comboRotation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(checkMirrorY)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(comboRotation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7))
.addComponent(checkMirrorX))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(checkMirrorY)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Results"));
jLabel11.setText("Origin X (px):");
textOriginX.setEditable(false);
textOriginX.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jLabel12.setText("Origin Y (px):");
textOriginY.setEditable(false);
textOriginY.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jLabel13.setText("Y pixel size (um/px):");
jLabel14.setText("X pixel size (um/px):");
textPixelSizeX.setEditable(false);
textPixelSizeX.setHorizontalAlignment(javax.swing.JTextField.CENTER);
textPixelSizeY.setEditable(false);
textPixelSizeY.setHorizontalAlignment(javax.swing.JTextField.CENTER);
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textOriginY, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textOriginX, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel13)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textPixelSizeY, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel14)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textPixelSizeX, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel11, jLabel12});
jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel13, jLabel14});
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel14)
.addComponent(textPixelSizeX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel13)
.addComponent(textPixelSizeY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11)
.addComponent(textOriginX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel12)
.addComponent(textOriginY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap())
);
buttonOk.setText("Ok");
buttonOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonOkActionPerformed(evt);
}
});
buttonCancel.setText("Cancel");
buttonCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonCancelActionPerformed(evt);
}
});
buttonApply.setText("Apply");
buttonApply.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonApplyActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(buttonCancel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(buttonApply)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(buttonOk)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonApply, buttonCancel, buttonOk});
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel3, 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.BASELINE)
.addComponent(buttonOk)
.addComponent(buttonCancel)
.addComponent(buttonApply))
.addContainerGap())
);
}// </editor-fold>//GEN-END:initComponents
private void buttonOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonOkActionPerformed
buttonApplyActionPerformed(evt);
accept();
}//GEN-LAST:event_buttonOkActionPerformed
private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
cancel();
}//GEN-LAST:event_buttonCancelActionPerformed
private void buttonFetchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonFetchActionPerformed
try{
//List<Double> calib = Inventory.getCalibFromInventory(null, cameraName);
List<Double> calib = (List<Double>) Class.forName("Inventory").
getMethod("getCalibFromInventory",
new Class[]{String.class,String.class}).
invoke(null, new Object[]{(String)null, cameraName});
spinnerRefWidth.setValue(calib.get(0)*1000.0);
spinnerRefHeight.setValue(calib.get(1)*1000.0);
spinnerAngleHor.setValue(calib.get(2).doubleValue());
spinnerAngleVer.setValue(calib.get(3).doubleValue());
} catch (Exception ex){
if (ex instanceof InvocationTargetException){
ex = (Exception) ((InvocationTargetException)ex).getCause();
}
SwingUtils.showException(this, ex);
}
}//GEN-LAST:event_buttonFetchActionPerformed
private void calibrationSpinnerChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_calibrationSpinnerChanged
updateResults();
}//GEN-LAST:event_calibrationSpinnerChanged
private void buttonApplyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonApplyActionPerformed
try {
int left = (Integer)spinnerLeft.getValue(); //left.getPosition().x
int right = (Integer)spinnerRight.getValue(); //right.getPosition().x
int top = (Integer)spinnerTop.getValue(); //top.getPosition().y
int bottom = (Integer)spinnerBottom.getValue(); //bottom.getPosition().y
double width = (Double)spinnerRefWidth.getValue();
double height = (Double)spinnerRefHeight.getValue();
double angleHor = (Double)spinnerAngleHor.getValue();
double angleVer = (Double)spinnerAngleVer.getValue();
int x1 = Math.min(left, right);
int x2 = Math.max(left, right);
int y1 = Math.min(top, bottom);
int y2 = Math.max(top, bottom);
System.out.println("Updating " + cameraName + " configuration");
HashMap calibration = null;
if (ckCalibrationEnabled.isSelected()){
calibration = new HashMap();
calibration.put("reference_marker", Arrays.asList(new Integer[]{x1, y1, x2, y2}));
calibration.put("reference_marker_width", width);
calibration.put("reference_marker_height", height);
calibration.put("angle_horizontal", angleHor);
calibration.put("angle_vertical", angleVer);
}
Map<String, Object> config = server.getConfig(cameraName);
config.put("camera_calibration", calibration);
config.put("mirror_x", checkMirrorX.isSelected());
config.put("mirror_y", checkMirrorY.isSelected());
config.put("rotate", comboRotation.getSelectedIndex());
server.setConfig(cameraName, config);
System.out.println("New config: " + config);
boolean reticle = renderer.getShowReticle();
if (reticle){
renderer.setShowReticle(false);
}
SwingUtils.showMessage(this, "Success", "Updated " + cameraName + " configuration");
if (reticle){
renderer.setShowReticle(true);
}
} catch (Exception ex) {
SwingUtils.showException(this, ex);
}
}//GEN-LAST:event_buttonApplyActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonApply;
private javax.swing.JButton buttonCancel;
private javax.swing.JButton buttonFetch;
private javax.swing.JButton buttonOk;
private javax.swing.JCheckBox checkMirrorX;
private javax.swing.JCheckBox checkMirrorY;
private javax.swing.JCheckBox ckCalibrationEnabled;
private javax.swing.JComboBox comboRotation;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JSpinner spinnerAngleHor;
private javax.swing.JSpinner spinnerAngleVer;
private javax.swing.JSpinner spinnerBottom;
private javax.swing.JSpinner spinnerLeft;
private javax.swing.JSpinner spinnerRefHeight;
private javax.swing.JSpinner spinnerRefWidth;
private javax.swing.JSpinner spinnerRight;
private javax.swing.JSpinner spinnerTop;
private javax.swing.JTextField textOriginX;
private javax.swing.JTextField textOriginY;
private javax.swing.JTextField textPixelSizeX;
private javax.swing.JTextField textPixelSizeY;
// End of variables declaration//GEN-END:variables
}

View File

@@ -1,524 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="2"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel1" max="32767" attributes="0"/>
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel2" alignment="0" max="32767" attributes="0"/>
<Component id="jPanel3" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="buttonOk" linkSize="2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="buttonCancel" linkSize="2" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel3" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonOk" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonCancel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="16" 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="Calibrate the camera moving the line overlays to the reference marks."/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel1">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Calibration"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel2" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerTop" min="-2" pref="80" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerRefWidth" min="-2" pref="80" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel8" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerBottom" min="-2" pref="80" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerRefHeight" min="-2" pref="80" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel10" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerRight" min="-2" pref="80" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel6" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerAngleVer" min="-2" pref="80" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel9" linkSize="1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerLeft" min="-2" pref="80" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spinnerAngleHor" min="-2" pref="80" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="buttonFetch" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerRefWidth" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerTop" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerRefHeight" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerBottom" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel9" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerAngleHor" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerLeft" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel10" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerAngleVer" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spinnerRight" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="12" max="32767" attributes="0"/>
<Component id="buttonFetch" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Reference marker height (um):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Horizontal camera angle (deg):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Vertical camera angle (deg):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Reference marker width (um):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Top (px):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel8">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Botton (px):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel9">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Left (px):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel10">
<Properties>
<Property name="horizontalAlignment" type="int" value="11"/>
<Property name="text" type="java.lang.String" value="Right (px):"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerAngleHor">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" maximum="360.0" minimum="-360.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="calibrationSpinnerChanged"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerAngleVer">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0.0" maximum="360.0" minimum="-360.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="calibrationSpinnerChanged"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerRefWidth">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="30000.0" maximum="500000.0" minimum="1.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="calibrationSpinnerChanged"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerRefHeight">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="30000.0" maximum="500000.0" minimum="1.0" numberType="java.lang.Double" stepSize="1.0" type="number"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="calibrationSpinnerChanged"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerTop">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" maximum="10000" minimum="-10000" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="calibrationSpinnerChanged"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerBottom">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" maximum="10000" minimum="-10000" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="calibrationSpinnerChanged"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerLeft">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" maximum="10000" minimum="-10000" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="calibrationSpinnerChanged"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="spinnerRight">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" maximum="10000" minimum="-10000" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="calibrationSpinnerChanged"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonFetch">
<Properties>
<Property name="text" type="java.lang.String" value="Fetch from Inventory"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonFetchActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel2">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Transformations"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="checkMirrorX" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="jLabel7" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="comboRotation" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="checkMirrorY" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="0" groupAlignment="3" attributes="0">
<Component id="comboRotation" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel7" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="checkMirrorX" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="checkMirrorY" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JCheckBox" name="checkMirrorX">
<Properties>
<Property name="text" type="java.lang.String" value="Mirror X"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkMirrorY">
<Properties>
<Property name="text" type="java.lang.String" value="Mirror Y"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboRotation">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="0"/>
<StringItem index="1" value="270"/>
<StringItem index="2" value="180"/>
<StringItem index="3" value="90"/>
</StringArray>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel7">
<Properties>
<Property name="text" type="java.lang.String" value="Rotation: "/>
</Properties>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="jPanel3">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
<TitledBorder title="Results"/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="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="1" attributes="0">
<Group type="102" attributes="0">
<Component id="jLabel12" linkSize="3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="textOriginY" min="-2" pref="100" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel11" linkSize="3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="textOriginX" min="-2" pref="100" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel13" linkSize="4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="textPixelSizeY" min="-2" pref="100" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="jLabel14" linkSize="4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="textPixelSizeX" min="-2" pref="100" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel14" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textPixelSizeX" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel13" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textPixelSizeY" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel11" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textOriginX" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel12" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textOriginY" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel11">
<Properties>
<Property name="text" type="java.lang.String" value="Origin X (px):"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textOriginX">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel12">
<Properties>
<Property name="text" type="java.lang.String" value="Origin Y (px):"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textOriginY">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel13">
<Properties>
<Property name="text" type="java.lang.String" value="Y pixel size (um/px):"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel14">
<Properties>
<Property name="text" type="java.lang.String" value="X pixel size (um/px):"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textPixelSizeX">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textPixelSizeY">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="buttonOk">
<Properties>
<Property name="text" type="java.lang.String" value="Ok"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonOkActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonCancel">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonCancelActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@@ -1,696 +0,0 @@
import ch.psi.utils.swing.StandardDialog;
import ch.psi.utils.swing.SwingUtils;
import ch.psi.pshell.bs.Camtool;
import ch.psi.pshell.imaging.Overlay;
import ch.psi.pshell.imaging.Overlays;
import ch.psi.pshell.imaging.Pen;
import ch.psi.pshell.imaging.Renderer;
import ch.psi.pshell.imaging.RendererListener;
import ch.psi.pshell.imaging.RendererMode;
import ch.psi.utils.Convert;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Point;
import java.awt.Rectangle;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.swing.JDialog;
/*
*/
/**
*
*/
public class CameraConfigDialog extends StandardDialog {
Camtool camera;
Renderer renderer;
String cameraName;
Overlay[] calibrationOverlays;
Pen pen = new Pen(new Color(128, 0, 128), 1, Pen.LineStyle.solid);
Overlays.Crosshairs ovTop = new Overlays.Crosshairs(pen, new Dimension(-1, 1));
Overlays.Crosshairs ovBottom = new Overlays.Crosshairs(pen, new Dimension(-1, 1));
Overlays.Crosshairs ovLeft = new Overlays.Crosshairs(pen, new Dimension(1, -1));
Overlays.Crosshairs ovRight = new Overlays.Crosshairs(pen, new Dimension(1, -1));
/**
*
* {
* name=SINEG01-DSCR350,
* prefix=SINEG01-DSCR350,
* mirror_x=true,
* mirror_y=true,
* rotate=0,
* calibration={
* horizontal_camera_angle=0,
* vertical_camera_angle=0
* reference_marker_width=16000.0,
* reference_marker_height=16000.0,
* reference_marker=[120, 245, 1251, 1504],
* },
* }
*/
public CameraConfigDialog(Frame parent, Camtool camera, Renderer renderer) throws IOException {
super(parent, camera.getCurrentCamera(), false);
initComponents();
this.camera = camera;
this.cameraName = camera.getCurrentCamera();
this.renderer = renderer;
Map<String, Object> config = camera.getConfig(cameraName);
Map<String, Object> calibration = (Map<String, Object>) config.get("calibration");
List<Integer> refMarker = null;
System.out.println("Current config: " + config);
checkMirrorX.setSelected((config.get("mirror_x") ==null) ? Boolean.FALSE: (Boolean)config.get("mirror_x"));
checkMirrorY.setSelected((config.get("mirror_y") ==null) ? Boolean.FALSE: (Boolean)config.get("mirror_y"));
comboRotation.setSelectedIndex((config.get("rotate") == null) ? 0 :(Integer) (config.get("rotate")));
if (calibration!=null){
spinnerRefWidth.setValue(((Number)calibration.get("reference_marker_width")).doubleValue());
spinnerRefHeight.setValue(((Number)calibration.get("reference_marker_height")).doubleValue());
spinnerAngleHor.setValue(((Number)calibration.get("horizontal_camera_angle")).doubleValue());
spinnerAngleVer.setValue(((Number)calibration.get("vertical_camera_angle")).doubleValue());
refMarker = ((List)calibration.get("reference_marker"));
if (refMarker.size()==4){
spinnerLeft.setValue(refMarker.get(0));
spinnerTop.setValue(refMarker.get(1));
spinnerRight.setValue(refMarker.get(2));
spinnerBottom.setValue(refMarker.get(3));
}
}
updateResults();
camera.resetRoi();
renderer.setMode(RendererMode.Fit);
calibrationOverlays = new Overlay[]{ovTop, ovBottom, ovLeft, ovRight};
for (Overlay ov : calibrationOverlays){
ov.setMovable(true);
}
renderer.addOverlays(calibrationOverlays);
try{
Rectangle r = new Rectangle();
ovLeft.update(new Point(Math.max(refMarker.get(0), 0), 0));
ovTop.update(new Point(0, Math.max(refMarker.get(1), 0)));
ovRight.update(new Point(Math.max(refMarker.get(2), 0), 0));
ovBottom.update(new Point(0, Math.max(refMarker.get(3),0)));
} catch (Exception ex){
SwingUtils.invokeDelayed(() -> {
Dimension size = renderer.getImageSize();
ovTop.update(new Point(0, size.height/8));
ovBottom.update(new Point(0, 7*size.height/8));
ovLeft.update(new Point(size.width/8, 0));
ovRight.update(new Point(7*size.width/8, 0));
}, 500);
}
renderer.addListener(new RendererListener(){
@Override
public void onMoveFinished(Renderer renderer, Overlay overlay) {
if (overlay==ovTop){
spinnerTop.setValue(ovTop.getPosition().y);
} else if (overlay==ovBottom){
spinnerBottom.setValue(ovBottom.getPosition().y);
} else if (overlay==ovLeft){
spinnerLeft.setValue(ovLeft.getPosition().x);
} else if (overlay==ovRight){
spinnerRight.setValue(ovRight.getPosition().x);
}
}
});
setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
pack();
}
@Override
protected void onClosed() {
renderer.removeOverlays(calibrationOverlays);
calibrationOverlays = null;
}
void updateResults(){
try{
int left = (Integer)spinnerLeft.getValue();
int right = (Integer)spinnerRight.getValue();
int top = (Integer)spinnerTop.getValue();
int bottom = (Integer)spinnerBottom.getValue();
double width = (Double)spinnerRefWidth.getValue();
double height = (Double)spinnerRefHeight.getValue();
double angleHor = (Double)spinnerAngleHor.getValue();
double angleVer = (Double)spinnerAngleVer.getValue();
double pixelHor = width * Math.cos(Math.toRadians(angleHor)) /Math.abs(right-left);
double pixelVer = height * Math.cos(Math.toRadians(angleVer)) /Math.abs(bottom-top);
textOriginX.setText(String.valueOf((left+right)/2));
textOriginY.setText(String.valueOf((top+bottom)/2));
textPixelSizeX.setText(String.valueOf(Convert.roundDouble(pixelHor, 2)));
textPixelSizeY.setText(String.valueOf(Convert.roundDouble(pixelVer, 2)));
ovLeft.update(new Point(Math.max(left, 0), 0));
ovTop.update(new Point(0, Math.max(top, 0)));
ovRight.update(new Point(Math.max(right, 0), 0));
ovBottom.update(new Point(0, Math.max(bottom,0)));
renderer.refresh();
} catch (Exception ex){
SwingUtils.showException(this, ex);
}
}
public static void main(String args[]) throws Exception {
//String cameraName = "SINEG01-DSCR190";
String cameraName = "SATSY02-DSCR220" ;
Camtool camtool = new Camtool("Camera", "localhost:10000");
camtool.start(cameraName);
//java.awt.EventQueue.invokeLater(() -> {
Renderer renderer = new Renderer();
camtool.addListener(renderer);
JDialog dlgRenderer = SwingUtils.showDialog(null, cameraName, new Dimension(600,400), renderer);
CameraConfigDialog dialog = new CameraConfigDialog(null, camtool, renderer);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
dlgRenderer.setVisible(false);
camtool.close();
System.exit(0);
}
});
SwingUtils.centerComponent(null, dialog);
dialog.setVisible(true);
// });
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jPanel1 = new javax.swing.JPanel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
jLabel9 = new javax.swing.JLabel();
jLabel10 = new javax.swing.JLabel();
spinnerAngleHor = new javax.swing.JSpinner();
spinnerAngleVer = new javax.swing.JSpinner();
spinnerRefWidth = new javax.swing.JSpinner();
spinnerRefHeight = new javax.swing.JSpinner();
spinnerTop = new javax.swing.JSpinner();
spinnerBottom = new javax.swing.JSpinner();
spinnerLeft = new javax.swing.JSpinner();
spinnerRight = new javax.swing.JSpinner();
buttonFetch = new javax.swing.JButton();
jPanel2 = new javax.swing.JPanel();
checkMirrorX = new javax.swing.JCheckBox();
checkMirrorY = new javax.swing.JCheckBox();
comboRotation = new javax.swing.JComboBox();
jLabel7 = new javax.swing.JLabel();
jPanel3 = new javax.swing.JPanel();
jLabel11 = new javax.swing.JLabel();
textOriginX = new javax.swing.JTextField();
jLabel12 = new javax.swing.JLabel();
textOriginY = new javax.swing.JTextField();
jLabel13 = new javax.swing.JLabel();
jLabel14 = new javax.swing.JLabel();
textPixelSizeX = new javax.swing.JTextField();
textPixelSizeY = new javax.swing.JTextField();
buttonOk = new javax.swing.JButton();
buttonCancel = new javax.swing.JButton();
jLabel1.setText("Calibrate the camera moving the line overlays to the reference marks.");
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Calibration"));
jLabel4.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel4.setText("Reference marker height (um):");
jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel5.setText("Horizontal camera angle (deg):");
jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel6.setText("Vertical camera angle (deg):");
jLabel3.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel3.setText("Reference marker width (um):");
jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel2.setText("Top (px):");
jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel8.setText("Botton (px):");
jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel9.setText("Left (px):");
jLabel10.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
jLabel10.setText("Right (px):");
spinnerAngleHor.setModel(new javax.swing.SpinnerNumberModel(0.0d, -360.0d, 360.0d, 1.0d));
spinnerAngleHor.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
calibrationSpinnerChanged(evt);
}
});
spinnerAngleVer.setModel(new javax.swing.SpinnerNumberModel(0.0d, -360.0d, 360.0d, 1.0d));
spinnerAngleVer.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
calibrationSpinnerChanged(evt);
}
});
spinnerRefWidth.setModel(new javax.swing.SpinnerNumberModel(30000.0d, 1.0d, 500000.0d, 1.0d));
spinnerRefWidth.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
calibrationSpinnerChanged(evt);
}
});
spinnerRefHeight.setModel(new javax.swing.SpinnerNumberModel(30000.0d, 1.0d, 500000.0d, 1.0d));
spinnerRefHeight.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
calibrationSpinnerChanged(evt);
}
});
spinnerTop.setModel(new javax.swing.SpinnerNumberModel(0, -10000, 10000, 1));
spinnerTop.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
calibrationSpinnerChanged(evt);
}
});
spinnerBottom.setModel(new javax.swing.SpinnerNumberModel(0, -10000, 10000, 1));
spinnerBottom.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
calibrationSpinnerChanged(evt);
}
});
spinnerLeft.setModel(new javax.swing.SpinnerNumberModel(0, -10000, 10000, 1));
spinnerLeft.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
calibrationSpinnerChanged(evt);
}
});
spinnerRight.setModel(new javax.swing.SpinnerNumberModel(0, -10000, 10000, 1));
spinnerRight.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
calibrationSpinnerChanged(evt);
}
});
buttonFetch.setText("Fetch from Inventory");
buttonFetch.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonFetchActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerTop, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerRefWidth, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jLabel8)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerBottom, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerRefHeight, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jLabel10)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerRight, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerAngleVer, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jLabel9)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerLeft, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spinnerAngleHor, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(buttonFetch)))
.addContainerGap())
);
jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel10, jLabel2, jLabel8, jLabel9});
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jLabel2)
.addComponent(spinnerRefWidth, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerTop, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(jLabel8)
.addComponent(spinnerRefHeight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerBottom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel5)
.addComponent(jLabel9)
.addComponent(spinnerAngleHor, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerLeft, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel6)
.addComponent(jLabel10)
.addComponent(spinnerAngleVer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerRight, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 12, Short.MAX_VALUE)
.addComponent(buttonFetch)
.addContainerGap())
);
jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Transformations"));
checkMirrorX.setText("Mirror X");
checkMirrorY.setText("Mirror Y");
comboRotation.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "270", "180", "90" }));
jLabel7.setText("Rotation: ");
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(checkMirrorX)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel7)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(comboRotation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel2Layout.createSequentialGroup()
.addComponent(checkMirrorY)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(comboRotation, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel7))
.addComponent(checkMirrorX))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(checkMirrorY)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Results"));
jLabel11.setText("Origin X (px):");
textOriginX.setEditable(false);
textOriginX.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jLabel12.setText("Origin Y (px):");
textOriginY.setEditable(false);
textOriginY.setHorizontalAlignment(javax.swing.JTextField.CENTER);
jLabel13.setText("Y pixel size (um/px):");
jLabel14.setText("X pixel size (um/px):");
textPixelSizeX.setEditable(false);
textPixelSizeX.setHorizontalAlignment(javax.swing.JTextField.CENTER);
textPixelSizeY.setEditable(false);
textPixelSizeY.setHorizontalAlignment(javax.swing.JTextField.CENTER);
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(21, 21, 21)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel12)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textOriginY, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textOriginX, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel13)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textPixelSizeY, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(jLabel14)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textPixelSizeX, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel11, jLabel12});
jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {jLabel13, jLabel14});
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel14)
.addComponent(textPixelSizeX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel13)
.addComponent(textPixelSizeY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel3Layout.createSequentialGroup()
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11)
.addComponent(textOriginX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel12)
.addComponent(textOriginY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addContainerGap())
);
buttonOk.setText("Ok");
buttonOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonOkActionPerformed(evt);
}
});
buttonCancel.setText("Cancel");
buttonCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonCancelActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(buttonOk)
.addGap(18, 18, 18)
.addComponent(buttonCancel)
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap())
);
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonCancel, buttonOk});
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel3, 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.BASELINE)
.addComponent(buttonOk)
.addComponent(buttonCancel))
.addContainerGap(16, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void buttonOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonOkActionPerformed
try {
//renderer.removeOverlays(calibrationOverlays);
//calibrationOverlays = null;
//calibrationDialolg = null;
int left = (Integer)spinnerLeft.getValue(); //left.getPosition().x
int right = (Integer)spinnerRight.getValue(); //right.getPosition().x
int top = (Integer)spinnerTop.getValue(); //top.getPosition().y
int bottom = (Integer)spinnerBottom.getValue(); //bottom.getPosition().y
double width = (Double)spinnerRefWidth.getValue();
double height = (Double)spinnerRefHeight.getValue();
double angleHor = (Double)spinnerAngleHor.getValue();
double angleVer = (Double)spinnerAngleVer.getValue();
int x1 = Math.min(left, right);
int x2 = Math.max(left, right);
int y1 = Math.min(top, bottom);
int y2 = Math.max(top, bottom);
if ((x1!=-1) && (x2!=-1) && (y1!=-1) && (y2!=-1)){
System.out.println("Updating " + cameraName + " configuration");
HashMap calibration = new HashMap();
calibration.put("reference_marker", Arrays.asList(new Integer[]{x1, y1, x2, y2}));
calibration.put("reference_marker_width", width);
calibration.put("reference_marker_height", height);
calibration.put("horizontal_camera_angle", angleHor);
calibration.put("vertical_camera_angle", angleVer);
//((Camtool) camera).setCalibration(cameraName, calibration);
HashMap config = new HashMap();
config.put("calibration", calibration);
config.put("mirror_x", checkMirrorX.isSelected());
config.put("mirror_y", checkMirrorY.isSelected());
config.put("rotate", comboRotation.getSelectedIndex());
((Camtool) camera).setConfig(cameraName, config);
System.out.println("New config: " + config);
SwingUtils.showMessage(this, "Success", "Updated " + cameraName + " configuration");
}
} catch (Exception ex) {
SwingUtils.showException(this, ex);
}
accept();
}//GEN-LAST:event_buttonOkActionPerformed
private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCancelActionPerformed
cancel();
}//GEN-LAST:event_buttonCancelActionPerformed
private void buttonFetchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonFetchActionPerformed
try{
//List<Double> calib = Inventory.getCalibFromInventory(null, cameraName);
List<Double> calib = (List<Double>) Class.forName("Inventory").
getMethod("getCalibFromInventory",
new Class[]{String.class,String.class}).
invoke(null, new Object[]{(String)null, cameraName});
spinnerRefWidth.setValue(calib.get(0)*1000.0);
spinnerRefHeight.setValue(calib.get(1)*1000.0);
spinnerAngleHor.setValue(calib.get(2).intValue());
spinnerAngleVer.setValue(calib.get(3).intValue());
} catch (Exception ex){
if (ex instanceof InvocationTargetException){
ex = (Exception) ((InvocationTargetException)ex).getCause();
}
SwingUtils.showException(this, ex);
}
}//GEN-LAST:event_buttonFetchActionPerformed
private void calibrationSpinnerChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_calibrationSpinnerChanged
updateResults();
}//GEN-LAST:event_calibrationSpinnerChanged
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonCancel;
private javax.swing.JButton buttonFetch;
private javax.swing.JButton buttonOk;
private javax.swing.JCheckBox checkMirrorX;
private javax.swing.JCheckBox checkMirrorY;
private javax.swing.JComboBox comboRotation;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel13;
private javax.swing.JLabel jLabel14;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JPanel jPanel3;
private javax.swing.JSpinner spinnerAngleHor;
private javax.swing.JSpinner spinnerAngleVer;
private javax.swing.JSpinner spinnerBottom;
private javax.swing.JSpinner spinnerLeft;
private javax.swing.JSpinner spinnerRefHeight;
private javax.swing.JSpinner spinnerRefWidth;
private javax.swing.JSpinner spinnerRight;
private javax.swing.JSpinner spinnerTop;
private javax.swing.JTextField textOriginX;
private javax.swing.JTextField textOriginY;
private javax.swing.JTextField textPixelSizeX;
private javax.swing.JTextField textPixelSizeY;
// End of variables declaration//GEN-END:variables
}

View File

@@ -1,189 +0,0 @@
<?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 max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="renderer" alignment="1" pref="650" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Component id="checkCamtool" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="comboCameras" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="buttonConfig" linkSize="3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonSetup" linkSize="3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="textState" min="-2" pref="120" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="buttonPause" linkSize="5" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonMarker" linkSize="5" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonFit" linkSize="5" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonReticle" linkSize="5" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="buttonGrabBackground" linkSize="6" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="buttonSave" linkSize="6" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="comboCameras" linkSize="2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="textState" linkSize="2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonConfig" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonSetup" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="checkCamtool" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="renderer" pref="307" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="buttonPause" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonFit" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonMarker" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonSave" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonReticle" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="buttonGrabBackground" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="ch.psi.pshell.imaging.Renderer" name="renderer">
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Camera:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="comboCameras">
<Properties>
<Property name="maximumRowCount" type="int" value="30"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="comboCamerasActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="State:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="textState">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="horizontalAlignment" type="int" value="0"/>
<Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="0" type="rgb"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="buttonConfig">
<Properties>
<Property name="text" type="java.lang.String" value="Config"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonConfigActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonSetup">
<Properties>
<Property name="text" type="java.lang.String" value="Setup"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonSetupActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JCheckBox" name="checkCamtool">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Camtool"/>
</Properties>
</Component>
<Component class="javax.swing.JToggleButton" name="buttonFit">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Fit"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonFitActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JToggleButton" name="buttonPause">
<Properties>
<Property name="text" type="java.lang.String" value="Pause"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonPauseActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JToggleButton" name="buttonMarker">
<Properties>
<Property name="text" type="java.lang.String" value="Marker"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonMarkerActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JToggleButton" name="buttonSave">
<Properties>
<Property name="text" type="java.lang.String" value="Save Snapshot"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonSaveActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JToggleButton" name="buttonReticle">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Reticle"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonReticleActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="buttonGrabBackground">
<Properties>
<Property name="text" type="java.lang.String" value="Grab Background"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonGrabBackgroundActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Form>

View File

@@ -1,847 +0,0 @@
/*
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
*/
import ch.psi.pshell.core.Context;
import java.io.File;
import java.io.IOException;
import java.nio.file.Paths;
import javax.swing.DefaultComboBoxModel;
import ch.psi.pshell.ui.Panel;
import ch.psi.pshell.imaging.ImageListener;
import ch.psi.utils.State;
import ch.psi.utils.IO;
import ch.psi.utils.swing.SwingUtils;
import ch.psi.utils.swing.TextEditor;
import ch.psi.pshell.epics.PsiCamera;
import ch.psi.pshell.epics.Camtool;
import ch.psi.pshell.core.JsonSerializer;
import ch.psi.pshell.device.Device;
import ch.psi.pshell.epics.ArraySource;
import ch.psi.pshell.epics.ChannelDouble;
import ch.psi.pshell.epics.ChannelDoubleArray;
import ch.psi.pshell.epics.ChannelInteger;
import ch.psi.pshell.epics.ChannelIntegerArray;
import ch.psi.pshell.ui.App;
import ch.psi.pshell.imaging.Data;
import ch.psi.pshell.imaging.Overlay;
import ch.psi.pshell.imaging.Overlays;
import ch.psi.pshell.imaging.Overlays.Text;
import ch.psi.pshell.imaging.Pen;
import ch.psi.pshell.imaging.Renderer.Profile;
import ch.psi.pshell.imaging.Source;
import ch.psi.pshell.imaging.Utils;
import ch.psi.pshell.scripting.InterpreterResult;
import ch.psi.pshell.scripting.ScriptManager;
import ch.psi.utils.Arr;
import ch.psi.utils.ArrayProperties;
import ch.psi.utils.Convert;
import ch.psi.utils.Str;
import ch.psi.utils.swing.Editor.EditorDialog;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import java.awt.image.BufferedImage;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.apache.commons.math3.analysis.function.Gaussian;
import org.apache.commons.math3.fitting.GaussianCurveFitter;
import org.apache.commons.math3.fitting.WeightedObservedPoint;
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
/**
*
*/
public class Cameras extends Panel {
public Cameras() {
initComponents();
renderer.setPersistenceFile(Paths.get(getContext().getSetup().getContextPath(), "Renderer_Cameras.bin"));
setPersistedComponents(new Component[]{checkCamtool});
comboCameras.setEnabled(false);
if (App.hasArgument("poll")) {
try{
polling = Integer.valueOf(App.getArgumentValue("poll"));
} catch (Exception ex){
ex.printStackTrace();
}
}
if (App.hasArgument("zoom")) {
try{
renderer.setDefaultZoom(Double.valueOf(App.getArgumentValue("zoom")));
renderer.resetZoom();
} catch (Exception ex){
ex.printStackTrace();
}
}
}
@Override
public void onStart() {
super.onStart();
if (App.hasArgument("ct")) {
checkCamtool.setSelected(!App.getArgumentValue("ct").equals("0") && !App.getArgumentValue("ct").equalsIgnoreCase("false"));
}
}
final String configFolder = "/afs/psi.ch/intranet/SF/Applications/config/camtool";
File[] cameraConfigFiles = new File[0];
ArraySource camera;
String cameraName;
String cameraConfigJson;
CameraConfig config;
int polling = 1000;
Overlay marker = null;
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
comboCameras.setEnabled(false);
if (App.hasArgument("s")){
renderer.setDevice((Source)getDevice("image"));
renderer.setAutoScroll(true);
((Source)getDevice("image")).addListener(new ImageListener() {
@Override
public void onImage(Object o, BufferedImage bi, Data data) {
if (bi == null) {
fitOv = null;
} else {
Overlay[] profile = renderer.getProfileOverlays();
profile = ((profile != null) && (profile.length==4)) ? getFitOverlays(data) : null;
renderer.updateOverlays(profile, fitOv);
fitOv = profile;
}
}
@Override
public void onError(Object o, Exception excptn) {
}
}
);
} else {
cameraConfigFiles = IO.listFiles(configFolder, new String[]{"json"});
Arrays.sort(cameraConfigFiles, (a, b) -> a.compareTo(b));
DefaultComboBoxModel model = new DefaultComboBoxModel();
for (File file : cameraConfigFiles) {
String prefix = IO.getPrefix(file);
if (!prefix.startsWith("#")) {
model.addElement(prefix);
}
}
comboCameras.setModel(model);
comboCameras.setEnabled(true);
comboCameras.setSelectedItem(-1);
if (model.getSize() > 0) {
try {
//setCamera((String)comboCameras.getSelectedItem());
if (App.hasArgument("cam")) {
comboCameras.setSelectedItem(App.getArgumentValue("cam"));
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
startTimer(1000);
}
@Override
public void onStateChange(State state, State former) {
}
@Override
public void onExecutedFile(String fileName, Object result) {
}
//Callback to perform update - in event thread
@Override
protected void doUpdate() {
}
public static class CameraConfig {
public HashMap kwargs;
public ArrayList args;
public ArrayList links;
public String type;
public HashMap<String, Object> state;
public CameraConfig image_source;
public HashMap<String, CameraConfig> subcomponents;
public ArrayList<Integer> getCalibration() {
return (ArrayList<Integer>) state.get("calibration");
}
public double getCalOffsetX(){
ArrayList<Integer> calibration = getCalibration();
double ret = - (calibration.get(0) + calibration.get(2))/2;
return ret;
}
public double getCalOffsetY(){
ArrayList<Integer> calibration = getCalibration();
double ret = - (calibration.get(1) + calibration.get(3))/2;
return ret;
}
public double getScaleX(){
ArrayList<Integer> calibration = getCalibration();
double width = Math.abs( calibration.get(2) - calibration.get(0));
return getCalibrationWidth()/width;
//return getCalibrationWidth()/1000;
}
public double getScaleY(){
ArrayList<Integer> calibration = getCalibration();
double height = Math.abs( calibration.get(3) - calibration.get(1));
return getCalibrationHeight()/height;
}
public Double getCalibrationHeight() {
return (Double) state.get("calibration_height");
}
public Double getCalibrationWidth() {
return (Double) state.get("calibration_width");
}
public Double getCalibrationHorizontalAngle() {
return (Double) state.get("calibration_horizontal_angle");
}
public Double getCalibrationVerticalAngle() {
return (Double) state.get("calibration_vertical_angle");
}
public Boolean getMirrorX() {
return (Boolean) state.get("mirror_x");
}
public Boolean getMirrorY() {
return (Boolean) state.get("mirror_y");
}
public Integer getRotate() {
return (Integer) state.get("rotate");
}
public ArrayList<Integer> getOrigin() {
return (ArrayList<Integer>) state.get("origin");
}
public ArrayList<Integer> getRoi() {
return (ArrayList<Integer>) state.get("roi");
}
public Boolean getRoiEnable() {
if ((state.get("roi_enable") == null) || (state.get("roi") == null)) {
return false;
}
return (Boolean) state.get("roi_enable");
}
public ArrayList<Double> getUnitSize() {
return (ArrayList<Double>) state.get("unit_size");
}
public Integer getRun() {
return (Integer) state.get("run");
}
}
Overlay[] fitOv;
void setCamera(String cameraName) throws IOException, InterruptedException {
System.out.println("Setting camera: " + cameraName);
if (camera != null) {
camera.close();
camera = null;
renderer.setDevice(null);
renderer.setShowReticle(false);
renderer.removeOverlays(fitOv);
renderer.clear();
renderer.resetZoom();
}
try {
Path configFile = Paths.get(configFolder, cameraName + ".json");
cameraConfigJson = new String(Files.readAllBytes(configFile));
this.cameraName = cameraName;
//SwingUtils.showMessage(null, "", json);
try {
if (checkCamtool.isSelected()) {
camera = new Camtool("CurrentCamera", cameraName, false);
camera.getConfig().flipHorizontally = false;
camera.getConfig().flipVertically = false;
camera.getConfig().rotation = 0.0;
camera.getConfig().roiX = 0;
camera.getConfig().roiY = 0;
camera.getConfig().roiWidth = -1;
camera.getConfig().roiHeight = -1;
} else {
camera = new PsiCamera("CurrentCamera", cameraName);
config = (CameraConfig) JsonSerializer.decode(cameraConfigJson, CameraConfig.class);
camera.getConfig().flipHorizontally = config.getMirrorX();
camera.getConfig().flipVertically = config.getMirrorY();
camera.getConfig().rotation = config.getRotate();
camera.getConfig().rotationCrop = true;
camera.getConfig().roiX = config.getRoiEnable() ? config.getRoi().get(0) : 0;
camera.getConfig().roiY = config.getRoiEnable() ? config.getRoi().get(1) : 0;
camera.getConfig().roiWidth = config.getRoiEnable() ? config.getRoi().get(2) : -1;
camera.getConfig().roiHeight = config.getRoiEnable() ? config.getRoi().get(3) : -1;
try{
camera.getConfig().spatialCalOffsetX = config.getCalOffsetX();
camera.getConfig().spatialCalOffsetY = config.getCalOffsetY();
camera.getConfig().spatialCalScaleX = config.getScaleX();
camera.getConfig().spatialCalScaleY = config.getScaleY();
} catch (Exception ex){
camera.getConfig().spatialCalOffsetX = Double.NaN;
camera.getConfig().spatialCalOffsetY = Double.NaN;
camera.getConfig().spatialCalScaleX = Double.NaN;
camera.getConfig().spatialCalScaleY = Double.NaN;
}
}
} catch (Exception ex) {
config = null;
showException(ex);
}
camera.initialize();
if (camera instanceof Camtool){
try{
camera.getConfig().spatialCalOffsetX = ((Camtool)camera).calOffX.read();
camera.getConfig().spatialCalOffsetY = ((Camtool)camera).calOffY.read();
camera.getConfig().spatialCalScaleX = ((Camtool)camera).calScaleX.read();
camera.getConfig().spatialCalScaleY = ((Camtool)camera).calScaleY.read();
} catch (Exception ex){
ex.printStackTrace();
camera.getConfig().spatialCalOffsetX = 0.0;
camera.getConfig().spatialCalOffsetY = 0.0;
camera.getConfig().spatialCalScaleX = 1.0;
camera.getConfig().spatialCalScaleY = 1.0;
}
/*
double[] origin = ((Camtool)camera).origin.read();
if (origin.length>=2){
camera.getConfig().spatialCalOffsetX = origin[0];
camera.getConfig().spatialCalOffsetY = origin[1];
}
*/
}
buttonReticle.setEnabled(camera.getConfig().isCalibrated());
buttonGrabBackground.setEnabled(camera instanceof Camtool);
camera.getConfig().save();
if (polling<=0){
camera.setMonitored(true);
} else {
camera.setPolling(-polling);
}
renderer.setDevice(camera);
renderer.setAutoScroll(true);
renderer.setMarker(marker);
camera.addListener(new ImageListener() {
@Override
public void onImage(Object o, BufferedImage bi, Data data) {
if (bi == null) {
renderer.removeOverlays(fitOv);
fitOv = null;
} else {
//System.out.println(bi.getWidth() + " - " + bi.getHeight());
if (!renderer.isPaused() && buttonFit.isSelected()){
Overlay[] profile = renderer.getProfileOverlays();
profile = ((profile != null) && (profile.length==4)) ? getFitOverlays(data) : null;
renderer.updateOverlays(profile, fitOv);
fitOv = profile;
}
}
}
@Override
public void onError(Object o, Exception excptn) {
}
});
} catch (Exception ex) {
if (renderer.getDevice()==null){
renderer.setZoom(1.0);
renderer.addOverlay(new Text(renderer.getPenErrorText(), ex.toString(), new Font("Verdana", Font.PLAIN, 12), new Point(20, 20)));
}
} finally {
checkReticle();
onTimer();
}
}
void checkReticle(){
if ((renderer.getDevice()!=null) && (camera!=null) && (camera.getConfig().isCalibrated()) && buttonReticle.isSelected()){
renderer.setCalibration(camera.getCalibration());
renderer.configureReticle(new Dimension(800,800), 200);
renderer.setShowReticle(true);
} else {
renderer.setShowReticle(false);
}
renderer.refresh();
}
@Override
protected void onTimer() {
textState.setText((camera == null) ? "" : camera.getState().toString());
buttonConfig.setEnabled(camera != null);
if (App.hasArgument("s")){
try {
((Source)getDevice("image")).initialize();
} catch (IOException ex) {
Logger.getLogger(Cameras.class.getName()).log(Level.SEVERE, null, ex);
} catch (InterruptedException ex) {
Logger.getLogger(Cameras.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
Pen fitPen = new Pen(new Color(192, 105, 0), 1);
Pen crossPen = new Pen(new Color(192, 105, 0), 1);
Overlay[] getFitOverlays(Data data) {
Overlays.Polyline hpoly = null;
Overlays.Polyline vpoly = null;
Double xMean = null;
Double xSigma = null;
Double yMean = null;
Double ySigma = null;
if (data != null) {
//img = Utils.grayscale(img);
int profileSize = Math.min(data.getWidth(), data.getHeight())/4;
try {
double[] sum = (double[]) Convert.toDouble(data.integrateVertically(true));
int[] x = Arr.indexesInt(sum.length);
DescriptiveStatistics stats = new DescriptiveStatistics(sum);
double min = stats.getMin();
for (int i = 0; i < sum.length; i++) {
sum[i] = sum[i] - min;
}
double[] gaussian = fitGaussian(sum, x);
if (gaussian != null) {
if ((gaussian[2] < sum.length * 0.45) && (gaussian[0] > min * 0.03)) {
double maxPlot = gaussian[0];
xMean = gaussian[1];
xSigma = gaussian[2];
gaussian[0] += min;
double[] fit = getFitFunction(gaussian, x);
int[] y = new int[x.length];
for (int i = 0; i < x.length; i++) {
y[i] = (int) (data.getHeight() - 1 - ((fit[i] / maxPlot) * profileSize));
}
vpoly = new Overlays.Polyline(fitPen, x, y);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
try {
double[] sum = (double[]) Convert.toDouble(data.integrateHorizontally(true));
int[] x = Arr.indexesInt(sum.length);
DescriptiveStatistics stats = new DescriptiveStatistics(sum);
double min = stats.getMin();
for (int i = 0; i < sum.length; i++) {
sum[i] = sum[i] - min;
}
double[] gaussian = fitGaussian(sum, x);
if (gaussian != null) {
//Only aknowledge beam fully inside the image and peak over 3% of min
if ((gaussian[2] < sum.length * 0.45) && (gaussian[0] > min * 0.03)) {
double maxPlot = gaussian[0];
yMean = gaussian[1];
ySigma = gaussian[2];
gaussian[0] += min;
double[] fit = getFitFunction(gaussian, x);
int[] y = new int[x.length];
for (int i = 0; i < x.length; i++) {
y[i] = (int) ((fit[i] / maxPlot) * profileSize);
}
hpoly = new Overlays.Polyline(fitPen, y, x);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
Overlays.Crosshairs cross = null;
Overlays.Text text = null;
if ((xMean != null) && (yMean != null)) {
cross = new Overlays.Crosshairs(crossPen,
new Point(xMean.intValue(), yMean.intValue()),
new Dimension(2 * xSigma.intValue(), 2 * ySigma.intValue()));
text = new Overlays.Text(fitPen,
String.format("x = %f \n y = %f" , data.getX((int) Math.round(xMean)), data.getY((int) Math.round(yMean))),
new Font(Font.MONOSPACED, 0, 14), new Point(20,20));
}
return new Overlay[]{hpoly, vpoly, cross, text};
}
return null;
}
double[] fitGaussianScript(int[] y, int[] x) {
ScriptManager sm = Context.getInstance().getScriptManager();
ArrayProperties pY = ArrayProperties.get(y);
sm.setVar("y", y);
sm.setVar("x", x);
InterpreterResult r = sm.eval("r = fit_gaussians(y, x, [" + pY.maxIndex + ",])");
if (r.exception != null) {
r.exception.printStackTrace();
} else {
List ret = (List) sm.getVar("r");
if ((ret != null) && (ret.size() == 1) && (ret.get(0) instanceof List) && (((List) (ret.get(0))).size() == 3)) {
double norm = (Double) ((List) ret.get(0)).get(0);
double mean = (Double) ((List) ret.get(0)).get(1);
double sigma = (Double) ((List) ret.get(0)).get(2);
return new double[]{norm, mean, sigma};
}
}
return null;
}
double[] fitGaussian(double[] y, int[] x) {
try {
ArrayProperties pY = ArrayProperties.get(y);
GaussianCurveFitter fitter = GaussianCurveFitter.create().withStartPoint(new double[]{(pY.max - pY.min) / 2, x[pY.maxIndex], 1.0}).withMaxIterations(1000);
ArrayList<WeightedObservedPoint> values = new ArrayList<>();
for (int i = 0; i < y.length; i++) {
values.add(new WeightedObservedPoint(1.0, x[i], y[i]));
}
return fitter.fit(values);
} catch (Exception ex) {
return null;
}
}
double[] getFitFunction(double[] pars, int[] x) {
double[] fit = new double[x.length];
Gaussian g = new Gaussian(pars[0], pars[1], pars[2]);
for (int i = 0; i < x.length; i++) {
fit[i] = g.value(x[i]);
}
return fit;
}
////////
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
renderer = new ch.psi.pshell.imaging.Renderer();
jLabel1 = new javax.swing.JLabel();
comboCameras = new javax.swing.JComboBox();
jLabel2 = new javax.swing.JLabel();
textState = new javax.swing.JTextField();
buttonConfig = new javax.swing.JButton();
buttonSetup = new javax.swing.JButton();
checkCamtool = new javax.swing.JCheckBox();
buttonFit = new javax.swing.JToggleButton();
buttonPause = new javax.swing.JToggleButton();
buttonMarker = new javax.swing.JToggleButton();
buttonSave = new javax.swing.JToggleButton();
buttonReticle = new javax.swing.JToggleButton();
buttonGrabBackground = new javax.swing.JButton();
jLabel1.setText("Camera:");
comboCameras.setMaximumRowCount(30);
comboCameras.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
comboCamerasActionPerformed(evt);
}
});
jLabel2.setText("State:");
textState.setEditable(false);
textState.setHorizontalAlignment(javax.swing.JTextField.CENTER);
textState.setDisabledTextColor(new java.awt.Color(0, 0, 0));
textState.setEnabled(false);
buttonConfig.setText("Config");
buttonConfig.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonConfigActionPerformed(evt);
}
});
buttonSetup.setText("Setup");
buttonSetup.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonSetupActionPerformed(evt);
}
});
checkCamtool.setSelected(true);
checkCamtool.setText("Camtool");
buttonFit.setSelected(true);
buttonFit.setText("Fit");
buttonFit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonFitActionPerformed(evt);
}
});
buttonPause.setText("Pause");
buttonPause.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonPauseActionPerformed(evt);
}
});
buttonMarker.setText("Marker");
buttonMarker.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonMarkerActionPerformed(evt);
}
});
buttonSave.setText("Save Snapshot");
buttonSave.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonSaveActionPerformed(evt);
}
});
buttonReticle.setSelected(true);
buttonReticle.setText("Reticle");
buttonReticle.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonReticleActionPerformed(evt);
}
});
buttonGrabBackground.setText("Grab Background");
buttonGrabBackground.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonGrabBackgroundActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(renderer, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 650, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(checkCamtool)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(comboCameras, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonConfig)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonSetup)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textState, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(buttonPause)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonMarker)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonFit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonReticle)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(buttonGrabBackground)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonSave)))
.addContainerGap())
);
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonConfig, buttonSetup});
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonFit, buttonMarker, buttonPause, buttonReticle});
layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonGrabBackground, buttonSave});
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(comboCameras, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2)
.addComponent(textState, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonConfig)
.addComponent(buttonSetup)
.addComponent(checkCamtool))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(renderer, javax.swing.GroupLayout.DEFAULT_SIZE, 307, Short.MAX_VALUE)
.addGap(12, 12, 12)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonPause)
.addComponent(buttonFit)
.addComponent(buttonMarker)
.addComponent(buttonSave)
.addComponent(buttonReticle)
.addComponent(buttonGrabBackground))
.addContainerGap())
);
layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {comboCameras, textState});
}// </editor-fold>//GEN-END:initComponents
private void comboCamerasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboCamerasActionPerformed
try {
comboCameras.setEnabled(false);
new Thread(new Runnable() {
@Override
public void run() {
try{
setCamera((String) comboCameras.getSelectedItem());
} catch(Exception ex){
ex.printStackTrace();
} finally{
comboCameras.setEnabled(true);
}
}
}).start();
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_comboCamerasActionPerformed
private void buttonConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonConfigActionPerformed
try {
if (camera != null) {
TextEditor editor = new TextEditor();
editor.setText(cameraConfigJson);
editor.setReadOnly(true);
editor.setTitle(cameraName);
EditorDialog dlg = editor.getDialog(getTopLevel(), false);
dlg.setSize(480, 640);
dlg.setVisible(true);
SwingUtils.centerComponent(this, dlg);
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonConfigActionPerformed
private void buttonSetupActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSetupActionPerformed
try {
if (camera != null) {
this.showDeviceConfigDialog(camera, false);
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonSetupActionPerformed
private void buttonPauseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPauseActionPerformed
try {
if (camera != null) {
if (buttonPause.isSelected()){
renderer.pause();
} else {
renderer.resume();
}
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonPauseActionPerformed
private void buttonMarkerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonMarkerActionPerformed
try {
if (camera != null) {
if (buttonMarker.isSelected()){
Dimension d = renderer.getImageSize();
Point p = (d == null) ? new Point(renderer.getWidth() / 2, renderer.getHeight() / 2) : new Point(d.width / 2, d.height / 2);
Overlay ov = null;
marker = new Overlays.Crosshairs(renderer.getPenMarker(), p, new Dimension(100, 100));
marker.setMovable(true);
} else {
marker = null;
}
renderer.setMarker(marker);
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonMarkerActionPerformed
private void buttonFitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonFitActionPerformed
try {
renderer.setProfile(buttonFit.isSelected() ? Profile.Both :Profile.None);
if (!buttonFit.isSelected()){
renderer.removeOverlays(fitOv);
fitOv = null;
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonFitActionPerformed
private void buttonReticleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReticleActionPerformed
try {
checkReticle();
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonReticleActionPerformed
private void buttonSaveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSaveActionPerformed
try {
renderer.setSnapshotDialogVisible(buttonSave.isSelected());
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonSaveActionPerformed
private void buttonGrabBackgroundActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonGrabBackgroundActionPerformed
try {
if (camera instanceof Camtool){
((Camtool)camera).captureBackground(5);
}
} catch (Exception ex) {
showException(ex);
}
}//GEN-LAST:event_buttonGrabBackgroundActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton buttonConfig;
private javax.swing.JToggleButton buttonFit;
private javax.swing.JButton buttonGrabBackground;
private javax.swing.JToggleButton buttonMarker;
private javax.swing.JToggleButton buttonPause;
private javax.swing.JToggleButton buttonReticle;
private javax.swing.JToggleButton buttonSave;
private javax.swing.JButton buttonSetup;
private javax.swing.JCheckBox checkCamtool;
private javax.swing.JComboBox comboCameras;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private ch.psi.pshell.imaging.Renderer renderer;
private javax.swing.JTextField textState;
// End of variables declaration//GEN-END:variables
}

View File

@@ -1,309 +0,0 @@
/*
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
*/
import ch.psi.pshell.device.Device;
import ch.psi.pshell.device.Readable;
import ch.psi.pshell.epics.*;
import java.io.IOException;
import java.util.ArrayList;
/**
*
*/
public class Camtool extends ArraySource {
final String prefix;
final String dataPrefix;
final boolean latch;
final public ChannelInteger channelRun;
final public ChannelInteger channelLatch;
final public ChannelDouble channelTimestamp;
final public ChannelDoubleArray origin;
final public ChannelDouble posX, posY;
final public ChannelDoubleArray profileX, profileY;
final public ChannelIntegerArray shape;
final public ChannelInteger roiEnabled;
final public ChannelIntegerArray roiShape;
final public ChannelInteger bgEnable, bgCapture, bgCaptureRemain;
final public ChannelDouble calOffX, calOffY, calScaleX, calScaleY;
final public CamToolPosX posMeanX;
final public CamToolPosY posMeanY;
final public CamToolVarX posVarX;
final public CamToolVarY posVarY;
public Camtool(String name, String prefix) {
this(name, prefix, false);
}
public Camtool(String name, String prefix, boolean latch) {
//super(name, prefix + (latch ? ":latch" : ":pipeline") + (roi ? ".roi.output" : ".image"));
super(name, prefix + (latch ? ":latch" : ":pipeline") + ".roi.output");
this.prefix = prefix + ":";
this.latch = latch;
dataPrefix = this.prefix + (latch ? "latch" : "pipeline") + ".";
channelRun = new ChannelInteger(name + " run", this.prefix + "camera.run");
channelLatch = new ChannelInteger(name + " latch", this.prefix + "latch.capture");
channelTimestamp = new ChannelDouble(name + " timestamp", dataPrefix + "timestamp");
channelTimestamp.setMonitored(true);
//posX = new ChannelDouble(name + " com x", dataPrefix + "x_stats.com");
//posY = new ChannelDouble(name + " com y", dataPrefix + "y_stats.com");
posX = new ChannelDouble(name + " com x", dataPrefix + "x_stats.com_egu");
posY = new ChannelDouble(name + " com y", dataPrefix + "y_stats.com_egu");
profileX = new ChannelDoubleArray(name + " profile x", dataPrefix + "profile.x");
profileY = new ChannelDoubleArray(name + " profile y", dataPrefix + "profile.y");
//shape = new ChannelIntegerArray(name + " shape", dataPrefix + (roi ? "roi.output.shape" : "image.shape"));
shape = new ChannelIntegerArray(name + " shape", dataPrefix + ("image.shape"));
roiShape = new ChannelIntegerArray(name + " roi shape", dataPrefix + "roi.roi");
roiEnabled = new ChannelInteger(name + " roi enabled", dataPrefix + "roi.enabled");
//origin = new ChannelDoubleArray(name + " origin X", roi ? (dataPrefix + "roi.origin_out") : (prefix + "origin"));
origin = new ChannelDoubleArray(name + " origin X", dataPrefix + "roi.origin_out");
bgEnable = new ChannelInteger(name + " bg enable", this.prefix + "pipeline.bg.enabled");
bgCapture = new ChannelInteger(name + " bg capture", this.prefix + "pipeline.bg.capture");
bgCaptureRemain = new ChannelInteger(name + " bg capture remain", this.prefix + "pipeline.bg.capture_remain");
calOffX = new ChannelDouble(name + " cal off x", this.prefix + "pipeline.egu.eoff_x");
calOffY = new ChannelDouble(name + " cal off y", this.prefix + "pipeline.egu.eoff_y");
calScaleX = new ChannelDouble(name + " cal scale x", this.prefix + "pipeline.egu.eslo_x");
calScaleY = new ChannelDouble(name + " cal scale y", this.prefix + "pipeline.egu.eslo_y");
posMeanX = new CamToolPosX();
posMeanY = new CamToolPosY();
posVarX = new CamToolVarX();
posVarY = new CamToolVarY();
}
@Override
public void doSetMonitored(boolean value) {
super.doSetMonitored(value);
getDevice().setMonitored(value);
}
@Override
public void doUpdate() throws IOException, InterruptedException {
super.doUpdate();
getDevice().update();
}
void safeInitialize(Device dev, int timeout) throws IOException, InterruptedException {
for (int retries = 0; retries < 10; retries++) {
try {
dev.initialize();
break;
} catch (IOException ex) {
if (retries == 9) {
throw ex;
}
Thread.sleep(timeout / 10);
}
}
}
@Override
protected void doInitialize() throws IOException, InterruptedException {
try {
channelRun.initialize();
channelLatch.initialize();
if (latch) {
start();
latch();
}
safeInitialize(channelTimestamp, 2000);
posX.initialize();
posY.initialize();
profileX.initialize();
profileY.initialize();
shape.initialize();
roiShape.initialize();
roiEnabled.initialize();
origin.initialize();
bgEnable.initialize();
bgCapture.initialize();
bgCaptureRemain.initialize();
try {
calOffX.initialize();
calOffY.initialize();
calScaleX.initialize();
calScaleY.initialize();
} catch (Exception ex) {
ex.printStackTrace();
}
if (roiEnabled.read()>0){
int[] s = roiShape.read();
//for (int x : s) System.out.println(x);
getConfig().imageHeight = s[3];
getConfig().imageWidth = s[2];
} else {
int[] s = shape.read();
//for (int x : s){ System.out.println(x);}
getConfig().imageHeight = s[0];
getConfig().imageWidth = s[1];
}
getConfig().save();
getDevice().setSize(getConfig().imageHeight * getConfig().imageWidth);
super.doInitialize();
//System.out.println(((int[])(getDevice().read())).length);
} catch (InterruptedException ex) {
throw ex;
} catch (Exception ex) {
ex.printStackTrace();
throw new IOException(ex);
}
}
int numImages = 1;
public int getNumImages() {
return numImages;
}
public void setNumImages(int value) {
numImages = value;
}
double grabTimeout = 3.0;
public double getGrabTimeout() {
return grabTimeout;
}
public void setGrabTimeou(double value) {
grabTimeout = value;
}
public void capture() throws IOException, InterruptedException {
int retries = 3;
while (true) {
try {
double timestamp = channelTimestamp.read();
if (latch) {
channelLatch.write(1);
} else {
channelRun.write(1);
}
long start = System.currentTimeMillis();
while (true) {
double val = channelTimestamp.read();
if (timestamp != val) {
return;
}
if ((System.currentTimeMillis() - start) > grabTimeout) {
throw new IOException("Frame timeout");
}
Thread.sleep(5);
}
} catch (IOException ex) {
retries--;
if (--retries <= 0) {
throw ex;
}
}
}
}
public void start() throws IOException, InterruptedException {
channelRun.write(-1);
}
public void stop() throws IOException, InterruptedException {
channelRun.write(0);
}
public void grabSingle() throws IOException, InterruptedException {
channelRun.write(1);
}
public void latch() throws IOException, InterruptedException {
channelLatch.write(1);
}
public void enableBackground(boolean value) throws IOException, InterruptedException {
bgEnable.write(value ? 1 : 0);
}
public void captureBackground(int images) throws IOException, InterruptedException {
start();
bgCapture.write(images);
Thread.sleep(200);
while (bgCaptureRemain.read() > 0) {
Thread.sleep(10);
}
}
//Statisticss pseudo devices
ArrayList<Double> posXSamples;
ArrayList<Double> posYSamples;
public void updateStats() throws IOException, InterruptedException {
posXSamples.clear();
posYSamples.clear();
for (int i = 0; i < getNumImages(); i++) {
capture();
posXSamples.add(posX.read());
posXSamples.add(posY.read());
}
}
class CamToolPosX implements Readable {
@Override
public Object read() throws IOException, InterruptedException {
return mean(posXSamples);
}
}
class CamToolPosY implements Readable {
@Override
public Object read() throws IOException, InterruptedException {
return mean(posYSamples);
}
}
class CamToolVarX implements Readable {
@Override
public Object read() throws IOException, InterruptedException {
return stdev(posXSamples);
}
}
class CamToolVarY implements Readable {
@Override
public Object read() throws IOException, InterruptedException {
return stdev(posYSamples);
}
}
public double mean(ArrayList<Double> samples) {
int count = 0;
double temp = 0;
for (Double n : samples) {
if (!Double.isNaN(n)) {
temp += n.doubleValue();
count++;
}
}
return count == 0 ? Double.NaN : temp / count;
}
public double stdev(ArrayList<Double> samples) {
int count = 0;
double temp = 0;
double mean = mean(samples);
for (Double n : samples) {
if (!Double.isNaN(n)) {
temp += Math.pow((mean - n), 2);
}
}
return count == 0 ? Double.NaN : temp / count;
}
}

View File

@@ -2,10 +2,11 @@
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
*/
import ch.psi.pshell.App;
import ch.psi.pshell.framework.Context;
import ch.psi.pshell.plot.Plot;
import ch.psi.pshell.ui.App;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import ch.psi.pshell.framework.Panel;
import ch.psi.pshell.utils.State;
import java.awt.Component;
import java.util.HashMap;
import java.util.List;
@@ -73,14 +74,14 @@ public class Correlation extends Panel {
//DecimalFormat formatter = new DecimalFormat("0.##E0");
void updateResults(){
try{
textCorrelation.setText(String.format("%1.4f", Double.valueOf((Double)getContext().getInterpreterVariable("corr"))));
textCorrelation.setText(String.format("%1.4f", Double.valueOf((Double)Context.getSequencer().getInterpreterVariable("corr"))));
} catch (Exception ex){
textCorrelation.setText("");
}
if (checkLinear.isSelected()){
try{
List pars = (List)getContext().getInterpreterVariable("pars_lin");
List pars = (List)Context.getSequencer().getInterpreterVariable("pars_lin");
//textLinear.setText(String.format("%1.3fx%+1.3f", (Double)(pars.get(1)), (Double)(pars.get(0))));
textLinear.setText(String.format("%1.6gx%+1.6g",pars.get(1), pars.get(0)));
} catch (Exception ex){
@@ -90,7 +91,7 @@ public class Correlation extends Panel {
if (checkQuadratic.isSelected()){
try{
List pars = (List)getContext().getInterpreterVariable("pars_quad");
List pars = (List)Context.getSequencer().getInterpreterVariable("pars_quad");
//textQuadratic.setText(String.format("%1.2fx\u00B2 %+1.2fx%+1.2f", (Double)(pars.get(0)), (Double)(pars.get(1)), (Double)(pars.get(0))));
textQuadratic.setText(String.format("%1.3gx\u00B2%+1.3gx%+1.3g", pars.get(0), pars.get(1), pars.get(0)));
//textQuadratic.setText(formatter.format(pars.get(2))+ formatter.format(pars.get(1)) + formatter.format(pars.get(0)));

View File

@@ -2,15 +2,17 @@
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
*/
import ch.psi.pshell.App;
import ch.psi.pshell.app.Setup;
import ch.psi.pshell.framework.Context;
import ch.psi.pshell.plot.Plot;
import ch.psi.pshell.swing.ChannelSelector;
import ch.psi.pshell.ui.App;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import ch.psi.utils.Chrono;
import ch.psi.utils.swing.SwingUtils;
import ch.psi.utils.swing.SwingUtils.OptionResult;
import ch.psi.utils.swing.SwingUtils.OptionType;
import ch.psi.pshell.framework.Panel;
import ch.psi.pshell.utils.State;
import ch.psi.pshell.utils.Chrono;
import ch.psi.pshell.swing.SwingUtils;
import ch.psi.pshell.swing.SwingUtils.OptionResult;
import ch.psi.pshell.swing.SwingUtils.OptionType;
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
@@ -86,14 +88,14 @@ public class Correlation2 extends Panel {
//DecimalFormat formatter = new DecimalFormat("0.##E0");
void updateResults(){
try{
textCorrelation.setText(String.format("%1.4f", Double.valueOf((Double)getContext().getInterpreterVariable("corr"))));
textCorrelation.setText(String.format("%1.4f", Double.valueOf((Double)Context.getSequencer().getInterpreterVariable("corr"))));
} catch (Exception ex){
textCorrelation.setText("");
}
if (checkLinear.isSelected()){
try{
List pars = (List)getContext().getInterpreterVariable("pars_lin");
List pars = (List)Context.getSequencer().getInterpreterVariable("pars_lin");
//textLinear.setText(String.format("%1.3fx%+1.3f", (Double)(pars.get(1)), (Double)(pars.get(0))));
textLinear.setText(String.format("%1.6gx%+1.6g",pars.get(1), pars.get(0)));
} catch (Exception ex){
@@ -103,7 +105,7 @@ public class Correlation2 extends Panel {
if (checkQuadratic.isSelected()){
try{
List pars = (List)getContext().getInterpreterVariable("pars_quad");
List pars = (List)Context.getSequencer().getInterpreterVariable("pars_quad");
//textQuadratic.setText(String.format("%1.2fx\u00B2 %+1.2fx%+1.2f", (Double)(pars.get(0)), (Double)(pars.get(1)), (Double)(pars.get(0))));
textQuadratic.setText(String.format("%1.3gx\u00B2%+1.3gx%+1.3g", pars.get(0), pars.get(1), pars.get(0)));
//textQuadratic.setText(formatter.format(pars.get(2))+ formatter.format(pars.get(1)) + formatter.format(pars.get(0)));
@@ -112,11 +114,11 @@ public class Correlation2 extends Panel {
textQuadratic.setText("");
}
try{
String peak = (String)getContext().getInterpreterVariable("pos_peak");
String peak = (String)Context.getSequencer().getInterpreterVariable("pos_peak");
if (peak!=null){
textPeak.setText(peak + " (max)");
} else {
peak = (String)getContext().getInterpreterVariable("neg_peak");
peak = (String)Context.getSequencer().getInterpreterVariable("neg_peak");
if (peak!=null){
textPeak.setText(peak + " (min)");
} else {
@@ -449,15 +451,15 @@ public class Correlation2 extends Panel {
if (isRunning()){
//abort();
//Stooping smootly so displayed variables get updated.
getContext().setInterpreterVariable("stop_exec", true);
Context.getSequencer().setInterpreterVariable("stop_exec", true);
Chrono chrono = new Chrono();
while (!chrono.isTimeout(500)){
if (!Boolean.TRUE.equals(getContext().getInterpreterVariable("stop_exec"))){
if (!Boolean.TRUE.equals(Context.getSequencer().getInterpreterVariable("stop_exec"))){
break;
}
Thread.sleep(1);
}
if (Boolean.TRUE.equals(getContext().getInterpreterVariable("stop_exec"))){
if (Boolean.TRUE.equals(Context.getSequencer().getInterpreterVariable("stop_exec"))){
System.out.println("Timeout stopping script - aborting...");
abort();
}
@@ -515,7 +517,7 @@ public class Correlation2 extends Panel {
private void buttonElogActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonElogActionPerformed
try{
String snapshotFile = getContext().getSetup().expandPath("{context}/correlation_plot.png");
String snapshotFile = Setup.expandPath("{context}/correlation_plot.png");
plot.saveSnapshot(snapshotFile, "png");
JPanel panel = new JPanel();
GridBagLayout layout = new GridBagLayout();

View File

@@ -3,9 +3,9 @@
*/
import ch.psi.pshell.plot.LinePlot;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import ch.psi.utils.swing.SwingUtils;
import ch.psi.pshell.framework.Panel;
import ch.psi.pshell.swing.SwingUtils;
import ch.psi.pshell.utils.State;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JSpinner;

View File

@@ -2,15 +2,11 @@
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
*/
import ch.psi.pshell.core.Context;
import ch.psi.pshell.plot.LinePlot;
import ch.psi.pshell.plot.LinePlotJFree;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import ch.psi.pshell.framework.Panel;
import ch.psi.pshell.utils.State;
import java.awt.Component;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JPanel;
/**
@@ -39,7 +35,7 @@ public class GunSolenoidAlignment extends Panel {
}
return ret;
});
} catch (Context.ContextStateException ex) {
} catch (StateException ex) {
showException((Exception) ex);
}
}

View File

@@ -1,148 +0,0 @@
/*
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
*/
import ch.psi.pshell.core.JsonSerializer;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.glassfish.jersey.client.ClientConfig;
import org.glassfish.jersey.jackson.JacksonFeature;
/**
*
*/
public class Inventory {
public static <T> T inventoryRequest(String url, Map attributes, Class<T> type) throws IOException {
String json = JsonSerializer.encode(attributes);
Client client = ClientBuilder.newClient(new ClientConfig().register(JacksonFeature.class));
try {
WebTarget resource = client.target(url);
Response r = resource.request().accept(MediaType.TEXT_HTML).post(Entity.json(json));
json = r.readEntity(String.class);
if (r.getStatus() != Response.Status.OK.getStatusCode()) {
throw new IOException("Inventory returned error: " + json);
}
Map ret = (Map) JsonSerializer.decode(json, Map.class);
return (T) ret.get("d");
} finally {
client.close();
}
}
public static String findPartidByHoly(String holy_name, String type) throws IOException {
if (type == null) {
type = "DSCR";
}
Map query = new HashMap();
Map qn = new HashMap();
Map qt = new HashMap();
qn.put("Field", "Holy List Name");
qn.put("Operator", "Is");
qn.put("Value", holy_name);
qt.put("Field", "Type");
qt.put("Operator", "Is");
qt.put("Value", type);
query.put("query", Arrays.asList(new Map[]{qn, qt}));
query.put("columns", Arrays.asList(new String[]{"Label"}));
Map attr = new HashMap();
attr.put("search", query);
Map ret = (Map) inventoryRequest("https://inventory.psi.ch/DataAccess.asmx/FindObjects", attr, Map.class);
try {
return (String) ((List) (((List) ret.get("Rows")).get(0))).get(0);
} catch (Exception ex) {
return null;
}
}
public static List findAllByType(String type, String column) throws IOException {
if (type == null) {
type = "DSCR";
}
if (column == null) {
column = "Holy List Name";
}
Map query = new HashMap();
Map q = new HashMap();
q.put("Field", "Type");
q.put("Operator", "Is");
q.put("Value", type);
query.put("query", Arrays.asList(new Map[]{q}));
query.put("columns", Arrays.asList(new String[]{"Label"}));
Map attr = new HashMap();
attr.put("search", query);
Map r = (Map) inventoryRequest("https://inventory.psi.ch/DataAccess.asmx/FindObjects", attr, Map.class);
List rows = (List) (r.get("Rows"));
List ret = new ArrayList();
for (Object list : rows) {
ret.add(((List) list).get(0));
}
return ret;
}
public static List<Map> getPartAttributesFromInventory(String part_label, String holy_name) throws IOException {
if ((holy_name != null) && !holy_name.isEmpty()) {
part_label = findPartidByHoly(holy_name, "DSCR");
if ((part_label == null) || part_label.isEmpty()) {
throw new IOException("Could not find inventory part for: " + holy_name);
}
}
Map map = new HashMap();
map.put("psiLabel", part_label);
return (List) inventoryRequest("https://inventory.psi.ch/DataAccess.asmx/GetPartAttributes", map, List.class);
}
public static List<Double> getCalibFromInventory(String part_label, String holy_name) throws IOException {
double horizontal_dist = 0.0;
double vertical_dist = 0.0;
double horizontal_tilt = 0.0;
double vertical_tilt = 0.0;
List<Map> attributes = getPartAttributesFromInventory(part_label, holy_name);
for (Map a : attributes) {
String name = (String) a.get("Name");
Double val = 0.0;
try {
val = Double.valueOf(a.get("Value").toString());
} catch (Exception ex) {
}
switch (name) {
case "Crystal angle in x (e-beam system) [deg]":
horizontal_tilt = val;
break;
case "Crystal angle in y (e-beam system) [deg]":
vertical_tilt = val;
break;
case "Mark distance in x (e-beam system) [mm]":
horizontal_dist = val;
break;
case "Mark distance in y (e-beam system) [mm]":
vertical_dist = val;
break;
}
}
return Arrays.asList(new Double[]{horizontal_dist, vertical_dist, horizontal_tilt, vertical_tilt});
}
public static void main(String[] args) throws IOException {
System.out.println(getCalibFromInventory("SINEG01-DSCR190", "SINEG01-DSCR190"));
System.out.println(findAllByType(null, null));
}
}

View File

@@ -2,10 +2,9 @@
* Copyright (c) 2014 Paul Scherrer Institute. All rights reserved.
*/
import ch.psi.pshell.core.Context;
import ch.psi.pshell.plot.LinePlot;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
import ch.psi.pshell.framework.Panel;
import ch.psi.pshell.utils.State;
import java.awt.Component;
import java.util.HashMap;
import javax.swing.JPanel;
@@ -36,7 +35,7 @@ public class LaserGunAlignment extends Panel {
}
return ret;
});
} catch (Context.ContextStateException ex) {
} catch (StateException ex) {
showException((Exception) ex);
}
}

View File

@@ -11,10 +11,10 @@ import ch.psi.pshell.plot.Plot;
import ch.psi.pshell.scan.Scan;
import ch.psi.pshell.scan.ScanListener;
import ch.psi.pshell.scan.ScanRecord;
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.Convert;
import ch.psi.utils.State;
import ch.psi.utils.swing.SwingUtils;
import ch.psi.pshell.framework.Panel;
import ch.psi.pshell.utils.Convert;
import ch.psi.pshell.utils.State;
import ch.psi.pshell.swing.SwingUtils;
import java.awt.Color;
import java.awt.Component;
import java.util.ArrayList;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More