changeset 400:1137f315209b

use the remainder of times
author Matt Johnston <matt@ucc.asn.au>
date Mon, 16 Jul 2012 21:50:39 +0800
parents 744c3c7eb09d
children 56c32a62b0cd 45d96250387c
files server/ts.py web/log.py
diffstat 2 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/server/ts.py	Mon Jul 16 21:50:24 2012 +0800
+++ b/server/ts.py	Mon Jul 16 21:50:39 2012 +0800
@@ -186,7 +186,7 @@
         try:
             sock = get_socket(config.BTADDR)
         except Exception, e:
-            logging.exception("Error connecting")
+            #logging.exception("Error connecting")
             pass
         next_wake_time = 0
         if sock:
--- 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)