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 minimal support for domes into POCS. #248

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pocs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ class POCS(PanStateMachine, PanBase):

Attributes:
name (str): Name of PANOPTES unit
next_state (str): The next state for the state machine
observatory (`pocs.observatory.Observatory`): The `~pocs.observatory.Observatory` object

"""
Expand Down Expand Up @@ -223,8 +222,13 @@ def power_down(self):
"Shutting down {}, please be patient and allow for exit.".format(
self.name))

if not self.observatory.close_dome():
self.logger.critical('Unable to close dome!')
Copy link
Member

Choose a reason for hiding this comment

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

This is perhaps one of those places where we need to somehow add email support.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. Perhaps we should extend the idea of the "say" method to include a "yell" method, designed to ask for help.


# Park if needed
if self.state not in ['parking', 'parked', 'sleeping', 'housekeeping']:
# TODO(jamessynge): Figure out how to handle the situation where we have both
# mount and dome, but this code is only checking for a mount.
if self.observatory.mount.is_connected:
if not self.observatory.mount.is_parked:
self.logger.info("Parking mount")
Expand Down Expand Up @@ -295,7 +299,6 @@ def is_safe(self, no_warning=False):
if no_warning is False:
self.logger.warning('Unsafe conditions: {}'.format(is_safe_values))

# Not safe so park unless we are not active
if self.state not in ['sleeping', 'parked', 'parking', 'housekeeping', 'ready']:
self.logger.warning('Safety failed so sending to park')
self.park()
Expand Down
33 changes: 33 additions & 0 deletions pocs/observatory.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ def current_observation(self):
def current_observation(self, new_observation):
self.scheduler.current_observation = new_observation

@property
def has_dome(self):
return self.dome is not None

##########################################################################
# Methods
Expand All @@ -110,6 +113,8 @@ def initialize(self):
"""Initialize the observatory and connected hardware """
self.logger.debug("Initializing mount")
self.mount.initialize()
if self.dome:
self.dome.connect()

def power_down(self):
"""Power down the observatory. Currently does nothing
Expand Down Expand Up @@ -428,6 +433,34 @@ def autofocus_cameras(self, camera_list=None, coarse=False):

return autofocus_events

def open_dome(self):
"""Open the dome, if there is one.

Returns: False if there is a problem opening the dome,
else True if open (or if not exists).
"""
if not self.dome:
return True
if not self.dome.connect():
return False
if not self.dome.is_open:
self.logger.info('Opening dome')
return self.dome.open()

def close_dome(self):
"""Close the dome, if there is one.

Returns: False if there is a problem closing the dome,
else True if closed (or if not exists).
"""
if not self.dome:
return True
if not self.dome.connect():
return False
if not self.dome.is_closed:
self.logger.info('Closed dome')
return self.dome.close()

##########################################################################
# Private Methods
##########################################################################
Expand Down
6 changes: 6 additions & 0 deletions pocs/state/states/default/parking.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,11 @@ def on_enter(event_data):

pocs.next_state = 'parked'

if pocs.observatory.has_dome:
pocs.say('Closing dome')
if not pocs.observatory.close_dome():
self.logger.critical('Unable to close dome!')
pocs.say('Unable to close dome!')

pocs.say("I'm takin' it on home and then parking.")
pocs.observatory.mount.home_and_park()