From 393b91c2acdcd788332e6cc4bbf52e5979ce2f37 Mon Sep 17 00:00:00 2001 From: x01dc Date: Fri, 6 Mar 2026 14:31:23 +0100 Subject: [PATCH 1/2] now reading encoder values for axes with encoder --- csaxs_bec/devices/omny/galil/lgalil_ophyd.py | 31 ++++++++++++++++---- csaxs_bec/scans/LamNIFermatScan.py | 3 ++ 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/csaxs_bec/devices/omny/galil/lgalil_ophyd.py b/csaxs_bec/devices/omny/galil/lgalil_ophyd.py index 31757fa..b17d429 100644 --- a/csaxs_bec/devices/omny/galil/lgalil_ophyd.py +++ b/csaxs_bec/devices/omny/galil/lgalil_ophyd.py @@ -15,7 +15,6 @@ from csaxs_bec.devices.omny.galil.galil_ophyd import ( GalilAxesReferenced, GalilController, GalilMotorIsMoving, - GalilMotorResolution, GalilSetpointSignal, GalilSignalRO, retry_once, @@ -24,6 +23,19 @@ from csaxs_bec.devices.omny.galil.galil_ophyd import ( logger = bec_logger.logger +class GalilMotorResolution(GalilSignalRO): + @retry_once + @threadlocked + def _socket_get(self): + if self.parent.axis_Id_numeric < 6: + return float( + self.controller.socket_put_and_receive(f"MG encpermm[{self.parent.axis_Id_numeric}]") + ) + else: + return float( + self.controller.socket_put_and_receive(f"MG stppermm[{self.parent.axis_Id_numeric}]") + ) + class LamniGalilController(GalilController): @@ -154,11 +166,18 @@ class LamniGalilReadbackSignal(GalilSignalRO): Returns: float: Readback value after adjusting for sign and motor resolution. """ - current_pos = float(self.controller.socket_put_and_receive(f"TD{self.parent.axis_Id}")) - current_pos *= self.parent.sign - step_mm = self.parent.motor_resolution.get() - return current_pos / step_mm - + if self.parent.axis_Id_numeric < 6: + current_pos = float(self.controller.socket_put_and_receive(f"TP{self.parent.axis_Id}")) + current_pos *= self.parent.sign + encoder_resolution = self.parent.motor_resolution.get() + logger.info(f"Read galil encoder position of axis {self.parent.axis_Id_numeric} to be TP {current_pos} with resolution {encoder_resolution}") + return current_pos / encoder_resolution + else: + current_pos = float(self.controller.socket_put_and_receive(f"TD{self.parent.axis_Id}")) + current_pos *= self.parent.sign + step_mm = self.parent.motor_resolution.get() + return current_pos / step_mm + def read(self): self._metadata["timestamp"] = time.time() val = super().read() diff --git a/csaxs_bec/scans/LamNIFermatScan.py b/csaxs_bec/scans/LamNIFermatScan.py index 128e372..98982c2 100644 --- a/csaxs_bec/scans/LamNIFermatScan.py +++ b/csaxs_bec/scans/LamNIFermatScan.py @@ -169,6 +169,9 @@ class LamNIMixin: self.device_manager.devices.lsamx.read_only = True self.device_manager.devices.lsamy.read_only = True + + #update angle readback before start of the scan + yield from self.stubs.send_rpc_and_wait("lsamrot", "readback.get") yield from self.stubs.send_rpc_and_wait("rtx", "controller.feedback_enable_without_reset") -- 2.52.0 From 8013a6305d02317831c170836d3d489decc54cf6 Mon Sep 17 00:00:00 2001 From: x01dc Date: Fri, 6 Mar 2026 14:32:47 +0100 Subject: [PATCH 2/2] added beck startup --- csaxs_bec/device_configs/ptycho_lamni.yaml | 18 +++++++++++++++++- docs/user/ptychography/flomni.md | 15 ++++++++++++--- docs/user/ptychography/lamni.md | 15 ++++++++++++--- 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/csaxs_bec/device_configs/ptycho_lamni.yaml b/csaxs_bec/device_configs/ptycho_lamni.yaml index cd3c250..63ccf96 100644 --- a/csaxs_bec/device_configs/ptycho_lamni.yaml +++ b/csaxs_bec/device_configs/ptycho_lamni.yaml @@ -271,4 +271,20 @@ rty: enabled: true readOnly: False - +############################################################ +######################### Cameras ########################## +############################################################ +cam_xeye: + description: Camera LamNI Xray eye ID15 + deviceClass: csaxs_bec.devices.ids_cameras.ids_camera.IDSCamera + deviceConfig: + camera_id: 15 + bits_per_pixel: 24 + num_rotation_90: 3 + transpose: false + force_monochrome: true + m_n_colormode: 1 + enabled: true + onFailure: buffer + readOnly: false + readoutPriority: async \ No newline at end of file diff --git a/docs/user/ptychography/flomni.md b/docs/user/ptychography/flomni.md index 185519b..26e8946 100644 --- a/docs/user/ptychography/flomni.md +++ b/docs/user/ptychography/flomni.md @@ -108,12 +108,17 @@ The nano-positioning is controlled by a feedback loop running on a real-time lin Once the loop has started, it is possible to start bec with the flOMNI configuration file. +Starting bec with session will load the scripts +`bec --session flomni` + +The flOMNI scripts can be loaded manually by +`from csaxs_bec.bec_ipython_client.plugins.flomni import Flomni` +`flomni = Flomni(bec)` + Loading the flOMNI configuration (this command will load the OMNY configuration only - isolated from the beamline) `bec.config.update_session_with_file("/bec/csaxs_bec/csaxs_bec/device_configs/flomni_config.yaml")` -Loading the flOMNI scripts -`from csaxs_bec.bec_ipython_client.plugins.flomni import Flomni` -`flomni = Flomni(bec)` + If the realtime system is restarted, bec will lose communication. To restart: `flomni.rt_off()` … then wait a few seconds @@ -138,10 +143,14 @@ This script will first verify that the stages are not in an initialized state, a The positions of the optics stages are stored as stage parameters and are thus linked to the configuration file. Example: The OSAx “in” position can be reviewed by `dev.fosax.user_parameter` Update the value by (example "fosax", "in") by `dev.fosax.update_user_parameter({"in":value})` +Important note: if these values are changed, they are not automatically stored to the config file and will only be available in the current session. `flomni.ffzp_info()` shows info about the available FZPs at the current energy of the beamline. Optional parameter is the photon _energy_ in keV. Example: `flomni.ffzp_info(6.2)` +Documents about availabe optics can be accessed by +`flomni.flomnigui_docs` + The [laser feedback](user.ptychography.flomni.laser_feedback) will be disabled and fine alignment lost if foptx/y are moved! Following functions exist to move the optics in and out, with self-explaining naming. diff --git a/docs/user/ptychography/lamni.md b/docs/user/ptychography/lamni.md index 3a06722..c916b04 100644 --- a/docs/user/ptychography/lamni.md +++ b/docs/user/ptychography/lamni.md @@ -102,13 +102,16 @@ The nano-positioning is controlled by a feedback loop running on a real-time lin Once the loop has started, it is possible to start bec with the LamNI configuration file. -Loading the LamNI configuration (this command will load the LamNI configuration only - isolated from the beamline) -`bec.config.update_session_with_file("/bec/csaxs_bec/csaxs_bec/device_configs/lamni_config.yaml")` +Loading the LamNI scripts is done by starting bec as +`bec --session lamni` -Loading the LamNI scripts +The scripts can alternatively manually be loaded by `from csaxs_bec.bec_ipython_client.plugins.LamNI import LamNI` `lamni = LamNI(bec)` +Loading the LamNI configuration (this command will load the LamNI configuration only - isolated from the beamline) +`bec.config.update_session_with_file("/bec/csaxs_bec/csaxs_bec/device_configs/lamni_config.yaml")` + If the realtime system is restarted, BEC will lose communication. To restart: `lamni.rt_off()` … then wait a 10 seconds `lamni.rt_on()` @@ -152,6 +155,12 @@ The underlying scan function can be called as Use `scans.lamni_fermat_scan?`for detailed information. A prerequisite for scanning is a running feedback system. +### GUI tools + +During operation the BEC GUI will show the relevant cameras or progress information. To manually switch view TAB completion on 'lamni.lamnigui_' will show all options to control the GUI. Most useful +'lamni.lamnigui_show_progress()' will show the measurement progress GUI +'lamnigui_show_xeyealign()' will show the XrayEye alignment GUI + ### X-ray optics alignment The positions of the optics stages are stored as stage parameters and are thus linked to the configuration file. -- 2.52.0