Skip to content

Commit

Permalink
Updates to floco functions
Browse files Browse the repository at this point in the history
  • Loading branch information
vshekar committed Nov 21, 2024
1 parent 35a3969 commit 1ec1798
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 32 deletions.
30 changes: 18 additions & 12 deletions daq_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,20 +238,26 @@ def flocoUnlock():
govMonOn()

def flocoStopOperations():
daq_macros.run_recovery_procedure(stop=True)
lockGUI()
try:
daq_macros.run_recovery_procedure(stop=True)
lockGUI()
except Exception as e:
logger.exception("Error encountered while running flocoStopOperations. Stopping...")

def flocoContinueOperations():
daq_macros.run_recovery_procedure(stop=False)
flocoUnlock()
beamline_support.set_any_epics_pv(daq_utils.beamlineComm + "command_s", "VAL",
json.dumps(
{
"function": "runDCQueue",
"args": [],
"kwargs": {},
}
))
try:
daq_macros.run_recovery_procedure(stop=False)
flocoUnlock()
beamline_support.set_any_epics_pv(daq_utils.beamlineComm + "command_s", "VAL",
json.dumps(
{
"function": "runDCQueue",
"args": [],
"kwargs": {},
}
))
except Exception as e:
logger.exception("Error encountered while running flocoContinueOperations. Stopping...")

def refreshGuiTree():
beamline_support.set_any_epics_pv(daq_utils.beamlineComm+"live_q_change_flag","VAL",1)
Expand Down
57 changes: 37 additions & 20 deletions daq_macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ def run_robot_recovery_procedure():
# Dry Gripper
logger.info("Drying gripper")
robot_lib.dryGripper()
# Dry Gripper
logger.info("Drying gripper, again")
robot_lib.dryGripper()
# Park Gripper and cool gripper
logger.info("Cooling gripper")
robot_lib.cooldownGripper()
Expand Down Expand Up @@ -293,28 +296,42 @@ def run_recovery_procedure(stop=True):
Manual recovery procedure used in daq_lib.flocoStopOperations and daq_lib.flocoContinueOperations
"""
logger.info(f"Running recovery procedure: {'stop operations' if stop else 'continue operations'}")
logger.info("Recovering robot")
robot_lib.recoverRobot()
if not getBlConfig("robot_online") or not getBlConfig("mountEnabled"):
logger.info("Robot is offline or mount is disabled, sample found in gripper. Stopping recovery...")
return
logger.info("Drying gripper")
robot_lib.dryGripper()
logger.info("Homing pins")
from start_bs import home_pins
RE(home_pins())
def check_robot():
if not getBlConfig("robot_online") or not getBlConfig("mountEnabled"):
raise ValueError("Robot is offline or mount is disabled, sample found in gripper. Stopping recovery...")

def run_home_pin():
from start_bs import home_pins
RE(home_pins())

def gov_state_to_se():
gov_lib.setGovRobot(gov_robot, 'SE')

def check_robot_speed():
if not robot_arm.is_full_speed():
logger.error("Robot arm speed is NOT 100%")

def check_beam():
if not (getPvDesc("beamAvailable") or getBlConfig(BEAM_CHECK) == 0):
logger.error("Beam not available, please open shutter")

steps_to_run = {"Recover robot": robot_lib.recoverRobot,
"Check robot status": check_robot,
"Dry gripper": robot_lib.dryGripper,
"Home pin": run_home_pin, }
if stop:
logger.info("Disabling mount")
disableMount()
logger.info("Turning robot off")
robotOff()
steps_to_run.update({"Disable mount": disableMount, "Robot off": robotOff})
else:
logger.info("Enabling mount")
enableMount()
logger.info("Turning robot on")
robotOn()
logger.info("Setting robot state to SE")
gov_lib.setGovRobot(gov_robot, 'SE')
steps_to_run.update({"Enable mount": enableMount, "Robot on": robotOn})

steps_to_run.update({"Move Governor to SE": gov_state_to_se,
"Checking robot arm speed": check_robot_speed,
"Checking beam": check_beam})

for i, (step_message, func) in enumerate(steps_to_run.items()):
logger.info(f"Step {i+1} of {len(steps_to_run)}: {step_message}")
func()
logger.info(f"Completed step: {step_message}")


def run_top_view_optimized():
Expand Down

0 comments on commit 1ec1798

Please sign in to comment.