alpaca package

Submodules

alpacadsc.alpaca_controller module

class alpacadsc.alpaca_controller.AlpacaBase(*args, **kwargs)

Bases: flask_restx.resource.Resource

Handle common Alpaca REST APIs for all device types.

get(action)
methods = {'GET', 'PUT'}
put(action)
class alpacadsc.alpaca_controller.AlpacaTelescope(*args, **kwargs)

Bases: alpacadsc.alpaca_controller.AlpacaBase

Handle common Alpaca REST APIs for all device types.

get(action)
methods = {'GET', 'PUT'}
put(action)

alpacadsc.alpaca_models module

class alpacadsc.alpaca_models.AlpacaAltAzTelescopeModel(use_profile=None)

Bases: alpacadsc.alpaca_models.AlpacaBaseModel

Driver for Alt/Az setting circles

connect()

Attempts to connect to device

Returns:Success code - True means success.
Return type:bool
convert_encoder_position_to_altaz(enc_alt, enc_az)

Converts from raw encoder values to sky alt/az values.

note Driver must be synchronized or value will be meaningless.

Parameters:
  • enc_alt – Raw encoder alitude value
  • enc_az – Raw encoder azimuth value
Returns:

(float, float) Sky altitude/azimuth positions or None if device is

not synchronized yet

disconnect()

Disconnects from device

Returns:Success code - True means success.
Return type:bool
find_encoders_plugins()

Searches for encoders drivers.

Drivers will have a name in the format “encoders_<drivername>” and are located in the alpacadsc package, an example being “encoders_altaz_simulator”

The path containing the alpacadsc package is scanned for modules matching this pattern. Then for each module it is inspected to determine if it is an encoder driver. The signature for this is if the module contains a class that is derived from the EncodersBase class.

The result will be to add an attribute to the object called “encoders_plugins” which is a list of Plugins namedtuples which contains the human readable name of the driver as well as a reference to the important module and the class containing the encoders driver.

get_current_altaz()

Returns current RA/ALT/AZ of where device is pointing.

note Driver must be synchronized or value will be meaningless.

Returns:
(float, float) RA/DEC position or None if device is
not synchronized yet
get_current_radec()

Returns current RA/DEC of where device is pointing.

note Driver must be synchronized or value will be meaningless.

Returns:
(float, float) RA/DEC position or None if device is
not synchronized yet
load_current_profile()

Attempts to load the current active profile.

Returns:Success code - True for success
Return type:bool
load_encoders(encoders_profile)

Load encoders and connect.

Parameters:encoders_profile – Dictionary containing encoder parameters
Returns:True on success, False if fails.
Return type:bool
load_profile(try_profile=None)

Load a configuration profile. Will load the current active profile or if a profile name is provided it will be attempted first.

Parameters:try_profile (str) – Optional profile name (without ‘.yaml’ extension), defaults to None
Returns:Tuple with loaded Profile object and name of profile loaded
Return type:tuple of (Profile, str)
sync_to_coordinates(ra, dec)

Synchronize device to RA/DEC position.

Parameters:
  • ra – RA position in decimal hours
  • dec – DEC position in decimal degrees
Returns:

(bool) Return code True = success False = failure

unload_current_profile()

Clear any profile information from object.

class alpacadsc.alpaca_models.AlpacaBaseModel

Bases: object

class alpacadsc.alpaca_models.Plugin(name, moduleref, classref)

Bases: tuple

Create new instance of Plugin(name, moduleref, classref)

classref

Alias for field number 2

moduleref

Alias for field number 1

name

Alias for field number 0

alpacadsc.alpaca_service module

class alpacadsc.alpaca_service.AlpacaBaseService(driver)

Bases: object

Handle PUT REST API methods common to all Alpaca devices

connected(form)

Handle request to connect/disconnect the driver from hardware.

Parameters:form (dict) – PUT form data as a dict
Returns:Success code - True means success.
Return type:bool
class alpacadsc.alpaca_service.AlpacaTelescopeService(driver)

Bases: object

Handle PUT REST API command for the Alpaca telescope driver.

siteelevation(form)

Handle request to set site elevation.

Parameters:form (dict) – PUT form data as a dict
Returns:Success code - True means success.
Return type:bool
sitelatitude(form)

Handle request to set site latitude.

