This commit is contained in:
@@ -11,4 +11,12 @@ def get_puck_info():
|
||||
|
||||
|
||||
def get_puck_obj(address):
|
||||
return BasePlate.getChild(address)
|
||||
return BasePlate.getChild(address)
|
||||
|
||||
|
||||
def get_puck_obj_by_id(puck_id):
|
||||
for puck in BasePlate.pucks:
|
||||
if puck.id == puck_id:
|
||||
return puck
|
||||
return None
|
||||
|
||||
@@ -2,7 +2,7 @@ import json
|
||||
import org.python.core.PyDictionary as PyDictionary
|
||||
|
||||
SAMPLE_INFO_KEYS = ["userName", "dewarName", "puckName", "puckBarcode", "puckType", "puckAddress",
|
||||
"sampleName", "samplePosition", "sampleStatus", "sampleMountCount"]
|
||||
"sampleName", "samplePosition", "sampleBarcode", "sampleStatus", "sampleMountCount"]
|
||||
samples_info = []
|
||||
|
||||
|
||||
@@ -103,7 +103,10 @@ def reset_puck_datamatrix(puck = None):
|
||||
for si in samples_info:
|
||||
if (si["puckAddress"] == puck) or (puck is None):
|
||||
si["puckAddress"] = ""
|
||||
save_samples_info()
|
||||
save_samples_info()
|
||||
for p in BasePlate.getChildren():
|
||||
if (p.name == puck) or (puck is None):
|
||||
p.id = None
|
||||
|
||||
def get_puck_datamatrix():
|
||||
ret = {}
|
||||
@@ -130,7 +133,8 @@ def update_puck_table():
|
||||
|
||||
#Sample mount/unmount
|
||||
|
||||
def update_samples_info_sample_mount(puck_address, sample_position, sample_detected):
|
||||
def update_samples_info_sample_mount(puck_address, sample_position, sample_detected, sample_id):
|
||||
print ""
|
||||
try:
|
||||
if (samples_info is not None) and (puck_address is not None):
|
||||
for si in samples_info:
|
||||
@@ -145,6 +149,10 @@ def update_samples_info_sample_mount(puck_address, sample_position, sample_detec
|
||||
si["sampleMountCount"] = mount_count + 1
|
||||
else:
|
||||
si["sampleStatus"] = "Unknown"
|
||||
|
||||
if sample_id is not None:
|
||||
si["sampleBarcode"] = sample_id
|
||||
|
||||
save_samples_info()
|
||||
return
|
||||
except:
|
||||
@@ -172,6 +180,7 @@ test_sample_data = [ \
|
||||
"puckAddress": "A1",\
|
||||
"sampleName": "MySample 1", \
|
||||
"samplePosition": 1,\
|
||||
"sampleBarcode": "", \
|
||||
"sampleStatus": "Present", \
|
||||
"sampleMountCount": 0,
|
||||
} , \
|
||||
@@ -183,6 +192,7 @@ test_sample_data = [ \
|
||||
"puckAddress": "A1",\
|
||||
"sampleName": "MySample 2", \
|
||||
"samplePosition": 2,\
|
||||
"sampleBarcode": "", \
|
||||
"sampleStatus": "Present", \
|
||||
"sampleMountCount": 0,
|
||||
} , \
|
||||
@@ -194,6 +204,7 @@ test_sample_data = [ \
|
||||
"puckAddress": "A1",\
|
||||
"sampleName": "MySample 3", \
|
||||
"samplePosition": 3,\
|
||||
"sampleBarcode": "", \
|
||||
"sampleStatus": "Present", \
|
||||
"sampleMountCount": 0,
|
||||
} , \
|
||||
@@ -205,6 +216,7 @@ test_sample_data = [ \
|
||||
"puckAddress": "A1",\
|
||||
"sampleName": "MySample 4", \
|
||||
"samplePosition": 4,\
|
||||
"sampleBarcode": "", \
|
||||
"sampleStatus": "Present", \
|
||||
"sampleMountCount": 0,
|
||||
} , \
|
||||
@@ -215,6 +227,7 @@ test_sample_data = [ \
|
||||
"puckType": "unipuck", \
|
||||
"puckAddress": "A1",\
|
||||
"sampleName": "MySample 5", \
|
||||
"sampleBarcode": "", \
|
||||
"samplePosition": 5,\
|
||||
"sampleStatus": "Present", \
|
||||
"sampleMountCount": 0,
|
||||
@@ -228,6 +241,7 @@ test_sample_data = [ \
|
||||
"puckAddress": "C2",\
|
||||
"sampleName": "MySample 1", \
|
||||
"samplePosition": 1,\
|
||||
"sampleBarcode": "", \
|
||||
"sampleStatus": "Present", \
|
||||
"sampleMountCount": 0,
|
||||
} , \
|
||||
@@ -239,6 +253,7 @@ test_sample_data = [ \
|
||||
"puckAddress": "C2",\
|
||||
"sampleName": "MySample 2", \
|
||||
"samplePosition": 2,\
|
||||
"sampleBarcode": "", \
|
||||
"sampleStatus": "Present", \
|
||||
"sampleMountCount": 0,
|
||||
} , \
|
||||
@@ -250,6 +265,7 @@ test_sample_data = [ \
|
||||
"puckAddress": "C2",\
|
||||
"sampleName": "MySample 3", \
|
||||
"samplePosition": 3,\
|
||||
"sampleBarcode": "", \
|
||||
"sampleStatus": "Present", \
|
||||
"sampleMountCount": 0,
|
||||
} , \
|
||||
@@ -261,6 +277,7 @@ test_sample_data = [ \
|
||||
"puckAddress": "C2",\
|
||||
"sampleName": "MySample 4", \
|
||||
"samplePosition": 4,\
|
||||
"sampleBarcode": "", \
|
||||
"sampleStatus": "Present", \
|
||||
"sampleMountCount": 0,
|
||||
} , \
|
||||
@@ -272,6 +289,7 @@ test_sample_data = [ \
|
||||
"puckAddress": "C2",\
|
||||
"sampleName": "MySample 5", \
|
||||
"samplePosition": 5,\
|
||||
"sampleBarcode": "", \
|
||||
"sampleStatus": "Present", \
|
||||
"sampleMountCount": 0,
|
||||
} , \
|
||||
|
||||
@@ -163,7 +163,7 @@ class RobotTCP(TcpDevice, Stoppable):
|
||||
|
||||
def evaluate(self, cmd, timeout=None):
|
||||
ret = self.execute('eval', cmd, timeout=timeout)
|
||||
if type(ret) is str:
|
||||
if is_string(ret):
|
||||
if ret.strip() != "": raise Exception(ret)
|
||||
|
||||
def get_var(self, name):
|
||||
|
||||
@@ -47,7 +47,7 @@ class SmartMagnet(DeviceBase):
|
||||
def get_supress(self):
|
||||
return smc_sup_det.read()
|
||||
|
||||
def check_mounted(self, idle_time =1.0, timeout = -1):
|
||||
def check_mounted(self, idle_time =1.0, timeout = -1, interval = 0.01):
|
||||
self.assert_status()
|
||||
start = time.time()
|
||||
last = None
|
||||
@@ -66,7 +66,7 @@ class SmartMagnet(DeviceBase):
|
||||
if timeout >= 0:
|
||||
if (time.time() - start) > timeout:
|
||||
raise Exception("Timeout waiting for Smart Magnet detection.")
|
||||
time.sleep(0.01)
|
||||
time.sleep(interval)
|
||||
|
||||
|
||||
def doUpdate(self):
|
||||
|
||||
@@ -18,7 +18,7 @@ def assert_img_in_cover_pos(pos = None):
|
||||
pos = hexiposi.take()
|
||||
elif type(pos) is int:
|
||||
pos = chr( ord('A') + (pos-1))
|
||||
elif type(pos) is str:
|
||||
elif is_string(pos):
|
||||
pos = pos.upper()
|
||||
img_segment = get_img_cover_pos()
|
||||
if img_segment != pos:
|
||||
|
||||
@@ -1,12 +1,25 @@
|
||||
mount_sample_id = None
|
||||
mount_sample_detected = None
|
||||
|
||||
def mount(segment, puck, sample, force=False, read_dm=False):
|
||||
"""
|
||||
"""
|
||||
global mount_sample_id, mount_sample_detected
|
||||
print "mount: ", segment, puck, sample, force
|
||||
start = time.time()
|
||||
|
||||
puck_address = get_puck_address(puck)
|
||||
if puck_address is None:
|
||||
puck_obj = get_puck_obj_by_id(puck)
|
||||
if puck_obj is not None:
|
||||
puck_address = puck_obj.name
|
||||
if puck_address is not None:
|
||||
print "puck address: ", puck_address
|
||||
segment = puck_address[:1]
|
||||
puck = int(puck_address[1:])
|
||||
#Initial checks
|
||||
assert_valid_address(segment, puck, sample)
|
||||
assert_puck_detected(segment, puck)
|
||||
|
||||
robot.assert_no_task()
|
||||
robot.reset_motion()
|
||||
robot.wait_ready()
|
||||
@@ -31,25 +44,31 @@ def mount(segment, puck, sample, force=False, read_dm=False):
|
||||
robot.move_dewar()
|
||||
|
||||
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()
|
||||
robot.move_scanner()
|
||||
time.sleep(1.0)
|
||||
|
||||
robot.move_gonio()
|
||||
|
||||
|
||||
if read_dm:
|
||||
dm = barcode_reader.get_readout()
|
||||
print "Datamatrix: " , dm
|
||||
mount_sample_id = barcode_reader.get_readout()
|
||||
print "Datamatrix: " , mount_sample_id
|
||||
else:
|
||||
mount_sample_id = None
|
||||
|
||||
smart_magnet.set_mount_current()
|
||||
try:
|
||||
robot.put_gonio()
|
||||
robot.move_dewar()
|
||||
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)
|
||||
#TODO: Should do on finally?
|
||||
update_samples_info_sample_mount(get_puck_name(segment, puck), sample, sample_detected)
|
||||
if sample_detected == False:
|
||||
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")
|
||||
return [mount_sample_detected, mount_sample_id]
|
||||
finally:
|
||||
smart_magnet.set_default_current()
|
||||
|
||||
@@ -142,15 +142,17 @@ def get_puck_name(segment, puck):
|
||||
try:
|
||||
assert_valid_address(segment, puck, 1)
|
||||
if type(segment) is int:
|
||||
segment = chr( ord('A') + (pos-1))
|
||||
elif type(segment) is str:
|
||||
segment = pos.upper()
|
||||
segment = chr( ord('A') + (segment-1))
|
||||
elif is_string(segment):
|
||||
segment = segment.upper()
|
||||
else:
|
||||
return None
|
||||
return segment + str(puck)
|
||||
except:
|
||||
return None
|
||||
|
||||
|
||||
def get_sample_name(segment, puck, sample):
|
||||
puck_name = get_puck_name(segment, puck)
|
||||
return None if (puck_name is None) else puck_name + str(sample)
|
||||
|
||||
|
||||
@@ -1,7 +1,14 @@
|
||||
def unmount(segment, puck, sample, force=False):
|
||||
def unmount(segment = None, puck = None, sample = None, force=False):
|
||||
"""
|
||||
"""
|
||||
print "unmount: ", segment, puck, sample, force
|
||||
|
||||
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
|
||||
assert_valid_address(segment, puck, sample)
|
||||
@@ -14,7 +21,7 @@ def unmount(segment, puck, sample, force=False):
|
||||
#robot.assert_in_known_point()
|
||||
hexiposi.assert_homed()
|
||||
|
||||
if smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) == False:
|
||||
if smart_magnet.check_mounted(idle_time=0.5, timeout = 3.0) == False:
|
||||
raise Exception("No pin detected on gonio")
|
||||
|
||||
|
||||
@@ -38,6 +45,7 @@ def unmount(segment, puck, sample, force=False):
|
||||
update_samples_info_sample_unmount(get_puck_name(segment, puck), sample)
|
||||
robot.move_dewar()
|
||||
robot.put_dewar(segment, puck, sample)
|
||||
set_setting("mounted_sample_position", None)
|
||||
finally:
|
||||
smart_magnet.set_default_current()
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
1862
script/test/SampleDataInput_Dominik.py
Normal file
1862
script/test/SampleDataInput_Dominik.py
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user