Skip to content

Commit

Permalink
Fetch logged data before live data loop
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 18, 2018
1 parent 7f2fa93 commit c044edd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 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 = '1634'
_commit = 'bbcc543'
_release = '1635'
_commit = '7f2fa93'
5 changes: 4 additions & 1 deletion src/pywws/livelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ def live_log(data_dir):
datalogger = pywws.logdata.DataLogger(context)
# create a RegularTasks object
tasks = pywws.regulartasks.RegularTasks(context)
# get live data
try:
# fetch and process any new logged data
datalogger.log_data()
pywws.process.process_data(context)
# get live data
for data, logged in datalogger.live_data(
logged_only=(not tasks.has_live_tasks())):
if logged:
Expand Down
6 changes: 3 additions & 3 deletions src/pywws/weatherstation.py
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,7 @@ def __init__(self, context=None):
'solar', self.status, 60, self.avoid)
else:
self._solar_clock = None
self.last_status = {}
# check ws_type
if self.ws_type not in ('1080', '3080'):
if self.get_fixed_block(['lux_wm2_coeff']) == 0.0:
Expand Down Expand Up @@ -525,7 +526,6 @@ def live_data(self, logged_only=False):
next_log = self._station_clock.before(last_log + log_interval)
ptr_time = 0
data_time = 0
last_status = {}
not_logging = False
while True:
# sleep until just before next reading is due
Expand Down Expand Up @@ -560,9 +560,9 @@ def live_data(self, logged_only=False):
for key in ('hum_in', 'temp_in', 'abs_pressure'):
old_data[key] = new_data[key]
# log any change of status
if new_data['status'] != last_status:
if new_data['status'] != self.last_status:
logger.warning('status %s', str(new_data['status']))
last_status = new_data['status']
self.last_status = new_data['status']
if (new_data['status']['lost_connection'] and not
old_data['status']['lost_connection']):
# 'lost connection' decision can happen at any time
Expand Down

0 comments on commit c044edd

Please sign in to comment.