Fix TBR logging

This commit is contained in:
TebbeUbben 2019-01-19 15:15:56 +01:00
parent b5daa8f297
commit 7724092843

View file

@ -16,6 +16,7 @@ import org.slf4j.LoggerFactory;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.TimeZone; import java.util.TimeZone;
@ -995,7 +996,6 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
for (HistoryEvent historyEvent : historyEvents) for (HistoryEvent historyEvent : historyEvents)
if (!processHistoryEvent(serial, historyEvent)) break; if (!processHistoryEvent(serial, historyEvent)) break;
Collections.reverse(temporaryBasals); Collections.reverse(temporaryBasals);
for (TemporaryBasal temporaryBasal : temporaryBasals) TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal);
for (InsightPumpID pumpID : pumpStartedEvents) { for (InsightPumpID pumpID : pumpStartedEvents) {
long tbrStart = MainApp.getDbHelper().getPumpStoppedEvent(pumpID.pumpSerial, pumpID.timestamp).timestamp + 10000; long tbrStart = MainApp.getDbHelper().getPumpStoppedEvent(pumpID.pumpSerial, pumpID.timestamp).timestamp + 10000;
TemporaryBasal temporaryBasal = new TemporaryBasal(); TemporaryBasal temporaryBasal = new TemporaryBasal();
@ -1005,10 +1005,12 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
temporaryBasal.pumpId = pumpID.id; temporaryBasal.pumpId = pumpID.id;
temporaryBasal.percentRate = 0; temporaryBasal.percentRate = 0;
temporaryBasal.isAbsolute = false; temporaryBasal.isAbsolute = false;
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal); temporaryBasals.add(temporaryBasal);
} }
temporaryBasals = null;
pumpStartedEvents = null; pumpStartedEvents = null;
Collections.sort(temporaryBasals, (o1, o2) -> (int) (o1.date - o2.date));
for (TemporaryBasal temporaryBasal : temporaryBasals) TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal);
temporaryBasals = null;
if (historyEvents.size() > 0) { if (historyEvents.size() > 0) {
InsightHistoryOffset historyOffset = new InsightHistoryOffset(); InsightHistoryOffset historyOffset = new InsightHistoryOffset();
historyOffset.pumpSerial = serial; historyOffset.pumpSerial = serial;