This commit is contained in:
@@ -117,7 +117,7 @@ class Hexiposi(DiscretePositionerBase):
|
||||
self.update()
|
||||
|
||||
def is_in_position(self, pos):
|
||||
return take() == pos
|
||||
return self.take() == pos
|
||||
|
||||
|
||||
def assert_in_position(self, pos):
|
||||
@@ -128,6 +128,10 @@ class Hexiposi(DiscretePositionerBase):
|
||||
if self.homed == False:
|
||||
raise Exception ("Hexiposi is not homed")
|
||||
|
||||
def assert_in_known_position(self):
|
||||
self.get_status()
|
||||
if self.rback == 'Unknown':
|
||||
raise Exception("Hexiposi is in an unknown position, please home.")
|
||||
|
||||
#def isReady(self):
|
||||
# self.get_status()
|
||||
|
||||
@@ -31,8 +31,9 @@ class SmartMagnet(DeviceBase):
|
||||
return smc_magnet_status.read()
|
||||
|
||||
def assert_status(self):
|
||||
if self.get_status() == False:
|
||||
raise Exception("Smart Magnet is in faulty status.")
|
||||
pass
|
||||
#if self.get_status() == False:
|
||||
# raise Exception("Smart Magnet is in faulty status.")
|
||||
|
||||
def is_mounted(self):
|
||||
self.assert_status()
|
||||
@@ -72,7 +73,9 @@ class SmartMagnet(DeviceBase):
|
||||
|
||||
def doUpdate(self):
|
||||
try:
|
||||
if self.is_mounted():
|
||||
if self.get_supress():
|
||||
self.setState(State.Paused)
|
||||
elif self.is_mounted():
|
||||
self.setState(State.Busy)
|
||||
else:
|
||||
self.setState(State.Ready)
|
||||
@@ -104,15 +107,18 @@ class SmartMagnet(DeviceBase):
|
||||
return self.get_current() == self.config.getFieldValue("restingCurrent")
|
||||
|
||||
|
||||
#Setting resting current to better detect sample
|
||||
def enforce_sample_detection(self):
|
||||
def apply_reverse(self):
|
||||
reverse_wait = float(self.config.getFieldValue("reverseTime"))
|
||||
if reverse_wait >0:
|
||||
self.set_reverse_current()
|
||||
time.sleep(reverse_wait)
|
||||
|
||||
#Setting resting current to better detect sample
|
||||
def apply_resting(self):
|
||||
if not self.is_resting_current():
|
||||
self.set_resting_current()
|
||||
time.sleep(0.2)
|
||||
|
||||
|
||||
|
||||
|
||||
add_device(SmartMagnet("smart_magnet"), force = True)
|
||||
|
||||
+28
-2
@@ -149,6 +149,8 @@ def system_check(robot_move=True):
|
||||
raise Exception("Air pressure is not ok")
|
||||
if not n2_pressure_ok.read():
|
||||
raise Exception("N2 pressure is not ok")
|
||||
hexiposi.assert_in_known_position()
|
||||
|
||||
if robot_move:
|
||||
if not feedback_local_safety.read():
|
||||
raise Exception("Local safety not released")
|
||||
@@ -165,9 +167,15 @@ def system_check_msg():
|
||||
return "Ok"
|
||||
except:
|
||||
return sys.exc_info()[1]
|
||||
|
||||
|
||||
def get_puck_dev(segment, puck):
|
||||
if type(segment) is int:
|
||||
segment = chr( ord('A') + (segment-1))
|
||||
|
||||
return Controller.getInstance().getPuck(str(segment).upper() + str(puck))
|
||||
|
||||
def get_puck_elect_detection(segment, puck):
|
||||
return str(Controller.getInstance().getPuck(str(segment).upper() + str(puck)).detection)
|
||||
return str(get_puck_dev(segment, puck).detection)
|
||||
|
||||
def get_puck_img_detection(segment, puck):
|
||||
return str(Controller.getInstance().getPuck(str(segment).upper() + str(puck)).imageDetection)
|
||||
@@ -198,6 +206,18 @@ def get_detected_pucks():
|
||||
ret.append(str(p.getName()))
|
||||
return ret
|
||||
|
||||
def get_pucks_info():
|
||||
ret = []
|
||||
for i in range(30):
|
||||
p = BasePlate.getPucks()[i]
|
||||
name = p.getName()
|
||||
det = str(p.getDetection())
|
||||
barcode = "" if p.getId() is None else p.getId()
|
||||
|
||||
ret.append({"puckAddress": name, "puckState": det, "puckBarcode":barcode})
|
||||
return json.dumps(ret)
|
||||
|
||||
|
||||
###################################################################################################
|
||||
# Device initialization
|
||||
###################################################################################################
|
||||
@@ -253,6 +273,12 @@ if is_imaging_enabled():
|
||||
except:
|
||||
print >> sys.stderr, traceback.format_exc()
|
||||
|
||||
#TODO: The Smart Magnet keeps moving sample if detecting is enabled
|
||||
# Detection keeps disabled unless during moount/unmount
|
||||
try:
|
||||
smart_magnet.set_supress(True)
|
||||
except:
|
||||
print >> sys.stderr, traceback.format_exc()
|
||||
|
||||
#gripper_cam.paused = True
|
||||
###################################################################################################
|
||||
|
||||
@@ -12,5 +12,7 @@ def homing_hexiposi():
|
||||
|
||||
set_status("Homing hexiposi")
|
||||
hexiposi.move_home()
|
||||
hexiposi.waitState(State.Ready,-1)
|
||||
hexiposi.waitState(State.Ready,-1)
|
||||
hexiposi.move_pos(1)
|
||||
|
||||
|
||||
+34
-29
@@ -7,13 +7,13 @@ 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()
|
||||
|
||||
start = time.time()
|
||||
#time.sleep(2)
|
||||
is_aux = (segment == AUX_SEGMENT)
|
||||
|
||||
#ZACH
|
||||
#needs_chilling = not is_aux and (not robot.is_cold())
|
||||
#needs_drying = is_aux and robot.is_cold()
|
||||
needs_chilling = not is_aux and (not robot.is_cold())
|
||||
needs_drying = is_aux and robot.is_cold()
|
||||
|
||||
puck_address = get_puck_address(puck)
|
||||
if puck_address is None:
|
||||
@@ -47,17 +47,21 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
|
||||
|
||||
try:
|
||||
#ZACH
|
||||
#if needs_chilling:
|
||||
# robot.move_cold()
|
||||
# time.sleep(30.0)
|
||||
if needs_chilling:
|
||||
robot.move_cold()
|
||||
time.sleep(30.0)
|
||||
|
||||
smart_magnet.enforce_sample_detection()
|
||||
if smart_magnet.get_supress() == True:
|
||||
smart_magnet.set_supress(False)
|
||||
time.sleep(0.2)
|
||||
#To better dectect sample
|
||||
smart_magnet.apply_resting()
|
||||
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)
|
||||
#auto_unmount set to true so detection remains enabled
|
||||
unmount(force = True, auto_unmount = True)
|
||||
else:
|
||||
raise Exception("Pin detected on gonio")
|
||||
|
||||
raise Exception("Pin detected on gonio")
|
||||
set_status("Mounting: " + str(segment) + str(puck) + str(sample))
|
||||
#location = robot.get_current_point()
|
||||
|
||||
@@ -65,8 +69,9 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
|
||||
enable_motion()
|
||||
|
||||
#ZACH
|
||||
#if needs_drying:
|
||||
# dry(wait_cold=-1)
|
||||
# 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():
|
||||
@@ -85,9 +90,7 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
|
||||
|
||||
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()
|
||||
@@ -100,12 +103,11 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
|
||||
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:
|
||||
@@ -117,18 +119,21 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
|
||||
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")
|
||||
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")
|
||||
|
||||
|
||||
if is_force_dry():
|
||||
smart_magnet.set_default_current()
|
||||
print "Auto dry"
|
||||
log("Starting auto dry", False)
|
||||
dry()
|
||||
if is_force_dry():
|
||||
smart_magnet.set_default_current()
|
||||
print "Auto dry"
|
||||
log("Starting auto dry", False)
|
||||
set_exec_pars(then = "dry()")
|
||||
|
||||
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)
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ def get_dist_to_segment(segment):
|
||||
l = Line3D(v1, v2, 0.01)
|
||||
d = l.distance(v)
|
||||
|
||||
pj = get_pojection_at_line(segment)
|
||||
pj = get_projection_at_line(segment)
|
||||
|
||||
d1, d2 = v1.distance(v), v2.distance(v)
|
||||
dp1, dp2 = v1.distance(pj), v2.distance(pj)
|
||||
@@ -61,7 +61,7 @@ def is_on_segment(segment):
|
||||
#print "Current robot position " + str(p) + " on segment " + str(segment) + " - distance=" + str(d)
|
||||
return True
|
||||
|
||||
def get_pojection_at_line(segment):
|
||||
def get_projection_at_line(segment):
|
||||
tolerance = segment[2]
|
||||
p1, p2 = robot.get_pnt(segment[0]), robot.get_pnt(segment[1])
|
||||
p = get_robot_position()
|
||||
@@ -91,7 +91,7 @@ def move_to_segment(segment):
|
||||
tolerance = segment[2]
|
||||
p = get_robot_position()
|
||||
v = Vector3D(p[0], p[1], p[2])
|
||||
lv = get_pojection_at_line(segment)
|
||||
lv = get_projection_at_line(segment)
|
||||
dlv = lv.distance(v)
|
||||
if dlv> (tolerance + 0.1):
|
||||
raise Exception( "Error moving from " + str(p) + " to segment - distance=" + str(dlv))
|
||||
|
||||
@@ -140,6 +140,8 @@ def assert_valid_address(segment, puck, sample):
|
||||
raise Exception ("Invalid puck")
|
||||
if sample<=0 or sample >16:
|
||||
raise Exception ("Invalid sample")
|
||||
if get_puck_dev(segment, puck).isDisabled():
|
||||
raise Exception ("Puck is disabled")
|
||||
|
||||
def assert_valid_sample(sample):
|
||||
if sample<=0 or sample >16:
|
||||
|
||||
+38
-13
@@ -1,7 +1,12 @@
|
||||
def unmount(segment = None, puck = None, sample = None, force=False):
|
||||
def unmount(segment = None, puck = None, sample = None, force=False, auto_unmount = False):
|
||||
"""
|
||||
"""
|
||||
print "unmount: ", segment, puck, sample, force
|
||||
print "unmount: ", segment, puck, sample, force
|
||||
|
||||
#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")
|
||||
@@ -9,10 +14,11 @@ def unmount(segment = None, puck = None, sample = None, force=False):
|
||||
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
|
||||
print "assert valid address"
|
||||
assert_valid_address(segment, puck, sample)
|
||||
print "asser puck detected"
|
||||
assert_puck_detected(segment, puck)
|
||||
|
||||
if robot.simulated:
|
||||
@@ -20,23 +26,33 @@ def unmount(segment = None, puck = None, sample = None, force=False):
|
||||
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()
|
||||
|
||||
set_status("Umounting: " + str(segment) + str(puck) + str(sample))
|
||||
|
||||
try:
|
||||
if not force:
|
||||
smart_magnet.enforce_sample_detection()
|
||||
if smart_magnet.check_mounted(idle_time=0.5, timeout = 3.0) == False:
|
||||
raise Exception("No pin detected on gonio")
|
||||
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")
|
||||
|
||||
#Enabling
|
||||
enable_motion()
|
||||
@@ -46,16 +62,24 @@ def unmount(segment = None, puck = None, sample = None, force=False):
|
||||
|
||||
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()
|
||||
|
||||
if not robot.is_gonio():
|
||||
robot.move_gonio()
|
||||
|
||||
smart_magnet.set_unmount_current()
|
||||
|
||||
#smart_magnet.set_unmount_current()
|
||||
|
||||
robot.get_gonio()
|
||||
|
||||
#smart_magnet.apply_reverse()
|
||||
#smart_magnet.apply_resting()
|
||||
|
||||
if is_aux:
|
||||
robot.move_aux()
|
||||
robot.put_aux( sample)
|
||||
@@ -66,5 +90,6 @@ def unmount(segment = None, puck = None, sample = None, force=False):
|
||||
robot.put_dewar(segment, puck, sample)
|
||||
set_setting("mounted_sample_position", None)
|
||||
finally:
|
||||
smart_magnet.set_default_current()
|
||||
|
||||
if not auto_unmount:
|
||||
smart_magnet.set_default_current()
|
||||
smart_magnet.set_supress(True)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
time.sleep(3.0)
|
||||
|
||||
set_exec_pars(then = "time.sleep(5.0)")
|
||||
Reference in New Issue
Block a user