From 49c8d1d4b5475bf65f486c046b64ddb87e897924 Mon Sep 17 00:00:00 2001 From: gac-S_Changer Date: Tue, 26 Jan 2021 15:55:31 +0100 Subject: [PATCH] Bug on ScanPuck - hexiposi --- config/config.properties | 4 +-- config/devices.properties | 16 ++++++------ config/settings.properties | 9 +++---- config/variables.properties | 4 +-- devices/B5.properties | 2 +- devices/C3.properties | 2 +- devices/C4.properties | 2 +- devices/led_ctrl_1.properties | 2 +- devices/led_ctrl_2.properties | 2 +- devices/led_ctrl_3.properties | 2 +- script/data/samples.py | 20 +++++++++++++++ script/devices/Hexiposi.py | 47 ++++++++++++++++++++++------------- script/motion/mount.py | 2 +- script/motion/scan_pin.py | 42 ++++++++++++++++++++++++++++--- script/motion/tools.py | 3 ++- script/motion/unmount.py | 2 +- 16 files changed, 115 insertions(+), 46 deletions(-) diff --git a/config/config.properties b/config/config.properties index fbfe3e8..05bd7fd 100644 --- a/config/config.properties +++ b/config/config.properties @@ -1,4 +1,4 @@ -#Tue Sep 08 11:55:02 CEST 2020 +#Tue Jan 26 15:45:35 CET 2021 autoSaveScanData=true simulation=false commandExecutionEvents=false @@ -19,7 +19,7 @@ hideServerMessages=true serverPort=8080 versionTrackingEnabled=true dataPath={data}/{year}_{month}/{date}/{date}_{time}_{name} -serverEnabled=true +serverEnabled=false dataScanReleaseRecords=false depthDimension=0 dataScanPreserveTypes=false diff --git a/config/devices.properties b/config/devices.properties index eafe62f..4355d14 100644 --- a/config/devices.properties +++ b/config/devices.properties @@ -3,10 +3,10 @@ img=ch.psi.pshell.prosilica.Prosilica|204464 "PacketSize=1504;PixelFormat=Mono8; #monitoring_cam=ch.psi.pshell.imaging.MjpegSource|http://axis-accc8ea5e463.psi.ch/axis-cgi/mjpg/video.cgi?camera=2 reopen||-200| #top_cam=ch.psi.pshell.imaging.MjpegSource|http://axis-accc8ea5e463.psi.ch/axis-cgi/mjpg/video.cgi?camera=3 true||-200| #cam=ch.psi.pshell.epics.AreaDetector|MX-SAMCAM||| -mscan_pin=ch.psi.pshell.serial.TcpDevice|129.129.110.109:2001||| -mscan_pin_cmd=ch.psi.pshell.serial.TcpDevice|129.129.110.109:2003||| -mscan_puck=ch.psi.pshell.serial.TcpDevice|129.129.110.93:2001||| -mscan_puck_cmd=ch.psi.pshell.serial.TcpDevice|129.129.110.93:2003||| +mscan_pin=ch.psi.pshell.serial.TcpDevice|129.129.110.87:2001||| +mscan_pin_cmd=ch.psi.pshell.serial.TcpDevice|129.129.110.87:2003||| +mscan_puck=ch.psi.pshell.serial.TcpDevice|129.129.110.88:2001||| +mscan_puck_cmd=ch.psi.pshell.serial.TcpDevice|129.129.110.88:2003||| ue=LaserUE|COM3 50 35|||true puck_detection=ch.psi.mxsc.PuckDetection|tell6d-raspberrypi:5556||| wago=ch.psi.pshell.modbus.ModbusTCP|tell6d-wago:502||| @@ -55,7 +55,7 @@ led_ctrl_1=ch.psi.pshell.modbus.ProcessVariable|wago 0||| led_ctrl_2=ch.psi.pshell.modbus.ProcessVariable|wago 1||| led_ctrl_3=ch.psi.pshell.modbus.ProcessVariable|wago 2||| smc_current=ch.psi.pshell.modbus.ProcessVariable|wago 3||| -th2e=ch.psi.pshell.modbus.ModbusTCP|129.129.110.:502||| -temperature=ch.psi.pshell.modbus.ReadonlyProcessVariable|th2e 1||10000| -humidity=ch.psi.pshell.modbus.ReadonlyProcessVariable|th2e 5||10000| -dew_point=ch.psi.pshell.modbus.ReadonlyProcessVariable|th2e 9||10000| +#th2e=ch.psi.pshell.modbus.ModbusTCP|129.129.110.:502||| +#temperature=ch.psi.pshell.modbus.ReadonlyProcessVariable|th2e 1||10000| +#humidity=ch.psi.pshell.modbus.ReadonlyProcessVariable|th2e 5||10000| +#dew_point=ch.psi.pshell.modbus.ReadonlyProcessVariable|th2e 9||10000| diff --git a/config/settings.properties b/config/settings.properties index 6a8bdd9..d19735a 100644 --- a/config/settings.properties +++ b/config/settings.properties @@ -1,12 +1,11 @@ -#Tue Oct 06 10:03:09 CEST 2020 -dry_mount_counter=7 -mounted_sample_position=C11 +#Tue Jan 26 15:46:23 CET 2021 +dry_mount_counter=4 room_temperature_enabled=false -pin_offset=0.508 +pin_offset=1.0 puck_types=true pin_cleaner_timer=60 imaging_enabled=false -dry_timestamp=1.601971335576E9 +dry_timestamp=1.611668783052E9 roi_h=1000 led_level=0.0 beamline_status_enabled=false diff --git a/config/variables.properties b/config/variables.properties index d3aee7a..30ae3fc 100644 --- a/config/variables.properties +++ b/config/variables.properties @@ -1,2 +1,2 @@ -#Tue Sep 01 09:11:47 CEST 2020 -FileSequentialNumber=184 +#Thu Jan 21 10:33:11 CET 2021 +FileSequentialNumber=207 diff --git a/devices/B5.properties b/devices/B5.properties index f768e0f..986bf78 100644 --- a/devices/B5.properties +++ b/devices/B5.properties @@ -1,3 +1,3 @@ -#Wed Dec 11 08:55:08 CET 2019 +#Thu Jan 21 09:38:30 CET 2021 detection=Mechanical disabled=false diff --git a/devices/C3.properties b/devices/C3.properties index 5210a65..ea61eb4 100644 --- a/devices/C3.properties +++ b/devices/C3.properties @@ -1,3 +1,3 @@ -#Thu Sep 19 08:23:37 CEST 2019 +#Thu Nov 12 13:39:42 CET 2020 detection=Mechanical disabled=false diff --git a/devices/C4.properties b/devices/C4.properties index 61fba0c..c83df35 100644 --- a/devices/C4.properties +++ b/devices/C4.properties @@ -1,3 +1,3 @@ -#Wed Dec 11 08:56:26 CET 2019 +#Tue Dec 01 08:46:40 CET 2020 detection=Mechanical disabled=false diff --git a/devices/led_ctrl_1.properties b/devices/led_ctrl_1.properties index f753782..da8d4cf 100644 --- a/devices/led_ctrl_1.properties +++ b/devices/led_ctrl_1.properties @@ -1,4 +1,4 @@ -#Fri Oct 02 14:37:21 CEST 2020 +#Thu Jan 21 10:56:46 CET 2021 minValue=0.0 unit=V offset=0.0 diff --git a/devices/led_ctrl_2.properties b/devices/led_ctrl_2.properties index f753782..da8d4cf 100644 --- a/devices/led_ctrl_2.properties +++ b/devices/led_ctrl_2.properties @@ -1,4 +1,4 @@ -#Fri Oct 02 14:37:21 CEST 2020 +#Thu Jan 21 10:56:46 CET 2021 minValue=0.0 unit=V offset=0.0 diff --git a/devices/led_ctrl_3.properties b/devices/led_ctrl_3.properties index f753782..da8d4cf 100644 --- a/devices/led_ctrl_3.properties +++ b/devices/led_ctrl_3.properties @@ -1,4 +1,4 @@ -#Fri Oct 02 14:37:21 CEST 2020 +#Thu Jan 21 10:56:46 CET 2021 minValue=0.0 unit=V offset=0.0 diff --git a/script/data/samples.py b/script/data/samples.py index 7110d57..ce3d213 100644 --- a/script/data/samples.py +++ b/script/data/samples.py @@ -134,6 +134,26 @@ def get_puck_datamatrix(): ret[si["puckBarcode"]] = si["puckAddress"] return ret + +def get_puck_datamatrix_info(): + ret = {} + for si in samples_info: + if si["puckBarcode"] is not None and si["puckBarcode"]!="": + info = {} + info["address"] = si["puckAddress"] + info["dewar"] = si ["dewarName"] + info["name"] = si ["puckName"] + info["user"] = si ["userName"] + info["type"] = si ["puckType"] + ret[si["puckBarcode"]] = info + return ret + +def get_puck_address(barcode): + try: + return get_puck_datamatrix()[barcode] + except: + return None + def get_puck_address(barcode): try: return get_puck_datamatrix()[barcode] diff --git a/script/devices/Hexiposi.py b/script/devices/Hexiposi.py index e787e56..39eb440 100644 --- a/script/devices/Hexiposi.py +++ b/script/devices/Hexiposi.py @@ -21,7 +21,7 @@ class Hexiposi(DiscretePositionerBase): def doInitialize(self): super(Hexiposi, self).doInitialize() - self.val = self.doReadReadback() + self.val = self._posNameToIndex(self.doReadReadback()) def get_response(self, response): if (response.status_code!=200): @@ -40,14 +40,10 @@ class Hexiposi(DiscretePositionerBase): self.moving = self.status["moving"] self.offset = self.status["offset"] self.dpos = self.status["discretePosition"] - if (self.homed==False): rback = self.UNKNOWN_POSITION - elif self.dpos == 1: rback = "B" # "A" - elif self.dpos == 2: rback = "C" # "B" - elif self.dpos == 4: rback = "D" # "C" - elif self.dpos == 8: rback = "E" # "D" - elif self.dpos == 16: rback = "F" # "E" - elif self.dpos == 32: rback = "A" # "F" - else: rback = self.UNKNOWN_POSITION + if (self.homed==False): + rback = self.UNKNOWN_POSITION + else: + rback = self._posIndexToName(self.dpos) if (rback == self.UNKNOWN_POSITION) or (rback != self.rback): self.moved = True self.rback = rback @@ -58,7 +54,7 @@ class Hexiposi(DiscretePositionerBase): self.updateState() raise - def set_deadband(self, value = 0.1): #degrees + def set_deadband(self, value = 1.0): #degrees ret = self.get_response(requests.get(url=self.url_set+"setDeadband?deadband=" + str(value), timeout=self.timeout)) if ret["deadbandOutput"] == value: return value @@ -96,13 +92,30 @@ class Hexiposi(DiscretePositionerBase): self.get_status() return self.rback - def doWrite(self, val): - #val = ord(val) - ord('A') +1 + def _posNameToIndex(self, val): + if val == self.UNKNOWN_POSITION: + return None val = ord(val) - ord('B') +1 if val==0: val=6 #A - if val<1 or val>6: + return val + + def _posIndexToName(self, val): + if self.dpos == 1: return "B" # "A" + elif self.dpos == 2:return "C" # "B" + elif self.dpos == 4:return "D" # "C" + elif self.dpos == 8:return "E" # "D" + elif self.dpos == 16:return "F" # "E" + elif self.dpos == 32:return "A" # "F" + else: return self.UNKNOWN_POSITION + + def doWrite(self, val): + self.assert_homed() + #val = ord(val) - ord('A') +1 + val = self._posNameToIndex(val) + if (val is None) or val<1 or val>6: raise Exception("Invalid value: " + str(val)) moving = val != self.val + print "Moving hexiposi to:", val, " current:", self.val, " moving:",moving self.val = val self.move_pos(self.val) #Workaround as state does not changes immediatelly @@ -123,8 +136,8 @@ class Hexiposi(DiscretePositionerBase): def assert_in_position(self, pos): - if not is_in_position(pos): - raise Exception ("Hexiposi is not in position") + if not self.is_in_position(pos): + raise Exception ("Hexiposi is not in position: " + str(pos)) def assert_homed(self): if self.homed == False: @@ -133,7 +146,7 @@ class Hexiposi(DiscretePositionerBase): def assert_in_known_position(self): self.get_status() if self.rback == 'Unknown': - raise Exception("Hexiposi is in an unknown position, please home.") + raise Exception("Hexiposi is in an unknown position.") #def isReady(self): # self.get_status() @@ -172,4 +185,4 @@ class hexiposi_position(ReadonlyRegisterBase): add_device(hexiposi_position(), True) hexiposi_position.polling = 1000 -hexiposi.set_deadband(1.0) +hexiposi.set_deadband(1.3) diff --git a/script/motion/mount.py b/script/motion/mount.py index ab93351..485153d 100644 --- a/script/motion/mount.py +++ b/script/motion/mount.py @@ -90,7 +90,7 @@ def mount(segment, puck, sample, force=False, read_dm=False, auto_unmount=False) robot.get_aux(sample) else: - set_hexiposi(segment) + set_hexiposi(segment, force=True) if not force: visual_check_hexiposi(segment) diff --git a/script/motion/scan_pin.py b/script/motion/scan_pin.py index 77bb83c..bce6c18 100644 --- a/script/motion/scan_pin.py +++ b/script/motion/scan_pin.py @@ -34,9 +34,9 @@ def scan_pin(segment, puck, sample, force=False): robot.get_aux(sample) else: - # set_hexiposi(segment) - # if not force: - # visual_check_hexiposi(segment) + set_hexiposi(segment) + if not force: + visual_check_hexiposi(segment) if not robot.is_dewar(): robot.move_dewar() @@ -70,6 +70,42 @@ def scan_puck(segment, puck, force=False): return ret +def mount_pucks(pucks): + """mount evry position from the given pucks + + pucks is a list of puck specification in the format: [segment][puck] + + Example: mount_pucks(['c4', e3', 'e2', 'f1']) + """ + for p in pucks: + seg, puc = list(p) + seg = seg.upper() + puc = int(puc) + print "Mounting all positions from {} {}".format(seg.upper(), puc) + mount_puck_pins(seg, puc) + # mount_puck_pins(seg, puc, [1, 2, 3]) # mount only pins 1, 2, 3 for each puck + +def mount_puck_pins(segment, puck, positions=None): + """ Mounts every position from the given segment/puck.""" + from time import sleep + results = [] + + if positions is None: + positions = range(1, 17) + + for i in positions: + #b = magnet_position.getValue() + mount(segment, puck, i, True, False, True) + #a = magnet_position.getValue() + #results.append((b, a)) + #print "{:^8.3f}|{:^8.3f}".format(b, a) + sleep(1.0) + + # print results + print "{:^8s}|{:^8s}".format("Before", "After") + for b,a in results: + print "{:^8.3f}|{:^8.3f}".format(b, a) + def scan_gripper(): print "scan gripper" #Initial checks diff --git a/script/motion/tools.py b/script/motion/tools.py index 58bb7fc..3aa3720 100644 --- a/script/motion/tools.py +++ b/script/motion/tools.py @@ -41,7 +41,7 @@ def enable_motion(): raise Exception("Cannot enable power: robot state is " + str(robot.state)) robot.enable() -def set_hexiposi(pos, force = False): +def set_hexiposi(pos, force = True): """ Set the hexiposi position in remote mode, or wait for it to be set in manual mode """ @@ -58,6 +58,7 @@ def set_hexiposi(pos, force = False): set_status(None) else: hexiposi.move(pos) + #hexiposi.assert_in_position(pos) #Can be used if cover has following error (no checking readback) def _set_hexiposi(pos): diff --git a/script/motion/unmount.py b/script/motion/unmount.py index 6f9ce22..a9d8931 100644 --- a/script/motion/unmount.py +++ b/script/motion/unmount.py @@ -67,7 +67,7 @@ def unmount(segment = None, puck = None, sample = None, force=False, auto_unmoun enable_motion() if not is_aux: - set_hexiposi(segment) + set_hexiposi(segment, force=True) if not force: visual_check_hexiposi(segment)