From ebb3e90587294f8d4714351efe0c0bf372ba4cce Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 4 Jan 2017 22:47:21 +0100 Subject: [PATCH] extract MealData --- .../nightscout/androidaps/data/MealData.java | 10 ++++++ .../interfaces/TreatmentsInterface.java | 4 +-- .../DetermineBasalAdapterAMAJS.java | 4 +-- .../OpenAPSAMA/DetermineBasalResultAMA.java | 31 ------------------- .../plugins/OpenAPSAMA/OpenAPSAMAPlugin.java | 4 +-- .../OpenAPSMA/DetermineBasalAdapterMAJS.java | 4 +-- .../plugins/OpenAPSMA/OpenAPSMAPlugin.java | 4 +-- .../plugins/Treatments/TreatmentsPlugin.java | 7 +---- 8 files changed, 21 insertions(+), 47 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/data/MealData.java diff --git a/app/src/main/java/info/nightscout/androidaps/data/MealData.java b/app/src/main/java/info/nightscout/androidaps/data/MealData.java new file mode 100644 index 0000000000..02db574a54 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/data/MealData.java @@ -0,0 +1,10 @@ +package info.nightscout.androidaps.data; + +/** + * Created by mike on 04.01.2017. + */ +public class MealData { + public double boluses = 0d; + public double carbs = 0d; + public double mealCOB = 0.0d; // TODO: add calculation for AMA +} diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java b/app/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java index 3eef0af344..792db7d1d6 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/TreatmentsInterface.java @@ -2,9 +2,9 @@ package info.nightscout.androidaps.interfaces; import java.util.List; +import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.data.IobTotal; -import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; /** * Created by mike on 14.06.2016. @@ -13,6 +13,6 @@ public interface TreatmentsInterface { void updateTotalIOB(); IobTotal getLastCalculation(); - TreatmentsPlugin.MealData getMealData(); + MealData getMealData(); List getTreatments(); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java index 1f7d9e9254..91f1ce59d5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalAdapterAMAJS.java @@ -14,10 +14,10 @@ import java.io.IOException; import info.nightscout.androidaps.Config; import info.nightscout.androidaps.data.GlucoseStatus; +import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.plugins.Loop.ScriptReader; import info.nightscout.androidaps.data.IobTotal; -import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.client.data.NSProfile; public class DetermineBasalAdapterAMAJS { @@ -246,7 +246,7 @@ public class DetermineBasalAdapterAMAJS { PumpInterface pump, IobTotal iobData, GlucoseStatus glucoseStatus, - TreatmentsPlugin.MealData mealData, + MealData mealData, JSONObject autosensData) { String units = profile.getUnits(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java index 148e529921..7475c55de6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java @@ -53,37 +53,6 @@ public class DetermineBasalResultAMA extends APSResult { result.release(); } - @Override - public void writeToParcel(Parcel dest, int flags) { - super.writeToParcel(dest, flags); - dest.writeString(json.toString()); - dest.writeDouble(eventualBG); - dest.writeDouble(snoozeBG); - dest.writeString(mealAssist); - } - - public final Parcelable.Creator CREATOR = new Parcelable.Creator() { - public DetermineBasalResultAMA createFromParcel(Parcel in) { - return new DetermineBasalResultAMA(in); - } - - public DetermineBasalResultAMA[] newArray(int size) { - return new DetermineBasalResultAMA[size]; - } - }; - - private DetermineBasalResultAMA(Parcel in) { - super(in); - try { - json = new JSONObject(in.readString()); - } catch (JSONException e) { - e.printStackTrace(); - } - eventualBG = in.readDouble(); - snoozeBG = in.readDouble(); - mealAssist = in.readString(); - } - public DetermineBasalResultAMA() { } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java index cc940c03b3..36d989b446 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java @@ -15,6 +15,7 @@ import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.GlucoseStatus; +import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.interfaces.APSInterface; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PumpInterface; @@ -25,7 +26,6 @@ import info.nightscout.androidaps.plugins.Loop.ScriptReader; import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui; -import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.client.data.NSProfile; import info.nightscout.utils.DateUtil; import info.nightscout.utils.Round; @@ -171,7 +171,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface { IobTotal iobTotal = IobTotal.combine(bolusIob, basalIob).round(); - TreatmentsPlugin.MealData mealData = treatments.getMealData(); + MealData mealData = treatments.getMealData(); maxIob = MainApp.getConfigBuilder().applyMaxIOBConstraints(maxIob); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java index 6512754b75..d2dbe0e67e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/DetermineBasalAdapterMAJS.java @@ -15,9 +15,9 @@ import java.io.IOException; import info.nightscout.androidaps.Config; import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; +import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.plugins.Loop.ScriptReader; -import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.client.data.NSProfile; public class DetermineBasalAdapterMAJS { @@ -225,7 +225,7 @@ public class DetermineBasalAdapterMAJS { PumpInterface pump, IobTotal iobData, GlucoseStatus glucoseStatus, - TreatmentsPlugin.MealData mealData) { + MealData mealData) { String units = profile.getUnits(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java index 74d72192b8..4d09b82ec3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java @@ -16,6 +16,7 @@ import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; +import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.interfaces.APSInterface; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PumpInterface; @@ -25,7 +26,6 @@ import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.androidaps.plugins.Loop.ScriptReader; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui; -import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.client.data.NSProfile; import info.nightscout.utils.DateUtil; import info.nightscout.utils.Round; @@ -171,7 +171,7 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface { IobTotal iobTotal = IobTotal.combine(bolusIob, basalIob).round(); - TreatmentsPlugin.MealData mealData = treatments.getMealData(); + MealData mealData = treatments.getMealData(); maxIob = MainApp.getConfigBuilder().applyMaxIOBConstraints(maxIob); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java index d2dc676109..874c19820d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java @@ -16,6 +16,7 @@ import java.util.List; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Iob; +import info.nightscout.androidaps.data.MealData; import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.events.EventTreatmentChange; import info.nightscout.androidaps.interfaces.PluginBase; @@ -138,12 +139,6 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface { lastCalculation = total; } - public class MealData { - public double boluses = 0d; - public double carbs = 0d; - public double mealCOB = 0.0d; // TODO: add calculation for AMA - } - @Override public MealData getMealData() { MealData result = new MealData();