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

Parking cleanups #590

Merged
merged 2 commits into from
Sep 15, 2018
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
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')
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps add the TODO here for the behavior you suggested in the PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

Would prefer to move to #592 actually. Can make a note.

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'