Defining a bec device pv as a variable that can be called is significantly faster than calling motor.postion or motor.low_limit everytime. (~6 us compared to 200 ms)

This commit is contained in:
appleb_m
2026-06-24 15:30:01 +02:00
parent dace8ad248
commit 1ca4e5cc23
+13 -11
View File
@@ -40,8 +40,10 @@ class BeamlineDevices:
self.__smargon = smargon.Smargon(beamline)
self.exp_shutter = ExperimentalHutchShutter(beamline=self._beamline)
#only used at the moment to get hlm and llm from BEC
self.__dtz = self.bec_worker.dev.det_z
#faster to define the dtz object here than in functions and then use
self.__dtz_rbk = self.bec_worker.dev.det_z.position
self.__dtz_llm= self.bec_worker.dev.det_z.low_limit
self.__dtz_hlm= self.bec_worker.dev.det_z.high_limit
self.dtz_mod = cfg_get('daq.detector_distance_limit_modifier', 1.0)
#TODO convert epics pvs to BEC
self.__sample_cam = epicsAD(f"{BEAMLINE}-ES-MS:")
@@ -263,20 +265,20 @@ class BeamlineDevices:
# Detector Z
@property
def dtz(self) -> float:
return self.bec_worker.get_det_z()
return self.__dtz_rbk
@dtz.setter
def dtz(self, value: float):
self.set_dtz(value, wait=True)
def set_dtz(self, value: float, /, wait: bool = True):
if value < self.__dtz.low_limit:
if value < self.__dtz_llm:
#raise ValueError(f"Detector distance cannot be less than {self.detector_distance_minimum} mm")
logger.warning(f"Requested detector distance {value} is less than minimum: {self.__dtz.low_limit}, setting to minimum")
value = self.__dtz.low_limit + self.dtz_mod
if value > self.__dtz.high_limit:
logger.warning(f"Requested detector distance {value} is greater than maximum: {self.__dtz.high_limit}, setting to maximum")
value = self.__dtz.high_limit - self.dtz_mod
logger.warning(f"Requested detector distance {value} is less than minimum: {self.__dtz_llm}, setting to minimum")
value = self.__dtz_llm + self.dtz_mod
if value > self.__dtz_hlm:
logger.warning(f"Requested detector distance {value} is greater than maximum: {self.__dtz_hlm}, setting to maximum")
value = self.__dtz_hlm - self.dtz_mod
if wait:
status = self.bec_worker.det_z(value, timeout=60)
return status
@@ -286,11 +288,11 @@ class BeamlineDevices:
@property
def dtz_low(self) -> float:
return self.__dtz.get("LLM")
return self.__dtz_llm
@property
def dtz_high(self) -> float:
return self.__dtz.get("HLM")
return self.__dtz_hlm
@property
def aerotech_pos(self) -> AerotechCoordinate: