Commit a8d12c18 authored by vertighel's avatar vertighel
Browse files

Error handling in mercury.py

parent 6c6807bc
Loading
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -126,11 +126,18 @@ class Mercury(BaseDevice):
        """

        pidevice = self._check_connection()
        method = getattr(pidevice, f"q{command}")
        method = getattr(pidevice, f"q{command.upper()}")
        try:
            if (command == "ERR"):
                return method()
            else:
                return method(self.axis)[self.axis]
        except GCSError as e:
            log.error(f"Error: {e}")
            return None
        except AttributeError as e:
            log.error(f"Command not found: {e}")
            return None


    def put(self, command, *args):
@@ -144,11 +151,14 @@ class Mercury(BaseDevice):
        """

        pidevice = self._check_connection()
        method = getattr(pidevice, command)
        method = getattr(pidevice, command.upper())
        try:
            return method(self.axis, *args)
        except GCSError as e:
            log.error(f"Device not initialized: {e}")
            log.error(f"Error: {e}")
            return None
        except AttributeError as e:
            log.error(f"Command not found: {e}")
            return None

    def wait(self):