Skip to content

Commit

Permalink
POCS wait status
Browse files Browse the repository at this point in the history
* The `pocs.wait` method calls `status` so there are updates.
* Slightly longer wait delay if we know it is not dark. This could be improved.
  • Loading branch information
wtgee committed May 14, 2024
1 parent 68719cf commit e9db4e9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
10 changes: 6 additions & 4 deletions src/panoptes/pocs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,14 +583,16 @@ def wait(self, delay=None):
if delay is None: # pragma: no cover
delay = self.get_config('wait_delay', default=2.5)

sleep_timer = CountdownTimer(delay, name='POCSWait')
self.logger.info(f'Starting a wait timer of {delay} seconds')
timer_name = 'POCSWait'
sleep_timer = CountdownTimer(delay, name=timer_name)
self.logger.info(f'Starting {timer_name} timer of {delay} seconds')
while not sleep_timer.expired() and not self.interrupted:
self.logger.debug(f'Wait timer: {sleep_timer.time_left():.02f} / {delay:.02f}')
self.logger.debug(f'POCS status: {self.status}')
self.logger.debug(f'{timer_name}: {sleep_timer.time_left():.02f} / {delay:.02f}')
sleep_timer.sleep(max_sleep=30)

is_expired = sleep_timer.expired()
self.logger.debug(f'Leaving wait timer: expired={is_expired}')
self.logger.debug(f'Leaving wait timer: {is_expired}')
return is_expired

################################################################################################
Expand Down
8 changes: 6 additions & 2 deletions src/panoptes/pocs/state/states/default/ready.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ def on_enter(event_data):
pocs.next_state = 'scheduling'

# Wait until it's safe to proceed.
wait_delay = pocs.get_config('wait_delay', default=180) # seconds

# TODO separate check for disk space, which will never break this loop.
disk_space_checks = ['free_space_root', 'free_space_images']
while pocs.is_safe(park_if_not_safe=False, ignore=disk_space_checks) is False:
if pocs.is_dark() is False:
# TODO figure out how long until sunset and wait until then.
wait_delay = 10 * 60 # 10 minutes
else:
wait_delay = pocs.get_config('wait_delay', default=180) # seconds

Check warning on line 23 in src/panoptes/pocs/state/states/default/ready.py

View check run for this annotation

Codecov / codecov/patch

src/panoptes/pocs/state/states/default/ready.py#L23

Added line #L23 was not covered by tests

pocs.wait(delay=wait_delay)

pocs.say("Ok, I'm all set up and ready to go!")

0 comments on commit e9db4e9

Please sign in to comment.