Parameters:form (dict) – PUT form data as a dict
Returns:Success code - True means success.
Return type:bool
sitelongitude(form)

Handle request to set site longitude.

Parameters:form (dict) – PUT form data as a dict
Returns:Success code - True means success.
Return type:bool
synctoaltaz(form)

Handle request to sync mount to an alt/az position.

Parameters:form (dict) – PUT form data as a dict
Returns:Success code - True means success.
Return type:bool
synctocoordinates(form)

Handle request to sync mount to a ra/dec position.

Parameters:form (dict) – PUT form data as a dict
Returns:Success code - True means success.
Return type:bool
alpacadsc.alpaca_service.field_declination(*args, **kwargs)

Fields descriptor for declination

alpacadsc.alpaca_service.field_latitude(*args, **kwargs)

Fields descriptor for latitude

alpacadsc.alpaca_service.field_longitude(*args, **kwargs)

Fields descriptor for longitude

alpacadsc.alpaca_service.field_right_ascension(*args, **kwargs)

Fields descriptor for right ascension

alpacadsc.altaz_dsc_profile module

class alpacadsc.altaz_dsc_profile.AltAzSettingCirclesProfile(reldir, name=None)

Bases: alpacadsc.profiles.Profile

class Encoders(_sectionname: str = 'encoders', driver: str = None, serial_port: str = None, serial_speed: int = 9600, alt_resolution: int = None, az_resolution: int = None, alt_reverse: bool = False, az_reverse: bool = False)

Bases: alpacadsc.profiles.ProfileSection

alt_resolution = None

Alt axis resolution

alt_reverse = False

Reverse ALT?

az_resolution = None

AZ axis resolution

az_reverse = False

Reverse AZ?

driver = None
serial_port = None
serial_speed = 9600
class Location(_sectionname: str = 'location', obsname: str = None, latitude: float = None, longitude: float = None, altitude: float = None)

Bases: alpacadsc.profiles.ProfileSection

altitude = None

Altitude in meters

latitude = None

Latitude in degrees

longitude = None

Longitude in degrees

obsname = None

Name of observing location

read()

Read profile config file.

Returns:(bool) Whether or not read succeeded.

alpacadsc.baseencoders module

class alpacadsc.baseencoders.EncodersBase

Bases: object

Base class for all encoder drivers.

connect()

The driver should connect to the digital setting circles hardware when this method is called.

disconnect()

The driver should disconnect to the digital setting circles hardware when this method is called.

get_encoder_position()

Read the encoders resolution from the digital setting circles hardware.

Returns:(tuple) The position of the altitude and azimuth encoders.
get_encoder_resolution()

Read the encoders resolution from the digital setting circles hardware.

Returns:(tuple) The resolution of the altitude and azimuth encoders.
name()

Returns the human readable name for this driver.

set_encoder_resolution(res_alt, res_az)

Read the encoders resolution from the digital setting circles hardware.

Parameters:
  • res_alt – Resolution (steps/rev) of altitude encoder.
  • res_alt – Resolution (steps/rev) of azimuth encoder.

alpacadsc.baseencoders_serial module

class alpacadsc.baseencoders_serial.EncodersSerial(res_alt=4000, res_az=4000, reverse_alt=False, reverse_az=False)

Bases: alpacadsc.baseencoders.EncodersBase

Base class for all DSC drivers using a serial port.

Parameters:
  • res_alt (int, optional) – Altitude encoder resolution, defaults to 4000
  • res_az (int, optional) – Azimuth encoder resolution, defaults to 4000
  • reverse_alt (bool, optional) – Reverse altitude axis, defaults to False
  • reverse_az (bool, optional) – Reverse azimuth axis, defaults to False
connect(port, speed=9600)

The driver should connect to the digital setting circles hardware when this method is called.

Parameters:
  • port – Serial device to which digital setting circles is connected.
  • res_alt – Speed for serial connection.
Returns:

True is successful.

Return type:

bool

disconnect()

Disconnect.

Returns:True is successful.
Return type:bool
get_encoder_position()

Read the encoders resolution from the digital setting circles hardware.

Returns:(ttuple) The position of the altitude and azimuth encoders.
get_encoder_resolution()

Read the encoders resolution from the digital setting circles hardware.

