124 lines
4.2 KiB
Python
124 lines
4.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
|
|
print "mount: ", segment, puck, sample
|
|
|
|
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()
|
|
assert_mount_position()
|
|
|
|
lid_open_by_unmount = False
|
|
try:
|
|
|
|
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)
|
|
if smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) == True:
|
|
mounted_sample = get_setting("mounted_sample_position")
|
|
if auto_unmount and ( mounted_sample is not None):
|
|
previous_segment = mounted_sample[0:1]
|
|
#auto_unmount set to true so detection remains enabled
|
|
unmount(force = True, auto_unmount = True)
|
|
#We know the lid is open for sure
|
|
lid_open_by_unmount = 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 lid_open_by_unmount:
|
|
lid_open_by_unmount = False
|
|
robot.close_lid(segment)
|
|
if not robot.is_aux():
|
|
robot.move_aux()
|
|
robot.get_aux(sample)
|
|
|
|
else:
|
|
|
|
if not robot.is_home():
|
|
if (not lid_open_by_unmount) or (segment != previous_segment):
|
|
robot.move_home()
|
|
|
|
set_hexiposi(segment)
|
|
|
|
if not force:
|
|
visual_check_hexiposi(segment)
|
|
|
|
if not lid_open_by_unmount:
|
|
robot.open_lid(segment)
|
|
lid_open_by_unmount = False
|
|
|
|
robot.get_rt(segment, puck, sample) #Should we close lid if this command raise exception?
|
|
robot.close_lid(segment)
|
|
|
|
robot.move_gonio()
|
|
|
|
if read_dm:
|
|
mount_sample_id = barcode_reader.get_readout()
|
|
print "Datamatrix: " , mount_sample_id
|
|
else:
|
|
mount_sample_id = None
|
|
|
|
|
|
robot.put_gonio()
|
|
|
|
#robot.move_home()
|
|
|
|
|
|
mount_sample_detected = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0)
|
|
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")
|
|
|
|
set_setting("mounted_sample_position", get_sample_name(segment, puck, sample))
|
|
return [mount_sample_detected, mount_sample_id]
|
|
except:
|
|
if lid_open_by_unmount:
|
|
robot.close_lid(segment)
|
|
raise
|
|
finally:
|
|
smart_magnet.set_default_current()
|
|
smart_magnet.set_supress(True)
|
|
|