diff --git a/src/aare/daq/daq.py b/src/aare/daq/daq.py index 22628291..d27ca656 100644 --- a/src/aare/daq/daq.py +++ b/src/aare/daq/daq.py @@ -1143,6 +1143,17 @@ class AareDAQ: ) raise + except TellCommunicationError as e: + self._last_mount_error_message = str(e) or "Mount failed" + logger.error(f"Tell communication error occured: {e}") + self._handle_operation_error( + operation=DAQOperation.MOUNT if sample is not None else DAQOperation.UNMOUNT, + sample=sample, + error=e, + event_type=SampleEventType.MOUNTFAILED, + ) + raise + except Exception as e: self._last_mount_error_message = str(e) or "Mount failed" logger.error(f"Mount failed: {e}") diff --git a/src/aare/devices/tell_client.py b/src/aare/devices/tell_client.py index 85743544..5c06354b 100755 --- a/src/aare/devices/tell_client.py +++ b/src/aare/devices/tell_client.py @@ -279,12 +279,6 @@ class TellClient: ) logger.info(f"event: {event} occurred with value: {value}") if event is None or event == "state": - # TELL reports a state transition (typically "Busy" then - # "Ready"). Event timing means we sometimes observe the - # intermediate "Busy", and the value can arrive quoted or - # unquoted, so we do not trust the event value here. Instead - # wait for the mount to finish and let check_command_ok be - # the sole authority on success/failure. state_value = str(value).strip().strip('"\'').lower() if state_value == "busy": logger.warning("got busy response from robot, waiting for mount to complete") @@ -293,12 +287,6 @@ class TellClient: timeout=wait_timeout, msg=f"Mount {segment}{puck}-{sample}: " ) logger.info(f"Check command okay response: {msg}") - # check_command_ok blocks (wait_not_busy) until the whole - # mount sequence has finished, so the gripper-detection event - # we observed as an intermediate "state"/Busy event is now - # resolved. The robot's own record is authoritative: if it - # reports nothing mounted, the gripper was empty (no pin), - # which we must surface rather than reporting success. if self.get_mounted_sample() is None: logger.warning("Mount command completed but robot reports no sample mounted") return TellEventValueEnum.NO_PIN_IN_GRIPPER @@ -348,10 +336,11 @@ class TellClient: ) logger.info("post waiting") return TellEventValueEnum.SUCCESS - + except TellCommunicationError: + raise except Exception as e: logger.error(f"Exception occurred: {e}") - raise TellCommunicationError(message=f"Mount {segment}{puck}-{sample}", critical=True) + raise TellCommunicationError(message=f"Error during mount {segment}{puck}-{sample}: {e}", critical=True) def unmount(self, force=False, wait=False, timeout=360.0): if self.is_busy():