Returns:(tuple) The resolution of the altitude and azimuth encoders.
name()

Returns the human readable name for this driver.

set_encoder_resolution(res_alt, res_az)

Read the encoders resolution from the digital setting circles hardware.

Parameters:
  • res_alt – Resolution (steps/rev) of altitude encoder.
  • res_alt – Resolution (steps/rev) of azimuth encoder.

alpacadsc.encoders_altaz_daveek module

class alpacadsc.encoders_altaz_daveek.EncodersDaveEk(res_alt=4000, res_az=4000, reverse_alt=False, reverse_az=False)

Bases: alpacadsc.baseencoders_serial.EncodersSerial

Parameters:
  • res_alt (int, optional) – Altitude encoder resolution, defaults to 4000
  • res_az (int, optional) – Azimuth encoder resolution, defaults to 4000
  • reverse_alt (bool, optional) – Reverse altitude axis, defaults to False
  • reverse_az (bool, optional) – Reverse azimuth axis, defaults to False
get_encoder_position()

Read the encoders resolution from the digital setting circles hardware.

Returns:(ttuple) The position of the altitude and azimuth encoders.
get_encoder_resolution()

Read the encoders resolution from the digital setting circles hardware.

Returns:(tuple) The resolution of the altitude and azimuth encoders.
name()

Returns the human readable name for this driver.

set_encoder_resolution(res_alt, res_az)

Read the encoders resolution from the digital setting circles hardware.

Parameters:
  • res_alt – Resolution (steps/rev) of altitude encoder.
  • res_alt – Resolution (steps/rev) of azimuth encoder.

alpacadsc.encoders_altaz_simulator module

class alpacadsc.encoders_altaz_simulator.EncodersAltAzSimulator(res_alt=4000, res_az=4000, *, reverse_alt=False, reverse_az=False)

Bases: alpacadsc.baseencoders.EncodersBase

Parameters:
  • res_alt (int, optional) – Altitude encoder resolution, defaults to 4000
  • res_az (int, optional) – Azimuth encoder resolution, defaults to 4000
  • reverse_alt (bool, optional) – Reverse altitude axis, defaults to False
  • reverse_az (bool, optional) – Reverse azimuth axis, defaults to False
connect(port, speed=9600)

The driver should connect to the digital setting circles hardware when this method is called.

Note: port and speed ignored in this simulator driver.

Parameters:
  • port – Serial device to which digital setting circles is connected.
  • res_alt – Speed for serial connection.
Returns:

(bool) True is successful.

disconnect()

The driver should disconnect to the digital setting circles hardware when this method is called.

get_encoder_position()

Read the encoders resolution from the digital setting circles hardware.

Returns:(ttuple) The position of the altitude and azimuth encoders.
get_encoder_resolution()

Read the encoders resolution from the digital setting circles hardware.

Returns:(ttuple) The resolution of the altitude and azimuth encoders.
name()

Returns the human readable name for this driver.

set_encoder_resolution(res_alt, res_az)

Read the encoders resolution from the digital setting circles hardware.

Parameters:
  • res_alt – Resolution (steps/rev) of altitude encoder.
  • res_alt – Resolution (steps/rev) of azimuth encoder.

alpacadsc.profiles module

class alpacadsc.profiles.Profile(reldir, name=None)

Bases: object

Stores program settings which can be saved persistently. Supports ProfileSection’s which allow a hierarchical namespace for parameters.

Set some defaults for program settings

Parameters:
  • reldir (str) – location relative to top of default config location If None then will be relative to current working directory.
  • name (str) – name of profile config file

Note: reldir = “hfdfocus/” and name = “C8F7.yaml” would create a file <configbasedir>/hfdfocus/C8F7.yaml

add_section(sectionclass)

Add a section to Profile.

Parameters:sectionclass (ProfileSection) – Section to be added.
filename()

Return profile config filename.

Returns:(Path) Profile filename
read()

Read profile config file.

Returns:(bool) Whether or not read succeeded.
write()

Write profile config file.

Returns:(bool) Whether or not write succeeded.
class alpacadsc.profiles.ProfileSection

Bases: object

A ProfileSection is a subtree member of a Profile and contains its own set of key/value pairs. Multiple ProfileSection’s can be added to a Profile to give parameters different namespaces in the Profile.’

