diff web/log.py @ 400:1137f315209b

use the remainder of times
author Matt Johnston <matt@ucc.asn.au>
date Mon, 16 Jul 2012 21:50:39 +0800
parents 2cd246ea92c6
children fd9cfa6829fd
line wrap: on
line diff
--- a/web/log.py	Mon Jul 16 21:50:24 2012 +0800
+++ b/web/log.py	Mon Jul 16 21:50:39 2012 +0800
@@ -158,6 +158,13 @@
     value = struct.unpack('>h', binascii.unhexlify(reading))[0]
     return value * 0.0625
 
+def time_rem(name, entries):
+    val_ticks = int(entries[name])
+    val_rem = int(entries[name])
+    tick_wake = int(entries['tick_wake'])
+    tick_secs = int(entries['tick_secs'])
+    return val_ticks + float(val_rem) * tick_secs / tick_wake
+
 def parse(lines):
    
     debugf = record_debug(lines)
@@ -183,10 +190,14 @@
         for s in xrange(num_sensors):
             meas[s].append(vals[s])
 
-    avr_now = float(entries['now'])
-    avr_first_time = float(entries['first_time'])
+    avr_now = time_rem('now', entries)
+    avr_first_time = time_rem('first_time', entries)
+    avr_comms_time = time_rem('comms_time', entries)
     time_step = float(entries['time_step'])
 
+    debugf.write('now %f, comms_time %f, first_time %f, delta %f\n' %
+            (avr_now, avr_comms_time, avr_first_time, avr_now - avr_comms_time))
+
     if 'avrtemp' in entries:
         avrtemp = val_scale(int(entries['avrtemp']))
         sensor_update('avrtemp', [avrtemp], time.time(), 1)