Browse Source

Accumulate delta separately from data timestamp

tags/nilmtools-1.0.3^0
Jim Paris 9 years ago
parent
commit
1988955671
1 changed files with 6 additions and 5 deletions
  1. +6
    -5
      src/insert.py

+ 6
- 5
src/insert.py View File

@@ -132,9 +132,10 @@ def main(argv = None):
data_ts_base = 0
data_ts_inc = 0
data_ts_rate = args.rate
data_ts_delta = 0
def get_data_ts():
if args.delta:
return data_ts_base
return data_ts_base + data_ts_delta
else:
return data_ts_base + rate_to_period(data_ts_rate,
data_ts_inc)
@@ -207,12 +208,12 @@ def main(argv = None):
pass
continue

# If --delta mode, increment data_ts_base by the delta
# from the file.
# If --delta mode, increment data_ts_delta by the
# delta from the file.
if args.delta:
try:
(delta, line) = line.split(None, 1)
data_ts_base += float(delta)
data_ts_delta += float(delta)
except ValueError:
raise ParseError(filename, "can't parse delta")

@@ -247,7 +248,7 @@ def main(argv = None):
timestamp_to_human(clock_ts))
stream.finalize()
data_ts_base = data_ts = clock_ts
data_ts_inc = 0
data_ts_inc = data_ts_delta = 0

# Don't use this clock time anymore until we update it
clock_ts = None


Loading…
Cancel
Save