14 Commits

Author SHA1 Message Date
26818dd8aa changed default values from None in RobotSC
- some comparisons would fail with "None"
  as initial values
- whitespace on the other file
2023-06-14 07:55:40 +02:00
94c34138a8 epics/jcae changes in gateway, eh_door_lock
- added channel access gateways to access
  epics channels outside beamline network
- modifed eh_door_lock device so it always
  returns the value regardless of alarm status
2023-06-14 07:53:48 +02:00
985226e9cd improve assertInPosition
- sometimes this is called while the lid is still moving
2023-05-09 12:33:19 +02:00
4d414860cd override assertInPosition from base class
- trying to avoid spurious "Hexiposi not in position"
  messages
2023-05-09 10:23:10 +02:00
37e9c4d4db properties... 2023-05-09 10:13:02 +02:00
bf6d935f50 pull major unmount update from x10sa 2023-04-26 09:59:32 +02:00
609a87a986 pulling some changes from x10sa
- bugfix: hexiposi missing "self." for method call
- pretend dry for development
- bugfix: ensure cryojet retracted in trash sample
- typos and whitespace
2023-04-26 09:29:10 +02:00
91c9b36cfb day 2 day 2023-04-26 09:03:28 +02:00
da3f276557 settings/properties 2023-04-19 09:58:45 +02:00
gac-S_Changer
861799ecc1 puck dislodgement check 2022-12-13 14:08:03 +01:00
gac-S_Changer
8a67aac0a7 blower on/off cryo pos tweak 2022-12-13 13:54:30 +01:00
269b4ccfb5 settings and device properties 2022-04-19 10:34:30 +02:00
gac-S_Changer
71aa50f075 pre april shutdown 2022-04-12 09:11:53 +02:00
5068ce6185 enable gripper sensor code 2022-04-05 12:22:23 +02:00
37 changed files with 412 additions and 183 deletions

View File

@@ -1,5 +1,5 @@
eh_door_lock=ch.psi.pshell.epics.ChannelString|X06SA-EH1-LAC:02_05 true None|Read||
cryopos=ch.psi.pshell.epics.Motor|X06SA-ES-CJ:TRY1|||true
eh_door_lock=ch.psi.pshell.epics.ChannelString|X06SA-EH1-LAC:02_05|Read||true
img=ch.psi.pshell.prosilica.Prosilica|204464 "PacketSize=1504;PixelFormat=Mono8;BinningX=1;BinningY=1;RegionX=290;RegionY=130;Width=1000;Height=1000;MulticastEnable=Off"||-200|false
gripper_cam=ch.psi.pshell.imaging.MjpegSource|http://axis-accc8ea5e463.psi.ch/axis-cgi/mjpg/video.cgi?camera=1 reopen||-200|false
monitoring_cam=ch.psi.pshell.imaging.MjpegSource|http://axis-accc8ea5e463.psi.ch/axis-cgi/mjpg/video.cgi?camera=2 reopen||-200|

View File

@@ -1,11 +1,12 @@
#Tue Sep 06 15:10:24 CEST 2016
ch.psi.jcae.ContextFactory.addressList=
#Tue Jun 13 13:06:34 CEST 2023
ch.psi.jcae.ContextFactory.addressList=129.129.109.255 sls-x06sa-cagw.psi.ch\:5832 sls-bl-cagw.psi.ch\:5820
ch.psi.jcae.ContextFactory.serverPort=
ch.psi.jcae.ContextFactory.maxArrayBytes=20000000
ch.psi.jcae.ChannelFactory.retries=1
ch.psi.jcae.ChannelFactory.timeout=500
ch.psi.jcae.ChannelFactory.timeout=1000
ch.psi.jcae.impl.DefaultChannelService.retries=2
ch.psi.jcae.impl.DefaultChannelService.timeout=1000
ch.psi.jcae.ContextFactory.autoAddressList=true
ch.psi.jcae.ContextFactory.useShellVariables=false
ch.psi.jcae.ContextFactory.addLocalBroadcastInterfaces=false
ch.psi.jcae.ContextFactory.addLocalBroadcastInterfaces=true
ch.psi.jcae.ContextFactory.maxSendArrayBytes=

