diff --git a/config/settings.properties b/config/settings.properties index e33f90d..767e1d1 100644 --- a/config/settings.properties +++ b/config/settings.properties @@ -1,12 +1,12 @@ -#Fri Aug 13 09:02:02 CEST 2021 -dry_mount_counter=2 -mounted_sample_position=X11 +#Mon Oct 25 10:55:19 CEST 2021 +dry_mount_counter=0 +mounted_sample_position=C516 room_temperature_enabled=false pin_offset=-0.0 cryopos_in=5.0 puck_types=true imaging_enabled=false -dry_timestamp=1.628757867864E9 +dry_timestamp=1.635151972268E9 roi_h=1000 led_level=0.0 beamline_status_enabled=false diff --git a/config/variables.properties b/config/variables.properties index 31428e1..741d6e8 100644 --- a/config/variables.properties +++ b/config/variables.properties @@ -1,2 +1,2 @@ -#Fri Aug 06 08:44:51 CEST 2021 -FileSequentialNumber=297 +#Tue Oct 05 14:34:33 CEST 2021 +FileSequentialNumber=299 diff --git a/devices/led_ctrl_1.properties b/devices/led_ctrl_1.properties index efb734d..847c74b 100644 --- a/devices/led_ctrl_1.properties +++ b/devices/led_ctrl_1.properties @@ -1,4 +1,4 @@ -#Fri Aug 06 09:14:09 CEST 2021 +#Tue Oct 05 15:05:31 CEST 2021 minValue=0.0 unit=V offset=0.0 diff --git a/devices/led_ctrl_2.properties b/devices/led_ctrl_2.properties index efb734d..847c74b 100644 --- a/devices/led_ctrl_2.properties +++ b/devices/led_ctrl_2.properties @@ -1,4 +1,4 @@ -#Fri Aug 06 09:14:09 CEST 2021 +#Tue Oct 05 15:05:31 CEST 2021 minValue=0.0 unit=V offset=0.0 diff --git a/devices/led_ctrl_3.properties b/devices/led_ctrl_3.properties index efb734d..847c74b 100644 --- a/devices/led_ctrl_3.properties +++ b/devices/led_ctrl_3.properties @@ -1,4 +1,4 @@ -#Fri Aug 06 09:14:09 CEST 2021 +#Tue Oct 05 15:05:31 CEST 2021 minValue=0.0 unit=V offset=0.0 diff --git a/script/motion/mount.py b/script/motion/mount.py index df9cffc..9443755 100644 --- a/script/motion/mount.py +++ b/script/motion/mount.py @@ -1,215 +1,215 @@ -mount_sample_id = None -mount_sample_detected = None - -def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False): - """ - """ - global mount_sample_id, mount_sample_detected - tg = time.time - t1 = tg() - print "mount: ", segment, puck, sample, force - - is_aux = (segment == AUX_SEGMENT) - is_rt = (segment == RT_SEGMENT) - is_normal = not (is_aux or is_rt) - - 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 - mounting_in_same_segment = (previous_segment == segment) - - # 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) - - pin_offset = get_pin_offset() - - puck_address = get_puck_address(puck) - if puck_address is None: - puck_obj = get_puck_obj_by_id(puck) - if puck_obj is not None: - puck_address = puck_obj.name - if puck_address is not None: - print "puck address: ", puck_address - segment = puck_address[:1] - puck = int(puck_address[1:]) - #Initial checks - print "%4.1f s asserting" % (tg() - t1,) - #Initial checks - assert_valid_address(segment, puck, sample) - assert_puck_detected(segment, puck) - - if robot.simulated: - time.sleep(3.0) - mount_sample_detected = True - mount_sample_id = "YYY0001" - update_samples_info_sample_mount(get_puck_name(segment, puck), sample, mount_sample_detected, mount_sample_id) - set_setting("mounted_sample_position", get_sample_name(segment, puck, sample)) - return [mount_sample_detected, mount_sample_id] - - robot.assert_no_task() - robot.reset_motion() - robot.wait_ready() - robot.assert_cleared() - #robot.assert_in_known_point() - hexiposi.assert_homed() - assert_mount_position() - do_unmount = False - print "%4.1f s asserted " % (tg() - t1,) - - # 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)) - - print "%4.1f s SMC checked" % (tg() - t1,) - - - - mounting_in_same_segment = False - - 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): - if mounting_in_same_segment: - print " Mounting from the same segment" - #auto_unmount set to true so detection remains enabled - print "%4.1f s unmounting" % (tg() - t1,) - sample_det = unmount(force = True, auto_unmount = True, mounting_in_same_segment=mounting_in_same_segment, next_segment=segment) - print "%4.1f s ....done" % (tg() - t1,) - - 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() - - #Enabling. If did unmount then it is already enabled. - if not do_unmount: - enable_motion() - - if needs_drying: - dry(wait_cold=-1) # move to park after dry - - if is_aux: - if not robot.is_aux(): - robot.move_aux() - robot.get_aux(sample) - - elif is_rt: - if not robot.is_rt(): - robot.move_rt() - robot.get_rt(puck, sample) - # TODO: implement room temperature for X06SA - else: - print "%4.1f s moving lid " % (tg() - t1,) - - set_hexiposi(segment) - if not force: - visual_check_hexiposi(segment) - if (not robot.is_dewar()) and (not mounting_in_same_segment): - robot.move_dewar() - print "%4.1f s get_dewar" % (tg() - t1,) - robot.get_dewar(segment, puck, sample, mounting_in_same_segment=mounting_in_same_segment) - - - 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,) - #time.sleep(1.0) - 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) - else: - mount_sample_id = None - - print "%4.1f s moving cryo out" % (tg() - t1,) - curpos = cryopos.getPosition() - speed = cryopos.getSpeed() / 1000. - movetime = int(round(3000 + abs(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,) - - if is_normal: - print "%4.1f s async moving cryo to 5mm " % (tg() - t1,) - cryopos.moveAsync(12.0) - - 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 "%4.1f s mount/moving home in RT" % (tg() - t1,) - robot.move_home() - elif is_normal: - print "%4.1f 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() - 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) - if mount_sample_detected == False: - raise Exception("No pin detected on gonio") - - - if is_force_dry(): - smart_magnet.set_default_current() - print "%4.1f Auto dry async" % (tg() - t1,) - log("Starting auto dry", False) - 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,) - smart_magnet.set_default_current() - smart_magnet.set_supress(True) +mount_sample_id = None +mount_sample_detected = None + +def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False): + """ + """ + global mount_sample_id, mount_sample_detected + tg = time.time + t1 = tg() + print "mount('%s', %d, %d, force=%d, read_dm=%d, auto_unmount=%d)" % (segment, puck, sample, force, read_dm, auto_unmount) + + is_aux = (segment == AUX_SEGMENT) + is_rt = (segment == RT_SEGMENT) + is_normal = not (is_aux or is_rt) + + 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 + mounting_in_same_segment = (previous_segment == segment) + + # 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) + + pin_offset = get_pin_offset() + + puck_address = get_puck_address(puck) + if puck_address is None: + puck_obj = get_puck_obj_by_id(puck) + if puck_obj is not None: + puck_address = puck_obj.name + if puck_address is not None: + print "puck address: ", puck_address + segment = puck_address[:1] + puck = int(puck_address[1:]) + #Initial checks + print "%4.1f s asserting" % (tg() - t1,) + #Initial checks + assert_valid_address(segment, puck, sample) + assert_puck_detected(segment, puck) + + if robot.simulated: + time.sleep(3.0) + mount_sample_detected = True + mount_sample_id = "YYY0001" + update_samples_info_sample_mount(get_puck_name(segment, puck), sample, mount_sample_detected, mount_sample_id) + set_setting("mounted_sample_position", get_sample_name(segment, puck, sample)) + return [mount_sample_detected, mount_sample_id] + + robot.assert_no_task() + robot.reset_motion() + robot.wait_ready() + robot.assert_cleared() + #robot.assert_in_known_point() + hexiposi.assert_homed() + assert_mount_position() + do_unmount = False + print "%4.1f s asserted " % (tg() - t1,) + + # 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)) + + print "%4.1f s SMC checked" % (tg() - t1,) + + + + mounting_in_same_segment = False + + 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): + if mounting_in_same_segment: + print " Mounting from the same segment" + #auto_unmount set to true so detection remains enabled + print "%4.1f s unmounting" % (tg() - t1,) + sample_det = unmount(force = True, auto_unmount = True, mounting_in_same_segment=mounting_in_same_segment, next_segment=segment) + print "%4.1f s ....done" % (tg() - t1,) + + 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() + + #Enabling. If did unmount then it is already enabled. + if not do_unmount: + enable_motion() + + if needs_drying: + dry(wait_cold=-1) # move to park after dry + + if is_aux: + if not robot.is_aux(): + robot.move_aux() + robot.get_aux(sample) + + elif is_rt: + if not robot.is_rt(): + robot.move_rt() + robot.get_rt(puck, sample) + # TODO: implement room temperature for X06SA + else: + print "%4.1f s moving lid " % (tg() - t1,) + + set_hexiposi(segment) + if not force: + visual_check_hexiposi(segment) + if (not robot.is_dewar()) and (not mounting_in_same_segment): + robot.move_dewar() + print "%4.1f s get_dewar" % (tg() - t1,) + robot.get_dewar(segment, puck, sample, mounting_in_same_segment=mounting_in_same_segment) + + + 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,) + #time.sleep(1.0) + 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) + else: + mount_sample_id = None + + print "%4.1f s moving cryo out" % (tg() - t1,) + curpos = cryopos.getPosition() + speed = cryopos.getSpeed() / 1000. + movetime = int(round(3000 + abs(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,) + + if is_normal: + print "%4.1f s async moving cryo to 5mm " % (tg() - t1,) + cryopos.moveAsync(12.0) + + 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 "%4.1f s mount/moving home in RT" % (tg() - t1,) + robot.move_home() + elif is_normal: + print "%4.1f 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() + 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) + if mount_sample_detected == False: + raise Exception("No pin detected on gonio") + + + if is_force_dry(): + smart_magnet.set_default_current() + print "%4.1f Auto dry async" % (tg() - t1,) + log("Starting auto dry", False) + 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,) + smart_magnet.set_default_current() + smart_magnet.set_supress(True)