Skip to content

Commit

Permalink
Better handling of "missed ptr change time"
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Easterbrook <jim@jim-easterbrook.me.uk>
  • Loading branch information
jim-easterbrook committed Sep 10, 2018
1 parent 779ece9 commit ad0d264
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/pywws/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
__version__ = '18.9.0'
_release = '1630'
_commit = '7689ef9'
_release = '1631'
_commit = '779ece9'
10 changes: 7 additions & 3 deletions src/pywws/weatherstation.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,17 +626,21 @@ def live_data(self, logged_only=False):
'live_data lost log sync %g', ptr_time - next_log)
self._station_clock.invalidate()
else:
logger.warning('missed ptr change time')
logger.info('missed ptr change time')
if read_period > new_data['delay']:
read_period = new_data['delay']
logger.warning('reset read period %d', read_period)
log_interval = float(read_period * 60)
result = dict(new_data)
next_log = self._station_clock.before(ptr_time + self.margin)
if next_log:
result = dict(new_data)
result['idx'] = datetime.utcfromtimestamp(int(next_log))
yield result, old_ptr, True
next_log += log_interval
else:
# use best guess of logging time
result['idx'] = datetime.utcfromtimestamp(
int(ptr_time - (self.avoid / 2)))
yield result, old_ptr, True
old_ptr = new_ptr
old_data['delay'] = 0
data_time = 0
Expand Down

0 comments on commit ad0d264

Please sign in to comment.