Пример #1
0
 def focuser(self):
     if not hasattr(self, '_focuser'):
         try:
             self._focuser = focuser.driver.Driver(
                 host=self.config['focuser']['host'])
         except socket.timeout as e:
             raise ttypes.LesediException('Connection timed out.')
         except socket.error as e:
             raise ttypes.LesediException(str(e))
     return self._focuser
Пример #2
0
 def rotator_left(self):
     if not hasattr(self, '_rotator_left'):
         try:
             self._rotator_left = rotator.driver.LeftRotatorDriver(
                 host=self.config['rotator']['host'])
         except socket.timeout as e:
             raise ttypes.LesediException('Connection timed out.')
         except socket.error as e:
             raise ttypes.LesediException(str(e))
     return self._rotator_left
Пример #3
0
 def telescope(self):
     if not hasattr(self, '_telescope'):
         try:
             self._telescope = telescope.driver.Driver(
                 host=self.config['telescope']['host'])
         except socket.timeout as e:
             raise ttypes.LesediException('Connection timed out.')
         except socket.error as e:
             raise ttypes.LesediException(str(e))
     return self._telescope
Пример #4
0
    def goto_radec(self, ra, dec):
        telescope = self.telescope.get_status()

        if telescope.parked:
            raise ttypes.LesediException(
                'Telescope cannot be slewed while parked.')

        if telescope.manual:
            raise ttypes.LesediException(
                'Cannot move telescope. Motors are in manual mode.')

        self.telescope.goto_radec(ra, dec)
Пример #5
0
    def wrapper(self, *args, **kwargs):
        if self._stop.is_set():
            raise ttypes.LesediException(
                'Emergency stop has been triggered. Please reset to continue.')

        dome = self.dome.get_status()

        if dome.tcs_locked_out:
            raise ttypes.LesediException(
                'Lockout engaged. Command not allowed.')

        return f(self, *args, **kwargs)
Пример #6
0
    def _write(self, value):

        builder = BinaryPayloadBuilder(byteorder='>', wordorder='<')
        builder.add_16bit_uint(value)
        payload = builder.to_registers()

        try:
            with ModbusTcpClient(self.host, self.port) as client:
                result = client.write_registers(self.COMMAND_ADDRESS, payload)
        except ConnectionException as e:
            raise ttypes.LesediException(str(e))

        if result.isError():
            raise ttypes.LesediException(str(result))
Пример #7
0
    def unpark(self):
        response = Response(self.execute('UnParkRotator'))

        if response.message == 'UnParkRotatorAccepted':
            return response

        raise ttypes.LesediException('Unpark command failed.')
Пример #8
0
    def get_status(self):
        try:
            with ModbusTcpClient(self.host, self.port) as client:
                result = client.read_holding_registers(
                    self.COVERS_STATUS_ADDRESS, self.COVERS_STATUS_LENGTH)
        except ConnectionException as e:
            raise ttypes.LesediException(str(e))

        if result.isError():
            raise ttypes.LesediException(str(result))

        status = BinaryPayloadDecoder.fromRegisters(
            result.registers, byteorder='>',
            wordorder='<').decode_16bit_uint()

        return Status(status)
Пример #9
0
    def close_dome(self):
        dome = self.dome.get_status()

        if not dome.remote:
            raise ttypes.LesediException(
                'Dome cannot be closed while not in remote mode.')

        self.dome.close()
Пример #10
0
    def tertiary_go_right(self):

        response = Response(self.execute('GoRightTertiary'))

        if response.message == 'GoRightTertiaryAccepted':
            return response

        raise ttypes.LesediException('Tertiary go command failed.')
Пример #11
0
    def rotate_dome(self, az):
        dome = self.dome.get_status()

        if not dome.remote:
            raise ttypes.LesediException(
                'Dome cannot be rotated while not in remote mode.')

        self.dome.rotate(az)
Пример #12
0
    def secondary_to_manual(self):

        response = Response(self.execute('ToBlinkyFocuser'))

        if response.message == 'ToBlinkyFocuserAccepted':
            return response

        raise ttypes.LesediException('Manual command failed.')
Пример #13
0
    def select_instrument(self, instrument):
        """Tertiary mirror is is position 1 (i.e. directing the beam to the
        SHOC port) or position 2 (for WiNCam).
        """

        if instrument == ttypes.Instrument.WINCAM:
            response = Response(self.execute('GoLeftTertiary'))
        elif instrument == ttypes.Instrument.SHOC:
            response = Response(self.execute('GoRightTertiary'))
        else:
            raise ttypes.LesediException('Unknown instrument')

        if response.message in ('GoLeftTertiaryAccepted',
                                'GoRightTertiaryAccepted'):
            return response

        raise ttypes.LesediException('Select instrument command failed.')
