comparison web/log.py @ 94:229b740a607f

use the remainder of times
author Matt Johnston <matt@ucc.asn.au>
date Mon, 16 Jul 2012 21:50:39 +0800
parents 6f4497a448e8
children fd9cfa6829fd
comparison
equal deleted inserted replaced
93:f18fd4257296 94:229b740a607f
156 156
157 def convert_ds18b20_12bit(reading): 157 def convert_ds18b20_12bit(reading):
158 value = struct.unpack('>h', binascii.unhexlify(reading))[0] 158 value = struct.unpack('>h', binascii.unhexlify(reading))[0]
159 return value * 0.0625 159 return value * 0.0625
160 160
161 def time_rem(name, entries):
162 val_ticks = int(entries[name])
163 val_rem = int(entries[name])
164 tick_wake = int(entries['tick_wake'])
165 tick_secs = int(entries['tick_secs'])
166 return val_ticks + float(val_rem) * tick_secs / tick_wake
167
161 def parse(lines): 168 def parse(lines):
162 169
163 debugf = record_debug(lines) 170 debugf = record_debug(lines)
164 171
165 entries = dict(l.split('=', 1) for l in lines) 172 entries = dict(l.split('=', 1) for l in lines)
181 raise Exception("Wrong number of sensors for measurement %d" % n) 188 raise Exception("Wrong number of sensors for measurement %d" % n)
182 # we make an array of values for each sensor 189 # we make an array of values for each sensor
183 for s in xrange(num_sensors): 190 for s in xrange(num_sensors):
184 meas[s].append(vals[s]) 191 meas[s].append(vals[s])
185 192
186 avr_now = float(entries['now']) 193 avr_now = time_rem('now', entries)
187 avr_first_time = float(entries['first_time']) 194 avr_first_time = time_rem('first_time', entries)
195 avr_comms_time = time_rem('comms_time', entries)
188 time_step = float(entries['time_step']) 196 time_step = float(entries['time_step'])
197
198 debugf.write('now %f, comms_time %f, first_time %f, delta %f\n' %
199 (avr_now, avr_comms_time, avr_first_time, avr_now - avr_comms_time))
189 200
190 if 'avrtemp' in entries: 201 if 'avrtemp' in entries:
191 avrtemp = val_scale(int(entries['avrtemp'])) 202 avrtemp = val_scale(int(entries['avrtemp']))
192 sensor_update('avrtemp', [avrtemp], time.time(), 1) 203 sensor_update('avrtemp', [avrtemp], time.time(), 1)
193 204