diff --git a/daq_macros.py b/daq_macros.py index a83c7429..4e6da73a 100644 --- a/daq_macros.py +++ b/daq_macros.py @@ -19,6 +19,7 @@ import parseSheet import attenCalc import raddoseLib +import robot_lib from raddoseLib import * import logging logger = logging.getLogger(__name__) @@ -248,6 +249,15 @@ def changeImageCenterHighMag(x,y,czoom): "face_on_omega" : 0 } +def run_robot_recovery_procedure(): + """ Generic recovery procedure to be used during automated + collection""" + # Recover robot + robot_lib.recoverRobot() + # Dry Gripper + robot_lib.dryGripper() + # Park Gripper and cool gripper + robot_lib.cooldownGripper() def run_top_view_optimized(): RE(topview_optimized()) diff --git a/embl_robot.py b/embl_robot.py index 9d540a15..6b9b516f 100644 --- a/embl_robot.py +++ b/embl_robot.py @@ -442,6 +442,7 @@ def unmount(self, gov_robot, puckPos, pinPos, sampID): absPos = (PINS_PER_PUCK*(puckPos%3))+pinPos+1 if getBlConfig('robot_online'): try: + logger.info("Unmounting sample") RobotControlLib.unmount2(absPos) except Exception as e: e_s = str(e) @@ -450,10 +451,24 @@ def unmount(self, gov_robot, puckPos, pinPos, sampID): daq_macros.disableMount() daq_lib.gui_message(e_s + ". FATAL ROBOT ERROR - CALL STAFF! robotOff() executed.") return UNMOUNT_FAILURE - message = "ROBOT unmount2 ERROR: " + e_s - daq_lib.gui_message(message) - logger.error(message) - return UNMOUNT_FAILURE + elif "SE" in e_s: + # In case there is an SE Timeout error, run the recovery procedure + daq_macros.run_robot_recovery_procedure() + try: + # Try to unmount again + RobotControlLib.unmount2(absPos) + except Exception as e: + # If there is an exception again, return UNMOUNT_FAILURE + daq_macros.run_robot_recovery_procedure() + message = f"ROBOT unmount2 ERROR: {e}" + daq_lib.gui_message(message) + logger.error(message) + return UNMOUNT_FAILURE + else: + message = "ROBOT unmount2 ERROR: " + e_s + daq_lib.gui_message(message) + logger.error(message) + return UNMOUNT_FAILURE gov_status = gov_lib.setGovRobot(gov_robot, 'SE') if not gov_status.success: daq_lib.clearMountedSample() diff --git a/robot_lib.py b/robot_lib.py index d9c4bff6..e553f9c2 100644 --- a/robot_lib.py +++ b/robot_lib.py @@ -133,3 +133,6 @@ def openGripper(): def closeGripper(): robot.closeGripper() + +def cooldownGripper(): + robot.cooldownGripper() \ No newline at end of file