more treatments plugin tweaking

This commit is contained in:
Milos Kozak 2017-05-16 09:46:09 +02:00
parent 25110cfea4
commit fd62c572af
7 changed files with 48 additions and 16 deletions

View file

@ -26,12 +26,18 @@ public interface TreatmentsInterface {
List<Treatment> getTreatments(); List<Treatment> getTreatments();
List<Treatment> getTreatments5MinBack(long time); List<Treatment> getTreatments5MinBack(long time);
// real basals on pump
boolean isRealTempBasalInProgress();
TempBasal getRealTempBasal (long time);
void tempBasalStart(TempBasal tempBasal);
void tempBasalStop(long time);
// basal that can be faked by extended boluses
boolean isTempBasalInProgress(); boolean isTempBasalInProgress();
TempBasal getTempBasal (long time); TempBasal getTempBasal (long time);
double getTempBasalAbsoluteRate(); double getTempBasalAbsoluteRate();
double getTempBasalRemainingMinutes(); double getTempBasalRemainingMinutes();
void tempBasalStart(TempBasal tempBasal);
void tempBasalStop(long time);
boolean isExtendedBoluslInProgress(); boolean isExtendedBoluslInProgress();
TempBasal getExtendedBolus (long time); TempBasal getExtendedBolus (long time);

View file

@ -1178,6 +1178,16 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
return activeTreatments.getTreatments5MinBack(time); return activeTreatments.getTreatments5MinBack(time);
} }
@Override
public boolean isRealTempBasalInProgress() {
return activeTreatments.isRealTempBasalInProgress();
}
@Override
public TempBasal getRealTempBasal(long time) {
return activeTreatments.getRealTempBasal(time);
}
@Override @Override
public boolean isTempBasalInProgress() { public boolean isTempBasalInProgress() {
return activeTreatments.isTempBasalInProgress(); return activeTreatments.isTempBasalInProgress();

View file

@ -226,7 +226,7 @@ public class DanaRFragment extends Fragment {
SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d); SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d);
basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(getPlugin().getBaseBasalRate()) + " U/h"); basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(getPlugin().getBaseBasalRate()) + " U/h");
if (MainApp.getConfigBuilder().isTempBasalInProgress()) { if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
tempBasalView.setText(MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).toString()); tempBasalView.setText(MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime()).toString());
} else { } else {
tempBasalView.setText(""); tempBasalView.setText("");
} }

View file

@ -35,6 +35,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.ProfileInterface; import info.nightscout.androidaps.interfaces.ProfileInterface;
import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.androidaps.plugins.Overview.Notification; import info.nightscout.androidaps.plugins.Overview.Notification;
@ -303,14 +304,6 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
return getDanaRPump().currentBasal; return getDanaRPump().currentBasal;
} }
public TempBasal getTempBasal(long time) {
TempBasal temp = MainApp.getConfigBuilder().getTempBasal(time);
if (temp != null) return temp;
if (useExtendedBoluses)
return MainApp.getConfigBuilder().getExtendedBolus(time);
return null;
}
@Override @Override
public PumpEnactResult deliverTreatment(InsulinInterface insulinType, Double insulin, Integer carbs, Context context) { public PumpEnactResult deliverTreatment(InsulinInterface insulinType, Double insulin, Integer carbs, Context context) {
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
@ -678,7 +671,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
extended.put("PumpIOB", getDanaRPump().iob); extended.put("PumpIOB", getDanaRPump().iob);
extended.put("LastBolus", getDanaRPump().lastBolusTime.toLocaleString()); extended.put("LastBolus", getDanaRPump().lastBolusTime.toLocaleString());
extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount); extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount);
TempBasal tb = getTempBasal(new Date().getTime()); TempBasal tb = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
if (tb != null) { if (tb != null) {
extended.put("TempBasalAbsoluteRate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate()); extended.put("TempBasalAbsoluteRate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate());
extended.put("TempBasalStart", tb.timeStart.toLocaleString()); extended.put("TempBasalStart", tb.timeStart.toLocaleString());

View file

@ -225,7 +225,7 @@ public class DanaRKoreanFragment extends Fragment {
SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d); SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d);
basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(danaRKoreanPlugin.getBaseBasalRate()) + " U/h"); basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(danaRKoreanPlugin.getBaseBasalRate()) + " U/h");
if (MainApp.getConfigBuilder().isTempBasalInProgress()) { if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
tempBasalView.setText(MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).toString()); tempBasalView.setText(MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime()).toString());
} else { } else {
tempBasalView.setText(""); tempBasalView.setText("");
} }

View file

@ -312,14 +312,17 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
lastTempBasalsCalculation = total; lastTempBasalsCalculation = total;
} }
public boolean isRealTempBasalInProgress() {
return getRealTempBasal(new Date().getTime()) != null;
}
@Override @Override
public boolean isTempBasalInProgress() { public boolean isTempBasalInProgress() {
return getTempBasal(new Date().getTime()) != null; return getTempBasal(new Date().getTime()) != null;
} }
@Nullable @Nullable
@Override public TempBasal getRealTempBasal(long time) {
public TempBasal getTempBasal(long time) {
checkForExpired(tempBasals); checkForExpired(tempBasals);
for (TempBasal t : tempBasals) { for (TempBasal t : tempBasals) {
if (t.isInProgress(time)) return t; if (t.isInProgress(time)) return t;
@ -327,6 +330,16 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
return null; return null;
} }
@Nullable
@Override
public TempBasal getTempBasal(long time) {
if (isRealTempBasalInProgress())
return getRealTempBasal(time);
if (isExtendedBoluslInProgress() && useExtendedBoluses)
return getExtendedBolus(time);
return null;
}
@Override @Override
public boolean isExtendedBoluslInProgress() { public boolean isExtendedBoluslInProgress() {
return getExtendedBolus(new Date().getTime()) != null; //TODO: crosscheck here return getExtendedBolus(new Date().getTime()) != null; //TODO: crosscheck here
@ -344,7 +357,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
@Override @Override
public void extendedBolusStart(TempBasal extendedBolus) { public void extendedBolusStart(TempBasal extendedBolus) {
MainApp.getDbHelper().create(extendedBolus);
} }
@Override @Override

View file

@ -276,6 +276,16 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
return in5minback; return in5minback;
} }
@Override
public boolean isRealTempBasalInProgress() {
return false;
}
@Override
public TempBasal getRealTempBasal(long time) {
return null;
}
@Override @Override
public boolean isTempBasalInProgress() { public boolean isTempBasalInProgress() {
return getTempBasal(new Date().getTime()) != null; return getTempBasal(new Date().getTime()) != null;