From 77d81c182e12854ff14f084abfd7dc6fc7d34f5f Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Thu, 18 Sep 2025 10:11:10 +0200 Subject: [PATCH] DAQ: attempted fix of sample_geometry bug to handle error when the ABR disconnects. --- daq/src/aaredaq/daq.py | 46 +++++++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/daq/src/aaredaq/daq.py b/daq/src/aaredaq/daq.py index bf083128..6c51050d 100644 --- a/daq/src/aaredaq/daq.py +++ b/daq/src/aaredaq/daq.py @@ -650,30 +650,44 @@ class AareDAQ: zoom = self.__devs.zoom abr_pos = self.__cfg.abr_meas_pos try: - return SampleGeometryModel( + aerotech_coord = Coordinate( + x=self.__devs.gmx.value - abr_pos.x, + y=self.__devs.gmy.value - abr_pos.y, + z=self.__devs.gmz.value - abr_pos.z, + ) + sample_geom = SampleGeometryModel( beam_location_pxl=self.__cfg.beam_mark_coeff.apply(zoom), pixel_in_mm=self.__cfg.pixel_to_mm(zoom), omega_deg=self.__devs.aerotech.omega, smargon=self.__devs.smargon.readback, beam_size_mm=self.__cfg.beam_size_mm, - aerotech=Coordinate( - x=self.__devs.gmx.value - abr_pos.x, - y=self.__devs.gmy.value - abr_pos.y, - z=self.__devs.gmz.value - abr_pos.z, - ), + aerotech=aerotech_coord, aerotech_meas=self.__devs.abr_pos ) + return sample_geom + except Exception as e: - print(f"Error getting sample geometry: {e}") - return SampleGeometryModel( - beam_location_pxl=Coordinate(x=0, y=0), - pixel_in_mm=Coordinate(x=0, y=0), - omega_deg=0.0, - smargon=SmargonCoordinate(sh_mm=Coordinate(x=0, y=0), phi_deg=0.0, chi_deg=0.0), - beam_size_mm=Coordinate(x=0, y=0), - aerotech=Coordinate(x=0, y=0, z=0), - aerotech_meas=self.__devs.abr_pos - ) + + try: + test_x = self.__devs.gmx.value - abr_pos.x + print(f"Error creating sample geometry model: {e}") + print(f"Error not ABR, check smargon then restart server") + raise Exception(f"Error getting sample geometry {e}") + + except: + print(f"Error getting sample geometry: {e}") + print(f"!!!!! ABR MAY HAVE DISCONNECTED !!!!!") + print(f"!!!!! CHECK ABR EPICS PANEL FOR ERRORS!!!!!") + print("!!!!! IF NOT RESTART GUI !!!!!") + return SampleGeometryModel( + beam_location_pxl=self.__cfg.beam_mark_coeff.apply(zoom), + pixel_in_mm=self.__cfg.pixel_to_mm(zoom), + omega_deg=self.__devs.aerotech.omega, + smargon=self.__devs.smargon.readback, + beam_size_mm=self.__cfg.beam_size_mm, + aerotech=Coordinate(x=0.0, y=0.0, z=0.0), + aerotech_meas=self.__devs.abr_pos + ) @property def beam_center(self) -> Tuple[float, float]: