15 Commits

Author SHA1 Message Date
panepucci 9b112bdec5 hexiposi improvements from x06sa 2023-05-09 12:48:04 +02:00
gac-S_Changer (Resp.Neiger Thomas) 88c755638b assertInPosition in hexiposi to avoid early check
- the base class checks inposition immediately after
  motion stops and that raises not in position
  exception every now and then
2023-05-09 08:40:54 +02:00
gac-S_Changer (Resp.Neiger Thomas) fd7537be66 puck disable/enable 2023-04-25 16:39:10 +02:00
gac-S_Changer (Resp.Neiger Thomas) 34c144fd16 led ctrl updates 2023-04-25 16:38:21 +02:00
gac-S_Changer (Resp.Neiger Thomas) 05624d31b3 major re-work
- remove large try/finally
- try/except and raise on motions
- fine grained logging
2023-04-25 16:37:24 +02:00
gac-S_Changer (Resp.Neiger Thomas) 14b056683d whitespace... hopefully... 2023-04-25 16:36:21 +02:00
gac-S_Changer (Resp.Neiger Thomas) dc879d29fe newline, sigh.. 2023-04-25 16:33:21 +02:00
gac-S_Changer (Resp.Neiger Thomas) 3644bd8a1a a script to replace the dry function when developing 2023-04-25 16:33:00 +02:00
gac-S_Changer (Resp.Neiger Thomas) 1ade6c7980 remove print 2023-04-25 16:32:24 +02:00
gac-S_Changer (Resp.Neiger Thomas) 7a4532c6d7 bugfix, add missing self to method call 2023-04-25 16:32:06 +02:00
panepucci 0f25931238 unmount minor update and fake dry for testing
- unmount now returns to cold if unmounting cryo sample
  from gripper in park position
- fake dry function so that we can mount from a warmed up
  dewar without cooking the gripper
