Skip to content

Commit

Permalink
Parking cleanups (#590)
Browse files Browse the repository at this point in the history
* Cleanup to `parked` state to make it easier to understand
* Ctrl-c while pocs_shell is running will finish loop through state
machine rather than call park directly on the mount. This allows for
housekeeping (including uploading) of observations even when machine
is manually killed.
  • Loading branch information
wtgee authored Sep 15, 2018
1 parent aa226be commit abc8455
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
9 changes: 6 additions & 3 deletions bin/pocs_shell
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,12 @@ Hardware names: {} (or all for all hardware)'''.format(
try:
self.pocs.run()
except KeyboardInterrupt:
print_warning('POCS interrupted, skipping states and parking')
self.pocs.observatory.mount.home_and_park()
self._running = False
print_warning('POCS interrupted, parking')
if self.pocs.state not in ['sleeping', 'housekeeping', 'parked', 'parking']:
self.pocs.park()
else:
self.pocs.observatory.mount.home_and_park()
self._obs_run_retries = 0 # Don't retry
finally:
print_info('POCS stopped.')
else:
Expand Down
37 changes: 17 additions & 20 deletions pocs/state/states/default/parked.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
def on_enter(event_data):
""" """
pocs = event_data.model
pocs.say("I'm parked now. Phew.")
pocs.say("I'm parked now.")

has_valid_observations = pocs.observatory.scheduler.has_valid_observations

if has_valid_observations:
if pocs.is_safe():
if pocs.should_retry is False or pocs.run_once is True:
pocs.say("Done retrying for this run, going to clean up and shut down!")
pocs.next_state = 'housekeeping'
else: # This branch will only happen if there is an error causing a shutdown
if pocs.run_once is True:
pocs.say("Done running loop, going to clean up and sleep!")
pocs.next_state = 'housekeeping'
elif pocs.should_retry is False:
pocs.say("Done with retrying loop, going to clean up and sleep!")
pocs.next_state = 'housekeeping'
else:
if pocs.observatory.scheduler.has_valid_observations:
if pocs.is_safe():
pocs.say("Things look okay for now. I'm going to try again.")
pocs.next_state = 'ready'
else: # Normal end of night
pocs.say("Cleaning up for the night!")
pocs.next_state = 'housekeeping'
else:
pocs.say("No observations found.")
# TODO Should check if we are close to morning and if so do some morning
# calibration frames rather than just waiting for 30 minutes then shutting down.
if pocs.run_once is False:
else: # Normal end of night
pocs.say("Cleaning up for the night!")
pocs.next_state = 'housekeeping'
else:
pocs.say("No observations found.")
# TODO Should check if we are close to morning and if so do some morning
# calibration frames rather than just waiting for 30 minutes then shutting down.
pocs.say("Going to stay parked for half an hour then will try again.")

while True:
Expand All @@ -40,6 +40,3 @@ def on_enter(event_data):
break
else:
pocs.say("Seems to be bad weather. I'll wait another 30 minutes.")
else:
pocs.say("Only wanted to run once so cleaning up!")
pocs.next_state = 'housekeeping'

0 comments on commit abc8455

Please sign in to comment.