fix cob calculation

This commit is contained in:
Milos Kozak 2018-05-02 22:35:51 +02:00
parent e2f28e0ae4
commit 28430cc757
3 changed files with 5 additions and 1 deletions

View file

@ -417,6 +417,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
if (autosensData != null) {
displayCob = autosensData.cob;
for (Treatment treatment : treatments) {
if (!treatment.isValid) continue;
if (IobCobCalculatorPlugin.roundUpTime(treatment.date) > IobCobCalculatorPlugin.roundUpTime(autosensData.time)
&& treatment.date <= now && treatment.carbs > 0) {
displayCob += treatment.carbs;
@ -424,6 +425,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
}
}
for (Treatment treatment : treatments) {
if (!treatment.isValid) continue;
if (treatment.date > now && treatment.carbs > 0) {
futureCarbs += treatment.carbs;
}

View file

@ -284,6 +284,8 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
long last = 0;
synchronized (treatments) {
for (Treatment t : treatments) {
if (!t.isValid)
continue;
if (t.date > last && t.insulin > 0 && t.isValid && t.date <= now)
last = t.date;
}

View file

@ -465,7 +465,7 @@ public class WatchUpdaterService extends WearableListenerService implements
List<Treatment> treatments = TreatmentsPlugin.getPlugin().getTreatmentsFromHistory();
for (Treatment treatment : treatments) {
if (treatment.date > startTimeWindow) {
if (treatment.isValid && treatment.date > startTimeWindow) {
boluses.add(treatmentMap(treatment.date, treatment.insulin, treatment.carbs, treatment.isSMB, treatment.isValid));
}