Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a 'dome' attribute to Observatory. #231

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 7 additions & 11 deletions pocs/dome/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,19 @@
import pocs.utils
import pocs.utils.logger as logger_module

# A dome needs a config. We assume that there is at most one dome in the config,
# i.e. we don't support two different dome devices, such as might be the case
# if there are multiple independent actuators, for example slit, rotation and
# vents.


def create_dome_from_config(config):
def create_dome_from_config(config, logger=None):
"""If there is a dome specified in the config, create a driver for it.

A dome needs a config. We assume that there is at most one dome in the config, i.e. we don't
support two different dome devices, such as might be the case if there are multiple
independent actuators, for example slit, rotation and vents. Those would need to be handled
by a single dome class.
by a single dome driver class.
"""
root_logger = logger_module.get_root_logger()
if not logger:
logger = logger_module.get_root_logger()
if 'dome' not in config:
root_logger.debug('No dome in config.')
logger.info('No dome in config.')
return None
dome_config = config['dome']
if 'dome' in config.get('simulator', []):
Expand All @@ -30,10 +26,10 @@ def create_dome_from_config(config):
else:
brand = dome_config.get('brand')
driver = dome_config['driver']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This already made it's way in, but this will fail if dome is in config but driver is not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps that was intended but if so we should catch and warn.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. This is certainly a fatal error in terms of creating the dome instance, and will most likely keep POCS from working as intended. Probably we should just raise an exception.

root_logger.debug('Creating dome: brand={}, driver={}'.format(brand, driver))
logger.debug('Creating dome: brand={}, driver={}'.format(brand, driver))
module = pocs.utils.load_module('pocs.dome.{}'.format(driver))
dome = module.Dome(config=config)
root_logger.debug('Created dome.')
logger.info('Created dome driver: brand={}, driver={}'.format(brand, driver))
return dome


Expand Down
12 changes: 12 additions & 0 deletions pocs/observatory.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from astropy.coordinates import get_sun

from . import PanBase
import pocs.dome
from .images import Image
from .scheduler.constraint import Duration
from .scheduler.constraint import MoonAvoidance
Expand Down Expand Up @@ -49,6 +50,10 @@ def __init__(self, *args, **kwargs):
self._primary_camera = None
self._create_cameras(**kwargs)

# TODO(jamessynge): Discuss with Wilfred the serial port validation behavior
# here compared to that for the mount.
self.dome = pocs.dome.create_dome_from_config(self.config, logger=self.logger)

self.logger.info('\tSetting up scheduler')
self.scheduler = None
self._create_scheduler()
Expand Down Expand Up @@ -111,6 +116,8 @@ def power_down(self):
"""
self.logger.debug("Shutting down observatory")
self.mount.disconnect()
if self.dome:
self.dome.disconnect()

def status(self):
"""Get status information for various parts of the observatory
Expand All @@ -128,6 +135,9 @@ def status(self):
status['mount']['mount_target_ha'] = self.observer.target_hour_angle(
t, self.mount.get_target_coordinates())

if self.dome:
status['dome'] = self.dome.status()

if self.current_observation:
status['observation'] = self.current_observation.status()
status['observation']['field_ha'] = self.observer.target_hour_angle(
Expand Down Expand Up @@ -488,6 +498,8 @@ def _create_mount(self, mount_info=None):
Note:
This does not actually make a serial connection to the mount. To do so,
call the 'mount.connect()' explicitly.
TODO(jamessynge): Discuss this claim with Wilfred. SerialData automatically
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The claim is wrong as you point out and should be updated.

opens the connection, but doesn't start using it.

Args:
mount_info (dict): Configuration items for the mount.
Expand Down