trash function, cryo motion

This commit is contained in:
gac-S_Changer
2021-06-23 15:42:33 +02:00
parent 65d7fcc8aa
commit c5d26d76a3
11 changed files with 158 additions and 92 deletions
+2
View File
@@ -1,3 +1,5 @@
aerotech_x=ch.psi.pshell.epics.ChannelDouble|X10SA-ES-DF1:GMX-RBV|Read|1000|false
cryopos=ch.psi.pshell.epics.Motor|X10SA-ES-CJ:TRY1|||true
magnet_position=ch.psi.pshell.epics.ChannelDouble|X10SA-ES-DFS:CBOX-SENSOR1|Read||true
magnet_position_ok=ch.psi.pshell.epics.ChannelString|X10SA-ES-DF1:SN1-CMP|Read||true
th2e=ch.psi.pshell.modbus.ModbusTCP|129.129.118.200:502|||
+3 -4
View File
@@ -1,11 +1,10 @@
#Wed Jun 16 11:03:52 CEST 2021
dry_mount_counter=0
mounted_sample_position=X11
#Wed Jun 23 15:21:19 CEST 2021
dry_mount_counter=10
room_temperature_enabled=true
pin_offset=-0.0
puck_types=true
imaging_enabled=false
dry_timestamp=1.623598457599E9
dry_timestamp=1.624437082387E9
roi_h=1000
led_level=0.0
beamline_status_enabled=false
+2 -2
View File
@@ -1,2 +1,2 @@
#Mon Mar 22 13:26:12 CET 2021
FileSequentialNumber=170
#Tue Jun 22 08:54:23 CEST 2021
FileSequentialNumber=174
+18
View File
@@ -0,0 +1,18 @@
#Tue Jun 22 14:16:37 CEST 2021
offset=0.0
maxValue=148.0
rotation=false
precision=5
scale=1.0
estbilizationDelay=0
maxSpeed=NaN
resolution=0.0025
homingType=None
startRetries=1
minValue=3.0
unit=mm
defaultSpeed=10.0
hasEnable=false
sign_bit=0
monitorByPosition=false
minSpeed=1.0
+20 -10
View File
@@ -28,8 +28,8 @@ joint_forces = False
class RobotSC(RobotTCP):
def __init__(self, name, server, timeout = 1000, retries = 1):
RobotTCP.__init__(self, name, server, timeout, retries)
self.set_tasks(["getDewar", "putDewar", "putGonio", "getGonio", "recover", "moveDewar", "moveCold", "movePark", "moveGonio","moveHeater", "moveScanner","moveHome", "moveAux", "moveRT"])
self.set_known_points(["pPark", "pGonioA", "pDewar", "pGonioG", "pScan", "pHeater", "pHeat", "pHeatB", "pLaser","pHelium", "pHome", "pCold", "pAux","p1", "pRT"])
self.set_tasks(["getDewar", "putDewar", "putGonio", "getGonio", "recover", "moveDewar", "moveCold", "movePark", "moveGonio","moveHeater", "moveSc","moveHome", "moveAux", "moveRT","moveTrash"])
self.set_known_points(["pPark", "pGonioA", "pDewar", "pGonioG", "pScan", "pHeater", "pHeat", "pHeatB", "pLaser","pHe", "pHome", "pCold", "pAux","p1", "pRT","pGT"])
self.setPolling(DEFAULT_ROBOT_POLLING)
self.last_command_timestamp = None
self.last_command_position = None
@@ -76,10 +76,9 @@ class RobotSC(RobotTCP):
self.last_command_position = "dewar"
self.last_command_timestamp = time.time()
def put_gonio(self):
def put_gonio(self):
pin_offset = get_pin_offset()
pin_angle_offset = get_pin_angle_offset()
print "Pin offset = " + str(pin_offset)
self.start_task('putGonio', pin_offset)
self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
self.assert_gonio()
@@ -88,7 +87,6 @@ class RobotSC(RobotTCP):
def get_gonio(self):
pin_offset = get_pin_offset()
print "Pin offset = " + str(pin_offset)
self.start_task('getGonio', pin_offset)
self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
self.assert_gonio()
@@ -129,14 +127,14 @@ class RobotSC(RobotTCP):
def move_scanner(self):
self.start_task('moveScanner')
self.start_task('moveSc')
self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
self.assert_scanner()
self.last_command_position = "scanner"
self.last_command_timestamp = time.time()
def move_laser(self):
self.start_task('moveScanner')
self.start_task('moveSc')
self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
self.assert_laser()
self.last_command_position = "scanner"
@@ -207,6 +205,12 @@ class RobotSC(RobotTCP):
self.assert_scanner()
self.command_timestamps["scanner"] = time.time()
def trash_sample(self):
self.start_task('moveTrash')
self.wait_task_finished(TASK_WAIT_ROBOT_POLLING)
self.assert_trash()
self.last_command_position = "trash"
self.last_command_timestamp = time.time()
def toSegmentNumber(self, segment):
@@ -283,7 +287,7 @@ class RobotSC(RobotTCP):
return self.is_in_point("pGonioA")
def is_helium(self):
return self.is_in_point("pHelium")
return self.is_in_point("pHe")
def is_scanner(self):
return self.is_in_point("pScan")
@@ -298,7 +302,10 @@ class RobotSC(RobotTCP):
return self.is_in_point("pLaser")
def is_p1(self):
return self.is_in_point("p1")
return self.is_in_point("p1")
def is_trash(self):
return self.is_in_point("pGT")
def is_cleared(self):
#return self.is_home() or self.is_park() or self.is_dewar() or self.is_dewar_home()
@@ -329,7 +336,7 @@ class RobotSC(RobotTCP):
self.assert_in_point("pGonioA")
def assert_helium(self):
self.assert_in_point("pHelium")
self.assert_in_point("pHe")
def assert_scanner(self):
self.assert_in_point("pScan")
@@ -346,6 +353,9 @@ class RobotSC(RobotTCP):
def assert_p1(self):
self.assert_in_point("p1")
def assert_trash(self):
self.assert_in_point("pGT")
def assert_tool_ok(self):
if tool_psi.take():
if TOOL_DEFAULT != TOOL_PSI:
+1 -1
View File
@@ -151,8 +151,8 @@ run("motion/get_aux")
run("motion/put_aux")
run("motion/get_rt")
run("motion/put_rt")
run("motion/trash_sample")
run("motion/dry")
run("motion/trash")
run("motion/homing_hexiposi")
run("motion/calibrate_tool")
run("motion/scan_pin")
+47 -19
View File
@@ -5,9 +5,10 @@ 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
tg = time.time
t1 = tg()
print " mount: ", segment, puck, sample, force
start = time.time()
is_aux = (segment == AUX_SEGMENT)
is_rt = (segment == RT_SEGMENT)
is_normal = not (is_aux or is_rt)
@@ -26,6 +27,8 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
needs_drying = is_rt and was_cold
count_mount = is_normal or (is_aux and was_cold)
zero_counts = (is_aux and not was_cold) or (is_rt and was_cold)
pin_offset = get_pin_offset()
puck_address = get_puck_address(puck)
if puck_address is None:
@@ -33,9 +36,11 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
if puck_obj is not None:
puck_address = puck_obj.name
if puck_address is not None:
print "puck address: ", puck_address
print " puck address: ", puck_address
segment = puck_address[:1]
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)
@@ -56,6 +61,7 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
hexiposi.assert_homed()
assert_mount_position()
do_unmount = False
print "%4.1f s asserted " % (tg() - t1,)
# detect sample before moving to cold
if smart_magnet.get_supress() == True:
@@ -64,20 +70,26 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
sample_det = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0)
Controller.getInstance().logEvent("Sample Detection", str(sample_det))
print "%4.1f s SMC checked" % (tg() - t1,)
mounting_in_same_segment = False
try:
if sample_det == True:
if was_warm and previous_segment in COLD_SEGMENTS:
print "was warm previous %s %s $s" % (previous_segment, COLD_SEGMENTS, previous_mounted)
print " was warm previous %s %s %s" % (previous_segment, COLD_SEGMENTS, previous_mounted)
robot.move_cold()
time.sleep(30.0)
if auto_unmount and (get_setting("mounted_sample_position") is not None):
if mounting_in_same_segment:
print "Mounting from the same segment"
print " Mounting from the same segment"
#auto_unmount set to true so detection remains enabled
print "%4.1f s unmounting" % (tg() - t1,)
sample_det = unmount(force = True, auto_unmount = True, mounting_in_same_segment=mounting_in_same_segment, next_segment=segment)
print "%4.1f s ....done" % (tg() - t1,)
do_unmount = True
if sample_det == True:
raise Exception("Pin detected on gonio")
@@ -90,8 +102,6 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
if not do_unmount:
enable_motion()
# ZAC
# a room temp pin is being mounted but the gripper is cold
if needs_drying:
dry(wait_cold=-1) # move to park after dry
@@ -106,34 +116,51 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
robot.get_rt(puck, sample)
else:
print "%4.1f s moving lid " % (tg() - t1,)
set_hexiposi(segment)
if not force:
visual_check_hexiposi(segment)
if (not robot.is_dewar()) and (not mounting_in_same_segment):
robot.move_dewar()
print "%4.1f s get_dewar" % (tg() - t1,)
robot.get_dewar(segment, puck, sample, mounting_in_same_segment=mounting_in_same_segment)
piked_sample = robot.gripper_has_sample()
log("Sample Detection - mount: after get_dewar: " + str(piked_sample) + str(segment) + str(puck) + str(sample), False)
if read_dm:
print "%4.1f s barcode read" % (tg() - t1,)
barcode_reader.start_read(10.0)
robot.move_scanner()
#time.sleep(1.0)
robot.move_scanner()
print "%4.1f s ...done" % (tg() - t1,)
print "%4.1f s move to gonio " % (tg() - t1,)
robot.move_gonio()
print "%4.1f s ....done" % (tg() - t1,)
if read_dm:
print "%4.1f s reading pin barcode" % (tg() - t1,)
mount_sample_id = barcode_reader.get_readout()
print "Datamatrix: " , mount_sample_id
print "%4.1f s ....done --- barcode: %s" % (tg() - t1, mount_sample_id)
else:
mount_sample_id = None
print "%4.1f s moving cryo out" % (tg() - t1,)
curpos = cryopos.getPosition()
speed = cryopos.getSpeed()
movetime = int(round(5000 + (15. - curpos) / speed))
cryopos.move(15.0, movetime)
cryopos.waitValueInRange(15.0, 1.0, movetime)
robot.put_gonio()
#has_sample_after_put = robot.gripper_has_sample()
#log("Sample Detection - mount after put: " + str(has_sample_after_put), 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,)
if is_normal:
print "%4.1f s async moving cryo to 5mm " % (tg() - t1,)
cryopos.moveAsync(5.0)
if count_mount:
try:
dry_mount_count = int(get_setting("dry_mount_counter"))
@@ -146,17 +173,17 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
set_setting("dry_mount_counter", 0)
if is_rt:
print "mount/moving home in RT"
print "%4.1f s mount/moving home in RT" % (tg() - t1,)
robot.move_home()
elif is_normal:
print "mount/moving cold in cold"
print "%4.1f mount/moving cold in cold " % (tg() - t1,)
robot.move_cold()
elif is_aux:
if was_cold:
print "mount/moving cold after auxtool mount"
print "%4.1f s mount/moving cold after auxtool mount " % (tg() - t1,)
robot.move_cold()
else:
print "mount/moving cold after auxtool mount"
print "%4.1f s mount/moving park after auxtool mount" % (tg() - t1,)
robot.move_park()
else:
robot.move_cold()
@@ -176,12 +203,13 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
if is_force_dry():
smart_magnet.set_default_current()
print "Auto dry"
print "%4.1f Auto dry async" % (tg() - t1,)
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:
print "%4.1f s magnet suppress/default current" % (tg() - t1,)
smart_magnet.set_default_current()
smart_magnet.set_supress(True)
+1
View File
@@ -6,6 +6,7 @@ RECOVER_DESC = "mRecovery"
RECOVER_TOOL = TOOL_DEFAULT
known_segments = [ ("pGonioA", "pGonioG", 10), \
("pGonioA", "pGT", 10), \
("p1", "pGonioA", 100), \
("p1", "pScan", 100), \
("pPark", "pScan", 40), \
-45
View File
@@ -1,45 +0,0 @@
def trash():
"""
"""
print "trash"
if robot.simulated:
time.sleep(3.0)
return
was_cold = robot.is_cold()
#Initial checks
robot.assert_no_task()
robot.reset_motion()
robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
#Enabling
enable_motion()
robot.move_gonio()
robot.get_gonio()
#robot.move_heater(to_bottom = False)
#robot.move_heater(to_bottom = True)
try:
for i in range(3):
robot.open_tool()
time.sleep(0.5)
robot.close_tool()
time.sleep(0.5)
finally:
robot.open_tool()
#robot.move_heater(to_bottom = False)
if was_cold:
robot.move_cold()
else:
robot.move_aux()
+45
View File
@@ -0,0 +1,45 @@
def trash_sample():
"""
"""
print "trash_sample"
aerotech_x.waitValueInRange(-78, 1.0, 20000)
#Initial checks
robot.assert_no_task()
robot.reset_motion()
robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
#Enabling
enable_motion()
gripping = robot.gripper_has_sample()
if gripping is not None:
raise Exception("unknown gripper state, cannot trash; dry gripper first")
curpos = cryopos.getPosition()
speed = cryopos.getSpeed()
movetime = int(round(5000 + (15. - curpos) / speed))
cryopos.move(15.0, movetime)
cryopos.waitValueInRange(15.0, 1.0, movetime)
smart_magnet.set_supress(False)
smart_magnet.set_current(10.0)
if not robot.is_trash():
robot.trash_sample()
robot.move_cold()
sample_det = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0)
Controller.getInstance().logEvent("Sample Detection", str(sample_det))
if sample_det:
raise Exception("sample detected *after* trash action!")
smart_magnet.set_default_current()
smart_magnet.set_supress(True)
+19 -11
View File
@@ -2,15 +2,16 @@ def unmount(segment = None, puck = None, sample = None, force=False, auto_unmoun
"""
"""
print "unmount: ", segment, puck, sample, force
tg = time.time
t1 = tg()
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
print "%4.1f Mounted sample position: %s%s-%s" % (tg() - t1, segment, puck , sample)
#ZACH
is_aux = (segment == AUX_SEGMENT)
is_rt = (segment == RT_SEGMENT)
is_normal = not (is_aux or is_rt)
@@ -24,9 +25,10 @@ def unmount(segment = None, puck = None, sample = None, force=False, auto_unmoun
#Initial checks
if not auto_unmount:
print "assert valid address"
print "%4.1f s asserting" % (tg() - t1,)
print " assert valid address"
assert_valid_address(segment, puck, sample)
print "asser puck detected"
print " assert puck detected"
assert_puck_detected(segment, puck)
if robot.simulated:
@@ -35,18 +37,18 @@ def unmount(segment = None, puck = None, sample = None, force=False, auto_unmoun
set_setting("mounted_sample_position", None)
return False
print "assert no task"
print " assert no task"
robot.assert_no_task()
print "reset motion"
print " reset motion"
robot.reset_motion()
print "wait ready"
print " wait ready"
robot.wait_ready()
print "assert cleared"
print " assert cleared"
robot.assert_cleared()
#robot.assert_in_known_point()
print "assert homed"
print " assert homed"
hexiposi.assert_homed()
print "assert mount pos"
print " assert mount pos"
assert_mount_position()
set_status("Unmounting: " + str(segment) + str(puck) + str(sample))
@@ -88,6 +90,12 @@ def unmount(segment = None, puck = None, sample = None, force=False, auto_unmoun
#smart_magnet.set_unmount_current()
curpos = cryopos.getPosition()
speed = cryopos.getSpeed()
movetime = int(round(5000 + (15. - curpos) / speed))
cryopos.move(15.0, movetime)
cryopos.waitValueInRange(15.0, 1.0, movetime)
robot.get_gonio()
has_sample_after_get = robot.gripper_has_sample()