From aa7b26f8b41417ed3d31f2fc1107620bc2cdbebc Mon Sep 17 00:00:00 2001 From: gac-S_Changer Date: Fri, 22 Oct 2021 10:21:20 +0200 Subject: [PATCH] aux puck dry tool, gripper switches --- config/settings.properties | 7 ++- config/variables.properties | 4 +- script/local.py | 12 ++--- script/motion/check_gripper.py | 11 +++++ script/motion/mount.py | 84 ++++++++++++++++------------------ script/motion/unmount.py | 44 ++++++++---------- 6 files changed, 79 insertions(+), 83 deletions(-) diff --git a/config/settings.properties b/config/settings.properties index 9fd019e..c1c9d8b 100644 --- a/config/settings.properties +++ b/config/settings.properties @@ -1,11 +1,10 @@ -#Wed Oct 13 15:20:54 CEST 2021 -dry_mount_counter=5 -mounted_sample_position=D214 +#Fri Oct 22 10:20:19 CEST 2021 +dry_mount_counter=0 room_temperature_enabled=false pin_offset=-0.0 puck_types=true imaging_enabled=false -dry_timestamp=1.634130424209E9 +dry_timestamp=1.634884370097E9 roi_h=1000 led_level=0.0 beamline_status_enabled=false diff --git a/config/variables.properties b/config/variables.properties index 80bdc27..c9f97b4 100644 --- a/config/variables.properties +++ b/config/variables.properties @@ -1,2 +1,2 @@ -#Tue Jun 22 08:54:23 CEST 2021 -FileSequentialNumber=174 +#Thu Oct 21 13:40:17 CEST 2021 +FileSequentialNumber=176 diff --git a/script/local.py b/script/local.py index 4702138..6ca4480 100644 --- a/script/local.py +++ b/script/local.py @@ -103,6 +103,7 @@ set_setting(ROOM_TEMPERATURE_ENABLED_PREFERENCE, is_room_temperature_enabled()) def is_gripper_really_empty(timeout=2.0): + evlog = Controller.getInstance().logEvent timeout = timeout + time.time() while time.time() < timeout: if robot.eval_bool("diToolHasSample"): @@ -111,9 +112,8 @@ def is_gripper_really_empty(timeout=2.0): else: return True - msg = "WARNING 1st try: gripper should be empty, sample detected (dwell for 2s and try again)" - log(msg, False) - print msg + msg = "is_gripper_really_empty() WARNING GRIPPER-TEST 1st try: gripper should be empty, sample detected (dwell for 2s and try again)" + evlog(msg) time.sleep(2.0) robot.eval_bool("diToolOpen") @@ -122,14 +122,12 @@ def is_gripper_really_empty(timeout=2.0): timeout = 2.0 + time.time() while time.time() < timeout: if robot.eval_bool("diToolHasSample"): - print "test" time.sleep(0.10) else: return True - msg = "WARNING 2nd try: gripper should be empty, sample detected" - log(msg, False) - print printmsg + msg = "WARNING GRIPPER-TEST 2nd try: gripper should be empty, sample detected" + evlog(msg) return False diff --git a/script/motion/check_gripper.py b/script/motion/check_gripper.py index 5e7cd00..3ac6055 100644 --- a/script/motion/check_gripper.py +++ b/script/motion/check_gripper.py @@ -21,3 +21,14 @@ def swap_samples(a, b, empty): robot.get_aux(empty) robot.put_aux(b) +def fetch_go_cold(): + robot.move_gonio() + robot.get_gonio() + robot.move_cold() + +def pickup(seg, puck, sam): + robot.move_dewar() + robot.get_dewar(seg, puck, sam) + robot.move_cold() + + \ No newline at end of file diff --git a/script/motion/mount.py b/script/motion/mount.py index 963a866..9eb1c63 100644 --- a/script/motion/mount.py +++ b/script/motion/mount.py @@ -39,6 +39,12 @@ def mount(segment, puck, sample, force=True, read_dm=False, auto_unmount=False): segment = puck_address[:1] puck = int(puck_address[1:]) + + sampleAddress = str(segment) + str(puck) + "-" + str(sample) + set_status("Mounting: " + sampleAddress) + evlog(">>>>>>>>>>>>>>> MOUNT <<<<<<<<<<<<<<<<<<<<<") + evlog("mount() Mount Sample", sampleAddress) + print "%4.1f s asserting" % (tg() - t1,) #Initial checks @@ -68,13 +74,17 @@ def mount(segment, puck, sample, force=True, read_dm=False, auto_unmount=False): smart_magnet.set_supress(False) time.sleep(0.2) sample_det = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) - evlog("SMC Sample Detection", str(sample_det)) + evlog("mount() SMC Sample Detection", str(sample_det)) - print "%4.1f s SMC checked" % (tg() - t1,) + hasSample = robot.gripper_has_sample() + if hasSample: + msg = "CRITICAL ERROR: the gripper has a sample stuck to it, call local contact." + evlog(msg) + evlog("mount() terminating mount early") + raise Exception(msg) mounting_in_same_segment = False - sampleAddress = str(segment) + str(puck) + "-" + str(sample) try: if sample_det == True: @@ -93,10 +103,10 @@ def mount(segment, puck, sample, force=True, read_dm=False, auto_unmount=False): do_unmount = True if sample_det == True: - raise Exception("Pin detected on gonio") - - set_status("Mounting: " + sampleAddress) - evlog("Mount Sample", sampleAddress) + msg = "CRITICAL a pin is being detected on gonio after an unmount attempt, either trash the sample or try unmounting again" + evlog(msg) + evlog("mount() terminating mount early") + raise Exception(msg) if not do_unmount: enable_motion() @@ -130,57 +140,45 @@ def mount(segment, puck, sample, force=True, read_dm=False, auto_unmount=False): robot.get_dewar(segment, puck, sample, mounting_in_same_segment=mounting_in_same_segment) hasSample = robot.gripper_has_sample() - msg = "WARNING GRIPPER-TEST - after robot.get_* gripper has sample={} sample={}".format(hasSample, sampleAddress) + msg = "mount() WARNING GRIPPER-TEST - after get_(dewar,rt,aux) gripper has sample: {}".format(hasSample) evlog(msg) - print "%4.1f s %s" % (tg() - t1, msg) if not hasSample: - msg = "WARNING GRIPPER-TEST no sample in position {}".format(sampleAddress) - evlog(msg) - print "%4.1f s %s" % (tg() - t1, msg) if is_aux or is_rt: robot.move_park() else: robot.move_cold() + msg = "MISSING SAMPLE in position {} - try the next one".format(sampleAddress) + evlog(msg) + evlog("mount() terminating mount early") raise Exception(msg) if read_dm: - print "%4.1f s barcode read" % (tg() - t1,) barcode_reader.start_read(10.0) robot.move_scanner() - print "%4.1f s ...done" % (tg() - t1,) - print "%4.1f s move to gonio " % (tg() - t1,) robot.move_gonio() - print "%4.1f s ....done" % (tg() - t1,) if read_dm: - print "%4.1f s reading pin barcode" % (tg() - t1,) mount_sample_id = barcode_reader.get_readout() - print "%4.1f s ....done --- barcode: %s" % (tg() - t1, mount_sample_id) - evlog("read pin barcode: %s" % (mount_sample_id,)) + evlog("mount() read pin barcode: %s" % (mount_sample_id,)) else: mount_sample_id = None curpos = cryopos.getPosition() if is_room_temperature_enabled(): if curpos < 50: - print "%4.1f s moving cryo out to 50mm" % (tg() - t1,) cryopos.move(50.) else: - print "%4.1f s moving cryo out to 15mm" % (tg() - t1,) speed = cryopos.getSpeed() / 1000.0 movetime = int(round(3000 + (15. - curpos) / speed)) cryopos.move(15.0, movetime) cryopos.waitValueInRange(15.0, 1.0, movetime) - print " ....done\n%4.1f s putting_gonio with pin_offset = %.1f mm" % (tg() - t1, pin_offset) robot.put_gonio() - print "%4.1f s .....done" % (tg() - t1,) robot.close_tool() # closes gripper if is_normal: - print "%4.1f s async moving cryo to 5mm " % (tg() - t1,) cryopos.moveAsync(5.0) if count_mount: @@ -195,23 +193,16 @@ def mount(segment, puck, sample, force=True, read_dm=False, auto_unmount=False): set_setting("dry_mount_counter", 0) if is_rt: - print "%4.1f s mount/moving home in RT" % (tg() - t1,) robot.move_park() elif is_normal: - print "%4.1f s mount/moving cold in cold " % (tg() - t1,) robot.move_cold() elif is_aux: - if was_cold: - print "%4.1f s mount/moving cold after auxtool mount " % (tg() - t1,) - robot.move_cold() - else: - print "%4.1f s mount/moving park after auxtool mount" % (tg() - t1,) - robot.move_park() + robot.move_park() else: robot.move_cold() mount_sample_detected = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) - evlog("Sample Detection", str(mount_sample_detected)) + evlog("mount() SMC Detection", str(mount_sample_detected)) update_samples_info_sample_mount(get_puck_name(segment, puck), sample, mount_sample_detected, mount_sample_id) # Check gripper for frozen sample after trying to mount on gonio @@ -221,28 +212,31 @@ def mount(segment, puck, sample, force=True, read_dm=False, auto_unmount=False): reallyEmpty = is_gripper_really_empty(1.2) if not reallyEmpty: - msg = "WARNING GRIPPER-TEST still has a sample {} after mount attempt".format(sampleAddress) + msg = "CRITICAL The gripper still has sample {} after mount attempt, call local contact".format(sampleAddress) evlog(msg) - print "%4.1f s %s" % (tg() - t1, msg) - # raise Exception(msg) + evlog("mount() terminating mount early") + raise Exception(msg) sampleDelivered = True robot.open_tool() # open gripper if sampleDelivered and not mount_sample_detected: - msg = "WARNING GRIPPER-TEST sample {} lost during mount".format(sampleAddress) - evlog("SMC Sample Detection false after put gonio") - print "%4.1f s %s" % (tg() - t1, msg) - # raise Exception(msg) + msg = "CRITICAL The sample {} seems to have been lost during mount procedure. Try another sample or call your local contact".format(sampleAddress) + evlog(msg) + evlog("mount() terminating mount early") + raise Exception(msg) - if is_force_dry(): - smart_magnet.set_default_current() - print "%4.1f Auto dry async" % (tg() - t1,) - evlog("Starting async auto dry") + smart_magnet.set_default_current() + + if is_aux and was_cold: + evlog("mount() drying after tool mount") + set_exec_pars(then = "dry(wait_cold=-1)") + elif is_force_dry(): + evlog("mount() Starting async auto dry") set_exec_pars(then = "dry()") set_setting("mounted_sample_position", get_sample_name(segment, puck, sample)) return [mount_sample_detected, mount_sample_id] finally: - print "%4.1f s magnet suppress/default current" % (tg() - t1,) + evlog("############### MOUNT-FINISHED ####################") smart_magnet.set_default_current() smart_magnet.set_supress(True) diff --git a/script/motion/unmount.py b/script/motion/unmount.py index 33ac227..84ccbf3 100644 --- a/script/motion/unmount.py +++ b/script/motion/unmount.py @@ -14,8 +14,8 @@ def unmount(segment = None, puck = None, sample = None, force=True, auto_unmount sampleAddress = str(segment) + str(puck) + "-" + str(sample) - msg = "Unmounting %s" % (sampleAddress,) - print msg + evlog(">>>>>>>>>>>>>>> UNMOUNT <<<<<<<<<<<<<<<<<<<<<") + msg = "unmount() Unmounting %s" % (sampleAddress,) evlog(msg) is_aux = (segment == AUX_SEGMENT) @@ -58,7 +58,14 @@ def unmount(segment = None, puck = None, sample = None, force=True, auto_unmount assert_mount_position() set_status("Unmounting: " + str(segment) + str(puck) + str(sample)) - evlog("Unmount Sample", str(segment) + str(puck) + str(sample)) + + hasSample = robot.gripper_has_sample() + if hasSample: + msg = "unmount() CRITICAL GRIPPER-TEST - the gripper has a sample already!!!" + evlog(msg) + raise Exception("CRITICAL ERROR: the gripper has a sample stuck to it, call local contact.") + + try: if smart_magnet.get_supress() == True: @@ -78,7 +85,7 @@ def unmount(segment = None, puck = None, sample = None, force=True, auto_unmount enable_motion() if is_normal: - evlog("UNMOUNT() set_hexiposi(%s)" % (segment,)) + evlog("unmount() set_hexiposi(%s)" % (segment,)) set_hexiposi(segment) if not force: @@ -100,10 +107,8 @@ def unmount(segment = None, puck = None, sample = None, force=True, auto_unmount curpos = cryopos.getPosition() if is_room_temperature_enabled(): if curpos < 50: - print "%4.1f s moving cryo out to 50mm" % (tg() - t1,) cryopos.move(50.) else: - print "%4.1f s moving cryo out to 15mm" % (tg() - t1,) speed = cryopos.getSpeed() / 1000. movetime = int(round(3000 + (15. - curpos) / speed)) cryopos.move(15.0, movetime) @@ -124,16 +129,17 @@ def unmount(segment = None, puck = None, sample = None, force=True, auto_unmount robot.move_dewar() robot.put_dewar(segment, puck, sample, mounting_in_same_segment=mounting_in_same_segment) + robot.close_tool() # closes gripper has_sample_after_get = robot.gripper_has_sample() - evlog("Sample Detection - unmount after get_gonio: ", str(has_sample_after_get)) + evlog("unmount() sample detections after put_(dewar,rt,aux):") + evlog(" GRIPPER: ", str(has_sample_after_get)) smart_magnet.apply_reverse() smart_magnet.apply_resting() mount_sample_detected = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) - evlog("Sample Detection", str(mount_sample_detected)) + evlog(" SMC: ", str(mount_sample_detected)) - robot.close_tool() # closes gripper if not was_cold: robot.move_park() @@ -145,28 +151,16 @@ def unmount(segment = None, puck = None, sample = None, force=True, auto_unmount reallyEmpty = is_gripper_really_empty(0.8) if not reallyEmpty: - msg = "WARNING GRIPPER-TEST gripper still has a sample {} after mount attempt".format(sampleAddress) + msg = "unmount() CRITICAL gripper still has a sample {} after puck delivery attempt, call local contact!".format(sampleAddress) evlog(msg) - print msg - - if is_aux or is_rt: - robot.move_park() - # raise Exception(msg) + raise Exception(msg) + robot.open_tool() # open gripper - if has_sample_after_get == mount_sample_detected: - msg = "WARNING GRIPPER-TEST Sample Detection Error - unmount from SM:" + str(mount_sample_detected) + " gripper:" + str(has_sample_after_get) + sampleAddress - print msg - evlog(msg) - #has_sample_after_put = robot.gripper_has_sample() - #log("Sample Detection - unmount after put: " + str(has_sample_after_put), False) - #if has_sample_after_put: - # log("Sample Detection Error - unm put", False) - - set_setting("mounted_sample_position", None) return mount_sample_detected finally: if not auto_unmount: smart_magnet.set_default_current() smart_magnet.set_supress(True) + evlog("############### UNMOUNT-FINISHED ####################")