From cf285feb0c68db3449243107e30b3f77c37409c4 Mon Sep 17 00:00:00 2001 From: gac-S_Changer Date: Wed, 12 May 2021 16:46:05 +0200 Subject: [PATCH] updates to handle AUX tools --- config/settings.properties | 6 +- script/devices/RobotSC.py | 3 +- script/motion/mount.py | 120 +++++++++++++++++++++++-------------- script/motion/unmount.py | 29 ++++++--- 4 files changed, 100 insertions(+), 58 deletions(-) diff --git a/config/settings.properties b/config/settings.properties index c9af3ab..f74284f 100644 --- a/config/settings.properties +++ b/config/settings.properties @@ -1,10 +1,10 @@ -#Wed May 12 08:54:59 CEST 2021 -dry_mount_counter=0 +#Wed May 12 16:45:18 CEST 2021 +dry_mount_counter=2 room_temperature_enabled=false pin_offset=-0.0 puck_types=true imaging_enabled=false -dry_timestamp=1.620715310958E9 +dry_timestamp=1.620830387256E9 roi_h=1000 led_level=0.0 beamline_status_enabled=false diff --git a/script/devices/RobotSC.py b/script/devices/RobotSC.py index 1aa408a..8fc0088 100644 --- a/script/devices/RobotSC.py +++ b/script/devices/RobotSC.py @@ -10,7 +10,8 @@ DESC_SCAN = "mScan" DESC_DEFAULT = DESC_FAST AUX_SEGMENT = "X" - +RT_SEGMENT = "R" +COLD_SEGMENTS = "ABCDEF" DEFAULT_ROBOT_POLLING = 500 TASK_WAIT_ROBOT_POLLING = 50 diff --git a/script/motion/mount.py b/script/motion/mount.py index 39ea2e1..6593649 100644 --- a/script/motion/mount.py +++ b/script/motion/mount.py @@ -7,13 +7,25 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False) global mount_sample_id, mount_sample_detected print "mount: ", segment, puck, sample, force - start = time.time() - #time.sleep(2) + start = time.time() is_aux = (segment == AUX_SEGMENT) + is_rt = (segment == RT_SEGMENT) + is_normal = not (is_aux or is_rt) - #ZACH - needs_chilling = not is_aux and (not robot.is_cold()) - needs_drying = is_aux and robot.is_cold() + + previous_mounted = get_setting("mounted_sample_position") + if previous_mounted is not None: + previous_segment, previous_puck, previous_sample = previous_mounted[0], int(previous_mounted[1]), int(previous_mounted[2:]) + else: + previous_segment, previous_puck, previous_sample = "-", 0, 0 + + # ZAC + was_cold = robot.is_cold() + was_warm = not was_cold + needs_chilling = not is_rt and was_warm + needs_drying = is_rt and was_cold + count_mount = is_normal or (is_aux and was_cold) + zero_counts = (is_aux and not was_cold) or (is_rt and was_cold) puck_address = get_puck_address(puck) if puck_address is None: @@ -44,30 +56,34 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False) hexiposi.assert_homed() assert_mount_position() do_unmount = False - - try: - #ZACH - if needs_chilling: - robot.move_cold() - time.sleep(30.0) - if smart_magnet.get_supress() == True: - smart_magnet.set_supress(False) - time.sleep(0.2) - #To better dectect sample - #smart_magnet.apply_reverse() - #smart_magnet.apply_resting() - #time.sleep(0.5) - - sample_det = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) - Controller.getInstance().logEvent("Sample Detection", str(sample_det)) - if sample_det == True: + # detect sample before moving to cold + if smart_magnet.get_supress() == True: + smart_magnet.set_supress(False) + time.sleep(0.2) + sample_det = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) + Controller.getInstance().logEvent("Sample Detection", str(sample_det)) + + try: + if sample_det == True: + if was_warm and previous_segment in COLD_SEGMENTS: + print "was warm previous %s %s $s" % (previous_segment, COLD_SEGMENTS, previous_mounted) + robot.move_cold() + time.sleep(30.0) + if auto_unmount and (get_setting("mounted_sample_position") is not None): #auto_unmount set to true so detection remains enabled - sample_det = unmount(force = True, auto_unmount = True) + sample_det = unmount(force = True, auto_unmount = True, next_segment=segment) do_unmount = True if sample_det == True: raise Exception("Pin detected on gonio") + + + if is_normal and not robot.is_cold(): + print "mount():83 needs_chilling" + robot.move_cold() + time.sleep(30.0) + set_status("Mounting: " + str(segment) + str(puck) + str(sample)) Controller.getInstance().logEvent("Mount Sample", str(segment) + str(puck) + str(sample)) #location = robot.get_current_point() @@ -76,26 +92,26 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False) if not do_unmount: enable_motion() - #ZACH + # ZAC # a room temp pin is being mounted but the gripper is cold if needs_drying: dry(wait_cold=-1) # move to park after dry if is_aux: if not robot.is_aux(): - robot.move_aux() - + robot.move_aux() robot.get_aux(sample) - + + elif is_rt: + # TODO: implement room temperature for X06SA + pass + else: - set_hexiposi(segment) - - if not force: - visual_check_hexiposi(segment) - + set_hexiposi(segment) + if not force: + visual_check_hexiposi(segment) if not robot.is_dewar(): - robot.move_dewar() - + robot.move_dewar() robot.get_dewar(segment, puck, sample) @@ -115,18 +131,32 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False) robot.put_gonio() - - try: - dry_mount_count = int(get_setting("dry_mount_counter")) - except: - dry_mount_count = 0 - set_setting("dry_mount_counter", dry_mount_count+1) - - if is_aux: - robot.move_home() - else: + if count_mount: + try: + dry_mount_count = int(get_setting("dry_mount_counter")) + except: + dry_mount_count = 0 + finally: + set_setting("dry_mount_counter", dry_mount_count+1) + + elif zero_counts: + set_setting("dry_mount_counter", 0) + + if is_rt: + print "mount/moving park in RT" + robot.move_park() + elif is_normal: + print "mount/moving cold in cold" robot.move_cold() - + elif is_aux: + if was_cold: + print "mount/moving park in AUX" + robot.move_cold() + else: + robot.move_park() + else: + robot.move_cold() + mount_sample_detected = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) Controller.getInstance().logEvent("Sample Detection", str(mount_sample_detected)) update_samples_info_sample_mount(get_puck_name(segment, puck), sample, mount_sample_detected, mount_sample_id) diff --git a/script/motion/unmount.py b/script/motion/unmount.py index cd2d50b..7ba4f83 100644 --- a/script/motion/unmount.py +++ b/script/motion/unmount.py @@ -1,4 +1,4 @@ -def unmount(segment = None, puck = None, sample = None, force=False, auto_unmount = False): +def unmount(segment = None, puck = None, sample = None, force=False, auto_unmount = False, next_segment="-*-"): """ """ print "unmount: ", segment, puck, sample, force, auto_unmount @@ -10,10 +10,17 @@ def unmount(segment = None, puck = None, sample = None, force=False, auto_unmoun segment, puck , sample = pos[0:1], int(pos[1]), int(pos[2:]) print "Mounted sample position: ", segment, puck , sample - #ZACH: these need to happen after defining segment, puck, sample + # ZAC: these need to happen after defining segment, puck, sample is_aux = (segment == AUX_SEGMENT) - needs_chilling = not is_aux and (not robot.is_cold()) - needs_drying = is_aux and robot.is_cold() + is_rt = (segment == RT_SEGMENT) + is_normal = not (is_aux or is_rt) + + was_cold = robot.is_cold() + was_warm = not was_cold + needs_chilling = not is_rt and was_warm + needs_drying = is_rt and was_cold + move_cold_at_end = str(next_segment) in COLD_SEGMENTS + #Initial checks if not auto_unmount: @@ -68,6 +75,7 @@ def unmount(segment = None, puck = None, sample = None, force=False, auto_unmoun if not force: visual_check_hexiposi(segment) if needs_chilling: + print "umount():78 chilling" robot.move_cold() time.sleep(30.) else: @@ -88,13 +96,16 @@ def unmount(segment = None, puck = None, sample = None, force=False, auto_unmoun Controller.getInstance().logEvent("Sample Detection", str(mount_sample_detected)) if is_aux: - robot.move_aux() - robot.put_aux( sample) + robot.move_aux() + robot.put_aux(sample) + elif is_rt: + pass # TODO: implement RT at x06sa else: - #TODO: Should check if smart magnet detection is off? - update_samples_info_sample_unmount(get_puck_name(segment, puck), sample) - robot.move_dewar() + print "unmount():100 move_dewar & put_dewar" + update_samples_info_sample_unmount(get_puck_name(segment, puck), sample) + robot.move_dewar() robot.put_dewar(segment, puck, sample) + set_setting("mounted_sample_position", None) return mount_sample_detected finally: