82 lines
2.5 KiB
Python
82 lines
2.5 KiB
Python
def unmount(segment = None, puck = None, sample = None, force=False, auto_unmount = False):
|
|
"""
|
|
"""
|
|
print "unmount: ", segment, puck, sample, force
|
|
|
|
|
|
if (segment is None) or (puck is None) or (sample is None):
|
|
pos = get_setting("mounted_sample_position")
|
|
if pos is None:
|
|
raise Exception("Mounted sample position is not defined")
|
|
segment, puck , sample = pos[0:1], int(pos[1]), int(pos[2:])
|
|
print "Mounted sample position: ", segment, puck , sample
|
|
|
|
is_aux = (segment == AUX_SEGMENT)
|
|
|
|
#Initial checks
|
|
assert_valid_address(segment, puck, sample)
|
|
assert_puck_detected(segment, puck)
|
|
|
|
if robot.simulated:
|
|
time.sleep(3.0)
|
|
update_samples_info_sample_unmount(get_puck_name(segment, puck), sample)
|
|
set_setting("mounted_sample_position", None)
|
|
return
|
|
|
|
robot.assert_no_task()
|
|
robot.reset_motion()
|
|
robot.wait_ready()
|
|
robot.assert_cleared()
|
|
#robot.assert_in_known_point()
|
|
hexiposi.assert_homed()
|
|
assert_mount_position()
|
|
|
|
set_status("Umounting: " + str(segment) + str(puck) + str(sample))
|
|
|
|
try:
|
|
if smart_magnet.get_supress() == True:
|
|
smart_magnet.set_supress(False)
|
|
time.sleep(0.2)
|
|
|
|
smart_magnet.apply_reverse()
|
|
smart_magnet.apply_resting()
|
|
|
|
if not force:
|
|
if smart_magnet.check_mounted(idle_time=0.5, timeout = 3.0) == False:
|
|
raise Exception("No pin detected on gonio")
|
|
|
|
#Enabling
|
|
enable_motion()
|
|
|
|
set_hexiposi(segment)
|
|
|
|
if not force:
|
|
visual_check_hexiposi(segment)
|
|
|
|
|
|
if not robot.is_gonio():
|
|
robot.move_gonio()
|
|
|
|
|
|
robot.get_gonio()
|
|
|
|
if is_aux:
|
|
robot.move_aux()
|
|
robot.put_aux( sample)
|
|
else:
|
|
#TODO: Shuld check if smart magnet detection is off?
|
|
update_samples_info_sample_unmount(get_puck_name(segment, puck), sample)
|
|
robot.move_home()
|
|
robot.open_lid(segment)
|
|
robot.put_rt(segment, puck, sample)
|
|
set_setting("mounted_sample_position", None)
|
|
|
|
#imporant to be the very last command for the logic on chained mount
|
|
if not auto_unmount:
|
|
robot.close_lid(segment)
|
|
robot.move_park()
|
|
finally:
|
|
if not auto_unmount:
|
|
smart_magnet.set_default_current()
|
|
smart_magnet.set_supress(True)
|