get(key, default=None)

Retrieve parameter from ProfileSection by key name. Default value used if key not found in ProfileSection.

Parameters:
  • key (str) – Name of parameter to retrieve
  • default – Optional default value if key not present
Returns:

Parameter value or default value if not present.

alpacadsc.profiles.find_profiles(loc)

Return list of existing profiles in given location loc. The location loc is relative to the base path for config files for the given platform.

Parameters:loc (str) – Directory relative to base config path to search for profiles
Note:Assumes profile configuration files end with ‘.yaml’
Returns:(List[str]) List of profiles found or [] if none available.
alpacadsc.profiles.get_base_config_dir()

Find base path for where to store config files depending on platform.

Returns:(Path) Root path of where config files are stored
Raises:FileNotFoundError – If base path cannot be determined.
alpacadsc.profiles.get_current_profile(loc)

Read current_profile.yaml file to get name of current profile.

Parameters:loc (str) – Directory relative to base config path to search for profiles
Returns:(str) Name of currently active profile or None if none defined.
alpacadsc.profiles.set_current_profile(loc, current_profile_name)

Write current_profile.yaml file with name of current profile.

Parameters:
  • loc (str) – Directory relative to base config path to search for profiles
  • current_profile_name (str) – Name of current active profile - do NOT include a ‘.yaml’ extension on the profile name.
Returns:

(bool) Whether operation was successful or not

alpacadsc.setup_controller module

class alpacadsc.setup_controller.About(*args, **kwargs)

Bases: flask_restx.resource.Resource

Handle rendering the /about endpoint.

get()

Handle “/about” endpoint with info about the driver.

Returns:(str) Rendered Flask template HTML output.
methods = {'GET'}
class alpacadsc.setup_controller.DeviceSetup(*args, **kwargs)

Bases: flask_restx.resource.Resource

Handle device setup page requests.

change_profile_handler()

Handle request to change active profile.

Returns:Rendered output from handling request.
Return type:str
connect_disconnect_handler(form_id)
Parameters:form_id (str) – id of form to be handled - should be ‘connect_driver_form’ or ‘disconnect_driver_form’
Returns:Rendered output from handling request.
Return type:str
encoder_modify_handler(profile)

Handle request to modify profile parameters for encoders.

Returns:Rendered output from handling request.
Return type:str
get()

Handle device setup GET requests.

Returns:(str) Rendered Flask template HTML output.
location_modify_handler(profile)

Handle request to modify profile parameters for location.

Returns:Rendered output from handling request.
Return type:str
methods = {'GET', 'POST'}
new_profile_handler()

Handle request to create a new profile.

Returns:Rendered output from handling request.
Return type:str
post()

Handle device setup POST (form) requests.

Returns:(str) Rendered Flask template HTML output.

Multiple forms on the device setup pages come to this endpoint. The source is differentiated by a hidden variable “form_id” contained in each form. This value is used to route the response to the appropriate form data handler.

selected_profile_handler()

Handle selection of new active profile.

Returns:Rendered output from handling request.
Return type:str
unknown_form_handler()

Handle rendering output when unknown form_id is received.

Returns:Rendered output from handling request.
Return type:str
class alpacadsc.setup_controller.GlobalSetup(*args, **kwargs)

Bases: flask_restx.resource.Resource

Handle /setup GET request.

get()

Handle get global setup requests.

This returns a info page on the driver.

Returns:(str) Rendered template output for /setup endpoint.
methods = {'GET'}
class alpacadsc.setup_controller.MonitorEncoders(*args, **kwargs)

Bases: flask_restx.resource.Resource

Handle rednering the /encoders endpoint.

get()

Handle reading encoders positions requests (/encoders endpoint).

Returns:(str) Rendered Flask template HTML output.
methods = {'GET'}
alpacadsc.setup_controller.render_response(template, **kwargs)

alpacadsc.startservice module

alpacadsc.startservice.create_app(port=8000)

Create Flask app object.

Parameters:port (int) – TCP port for service to use.
Returns:Flask app object
Return type:Flask()
alpacadsc.startservice.main()
alpacadsc.startservice.parse_command_line()
alpacadsc.startservice.redirect_root()

Redirect root to setup page for convenience to user

alpacadsc.startservice.run_app(args)

Module contents