def recoverRobot(): try: rebootEMBL() time.sleep(8.0) RobotControlLib.runCmd("recover") except Exception as e: e_s = str(e) daq_lib.gui_message("ROBOT Recover failed! " + e_s)
def parkGripper(): try: RobotControlLib.runCmd("park") except Exception as e: e_s = str(e) message = "Park gripper Failed!: " + e_s daq_lib.gui_message(message) logger.error(message)
def mva(*args): try: beamline_support.mva(*args) except Exception as e: bl_stop_motors() e_s = str(e) error_msg = "detector move error: %s" % e_s daq_lib.gui_message(error_msg) logger.error(error_msg)
def testRobot(): try: RobotControlLib.testRobot() logger.info("Test Robot passed!") daq_lib.gui_message("Test Robot passed!") except Exception as e: e_s = str(e) message = "Test Robot failed!: " + e_s daq_lib.gui_message(message) logger.error(message)
def dryGripper(): try: saveThreshold = getPvDesc("warmupThresholdRBV") setPvDesc("warmupThreshold",50) _thread.start_new_thread(warmupGripperRecoverThread,(saveThreshold,0)) warmupGripperForDry() except Exception as e: e_s = str(e) daq_lib.gui_message("Dry gripper failed! " + e_s) setPvDesc("warmupThreshold",saveThreshold)
def finish(): if (db_lib.getBeamlineConfigParam(daq_utils.beamline,'robot_online')): try: RobotControlLib.runCmd("finish") return 1 except Exception as e: e_s = str(e) daq_lib.gui_message("ROBOT Finish ERROR: " + e_s) print(e) # daq_lib.gui_message(e) return 0
def finish(): if (getBlConfig('robot_online')): try: RobotControlLib.runCmd("finish") return 1 except Exception as e: e_s = str(e) message = "ROBOT Finish ERROR: " + e_s daq_lib.gui_message(message) logger.error(message) return 0
def spectrum_analysis(): #as of 12/04, this is letting chooch do the analysis peak = 0.0 infl = 0.0 fprime_peak = 0.0 fprime_infl = 0.0 f2prime_peak = 0.0 f2prime_infl = 0.0 result_list = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0] #expanded on 12/4 to include f', f'', dermin obsolete dermin = 1.0 #skinner 12/09 - just get this from energy scan_midpoint_w = 12398.5 / get_mono_energy() scan_element = guess_element_for_chooch(scan_midpoint_w) element_edge_info = scan_element + "-" + element_info[scan_element][2] chooch_prefix = specgen("spectrum.dat", element_edge_info, 3, 2) if (scan_element != "unknown"): comm_s = "chooch -e %s -o %s -p %s %s" % ( scan_element, chooch_prefix + ".efs", chooch_prefix + ".ps", chooch_prefix + ".raw") else: comm_s = "chooch -o %s -p %s %s" % (chooch_prefix + ".efs", chooch_prefix + ".ps", chooch_prefix + ".raw") logger.info(comm_s) daq_lib.gui_message("Running Chooch...&") for outputline in os.popen(comm_s).readlines(): logger.info(outputline) tokens = split(outputline) if (len(tokens) > 4): if (tokens[1] == "peak"): peak = float(tokens[3]) fprime_peak = float(tokens[7]) f2prime_peak = float(tokens[5]) elif (tokens[1] == "infl"): infl = float(tokens[3]) fprime_infl = float(tokens[7]) f2prime_infl = float(tokens[5]) else: pass daq_lib.destroy_gui_message() os.system("xmgrace spectrum.spec&") os.system("gv.sh " + chooch_prefix + ".ps") #kludged with a shell call to get around gv bug os.system("ln -sf " + chooch_prefix + ".ps latest_chooch_plot.ps") result_list[0] = infl result_list[1] = peak result_list[2] = dermin result_list[3] = f2prime_infl result_list[4] = fprime_infl result_list[5] = f2prime_peak result_list[6] = fprime_peak return result_list
def recoverRobot(): try: rebootEMBL() time.sleep(8.0) _,bLoaded,_ = RobotControlLib.recover() if bLoaded: daq_macros.robotOff() daq_macros.disableMount() daq_lib.gui_message("Found a sample in the gripper - CALL STAFF! disableMount() executed.") else: RobotControlLib.runCmd("goHome") except Exception as e: e_s = str(e) daq_lib.gui_message("ROBOT Recover failed! " + e_s)
def spectrum_analysis(): #as of 12/04, this is letting chooch do the analysis peak = 0.0 infl = 0.0 fprime_peak = 0.0 fprime_infl = 0.0 f2prime_peak = 0.0 f2prime_infl = 0.0 result_list = [0.0,0.0,0.0,0.0,0.0,0.0,0.0] #expanded on 12/4 to include f', f'', dermin obsolete dermin=1.0 #skinner 12/09 - just get this from energy scan_midpoint_w = 12398.5/get_mono_energy() scan_element = guess_element_for_chooch(scan_midpoint_w) element_edge_info = scan_element + "-" + element_info[scan_element][2] chooch_prefix = specgen("spectrum.dat",element_edge_info,3,2) if (scan_element != "unknown"): comm_s = "chooch -e %s -o %s -p %s %s" % (scan_element,chooch_prefix+".efs",chooch_prefix+".ps",chooch_prefix+".raw") else: comm_s = "chooch -o %s -p %s %s" % (chooch_prefix+".efs",chooch_prefix+".ps",chooch_prefix+".raw") print comm_s daq_lib.gui_message("Running Chooch...&") for outputline in os.popen(comm_s).readlines(): print outputline tokens = split(outputline) if (len(tokens)>4): if (tokens[1] == "peak"): peak = float(tokens[3]) fprime_peak = float(tokens[7]) f2prime_peak = float(tokens[5]) elif (tokens[1] == "infl"): infl = float(tokens[3]) fprime_infl = float(tokens[7]) f2prime_infl = float(tokens[5]) else: pass daq_lib.destroy_gui_message() os.system("xmgrace spectrum.spec&") os.system("gv.sh "+chooch_prefix+".ps") #kludged with a shell call to get around gv bug os.system("ln -sf "+chooch_prefix+".ps latest_chooch_plot.ps") result_list[0] = infl result_list[1] = peak result_list[2] = dermin result_list[3] = f2prime_infl result_list[4] = fprime_infl result_list[5] = f2prime_peak result_list[6] = fprime_peak return result_list
def move_mono(energy): # for now, not sure if this should go in macros mono_mot_code = beamline_support.get_motor_code(beamline_support.motor_code_from_descriptor("monochromator")) if (daq_utils.beamline == "x25a"): ### return max_needed = 0 if (get_epics_pv("crue","VAL") != 1): daq_lib.destroy_gui_message() daq_lib.gui_message("Gap not enabled. Will continue.&") if (abs(float(get_mono_energy())-float(energy)) > 100): # if (abs(float(daq_lib.get_field("mono_energy_current"))-float(energy)) > 100): max_needed=1 if (max_needed): max_needed = 0 daq_lib.gui_message("The wavelength change requires a beamlign realign. Please push the Realign button.&") # daq_macros.realign() if (abs(float(get_mono_energy())-float(energy)) > .1): mva(mono_mot_code,float(energy))
def mvr(*args): if (args[0] == "Omega" and int(os.environ["GON_OFFLINE"]) == 1): #shitty kludge for omega issues return try: beamline_support.mvr(*args) except KeyboardInterrupt: bl_stop_motors() except epicsMotor.epicsMotorException,status: try: ii = 0 status_string = "" while(1): status_string = status_string + str(status[ii]) ii = ii + 1 except IndexError: print status_string daq_lib.gui_message(status_string+"&")
def wait90TopviewThread(prefix1, prefix90): global sampXadjust, sampYadjust, sampZadjust sampXadjust = 0 sampYadjust = 0 sampZadjust = 0 startTime = time.time() if (getPvDesc("gripTemp") > -170): threadTimeout = 130.0 else: threadTimeout = 30.0 while (1): omegaCP = beamline_lib.motorPosFromDescriptor("omega") if (omegaCP > 89.5 and omegaCP < 90.5): logger.info("leaving topview thread for 90") break if (time.time() - startTime > threadTimeout): logger.info("leaving topview thread for " + str(threadTimeout)) setPvDesc("topViewTrigMode", 0) setPvDesc("topViewImMode", 2) setPvDesc("topViewDataType", 1) setPvDesc("topViewAcquire", 1, wait=False) return time.sleep(0.10) try: daq_macros.topViewWrite() daq_macros.topViewSnap(prefix90, os.getcwd() + "/pinAlign", 1) snapshot1Name = prefix1 + "_001.jpg" snapshot2Name = prefix90 + "_001.jpg" if ( not filecmp.cmp(os.getcwd() + "/pinAlign/" + snapshot1Name, os.getcwd() + "/pinAlign/" + snapshot2Name) ): #this would mean something is wrong if true because the pictures are identical comm_s = os.environ[ "LSDCHOME"] + "/runPinAlign.py " + snapshot1Name + " " + snapshot2Name logger.info(comm_s) lines = os.popen(comm_s).readlines() logger.info("printing lines right after popen ") logger.info(lines) logger.info(" done") if (lines[0].find("CANNOT CENTER") == -1): offsetTokens = lines[0].split() logger.info(offsetTokens[0] + " " + offsetTokens[1] + " " + offsetTokens[2]) xlimLow = getPvDesc("robotXMountPos") + getPvDesc( "robotXMountLowLim") xlimHi = getPvDesc("robotXMountPos") + getPvDesc( "robotXMountHiLim") xpos = beamline_lib.motorPosFromDescriptor("sampleX") target = xpos + float(offsetTokens[0]) * 1000.0 if (target < xlimLow or target > xlimHi): logger.info("Pin X move beyond limit - Mount next sample.") ##else it thinks it worked return 0 else: sampXadjust = 1000.0 * float(offsetTokens[0]) sampYadjust = 1000.0 * float(offsetTokens[1]) sampZadjust = 1000.0 * float(offsetTokens[2]) sampXCP = beamline_lib.motorPosFromDescriptor("sampleX") sampYCP = beamline_lib.motorPosFromDescriptor("sampleY") sampZCP = beamline_lib.motorPosFromDescriptor("sampleZ") sampXAbsolute = sampXCP + sampXadjust sampYAbsolute = sampYCP + sampYadjust sampZAbsolute = sampZCP + sampZadjust setPvDesc("robotXWorkPos", sampXAbsolute) setPvDesc("robotYWorkPos", sampYAbsolute) setPvDesc("robotZWorkPos", sampZAbsolute) else: logger.info("Cannot align pin - Mount next sample.") #else it thinks it worked return 0 for outputline in lines: logger.info(outputline) except Exception as e: e_s = str(e) message = "TopView check ERROR, will continue: " + e_s daq_lib.gui_message(message) logger.error(message)
def unmountRobotSample(puckPos, pinPos, sampID): #will somehow know where it came from absPos = (pinsPerPuck * (puckPos % 3)) + pinPos + 1 robotOnline = getBlConfig('robot_online') logger.info("robot online = " + str(robotOnline)) if (robotOnline): detDist = beamline_lib.motorPosFromDescriptor("detectorDist") if (detDist < ROBOT_MIN_DISTANCE): setPvDesc("govRobotDetDistOut", ROBOT_MIN_DISTANCE) setPvDesc("govHumanDetDistOut", ROBOT_MIN_DISTANCE) daq_lib.setRobotGovState("SE") logger.info("unmounting " + str(puckPos) + " " + str(pinPos) + " " + str(sampID)) logger.info("absPos = " + str(absPos)) platePos = int(puckPos / 3) rotMotTarget = daq_utils.dewarPlateMap[platePos][0] rotCP = beamline_lib.motorPosFromDescriptor("dewarRot") logger.info("dewar target,CP") logger.info("%s %s" % (rotMotTarget, rotCP)) if (abs(rotMotTarget - rotCP) > 1): logger.info("rot dewar") try: RobotControlLib.runCmd("park") except Exception as e: e_s = str(e) message = "ROBOT park ERROR: " + e_s daq_lib.gui_message(message) logger.error(message) return 0 beamline_lib.mvaDescriptor("dewarRot", rotMotTarget) try: par_init = (beamline_support.get_any_epics_pv( "SW:RobotState", "VAL") != "Ready") par_cool = (getPvDesc("gripTemp") > -170) RobotControlLib.unmount1(init=par_init, cooldown=par_cool) except Exception as e: e_s = str(e) message = "ROBOT unmount ERROR: " + e_s daq_lib.gui_message(message) logger.error(message) return 0 if daq_utils.beamline == "fmx": det_z_pv = 'XF:17IDC-ES:FMX{Det-Ax:Z}Mtr' detDist = caget(f'{det_z_pv}.RBV') if detDist < ROBOT_MIN_DISTANCE: caput( f'{det_z_pv}.VAL', ROBOT_MIN_DISTANCE, wait=True ) # TODO shouldn't this wait for SE transition or something?? detDist = caget(f'{det_z_pv}.RBV') else: detDist = beamline_lib.motorPosFromDescriptor("detectorDist") if detDist < ROBOT_MIN_DISTANCE and abs( detDist - ROBOT_MIN_DISTANCE) > ROBOT_DISTANCE_TOLERANCE: logger.error( f"ERROR - Detector closer than {ROBOT_MIN_DISTANCE} and move than {ROBOT_DISTANCE_TOLERANCE} from {ROBOT_MIN_DISTANCE}! actual distance: {detDist}. Stopping." ) return 0 try: RobotControlLib.unmount2(absPos) except Exception as e: e_s = str(e) if (e_s.find("Fatal") != -1): daq_macros.robotOff() daq_macros.disableMount() daq_lib.gui_message( e_s + ". FATAL ROBOT ERROR - CALL STAFF! robotOff() executed.") return 0 message = "ROBOT unmount2 ERROR: " + e_s daq_lib.gui_message(message) logger.error(message) return 0 if (not daq_lib.waitGovRobotSE()): daq_lib.clearMountedSample() logger.info("could not go to SE") return 0 return 1
def unmountRobotSample(puckPos, pinPos, sampID): #will somehow know where it came from absPos = (pinsPerPuck * (puckPos % 3)) + pinPos + 1 robotOnline = getBlConfig('robot_online') logger.info("robot online = " + str(robotOnline)) if (robotOnline): detDist = beamline_lib.motorPosFromDescriptor("detectorDist") if (detDist < 200.0): setPvDesc("govRobotDetDistOut", 200.0) setPvDesc("govHumanDetDistOut", 200.0) daq_lib.setRobotGovState("SE") logger.info("unmounting " + str(puckPos) + " " + str(pinPos) + " " + str(sampID)) logger.info("absPos = " + str(absPos)) platePos = int(puckPos / 3) rotMotTarget = daq_utils.dewarPlateMap[platePos][0] rotCP = beamline_lib.motorPosFromDescriptor("dewarRot") logger.info("dewar target,CP") logger.info("%s %s" % (rotMotTarget, rotCP)) if (abs(rotMotTarget - rotCP) > 1): logger.info("rot dewar") try: RobotControlLib.runCmd("park") except Exception as e: e_s = str(e) message = "ROBOT park ERROR: " + e_s daq_lib.gui_message(message) logger.error(message) return 0 beamline_lib.mvaDescriptor("dewarRot", rotMotTarget) try: par_init = (beamline_support.get_any_epics_pv( "SW:RobotState", "VAL") != "Ready") par_cool = (getPvDesc("gripTemp") > -170) RobotControlLib.unmount1(init=par_init, cooldown=par_cool) except Exception as e: e_s = str(e) message = "ROBOT unmount ERROR: " + e_s daq_lib.gui_message(message) logger.error(message) return 0 detDist = beamline_lib.motorPosFromDescriptor("detectorDist") if (detDist < 200.0): beamline_lib.mvaDescriptor("detectorDist", 200.0) if (beamline_lib.motorPosFromDescriptor("detectorDist") < 199.0): logger.error("ERROR - Detector < 200.0!") return 0 try: RobotControlLib.unmount2(absPos) except Exception as e: e_s = str(e) if (e_s.find("Fatal") != -1): daq_macros.robotOff() daq_macros.disableMount() daq_lib.gui_message( e_s + ". FATAL ROBOT ERROR - CALL STAFF! robotOff() executed.") return 0 message = "ROBOT unmount2 ERROR: " + e_s daq_lib.gui_message(message) logger.error(message) return 0 if (not daq_lib.waitGovRobotSE()): daq_lib.clearMountedSample() logger.info("could not go to SE") return 0 return 1
def mountRobotSample(puckPos, pinPos, sampID, init=0, warmup=0): global retryMountCount global sampXadjust, sampYadjust, sampZadjust absPos = (pinsPerPuck * (puckPos % 3)) + pinPos + 1 logger.info(f'init: {init} warmup: {warmup}') if (getBlConfig('robot_online')): if (not daq_lib.waitGovRobotSE()): daq_lib.setGovRobot('SE') if (getBlConfig(TOP_VIEW_CHECK) == 1): try: sample = db_lib.getSampleByID(sampID) sampName = sample['name'] reqCount = sample['request_count'] prefix1 = sampName + "_" + str(puckPos) + "_" + str( pinPos) + "_" + str(reqCount) + "_PA_0" prefix90 = sampName + "_" + str(puckPos) + "_" + str( pinPos) + "_" + str(reqCount) + "_PA_90" daq_macros.topViewSnap(prefix1, os.getcwd() + "/pinAlign", 1, acquire=0) except Exception as e: e_s = str(e) message = "TopView check ERROR, will continue: " + e_s daq_lib.gui_message(message) logger.error(message) logger.info("mounting " + str(puckPos) + " " + str(pinPos) + " " + str(sampID)) logger.info("absPos = " + str(absPos)) platePos = int(puckPos / 3) rotMotTarget = daq_utils.dewarPlateMap[platePos][0] rotCP = beamline_lib.motorPosFromDescriptor("dewarRot") logger.info("dewar target,CP") logger.info("%s %s" % (rotMotTarget, rotCP)) if (abs(rotMotTarget - rotCP) > 1): logger.info("rot dewar") try: if (init == 0): RobotControlLib.runCmd("park") except Exception as e: e_s = str(e) message = "ROBOT Park ERROR: " + e_s daq_lib.gui_message(message) logger.error(message) return 0 beamline_lib.mvaDescriptor("dewarRot", rotMotTarget) try: if (init): logger.debug('main loading part') setPvDesc("boostSelect", 0) if (getPvDesc("sampleDetected") == 0 ): #reverse logic, 0 = true setPvDesc("boostSelect", 1) else: robotStatus = beamline_support.get_any_epics_pv( "SW:RobotState", "VAL") if (robotStatus != "Ready"): if (daq_utils.beamline == "fmx"): daq_macros.homePins() time.sleep(3.0) if (not daq_lib.setGovRobot('SE')): return if (getBlConfig(TOP_VIEW_CHECK) == 1): omegaCP = beamline_lib.motorPosFromDescriptor("omega") if (omegaCP > 89.5 and omegaCP < 90.5): beamline_lib.mvrDescriptor("omega", 85.0) logger.info("calling thread") _thread.start_new_thread(wait90TopviewThread, (prefix1, prefix90)) logger.info("called thread") setPvDesc("boostSelect", 0) if (getPvDesc("gripTemp") > -170): try: logger.debug('mounting') RobotControlLib.mount(absPos) except Exception as e: e_s = str(e) message = "ROBOT mount ERROR: " + e_s daq_lib.gui_message(message) logger.error(message) return 0 else: time.sleep(0.5) if (getPvDesc("sampleDetected") == 0): logger.info("full mount") RobotControlLib.mount(absPos) else: logger.debug('quick mount') RobotControlLib.initialize() RobotControlLib._mount(absPos) setPvDesc("boostSelect", 1) else: if (getBlConfig(TOP_VIEW_CHECK) == 1): omegaCP = beamline_lib.motorPosFromDescriptor("omega") if (omegaCP > 89.5 and omegaCP < 90.5): beamline_lib.mvrDescriptor("omega", 85.0) logger.info("calling thread") _thread.start_new_thread(wait90TopviewThread, (prefix1, prefix90)) logger.info("called thread") if (warmup): RobotControlLib._mount(absPos, warmup=True) else: RobotControlLib._mount(absPos) logger.info(f'{getBlConfig(TOP_VIEW_CHECK)} {daq_utils.beamline}') if (getBlConfig(TOP_VIEW_CHECK) == 1): if (sampYadjust == 0): logger.info("Cannot align pin - Mount next sample.") daq_lib.setGovRobot('SA') return 1 except Exception as e: logger.error(e) e_s = str(e) if (e_s.find("Fatal") != -1): daq_macros.robotOff() daq_macros.disableMount() daq_lib.gui_message( e_s + ". FATAL ROBOT ERROR - CALL STAFF! robotOff() executed.") return 0 if (e_s.find("tilted") != -1 or e_s.find("Load Sample Failed") != -1): if (getBlConfig("queueCollect") == 0): daq_lib.gui_message(e_s + ". Try mounting again") return 0 else: if (retryMountCount == 0): retryMountCount += 1 mountStat = mountRobotSample(puckPos, pinPos, sampID, init) if (mountStat == 1): retryMountCount = 0 return mountStat else: retryMountCount = 0 daq_lib.gui_message("ROBOT: Could not recover from " + e_s) return 2 daq_lib.gui_message("ROBOT mount ERROR: " + e_s) return 0 return 1 else: return 1
def unmountRobotSample(puckPos,pinPos,sampID): #will somehow know where it came from # absPos = (pinsPerPuck*puckPos)+pinPos+1 absPos = (pinsPerPuck*(puckPos%3))+pinPos+1 robotOnline = db_lib.getBeamlineConfigParam(daq_utils.beamline,'robot_online') print("robot online = " + str(robotOnline)) if (robotOnline): detDist = beamline_lib.motorPosFromDescriptor("detectorDist") if (detDist<199.0): beamline_support.setPvValFromDescriptor("govRobotDetDistOut",200.0) beamline_support.setPvValFromDescriptor("govHumanDetDistOut",200.0) daq_lib.setRobotGovState("SE") print("unmounting " + str(puckPos) + " " + str(pinPos) + " " + str(sampID)) print("absPos = " + str(absPos)) platePos = int(puckPos/3) rotMotTarget = daq_utils.dewarPlateMap[platePos][0] rotCP = beamline_lib.motorPosFromDescriptor("dewarRot") print("dewar target,CP") print(rotMotTarget,rotCP) if (abs(rotMotTarget-rotCP)>1): print("rot dewar") try: RobotControlLib.runCmd("park") except Exception as e: e_s = str(e) daq_lib.gui_message("ROBOT park ERROR: " + e_s) print(e) return 0 beamline_lib.mvaDescriptor("dewarRot",rotMotTarget) try: par_init=(beamline_support.get_any_epics_pv("SW:RobotState","VAL")!="Ready") par_cool=(beamline_support.getPvValFromDescriptor("gripTemp")>-170) if par_cool == False and daq_utils.beamline == "fmx": time.sleep(3) RobotControlLib.unmount1(init=par_init,cooldown=par_cool) except Exception as e: e_s = str(e) daq_lib.gui_message("ROBOT unmount ERROR: " + e_s) print(e) return 0 detDist = beamline_lib.motorPosFromDescriptor("detectorDist") if (detDist<200.0): beamline_lib.mvaDescriptor("detectorDist",200.0) if (beamline_lib.motorPosFromDescriptor("detectorDist") < 199.0): print("ERROR - Detector < 200.0!") return 0 try: RobotControlLib.unmount2(absPos) except Exception as e: e_s = str(e) if (e_s.find("Fatal") != -1): daq_macros.robotOff() daq_macros.disableMount() daq_lib.gui_message(e_s + ". FATAL ROBOT ERROR - CALL STAFF! robotOff() executed.") return 0 daq_lib.gui_message("ROBOT unmount2 ERROR: " + e_s) print(e) return 0 if (not daq_lib.waitGovRobotSE()): daq_lib.clearMountedSample() print("could not go to SE") return 0 return 1
def mountRobotSample(puckPos,pinPos,sampID,init=0,warmup=0): global retryMountCount # absPos = (pinsPerPuck*puckPos)+pinPos+1 absPos = (pinsPerPuck*(puckPos%3))+pinPos+1 if (db_lib.getBeamlineConfigParam(daq_utils.beamline,'robot_online')): if (not daq_lib.waitGovRobotSE()): daq_lib.setGovRobotSE() print("mounting " + str(puckPos) + " " + str(pinPos) + " " + str(sampID)) print("absPos = " + str(absPos)) platePos = int(puckPos/3) rotMotTarget = daq_utils.dewarPlateMap[platePos][0] rotCP = beamline_lib.motorPosFromDescriptor("dewarRot") print("dewar target,CP") print(rotMotTarget,rotCP) if (abs(rotMotTarget-rotCP)>1): print("rot dewar") try: if (init == 0): RobotControlLib.runCmd("park") except Exception as e: e_s = str(e) daq_lib.gui_message("ROBOT Park ERROR: " + e_s) print(e) return 0 beamline_lib.mvaDescriptor("dewarRot",rotMotTarget) try: if (init): beamline_support.setPvValFromDescriptor("boostSelect",0) if (beamline_support.getPvValFromDescriptor("sampleDetected") == 0): #reverse logic, 0 = true beamline_support.setPvValFromDescriptor("boostSelect",1) else: # if (beamline_support.getPvValFromDescriptor("gripTemp") > 20.0): #gripper warm robotStatus = beamline_support.get_any_epics_pv("SW:RobotState","VAL") if (robotStatus != "Ready"): if (daq_utils.beamline == "fmx"): daq_macros.homePins() time.sleep(3.0) if (not daq_lib.setGovRobotSE()): return RobotControlLib.mount(absPos) else: if (warmup): RobotControlLib._mount(absPos,warmup=True) else: RobotControlLib._mount(absPos) daq_lib.setGovRobotSA() return 1 except Exception as e: print(e) e_s = str(e) if (e_s.find("Fatal") != -1): daq_macros.robotOff() daq_macros.disableMount() daq_lib.gui_message(e_s + ". FATAL ROBOT ERROR - CALL STAFF! robotOff() executed.") return 0 if (e_s.find("tilted") != -1 or e_s.find("Load Sample Failed") != -1): if (db_lib.getBeamlineConfigParam(daq_utils.beamline,"queueCollect") == 0): daq_lib.gui_message(e_s + ". Try mounting again") return 0 else: if (retryMountCount == 0): retryMountCount+=1 mountStat = mountRobotSample(puckPos,pinPos,sampID,init) if (mountStat == 1): retryMountCount = 0 return mountStat else: retryMountCount = 0 daq_lib.gui_message("ROBOT: Could not recover from " + e_s) return 2 daq_lib.gui_message("ROBOT mount ERROR: " + e_s) return 0 return 1 else: return 1
def cooldownGripper(): try: RobotControlLib.runCmd("cooldownGripper") except: daq_lib.gui_message("ROBOT cooldown failed!")
def warmupGripper(): try: RobotControlLib.runCmd("warmupGripper") daq_lib.mountCounter = 0 except: daq_lib.gui_message("ROBOT warmup failed!")
def move_gap(kev): if (get_epics_pv("MguMENB","VAL") != 1): daq_lib.destroy_gui_message() daq_lib.gui_message("Gap not enabled. Will continue.&") set_epics_pv("MguE","E",float(kev)*1000.0)