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

View file

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

View file

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