View File

@@ -1,11 +1,11 @@
#Tue Apr 05 08:55:24 CEST 2022
#Wed Jun 14 07:48:21 CEST 2023
dry_mount_counter=0
room_temperature_enabled=false
pin_offset=-0.0
cryopos_in=5.0
puck_types=true
imaging_enabled=false
dry_timestamp=1.649141147348E9
dry_timestamp=1.686638562447E9
roi_h=1000
led_level=0.0
beamline_status_enabled=false

View File

@@ -1,4 +1,4 @@
#Wed Mar 16 11:01:10 CET 2022
LastRunDate=220316
FileSequentialNumber=314
#Tue Apr 25 09:45:31 CEST 2023
LastRunDate=230425
FileSequentialNumber=334
DaySequentialNumber=2

View File

@@ -1,3 +1,3 @@
#Thu Nov 11 10:57:12 CET 2021
#Tue Sep 13 11:05:36 CEST 2022
detection=Mechanical
disabled=false

View File

@@ -1,3 +1,3 @@
#Tue Mar 10 08:15:12 CET 2020
#Tue Sep 13 11:05:59 CEST 2022
detection=Mechanical
disabled=false

View File

@@ -1,3 +1,3 @@
#Tue Jan 21 09:46:49 CET 2020
#Thu Apr 20 15:15:22 CEST 2023
detection=Mechanical
disabled=false
disabled=true

View File

@@ -1,3 +1,3 @@
#Wed Sep 16 08:50:16 CEST 2020
#Wed Nov 09 16:49:21 CET 2022
detection=Mechanical
disabled=false

View File

@@ -1,3 +1,3 @@
#Thu Nov 12 09:42:34 CET 2020
#Tue Sep 13 11:06:23 CEST 2022
detection=Mechanical
disabled=false

View File

@@ -1,3 +1,3 @@
#Tue Nov 19 11:00:48 CET 2019
#Tue Sep 13 11:06:46 CEST 2022
detection=Mechanical
disabled=false

View File

@@ -1,3 +1,3 @@
#Tue Jan 18 08:14:20 CET 2022
#Wed Nov 02 08:29:43 CET 2022
detection=Mechanical
disabled=false

View File

@@ -1,3 +1,3 @@
#Thu Nov 12 10:06:30 CET 2020
#Tue Sep 13 11:07:03 CEST 2022
detection=Mechanical
disabled=false

View File

@@ -1,3 +1,3 @@
#Thu Sep 19 08:23:53 CEST 2019
#Mon Jan 30 13:23:59 CET 2023
detection=Mechanical
disabled=false

View File

@@ -1,3 +1,3 @@
#Fri Dec 04 15:49:00 CET 2020
#Mon Jan 30 14:57:22 CET 2023
detection=Mechanical
disabled=false

View File

@@ -1,3 +1,3 @@
#Thu Mar 03 10:13:51 CET 2022
#Mon Mar 13 14:54:55 CET 2023
detection=Mechanical
disabled=false

View File

@@ -1,3 +1,3 @@
#Tue Aug 18 13:57:56 CEST 2020
#Mon Jan 30 14:28:54 CET 2023
detection=Mechanical
disabled=false

View File

@@ -1,3 +1,3 @@
#Tue Aug 18 13:58:36 CEST 2020
#Fri Jan 27 14:56:27 CET 2023
detection=Mechanical
disabled=false

View File

@@ -1,3 +1,3 @@
#Tue Sep 10 08:18:28 CEST 2019
#Mon Oct 03 15:49:00 CEST 2022
detection=Mechanical
disabled=false

View File

@@ -1,3 +1,3 @@
#Wed Mar 23 09:53:12 CET 2022
#Fri Oct 28 09:25:14 CEST 2022
detection=Mechanical
disabled=true
disabled=false

View File

@@ -1,4 +1,4 @@
#Wed Mar 16 11:04:48 CET 2022
#Tue Mar 14 11:09:55 CET 2023
minValue=0.0
unit=V
offset=0.0

View File

