tell: debuging.

This commit is contained in:
appleb_m
2026-06-17 11:40:34 +02:00
parent dde084538c
commit 5bc3e90bb4
3 changed files with 26 additions and 9 deletions
+12
View File
@@ -61,6 +61,12 @@ TRACKED_MOTION_SYNC_EVENTS = {
"Sample get on Puck",
},
}
TRACKED_STATE_EVENTS = {
"state": {
"Ready",
"Busy"
}
}
latest_tell_events = {}
tell_event_history = deque(maxlen=25)
@@ -186,6 +192,12 @@ def extract_tracked_tell_event(event_name, event_data):
return event_name, normalized_data
return None
if event_name in TRACKED_STATE_EVENTS:
allowed_values = TRACKED_STATE_EVENTS[event_name]
if normalized_data in allowed_values:
return event_name, normalized_data
return None
return None
+4 -3
View File
@@ -70,12 +70,12 @@ class PShellTellBackend:
def __init__(self, bl: MXBeamline):
self._url = self._resolve_url(bl)
print(f"Connecting TELL p-shell service at {self._url} ...", end="")
logger.info(f"Connecting TELL p-shell service at {self._url} ...")
hostname = urlparse(self._url).hostname
try:
requests.get(f"{self._url}/history/0", timeout=1.0)
except requests.exceptions.RequestException as e:
print(f"...connection to {hostname} failed")
logger.error(f"...connection to {hostname} failed")
raise TellCommunicationError(
f"TELL connection failed ({hostname})",
base_url=self._url,
@@ -83,7 +83,7 @@ class PShellTellBackend:
operation="GET",
) from e
except requests.ReadTimeout as e:
print(f"...PShell service {hostname} is down")
logger.error(f"...PShell service {hostname} is down")
raise TellCommunicationError(
f"TELL connection timedout ({hostname})",
base_url=self._url,
@@ -92,6 +92,7 @@ class PShellTellBackend:
) from e
self._pshell = PShellClient(self._url)
logger.info(f"...connected to {hostname}")
@staticmethod
def _resolve_url(bl: MXBeamline) -> str:
+10 -6
View File
@@ -52,6 +52,8 @@ class TellEventValueEnum(Enum):
UNMOUNT = "unmount"
MOUNT = "mount"
MANUAL = "manual"
READY = "Ready"
BUSY = "Busy"
class TellClient:
@@ -203,18 +205,18 @@ class TellClient:
logger.info("waiting for mount to complete")
try:
if wait and segment in "ABCDEF":
logger.info("Waiting for events from TELL:")
event, value = self.backend.wait_events(
{
"state": None,
"Motion Task": "dry",
"Motion Task": None,#"dry",
"Gripper detection": None,
"Motion Sync": "Robot Clear after mount",
},
timeout=wait_timeout,
)
logger.info(f"event: {event} occurred with value: {value}")
if event == "state" and value == 'Ready':
logger.warning('READY does not mean mount success')
if event == "state" and str(value) == '"Ready"':
try:
msg = self.check_command_ok(
timeout=wait_timeout, msg=f"Mount {segment}{puck}-{sample}: "
@@ -223,7 +225,7 @@ class TellClient:
return TellEventValueEnum.SUCCESS
except Exception:
raise
if event == "state" and value == 'Busy':
if event == "state" and value == '"Busy"':
logger.warning('got busy response form robot, waiting for mount to complete')
try:
msg = self.check_command_ok(
@@ -238,7 +240,10 @@ class TellClient:
self.check_command_ok(
timeout=wait_timeout, msg=f"Mount {segment}{puck}-{sample}: "
)
return value
if value.lower() == "ready" or value.lower() == '"ready"' or value == "Ready" or str(value.lower()) == "ready" or str(value.lower()) == '"ready"':
return TellEventValueEnum.SUCCESS
else:
raise Exception(f"Unexpected event: {event} occurred with value: {value}")
elif (
event == TellEventTypeEnum.GIPPER_DETECTION.value
and value == TellEventValueEnum.NO_PIN_IN_GRIPPER.value
@@ -306,7 +311,6 @@ class TellClient:
return self._last_cmd_id
def dry(self, heat_time=None, speed=None, wait_cold=None, wait=False):
#TODO add timeout variable????
self.backend.wait_state("Ready", timeout=30.0)
self._last_cmd_id = self.start_cmd("dry", heat_time, speed, wait_cold)
if wait: