<s> import time <EOL> from astropy import units as u <EOL> from astropy . coordinates import SkyCoord <EOL> from . . utils . logger import get_logger <EOL> from . . utils import current_time <EOL> class AbstractMount ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , <EOL> config = dict ( ) , <EOL> location = None , <EOL> ** kwargs <EOL> ) : <EOL> self . logger = get_logger ( self ) <EOL> self . mount_config = config <EOL> self . logger . debug ( "<STR_LIT>" . format ( config ) ) <EOL> self . config = config <EOL> self . logger . debug ( "<STR_LIT>" ) <EOL> self . commands = self . _setup_commands ( kwargs . get ( '<STR_LIT>' , [ ] ) ) <EOL> self . logger . debug ( "<STR_LIT>" ) <EOL> self . _location = location <EOL> self . non_sidereal_available = self . mount_config . setdefault ( '<STR_LIT>' , False ) <EOL> self . PEC_available = self . mount_config . setdefault ( '<STR_LIT>' , False ) <EOL> self . _is_connected = False <EOL> self . _is_initialized = False <EOL> self . _is_slewing = False <EOL> self . _is_parked = False <EOL> self . _is_tracking = False <EOL> self . _is_home = False <EOL> self . _state = '<STR_LIT>' <EOL> self . guide_rate = <NUM_LIT> <EOL> self . _tracking_rate = <NUM_LIT:1.0> <EOL> self . _tracking = '<STR_LIT>' <EOL> self . _status_lookup = dict ( ) <EOL> self . _target_coordinates = None <EOL> self . _current_coordinates = None <EOL> self . _park_coordinates = None <EOL> def connect ( self ) : <EOL> raise NotImplementedError ( ) <EOL> def status ( self ) : <EOL> raise NotImplementedError ( ) <EOL> def initialize ( self ) : <EOL> raise NotImplementedError ( ) <EOL> @ property <EOL> def location ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _location <EOL> @ location . setter <EOL> def location ( self , location ) : <EOL> self . _location = location <EOL> self . _setup_location_for_mount ( ) <EOL> @ property <EOL> def is_connected ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _is_connected <EOL> @ property <EOL> def is_initialized ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _is_initialized <EOL> @ property <EOL> def is_parked ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _is_parked <EOL> @ property <EOL> def is_home ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _is_home <EOL> @ property <EOL> def is_tracking ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _is_tracking <EOL> @ property <EOL> def is_slewing ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _is_slewing <EOL> @ property <EOL> def state ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _state <EOL> def set_park_coordinates ( self , ha = - <NUM_LIT> * u . degree , dec = - <NUM_LIT:10> * u . degree ) : <EOL> """<STR_LIT>""" <EOL> self . logger . debug ( '<STR_LIT>' ) <EOL> park_time = current_time ( ) <EOL> park_time . location = self . location <EOL> lst = park_time . sidereal_time ( '<STR_LIT>' ) <EOL> self . logger . debug ( "<STR_LIT>" . format ( lst ) ) <EOL> self . logger . debug ( "<STR_LIT>" . format ( ha ) ) <EOL> ra = lst - ha <EOL> self . logger . debug ( "<STR_LIT>" . format ( ra ) ) <EOL> self . logger . debug ( "<STR_LIT>" . format ( dec ) ) <EOL> self . _park_coordinates = SkyCoord ( ra , dec ) <EOL> self . logger . info ( "<STR_LIT>" . format ( self . _park_coordinates ) ) <EOL> def get_target_coordinates ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _target_coordinates <EOL> def set_target_coordinates ( self , coords ) : <EOL> """<STR_LIT>""" <EOL> self . _target_coordinates = coords <EOL> def get_current_coordinates ( self ) : <EOL> """<STR_LIT>""" <EOL> return self . _current_coordinates <EOL> def slew_to_coordinates ( self , coords , ra_rate = <NUM_LIT> , dec_rate = <NUM_LIT:0.0> ) : <EOL> """<STR_LIT>""" <EOL> assert isinstance ( coords , tuple ) , self . logger . warning ( <EOL> '<STR_LIT>' ) <EOL> response = <NUM_LIT:0> <EOL> if not self . is_parked : <EOL> if self . set_target_coordinates ( coords ) : <EOL> response = self . slew_to_target ( ) <EOL> else : <EOL> self . logger . warning ( "<STR_LIT>" ) <EOL> return response <EOL> def home_and_park ( self ) : <EOL> """<STR_LIT>""" <EOL> self . slew_to_home ( ) <EOL> while self . is_slewing : <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> self . logger . info ( "<STR_LIT>" ) <EOL> self . _is_initialized = False <EOL> self . initialize ( ) <EOL> self . park ( ) <EOL> while self . is_slewing : <EOL> time . sleep ( <NUM_LIT:5> ) <EOL> self . logger . info ( "<STR_LIT>" ) <EOL> self . logger . info ( "<STR_LIT>" ) <EOL> def slew_to_zero ( self ) : <EOL> """<STR_LIT>""" <EOL> self . slew_to_home ( ) <EOL> def slew_to_target ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def slew_to_home ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def park ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def unpark ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def move_direction ( self , direction = '<STR_LIT>' , seconds = <NUM_LIT:1.0> ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def serial_query ( self , cmd , * args ) : <EOL> raise NotImplementedError ( ) <EOL> def serial_read ( self ) : <EOL> raise NotImplementedError ( ) <EOL> def serial_write ( self , cmd ) : <EOL> raise NotImplementedError ( ) <EOL> def _setup_location_for_mount ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def _setup_commands ( self , commands ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def _set_zero_position ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( ) <EOL> def _mount_coord_to_skycoord ( self ) : <EOL> raise NotImplementedError ( ) <EOL> def _skycoord_to_mount_coord ( self ) : <EOL> raise NotImplementedError ( ) </s>