Пример #14
0
 def aux(self):
     if not hasattr(self, '_aux'):
         try:
             self._aux = aux.driver.Driver(host=self.config['aux']['host'])
         except Exception as e:
             # TODO: Handle more specific types of exceptions.
             raise ttypes.LesediException(str(e))
     return self._aux
Пример #15
0
    def open_dome(self):
        dome = self.dome.get_status()

        if not dome.remote:
            raise ttypes.LesediException(
                'Dome cannot be opened while not in remote mode.')

        self.dome.open()
Пример #16
0
    def set_focus(self, inches):
        focuser = self.focuser.get_status()

        if not focuser.secondary_mirror_auto:
            raise ttypes.LesediException(
                'Cannot set focus. Secondary mirror is in manual mode.')

        self.focuser.secondary_move_to(inches)
Пример #17
0
    def park_dome(self):
        dome = self.dome.get_status()

        if not dome.remote:
            raise ttypes.LesediException(
                'Dome cannot be parked while not in remote mode.')

        self.dome.park()
Пример #18
0
    def cancel_autofocus(self):

        response = Response(self.execute('CancelAutoFocus'))

        if response.message == 'CancelAutoFocusAccepted':
            return response

        raise ttypes.LesediException('Cancel command failed.')
Пример #19
0
    def secondary_to_auto(self):

        response = Response(self.execute('ToAutoFocuser'))

        if response.message == 'ToAutoFocuserAccepted':
            return response

        raise ttypes.LesediException('Auto command failed.')
Пример #20
0
    def tracking_off(self):

        response = Response(self.execute('RotatorTrackingOff'))

        if response.message == 'TrackingOffAccepted':
            return response

        raise ttypes.LesediException('Tracking off command failed.')
Пример #21
0
    def do_autofocus(self):

        response = Response(self.execute('DoAutoFocus'))

        if response.message == 'FocuserToAutoAccepted':
            return response

        raise ttypes.LesediException('Autofocus command failed.')
Пример #22
0
    def move_to_parallactic_angle(self):
        """Move the rotator to the parallactic angle (North Up) (or will move to the limit)."""

        response = Response(self.execute('MoveRotatorToParallacticAngle'))

        if response.message == '':
            return response

        raise ttypes.LesediException('Move to parallactic angle command failed.')
Пример #23
0
    def to_manual(self):
        """Put it in "Manual" (blinky) mode."""

        response = Response(self.execute('RotatorToBlinky'))

        if response.message == 'RotatorToBlinkyAccepted':
            return response

        raise ttypes.LesediException('Manual command failed.')
Пример #24
0
    def to_auto(self):
        """Put it in "Auto" mode."""

        response = Response(self.execute('RotatorToAuto'))

        if response.message == 'RotatorToAutoAccepted':
            return response

        raise ttypes.LesediException('Auto command failed.')
Пример #25
0
    def secondary_move_to(self, inches):
        """Move the focuser to nn.nn inches (or will move to the limit)."""

        response = Response(self.execute('MoveFocuserTo {}'.format(inches)))

        if response.message == 'MoveFocuserAccepted':
            return response

        raise ttypes.LesediException('Move command failed.')
Пример #26
0
    def secondary_stop(self):
        """Stop the focuser movement."""

        response = Response(self.execute('StopFocuser'))

        if response.message == 'StopFocuserAccepted':
            return response

        raise ttypes.LesediException('Stop command failed.')
Пример #27
0
    def tertiary_to_manual(self):
        """Puts the tertiary servo motor into the "Manual" (or blinky) mode."""

        response = Response(self.execute('ToBlinkyTertiary'))

        if response.message == 'ToBlinkyTertiaryAccepted':
            return response

        raise ttypes.LesediException('Tertiary manual command failed.')
Пример #28
0
    def restart_comms(self):
        """Try to reconnect to ServoCommunicator if there is no communications."""

        response = Response(self.execute('RestartCommunicatorComms'))

        if response.message == 'RestartCommunicatorCommsAccepted':
            return response

        raise ttypes.LesediException('Restart command failed.')
Пример #29
0
    def tertiary_to_auto(self):
        """Puts the tertiary servo motor into the "Auto" mode."""

        response = Response(self.execute('ToAutoTertiary'))

        if response.message == 'ToAutoTertiaryAccepted':
            return response

        raise ttypes.LesediException('Tertiary auto command failed.')
Пример #30
0
    def tertiary_jog_by(self, angle):
        """Jog the Tertiary mirror by nn.nn angle (or will move to the limit)."""

        response = Response(self.execute('JogTertiary {:.2f}'.format(angle)))

        if response.message == '':
            return response

        raise ttypes.LesediException('Tertiary jog command failed.')