From 7155b9893432d09075b06679b6f23c225ed4f8b5 Mon Sep 17 00:00:00 2001 From: Ziver Koc Date: Mon, 18 Jul 2016 19:57:23 +0200 Subject: [PATCH] Fixed null items for longer sensor intervals --- src/se/hal/util/AggregateDataListSqlResult.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/se/hal/util/AggregateDataListSqlResult.java b/src/se/hal/util/AggregateDataListSqlResult.java index 9895c426..f8775551 100755 --- a/src/se/hal/util/AggregateDataListSqlResult.java +++ b/src/se/hal/util/AggregateDataListSqlResult.java @@ -82,13 +82,15 @@ public class AggregateDataListSqlResult implements SQLResultHandler sensor.getDeviceData().getDataInterval()) { - // Add null data point to list if one or more periods of data is missing before this - if (previousTimestampEnd != -1 && previousTimestampEnd + 1 < timestampStart) { - list.add(new AggregateData(id, previousTimestampEnd + 1, null /*Float.NaN*/, username)); - } + // Add null data point to list if one or more periods of data is missing before this + if (previousTimestampEnd != -1 && sensor.getDeviceData() != null){ + boolean shortInterval = timestampEnd-timestampStart < sensor.getDeviceData().getDataInterval(); + long distance = timestampStart - (previousTimestampEnd + 1); + if (// Only add nulls if the report interval is smaller than the aggregated interval + !shortInterval && distance > 0 || + // Only add nulls if space between aggr is larger than sensor report interval + shortInterval && distance > sensor.getDeviceData().getDataInterval()) + list.add(new AggregateData(id, previousTimestampEnd + 1, null /*Float.NaN*/, username)); } list.add(new AggregateData(id, timestampEnd, (estimatedData/1000f), username)); //add this data point to list