TELL: get event from Tell when going to dry or if gripper detects no sample and then handle it correctly in the DAQ. Added protection to get_mounted_sample if repsonse is None or if fails to decode response
This commit is contained in:
+22
-26
@@ -297,7 +297,7 @@ class AareDAQ:
|
||||
# mount sample
|
||||
self.__aare.sample_unmounted(curr_sample)
|
||||
logger.info(f"Moving tell to mount")
|
||||
self.__devs.tell.mount(
|
||||
value = self.__devs.tell.mount(
|
||||
address=target.tell_address(),
|
||||
force=True,
|
||||
auto_unmount=True,
|
||||
@@ -306,20 +306,30 @@ class AareDAQ:
|
||||
timeout=360,
|
||||
)
|
||||
logger.debug(f"Post tell mount, pre db input")
|
||||
if not self.__devs.tell.get_mounted_sample():
|
||||
logger.info("No sample was mounted")
|
||||
if value is not None:
|
||||
if value == "No Pin in Gripper":
|
||||
logger.info("No sample was detected in gripper")
|
||||
self.__aare.sample_failed(target, failed_comment = "No sample was detected in gripper")
|
||||
raise Exception("No sample was detected in gripper")
|
||||
elif value == "dry":
|
||||
logger.info("Robot is drying")
|
||||
else:
|
||||
logger.info(f"Event detected from robot: {value}")
|
||||
|
||||
mounted = self.__devs.tell.get_mounted_sample()
|
||||
logger.info(f"response from tell {mounted}")
|
||||
if not mounted:
|
||||
logger.info(f"Failed to mount target: {target.db_id} {target.location} {target.pin}")
|
||||
self.__aare.sample_failed(target, failed_comment = "No sample was mounted")
|
||||
raise Exception("No sample was mounted")
|
||||
|
||||
if target is not None:
|
||||
self.__aare.sample_mounted(target)
|
||||
logger.info(f"Target mounted: {target.db_id} {target.location} {target.pin}")
|
||||
self.save_screenshot_db(target.db_id, f"sample_mounted")
|
||||
else:
|
||||
# check = self.__devs.tell.check_smart_magnet_mounted()
|
||||
# if check:
|
||||
if target is not None:
|
||||
self.__aare.sample_mounted(target)
|
||||
logger.info(f"target is mounted??? {target}")
|
||||
self.save_screenshot_db(target.db_id, f"sample_mounted")
|
||||
else:
|
||||
logger.info(f"target is None: {target}")
|
||||
self.__cfg.current_sample = target
|
||||
logger.info(f"Target is None: {target}")
|
||||
self.__cfg.current_sample = target
|
||||
|
||||
|
||||
# TODO: Need to know if dry needs to happen
|
||||
@@ -952,20 +962,6 @@ class AareDAQ:
|
||||
box_time = time.perf_counter()
|
||||
m = self.__mlbox.predict(curr_image, filename=None, preferred_class = (3,0))
|
||||
logger.info(f"time to predict: {time.perf_counter() - box_time}")
|
||||
if box:
|
||||
logger.info(f'found box: {box}')
|
||||
cls, x1, y1, x2, y2 = box
|
||||
boxes[angle] = (x1, y1, x2, y2)
|
||||
if cls == 0:
|
||||
logger.info(f"loop all for angle {angle}")
|
||||
boxes[angle] = (x1, y1, x2, y2)
|
||||
logger.info(f'box added to boxes: {boxes}')
|
||||
elif cls == 3:
|
||||
boxes[angle] = (x1, y1, x2, y2)
|
||||
else:
|
||||
logger.debug(f"no loop found only class: {cls} pin or xtal")
|
||||
else:
|
||||
logger.info(f'no box found for angle {angle}')
|
||||
|
||||
if not m or not m.box:
|
||||
logger.info(f"no box found for angle {angle}")
|
||||
|
||||
@@ -331,17 +331,20 @@ class TellClient:
|
||||
wait_timeout = timeout + self.estimate_mounting_time(segment)
|
||||
logger.info("waiting for mount to complete")
|
||||
if wait and segment in "ABCDEF":
|
||||
event, value = self.pshell.wait_events({"state": None, "motion_task": "dry", "gripper_detection" : None}, timeout=wait_timeout)
|
||||
event, value = self.pshell.wait_events({"state": None, "motion_task": "dry", "gripper_detection" : "No Pin in Gripper"}, timeout=wait_timeout)
|
||||
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}: "
|
||||
)
|
||||
return value
|
||||
elif event == "gripper_detection":
|
||||
logger.info(f"gripper detection: {event} occurred with value: {value}")
|
||||
return value
|
||||
elif event == "motion_task" and value == "dry":
|
||||
logger.info(f"event: {event} occurred with value: {value}")
|
||||
logger.info(" Drying occurring, releasing interface to user")
|
||||
return value
|
||||
else:
|
||||
logger.info(f"Unexpected event: {event} occurred with value: {value}")
|
||||
logger.info("Checking command completed okay anyway")
|
||||
@@ -354,7 +357,7 @@ class TellClient:
|
||||
timeout=wait_timeout, msg=f"Mount failed for {segment}{puck}-{sample}: "
|
||||
)
|
||||
logger.info("post waiting")
|
||||
return self._last_cmd_id
|
||||
return None
|
||||
|
||||
def unmount(self, force=False, wait=False, timeout=360.0):
|
||||
# Force has a meaning, will unmount even if smart magnet is not detecting sample
|
||||
@@ -437,8 +440,7 @@ class TellClient:
|
||||
ret = self._simulated_mounted_sample
|
||||
else:
|
||||
ret = self.pshell.eval("get_setting('mounted_sample_position')&").strip()
|
||||
|
||||
if len(ret) == 0:
|
||||
if not ret or len(ret) == 0:
|
||||
return None
|
||||
|
||||
match = re.match(r"([A-Z])(\d)(\d{1,2})", ret)
|
||||
@@ -448,7 +450,8 @@ class TellClient:
|
||||
dewar_location = DewarAddress(segment=segment, pos=int(puck))
|
||||
return SampleDewarAddress(puck=dewar_location, pin=int(sample))
|
||||
else:
|
||||
print("Failed to decode string!")
|
||||
logger.warning(f"Failed to decode mounted sample position: {ret}")
|
||||
return None
|
||||
|
||||
def get_system_check(self):
|
||||
if self.__simulation:
|
||||
|
||||
Reference in New Issue
Block a user