@@ -1,4 +1,4 @@
#Wed Mar 16 11:04:48 CET 2022
#Tue Mar 14 11:09:55 CET 2023
minValue=0.0
unit=V
offset=0.0

View File

@@ -1,4 +1,4 @@
#Wed Mar 16 11:04:48 CET 2022
#Tue Mar 14 11:09:55 CET 2023
minValue=0.0
unit=V
offset=0.0

Binary file not shown.

View File

@@ -47,4 +47,4 @@ def restore_puck_info():
except:
print >> sys.stderr, "Error reading pucks info file: " + str(sys.exc_info()[1])
info = []
set_puck_info(info)
set_puck_info(info)

View File

@@ -39,7 +39,7 @@ def save_samples_info():
output_file.write(data)
output_file.close()
get_context().sendEvent("samples_updated", True)
save_puck_info()
save_puck_info()
def restore_samples_info():
restore_puck_info()
@@ -145,7 +145,7 @@ def get_puck_datamatrix_info():
info["user"] = si ["userName"]
info["type"] = si ["puckType"]
ret[si["puckBarcode"]] = info
return ret
return ret
def get_puck_address(barcode):
try:

View File

@@ -35,7 +35,6 @@ class Hexiposi(DiscretePositionerBase):
self.homed = self.status["homed"]
self.error = self.status["errorCode"]
self.remote = self.status["mode"] == "remote"
self.moving = self.status["errorCode"]
self.pos = self.status["position"]
self.moving = self.status["moving"]
self.offset = self.status["offset"]
@@ -115,13 +114,32 @@ class Hexiposi(DiscretePositionerBase):
print "Timeout waiting Hexiposi busy"
break
self.update()
#Retrying after end of move -> once in a while move raises a not in position exception.
def assertInPosition(self, pos):
poll_interval = 2.0
max_turn_time = 8.0 # s
retries = int(max_turn_time / poll_interval)
for i in range(retries):
#st = self.get_status()
#print "asserting hexiposi in position " + pos + " --- moving:" + str(st["moving"]) + " --- state:" + str(self.getState())
try:
super(Hexiposi, self).assertInPosition(pos)
return
except:
if i < retries - 1:
time.sleep(poll_interval)
else:
raise
def is_in_position(self, pos):
return self.take() == pos
def assert_in_position(self, pos):
if not is_in_position(pos):
if not self.is_in_position(pos):
raise Exception ("Hexiposi is not in position")
def assert_homed(self):

View File

