Refactor TELL integration and update dependencies.

Replaced direct puck management logic with a WebSocket-based system for real-time updates from TELL. Introduced `tellupdater.py` to handle updates and improved AareDB client usage for cleaner API interactions. Updated `pyproject.toml` files to include dependency changes, ensuring compatibility with new TELL workflows.
This commit is contained in:
GotthardG committed 2025-06-17 13:36:27 +02:00
1 parent a780222d27
commit dc0874d8d4
1 file changed
+32 -1
+32 -1
View File
@@ -21,6 +21,7 @@ aare_db = AareWrapper(bl=beamline)
# Track current state
current_pucks = []
last_pucks_sent = []
def compare_and_report_change(old, new, key_func):
old_ids = set(key_func(p) for p in old)
@@ -33,11 +34,41 @@ def ws_update_samples_info(pucks):
"""Send sample info to TELL robot."""
tell_client.set_samples_info(pucks)
def convert_pucks(puck_list):
return [PuckWithTellPosition(
id=p.id,
puck_name=p.puck_name,
puck_type=getattr(p, 'puck_type', None),
puck_location_in_dewar=getattr(p, 'puck_location_in_dewar', None),
dewar_id=getattr(p, 'dewar_id', None),
dewar_name=getattr(p, 'dewar_name', None),
pgroup=getattr(p, 'pgroup', None),
samples=getattr(p, 'samples', None),
tell_position=getattr(p, 'tell_position', None),
) for p in puck_list]
def pucks_equal(pucks1, pucks2):
# Implement a simple equality check, e.g., comparing sorted ids, or full data
if len(pucks1) != len(pucks2): return False
return all(p1.id == p2.id for p1, p2 in zip(sorted(pucks1, key=lambda p: p.id),
sorted(pucks2, key=lambda p: p.id)))
def timer_update_pucks_beamline():
"""Poll tell for detected pucks, and update the DATABASE with their location."""
global last_pucks_sent
try:
detected_pucks = tell_client.get_detected_pucks()
aare_db.set_pucks_beamline(detected_pucks)
# Convert to list[PuckWithTellPosition]
pwtp_list = convert_pucks(detected_pucks)
# Only send if state changed
if not pucks_equal(pwtp_list, last_pucks_sent):
tell_client.set_samples_info(pwtp_list)
last_pucks_sent = pwtp_list
else:
print("[TIMER] No puck state change, not sending to TELL.")
except Exception as exc:
print(f"[ERROR][Timer] {exc}")