DAQ/CONFIG: added failed mount count, plus logic to DAQ.

This commit is contained in:
appleb_m
2025-12-10 13:32:14 +01:00
parent ee2f9a4789
commit 79694798db
2 changed files with 38 additions and 1 deletions
+17
View File
@@ -594,3 +594,20 @@ class BeamlineConfig:
self.__client.delete(f"{self.__bl}:auto_params")
else:
self.__client.set(f"{self.__bl}:auto_params", params.model_dump_json())
@property
def failed_mount_count(self) -> int:
tmp = self.__client.get(f"{self.__bl}:failed_mount_count")
if tmp is None:
return 0
return tmp
@failed_mount_count.setter
def failed_mount_count(self, count:int):
if count == 0:
self.__client.delete(f"{self.__bl}:failed_mount_count")
else:
self.__client.set(f"{self.__bl}:failed_mount_count", count)
def increment_failed_mount_count(self) -> int:
return int(self.__client.incr(f"{self.__bl}:failed_mount_count"))
+21 -1
View File
@@ -322,6 +322,23 @@ class AareDAQ:
self.__cfg.state_busy = False
raise
def __mount_failure_handler(self):
failed = self.__cfg.increment_failed_mount_count()
if failed == 2:
self.__devs.tell.dry(wait=True)
elif failed > 2:
self.__devs.tell.dry(wait=True, wait_cold=False)
raise MountingFailed(f"Repeated drying failure, moved to park. "
f"\n Please get a cup of coffee.\nAfter the robot has dried, "
f"check the sample positions that have been missed, if no samples continue!"
f"\nOtherwise there may be a critical error so please let your local "
f"contact for support")
elif failed > 3:
self.__devs.tell.dry(wait=True, wait_cold=False)
raise MountingFailed(f"Repeated drying failure, moved to park"
f"\nThere either really is no sample or"
f"a critical failure.\nPlease check the dewar and if a sample, "
f"please contact the MX team")
def __mount(self, target: SampleShortInfo | None):
self.__set_state(BeamlineStateEnum.RobotSampleExchange)
@@ -393,7 +410,7 @@ class AareDAQ:
if value is not None:
if value == "No Pin in Gripper":
logger.error("No sample was detected in gripper")
self.__devs.tell.dry(wait=True)
self.__mount_failure_handler()
self.__aare.sample_failed(target, failed_comment = "No sample was detected in gripper")
raise MountingFailed(f"No sample was detected in gripper, drying gripper {target.sample_name} {target.location} {target.pin}")
elif value == "dry":
@@ -406,13 +423,16 @@ class AareDAQ:
if not mounted:
logger.error(f"Failed to mount target: {target.db_id} {target.location} {target.pin}")
self.__aare.sample_failed(target, failed_comment = "No sample was mounted")
self.__mount_failure_handler()
raise MountingFailed(f"No Sample detected on smart magent: {target.sample_name} {target.location} {target.pin}")
if target is not None:
self.__aare.sample_mounted(target)
logger.info(f"Target mounted: {target.db_id} {target.location} {target.pin}")
self.__cfg.failed_mount_count = 0
self.save_screenshot_db(target.db_id, f"sample_mounted")
else:
self.__cfg.failed_mount_count = 0
logger.info(f"Target is None: {target}")
self.__cfg.current_sample = target