move rest of PumpInterface to TreatmentInterface
This commit is contained in:
parent
52177cead1
commit
d641b0edd9
12 changed files with 85 additions and 141 deletions
|
@ -30,8 +30,6 @@ public interface PumpInterface {
|
|||
void refreshDataFromPump(String reason);
|
||||
|
||||
double getBaseBasalRate(); // base basal rate, not temp basal
|
||||
double getTempBasalAbsoluteRate();
|
||||
double getTempBasalRemainingMinutes();
|
||||
|
||||
PumpEnactResult deliverTreatment(InsulinInterface insulinType, Double insulin, Integer carbs, Context context);
|
||||
void stopBolusDelivering();
|
||||
|
|
|
@ -27,9 +27,11 @@ public interface TreatmentsInterface {
|
|||
List<Treatment> getTreatments5MinBack(long time);
|
||||
|
||||
boolean isTempBasalInProgress();
|
||||
boolean isExtendedBoluslInProgress();
|
||||
|
||||
TempBasal getTempBasal (long time);
|
||||
double getTempBasalAbsoluteRate();
|
||||
double getTempBasalRemainingMinutes();
|
||||
|
||||
boolean isExtendedBoluslInProgress();
|
||||
TempBasal getExtendedBolus (long time);
|
||||
|
||||
long oldestDataAvaialable();
|
||||
|
|
|
@ -414,18 +414,12 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
|
||||
@Override
|
||||
public double getTempBasalAbsoluteRate() {
|
||||
if (activePump != null)
|
||||
return activePump.getTempBasalAbsoluteRate();
|
||||
else
|
||||
return 0d;
|
||||
return activeTreatments.getTempBasalAbsoluteRate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTempBasalRemainingMinutes() {
|
||||
if (activePump != null)
|
||||
return activePump.getTempBasalRemainingMinutes();
|
||||
else
|
||||
return 0d;
|
||||
return activeTreatments.getTempBasalRemainingMinutes();
|
||||
}
|
||||
|
||||
public PumpEnactResult deliverTreatmentFromBolusWizard(InsulinInterface insulinType, Context context, Double insulin, Integer carbs, Double glucose, String glucoseType, int carbTime, JSONObject boluscalc) {
|
||||
|
|
|
@ -228,8 +228,8 @@ public class DetermineBasalAdapterAMAJS {
|
|||
|
||||
mCurrentTemp = new V8Object(mV8rt);
|
||||
mCurrentTemp.add("temp", "absolute");
|
||||
mCurrentTemp.add("duration", pump.getTempBasalRemainingMinutes());
|
||||
mCurrentTemp.add("rate", pump.getTempBasalAbsoluteRate());
|
||||
mCurrentTemp.add("duration", MainApp.getConfigBuilder().getTempBasalRemainingMinutes());
|
||||
mCurrentTemp.add("rate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate());
|
||||
|
||||
// as we have non default temps longer than 30 mintues
|
||||
TempBasal tempBasal = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
|
||||
|
|
|
@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory;
|
|||
import java.io.IOException;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.data.MealData;
|
||||
|
@ -241,8 +242,8 @@ public class DetermineBasalAdapterMAJS {
|
|||
mProfile.add("sens", NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()).doubleValue(), units));
|
||||
|
||||
mProfile.add("current_basal", pump.getBaseBasalRate());
|
||||
mCurrentTemp.add("duration", pump.getTempBasalRemainingMinutes());
|
||||
mCurrentTemp.add("rate", pump.getTempBasalAbsoluteRate());
|
||||
mCurrentTemp.add("duration", MainApp.getConfigBuilder().getTempBasalRemainingMinutes());
|
||||
mCurrentTemp.add("rate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate());
|
||||
|
||||
mIobData.add("iob", iobData.iob); //netIob
|
||||
mIobData.add("activity", iobData.activity); //netActivity
|
||||
|
|
|
@ -303,34 +303,6 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
return getDanaRPump().currentBasal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTempBasalAbsoluteRate() {
|
||||
TempBasal tb = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
|
||||
if (tb != null) {
|
||||
if (tb.isAbsolute) {
|
||||
return tb.absolute;
|
||||
} else {
|
||||
Double baseRate = getBaseBasalRate();
|
||||
Double tempRate = baseRate * (tb.percent / 100d);
|
||||
return tempRate;
|
||||
}
|
||||
}
|
||||
TempBasal eb = MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime());
|
||||
if (eb != null && useExtendedBoluses) {
|
||||
return getBaseBasalRate() + eb.absolute;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTempBasalRemainingMinutes() {
|
||||
if (MainApp.getConfigBuilder().isTempBasalInProgress())
|
||||
return MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).getPlannedRemainingMinutes();
|
||||
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress() && useExtendedBoluses)
|
||||
return MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()).getPlannedRemainingMinutes();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public TempBasal getTempBasal(long time) {
|
||||
TempBasal temp = MainApp.getConfigBuilder().getTempBasal(time);
|
||||
if (temp != null) return temp;
|
||||
|
@ -439,9 +411,9 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
if (MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).percent == percentRate) {
|
||||
result.success = true;
|
||||
result.percent = percentRate;
|
||||
result.absolute = getTempBasalAbsoluteRate();
|
||||
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRate();
|
||||
result.enacted = false;
|
||||
result.duration = ((Double) getTempBasalRemainingMinutes()).intValue();
|
||||
result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutes()).intValue();
|
||||
result.isPercent = true;
|
||||
result.isTempCancel = false;
|
||||
if (Config.logPumpActions)
|
||||
|
@ -708,7 +680,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount);
|
||||
TempBasal tb = getTempBasal(new Date().getTime());
|
||||
if (tb != null) {
|
||||
extended.put("TempBasalAbsoluteRate", getTempBasalAbsoluteRate());
|
||||
extended.put("TempBasalAbsoluteRate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate());
|
||||
extended.put("TempBasalStart", tb.timeStart.toLocaleString());
|
||||
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
|
||||
extended.put("IsExtended", tb.isExtended);
|
||||
|
|
|
@ -310,34 +310,6 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
|
|||
return getDanaRPump().currentBasal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTempBasalAbsoluteRate() {
|
||||
TempBasal tb = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
|
||||
if (tb != null) {
|
||||
if (tb.isAbsolute) {
|
||||
return tb.absolute;
|
||||
} else {
|
||||
Double baseRate = getBaseBasalRate();
|
||||
Double tempRate = baseRate * (tb.percent / 100d);
|
||||
return tempRate;
|
||||
}
|
||||
}
|
||||
TempBasal eb = MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime());
|
||||
if (eb != null && useExtendedBoluses) {
|
||||
return getBaseBasalRate() + eb.absolute;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTempBasalRemainingMinutes() {
|
||||
if (MainApp.getConfigBuilder().isTempBasalInProgress())
|
||||
return MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).getPlannedRemainingMinutes();
|
||||
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress() && useExtendedBoluses)
|
||||
return MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()).getPlannedRemainingMinutes();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public TempBasal getTempBasal(long time) {
|
||||
TempBasal temp = MainApp.getConfigBuilder().getTempBasal(time);
|
||||
if (temp != null) return temp;
|
||||
|
@ -446,9 +418,9 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
|
|||
if (MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).percent == percentRate) {
|
||||
result.success = true;
|
||||
result.percent = percentRate;
|
||||
result.absolute = getTempBasalAbsoluteRate();
|
||||
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRate();
|
||||
result.enacted = false;
|
||||
result.duration = ((Double) getTempBasalRemainingMinutes()).intValue();
|
||||
result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutes()).intValue();
|
||||
result.isPercent = true;
|
||||
result.isTempCancel = false;
|
||||
if (Config.logPumpActions)
|
||||
|
@ -715,7 +687,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
|
|||
// extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount);
|
||||
TempBasal tb = getTempBasal(new Date().getTime());
|
||||
if (tb != null) {
|
||||
extended.put("TempBasalAbsoluteRate", getTempBasalAbsoluteRate());
|
||||
extended.put("TempBasalAbsoluteRate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate());
|
||||
extended.put("TempBasalStart", tb.timeStart.toLocaleString());
|
||||
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
|
||||
extended.put("IsExtended", tb.isExtended);
|
||||
|
|
|
@ -286,24 +286,6 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, ConstraintsInte
|
|||
return getDanaRPump().currentBasal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTempBasalAbsoluteRate() {
|
||||
TempBasal tb = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
|
||||
if (tb != null) {
|
||||
Double baseRate = getBaseBasalRate();
|
||||
Double tempRate = baseRate * (tb.percent / 100d);
|
||||
return tempRate;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTempBasalRemainingMinutes() {
|
||||
if (MainApp.getConfigBuilder().isTempBasalInProgress())
|
||||
return MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).getPlannedRemainingMinutes();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult deliverTreatment(InsulinInterface insulinType, Double insulin, Integer carbs, Context context) {
|
||||
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
||||
|
@ -386,9 +368,9 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, ConstraintsInte
|
|||
if (MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).percent == percentRate) {
|
||||
result.success = true;
|
||||
result.percent = percentRate;
|
||||
result.absolute = getTempBasalAbsoluteRate();
|
||||
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRate();
|
||||
result.enacted = false;
|
||||
result.duration = ((Double) getTempBasalRemainingMinutes()).intValue();
|
||||
result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutes()).intValue();
|
||||
result.isPercent = true;
|
||||
result.isTempCancel = false;
|
||||
if (Config.logPumpActions)
|
||||
|
@ -611,7 +593,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, ConstraintsInte
|
|||
extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount);
|
||||
TempBasal tb = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
|
||||
if (tb != null) {
|
||||
extended.put("TempBasalAbsoluteRate", getTempBasalAbsoluteRate());
|
||||
extended.put("TempBasalAbsoluteRate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate());
|
||||
extended.put("TempBasalStart", tb.timeStart.toLocaleString());
|
||||
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
|
||||
extended.put("IsExtended", tb.isExtended);
|
||||
|
|
|
@ -164,16 +164,6 @@ public class MDIPlugin implements PluginBase, PumpInterface {
|
|||
return 0d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTempBasalAbsoluteRate() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTempBasalRemainingMinutes() {
|
||||
return 0d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult deliverTreatment(InsulinInterface insulinType, Double insulin, Integer carbs, Context context) {
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
|
|
|
@ -187,29 +187,6 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
|||
return profile.getBasal(profile.secondsFromMidnight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTempBasalAbsoluteRate() {
|
||||
if (!MainApp.getConfigBuilder().isTempBasalInProgress())
|
||||
return 0;
|
||||
if (MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).isAbsolute) {
|
||||
return MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).absolute;
|
||||
} else {
|
||||
NSProfile profile = ConfigBuilderPlugin.getActiveProfile().getProfile();
|
||||
if (profile == null)
|
||||
return defaultBasalValue;
|
||||
Double baseRate = profile.getBasal(profile.secondsFromMidnight());
|
||||
Double tempRate = baseRate * (MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).percent / 100d);
|
||||
return baseRate + tempRate;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTempBasalRemainingMinutes() {
|
||||
if (!MainApp.getConfigBuilder().isTempBasalInProgress())
|
||||
return 0;
|
||||
return MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).getPlannedRemainingMinutes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult deliverTreatment(InsulinInterface insulinType, Double insulin, Integer carbs, Context context) {
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
|
|
|
@ -29,6 +29,7 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
|
|||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||
|
@ -345,6 +346,36 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTempBasalAbsoluteRate() {
|
||||
PumpInterface pump = MainApp.getConfigBuilder();
|
||||
|
||||
TempBasal tb = getTempBasal(new Date().getTime());
|
||||
if (tb != null) {
|
||||
if (tb.isAbsolute) {
|
||||
return tb.absolute;
|
||||
} else {
|
||||
Double baseRate = pump.getBaseBasalRate();
|
||||
Double tempRate = baseRate * (tb.percent / 100d);
|
||||
return tempRate;
|
||||
}
|
||||
}
|
||||
TempBasal eb = getExtendedBolus(new Date().getTime());
|
||||
if (eb != null && useExtendedBoluses) {
|
||||
return pump.getBaseBasalRate() + eb.absolute;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTempBasalRemainingMinutes() {
|
||||
if (isTempBasalInProgress())
|
||||
return getTempBasal(new Date().getTime()).getPlannedRemainingMinutes();
|
||||
if (isExtendedBoluslInProgress() && useExtendedBoluses)
|
||||
return getExtendedBolus(new Date().getTime()).getPlannedRemainingMinutes();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long oldestDataAvaialable() {
|
||||
long oldestTemp = new Date().getTime();
|
||||
|
|
|
@ -29,6 +29,7 @@ import info.nightscout.androidaps.events.EventTempBasalChange;
|
|||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
import info.nightscout.androidaps.interfaces.InsulinInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||
|
@ -341,6 +342,30 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTempBasalAbsoluteRate() {
|
||||
PumpInterface pump = MainApp.getConfigBuilder();
|
||||
|
||||
TempBasal tb = getTempBasal(new Date().getTime());
|
||||
if (tb != null) {
|
||||
if (tb.isAbsolute) {
|
||||
return tb.absolute;
|
||||
} else {
|
||||
Double baseRate = pump.getBaseBasalRate();
|
||||
Double tempRate = baseRate * (tb.percent / 100d);
|
||||
return tempRate;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTempBasalRemainingMinutes() {
|
||||
if (isTempBasalInProgress())
|
||||
return getTempBasal(new Date().getTime()).getPlannedRemainingMinutes();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long oldestDataAvaialable() {
|
||||
long oldestTemp = new Date().getTime();
|
||||
|
|
Loading…
Reference in a new issue