Files
x06da/script/test/unmount_profile.py
gac-S_Changer c85d4b4aa9 Startup
2020-09-08 11:53:11 +02:00

99 lines
3.6 KiB
Python

def unmount(segment = None, puck = None, sample = None, force=False, auto_unmount = False):
"""
"""
print "unmount: ", segment, puck, sample, force
start = time.time()
#ZACH
is_aux = (segment == AUX_SEGMENT)
needs_chilling = not is_aux and (not robot.is_cold())
needs_drying = is_aux and robot.is_cold()
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
#Initial checks
print "assert valid address"
assert_valid_address(segment, puck, sample)
print "asser puck detected"
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
print "assert no task"
robot.assert_no_task()
print "reset motion"
robot.reset_motion()
print "wait ready"
robot.wait_ready()
print "assert cleared"
robot.assert_cleared()
#robot.assert_in_known_point()
print "assert homed"
hexiposi.assert_homed()
print "assert mount pos"
assert_mount_position()
print "Pass A: " , time.time() - start; start = time.time()
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_resting()
if not force:
if smart_magnet.check_mounted(idle_time=0.5, timeout = 3.0) == False:
raise Exception("No pin detected on gonio")
print "Pass B: " , time.time() - start; start = time.time()
#Enabling
enable_motion()
print "Pass C: " , time.time() - start; start = time.time()
if not is_aux:
set_hexiposi(segment)
print "Pass D: " , time.time() - start; start = time.time()
if not force:
visual_check_hexiposi(segment)
if needs_chilling:
robot.move_cold()
time.sleep(30.)
else:
if needs_drying:
dry(wait_cold=-1)
#location = robot.get_current_point()
print "Pass E: " , time.time() - start; start = time.time()
if not robot.is_gonio():
robot.move_gonio()
print "Pass F: " , time.time() - start; start = time.time()
#smart_magnet.set_unmount_current()
robot.get_gonio()
print "Pass G: " , time.time() - start; start = time.time()
#smart_magnet.apply_reverse()
#smart_magnet.apply_resting()
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_dewar()
print "Pass H: " , time.time() - start; start = time.time()
robot.put_dewar(segment, puck, sample)
print "Pass I: " , time.time() - start; start = time.time()
set_setting("mounted_sample_position", None)
finally:
if not auto_unmount:
smart_magnet.set_default_current()
smart_magnet.set_supress(True)