feat: put current zoom level in redis #251

Merged
perl_d merged 1 commits from feat/put_current_zoom_in_redis into main 2026-10-06 15:52:45 +02:00
4 changed files with 20 additions and 4 deletions
+9
View File
@@ -617,6 +617,15 @@ class BeamlineConfig:
def gridscan_analysis_mode(self, val: GridscanAnalysisMode) -> None:
self.redis.set(f"{self._bl}:gridscan_analysis_mode", str(val))
@property
def current_zoom_level(self) -> float | None:
data = self.redis.get(f"{self._bl}:current_zoom_level")
return float(data) if data is not None else None
@current_zoom_level.setter
def current_zoom_level(self, val: float) -> None:
self.redis.set(f"{self._bl}:current_zoom_level", str(val))
def _get_settings(self) -> BeamlineSettingsModel:
tmp = self.redis.get(f"{self._bl}:settings")
if tmp is None:
+1
View File
@@ -1748,6 +1748,7 @@ class AareDAQ:
self._devs.zoom = val
time.sleep(0.2)
self._devs.samcam_auto(AutoEnum.ONCE)
self._cfg.current_zoom_level = val
def save_beam_location_camera_setting(self) -> None:
"""Persist the camera's current gain/exposure for the current zoom as
+6 -3
View File
@@ -15,6 +15,7 @@ from epics import PV
# - setter with option to do sync/async move
# - property setter, which assumes that sync move is done (excl. zoom, which is async by default)
from aare.beamline_dispatch.protocols import BeamlineDispatch
from aare.daq.config import BeamlineConfig
from aare.devices import aerotech, smargon
from aare.devices.area_detector import AutoEnum, epicsAD
from aare.devices.bec_worker import BECClientWorker
@@ -31,13 +32,14 @@ CHI_ZERO_TOLERANCE_DEG = 1e-3
class BeamlineDevices:
def __init__(self, beamline: MXBeamline, dispatch: BeamlineDispatch):
def __init__(self, beamline: MXBeamline, dispatch: BeamlineDispatch, cfg: BeamlineConfig):
self._cfg = cfg
self._dispatch = dispatch
self._beamline = beamline
BEAMLINE = beamline.value.upper()
self.tell = make_tell_client(beamline)
self.aerotech = aerotech.AerotechController(beamline)
self.bec_worker = BECClientWorker(beamline)
self.bec_worker = BECClientWorker(beamline, cfg=self._cfg)
self._smargon = smargon.Smargon(beamline)
self.exp_shutter = ExperimentalHutchShutter(beamline=self._beamline)
# Personnel Safety System: gates whether the robot is allowed to move.
@@ -125,7 +127,7 @@ class BeamlineDevices:
finally:
beamline = MXBeamline.SIMULATED if simulated else self._beamline
logger.info(f"Restarting BEC worker with simulated={simulated}")
self.bec_worker = BECClientWorker(beamline)
self.bec_worker = BECClientWorker(beamline, cfg=self._cfg)
def restart_tell(self, simulated: bool = False) -> None:
beamline = MXBeamline.SIMULATED if simulated else self._beamline
@@ -197,6 +199,7 @@ class BeamlineDevices:
def set_zoom(self, value: float, /, wait: bool = True):
self._zoom.move(value, wait=wait)
self._cfg.current_zoom_level = value
# Optics
@property
+4 -1
View File
@@ -15,6 +15,7 @@ from bec_lib.device import RPCError, ScanRequestError
from bec_lib.service_config import ServiceConfig
from aare.beamline_dispatch.beamline_dispatch import get_beamline_dispatch
from aare.daq.config import BeamlineConfig
logger = setup_logger("aareDAQ")
@@ -69,11 +70,12 @@ def _bec_state_to_aare_state(bec_state: str) -> BeamlineStateEnum:
class BECClientWorker:
def __init__(self, beamline: MXBeamline, name: str = "default"):
def __init__(self, beamline: MXBeamline, cfg: BeamlineConfig, name: str = "default"):
logger.debug(f"initialising BEC worker for {beamline}")
BEAMLINE = beamline.value.lower()
self.beamline = beamline
self._backlight_brightness: Any
self._cfg = cfg
if self.beamline is MXBeamline.X06DA:
self._beamline_name = "pxiii"
elif self.beamline is MXBeamline.X10SA:
@@ -527,6 +529,7 @@ class BECClientWorker:
@zoom.setter
def zoom(self, value: float):
self.scans.umv(self._zoom, value, relative=False)
self._cfg.current_zoom_level = value
@property
def ring_current(self) -> float: