Skip to content

Commit

Permalink
Add minimal support for domes into POCS. (#248)
Browse files Browse the repository at this point in the history
* Add minimal support for domes into POCS.
* Close dome when entering the parking state and when powering down.
* Tests TBS.
  • Loading branch information
jamessynge authored Dec 25, 2017
1 parent e390b99 commit f53c96e
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 2 deletions.
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!')

# 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()

0 comments on commit f53c96e

Please sign in to comment.