more treatments plugin tweaking
This commit is contained in:
parent
25110cfea4
commit
fd62c572af
7 changed files with 48 additions and 16 deletions
|
@ -26,12 +26,18 @@ public interface TreatmentsInterface {
|
|||
List<Treatment> getTreatments();
|
||||
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();
|
||||
TempBasal getTempBasal (long time);
|
||||
double getTempBasalAbsoluteRate();
|
||||
double getTempBasalRemainingMinutes();
|
||||
void tempBasalStart(TempBasal tempBasal);
|
||||
void tempBasalStop(long time);
|
||||
|
||||
boolean isExtendedBoluslInProgress();
|
||||
TempBasal getExtendedBolus (long time);
|
||||
|
|
|
@ -1178,6 +1178,16 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
return activeTreatments.getTreatments5MinBack(time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRealTempBasalInProgress() {
|
||||
return activeTreatments.isRealTempBasalInProgress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TempBasal getRealTempBasal(long time) {
|
||||
return activeTreatments.getRealTempBasal(time);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTempBasalInProgress() {
|
||||
return activeTreatments.isTempBasalInProgress();
|
||||
|
|
|
@ -226,7 +226,7 @@ public class DanaRFragment extends Fragment {
|
|||
SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d);
|
||||
basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(getPlugin().getBaseBasalRate()) + " U/h");
|
||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||
tempBasalView.setText(MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).toString());
|
||||
tempBasalView.setText(MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime()).toString());
|
||||
} else {
|
||||
tempBasalView.setText("");
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
|||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
|
||||
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||
|
@ -303,14 +304,6 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
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
|
||||
public PumpEnactResult deliverTreatment(InsulinInterface insulinType, Double insulin, Integer carbs, Context context) {
|
||||
ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder();
|
||||
|
@ -678,7 +671,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
|
|||
extended.put("PumpIOB", getDanaRPump().iob);
|
||||
extended.put("LastBolus", getDanaRPump().lastBolusTime.toLocaleString());
|
||||
extended.put("LastBolusAmount", getDanaRPump().lastBolusAmount);
|
||||
TempBasal tb = getTempBasal(new Date().getTime());
|
||||
TempBasal tb = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
|
||||
if (tb != null) {
|
||||
extended.put("TempBasalAbsoluteRate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate());
|
||||
extended.put("TempBasalStart", tb.timeStart.toLocaleString());
|
||||
|
|
|
@ -225,7 +225,7 @@ public class DanaRKoreanFragment extends Fragment {
|
|||
SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d);
|
||||
basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(danaRKoreanPlugin.getBaseBasalRate()) + " U/h");
|
||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||
tempBasalView.setText(MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).toString());
|
||||
tempBasalView.setText(MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime()).toString());
|
||||
} else {
|
||||
tempBasalView.setText("");
|
||||
}
|
||||
|
|
|
@ -312,14 +312,17 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
lastTempBasalsCalculation = total;
|
||||
}
|
||||
|
||||
public boolean isRealTempBasalInProgress() {
|
||||
return getRealTempBasal(new Date().getTime()) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTempBasalInProgress() {
|
||||
return getTempBasal(new Date().getTime()) != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TempBasal getTempBasal(long time) {
|
||||
public TempBasal getRealTempBasal(long time) {
|
||||
checkForExpired(tempBasals);
|
||||
for (TempBasal t : tempBasals) {
|
||||
if (t.isInProgress(time)) return t;
|
||||
|
@ -327,6 +330,16 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public TempBasal getTempBasal(long time) {
|
||||
if (isRealTempBasalInProgress())
|
||||
return getRealTempBasal(time);
|
||||
if (isExtendedBoluslInProgress() && useExtendedBoluses)
|
||||
return getExtendedBolus(time);
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExtendedBoluslInProgress() {
|
||||
return getExtendedBolus(new Date().getTime()) != null; //TODO: crosscheck here
|
||||
|
@ -344,7 +357,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
|
||||
@Override
|
||||
public void extendedBolusStart(TempBasal extendedBolus) {
|
||||
|
||||
MainApp.getDbHelper().create(extendedBolus);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -276,6 +276,16 @@ public class TreatmentsFromHistoryPlugin implements PluginBase, TreatmentsInterf
|
|||
return in5minback;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isRealTempBasalInProgress() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TempBasal getRealTempBasal(long time) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTempBasalInProgress() {
|
||||
return getTempBasal(new Date().getTime()) != null;
|
||||
|
|
Loading…
Reference in a new issue