From ee2df1c4899a405e3287aab66507110080ce6bbb Mon Sep 17 00:00:00 2001 From: gac-bernina Date: Thu, 4 Sep 2025 11:36:29 +0200 Subject: [PATCH] Sep.2025 --- config/config.properties | 56 ++-- config/devices.properties | 10 +- config/plugins.properties | 2 +- config/variables.properties | 8 +- devices/CurrentCamera.properties | 14 +- devices/ap_o_h.properties | 19 ++ devices/ap_o_w.properties | 19 ++ devices/ap_s_h.properties | 19 ++ devices/ap_s_w.properties | 19 ++ devices/asd.properties | 19 ++ devices/att.properties | 11 + devices/cam_server.properties | 10 +- devices/dp1.properties | 3 +- devices/m1.properties | 3 +- devices/m2.properties | 3 +- devices/p1.properties | 3 +- plugins/Pointing.form | 345 +++++++++++++++++++++---- plugins/Pointing.java | 388 ++++++++++++++++++++++++---- script/config_bernina.py | 39 +++ script/pointing/check_offset.py | 8 +- script/pointing/config.py | 34 ++- script/pointing/config_bkg.py | 18 ++ script/pointing/device_define.py | 27 ++ script/pointing/end.py | 7 +- script/pointing/local.py | 10 +- script/pointing/main.py | 45 +--- script/pointing/reference_offset.py | 16 +- script/pointing/reference_slope.py | 47 ++++ script/pointing/start.py | 19 +- 29 files changed, 993 insertions(+), 228 deletions(-) create mode 100644 devices/ap_o_h.properties create mode 100644 devices/ap_o_w.properties create mode 100644 devices/ap_s_h.properties create mode 100644 devices/ap_s_w.properties create mode 100644 devices/asd.properties create mode 100644 devices/att.properties mode change 100755 => 100644 devices/dp1.properties mode change 100755 => 100644 devices/m1.properties mode change 100755 => 100644 devices/m2.properties mode change 100755 => 100644 devices/p1.properties create mode 100644 script/config_bernina.py create mode 100644 script/pointing/config_bkg.py create mode 100644 script/pointing/device_define.py create mode 100644 script/pointing/reference_slope.py diff --git a/config/config.properties b/config/config.properties index 998ec0b..0256365 100755 --- a/config/config.properties +++ b/config/config.properties @@ -1,60 +1,62 @@ -#Mon May 15 09:51:30 CEST 2023 -xscanMoveTimeout=600 +#Thu Sep 04 11:33:42 CEST 2025 autoSaveScanData=true simulation=false -commandExecutionEvents=false -logDaysToLive=50 xscanCrlogicChannel=null dataScanSaveOutput=false -xscanCrlogicSimulated=false userAuthenticator= -logLevelConsole=Off -filePermissionsConfig=Public -scanStreamerPort=-1 dataScanSaveScript=false -dataScanSaveSetpoints=false notifiedTasks=null parallelInitialization=false fdaSerialization=false dataTransferPath=null saveConsoleSessionFiles=false xscanAppendSuffix=true -versionTrackingManual=true -dataTransferMode=Off hostName=null -userManagement=false disableEmbeddedAttributes=false -instanceName=BE -dataServerPort=-1 serverPort=8080 -hideServerMessages=false versionTrackingEnabled=true dataPath={data}/{year}_{month}/{date}/{date}_{time}_{name} serverEnabled=false depthDimension=0 -dataScanReleaseRecords=false -dataScanPreserveTypes=false logLevel=Info -dataScanFlushRecords=false -logPath={logs}/{date}_{time} -filePermissionsLogs=Public dataLayout=default disableDataFileLogs=false +dataScanSaveTimestamps=false sessionHandling=Off terminalEnabled=false notificationLevel=Off -filePermissionsScripts=Public terminalPort=3579 -xscanCrlogicPrefix=null dataTransferUser=null +xscanContinuousUpdate=false +versionTrackingLogin=auto +noBytecodeFiles=false +versionTrackingRemote=https\://gitea.psi.ch/pshell_config/saresb.git +dataScanLazyTableCreation=false +pythonHome= +xscanMoveTimeout=600 +commandExecutionEvents=false +logDaysToLive=50 +xscanCrlogicSimulated=false +logLevelConsole=Off +filePermissionsConfig=Public +scanStreamerPort=-1 +dataScanSaveSetpoints=false +versionTrackingManual=true +dataTransferMode=Off +userManagement=false +instanceName=BE +dataServerPort=-1 +hideServerMessages=false +dataScanReleaseRecords=false +dataScanPreserveTypes=false +dataScanFlushRecords=false +logPath={logs}/{date}_{time} +filePermissionsLogs=Public +filePermissionsScripts=Public +xscanCrlogicPrefix=null filePermissionsData=Default xscanCrlogicAbortable=true -xscanContinuousUpdate=false createSessionFiles=false -versionTrackingLogin={context}/svcusr-hlapp_robot -noBytecodeFiles=false -versionTrackingRemote=git@git.psi.ch\:pshell_config/saresb.git dataProvider=h5 xscanCrlogicIoc=null -dataScanLazyTableCreation=false saveCommandStatistics=false diff --git a/config/devices.properties b/config/devices.properties index 336a709..14a3965 100644 --- a/config/devices.properties +++ b/config/devices.properties @@ -1,4 +1,4 @@ -psss_fwhm_avg=ch.psi.pshell.epics.ChannelDouble|SARFE10-PSSS059:REL-E-SPREAD|||true +psss_fwhm_avg=ch.psi.pshell.epics.ChannelDouble|SARFE10-PSSS059:FIT-FWHM-RAVG|||true dispatcher=ch.psi.pshell.bs.Dispatcher|https://dispatcher-api.psi.ch/sf||| cam_server=ch.psi.pshell.bs.PipelineServer|sf-daqsync-01:8889||| cam_n=ch.psi.pshell.imaging.MjpegSource|http://bernina-cam-n/axis-cgi/mjpg/video.cgi reopen||-200|false @@ -10,14 +10,14 @@ camera_screen=ch.psi.pshell.epics.DiscretePositioner|SAROP21-PPRM094:PROBE_SP||| beamline_name=ch.psi.pshell.epics.ChannelString|SAROP-ARAMIS:BEAMLINE||| aperture_slope_width=ch.psi.pshell.epics.Motor|SAROP21-OAPU092:MOTOR_W|||true aperture_slope_height=ch.psi.pshell.epics.Motor|SAROP21-OAPU092:MOTOR_H|||true -$aperture_offset_width=ch.psi.pshell.epics.Motor|SARFE10-OAPU044:MOTOR_W|||true -$aperture_offset_height=ch.psi.pshell.epics.Motor|SARFE10-OAPU044:MOTOR_H|||true +aperture_offset_width=ch.psi.pshell.epics.Motor|SARFE10-OAPU044:MOTOR_W|||true +aperture_offset_height=ch.psi.pshell.epics.Motor|SARFE10-OAPU044:MOTOR_H|||true attenuator=ch.psi.pshell.epics.Positioner|SARFE10-OATT053:UsrRec.TD SARFE10-OATT053:UsrRec.TR1|||true #psss_energy=ch.psi.pshell.epics.ChannelDouble|SARFE10-PSSS059:ENERGY|||true #psss_spectrum_x=ch.psi.pshell.epics.ChannelDoubleArray|SARFE10-PSSS059:SPECTRUM_X -1 -3|||true #psss_spectrum_y=ch.psi.pshell.epics.ChannelDoubleArray|SARFE10-PSSS059:SPECTRUM_Y -1 -3|||true -#psss_center=ch.psi.pshell.epics.ChannelDouble|SARFE10-PSSS059:SPECTRUM_CENTER|||true -#psss_fwhm=ch.psi.pshell.epics.ChannelDouble|SARFE10-PSSS059:SPECTRUM_FWHM|||true +#psss_center=ch.psi.pshell.epics.ChannelDouble|SARFE10-PSSS059:FIT-COM|||true +#psss_fwhm=ch.psi.pshell.epics.ChannelDouble|SARFE10-PSSS059:FIT-FWHM|||true #psss_roi_min=ch.psi.pshell.epics.ChannelInteger|SARFE10-PSSS059:SPC_ROI_YMIN|||true #psss_roi_max=ch.psi.pshell.epics.ChannelInteger|SARFE10-PSSS059:SPC_ROI_YMAX|||true #histo_center=ch.psi.pshell.device.HistogramGenerator|psss_center|||true diff --git a/config/plugins.properties b/config/plugins.properties index 0ba2d44..b12c2b2 100644 --- a/config/plugins.properties +++ b/config/plugins.properties @@ -5,7 +5,7 @@ ScreenPanel3.java=disabled ScreenPanel4.java=disabled ScreenPanel5.java=disabled ScreenPanel6.java=disabled -PSSS.java=disabled +PSSS.java=enabled MonitoringCameras.java=disabled Chris.java=disabled SfCamera.java=enabled diff --git a/config/variables.properties b/config/variables.properties index be7acc5..18162f6 100644 --- a/config/variables.properties +++ b/config/variables.properties @@ -1,4 +1,4 @@ -#Tue Dec 12 12:48:24 CET 2023 -LastRunDate=231212 -DaySequentialNumber=3 -FileSequentialNumber=6 +#Tue Jul 15 07:16:59 CEST 2025 +LastRunDate=250708 +DaySequentialNumber=0 +FileSequentialNumber=50 diff --git a/devices/CurrentCamera.properties b/devices/CurrentCamera.properties index 8235f62..e494247 100644 --- a/devices/CurrentCamera.properties +++ b/devices/CurrentCamera.properties @@ -1,17 +1,17 @@ -#Mon Feb 19 14:45:17 CET 2024 -spatialCalOffsetY=-213.43204623518318 -spatialCalOffsetX=-415.6307007415859 +#Thu Sep 04 00:33:15 CEST 2025 +spatialCalOffsetY=-433.9999770445405 +spatialCalOffsetX=-756.0000055054078 colormapLogarithmic=false scale=1.0 grayscale=false -spatialCalScaleX=-15.057748904706497 -spatialCalScaleY=-11.764705882352942 -colormapMax=65535.0 +spatialCalScaleX=-0.009900989914499496 +spatialCalScaleY=-0.009999999781809498 +colormapMax=1590.0 rescaleOffset=0.0 roiWidth=-1 colormap=Flame invert=false -colormapMin=63.0 +colormapMin=0.0 rotation=0.0 rotationCrop=false false= diff --git a/devices/ap_o_h.properties b/devices/ap_o_h.properties new file mode 100644 index 0000000..b91f014 --- /dev/null +++ b/devices/ap_o_h.properties @@ -0,0 +1,19 @@ +#Fri Dec 06 13:46:02 CET 2024 +offset=0.0 +maxValue=1.0E10 +rotation=false +precision=3 +scale=1.0 +description=width Y +estbilizationDelay=0 +maxSpeed=NaN +resolution=0.1 +homingType=None +startRetries=1 +minValue=-1.0E10 +unit=mm +defaultSpeed=1.0 +hasEnable=false +sign_bit=0 +monitorByPosition=false +minSpeed=NaN diff --git a/devices/ap_o_w.properties b/devices/ap_o_w.properties new file mode 100644 index 0000000..51e7890 --- /dev/null +++ b/devices/ap_o_w.properties @@ -0,0 +1,19 @@ +#Fri Dec 06 13:46:02 CET 2024 +offset=0.0 +maxValue=1.0E10 +rotation=false +precision=3 +scale=1.0 +description=width X +estbilizationDelay=0 +maxSpeed=NaN +resolution=0.1 +homingType=None +startRetries=1 +minValue=-1.0E10 +unit=mm +defaultSpeed=1.0 +hasEnable=false +sign_bit=0 +monitorByPosition=false +minSpeed=NaN diff --git a/devices/ap_s_h.properties b/devices/ap_s_h.properties new file mode 100644 index 0000000..6d04cf1 --- /dev/null +++ b/devices/ap_s_h.properties @@ -0,0 +1,19 @@ +#Fri Dec 06 13:46:02 CET 2024 +offset=0.0 +maxValue=1.0E10 +rotation=false +precision=3 +scale=1.0 +description=width Y +estbilizationDelay=0 +maxSpeed=NaN +resolution=0.5 +homingType=None +startRetries=1 +minValue=-1.0E10 +unit=mm +defaultSpeed=0.3 +hasEnable=false +sign_bit=0 +monitorByPosition=false +minSpeed=NaN diff --git a/devices/ap_s_w.properties b/devices/ap_s_w.properties new file mode 100644 index 0000000..51f205a --- /dev/null +++ b/devices/ap_s_w.properties @@ -0,0 +1,19 @@ +#Fri Dec 06 13:46:01 CET 2024 +offset=0.0 +maxValue=1.0E10 +rotation=false +precision=3 +scale=1.0 +description=width X +estbilizationDelay=0 +maxSpeed=NaN +resolution=0.5 +homingType=None +startRetries=1 +minValue=-1.0E10 +unit=mm +defaultSpeed=0.3 +hasEnable=false +sign_bit=0 +monitorByPosition=false +minSpeed=NaN diff --git a/devices/asd.properties b/devices/asd.properties new file mode 100644 index 0000000..8553b98 --- /dev/null +++ b/devices/asd.properties @@ -0,0 +1,19 @@ +#Wed Dec 04 16:07:23 CET 2024 +offset=0.0 +maxValue=1.0E10 +rotation=false +precision=3 +scale=1.0 +description=width X +estbilizationDelay=0 +maxSpeed=NaN +resolution=0.5 +homingType=None +startRetries=1 +minValue=-1.0E10 +unit=mm +defaultSpeed=0.3 +hasEnable=false +sign_bit=0 +monitorByPosition=false +minSpeed=NaN diff --git a/devices/att.properties b/devices/att.properties new file mode 100644 index 0000000..8e2963c --- /dev/null +++ b/devices/att.properties @@ -0,0 +1,11 @@ +#Wed Dec 04 16:15:08 CET 2024 +offset=0.0 +maxValue=1.0 +rotation=false +precision=3 +scale=1.0 +description=null +resolution=0.01 +minValue=0.0 +unit=% +sign_bit=0 diff --git a/devices/cam_server.properties b/devices/cam_server.properties index 98c5fd7..39ec0d7 100644 --- a/devices/cam_server.properties +++ b/devices/cam_server.properties @@ -1,11 +1,11 @@ -#Mon Feb 19 10:07:14 CET 2024 -spatialCalOffsetY=-213.43204623518318 -spatialCalOffsetX=-415.6307007415859 +#Tue Apr 23 08:30:02 CEST 2024 +spatialCalOffsetY=-144.99999944661457 +spatialCalOffsetX=-282.99999635292636 colormapLogarithmic=false scale=1.0 grayscale=false -spatialCalScaleX=-15.057748904706497 -spatialCalScaleY=-11.764705882352942 +spatialCalScaleX=-15.057748510085574 +spatialCalScaleY=-11.764705729166666 colormapMax=255.0 rescaleOffset=0.0 roiWidth=-1 diff --git a/devices/dp1.properties b/devices/dp1.properties old mode 100755 new mode 100644 index 5e9124f..1a8e0c3 --- a/devices/dp1.properties +++ b/devices/dp1.properties @@ -1,9 +1,10 @@ -#Fri Jan 29 16:28:42 CET 2021 +#Sun Aug 18 11:11:13 CEST 2024 motor7=null motor8=null motor5=null motor6=null precision=-1 +description=null positions=Park|Ready|Out|Clear motor3=null motor4=null diff --git a/devices/m1.properties b/devices/m1.properties old mode 100755 new mode 100644 index 21f7399..405c8cb --- a/devices/m1.properties +++ b/devices/m1.properties @@ -1,9 +1,10 @@ -#Fri Jan 29 16:28:42 CET 2021 +#Sun Aug 18 11:11:13 CEST 2024 offset=0.0 maxValue=10.0 rotation=false precision=2 scale=1.0 +description=null estbilizationDelay=0 maxSpeed=10.0 resolution=NaN diff --git a/devices/m2.properties b/devices/m2.properties old mode 100755 new mode 100644 index 21f7399..405c8cb --- a/devices/m2.properties +++ b/devices/m2.properties @@ -1,9 +1,10 @@ -#Fri Jan 29 16:28:42 CET 2021 +#Sun Aug 18 11:11:13 CEST 2024 offset=0.0 maxValue=10.0 rotation=false precision=2 scale=1.0 +description=null estbilizationDelay=0 maxSpeed=10.0 resolution=NaN diff --git a/devices/p1.properties b/devices/p1.properties old mode 100755 new mode 100644 index f144d8f..cd28fc9 --- a/devices/p1.properties +++ b/devices/p1.properties @@ -1,4 +1,4 @@ -#Fri Jan 29 16:28:42 CET 2021 +#Sun Aug 18 11:11:13 CEST 2024 minValue=0.0 unit=mm offset=0.0 @@ -7,4 +7,5 @@ rotation=false precision=-1 sign_bit=0 scale=1.0 +description=null resolution=NaN diff --git a/plugins/Pointing.form b/plugins/Pointing.form index 811c9bb..32ba312 100644 --- a/plugins/Pointing.form +++ b/plugins/Pointing.form @@ -16,58 +16,128 @@ - - + + - - - - - - - - - - - + + - - - - - + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + + + - - - - - + + + + + + + + + + @@ -75,39 +145,95 @@ - + - + + + - - - + + + + - + + + + + + + + - - - - + + - - + + - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + + + + + @@ -127,7 +253,7 @@ - + @@ -186,6 +312,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/plugins/Pointing.java b/plugins/Pointing.java index d2a2de0..a99d16b 100644 --- a/plugins/Pointing.java +++ b/plugins/Pointing.java @@ -1,9 +1,17 @@ +import ch.psi.pshell.bs.Stream; +import ch.psi.pshell.bs.StreamValue; +import ch.psi.pshell.imaging.RendererMode; +import ch.psi.pshell.plot.Plot; +import ch.psi.pshell.plot.TimePlotSeries; import ch.psi.pshell.ui.CamServerViewer; import ch.psi.pshell.ui.Panel; import ch.psi.utils.State; +import ch.psi.utils.Str; import java.io.IOException; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; @@ -12,6 +20,11 @@ import java.util.logging.Logger; */ public class Pointing extends Panel { + TimePlotSeries offx = new TimePlotSeries("offx",1); + TimePlotSeries offy = new TimePlotSeries("offy",2); + TimePlotSeries slopex = new TimePlotSeries("slopex",1); + TimePlotSeries slopey = new TimePlotSeries("slopey",2); + public Pointing() { initComponents(); try { @@ -20,17 +33,43 @@ public class Pointing extends Panel { viewer.setPipelineServerUrl("sf-daqsync-01:8889"); viewer.setStartupStream(TOOL_TIP_TEXT_KEY); viewer.setToolbarVisible(false); - viewer.setZoom(2.0); + //viewer.setZoom(2.0); + viewer.getRenderer().setMode(RendererMode.Fit); + timePlotOffset.setDurationMillis(1000*60); + timePlotOffset.addSeries(offx); + timePlotOffset.addSeries(offy); + timePlotOffset.setLegendVisible(true); + timePlotOffset.getAxis(Plot.AxisId.X).setLabel(null); + timePlotOffset.getAxis(Plot.AxisId.Y).setLabel("Offset x [mm]"); + timePlotOffset.getAxis(Plot.AxisId.Y2).setLabel("Offset y [mm]"); + + timePlotSlope.setDurationMillis(1000*60); + timePlotSlope.addSeries(slopex); + timePlotSlope.addSeries(slopey); + timePlotSlope.setLegendVisible(true); + timePlotSlope.getAxis(Plot.AxisId.X).setLabel(null); + timePlotSlope.getAxis(Plot.AxisId.Y).setLabel("Slope x [mm]"); + timePlotSlope.getAxis(Plot.AxisId.Y2).setLabel("Slope y [mm]"); + } catch (Exception ex) { showException(ex); - } + } + } //Overridable callbacks @Override public void onInitialize(int runCount) { try { - viewer.setStream("SAROP21-PPRM094_sp"); + viewer.setStream("SAROP21-PPRM094_pointing"); + } catch (Exception ex) { + showException(ex); + } + try { + offx.clear(); + offy.clear(); + slopex.clear(); + slopey.clear(); } catch (Exception ex) { showException(ex); } @@ -49,10 +88,22 @@ public class Pointing extends Panel { @Override protected void onTimer() { try{ - Object img = viewer.getStreamDevice().take().getValue("image"); - this.setGlobalVar("plugin_img", img); - Object ret = eval("get_saturated_pixels(plugin_img)", true); - textSaturated.setText((ret==null) ? "" : ret.toString()); + StreamValue value = viewer.getStreamDevice().take(); + if (value==null){ + textSaturated.setText(""); + } else { + Object img = value.getValue("image"); + //Setting a global to be used as a paramemeter in the followinf funciton call + this.setGlobalVar("plugin_img", img); + //Running a function in the interpreter IN THE BACKGROUND + //It is synchronous - should not block! + Object ret = eval("get_saturated_pixels(plugin_img)", true); + textSaturated.setText((ret==null) ? "" : ret.toString()); + + //Example reading any variable from the interpreter + //Object obj = this.getGlobalVar("xxx"); + //System.out.println(Str.toString(obj)); + } } catch (Exception ex){ textSaturated.setText(""); this.getLogger().severe(ex.getMessage()); @@ -64,11 +115,22 @@ public class Pointing extends Panel { List offset = (List) ret; Double offX = (Double) offset.get(0); Double offY = (Double) offset.get(1); + Double slopeX = (Double) offset.get(2); + Double slopeY = (Double) offset.get(3); textOffX.setText(String.format("%1.3f",offX)); textOffY.setText(String.format("%1.3f",offY)); + textSlopeX.setText(String.format("%1.3f",slopeX)); + textSlopeY.setText(String.format("%1.3f",slopeY)); + + offx.appendData(offX); + offy.appendData(offY); + slopex.appendData(slopeX); + slopey.appendData(slopeY); } catch (Exception ex){ textOffX.setText(""); - textOffY.setText(""); + textOffY.setText(""); + textSlopeX.setText(""); + textSlopeY.setText(""); //showException(ex); } } @@ -106,6 +168,28 @@ public class Pointing extends Panel { jLabel3 = new javax.swing.JLabel(); textOffY = new javax.swing.JTextField(); ckOffsetCheck = new javax.swing.JCheckBox(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + jLabel6 = new javax.swing.JLabel(); + jLabel7 = new javax.swing.JLabel(); + jLabel8 = new javax.swing.JLabel(); + jLabel9 = new javax.swing.JLabel(); + jLabel10 = new javax.swing.JLabel(); + jLabel11 = new javax.swing.JLabel(); + jLabel12 = new javax.swing.JLabel(); + jLabel13 = new javax.swing.JLabel(); + buttonRefSlopeAp = new javax.swing.JButton(); + jLabel14 = new javax.swing.JLabel(); + timePlotOffset = new ch.psi.pshell.plot.TimePlotJFree(); + jLabel15 = new javax.swing.JLabel(); + textSlopeX = new javax.swing.JTextField(); + jLabel16 = new javax.swing.JLabel(); + textSlopeY = new javax.swing.JTextField(); + timePlotSlope = new ch.psi.pshell.plot.TimePlotJFree(); + jLabel17 = new javax.swing.JLabel(); + jLabel18 = new javax.swing.JLabel(); + jLabel19 = new javax.swing.JLabel(); + jLabel20 = new javax.swing.JLabel(); processVariablePanel1.setDeviceName("attenuator"); processVariablePanel1.setShowLimitButtons(false); @@ -114,7 +198,7 @@ public class Pointing extends Panel { processVariablePanel1.setStepIncrement(0.01); processVariablePanel1.setStepSize(0.01); - jLabel1.setText("Saturated Pixels:"); + jLabel1.setText("1."); textSaturated.setEditable(false); textSaturated.setHorizontalAlignment(javax.swing.JTextField.CENTER); @@ -151,49 +235,152 @@ public class Pointing extends Panel { textOffY.setHorizontalAlignment(javax.swing.JTextField.CENTER); ckOffsetCheck.setText("Enable Offset Check"); + ckOffsetCheck.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + ckOffsetCheckActionPerformed(evt); + } + }); + + jLabel4.setText("Saturated Pixels:"); + + jLabel5.setText("2."); + + jLabel6.setText("3."); + + jLabel7.setText("5."); + + jLabel8.setText("7."); + + jLabel9.setText("Reference the position of the offset apeature (takes around 10 seconds):"); + + jLabel10.setFont(new java.awt.Font("Cantarell", 1, 18)); // NOI18N + jLabel10.setText("To check the pointing of Aramis, follow the steps:"); + + jLabel11.setText("Measure beam position relative to target position of aperature:"); + + jLabel12.setText("If pixels are saturated, tweak attenuation:"); + + jLabel13.setText("Reference the position of the slope aperture (takes around 10 seconds):"); + + buttonRefSlopeAp.setText("Reference Slope Aperture"); + buttonRefSlopeAp.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + buttonRefSlopeApActionPerformed(evt); + } + }); + + jLabel14.setText("4."); + + jLabel15.setText("Slope X:"); + + textSlopeX.setEditable(false); + textSlopeX.setHorizontalAlignment(javax.swing.JTextField.CENTER); + + jLabel16.setText("Slope Y:"); + + textSlopeY.setEditable(false); + textSlopeY.setHorizontalAlignment(javax.swing.JTextField.CENTER); + + jLabel17.setText("Current beam position from slope reference (mm):"); + + jLabel18.setText("Current beam position from offset reference (mm):"); + + jLabel19.setText("6."); + + jLabel20.setText("Align undulators - iterate steps 3 and 4 as beam is aligned - this may take several rounds"); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addComponent(viewer, javax.swing.GroupLayout.PREFERRED_SIZE, 469, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() + .addComponent(viewer, javax.swing.GroupLayout.PREFERRED_SIZE, 471, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(99, 99, 99) + .addComponent(jLabel10)) .addGroup(layout.createSequentialGroup() .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(processVariablePanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() - .addGap(75, 75, 75) - .addComponent(jLabel1) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(textSaturated, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 181, Short.MAX_VALUE)))) - .addGroup(layout.createSequentialGroup() - .addGap(130, 130, 130) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(buttonRefOffAp, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(buttonEnd, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(ckOffsetCheck) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGap(9, 9, 9) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() - .addComponent(jLabel3) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(textOffY)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel5) + .addComponent(jLabel1)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel4) + .addGap(35, 35, 35) + .addComponent(textSaturated, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(buttonStart))) + .addComponent(jLabel12))) + .addComponent(jLabel9) + .addGroup(layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 2, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel11) .addGroup(layout.createSequentialGroup() - .addComponent(jLabel2) - .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(textOffX, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE))))) - .addGap(0, 0, Short.MAX_VALUE))) - .addContainerGap()) + .addComponent(jLabel6) + .addGap(18, 18, 18) + .addComponent(buttonRefOffAp, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel14) + .addGap(18, 18, 18) + .addComponent(buttonRefSlopeAp)))) + .addGroup(layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 2, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(processVariablePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 330, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLabel13) + .addGroup(layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 2, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel7) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(ckOffsetCheck) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(textOffY)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(textOffX, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel16) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(textSlopeY)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel15) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(textSlopeX, javax.swing.GroupLayout.PREFERRED_SIZE, 136, javax.swing.GroupLayout.PREFERRED_SIZE)))))) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel19)) + .addGap(23, 23, 23) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel20) + .addComponent(buttonEnd, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))))))) .addGroup(layout.createSequentialGroup() - .addGap(165, 165, 165) - .addComponent(buttonStart) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))) + .addGap(57, 57, 57) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(timePlotOffset, javax.swing.GroupLayout.PREFERRED_SIZE, 989, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(timePlotSlope, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 989, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jLabel17) + .addComponent(jLabel18)))) + .addContainerGap(19, Short.MAX_VALUE)) ); layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonEnd, buttonRefOffAp, buttonStart}); @@ -206,31 +393,76 @@ public class Pointing extends Panel { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() - .addComponent(viewer, javax.swing.GroupLayout.PREFERRED_SIZE, 716, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(viewer, javax.swing.GroupLayout.PREFERRED_SIZE, 441, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(150, 150, 150) + .addComponent(jLabel17)) .addGroup(layout.createSequentialGroup() - .addGap(86, 86, 86) - .addComponent(buttonStart) - .addGap(73, 73, 73) + .addGap(17, 17, 17) + .addComponent(jLabel10) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel1) - .addComponent(textSaturated, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(buttonStart) + .addComponent(jLabel1)) .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(textSaturated, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel5) + .addComponent(jLabel4)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel12) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(processVariablePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(97, 97, 97) - .addComponent(buttonRefOffAp) - .addGap(74, 74, 74) - .addComponent(ckOffsetCheck) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel9) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel2) - .addComponent(textOffX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(3, 3, 3) + .addComponent(jLabel6) + .addComponent(buttonRefOffAp)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel13) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jLabel3) - .addComponent(textOffY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) - .addGap(18, 18, 18) - .addComponent(buttonEnd))) - .addContainerGap(106, Short.MAX_VALUE)) + .addComponent(jLabel14) + .addComponent(buttonRefSlopeAp)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel11) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jLabel7) + .addComponent(ckOffsetCheck)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2) + .addComponent(textOffX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(3, 3, 3) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(textOffY, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel15) + .addComponent(textSlopeX, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(3, 3, 3) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel16) + .addComponent(textSlopeY, 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(jLabel19) + .addComponent(jLabel20)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel8) + .addComponent(buttonEnd)))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(timePlotSlope, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel18) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(timePlotOffset, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(20, Short.MAX_VALUE)) ); }// //GEN-END:initComponents @@ -246,7 +478,12 @@ public class Pointing extends Panel { private void buttonRefOffApActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRefOffApActionPerformed try{ - runAsync("pointing/reference_offset").handle((ret,ex)->{ + runAsync("pointing/reference_offset").handle((ret,ex)->{ + if (ex!=null){ + showException((Exception)ex); + } else { + showMessage("Reference offset aperture", Str.toString(ret)); + } return ret; }); } catch (Exception ex){ @@ -264,18 +501,59 @@ public class Pointing extends Panel { } }//GEN-LAST:event_buttonEndActionPerformed + private void buttonRefSlopeApActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonRefSlopeApActionPerformed + try{ + runAsync("pointing/reference_slope").handle((ret,ex)->{ + if (ex!=null){ + showException((Exception)ex); + } else { + showMessage("Reference slope aperture", Str.toString(ret)); + } + return ret; + }); + } catch (Exception ex){ + showException(ex); + } + }//GEN-LAST:event_buttonRefSlopeApActionPerformed + + private void ckOffsetCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ckOffsetCheckActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_ckOffsetCheckActionPerformed + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton buttonEnd; private javax.swing.JButton buttonRefOffAp; + private javax.swing.JButton buttonRefSlopeAp; private javax.swing.JButton buttonStart; private javax.swing.JCheckBox ckOffsetCheck; 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 jLabel15; + private javax.swing.JLabel jLabel16; + private javax.swing.JLabel jLabel17; + private javax.swing.JLabel jLabel18; + private javax.swing.JLabel jLabel19; private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel20; private javax.swing.JLabel 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 ch.psi.pshell.swing.ProcessVariablePanel processVariablePanel1; private javax.swing.JTextField textOffX; private javax.swing.JTextField textOffY; private javax.swing.JTextField textSaturated; + private javax.swing.JTextField textSlopeX; + private javax.swing.JTextField textSlopeY; + private ch.psi.pshell.plot.TimePlotJFree timePlotOffset; + private ch.psi.pshell.plot.TimePlotJFree timePlotSlope; private ch.psi.pshell.ui.CamServerViewer viewer; // End of variables declaration//GEN-END:variables } diff --git a/script/config_bernina.py b/script/config_bernina.py new file mode 100644 index 0000000..4f53b5a --- /dev/null +++ b/script/config_bernina.py @@ -0,0 +1,39 @@ +BEAMLINE_NAME = "Bernina" +CAMERA_NAME = "SAROP21-PPRM094" +BEAMLINE_MODE = "SAROP21-ARAMIS:MODE" +BEAMLINE_SELECTED = "SAROP-ARAMIS:BEAMLINE" +FEL_ENERGY = "SARUN03-UIND030:FELPHOTENE" +ATT_ENERGY = "SARFE10-OATT053:UsrRec.ERY" + + +# define aperature motor names +APERTURE_SLOPE_WIDTH_NAME = "SAROP21-OAPU092:MOTOR_W" +APERTURE_SLOPE_HEIGHT_NAME = "SAROP21-OAPU092:MOTOR_H" +APERTURE_OFFSET_WIDTH_NAME = "SARFE10-OAPU044:MOTOR_W" +APERTURE_OFFSET_HEIGHT_NAME = "SARFE10-OAPU044:MOTOR_H" + +# define other devices +SCREEN_PROBE = "SAROP21-PPRM094:PROBE_SP" +SCREEN_PROBE_IN = "SAROP21-PPRM094:IN_POS" +SCREEN_MAX = 4095 +SCREEN_TARGET = "Wafer 100um" + +APERTURE_SLOPE_W_MIN = 5.0 +APERTURE_SLOPE_H_MIN = 5.0 +APERTURE_OFFSET_W_MIN = 2.0 +APERTURE_OFFSET_H_MIN = 2.0 + + +APERTURE_SLOPE_W_DEFAULT = 5.0 +APERTURE_SLOPE_H_DEFAULT = 5.0 +APERTURE_OFFSET_W_DEFAULT = 2.0 +APERTURE_OFFSET_H_DEFAULT = 2.0 + +APERTURE_SLOPE_W_MID = 5.0 +APERTURE_SLOPE_H_MID = 5.0 +APERTURE_OFFSET_W_MID = 2.0 +APERTURE_OFFSET_H_MID = 2.0 + + +ATENUATOR_CAL = 1.0 +ATENUATOR_DEFAULT = 1.0 diff --git a/script/pointing/check_offset.py b/script/pointing/check_offset.py index f5a0ba5..331aa1b 100644 --- a/script/pointing/check_offset.py +++ b/script/pointing/check_offset.py @@ -1,5 +1,7 @@ -st.waitCacheChange(5000) +st.waitCacheChange(2000) val=st.take() fit_pos = val["x_fit_mean"], val["y_fit_mean"] -offset = fit_pos[0] - marker_pos[0], fit_pos[1] - marker_pos[1] -set_return(offset) +offset_offset = fit_pos[0] - marker_pos_offset[0], fit_pos[1] - marker_pos_offset[1] +offset_slope = fit_pos[0] - marker_pos_slope[0], fit_pos[1] - marker_pos_slope[1] +offset_all =offset_offset+offset_slope +set_return(offset_all) diff --git a/script/pointing/config.py b/script/pointing/config.py index 8042ec7..d5160f0 100644 --- a/script/pointing/config.py +++ b/script/pointing/config.py @@ -1,18 +1,40 @@ BEAMLINE_NAME = "Bernina" CAMERA_NAME = "SAROP21-PPRM094" +BEAMLINE_MODE = "SAROP21-ARAMIS:MODE" +BEAMLINE_SELECTED = "SAROP-ARAMIS:BEAMLINE" +FEL_ENERGY = "SARUN03-UIND030:FELPHOTENE" +ATT_ENERGY = "SARFE10-OATT053:UsrRec.ERY" +# define aperature motor names +APERTURE_SLOPE_WIDTH_NAME = "SAROP21-OAPU092:MOTOR_W" +APERTURE_SLOPE_HEIGHT_NAME = "SAROP21-OAPU092:MOTOR_H" +APERTURE_OFFSET_WIDTH_NAME = "SARFE10-OAPU044:MOTOR_W" +APERTURE_OFFSET_HEIGHT_NAME = "SARFE10-OAPU044:MOTOR_H" + +# define other devices +SCREEN_PROBE = "SAROP21-PPRM094:PROBE_SP" +SCREEN_PROBE_IN = "SAROP21-PPRM094:IN_POS" +SCREEN_MAX = 4095 +SCREEN_TARGET = "Wafer 100um" + APERTURE_SLOPE_W_MIN = 0.2 APERTURE_SLOPE_H_MIN = 0.2 -APERTURE_OFFSET_W_MIN = 0.2 -APERTURE_OFFSET_H_MIN = 0.2 +APERTURE_OFFSET_W_MIN = 0.05 +APERTURE_OFFSET_H_MIN = 0.05 APERTURE_SLOPE_W_DEFAULT = 5.0 APERTURE_SLOPE_H_DEFAULT = 5.0 -APERTURE_OFFSET_W_DEFAULT = 5.0 -APERTURE_OFFSET_H_DEFAULT = 5.0 +APERTURE_OFFSET_W_DEFAULT = 2.0 +APERTURE_OFFSET_H_DEFAULT = 2.0 + +APERTURE_SLOPE_W_MID = 2.0 +APERTURE_SLOPE_H_MID = 2.0 +APERTURE_OFFSET_W_MID = 1.5 +APERTURE_OFFSET_H_MID = 1.5 -ATENUATOR_CAL = 0.01 -ATENUATOR_DEFAULT = 0.05 \ No newline at end of file +ATENUATOR_CAL = 0.001 +ATENUATOR_DEFAULT = 1.0 + diff --git a/script/pointing/config_bkg.py b/script/pointing/config_bkg.py new file mode 100644 index 0000000..eb6c606 --- /dev/null +++ b/script/pointing/config_bkg.py @@ -0,0 +1,18 @@ +BEAMLINE_NAME = "Bernina" +CAMERA_NAME = "SAROP21-PPRM094" + + +APERTURE_SLOPE_W_MIN = 0.15 +APERTURE_SLOPE_H_MIN = 0.15 +APERTURE_OFFSET_W_MIN = 0.15 +APERTURE_OFFSET_H_MIN = 0.15 + + +APERTURE_SLOPE_W_DEFAULT = 5.0 +APERTURE_SLOPE_H_DEFAULT = 5.0 +APERTURE_OFFSET_W_DEFAULT = 5.0 +APERTURE_OFFSET_H_DEFAULT = 5.0 + + +ATENUATOR_CAL = 1.0 +ATENUATOR_DEFAULT = 1.0 \ No newline at end of file diff --git a/script/pointing/device_define.py b/script/pointing/device_define.py new file mode 100644 index 0000000..4fdc52f --- /dev/null +++ b/script/pointing/device_define.py @@ -0,0 +1,27 @@ +# Map short names to the corresponding variable names +motor_short_names = { + "ap_s_w": APERTURE_SLOPE_WIDTH_NAME, + "ap_s_h": APERTURE_SLOPE_HEIGHT_NAME, + "ap_o_w": APERTURE_OFFSET_WIDTH_NAME, + "ap_o_h": APERTURE_OFFSET_HEIGHT_NAME, +} + +# Loop to define and configure the motors +for short_name, full_name in motor_short_names.items(): + dev = EpicsMotor(short_name, full_name) # Create the motor + dev.monitored = True # Enable monitoring + add_device(dev, True) # Add the device to the system +# show_panel(dev) + + +# define reference screen +dev = DiscretePositioner("camera_screen", SCREEN_PROBE) +dev.monitored = True +add_device(dev, True) + + + +dev = Positioner("att", "SARFE10-OATT053:UsrRec.TD", "SARFE10-OATT053:UsrRec.TR1") +dev.monitored = True +add_device(dev, True) + diff --git a/script/pointing/end.py b/script/pointing/end.py index e1b862c..470ef68 100644 --- a/script/pointing/end.py +++ b/script/pointing/end.py @@ -1,3 +1,8 @@ -attenuator.write(ATENUATOR_DEFAULT) +att.write(ATENUATOR_DEFAULT) st.close() +camera_screen.move("Free") +ap_s_w.moveAsync(APERTURE_SLOPE_W_DEFAULT) +ap_s_h.moveAsync(APERTURE_SLOPE_H_DEFAULT) +ap_o_w.moveAsync(APERTURE_OFFSET_W_DEFAULT) +ap_o_h.move(APERTURE_OFFSET_H_DEFAULT) diff --git a/script/pointing/local.py b/script/pointing/local.py index e82c678..50b2066 100644 --- a/script/pointing/local.py +++ b/script/pointing/local.py @@ -1,14 +1,16 @@ +# load configuration run("pointing/config") +# configure devices +run("pointing/device_define") + def check(): if beamline_name.read() != BEAMLINE_NAME: raise "Invalid beamline mode" -camera_screen.setSettlingCondition(ChannelSettlingCondition("SAROP21-PPRM094:IN_POS", 1, None, 'i')) - - +camera_screen.setSettlingCondition(ChannelSettlingCondition(SCREEN_PROBE_IN, 1, None, 'i')) def get_saturated_pixels(img): img = flatten(img) - return sum([1 if v>=4095 else 0 for v in img]) \ No newline at end of file + return sum([1 if v>=SCREEN_MAX else 0 for v in img]) \ No newline at end of file diff --git a/script/pointing/main.py b/script/pointing/main.py index 540a7ed..2556e6a 100644 --- a/script/pointing/main.py +++ b/script/pointing/main.py @@ -3,50 +3,9 @@ run("pointing/start") -#Close aperture offset -aperture_offset_width.move(APERTURE_OFFSET_W_MIN) -aperture_offset_height.move(APERTURE_OFFSET_H_MIN) - - -#Move marker to the fit position -val=st.take() -fit_pos = val["x_fit_mean"], val["y_fit_mean"] -x_axis, y_axis = val["x_axis"], val["y_axis"] -fit_pos_px_x = int(fit_pos[0] / cam_server.config.spatialCalScaleX - cam_server.config.spatialCalOffsetX) -fit_pos_px_y = int(fit_pos[1] / cam_server.config.spatialCalScaleY - cam_server.config.spatialCalOffsetY) -fit_pos_px = [fit_pos_px_x, fit_pos_px_y] - -print fit_pos_px - -#marker_pos_px = cam_server.getInstanceConfigValue("Marker") -#marker_pos_x = (marker_pos_px[0] + cam_server.config.spatialCalOffsetX) * cam_server.config.spatialCalScaleX -#marker_pos_y = (marker_pos_px[1] + cam_server.config.spatialCalOffsetY) * cam_server.config.spatialCalScaleY -#marker_pos = [marker_pos_x, marker_pos_y] -#print marker_pos_px - -cam_server.setInstanceConfigValue("Marker", fit_pos_px) -marker_pos_px = fit_pos_px - - -#Open aperture offset -aperture_offset_width.move(APERTURE_OFFSET_W_DEFAULT) -aperture_offset_height.move(APERTURE_OFFSET_H_DEFAULT) - - -time.sleep(0.5) -st.waitCacheChange(5000) -val=st.take() -fit_pos = val["x_fit_mean"], val["y_fit_mean"] -marker_pos_x = (marker_pos_px[0] + cam_server.config.spatialCalOffsetX) * cam_server.config.spatialCalScaleX -marker_pos_y = (marker_pos_px[1] + cam_server.config.spatialCalOffsetY) * cam_server.config.spatialCalScaleY -marker_pos = [marker_pos_x, marker_pos_y] - - -offset = fit_pos[0] - marker_pos[0], fit_pos[1] - marker_pos[1] - -print offset - +run("pointing/reference_offset") +run("pointing/check_offset") #1/0 diff --git a/script/pointing/reference_offset.py b/script/pointing/reference_offset.py index c43893f..5dd2568 100644 --- a/script/pointing/reference_offset.py +++ b/script/pointing/reference_offset.py @@ -5,7 +5,7 @@ try: aperture_offset_height.move(APERTURE_OFFSET_H_MIN) aperture_offset_width.waitReady(-1) - + time.sleep(2.0) #Move marker to the fit position val=st.take() fit_pos = val["x_fit_mean"], val["y_fit_mean"] @@ -21,20 +21,26 @@ try: #marker_pos_y = (marker_pos_px[1] + cam_server.config.spatialCalOffsetY) * cam_server.config.spatialCalScaleY #marker_pos = [marker_pos_x, marker_pos_y] #print marker_pos_px + + cam_server.setInstanceConfigValue("Markeroffset", fit_pos_px) + + #cam_server.setInstanceConfigValue("Marker2", "dummy") - cam_server.setInstanceConfigValue("Marker", fit_pos_px) marker_pos_px = fit_pos_px marker_pos_x = (marker_pos_px[0] + cam_server.config.spatialCalOffsetX) * cam_server.config.spatialCalScaleX marker_pos_y = (marker_pos_px[1] + cam_server.config.spatialCalOffsetY) * cam_server.config.spatialCalScaleY - marker_pos = [marker_pos_x, marker_pos_y] + marker_pos_offset = [marker_pos_x, marker_pos_y] finally: #Open aperture offset - aperture_offset_width.moveAsync(APERTURE_OFFSET_W_DEFAULT) - aperture_offset_height.move(APERTURE_OFFSET_H_DEFAULT) + aperture_offset_width.moveAsync(APERTURE_OFFSET_W_MID) + aperture_offset_height.move(APERTURE_OFFSET_H_MID) aperture_offset_width.waitReady(-1) time.sleep(0.5) + + +set_return('Offset aperture referenced and opened to mid position') \ No newline at end of file diff --git a/script/pointing/reference_slope.py b/script/pointing/reference_slope.py new file mode 100644 index 0000000..9a73d2d --- /dev/null +++ b/script/pointing/reference_slope.py @@ -0,0 +1,47 @@ + +try: + #Close aperture offset + ap_s_w.moveAsync(APERTURE_SLOPE_W_MIN) + ap_s_h.move(APERTURE_SLOPE_H_MIN) + ap_s_w.waitReady(-1) + + time.sleep(2.0) + #Move marker to the fit position + val=st.take() + fit_pos = val["x_fit_mean"], val["y_fit_mean"] + #x_axis, y_axis = val["x_axis"], val["y_axis"] + fit_pos_px_x = int(fit_pos[0] / cam_server.config.spatialCalScaleX - cam_server.config.spatialCalOffsetX) + fit_pos_px_y = int(fit_pos[1] / cam_server.config.spatialCalScaleY - cam_server.config.spatialCalOffsetY) + fit_pos_px = [fit_pos_px_x, fit_pos_px_y] + + print fit_pos_px + + #marker_pos_px = cam_server.getInstanceConfigValue("Marker") + #marker_pos_x = (marker_pos_px[0] + cam_server.config.spatialCalOffsetX) * cam_server.config.spatialCalScaleX + #marker_pos_y = (marker_pos_px[1] + cam_server.config.spatialCalOffsetY) * cam_server.config.spatialCalScaleY + #marker_pos = [marker_pos_x, marker_pos_y] + #print marker_pos_px + + cam_server.setInstanceConfigValue("Markerslope", fit_pos_px) + + #cam_server.setInstanceConfigValue("Marker2", "dummy") + + marker_pos_px = fit_pos_px + + marker_pos_x = (marker_pos_px[0] + cam_server.config.spatialCalOffsetX) * cam_server.config.spatialCalScaleX + marker_pos_y = (marker_pos_px[1] + cam_server.config.spatialCalOffsetY) * cam_server.config.spatialCalScaleY + marker_pos_slope = [marker_pos_x, marker_pos_y] + + + + +finally: + #Open aperture offset + ap_s_w.moveAsync(APERTURE_SLOPE_W_MID) + ap_s_h.move(APERTURE_SLOPE_H_MID) + ap_s_w.waitReady(-1) + time.sleep(0.5) + + + +set_return('Slope aperture referenced and opened to mid position') \ No newline at end of file diff --git a/script/pointing/start.py b/script/pointing/start.py index 43aad3c..97a7d61 100644 --- a/script/pointing/start.py +++ b/script/pointing/start.py @@ -1,11 +1,14 @@ -aperture_offset_width = aperture_slope_width #TODO: REMOVE -aperture_offset_height = aperture_slope_height - -camera_screen.move("Wafer 100um") +Beamline_mode = caget(BEAMLINE_MODE) +Beamline_selected = caget(BEAMLINE_SELECTED) +if Beamline_selected != BEAMLINE_NAME: + show_message('Beamline selected not correct (selected: {}), set to {}'.format(Beamline_selected, BEAMLINE_NAME),"Wrong beamline set",blocking=True) +if Beamline_mode != "Pink": + show_message('Beamline not in pink mode, set beamline to pink',"Wrong beamline set",blocking=True) +camera_screen.move(SCREEN_TARGET) time.sleep(0.2) camera_screen.getSettlingCondition().waitSettled() #ecj -cam_server.start(CAMERA_NAME + '_sp', True) +cam_server.start(CAMERA_NAME + '_pointing', True) cam_server.averaging=10 st = cam_server.stream print('Started camera') @@ -14,4 +17,8 @@ time.sleep(0.5) st.waitCacheChange(5000) #show_panel(cam_server) add_device(st, True) -attenuator.write(ATENUATOR_CAL) \ No newline at end of file +# set the attenuator to current FEL energy and set attenuation +Fel_energy = caget(FEL_ENERGY)*1000 +caput(ATT_ENERGY, Fel_energy) + +att.write(ATENUATOR_CAL)