GUI/DAQ: changed how tell mounting errors are handled. need to be tested

This commit is contained in:
appleb_m committed 2025-12-10 16:05:36 +01:00
1 parent 521a488ec6
commit 116aa51fdd
5 files changed
+146 -38

No files matched your search

+22 -17
View File
@@ -322,23 +322,26 @@ class AareDAQ:
self.__cfg.state_busy = False
raise
def __mount_failure_handler(self):
def __mount_failure_handler(self, mount_error):
failed = self.__cfg.increment_failed_mount_count()
if failed == 2:
self.__devs.tell.dry(wait=True)
elif failed > 2:
if failed >=4:
self.__devs.tell.dry(wait=True, wait_cold=False)
raise MountingFailed(f"Repeated drying failure, moved to park. "
raise CriticalTellException(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")
elif failed >=3:
self.__devs.tell.dry(wait=True, wait_cold=False)
raise WarningTellException(f"Continued to not find a sample, drying robot in park for 10 minutes. "
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")
elif failed == 2:
self.__devs.tell.dry(wait=True)
raise MountingFailed(f"Drying gripper: repeated error: {mount_error}")
else:
raise MountingFailed(f"{mount_error}")
def __mount(self, target: SampleShortInfo | None):
self.__set_state(BeamlineStateEnum.RobotSampleExchange)
@@ -409,10 +412,11 @@ class AareDAQ:
logger.debug(f"Post tell mount, pre db input")
if value is not None:
if value == "No Pin in Gripper":
logger.error("No sample was detected in gripper")
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}")
mount_error = "No sample was detected in gripper"
logger.error(mount_error)
self.__aare.sample_failed(target, failed_comment = mount_error)
self.__mount_failure_handler(string=mount_error)
raise MountingFailed(f"{mount_error}: drying gripper {target.sample_name} {target.location} {target.pin}")
elif value == "dry":
logger.info("Robot is drying")
else:
@@ -421,9 +425,10 @@ class AareDAQ:
mounted = self.__devs.tell.get_mounted_sample()
logger.info(f"response from tell {mounted}")
if not mounted:
logger.error(f"Failed to mount target: {target.db_id} {target.location} {target.pin}")
mount_error = "Failed to mount target"
logger.error(f"{mount_error}: {target.db_id} {target.location} {target.pin}")
self.__aare.sample_failed(target, failed_comment = "No sample was mounted")
self.__mount_failure_handler()
self.__mount_failure_handler(string=mount_error)
raise MountingFailed(f"No Sample detected on smart magent: {target.sample_name} {target.location} {target.pin}")
if target is not None:
+22 -1
View File
@@ -25,7 +25,8 @@ from urllib3.exceptions import InsecureRequestWarning
from aaredaq import auth
from aaredaqlib.beamline import mx_beamline
from aaredaq.config import BeamlineConfig
from aaredaq.daq import AareDAQ, LoopCenteringFailed, TransformationInvalidException, MountingFailed
from aaredaq.daq import (AareDAQ, LoopCenteringFailed, TransformationInvalidException,
MountingFailed, WarningTellException, CriticalTellException)
app = FastAPI()
@@ -259,6 +260,16 @@ async def mount(dbid: int, token: str = Depends(oauth2_scheme), reference: bool
status_code=api_status.HTTP_404_NOT_FOUND,
detail=f"{e}",
)
except WarningTellException(Exception) as e:
raise HTTPException(
status_code=api_status.HTTP_410_GONE,
detail=f"{e}",
)
except CriticalTellException as e:
raise HTTPException(
status_code=api_status.HTTP_417_EXPECTATION_FAILED,
detail=f"{e}"
)
except Exception as e:
raise HTTPException(
status_code=api_status.HTTP_500_INTERNAL_SERVER_ERROR,
@@ -411,6 +422,16 @@ async def auto(s: SampleShortInfo, token: str = Depends(oauth2_scheme)):
status_code=api_status.HTTP_404_NOT_FOUND,
detail=f"{e}",
)
except WarningTellException(Exception) as e:
raise HTTPException(
status_code=api_status.HTTP_410_GONE,
detail=f"{e}",
)
except CriticalTellException as e:
raise HTTPException(
status_code=api_status.HTTP_417_EXPECTATION_FAILED,
detail=f"{e}"
)
except Exception as e:
logger.error(f"Exception in auto: {e}")
raise HTTPException(