Tell: added Tell client for X10SA, corrected print statements and added check for removed status.

This commit is contained in:
2026-01-29 13:51:56 +01:00
parent 808c25eecb
commit 71de06b3d1
+17 -8
View File
@@ -56,11 +56,15 @@ POSITION_HEATER = "pHeatB"
class TellClient:
def __init__(self, bl: MXBeamline):
self.__url = None
beamline = bl.value.lower()
if bl == MXBeamline.SIMULATED:
self.__simulation = True
elif bl == MXBeamline.X06DA:
self.__simulation = False
self.__url = "http://x06da-tell.psi.ch:22222"
self.__url = f"http://{beamline}-tell.psi.ch:22222"
elif bl == MXBeamline.X10SA:
self.__simulation = False
self.__url = f"http://PC17488:22222"
if self.__simulation:
print("TELL P-Shell in SIMULATION mode")
@@ -279,8 +283,13 @@ class TellClient:
def check_command_ok(self, timeout: float = 360.0, msg: str = ""):
self.wait_mount_complete(timeout)
result = self.get_result(self._last_cmd_id)
if "completed" != result["status"]:
raise TellMountFailedException(f"{msg} {result}")
logger.debug(f"{msg} {result}")
status = result["status"]
if "completed" != status:
if "removed" != status:
raise TellMountFailedException(f"{msg} {result}")
else:
return f"{msg} {result}"
def estimate_mounting_time(self, segment) -> int:
try:
@@ -321,12 +330,12 @@ class TellClient:
if self.__simulation:
self._last_cmd_id = random.randint(1000, 9999)
print(
logger.info(
f"simulated mount({segment}, {puck}, {sample}) -> {self._last_cmd_id}"
)
self._simulated_mounted_sample = f"{segment}{puck}{sample}"
if random.random() < 0.1:
print("simulated failed mount")
logger.info("simulated failed mount")
raise TellMountFailedException(f"mount failed for {segment}{puck}")
return self._last_cmd_id
@@ -347,7 +356,7 @@ class TellClient:
if event is None or event == "state":
logger.info(f"event: {event} occurred with value: {value}, checking command completed okay")
self.check_command_ok(
timeout=wait_timeout, msg=f"Mount failed for {segment}{puck}-{sample}: "
timeout=wait_timeout, msg=f"Mount {segment}{puck}-{sample}: "
)
return value
elif event == "gripper_detection":
@@ -361,12 +370,12 @@ class TellClient:
logger.info(f"Unexpected event: {event} occurred with value: {value}")
logger.info("Checking command completed okay anyway")
self.check_command_ok(
timeout=wait_timeout, msg=f"Mount failed for {segment}{puck}-{sample}: "
timeout=wait_timeout, msg=f"Mount {segment}{puck}-{sample}: "
)
elif wait and segment == "X":
logger.info("Loading an auxiliary puck")
self.check_command_ok(
timeout=wait_timeout, msg=f"Mount failed for {segment}{puck}-{sample}: "
timeout=wait_timeout, msg=f"Mount {segment}{puck}-{sample}: "
)
logger.info("post waiting")
return None