diff --git a/config/settings.properties b/config/settings.properties index ec63f39..4b49a46 100644 --- a/config/settings.properties +++ b/config/settings.properties @@ -1,9 +1,10 @@ -#Tue Mar 19 08:36:08 CET 2019 +#Tue Jul 23 10:58:33 CEST 2019 barcode_reader_scan_pucks=false beamline_status_enabled=false +cold_position_timeout=3600 dry_mount_counter=0 -dry_timestamp=1.552980281686E9 -force_dry_mount_count=15 +dry_timestamp=1.563869039847E9 +force_dry_mount_count=10 force_dry_timeout=0 imaging_enabled=false led_level=0.0 @@ -11,7 +12,7 @@ pin_offset=0.0 puck_types=true roi_h=1000 roi_w=1000 -roi_x=286 -roi_y=127 +roi_x=288 +roi_y=124 room_temperature_enabled=false valve_control=false diff --git a/config/tasks.properties b/config/tasks.properties index e291198..92f138b 100644 --- a/config/tasks.properties +++ b/config/tasks.properties @@ -1 +1,2 @@ tasks/LedMonitoring=120 +tasks/ColdPositionTimeout=300 diff --git a/devices/A1.properties b/devices/A1.properties index 41a5c55..0d37ef0 100644 --- a/devices/A1.properties +++ b/devices/A1.properties @@ -1,3 +1,3 @@ -#Wed Feb 13 08:55:42 CET 2019 -detection=Both +#Thu Jun 06 15:40:21 CEST 2019 +detection=Mechanical disabled=false diff --git a/devices/A2.properties b/devices/A2.properties index 8bf4688..ce6347e 100644 --- a/devices/A2.properties +++ b/devices/A2.properties @@ -1,3 +1,3 @@ -#Wed Feb 13 08:55:46 CET 2019 -detection=Both +#Thu Jun 06 15:47:03 CEST 2019 +detection=Mechanical disabled=false diff --git a/devices/A3.properties b/devices/A3.properties index 78a6ada..e34c6cb 100644 --- a/devices/A3.properties +++ b/devices/A3.properties @@ -1,3 +1,3 @@ -#Wed Feb 13 08:55:51 CET 2019 -detection=Both +#Thu Jun 06 15:40:30 CEST 2019 +detection=Mechanical disabled=false diff --git a/devices/A4.properties b/devices/A4.properties index a4c6a45..502a5d0 100644 --- a/devices/A4.properties +++ b/devices/A4.properties @@ -1,3 +1,3 @@ -#Wed Feb 13 08:55:56 CET 2019 -detection=Both +#Thu Jun 06 15:40:34 CEST 2019 +detection=Mechanical disabled=false diff --git a/devices/A5.properties b/devices/A5.properties index a83d88f..8b9ee93 100644 --- a/devices/A5.properties +++ b/devices/A5.properties @@ -1,3 +1,3 @@ -#Wed Feb 13 08:56:00 CET 2019 -detection=Both +#Thu Jun 06 15:40:38 CEST 2019 +detection=Mechanical disabled=false diff --git a/devices/B1.properties b/devices/B1.properties index 1fe40cc..22f2102 100644 --- a/devices/B1.properties +++ b/devices/B1.properties @@ -1,3 +1,3 @@ -#Tue Feb 19 09:01:59 CET 2019 +#Mon Apr 29 16:18:33 CEST 2019 detection=Mechanical disabled=false diff --git a/devices/B2.properties b/devices/B2.properties index dc39dc2..ea802c8 100644 --- a/devices/B2.properties +++ b/devices/B2.properties @@ -1,3 +1,3 @@ -#Tue Feb 19 11:27:20 CET 2019 +#Mon Apr 29 16:40:00 CEST 2019 detection=Mechanical disabled=false diff --git a/devices/B3.properties b/devices/B3.properties index 9bb6f5c..8b811a9 100644 --- a/devices/B3.properties +++ b/devices/B3.properties @@ -1,3 +1,3 @@ -#Tue Feb 19 11:27:24 CET 2019 +#Mon Apr 29 16:40:05 CEST 2019 detection=Mechanical disabled=false diff --git a/devices/B4.properties b/devices/B4.properties index 95f25f6..5382cce 100644 --- a/devices/B4.properties +++ b/devices/B4.properties @@ -1,3 +1,3 @@ -#Tue Feb 19 11:27:28 CET 2019 +#Mon Apr 29 16:40:10 CEST 2019 detection=Mechanical disabled=false diff --git a/devices/B5.properties b/devices/B5.properties index ed35652..1651b90 100644 --- a/devices/B5.properties +++ b/devices/B5.properties @@ -1,3 +1,3 @@ -#Tue Feb 19 11:27:32 CET 2019 +#Mon Apr 29 16:40:13 CEST 2019 detection=Mechanical disabled=false diff --git a/devices/C3.properties b/devices/C3.properties index 1f66279..85868a7 100644 --- a/devices/C3.properties +++ b/devices/C3.properties @@ -1,3 +1,3 @@ -#Wed Feb 06 11:02:06 CET 2019 +#Thu Jun 06 15:47:11 CEST 2019 detection=Mechanical disabled=false diff --git a/devices/C4.properties b/devices/C4.properties index 37b7170..b994628 100644 --- a/devices/C4.properties +++ b/devices/C4.properties @@ -1,3 +1,3 @@ -#Wed Feb 06 11:02:11 CET 2019 +#Tue Jun 25 10:55:28 CEST 2019 detection=Mechanical disabled=false diff --git a/devices/C5.properties b/devices/C5.properties index 5df0b2a..b6c3239 100644 --- a/devices/C5.properties +++ b/devices/C5.properties @@ -1,3 +1,3 @@ -#Mon Mar 11 10:22:44 CET 2019 +#Tue Jun 25 10:55:33 CEST 2019 detection=Mechanical -disabled=true +disabled=false diff --git a/devices/E3.properties b/devices/E3.properties index e14fd6b..1d4765f 100644 --- a/devices/E3.properties +++ b/devices/E3.properties @@ -1,3 +1,3 @@ -#Wed Feb 06 11:03:18 CET 2019 +#Thu Jun 06 15:47:19 CEST 2019 detection=Mechanical disabled=false diff --git a/devices/F1.properties b/devices/F1.properties index f3f127a..9521147 100644 --- a/devices/F1.properties +++ b/devices/F1.properties @@ -1,3 +1,3 @@ -#Wed Feb 06 11:03:33 CET 2019 +#Thu Jun 06 15:46:29 CEST 2019 detection=Mechanical disabled=false diff --git a/devices/F2.properties b/devices/F2.properties index f3a471b..7094b2c 100644 --- a/devices/F2.properties +++ b/devices/F2.properties @@ -1,3 +1,3 @@ -#Wed Feb 06 11:03:37 CET 2019 +#Thu Jun 06 15:46:33 CEST 2019 detection=Mechanical disabled=false diff --git a/devices/F3.properties b/devices/F3.properties index 88b0618..e7aeabe 100644 --- a/devices/F3.properties +++ b/devices/F3.properties @@ -1,3 +1,3 @@ -#Wed Feb 13 08:32:46 CET 2019 +#Thu Jun 06 15:47:23 CEST 2019 detection=Mechanical disabled=false diff --git a/devices/F4.properties b/devices/F4.properties index 464bca9..2b6dd64 100644 --- a/devices/F4.properties +++ b/devices/F4.properties @@ -1,3 +1,3 @@ -#Wed Feb 06 11:03:45 CET 2019 +#Tue Jun 25 10:55:43 CEST 2019 detection=Mechanical disabled=false diff --git a/devices/F5.properties b/devices/F5.properties index a7820d1..a73b981 100644 --- a/devices/F5.properties +++ b/devices/F5.properties @@ -1,3 +1,3 @@ -#Wed Feb 06 11:03:48 CET 2019 +#Thu Jun 06 15:46:43 CEST 2019 detection=Mechanical disabled=false diff --git a/devices/img.properties b/devices/img.properties index 966291b..96f9c93 100644 --- a/devices/img.properties +++ b/devices/img.properties @@ -1,4 +1,4 @@ -#Tue Mar 12 14:02:05 CET 2019 +#Tue Jul 23 10:11:03 CEST 2019 colormap=Grayscale colormapAutomatic=false colormapMax=18.133 @@ -9,16 +9,16 @@ grayscale=false invert=false rescaleFactor=1.0 rescaleOffset=0.0 -roiHeight=959 -roiWidth=958 -roiX=21 -roiY=20 -rotation=90.09354404670171 +roiHeight=955 +roiWidth=956 +roiX=20 +roiY=24 +rotation=210.3274314256251 rotationCrop=true scale=1.0 -spatialCalOffsetX=-479.0 -spatialCalOffsetY=-480.0 -spatialCalScaleX=0.49018322600904013 -spatialCalScaleY=0.489795265579423 +spatialCalOffsetX=-478.0 +spatialCalOffsetY=-478.0 +spatialCalScaleX=0.4915561854227953 +spatialCalScaleY=0.49182558383480557 spatialCalUnits=mm transpose=false diff --git a/devices/led_ctrl_1.properties b/devices/led_ctrl_1.properties index 5aed24d..061bf83 100644 --- a/devices/led_ctrl_1.properties +++ b/devices/led_ctrl_1.properties @@ -1,5 +1,5 @@ -#Mon Mar 11 10:54:31 CET 2019 -maxValue=1.0 +#Wed Jul 17 08:29:01 CEST 2019 +maxValue=0.4 minValue=0.0 offset=0.0 precision=2 diff --git a/devices/led_ctrl_2.properties b/devices/led_ctrl_2.properties index 5aed24d..061bf83 100644 --- a/devices/led_ctrl_2.properties +++ b/devices/led_ctrl_2.properties @@ -1,5 +1,5 @@ -#Mon Mar 11 10:54:31 CET 2019 -maxValue=1.0 +#Wed Jul 17 08:29:01 CEST 2019 +maxValue=0.4 minValue=0.0 offset=0.0 precision=2 diff --git a/devices/led_ctrl_3.properties b/devices/led_ctrl_3.properties index 5aed24d..061bf83 100644 --- a/devices/led_ctrl_3.properties +++ b/devices/led_ctrl_3.properties @@ -1,5 +1,5 @@ -#Mon Mar 11 10:54:31 CET 2019 -maxValue=1.0 +#Wed Jul 17 08:29:01 CEST 2019 +maxValue=0.4 minValue=0.0 offset=0.0 precision=2 diff --git a/devices/smart_magnet.properties b/devices/smart_magnet.properties index 472a7bd..eae60c8 100644 --- a/devices/smart_magnet.properties +++ b/devices/smart_magnet.properties @@ -1,4 +1,4 @@ -#Tue Feb 12 13:53:17 CET 2019 +#Wed Jul 03 11:55:12 CEST 2019 holdingCurrent=40.0 mountCurrent=20.0 remanenceCurrent=-10.0 diff --git a/plugins/MXSC-1.10.0 - Back.jar b/plugins/MXSC-1.10.0 - Back.jar new file mode 100644 index 0000000..04ee834 Binary files /dev/null and b/plugins/MXSC-1.10.0 - Back.jar differ diff --git a/plugins/MXSC-1.10.0.jar b/plugins/MXSC-1.10.0.jar index 04ee834..64c6c94 100644 Binary files a/plugins/MXSC-1.10.0.jar and b/plugins/MXSC-1.10.0.jar differ diff --git a/plugins/MXSC-1.10.0.jar.back b/plugins/MXSC-1.10.0.jar.back deleted file mode 100644 index 3f40c45..0000000 Binary files a/plugins/MXSC-1.10.0.jar.back and /dev/null differ diff --git a/script/data/reports.py b/script/data/reports.py new file mode 100644 index 0000000..629b414 --- /dev/null +++ b/script/data/reports.py @@ -0,0 +1,39 @@ +from statsutils import * + + +def report(start, end): + """ + Data format for start and end: "dd/mm/yy" or "dd/mm/yy hh:mm:ss.mmm" + + """ + cmds = ["mount%", "unmount%", "dry%", "recover%", "trash%", "robot_recover%", "scan%", "homing%"] + + conn = get_stats_connection() + try: + print_stats(cmds, start, end) + + for cmd in cmds: + print_cmd_stats (cmd, start, end) + + + finally: + conn.close() + +def print_recs(cmd,start, end, result=("%%")): + """ + Data format for start and end: "dd/mm/yy" or "dd/mm/yy hh:mm:ss.mmm" + Result: "error", "abort, "success". Defaulr for all + + """ + + conn = get_stats_connection() + try: + print_cmd_records(cmd,start, end, result) + finally: + conn.close() + + +#Print all records: +# + +#report("01/03/19","01/04/19") diff --git a/script/devices/Hexiposi.py b/script/devices/Hexiposi.py index dbe248a..75f6261 100644 --- a/script/devices/Hexiposi.py +++ b/script/devices/Hexiposi.py @@ -171,4 +171,4 @@ class hexiposi_position(ReadonlyRegisterBase): add_device(hexiposi_position(), True) hexiposi_position.polling = 1000 -hexiposi.set_deadband(0.5) +hexiposi.set_deadband(0.7) diff --git a/script/devices/RobotSC.py b/script/devices/RobotSC.py index 7ccc2ce..7fe709c 100644 --- a/script/devices/RobotSC.py +++ b/script/devices/RobotSC.py @@ -29,28 +29,38 @@ 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", "pScanStop","pHelium", "pHome", "pCold", "pAux"]) self.setPolling(DEFAULT_ROBOT_POLLING) + self.last_command_timestamp = None + self.last_command_position = None #self.setSimulated() def move_dewar(self): self.start_task('moveDewar') self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) self.assert_dewar() + self.last_command_position = "dewar" + self.last_command_timestamp = time.time() def move_cold(self): self.start_task('moveCold') self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) self.assert_cold() + self.last_command_position = "cold" + self.last_command_timestamp = time.time() def move_home(self): self.start_task('moveHome') self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) self.assert_home() + self.last_command_position = "home" + self.last_command_timestamp = time.time() def get_dewar(self, segment, puck, sample): segment = self.toSegmentNumber(segment) self.start_task('getDewar',segment, puck, sample, is_room_temp()) self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) self.assert_dewar() + self.last_command_position = "dewar" + self.last_command_timestamp = time.time() def put_dewar(self, segment, puck, sample): segment = self.toSegmentNumber(segment) @@ -59,6 +69,8 @@ class RobotSC(RobotTCP): self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) #self.assert_dewar() self.assert_cold() + self.last_command_position = "dewar" + self.last_command_timestamp = time.time() def put_gonio(self): pin_offset = get_pin_offset() @@ -67,6 +79,8 @@ class RobotSC(RobotTCP): self.start_task('putGonio', pin_offset) self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) self.assert_gonio() + self.last_command_position = "gonio" + self.last_command_timestamp = time.time() def get_gonio(self): pin_offset = get_pin_offset() @@ -74,23 +88,31 @@ class RobotSC(RobotTCP): self.start_task('getGonio', pin_offset) self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) self.assert_gonio() + self.last_command_position = "gonio" + self.last_command_timestamp = time.time() def get_aux(self, sample): self.assert_aux() self.start_task('getAuxiliary', sample) self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) self.assert_aux() + self.last_command_position = "aux" + self.last_command_timestamp = time.time() def put_aux(self, sample): self.assert_aux() self.start_task('putAuxiliary', sample) self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) self.assert_aux() + self.last_command_position = "aux" + self.last_command_timestamp = time.time() def move_scanner(self): self.start_task('moveScanner') self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) self.assert_scanner() + self.last_command_position = "scanner" + self.last_command_timestamp = time.time() #def do_scan(self): # self.start_task('doScan') @@ -101,12 +123,16 @@ class RobotSC(RobotTCP): self.start_task('moveGonio') self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) self.assert_gonio() + self.last_command_position = "gonio" + self.last_command_timestamp = time.time() def move_park(self): self.start_task('movePark') self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) self.assert_park() + self.last_command_position = "park" + self.last_command_timestamp = time.time() def move_heater(self, speed=-1, to_bottom=True): self.start_task('moveHeater', speed, to_bottom) @@ -115,27 +141,36 @@ class RobotSC(RobotTCP): self.assert_heater_bottom() else: self.assert_heater() + self.last_command_position = "heater" + self.last_command_timestamp = time.time() def robot_recover(self): self.start_task('recover') self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) self.assert_home() + self.last_command_position = "home" + self.last_command_timestamp = time.time() def move_aux(self): self.start_task('moveAux') self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) self.assert_aux() + self.last_command_position = "aux" + self.last_command_timestamp = time.time() def get_calibration_tool(self): self.start_task('getCalTool') self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) - self.assert_scanner() + self.assert_scanner() + self.last_command_position = "scanner" + self.last_command_timestamp = time.time() def put_calibration_tool(self): self.start_task('putCalTool') self.wait_task_finished(TASK_WAIT_ROBOT_POLLING) - self.assert_scanner() + self.assert_scanner() + self.command_timestamps["scanner"] = time.time() diff --git a/script/devices/RobotTCP.py b/script/devices/RobotTCP.py index 313f592..4727d68 100644 --- a/script/devices/RobotTCP.py +++ b/script/devices/RobotTCP.py @@ -722,8 +722,8 @@ class RobotTCP(TcpDevice, Stoppable): return self.here(tool, frame) def get_distance_to_pnt(self, name): - #self.here(self.tool, self.frame) #??? - self.get_cartesian_pos() + #self.here(self.tool, self.frame) #??? + self.set_pnt(self.get_cartesian_pos() ) return self.distance_p("tcp_p", name) def is_in_point(self, p, tolerance = None): #Tolerance in mm @@ -810,7 +810,7 @@ class RobotTCP(TcpDevice, Stoppable): self.assert_tool() if desc is None: desc = self.default_desc if point is None: - self.get_cartesian_pos() + self.set_pnt(self.get_cartesian_pos() ) else: self.set_pnt(point) np=self.eval_trf('align(tcp_p.trsf, ' + frame + '.trsf)') diff --git a/script/local.py b/script/local.py index 5ab54a5..30a8bb8 100644 --- a/script/local.py +++ b/script/local.py @@ -12,6 +12,8 @@ import ch.psi.mxsc.Controller as Controller run("setup/Layout") +run("data/reports") + @@ -87,7 +89,11 @@ force_dry_timeout = get_setting("force_dry_timeout") if force_dry_timeout is None: set_setting("force_dry_timeout", 0) - + +cold_position_timeout = get_setting("cold_position_timeout") +if cold_position_timeout is None: + set_setting("cold_position_timeout", 0) + def is_room_temperature_enabled(): setting = get_setting(ROOM_TEMPERATURE_ENABLED_PREFERENCE) @@ -411,7 +417,10 @@ def is_force_dry(): except: pass return False - + +def onPuckLoadingChange(puck_loading): + set_led_state(puck_loading) + #pass update() add_device(Controller.getInstance().basePlate, True) diff --git a/script/motion/mount.py b/script/motion/mount.py index 63ec906..1e05624 100644 --- a/script/motion/mount.py +++ b/script/motion/mount.py @@ -43,7 +43,7 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False) #robot.assert_in_known_point() hexiposi.assert_homed() assert_mount_position() - + do_unmount = False try: #ZACH @@ -55,19 +55,25 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False) smart_magnet.set_supress(False) time.sleep(0.2) #To better dectect sample + smart_magnet.apply_reverse() smart_magnet.apply_resting() time.sleep(0.5) - if smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) == True: + sample_det = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) + Controller.getInstance().logEvent("Sample Detection", str(sample_det)) + if sample_det == True: if auto_unmount and (get_setting("mounted_sample_position") is not None): #auto_unmount set to true so detection remains enabled unmount(force = True, auto_unmount = True) + do_unmount = True else: 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 - enable_motion() + #Enabling. If did unmount then it is already enabled. + if not do_unmount: + enable_motion() #ZACH # a room temp pin is being mounted but the gripper is cold @@ -120,7 +126,8 @@ 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) + Controller.getInstance().logEvent("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 == False: raise Exception("No pin detected on gonio") diff --git a/script/motion/recover.py b/script/motion/recover.py index 31e22f9..d58bf7e 100644 --- a/script/motion/recover.py +++ b/script/motion/recover.py @@ -117,6 +117,16 @@ def move_to_safest_point(segment, vicinity_tolerance = 100): print "Done" #print "Recovered to point " + str(robot.get_curjoint_or_pointrent_point()) +def is_in_dewar(): + z_dwr = robot.get_pnt('pDewar')[2] + z_cur=robot.get_cartesian_pos()[2] + if z_cur > (z_dwr + 30): + return False + d_dwr = robot.get_distance_to_pnt('pDewar') + if d_dwr > 300: + return False + return True + def recover(move_park = True): #Initial checks @@ -153,7 +163,11 @@ def recover(move_park = True): #finally: # robot.set_default_speed() if not is_on_known_segment: - raise Exception("Robot is not in known segment") + print ("Robot is not in known segment") + if is_in_dewar(): + robot.robot_recover() + else: + raise Exception("Robot is not in known segment or inside the dewar") diff --git a/script/motion/unmount.py b/script/motion/unmount.py index 45065d8..af11158 100644 --- a/script/motion/unmount.py +++ b/script/motion/unmount.py @@ -16,42 +16,46 @@ def unmount(segment = None, puck = None, sample = None, force=False, auto_unmoun print "Mounted sample position: ", segment, puck , sample #Initial checks - print "assert valid address" - assert_valid_address(segment, puck, sample) - print "asser puck detected" - assert_puck_detected(segment, puck) - - if robot.simulated: - time.sleep(3.0) - update_samples_info_sample_unmount(get_puck_name(segment, puck), sample) - set_setting("mounted_sample_position", None) - return - - print "assert no task" - robot.assert_no_task() - print "reset motion" - robot.reset_motion() - print "wait ready" - robot.wait_ready() - print "assert cleared" - robot.assert_cleared() - #robot.assert_in_known_point() - print "assert homed" - hexiposi.assert_homed() - print "assert mount pos" - assert_mount_position() - - set_status("Umounting: " + str(segment) + str(puck) + str(sample)) + if not auto_unmount: + print "assert valid address" + assert_valid_address(segment, puck, sample) + print "asser puck detected" + assert_puck_detected(segment, puck) + + if robot.simulated: + time.sleep(3.0) + update_samples_info_sample_unmount(get_puck_name(segment, puck), sample) + set_setting("mounted_sample_position", None) + return + + print "assert no task" + robot.assert_no_task() + print "reset motion" + robot.reset_motion() + print "wait ready" + robot.wait_ready() + print "assert cleared" + robot.assert_cleared() + #robot.assert_in_known_point() + print "assert homed" + hexiposi.assert_homed() + print "assert mount pos" + assert_mount_position() + + set_status("Unmounting: " + str(segment) + str(puck) + str(sample)) + Controller.getInstance().logEvent("Unmount Sample", str(segment) + str(puck) + str(sample)) 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: - if smart_magnet.check_mounted(idle_time=0.5, timeout = 3.0) == False: + 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 @@ -80,11 +84,14 @@ def unmount(segment = None, puck = None, sample = None, force=False, auto_unmoun #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) else: - #TODO: Shuld check if smart magnet detection is off? + #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) diff --git a/script/tasks/ColdPositionTimeout.py b/script/tasks/ColdPositionTimeout.py new file mode 100644 index 0000000..b61e0a0 --- /dev/null +++ b/script/tasks/ColdPositionTimeout.py @@ -0,0 +1,23 @@ +cold_position_timeout = int(get_setting("cold_position_timeout")) +if cold_position_timeout > 0: + if robot.last_command_position == "cold": + if (time.time() - robot.last_command_timestamp) > cold_position_timeout: + if robot.is_cold(): + log("Detected cold position timeout", False) + if get_context().state == State.Ready: + if robot.state == State.Ready: + if feedback_psys_safety.take() == True: + #TODO: Chan + get_context().evalLine("dry(wait_cold = -1)") #Dry and park : use get_context().evalLine to change application state + else: + raise Exception("Cannot clear cold position: feedback_psys_safety = False ") + else: + raise Exception("Cannot clear cold position: robot state: " + str(robot.state)) + else: + raise Exception("Cannot clear cold position: system state: " + str(get_context().state)) + + + + + + \ No newline at end of file diff --git a/script/test/mount_profile.py b/script/test/mount_profile.py new file mode 100644 index 0000000..89ebd80 --- /dev/null +++ b/script/test/mount_profile.py @@ -0,0 +1,144 @@ +mount_sample_id = None +mount_sample_detected = None + +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 + + start = time.time() + + #time.sleep(2) + is_aux = (segment == AUX_SEGMENT) + + #ZACH + needs_chilling = not is_aux and (not robot.is_cold()) + needs_drying = is_aux and robot.is_cold() + + 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) + + 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() + + print "Pass 1: ", time.time() - start; start = time.time() + try: + #ZACH + if needs_chilling: + robot.move_cold() + time.sleep(30.0) + + if smart_magnet.get_supress() == True: + smart_magnet.set_supress(False) + time.sleep(0.2) + #To better dectect sample + smart_magnet.apply_resting() + time.sleep(0.5) + if smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) == True: + print "Pass 1b: ", time.time() - start; start = time.time() + if auto_unmount and (get_setting("mounted_sample_position") is not None): + #auto_unmount set to true so detection remains enabled + unmount(force = True, auto_unmount = True) + else: + raise Exception("Pin detected on gonio") + print "Pass 2: ", time.time() - start; start = time.time() + set_status("Mounting: " + str(segment) + str(puck) + str(sample)) + #location = robot.get_current_point() + + #Enabling + enable_motion() + + print "Pass 3: ", time.time() - start; start = time.time() + #ZACH + # a room temp pin is being mounted but the gripper is cold + if needs_drying: + dry(wait_cold=-1) # move to park after dry + + if is_aux: + if not robot.is_aux(): + robot.move_aux() + print "Pass 3b: ", time.time() - start; start = time.time() + robot.get_aux(sample) + + else: + set_hexiposi(segment) + print "Pass 4: ", time.time() - start; start = time.time() + if not force: + visual_check_hexiposi(segment) + + if not robot.is_dewar(): + robot.move_dewar() + print "Pass 4b: ", time.time() - start; start = time.time() + robot.get_dewar(segment, puck, sample) + print "Pass 5: ", time.time() - start; start = time.time() + + if read_dm: + barcode_reader.start_read(10.0) + robot.move_scanner() + #time.sleep(1.0) + + robot.move_gonio() + + if read_dm: + mount_sample_id = barcode_reader.get_readout() + print "Datamatrix: " , mount_sample_id + else: + mount_sample_id = None + print "Pass 6: ", time.time() - start; start = time.time() + + robot.put_gonio() + print "Pass 7: ", time.time() - start; start = time.time() + + try: + dry_mount_count = int(get_setting("dry_mount_counter")) + except: + dry_mount_count = 0 + set_setting("dry_mount_counter", dry_mount_count+1) + + if is_aux: + robot.move_home() + else: + robot.move_cold() + print "Pass 8: ", time.time() - start; start = time.time() + mount_sample_detected = smart_magnet.check_mounted(idle_time=0.25, timeout = 1.0) + 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") + + + if is_force_dry(): + smart_magnet.set_default_current() + print "Auto dry" + log("Starting auto dry", False) + set_exec_pars(then = "dry()") + print "Pass 9: " , time.time() - start; start = time.time() + set_setting("mounted_sample_position", get_sample_name(segment, puck, sample)) + return [mount_sample_detected, mount_sample_id] + finally: + smart_magnet.set_default_current() + smart_magnet.set_supress(True) + diff --git a/script/test/transfer_profile.py b/script/test/transfer_profile.py new file mode 100644 index 0000000..00be4cb --- /dev/null +++ b/script/test/transfer_profile.py @@ -0,0 +1,23 @@ + + +measures = [] +#smart_magnet.measures = [] + + +for m in range(1): + print "Step ", m + start = time.time() + #mount('A',3,m+1, force=True, read_dm=False, auto_unmount=True) + #mount('A',5,m+1, force=True, read_dm=False, auto_unmount=True) + + #mount('A',3,1, force=True, read_dm=False, auto_unmount=True) + #unmount('A',3,1, force=True) + #mount('A',3,1, force=True, read_dm=False, auto_unmount=True) + measures.append( time.time()-start) + +print "Total transfer: ", measures +print "Time: ", mean(measures), "+-", stdev(measures) + + +#print "SM cehck: ", smart_magnet.measures +#print "Time: ", mean(smart_magnet.measures), "+-", stdev(smart_magnet.measures) \ No newline at end of file diff --git a/script/test/unmount_profile.py b/script/test/unmount_profile.py new file mode 100644 index 0000000..5adcdb3 --- /dev/null +++ b/script/test/unmount_profile.py @@ -0,0 +1,98 @@ +def unmount(segment = None, puck = None, sample = None, force=False, auto_unmount = False): + """ + """ + print "unmount: ", segment, puck, sample, force + start = time.time() + #ZACH + is_aux = (segment == AUX_SEGMENT) + needs_chilling = not is_aux and (not robot.is_cold()) + needs_drying = is_aux and robot.is_cold() + + 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 + print "assert valid address" + assert_valid_address(segment, puck, sample) + print "asser puck detected" + assert_puck_detected(segment, puck) + + if robot.simulated: + time.sleep(3.0) + update_samples_info_sample_unmount(get_puck_name(segment, puck), sample) + set_setting("mounted_sample_position", None) + return + + print "assert no task" + robot.assert_no_task() + print "reset motion" + robot.reset_motion() + print "wait ready" + robot.wait_ready() + print "assert cleared" + robot.assert_cleared() + #robot.assert_in_known_point() + print "assert homed" + hexiposi.assert_homed() + print "assert mount pos" + assert_mount_position() + print "Pass A: " , time.time() - start; start = time.time() + set_status("Umounting: " + str(segment) + str(puck) + str(sample)) + + try: + if smart_magnet.get_supress() == True: + smart_magnet.set_supress(False) + time.sleep(0.2) + + smart_magnet.apply_resting() + + if not force: + if smart_magnet.check_mounted(idle_time=0.5, timeout = 3.0) == False: + raise Exception("No pin detected on gonio") + print "Pass B: " , time.time() - start; start = time.time() + #Enabling + enable_motion() + print "Pass C: " , time.time() - start; start = time.time() + + if not is_aux: + set_hexiposi(segment) + print "Pass D: " , time.time() - start; start = time.time() + if not force: + visual_check_hexiposi(segment) + if needs_chilling: + robot.move_cold() + time.sleep(30.) + else: + if needs_drying: + dry(wait_cold=-1) + #location = robot.get_current_point() + print "Pass E: " , time.time() - start; start = time.time() + if not robot.is_gonio(): + robot.move_gonio() + print "Pass F: " , time.time() - start; start = time.time() + #smart_magnet.set_unmount_current() + + robot.get_gonio() + print "Pass G: " , time.time() - start; start = time.time() + #smart_magnet.apply_reverse() + #smart_magnet.apply_resting() + + if is_aux: + robot.move_aux() + robot.put_aux( sample) + else: + #TODO: Shuld check if smart magnet detection is off? + update_samples_info_sample_unmount(get_puck_name(segment, puck), sample) + robot.move_dewar() + print "Pass H: " , time.time() - start; start = time.time() + robot.put_dewar(segment, puck, sample) + print "Pass I: " , time.time() - start; start = time.time() + set_setting("mounted_sample_position", None) + finally: + if not auto_unmount: + smart_magnet.set_default_current() + smart_magnet.set_supress(True) diff --git a/script/tools/CheckPuckDetection.py b/script/tools/CheckPuckDetection.py index 0582bad..e39bae2 100644 --- a/script/tools/CheckPuckDetection.py +++ b/script/tools/CheckPuckDetection.py @@ -1,5 +1,5 @@ USR,PWD = "pi", "raspberry" -HOST,PORT = "tell-raspberrypi", 22 +HOST,PORT = "tell6s-raspberrypi", 22 CMD= "sudo systemctl status puck_detection.service" ret = run("tools/SshExec") diff --git a/script/tools/RestartPuckDetection.py b/script/tools/RestartPuckDetection.py index 2251921..88df774 100644 --- a/script/tools/RestartPuckDetection.py +++ b/script/tools/RestartPuckDetection.py @@ -1,5 +1,5 @@ USR,PWD = "pi", "raspberry" -HOST,PORT = "tell-raspberrypi", 22 +HOST,PORT = "tell6s-raspberrypi", 22 CMD= "sudo systemctl stop puck_detection.service;sudo systemctl start puck_detection.service" ret = run("tools/SshExec") diff --git a/script/tools/StopPuckDetection.py b/script/tools/StopPuckDetection.py index 1ff6f04..e45a6ae 100644 --- a/script/tools/StopPuckDetection.py +++ b/script/tools/StopPuckDetection.py @@ -1,5 +1,5 @@ USR,PWD = "pi", "raspberry" -HOST,PORT = "tell-raspberrypi", 22 +HOST,PORT = "tell6s-raspberrypi", 22 CMD= "sudo systemctl stop puck_detection.service" ret = run("tools/SshExec")