@@ -30,8 +30,8 @@ class RobotSC(RobotTCP):
self.set_tasks(["getDewar", "putDewar", "putGonio", "getGonio", "recover", "moveDewar", "moveCold", "movePark", "moveGonio","moveHeater", "moveScanner","moveHome", "moveAux"])
self.set_known_points(["pPark", "pGonioA", "pDewar", "pGonioG", "pScan", "pHeater", "pHeat", "pHeatB", "pLaser","pHelium", "pHome", "pCold", "pAux","p1"])
self.setPolling(DEFAULT_ROBOT_POLLING)
self.last_command_timestamp = None
self.last_command_position = None
self.last_command_timestamp = 0.0
self.last_command_position = "none"
self.ongoing_task = None
#self.setSimulated()
@@ -229,7 +229,12 @@ class RobotSC(RobotTCP):
def stop_task(self):
RobotTCP.stop_task(self)
#TODO: Restore safe position
def gripper_has_sample(self):
"""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):
robot.set_profile("remote")

13
script/hexiposi_tester.py Normal file
View File

@@ -0,0 +1,13 @@
import random
import time
def hexiposi_tester(num_moves = 10, wait = 3.0):
release_safety()
for n in range(num_moves):
pos = random.choice("ABCDEF")
print str(n) + " of " + str(num_moves) + ") moving to " + pos
hexiposi.move(pos)
#print " sleep " + str(wait) + " s"
time.sleep(wait)
print " done "

View File

@@ -28,7 +28,6 @@ ROOM_TEMPERATURE_ENABLED_PREFERENCE = "room_temperature_enabled"
BEAMLINE_STATUS_ENABLED_PREFERENCE = "beamline_status_enabled"
VALVE_CONTROL_ENABLED_PREFERENCE = "valve_control"
def is_imaging_enabled():
setting = get_setting(IMAGING_ENABLED_PREFERENCE)
return not (str(setting).lower() == 'false')
@@ -95,6 +94,14 @@ cold_position_timeout = get_setting("cold_position_timeout")
if cold_position_timeout is None:
set_setting("cold_position_timeout", 0)
def blower_on():
robot.evaluate("doFOut1=true")
def blower_off():
robot.evaluate("doFOut1=false")
def is_room_temperature_enabled():
setting = get_setting(ROOM_TEMPERATURE_ENABLED_PREFERENCE)
@@ -103,6 +110,35 @@ def is_room_temperature_enabled():
set_setting(ROOM_TEMPERATURE_ENABLED_PREFERENCE, is_room_temperature_enabled())
def is_gripper_really_empty(timeout=2.0):
evlog = Controller.getInstance().logEvent
timeout = timeout + time.time()
while time.time() < timeout:
if robot.eval_bool("diToolHasSample"):
time.sleep(0.10)
else:
return True
msg = "is_gripper_really_empty() WARNING GRIPPER-TEST 1st try: gripper should be empty, sample detected (dwell for 2s and try again)"
evlog(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"):
time.sleep(0.10)
else:
return True
msg = "WARNING GRIPPER-TEST 2nd try: gripper should be empty, sample detected"
evlog(msg)
return False
def is_beamline_status_enabled():
setting = get_setting(BEAMLINE_STATUS_ENABLED_PREFERENCE)
return str(setting).lower() == 'true'
@@ -354,10 +390,10 @@ def assert_mount_position():
def is_puck_loading():
guiding_tools_parked = guiding_tool_park.read() and guiding_tool_park_2.read()
guiding_tool_parked = guiding_tool_park.read() and guiding_tool_park_2.read()
return robot.state == State.Ready and robot.take()["pos"] == 'pPark' and \
feedback_psys_safety.take() == False and \
not guiding_tools_parked
not guiding_tool_parked
def set_pin_offset(val):
if abs(val) >5:
@@ -432,4 +468,4 @@ restore_samples_info()
print "Initialization complete"

View File

@@ -0,0 +1,34 @@
def check_gripper(sample):
print "tool open: " + str(robot.is_tool_open())
print "gripper: " + str(robot.gripper_has_sample())
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():
robot.move_aux()
robot.get_aux(sample)
print "tool open: " + str(robot.is_tool_open())
print "gripper: " + str(robot.gripper_has_sample())
print "di has sample: " + str(robot.eval_bool("diToolHasSample"))
print "di tool open: " + str(robot.eval_bool("diToolOpen"))
def swap_samples(a, b, empty):
robot.get_aux(a)
robot.put_aux(empty)
robot.get_aux(b)
robot.put_aux(a)
robot.get_aux(empty)
robot.put_aux(b)
def fetch_go_cold():
robot.move_gonio()
robot.get_gonio()
robot.move_cold()
def pickup(seg, puck, sam):
robot.move_dewar()
robot.get_dewar(seg, puck, sam)
robot.move_cold()

View File

@@ -1,7 +1,7 @@
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
@@ -16,6 +16,7 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
previous_mounted = get_setting("mounted_sample_position")
if previous_mounted is not None:
print "here now"
previous_segment, previous_puck, previous_sample = previous_mounted[0], int(previous_mounted[1]), int(previous_mounted[2:])
else:
previous_segment, previous_puck, previous_sample = "-", 0, 0
@@ -27,7 +28,7 @@ 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)
@@ -36,17 +37,19 @@ 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:])
sampleAddress = str(segment) + str(puck) + "-" + str(sample)
set_status("Mounting: " + sampleAddress)
evlog(">>>>>>>>>>>>>>> MOUNT <<<<<<<<<<<<<<<<<<<<<")
evlog("mount() Mount Sample", sampleAddress)
#Initial checks
print "%4.1f s asserting" % (tg() - t1,)
#Initial checks
assert_valid_address(segment, puck, sample)
assert_puck_detected(segment, puck)
@@ -74,16 +77,17 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
time.sleep(0.2)
sample_det = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0)
evlog("mount() SMC Sample Detection", str(sample_det))
#hasSample = robot.gripper_has_sample()
#if hasSample:
# msg = "CRITICAL ERROR: the gripper has a sample stuck to it, call local contact."
# evlog(msg)
# evlog("mount() terminating mount early")
# raise Exception(msg)
hasSample = robot.gripper_has_sample()
if hasSample:
msg = "CRITICAL ERROR: the gripper has a sample stuck to it, call local contact."
evlog(msg)
evlog("mount() terminating mount early")
raise Exception(msg)
mounting_in_same_segment = False
try:
if sample_det == True:
if was_warm and previous_segment in COLD_SEGMENTS:
@@ -118,12 +122,16 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
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()
robot.get_aux(sample)
elif is_rt:
elif is_rt:
if not robot.is_rt():
robot.move_rt()
robot.get_rt(puck, sample)
@@ -131,30 +139,32 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
else:
evlog("moving lid to " + segment)
set_hexiposi(segment)
set_hexiposi(segment)
if not force:
visual_check_hexiposi(segment)
if (not robot.is_dewar()) and (not mounting_in_same_segment):
robot.move_dewar()
robot.get_dewar(segment, puck, sample, mounting_in_same_segment=mounting_in_same_segment)
#hasSample = robot.gripper_has_sample()
#msg = "mount() WARNING GRIPPER-TEST - after get_(dewar,rt,aux) gripper has sample: {}".format(hasSample)
#evlog(msg)
hasSample = robot.gripper_has_sample()
msg = "mount() WARNING GRIPPER-TEST - after get_(dewar,rt,aux) gripper has sample: {}".format(hasSample)
evlog(msg)
#if not hasSample:
# if is_aux or is_rt:
# robot.move_park()
# else:
# robot.move_cold()
# msg = "MISSING SAMPLE in position {} - try the next one".format(sampleAddress)
# evlog(msg)
# evlog("mount() terminating mount early")
# raise Exception(msg)
if not hasSample:
if is_aux or is_rt:
robot.move_park()
else:
robot.move_cold()
msg = "MISSING SAMPLE in position {} - try the next one".format(sampleAddress)
evlog(msg)
evlog("mount() terminating mount early")
raise Exception(msg)
if read_dm:
barcode_reader.start_read(10.0)
robot.move_scanner()
robot.move_scanner()
robot.move_gonio()
if read_dm:
@@ -162,17 +172,18 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
evlog("mount() read pin barcode: %s" % (mount_sample_id,))
else:
mount_sample_id = None
curpos = cryopos.getPosition()
speed = cryopos.getSpeed() / 1000.
movetime = int(round(3000 + abs(15. - curpos) / speed))
cryopos.move(15.0, movetime)
cryopos.waitValueInRange(15.0, 1.0, movetime)
robot.put_gonio()
robot.close_tool() # closes gripper
if is_normal:
cryopos.moveAsync(12.0)
cryopos.moveAsync(15.0)
if count_mount:
try:
@@ -180,7 +191,7 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
except:
dry_mount_count = 0
finally:
set_setting("dry_mount_counter", dry_mount_count+1)
set_setting("dry_mount_counter", dry_mount_count+1)
elif zero_counts:
set_setting("dry_mount_counter", 0)
@@ -188,7 +199,7 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
if is_rt:
robot.move_park()
elif is_normal:
robot.move_cold()
robot.move_cold()
elif is_aux:
robot.move_park()
else:
@@ -197,38 +208,36 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False)
mount_sample_detected = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0)
evlog("mount() SMC 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 == False:
raise Exception("MISSING SAMPLE: No pin detected on gonio")
# 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 = "CRITICAL The gripper still has sample {} after mount attempt, call local contact".format(sampleAddress)
# evlog(msg)
# evlog("mount() terminating mount early")
# raise Exception(msg)
# sampleDelivered = True
# robot.open_tool() # open gripper
#
# if sampleDelivered and not mount_sample_detected:
# msg = "CRITICAL The sample {} seems to have been lost during mount procedure. Try another sample or call your local contact".format(sampleAddress)
# evlog(msg)
# evlog("mount() terminating mount early")
# raise Exception(msg)
#
reallyEmpty = is_gripper_really_empty(1.2)
if not reallyEmpty:
msg = "CRITICAL The gripper still has sample {} after mount attempt, call local contact".format(sampleAddress)
evlog(msg)
evlog("mount() terminating mount early")
raise Exception(msg)
sampleDelivered = True
robot.open_tool() # open gripper
if sampleDelivered and not mount_sample_detected:
msg = "CRITICAL The sample {} seems to have been lost during mount procedure; call your local contact".format(sampleAddress)
evlog(msg)
evlog("mount() terminating mount early")
raise Exception(msg)
smart_magnet.set_default_current()
if is_aux and was_cold:
evlog("mount() drying after tool mount")
set_exec_pars(then = "dry(wait_cold=-1)")
elif is_force_dry():
evlog("mount() Starting async auto dry")
set_exec_pars(then = "dry()")
set_setting("mounted_sample_position", get_sample_name(segment, puck, sample))
return [mount_sample_detected, mount_sample_id]
finally:

View File

@@ -2,7 +2,8 @@ def put_aux(sample):
"""
"""
print "put_aux: ",sample
sample = int(sample) #assert_valid_sample only acceps int as parameters
#Initial checks
assert_valid_sample(sample)

View File

@@ -14,7 +14,7 @@ def release_safety():
if air_pressure_ok.take() != True:
raise Exception("Cannot release safety: air preassure not ok")
if n2_pressure_ok.take() != True:
raise Exception("Cannot release safety: n2 pressure not ok")
raise Exception("Cannot release safety: N2 pressure not ok")
auto = not is_manual_mode()
if auto:
if feedback_psys_safety.read() == False:
@@ -177,4 +177,4 @@ def is_pin_detected_in_scanner():
return False
if abs(s-av) > 0.1:
return False
return True
return True

View File

@@ -1,7 +1,8 @@
def trash():
def trash_sample():
"""
"""
print "trash"
evlog = Controller.getInstance().logEvent
evlog("trash_sample")
if robot.simulated:
time.sleep(3.0)
@@ -20,6 +21,13 @@ def trash():
enable_motion()
robot.move_gonio()
curpos = cryopos.getPosition()
speed = cryopos.getSpeed() / 1000.0
movetime = int(round(3000 + (15. - curpos) / speed))
cryopos.move(15.0, movetime)
cryopos.waitValueInRange(15.0, 1.0, movetime)
robot.get_gonio()
robot.move_heater(to_bottom = False)
robot.move_heater(to_bottom = True)
@@ -39,5 +47,3 @@ def trash():
robot.move_cold()
else:
robot.move_home()
trash_sample = trash

View File

@@ -1,13 +1,24 @@
def unmount(segment = None, puck = None, sample = None, force=False, auto_unmount = False, next_segment="-*-", mounting_in_same_segment=False):
def finalize_unmount(auto_unmount, raising=False):
evlog = Controller.getInstance().logEvent
if not auto_unmount:
evlog("setting magnet to default current and no detection")
smart_magnet.set_default_current()
smart_magnet.set_supress(True)
if raising:
evlog(">>>>>>>>> raising exception")
evlog("############### UNMOUNT-FINISHED ####################")
def unmount(segment = None, puck = None, sample = None, force=True, auto_unmount = False, next_segment="-*-", mounting_in_same_segment=False):
"""
"""
evlog = Controller.getInstance().logEvent
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:
evlog("Mounted sample position is not defined")
raise Exception("Mounted sample position is not defined")
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)
@@ -17,22 +28,31 @@ def unmount(segment = None, puck = None, sample = None, force=False, auto_unmoun
evlog(">>>>>>>>>>>>>>> UNMOUNT <<<<<<<<<<<<<<<<<<<<<")
msg = "unmount() Unmounting %s" % (sampleAddress,)
evlog(msg)
is_aux = (segment == AUX_SEGMENT)
is_rt = (segment == RT_SEGMENT)
is_normal = not (is_aux or is_rt)
is_cryo_sample = not (is_aux or is_rt)
was_cold = robot.is_cold()
was_warm = not was_cold
needs_chilling = not is_rt and was_warm
needs_drying = is_rt and was_cold
move_cold_at_end = str(next_segment) in COLD_SEGMENTS
try:
assert_puck_detected(segment, puck)
except:
msg = "PUCK DISLODGED: puck no longer detected"
evlog(msg)
finalize_unmount(auto_unmount, raising=True)
raise Exception(msg)
#Initial checks
if not auto_unmount:
print "%4.1f s asserting" % (tg() - t1,)
print "assert valid address"
print " assert valid address"
assert_valid_address(segment, puck, sample)
print " assert puck detected"
assert_puck_detected(segment, puck)
@@ -41,108 +61,179 @@ def unmount(segment = None, puck = None, sample = None, force=False, auto_unmoun
time.sleep(3.0)
update_samples_info_sample_unmount(get_puck_name(segment, puck), sample)
set_setting("mounted_sample_position", None)
return False
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))
# hasSample = robot.gripper_has_sample()
# if hasSample:
# msg = "unmount() CRITICAL GRIPPER-TEST - the gripper has a sample already!!!"
# evlog(msg)
# raise Exception("CRITICAL ERROR: the gripper has a sample stuck to it, call local contact.")
hasSample = robot.gripper_has_sample()
if hasSample:
msg = "unmount() CRITICAL GRIPPER-TEST - the gripper has a sample already!!!"
evlog(msg)
finalize_unmount(auto_unmount, raising=True)
raise Exception("CRITICAL ERROR: the gripper has a sample stuck to it, call local contact.")
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 smart_magnet.get_supress() == True:
smart_magnet.set_supress(False)
time.sleep(0.2)
if not force:
sample_det = smart_magnet.check_mounted(idle_time=0.5, timeout = 3.0)
evlog("SMC Detection", str(sample_det))
evlog("Sample Detection", str(sample_det))
if sample_det == False:
evlog("No pin detected on gonio")
finalize_unmount(auto_unmount, raising=True)
raise Exception("No pin detected on gonio")
if not force:
if sample_det == False:
raise Exception("No pin detected on gonio")
#Enabling
evlog("enabling motion")
try:
enable_motion()
if is_normal:
evlog("unmount() set_hexiposi(%s)" % (segment,))
set_hexiposi(segment)
except:
evlog("error in enable_motion()")
finalize_unmount(auto_unmount, raising=True)
raise Exception("error in enable_motion()")
if not force:
visual_check_hexiposi(segment)
if needs_chilling:
robot.move_cold()
time.sleep(30.)
else:
if needs_drying:
dry(wait_cold=-1)
if is_cryo_sample:
evlog("set_hexiposi(%s)" % (segment,))
try:
set_hexiposi(segment)
except:
evlog("failed to move hexiposi for unmount")
finalize_unmount(auto_unmount, raising=True)
raise Exception("failed to move hexiposi for unmount")
#location = robot.get_current_point()
if needs_chilling:
evlog("unmount() cooling gripper for 30s prior to unmount")
try:
robot.move_cold()
except:
evlog("failure moving gripper into cold position")
finalize_unmount(auto_unmount, raising=True)
raise Exception("failure moving gripper into cold position")
time.sleep(30.)
else:
if needs_drying:
evlog("drying gripper before unmount")
try:
dry(wait_cold=-1)
except:
evlog("problems drying gripper dry(wait_cold=-1)")
finalize_unmount(auto_unmount, raising=True)
raise Exception("problems drying gripper dry(wait_cold=-1)")
evlog("moving arm to gonio")
try:
if not robot.is_gonio():
robot.move_gonio()
except:
evlog("error in move_gonio()")
finalize_unmount(auto_unmount, raising=True)
raise Exception("error in move_gonio()")
evlog("retracting cryojet if necessary")
try:
curpos = cryopos.getPosition()
speed = cryopos.getSpeed() / 1000.
movetime = int(round(3000 + abs(15. - curpos) / speed))
cryopos.move(15.0, movetime)
cryopos.waitValueInRange(15.0, 1.0, movetime)
if is_room_temperature_enabled():
if curpos < 50:
cryopos.move(50.)
else:
speed = cryopos.getSpeed() / 1000.
movetime = int(round(3000 + abs(15. - curpos) / speed))
cryopos.move(15.0, movetime)
cryopos.waitValueInRange(15.0, 1.0, movetime)
except:
evlog("error retracting cryojet")
finalize_unmount(auto_unmount, raising=True)
raise Exception("error retracting cryojet")
evlog("getting gonio")
try:
robot.get_gonio()
except:
evlog("error in get_gonio()")
finalize_unmount(auto_unmount, raising=True)
raise Exception("error in get_gonio()")
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))
evlog("returning sample")
try:
if is_aux:
robot.move_aux()
robot.move_aux()
robot.put_aux(sample)
elif is_rt:
robot.move_rt()
robot.put_rt(puck, sample)
else:
update_samples_info_sample_unmount(get_puck_name(segment, puck), sample)
robot.move_dewar()
robot.put_dewar(segment, puck, sample)
#TODO: Should check if smart magnet detection is off?
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)
except:
evlog("error in move/put (aux, rt, dewar)")
finalize_unmount(auto_unmount, raising=True)
raise Exception("error in move/put (aux, rt, dewar)")
if not auto_unmount:
if was_cold:
robot.move_cold()
else:
robot.move_park()
# FIXME, this check is necessary in case the puck was lifted/flipped during unmount
evlog("checking for puck dislodgement")
try:
time.sleep(1.0)
assert_puck_detected(segment, puck)
except:
msg = "PUCK DISLODGED: puck no longer detected after put_dewar()"
evlog(msg)
finalize_unmount(auto_unmount, raising=True)
raise Exception(msg)
# robot.close_tool() # closes gripper
#
# has_sample_after_get = robot.gripper_has_sample()
# evlog("unmount() sample detections after put_(dewar,rt,aux):")
# evlog(" GRIPPER: ", str(has_sample_after_get))
#
set_setting("mounted_sample_position", None)
return mount_sample_detected
finally:
if not auto_unmount:
smart_magnet.set_default_current()
smart_magnet.set_supress(True)
evlog("############### UNMOUNT-FINISHED ####################")
robot.close_tool() # closes gripper
has_sample_after_get = robot.gripper_has_sample()
evlog("unmount() sample detections after put_(dewar,rt,aux):")
evlog(" GRIPPER: ", 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(" SMC: ", str(mount_sample_detected))
evlog("moving gripper to either cold or park")
try:
if is_cryo_sample:
robot.move_cold()
else:
robot.move_park()
except:
evlog("error in move_(cold/park)")
finalize_unmount(auto_unmount, raising=True)
raise Exception("error in move_(cold/park)")
evlog("checking if gripper really empty")
reallyEmpty = is_gripper_really_empty(0.8)
if not reallyEmpty:
msg = "unmount() CRITICAL gripper still has a sample {} after puck delivery attempt, call local contact!".format(sampleAddress)
evlog(msg)
finalize_unmount(auto_unmount, raising=True)
raise Exception(msg)
robot.open_tool()
set_setting("mounted_sample_position", None)
finalize_unmount(auto_unmount)
return mount_sample_detected

21
script/pretend_dry.py Normal file
View File

@@ -0,0 +1,21 @@
###
### run this file to replace the real dry() function
### with this fake version when TESTING ONLY!!!!!!
###
def dry(heat_time=None, speed=None, wait_cold = None):
"""run this file to replace the real dry() function
with this fake version when TESTING ONLY!!!!!!
"""
print "#################################"
print "## PRETENDING to DRY real fast ##"
print "#################################"
def _test_update_mount_counts(count=0):
global samples_info
for _s in samples_info:
_s["sampleMountCount"] = count
print "sample %s mounted %d times" % (_s["puckAddress"], _s["sampleMountCount"])

View File

@@ -16,9 +16,3 @@ if "Locked" == eh_door_lock.getValue():
raise Exception("Cannot clear cold position: robot state: " + str(robot.state))
else:
raise Exception("Cannot clear cold position: system state: " + str(get_context().state))