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;
}
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) {
long now = new Date().getTime();
if (time > now)
return null;
time = roundUpTime(time);
Long previous = findPreviousTimeFromBucketedData(time);
if (previous == null)
return null;
time = roundUpTime(previous);
AutosensData data = autosensDataTable.get(time);
if (data != null) {
//log.debug(">>> Cache hit " + data.log(time));