2023-03-08 14:35:04 +01:00
panepucci 65eb7e3d76 properties update 2023-03-08 14:27:02 +01:00
gac-S_Changer 0932721bfb check for puck dislodgement 2022-12-13 13:46:03 +01:00
gac-S_Changer 119d75fc21 before puck checks 2022-12-13 13:22:39 +01:00
gac-S_Changer 67dd3f6f40 fix mount.py park or cold after failure 2022-06-07 11:08:06 +02:00
44 changed files with 593 additions and 341 deletions
+5 -4
View File
@@ -1,15 +1,16 @@
#Tue Apr 05 09:11:38 CEST 2022
dry_mount_counter=0
#Tue Apr 25 15:32:25 CEST 2023
dry_mount_counter=2
mounted_sample_position=D51
room_temperature_enabled=false
pin_offset=-0.0
puck_types=true
imaging_enabled=false
dry_timestamp=1.649142698729E9
dry_timestamp=1.682426895613E9
roi_h=1000
led_level=0.0
beamline_status_enabled=false
tool_default=tPSI
force_dry_mount_count=12
force_dry_mount_count=10
roi_y=124
barcode_reader_scan_pucks=false
cold_position_timeout=3600
+3 -3
View File
@@ -1,4 +1,4 @@
#Wed Mar 02 10:58:36 CET 2022
LastRunDate=220302
FileSequentialNumber=206
#Mon Jan 30 10:39:42 CET 2023
LastRunDate=230130
FileSequentialNumber=225
DaySequentialNumber=2
+1 -1
View File
@@ -1,3 +1,3 @@
#Tue May 25 11:05:57 CEST 2021
#Tue Mar 28 09:33:45 CEST 2023
detection=Mechanical
disabled=false
+1 -1
View File
@@ -1,3 +1,3 @@
#Wed Sep 08 08:15:44 CEST 2021
#Mon Mar 13 10:25:03 CET 2023
detection=Mechanical
disabled=false
+2 -2
View File
@@ -1,3 +1,3 @@
#Sat Apr 02 16:26:23 CEST 2022
#Mon Mar 13 10:25:10 CET 2023
detection=Mechanical
disabled=true
disabled=false
+1 -1
View File
@@ -1,3 +1,3 @@
#Tue Nov 30 11:36:11 CET 2021
#Mon Mar 13 10:24:34 CET 2023
detection=Mechanical
disabled=false
+1 -1
View File
@@ -1,3 +1,3 @@
#Thu Jun 06 15:40:38 CEST 2019
#Tue Jul 26 15:51:30 CEST 2022
detection=Mechanical
disabled=false
+1 -1
View File
@@ -1,3 +1,3 @@
#Mon Nov 15 08:48:20 CET 2021
#Wed Jun 29 09:37:46 CEST 2022
detection=Mechanical
disabled=false
+2 -2
View File
@@ -1,3 +1,3 @@
#Fri Apr 01 11:06:19 CEST 2022
#Mon Mar 13 10:25:16 CET 2023
detection=Mechanical
disabled=true
disabled=false
+1 -1
View File
@@ -1,3 +1,3 @@
#Mon Apr 29 16:40:05 CEST 2019
#Wed Sep 14 09:20:11 CEST 2022
detection=Mechanical
disabled=false
+1 -1
View File
@@ -1,3 +1,3 @@
#Tue Nov 30 11:36:31 CET 2021
#Wed Nov 02 10:13:00 CET 2022
detection=Mechanical
disabled=false
+2 -2
View File
@@ -1,3 +1,3 @@
#Fri Apr 01 11:06:42 CEST 2022
#Wed Jun 29 09:37:52 CEST 2022
detection=Mechanical
disabled=true
disabled=false
+1 -1
View File
@@ -1,3 +1,3 @@
#Tue May 25 11:08:06 CEST 2021
#Wed Nov 02 10:15:35 CET 2022
detection=Mechanical
disabled=false
+1 -1
View File
@@ -1,3 +1,3 @@
#Sun Apr 25 10:13:29 CEST 2021
#Wed Nov 02 10:15:39 CET 2022
detection=Mechanical
disabled=false
+1 -1
View File
@@ -1,3 +1,3 @@
#Mon Nov 15 08:49:21 CET 2021
#Tue Mar 28 09:33:50 CEST 2023
detection=Mechanical
disabled=false
+2 -2
View File
@@ -1,3 +1,3 @@
#Wed Mar 23 13:38:45 CET 2022
#Wed Nov 02 10:15:43 CET 2022
detection=Mechanical
disabled=true
disabled=false
+1 -1
View File
@@ -1,3 +1,3 @@
#Tue Aug 03 11:48:24 CEST 2021
#Wed Sep 14 09:20:18 CEST 2022
detection=Mechanical
disabled=false
+1 -1
View File
@@ -1,3 +1,3 @@
#Thu Sep 19 08:23:53 CEST 2019
#Tue Mar 28 09:33:56 CEST 2023
detection=Mechanical
disabled=false
+1 -1
View File
@@ -1,3 +1,3 @@
#Thu Sep 19 08:23:55 CEST 2019
#Tue Mar 28 09:34:02 CEST 2023
detection=Mechanical
disabled=false
+2 -2
View File
@@ -1,3 +1,3 @@
#Wed Mar 23 13:38:50 CET 2022
#Thu Apr 14 09:52:40 CEST 2022
detection=Mechanical
disabled=true
disabled=false
+1 -1
View File
@@ -1,3 +1,3 @@
#Tue Jan 18 10:28:22 CET 2022
#Wed Dec 07 08:15:09 CET 2022
detection=Mechanical
disabled=false
+1 -1
View File
@@ -1,3 +1,3 @@
#Tue Nov 30 11:36:19 CET 2021
#Tue Mar 28 09:34:08 CEST 2023
detection=Mechanical
disabled=false
+1 -1
View File
@@ -1,3 +1,3 @@
#Wed Aug 25 10:06:27 CEST 2021
#Mon Jan 30 10:18:42 CET 2023
detection=Mechanical
disabled=false
+1 -1
View File
@@ -1,3 +1,3 @@
#Wed Aug 25 10:06:21 CEST 2021
#Mon Jan 30 10:18:44 CET 2023
detection=Mechanical
disabled=false
+2 -2
View File
@@ -1,3 +1,3 @@
#Fri Apr 01 11:06:30 CEST 2022
#Wed May 18 13:59:19 CEST 2022
detection=Mechanical
disabled=true
disabled=false
+1 -1
View File
@@ -1,3 +1,3 @@
#Mon Nov 15 08:51:45 CET 2021
#Mon Mar 13 10:25:26 CET 2023
detection=Mechanical
disabled=false
+1 -1
View File
@@ -1,3 +1,3 @@
#Mon Nov 15 08:51:49 CET 2021
#Tue Feb 07 13:10:12 CET 2023
detection=Mechanical
disabled=false
+1 -1
View File
@@ -1,4 +1,4 @@
#Fri Mar 11 13:48:49 CET 2022
#Wed Mar 29 08:57:56 CEST 2023
minValue=0.0
unit=V
offset=0.0
+1 -1
View File
@@ -1,4 +1,4 @@
#Fri Mar 11 13:48:49 CET 2022
#Wed Mar 29 08:57:56 CEST 2023
minValue=0.0
unit=V
offset=0.0
+1 -1
View File
@@ -1,4 +1,4 @@
#Fri Mar 11 13:48:49 CET 2022
#Wed Mar 29 08:57:56 CEST 2023
minValue=0.0
unit=V
offset=0.0
+2 -2
View File
@@ -1,7 +1,7 @@
#Thu Mar 25 17:47:27 CET 2021
#Fri Aug 05 08:40:31 CEST 2022
reverseTime=0.2
unmountCurrent=20.0
holdingCurrent=50.0
holdingCurrent=60.0
restingCurrent=50.0
reverseCurrent=-10.0
remanenceCurrent=-10.0
Binary file not shown.
+43
View File
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="76" max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="300" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="34" max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="80" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JButton" name="jButton1">
<Properties>
<Property name="text" type="java.lang.String" value="jButton1"/>
</Properties>
</Component>
</SubComponents>
</Form>
+77
View File
@@ -0,0 +1,77 @@
import ch.psi.pshell.ui.Panel;
import ch.psi.utils.State;
/**
*
*/
public class Zach extends Panel {
public Zach() {
initComponents();
}
//Overridable callbacks
@Override
public void onInitialize(int runCount) {
}
@Override
public void onStateChange(State state, State former) {
}
@Override
public void onExecutedFile(String fileName, Object result) {
}
@Override
protected void onTimer() {
}
@Override
protected void onLoaded() {
}
@Override
protected void onUnloaded() {
}
//Invoked by 'update()' to update components in the event thread
@Override
protected void doUpdate() {
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jButton1 = new javax.swing.JButton();
jButton1.setText("jButton1");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(76, 76, 76)
.addComponent(jButton1)
.addContainerGap(300, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(34, 34, 34)
.addComponent(jButton1)
.addContainerGap(80, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
// End of variables declaration//GEN-END:variables
}
+22 -3
View File
@@ -11,8 +11,8 @@ class Hexiposi(DiscretePositionerBase):
url = "http://" + url
if not url.endswith(":"):
url = url + ":"
self.url_set = url + str (self.PORT_SET)+ "/hexiposi/" #"/TellWeb/"
self.url_get = url + str (self.PORT_GET)+ "/hexiposi/" #"/TellWeb/"
self.url_set = url + str (self.PORT_SET)+ "/hexiposi/"
self.url_get = url + str (self.PORT_GET)+ "/hexiposi/"
self.moved = True
self.homing_state = State.Disabled
self.rback = self.UNKNOWN_POSITION
@@ -114,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):
+13
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 "
+10 -3
View File
@@ -94,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)
@@ -107,7 +115,6 @@ 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
@@ -181,7 +188,7 @@ run("motion/get_aux")
run("motion/put_aux")
run("motion/get_rt")
run("motion/put_rt")
run("motion/trash_sample")
run("motion/trash")
run("motion/dry")
run("motion/homing_hexiposi")
run("motion/calibrate_tool")
@@ -468,4 +475,4 @@ restore_samples_info()
print "Initialization complete"
+1 -1
View File
@@ -1,7 +1,7 @@
IS_PSI_GRIPPER = get_setting("tool_default") == "tPSI"
# PSI SUNA
DEFAULT_DRY_HEAT_TIME = 45.0 if IS_PSI_GRIPPER else 45.0
DEFAULT_DRY_SPEED = 0.4 if IS_PSI_GRIPPER else 0.4
DEFAULT_DRY_SPEED = 0.3 if IS_PSI_GRIPPER else 0.3
DEFAULT_DRY_WAIT_COLD = 40.0 if IS_PSI_GRIPPER else 40.0
def dry(heat_time=None, speed=None, wait_cold = None):
+175 -175
View File
@@ -1,81 +1,81 @@
mount_sample_id = None
mount_sample_detected = None
def mount(segment, puck, sample, force=True, read_dm=False, auto_unmount=False):
"""
"""
global mount_sample_id, mount_sample_detected
mount_sample_id = None
mount_sample_detected = None
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()
is_aux = (segment == AUX_SEGMENT)
is_rt = (segment == RT_SEGMENT)
is_normal = not (is_aux or is_rt)
previous_mounted = get_setting("mounted_sample_position")
if previous_mounted is not None:
tg = time.time
t1 = tg()
is_aux = (segment == AUX_SEGMENT)
is_rt = (segment == RT_SEGMENT)
is_normal = not (is_aux or is_rt)
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
mounting_in_same_segment = (previous_segment == segment)
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
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:
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:])
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
mounting_in_same_segment = (previous_segment == segment)
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
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:
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:])
sampleAddress = str(segment) + str(puck) + "-" + str(sample)
set_status("Mounting: " + sampleAddress)
evlog(">>>>>>>>>>>>>>> MOUNT <<<<<<<<<<<<<<<<<<<<<")
evlog("mount() Mount Sample", sampleAddress)
print "%4.1f s asserting" % (tg() - t1,)
print "%4.1f s asserting" % (tg() - t1,)
#Initial checks
assert_valid_address(segment, puck, sample)
assert_puck_detected(segment, puck)
if robot.simulated:
time.sleep(3.0)
mount_sample_detected = True
mount_sample_id = "YYY0001"
update_samples_info_sample_mount(get_puck_name(segment, puck), sample, mount_sample_detected, mount_sample_id)
set_setting("mounted_sample_position", get_sample_name(segment, puck, sample))
return [mount_sample_detected, mount_sample_id]
robot.assert_no_task()
robot.reset_motion()
robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
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:
smart_magnet.set_supress(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))
#Initial checks
assert_valid_address(segment, puck, sample)
assert_puck_detected(segment, puck)
if robot.simulated:
time.sleep(3.0)
mount_sample_detected = True
mount_sample_id = "YYY0001"
update_samples_info_sample_mount(get_puck_name(segment, puck), sample, mount_sample_detected, mount_sample_id)
set_setting("mounted_sample_position", get_sample_name(segment, puck, sample))
return [mount_sample_detected, mount_sample_id]
robot.assert_no_task()
robot.reset_motion()
robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
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:
smart_magnet.set_supress(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))
@@ -84,68 +84,68 @@ def mount(segment, puck, sample, force=True, read_dm=False, auto_unmount=False):
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
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)
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"
#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:
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)
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"
#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:
msg = "CRITICAL a pin is being detected on gonio after an unmount attempt, either trash the sample or try unmounting again"
evlog(msg)
raise Exception(msg)
if not do_unmount:
enable_motion()
if needs_drying:
dry(wait_cold=-1) # move to park after dry
evlog("mount() terminating mount early")
raise Exception(msg)
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()
robot.get_aux(sample)
elif is_rt:
if not robot.is_rt():
robot.move_rt()
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)
###
if is_aux:
if not robot.is_aux():
robot.move_aux()
robot.get_aux(sample)
elif is_rt:
if not robot.is_rt():
robot.move_rt()
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)
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 not hasSample:
if was_warm and (is_aux or is_rt):
robot.move_park()
@@ -154,56 +154,56 @@ def mount(segment, puck, sample, force=True, read_dm=False, auto_unmount=False):
msg = "MISSING SAMPLE in position {} - try the next one".format(sampleAddress)
evlog(msg)
evlog("mount() terminating mount early")
if read_dm:
barcode_reader.start_read(10.0)
robot.move_scanner()
robot.move_gonio()
if read_dm:
raise Exception(msg)
if read_dm:
barcode_reader.start_read(10.0)
robot.move_scanner()
robot.move_gonio()
if read_dm:
evlog("mount() read pin barcode: %s" % (mount_sample_id,))
else:
mount_sample_id = None
mount_sample_id = barcode_reader.get_readout()
evlog("mount() read pin barcode: %s" % (mount_sample_id,))
else:
mount_sample_id = None
curpos = cryopos.getPosition()
if is_room_temperature_enabled():
if curpos < 50:
cryopos.move(50.)
else:
speed = cryopos.getSpeed() / 1000.0
movetime = int(round(3000 + (15. - curpos) / speed))
curpos = cryopos.getPosition()
if is_room_temperature_enabled():
if curpos < 50:
cryopos.move(50.)
else:
speed = cryopos.getSpeed() / 1000.0
movetime = int(round(3000 + (15. - curpos) / speed))
cryopos.waitValueInRange(15.0, 1.0, movetime)
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(5.0)
if count_mount:
try:
dry_mount_count = int(get_setting("dry_mount_counter"))
except:
dry_mount_count = 0
finally:
set_setting("dry_mount_counter", dry_mount_count+1)
elif zero_counts:
set_setting("dry_mount_counter", 0)
if is_rt:
robot.move_park()
elif is_normal:
robot.move_cold()
elif is_aux:
robot.move_park()
else:
robot.move_cold()
robot.put_gonio()
robot.close_tool() # closes gripper
if is_normal:
cryopos.moveAsync(5.0)
if count_mount:
try:
dry_mount_count = int(get_setting("dry_mount_counter"))
except:
dry_mount_count = 0
finally:
set_setting("dry_mount_counter", dry_mount_count+1)
elif zero_counts:
set_setting("dry_mount_counter", 0)
if is_rt:
robot.move_park()
elif is_normal:
robot.move_cold()
elif is_aux:
robot.move_park()
else:
robot.move_cold()
mount_sample_detected = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0)
evlog("mount() SMC Detection", str(mount_sample_detected))
@@ -218,25 +218,25 @@ def mount(segment, puck, sample, force=True, read_dm=False, auto_unmount=False):
if not reallyEmpty:
msg = "CRITICAL The gripper still has sample {} after mount attempt, call local contact".format(sampleAddress)
evlog(msg)
raise Exception(msg)
sampleDelivered = True
robot.open_tool() # open gripper
evlog("mount() terminating mount early")
raise Exception(msg)
sampleDelivered = True
robot.open_tool() # open gripper
msg = "CRITICAL The sample {} seems to have been lost during mount procedure; call your local contact".format(sampleAddress)
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()")
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()")
return [mount_sample_detected, mount_sample_id]
finally:
set_setting("mounted_sample_position", get_sample_name(segment, puck, sample))
return [mount_sample_detected, mount_sample_id]
+2 -1
View File
@@ -57,6 +57,7 @@ def set_hexiposi(pos, force = True):
set_status(None)
else:
hexiposi.move(pos)
#Can be used if cover has following error (no checking readback)
def _set_hexiposi(pos):
@@ -179,4 +180,4 @@ def is_pin_detected_in_scanner():
return False
if abs(s-av) > 0.1:
return False
return True
return True
+49
View File
@@ -0,0 +1,49 @@
def trash_sample():
"""
"""
evlog = Controller.getInstance().logEvent
evlog("trash_sample")
if robot.simulated:
time.sleep(3.0)
return
#Initial checks
robot.assert_no_task()
robot.reset_motion()
robot.wait_ready()
robot.assert_cleared()
#robot.assert_in_known_point()
was_cold = robot.is_cold()
#Enabling
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)
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_home()
-52
View File
@@ -1,52 +0,0 @@
def trash_sample():
"""
"""
evlog = Controller.getInstance().logEvent
evlog("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()
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)
time.sleep(0.5)
if not robot.is_trash():
robot.trash_sample()
robot.move_cold()
time.sleep(0.5)
smart_magnet.set_current(30.0)
sample_det = False
msg = None
try:
sample_det = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0)
evlog("SMC Detection", str(sample_det))
except:
msg = "failed to check SMC status"
if sample_det:
msg = "sample detected *after* trash action!"
smart_magnet.set_default_current()
smart_magnet.set_supress(True)
if msg:
raise Exception(msg)
+136 -63
View File
@@ -1,3 +1,13 @@
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):
"""
"""
@@ -8,6 +18,7 @@ def unmount(segment = None, puck = None, sample = None, force=True, auto_unmount
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)
@@ -20,7 +31,7 @@ def unmount(segment = None, puck = None, sample = None, force=True, auto_unmount
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
@@ -28,7 +39,16 @@ def unmount(segment = None, puck = None, sample = None, force=True, auto_unmount
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,)
@@ -63,47 +83,71 @@ def unmount(segment = None, puck = None, sample = None, force=True, auto_unmount
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.")
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("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")
evlog("enabling motion")
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 not force:
sample_det = smart_magnet.check_mounted(idle_time=0.5, timeout = 3.0)
Controller.getInstance().logEvent("Sample Detection", str(sample_det))
if sample_det == False:
raise Exception("No pin detected on gonio")
#Enabling
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()
#smart_magnet.set_unmount_current()
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()
if is_room_temperature_enabled():
if curpos < 50:
@@ -113,10 +157,22 @@ def unmount(segment = None, puck = None, sample = None, force=True, auto_unmount
movetime = int(round(3000 + (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()")
evlog("returning sample")
try:
if is_aux:
robot.move_aux()
robot.put_aux(sample)
@@ -128,39 +184,56 @@ def unmount(segment = None, puck = None, sample = None, force=True, auto_unmount
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)")
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))
# 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)
if not was_cold:
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()
# 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
except:
evlog("error in move_(cold/park)")
finalize_unmount(auto_unmount, raising=True)
raise Exception("error in move_(cold/park)")
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)
raise Exception(msg)
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() # open gripper
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.open_tool()
set_setting("mounted_sample_position", None)
finalize_unmount(auto_unmount)
return mount_sample_detected
+21
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"])