120 lines
3.9 KiB
Python
120 lines
3.9 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
|
|
print "mount: ", segment, puck, sample, force
|
|
|
|
start = time.time()
|
|
|
|
is_aux = (segment == AUX_SEGMENT)
|
|
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_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()
|
|
|
|
|
|
try:
|
|
smart_magnet.enforce_sample_detection()
|
|
if smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) == True:
|
|
if auto_unmount and (get_setting("mounted_sample_position") is not None):
|
|
unmount(force = True)
|
|
else:
|
|
raise Exception("Pin detected on gonio")
|
|
|
|
set_status("Mounting: " + str(segment) + str(puck) + str(sample))
|
|
#location = robot.get_current_point()
|
|
|
|
#Enabling
|
|
enable_motion()
|
|
|
|
if is_aux:
|
|
if not robot.is_aux():
|
|
robot.move_aux()
|
|
|
|
robot.get_aux(sample)
|
|
|
|
else:
|
|
set_hexiposi(segment)
|
|
|
|
if not force:
|
|
visual_check_hexiposi(segment)
|
|
|
|
if not robot.is_dewar():
|
|
robot.move_dewar()
|
|
|
|
robot.get_dewar(segment, puck, sample)
|
|
|
|
|
|
set_setting("mounted_sample_position", get_sample_name(segment, puck, sample))
|
|
|
|
if read_dm:
|
|
barcode_reader.start_read(10.0)
|
|
robot.move_scanner()
|
|
#time.sleep(1.0)
|
|
|
|
robot.move_gonio()
|
|
|
|
if read_dm:
|
|
mount_sample_id = barcode_reader.get_readout()
|
|
print "Datamatrix: " , mount_sample_id
|
|
else:
|
|
mount_sample_id = None
|
|
|
|
smart_magnet.set_mount_current()
|
|
|
|
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:
|
|
robot.move_cold()
|
|
|
|
mount_sample_detected = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0)
|
|
#TODO: Should do on finally?
|
|
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 "Auto dry"
|
|
log("Starting auto dry", False)
|
|
dry()
|
|
return [mount_sample_detected, mount_sample_id]
|
|
finally:
|
|
smart_magnet.set_default_current()
|
|
|