210 lines
7.2 KiB
Python
210 lines
7.2 KiB
Python
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
|
|
evlog = Controller.getInstance().logEvent
|
|
print "mount(\"%s\", %d, %d, force=%d, read_dm=%d, auto_unmount=%d)" % (segment, puck, sample, force, read_dm, auto_unmount)
|
|
|
|
start = time.time()
|
|
cover_info = get_cover_location_mm()
|
|
was_cold = robot.is_cold()
|
|
is_aux = segment == AUX_SEGMENT
|
|
is_rt = segment == RT_SEGMENT
|
|
is_cold = segment in COLD_SEGMENTS
|
|
needs_chilling = is_cold and not was_cold
|
|
needs_drying = is_rt and was_cold
|
|
|
|
delayed_chill = False
|
|
pos = get_setting("mounted_sample_position")
|
|
if pos is not None:
|
|
try:
|
|
ss, pp , mm = pos[0:1], int(pos[1]), int(pos[2:])
|
|
delayed_chill = 'X' == ss and needs_chilling
|
|
except:
|
|
err_msg = "Invalid mounted sample position: " + str(pos) + " - setting to None";
|
|
log(err_msg , False)
|
|
set_setting("mounted_sample_position", None)
|
|
if auto_unmount:
|
|
raise Exception(err_msg)
|
|
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
|
|
assert_detector_safe()
|
|
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()
|
|
assert_mount_position()
|
|
do_unmount = False
|
|
|
|
try:
|
|
#ZACH
|
|
if needs_chilling and not delayed_chill:
|
|
#added bt domi 26.8.2025
|
|
set_setting("dry_timestamp",time.time())
|
|
set_setting("dry_mount_counter", 0)
|
|
robot.move_dewar(*cover_info)
|
|
robot.move_cold()
|
|
time.sleep(30.0)
|
|
invalidate_cover_info(cover_info)
|
|
|
|
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.6, timeout = 2.0)
|
|
evlog("SMC Detection: ", "sample on gonio" if sample_det else "gonio free")
|
|
|
|
if sample_det == True:
|
|
if auto_unmount and (get_setting("mounted_sample_position") is not None):
|
|
evlog("sample detected on gonio, calling unmount script")
|
|
#auto_unmount set to true so detection remains enabled
|
|
sample_det = unmount(force = True, auto_unmount = True)
|
|
do_unmount = True
|
|
if sample_det == True:
|
|
raise Exception("Pin detected on gonio")
|
|
|
|
set_status("Mounting: " + str(segment) + str(puck) + str(sample))
|
|
evlog("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 delayed_chill:
|
|
robot.move_dewar(*cover_info)
|
|
robot.move_cold()
|
|
time.sleep(30.0)
|
|
invalidate_cover_info(cover_info)
|
|
|
|
#ZACH
|
|
# 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.get_aux(sample)
|
|
|
|
else:
|
|
if not robot.is_dewar():
|
|
robot.move_dewar(*cover_info)
|
|
invalidate_cover_info(cover_info)
|
|
|
|
robot.get_dewar(segment, puck, sample)
|
|
|
|
|
|
if read_dm:
|
|
barcode_reader.start_read(10.0)
|
|
robot.move_scanner()
|
|
#time.sleep(1.0)
|
|
|
|
#print "moving cryo out to 17"
|
|
cryostage.moveAsync(15.0)
|
|
#print "waiting cryo out to 17"
|
|
#cryostage.waitInPosition(15.0, 3500)
|
|
|
|
#time.sleep(0.05)
|
|
#if cryostage.getDoneChannel().getValue()=0
|
|
|
|
print "move_gonio"
|
|
robot.move_gonio()
|
|
|
|
|
|
if read_dm:
|
|
mount_sample_id = barcode_reader.get_readout()
|
|
print "Datamatrix: " , mount_sample_id
|
|
else:
|
|
mount_sample_id = None
|
|
|
|
cryostage.waitInPosition(15.0, 3500)
|
|
|
|
print "put_gonio"
|
|
robot.put_gonio()
|
|
#set_pin_cleaner(True)
|
|
print get_valves_states()
|
|
if not is_aux:
|
|
cryostage.moveAsync(5.0)
|
|
|
|
# cleaner_timer = float(get_setting("pin_cleaner_timer"))
|
|
# if cleaner_timer > 0:
|
|
# start_pin_cleaner(cleaner_timer)
|
|
|
|
|
|
if is_aux:
|
|
robot.move_park_async()
|
|
else:
|
|
robot.move_dewar(*cover_info)
|
|
if is_force_dry():
|
|
robot.move_park_async()
|
|
else:
|
|
robot.move_cold_async()
|
|
|
|
robot.wait_async_motion()
|
|
|
|
|
|
mount_sample_detected = smart_magnet.check_mounted(idle_time=0.6, timeout = 2.0, interval=0.1)
|
|
|
|
evlog("SMC Detection", str(mount_sample_detected))
|
|
|
|
print "updating sample mounted info in spreadsheet"
|
|
update_samples_info_sample_mount(get_puck_name(segment, puck), sample, mount_sample_detected, mount_sample_id)
|
|
|
|
if mount_sample_detected == False:
|
|
evlog("MISSING SAMPLE: No pin detected on gonio")
|
|
raise Exception("MISSING SAMPLE: No pin detected on gonio")
|
|
|
|
keep_gripper_warm = was_cold and is_aux
|
|
|
|
if is_force_dry() or keep_gripper_warm:
|
|
print "Auto dry after setting magnet to default current"
|
|
smart_magnet.set_default_current()
|
|
log("Starting auto dry", False)
|
|
if keep_gripper_warm or is_aux:
|
|
set_exec_pars(then = "dry(wait_cold = -1)")
|
|
else:
|
|
set_exec_pars(then = "dry()")
|
|
else:
|
|
try:
|
|
dry_mount_count = int(get_setting("dry_mount_counter"))
|
|
except:
|
|
dry_mount_count = 0
|
|
set_setting("dry_mount_counter", dry_mount_count+1)
|
|
|
|
|
|
print "setting mounted sample to %s%d-%d" % (segment, puck, sample)
|
|
set_setting("mounted_sample_position", get_sample_name(segment, puck, sample))
|
|
return [mount_sample_detected, mount_sample_id]
|
|
finally:
|
|
smart_magnet.set_default_current()
|
|
smart_magnet.set_supress(True)
|
|
|