try to fix cob graph

This commit is contained in:
Milos Kozak 2017-04-30 21:27:40 +02:00
parent 74e43840a6
commit 9ff714ea2d

View file

@ -352,11 +352,22 @@ public class IobCobCalculatorPlugin implements PluginBase {
return iobTotal; return iobTotal;
} }
private static Long findPreviousTimeFromBucketedData(long time) {
for (int index = 0; index < bucketed_data.size(); index++) {
if (bucketed_data.get(index).timeIndex < time)
return bucketed_data.get(index).timeIndex;
}
return null;
}
public static AutosensData getAutosensData(long time) { public static AutosensData getAutosensData(long time) {
long now = new Date().getTime(); long now = new Date().getTime();
if (time > now) if (time > now)
return null; return null;
time = roundUpTime(time); Long previous = findPreviousTimeFromBucketedData(time);
if (previous == null)
return null;
time = roundUpTime(previous);
AutosensData data = autosensDataTable.get(time); AutosensData data = autosensDataTable.get(time);
if (data != null) { if (data != null) {
//log.debug(">>> Cache hit " + data.log(time)); //log.debug(">>> Cache hit " + data.log(time));