gripper switches implementation, readout only
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
#Thu Oct 07 15:50:53 CEST 2021
|
||||
dry_mount_counter=0
|
||||
#Wed Oct 13 15:20:54 CEST 2021
|
||||
dry_mount_counter=5
|
||||
mounted_sample_position=D214
|
||||
room_temperature_enabled=false
|
||||
pin_offset=-0.0
|
||||
puck_types=true
|
||||
imaging_enabled=false
|
||||
dry_timestamp=1.633614653956E9
|
||||
dry_timestamp=1.634130424209E9
|
||||
roi_h=1000
|
||||
led_level=0.0
|
||||
beamline_status_enabled=false
|
||||
|
||||
@@ -247,19 +247,9 @@ class RobotSC(RobotTCP):
|
||||
#TODO: Restore safe position
|
||||
|
||||
def gripper_has_sample(self):
|
||||
"""checks gripper switches for presence of sample
|
||||
|
||||
return: None => unclear
|
||||
True => sample in gripper (grip. closed)
|
||||
False => no sample in gripper (grip. closed)
|
||||
"""
|
||||
sample, without = self.eval_bool("di_toolWithSample"), self.eval_bool("di_toolNoSample")
|
||||
if sample and not without:
|
||||
return True
|
||||
if not sample and without:
|
||||
return False
|
||||
else:
|
||||
return None
|
||||
"""checks gripper switches for presence of sample"""
|
||||
hasSample, toolOpen = self.eval_bool("diToolHasSample"), self.eval_bool("diToolOpen")
|
||||
return (not toolOpen) and hasSample
|
||||
|
||||
|
||||
def set_remote_mode(self):
|
||||
|
||||
@@ -102,6 +102,38 @@ def is_room_temperature_enabled():
|
||||
set_setting(ROOM_TEMPERATURE_ENABLED_PREFERENCE, is_room_temperature_enabled())
|
||||
|
||||
|
||||
def is_gripper_really_empty(timeout=2.0):
|
||||
timeout = timeout + time.time()
|
||||
while time.time() < timeout:
|
||||
if robot.eval_bool("diToolHasSample"):
|
||||
print "test"
|
||||
time.sleep(0.10)
|
||||
else:
|
||||
return True
|
||||
|
||||
msg = "WARNING 1st try: gripper should be empty, sample detected (dwell for 2s and try again)"
|
||||
log(msg, False)
|
||||
print msg
|
||||
time.sleep(2.0)
|
||||
|
||||
robot.eval_bool("diToolOpen")
|
||||
robot.eval_bool("diToolHasSample")
|
||||
|
||||
timeout = 2.0 + time.time()
|
||||
while time.time() < timeout:
|
||||
if robot.eval_bool("diToolHasSample"):
|
||||
print "test"
|
||||
time.sleep(0.10)
|
||||
else:
|
||||
return True
|
||||
|
||||
msg = "WARNING 2nd try: gripper should be empty, sample detected"
|
||||
log(msg, False)
|
||||
print printmsg
|
||||
|
||||
return False
|
||||
|
||||
|
||||
def is_beamline_status_enabled():
|
||||
setting = get_setting(BEAMLINE_STATUS_ENABLED_PREFERENCE)
|
||||
return str(setting).lower() == 'true'
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
def check_gripper(sample):
|
||||
print "tool open: " + str(robot.is_tool_open())
|
||||
print "gripper: " + str(robot.gripper_has_sample())
|
||||
print "di with sample: " + str(robot.eval_bool("di_toolWithSample"))
|
||||
print "di no sample: " + str(robot.eval_bool("di_toolNoSample"))
|
||||
print "di gripper has sample: " + str(robot.eval_bool("diToolHasSample"))
|
||||
print "di gripper open: " + str(robot.eval_bool("diToolOpen"))
|
||||
|
||||
def fetch_check_gripper(sample):
|
||||
if not robot.is_aux():
|
||||
@@ -10,8 +10,8 @@ def fetch_check_gripper(sample):
|
||||
robot.get_aux(sample)
|
||||
print "tool open: " + str(robot.is_tool_open())
|
||||
print "gripper: " + str(robot.gripper_has_sample())
|
||||
print "di with sample: " + str(robot.eval_bool("di_toolWithSample"))
|
||||
print "di no sample: " + str(robot.eval_bool("di_toolNoSample"))
|
||||
print "di with sample: " + str(robot.eval_bool("diToolHasSample"))
|
||||
print "di no sample: " + str(robot.eval_bool("diToolOpen"))
|
||||
|
||||
def swap_samples(a, b, empty):
|
||||
robot.get_aux(a)
|
||||
|
||||
+51
-35
@@ -1,13 +1,13 @@
|
||||
mount_sample_id = None
|
||||
mount_sample_detected = None
|
||||
|
||||
def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False):
|
||||
def mount(segment, puck, sample, force=True, read_dm=False, auto_unmount=False):
|
||||
"""
|
||||
"""
|
||||
global mount_sample_id, mount_sample_detected
|
||||
evlog = Controller.getInstance().logEvent
|
||||
tg = time.time
|
||||
t1 = tg()
|
||||
print " mount: ", segment, puck, sample, force
|
||||
|
||||
is_aux = (segment == AUX_SEGMENT)
|
||||
is_rt = (segment == RT_SEGMENT)
|
||||
@@ -20,7 +20,6 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
|
||||
previous_segment, previous_puck, previous_sample = "-", 0, 0
|
||||
mounting_in_same_segment = (previous_segment == segment)
|
||||
|
||||
# ZAC
|
||||
was_cold = robot.is_cold()
|
||||
was_warm = not was_cold
|
||||
needs_chilling = not is_rt and was_warm
|
||||
@@ -41,6 +40,7 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
|
||||
puck = int(puck_address[1:])
|
||||
|
||||
print "%4.1f s asserting" % (tg() - t1,)
|
||||
|
||||
#Initial checks
|
||||
assert_valid_address(segment, puck, sample)
|
||||
assert_puck_detected(segment, puck)
|
||||
@@ -68,13 +68,14 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
|
||||
smart_magnet.set_supress(False)
|
||||
time.sleep(0.2)
|
||||
sample_det = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0)
|
||||
Controller.getInstance().logEvent("Sample Detection", str(sample_det))
|
||||
evlog("SMC Sample Detection", str(sample_det))
|
||||
|
||||
print "%4.1f s SMC checked" % (tg() - t1,)
|
||||
|
||||
|
||||
mounting_in_same_segment = False
|
||||
|
||||
sampleAddress = str(segment) + str(puck) + "-" + str(sample)
|
||||
|
||||
try:
|
||||
if sample_det == True:
|
||||
if was_warm and previous_segment in COLD_SEGMENTS:
|
||||
@@ -94,17 +95,19 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
|
||||
if sample_det == True:
|
||||
raise Exception("Pin detected on gonio")
|
||||
|
||||
set_status("Mounting: " + str(segment) + str(puck) + str(sample))
|
||||
Controller.getInstance().logEvent("Mount Sample", str(segment) + str(puck) + str(sample))
|
||||
#location = robot.get_current_point()
|
||||
|
||||
#Enabling. If did unmount then it is already enabled.
|
||||
set_status("Mounting: " + sampleAddress)
|
||||
evlog("Mount Sample", sampleAddress)
|
||||
|
||||
if not do_unmount:
|
||||
enable_motion()
|
||||
|
||||
if needs_drying:
|
||||
dry(wait_cold=-1) # move to park after dry
|
||||
|
||||
###
|
||||
### FETCH SAMPLE TO MOUNT
|
||||
###
|
||||
|
||||
if is_aux:
|
||||
if not robot.is_aux():
|
||||
robot.move_aux()
|
||||
@@ -126,20 +129,20 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
|
||||
print "%4.1f s get_dewar" % (tg() - t1,)
|
||||
robot.get_dewar(segment, puck, sample, mounting_in_same_segment=mounting_in_same_segment)
|
||||
|
||||
|
||||
# grip_is_open = robot.is_tool_open()
|
||||
# grip_is_closed = not grip_is_open
|
||||
# pik = robot.gripper_has_sample()
|
||||
# grip_has_sample = grip_is_closed and pik
|
||||
# msg = "Sample Detection - mount: after get_dewar: gripper has sample={} sample={}{}{}".format(str(grip_has_sample), str(segment), str(puck), str(sample))
|
||||
# log(msg, False)
|
||||
# print msg
|
||||
#
|
||||
# if not grip_has_sample:
|
||||
# if is_aux or is_rt:
|
||||
# robot.move_park()
|
||||
# else:
|
||||
# robot.move_cold()
|
||||
|
||||
hasSample = robot.gripper_has_sample()
|
||||
msg = "WARNING GRIPPER-TEST - after robot.get_* gripper has sample={} sample={}".format(hasSample, sampleAddress)
|
||||
evlog(msg)
|
||||
print "%4.1f s %s" % (tg() - t1, msg)
|
||||
|
||||
if not hasSample:
|
||||
msg = "WARNING GRIPPER-TEST no sample in position {}".format(sampleAddress)
|
||||
evlog(msg)
|
||||
print "%4.1f s %s" % (tg() - t1, msg)
|
||||
if is_aux or is_rt:
|
||||
robot.move_park()
|
||||
else:
|
||||
robot.move_cold()
|
||||
raise Exception(msg)
|
||||
|
||||
if read_dm:
|
||||
@@ -155,6 +158,7 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
|
||||
if read_dm:
|
||||
print "%4.1f s reading pin barcode" % (tg() - t1,)
|
||||
mount_sample_id = barcode_reader.get_readout()
|
||||
print "%4.1f s ....done --- barcode: %s" % (tg() - t1, mount_sample_id)
|
||||
evlog("read pin barcode: %s" % (mount_sample_id,))
|
||||
else:
|
||||
mount_sample_id = None
|
||||
@@ -173,6 +177,7 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
|
||||
|
||||
print " ....done\n%4.1f s putting_gonio with pin_offset = %.1f mm" % (tg() - t1, pin_offset)
|
||||
robot.put_gonio()
|
||||
print "%4.1f s .....done" % (tg() - t1,)
|
||||
robot.close_tool() # closes gripper
|
||||
|
||||
if is_normal:
|
||||
@@ -193,7 +198,7 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
|
||||
if is_rt:
|
||||
print "%4.1f s mount/moving home in RT" % (tg() - t1,)
|
||||
robot.move_park()
|
||||
elif is_normal:
|
||||
elif is_normal:
|
||||
print "%4.1f s mount/moving cold in cold " % (tg() - t1,)
|
||||
robot.move_cold()
|
||||
elif is_aux:
|
||||
@@ -206,22 +211,33 @@ 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)
|
||||
mount_sample_detected = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0)
|
||||
evlog("Sample Detection", str(mount_sample_detected))
|
||||
update_samples_info_sample_mount(get_puck_name(segment, puck), sample, mount_sample_detected, mount_sample_id)
|
||||
|
||||
if mount_sample_detected != piked_sample:
|
||||
log("Sample Detection Error - after put on SM:" + str(mount_sample_detected) + " gripper:" + str(piked_sample), False)
|
||||
#if has_sample_after_put and mount_sample_detected:
|
||||
# log("Sample Detection Error - put SM:" + str(mount_sample_detected) + " gripper:" + str(has_sample_after_put), False)
|
||||
|
||||
if mount_sample_detected == False:
|
||||
|
||||
# Check gripper for frozen sample after trying to mount on gonio
|
||||
# if we detect a sample after closing gripper then we move the
|
||||
# gripper back to cold/park and call for local contact or give user
|
||||
# option to dry gripper and lose the sample
|
||||
|
||||
reallyEmpty = is_gripper_really_empty(1.2)
|
||||
if not reallyEmpty:
|
||||
msg = "WARNING GRIPPER-TEST still has a sample {} after mount attempt".format(sampleAddress)
|
||||
evlog(msg)
|
||||
print "%4.1f s %s" % (tg() - t1, msg)
|
||||
# raise Exception(msg)
|
||||
sampleDelivered = True
|
||||
robot.open_tool() # open gripper
|
||||
|
||||
if sampleDelivered and not mount_sample_detected:
|
||||
msg = "WARNING GRIPPER-TEST sample {} lost during mount".format(sampleAddress)
|
||||
evlog("SMC Sample Detection false after put gonio")
|
||||
print "%4.1f s %s" % (tg() - t1, msg)
|
||||
# raise Exception(msg)
|
||||
|
||||
|
||||
if is_force_dry():
|
||||
smart_magnet.set_default_current()
|
||||
print "%4.1f Auto dry async" % (tg() - t1,)
|
||||
print "%4.1f Auto dry async" % (tg() - t1,)
|
||||
evlog("Starting async auto dry")
|
||||
set_exec_pars(then = "dry()")
|
||||
|
||||
|
||||
+42
-16
@@ -1,7 +1,7 @@
|
||||
def unmount(segment = None, puck = None, sample = None, force=False, auto_unmount = False, next_segment="-*-", mounting_in_same_segment=False):
|
||||
def unmount(segment = None, puck = None, sample = None, force=True, auto_unmount = False, next_segment="-*-", mounting_in_same_segment=False):
|
||||
"""
|
||||
"""
|
||||
print "unmount: ", segment, puck, sample, force
|
||||
evlog = Controller.getInstance().logEvent
|
||||
tg = time.time
|
||||
t1 = tg()
|
||||
|
||||
@@ -12,6 +12,12 @@ def unmount(segment = None, puck = None, sample = None, force=False, auto_unmoun
|
||||
segment, puck , sample = pos[0:1], int(pos[1]), int(pos[2:])
|
||||
print "%4.1f Mounted sample position: %s%s-%s" % (tg() - t1, segment, puck , sample)
|
||||
|
||||
sampleAddress = str(segment) + str(puck) + "-" + str(sample)
|
||||
|
||||
msg = "Unmounting %s" % (sampleAddress,)
|
||||
print msg
|
||||
evlog(msg)
|
||||
|
||||
is_aux = (segment == AUX_SEGMENT)
|
||||
is_rt = (segment == RT_SEGMENT)
|
||||
is_normal = not (is_aux or is_rt)
|
||||
@@ -52,7 +58,7 @@ def unmount(segment = None, puck = None, sample = None, force=False, auto_unmoun
|
||||
assert_mount_position()
|
||||
|
||||
set_status("Unmounting: " + str(segment) + str(puck) + str(sample))
|
||||
Controller.getInstance().logEvent("Unmount Sample", str(segment) + str(puck) + str(sample))
|
||||
evlog("Unmount Sample", str(segment) + str(puck) + str(sample))
|
||||
|
||||
try:
|
||||
if smart_magnet.get_supress() == True:
|
||||
@@ -72,6 +78,7 @@ def unmount(segment = None, puck = None, sample = None, force=False, auto_unmoun
|
||||
enable_motion()
|
||||
|
||||
if is_normal:
|
||||
evlog("UNMOUNT() set_hexiposi(%s)" % (segment,))
|
||||
set_hexiposi(segment)
|
||||
|
||||
if not force:
|
||||
@@ -105,14 +112,6 @@ def unmount(segment = None, puck = None, sample = None, force=False, auto_unmoun
|
||||
|
||||
robot.get_gonio()
|
||||
|
||||
has_sample_after_get = robot.gripper_has_sample()
|
||||
log("Sample Detection - unmount after get_gonio: " + str(has_sample_after_get), False)
|
||||
|
||||
smart_magnet.apply_reverse()
|
||||
smart_magnet.apply_resting()
|
||||
mount_sample_detected = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0)
|
||||
Controller.getInstance().logEvent("Sample Detection", str(mount_sample_detected))
|
||||
|
||||
if is_aux:
|
||||
robot.move_aux()
|
||||
robot.put_aux(sample)
|
||||
@@ -124,14 +123,41 @@ def unmount(segment = None, puck = None, sample = None, force=False, auto_unmoun
|
||||
update_samples_info_sample_unmount(get_puck_name(segment, puck), sample)
|
||||
robot.move_dewar()
|
||||
robot.put_dewar(segment, puck, sample, mounting_in_same_segment=mounting_in_same_segment)
|
||||
|
||||
if was_cold:
|
||||
robot.move_cold()
|
||||
else:
|
||||
|
||||
|
||||
has_sample_after_get = robot.gripper_has_sample()
|
||||
evlog("Sample Detection - unmount after get_gonio: ", str(has_sample_after_get))
|
||||
|
||||
smart_magnet.apply_reverse()
|
||||
smart_magnet.apply_resting()
|
||||
mount_sample_detected = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0)
|
||||
evlog("Sample Detection", str(mount_sample_detected))
|
||||
|
||||
robot.close_tool() # closes gripper
|
||||
|
||||
if not was_cold:
|
||||
robot.move_park()
|
||||
|
||||
# Check gripper for frozen sample after trying to put back to puck
|
||||
# if we detect a sample after closing gripper then we move the
|
||||
# gripper back to cold/park and call for local contact or give user
|
||||
# option to dry gripper and lose the sample
|
||||
|
||||
reallyEmpty = is_gripper_really_empty(0.8)
|
||||
if not reallyEmpty:
|
||||
msg = "WARNING GRIPPER-TEST gripper still has a sample {} after mount attempt".format(sampleAddress)
|
||||
evlog(msg)
|
||||
print msg
|
||||
|
||||
if is_aux or is_rt:
|
||||
robot.move_park()
|
||||
# raise Exception(msg)
|
||||
robot.open_tool() # open gripper
|
||||
|
||||
if has_sample_after_get == mount_sample_detected:
|
||||
log("Sample Detection Error - unmount from SM:" + str(mount_sample_detected) + " gripper:" + str(has_sample_after_get)+ str(segment) + str(puck) + str(sample), False)
|
||||
msg = "WARNING GRIPPER-TEST Sample Detection Error - unmount from SM:" + str(mount_sample_detected) + " gripper:" + str(has_sample_after_get) + sampleAddress
|
||||
print msg
|
||||
evlog(msg)
|
||||
#has_sample_after_put = robot.gripper_has_sample()
|
||||
#log("Sample Detection - unmount after put: " + str(has_sample_after_put), False)
|
||||
#if has_sample_after_put:
|
||||
|
||||
Reference in New Issue
Block a user