rename treatment interfaace functions to be more clear

This commit is contained in:
Milos Kozak 2017-05-26 15:33:42 +02:00
parent 0371e97391
commit 4dff0e3a56
27 changed files with 192 additions and 195 deletions

View file

@ -25,31 +25,31 @@ public interface TreatmentsInterface {
MealData getMealData();
List<Treatment> getTreatments();
List<Treatment> getTreatments5MinBack(long time);
List<Treatment> getTreatmentsFromHistory();
List<Treatment> getTreatments5MinBackFromHistory(long time);
// real basals on pump
boolean isRealTempBasalInProgress();
TemporaryBasal getRealTempBasal (long time);
// real basals (not faked by extended bolus)
boolean isInHistoryRealTempBasalInProgress();
TemporaryBasal getRealTempBasalFromHistory(long time);
void tempBasalStart(TemporaryBasal tempBasal);
void tempBasalStop(long time);
void addToHistoryTempBasalStart(TemporaryBasal tempBasal);
void addToHistoryTempBasalStop(long time);
// basal that can be faked by extended boluses
boolean isTempBasalInProgress();
TemporaryBasal getTempBasal (long time);
double getTempBasalAbsoluteRate();
double getTempBasalRemainingMinutes();
OverlappingIntervals<TemporaryBasal> getTemporaryBasals();
TemporaryBasal getTempBasalFromHistory(long time);
double getTempBasalAbsoluteRateHistory();
double getTempBasalRemainingMinutesFromHistory();
OverlappingIntervals<TemporaryBasal> getTemporaryBasalsFromHistory();
boolean isExtendedBoluslInProgress();
ExtendedBolus getExtendedBolus (long time);
void extendedBolusStart(ExtendedBolus extendedBolus);
void extendedBolusStop(long time);
OverlappingIntervals<ExtendedBolus> getExtendedBoluses();
boolean isInHistoryExtendedBoluslInProgress();
ExtendedBolus getExtendedBolusFromHistory(long time);
void addToHistoryExtendedBolusStart(ExtendedBolus extendedBolus);
void addToHistoryExtendedBolusStop(long time);
OverlappingIntervals<ExtendedBolus> getExtendedBolusesFromHistory();
TempTarget getTempTarget (long time);
OverlappingIntervals<TempTarget> getTempTargets();
TempTarget getTempTargetFromHistory(long time);
OverlappingIntervals<TempTarget> getTempTargetsFromHistory();
long oldestDataAvaialable();

View file

@ -133,16 +133,16 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
profileSwitch.setVisibility(View.GONE);
else
profileSwitch.setVisibility(View.VISIBLE);
if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || MainApp.getConfigBuilder().isExtendedBoluslInProgress())
if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress())
extendedBolus.setVisibility(View.GONE);
else {
extendedBolus.setVisibility(View.VISIBLE);
}
if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().isExtendedBoluslInProgress())
if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress())
extendedBolusCancel.setVisibility(View.GONE);
else {
extendedBolusCancel.setVisibility(View.VISIBLE);
ExtendedBolus running = MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime());
ExtendedBolus running = MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime());
extendedBolusCancel.setText(MainApp.instance().getString(R.string.cancel) + " " + running.toString());
}
if (!MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || MainApp.getConfigBuilder().isTempBasalInProgress())
@ -186,7 +186,7 @@ public class ActionsFragment extends Fragment implements View.OnClickListener {
newExtendedDialog.show(manager, "NewExtendedDialog");
break;
case R.id.actions_extendedbolus_cancel:
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress()) {
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
sHandler.post(new Runnable() {
@Override
public void run() {

View file

@ -638,10 +638,10 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
if (Config.logCongigBuilderActions)
log.debug("applyAPSRequest: Basal set correctly");
}
} else if (isTempBasalInProgress() && Math.abs(request.rate - getTempBasalAbsoluteRate()) < 0.05) {
} else if (isTempBasalInProgress() && Math.abs(request.rate - getTempBasalAbsoluteRateHistory()) < 0.05) {
result = new PumpEnactResult();
result.absolute = getTempBasalAbsoluteRate();
result.duration = getTempBasal(new Date().getTime()).getPlannedRemainingMinutes();
result.absolute = getTempBasalAbsoluteRateHistory();
result.duration = getTempBasalFromHistory(new Date().getTime()).getPlannedRemainingMinutes();
result.enacted = false;
result.comment = "Temp basal set correctly";
result.success = true;
@ -852,23 +852,23 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
}
@Override
public List<Treatment> getTreatments() {
return activeTreatments.getTreatments();
public List<Treatment> getTreatmentsFromHistory() {
return activeTreatments.getTreatmentsFromHistory();
}
@Override
public List<Treatment> getTreatments5MinBack(long time) {
return activeTreatments.getTreatments5MinBack(time);
public List<Treatment> getTreatments5MinBackFromHistory(long time) {
return activeTreatments.getTreatments5MinBackFromHistory(time);
}
@Override
public boolean isRealTempBasalInProgress() {
return activeTreatments.isRealTempBasalInProgress();
public boolean isInHistoryRealTempBasalInProgress() {
return activeTreatments.isInHistoryRealTempBasalInProgress();
}
@Override
public TemporaryBasal getRealTempBasal(long time) {
return activeTreatments.getRealTempBasal(time);
public TemporaryBasal getRealTempBasalFromHistory(long time) {
return activeTreatments.getRealTempBasalFromHistory(time);
}
@Override
@ -877,68 +877,68 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
}
@Override
public TemporaryBasal getTempBasal(long time) {
return activeTreatments.getTempBasal(time);
public TemporaryBasal getTempBasalFromHistory(long time) {
return activeTreatments.getTempBasalFromHistory(time);
}
@Override
public double getTempBasalAbsoluteRate() {
return activeTreatments.getTempBasalAbsoluteRate();
public double getTempBasalAbsoluteRateHistory() {
return activeTreatments.getTempBasalAbsoluteRateHistory();
}
@Override
public double getTempBasalRemainingMinutes() {
return activeTreatments.getTempBasalRemainingMinutes();
public double getTempBasalRemainingMinutesFromHistory() {
return activeTreatments.getTempBasalRemainingMinutesFromHistory();
}
@Override
public OverlappingIntervals<TemporaryBasal> getTemporaryBasals() {
return activeTreatments.getTemporaryBasals();
public OverlappingIntervals<TemporaryBasal> getTemporaryBasalsFromHistory() {
return activeTreatments.getTemporaryBasalsFromHistory();
}
@Override
public void tempBasalStart(TemporaryBasal tempBasal) {
activeTreatments.tempBasalStart(tempBasal);
public void addToHistoryTempBasalStart(TemporaryBasal tempBasal) {
activeTreatments.addToHistoryTempBasalStart(tempBasal);
}
@Override
public void tempBasalStop(long time) {
activeTreatments.tempBasalStop(time);
public void addToHistoryTempBasalStop(long time) {
activeTreatments.addToHistoryTempBasalStop(time);
}
@Override
public boolean isExtendedBoluslInProgress() {
return activeTreatments.isExtendedBoluslInProgress();
public boolean isInHistoryExtendedBoluslInProgress() {
return activeTreatments.isInHistoryExtendedBoluslInProgress();
}
@Override
public ExtendedBolus getExtendedBolus(long time) {
return activeTreatments.getExtendedBolus(time);
public ExtendedBolus getExtendedBolusFromHistory(long time) {
return activeTreatments.getExtendedBolusFromHistory(time);
}
@Override
public void extendedBolusStart(ExtendedBolus extendedBolus) {
activeTreatments.extendedBolusStart(extendedBolus);
public void addToHistoryExtendedBolusStart(ExtendedBolus extendedBolus) {
activeTreatments.addToHistoryExtendedBolusStart(extendedBolus);
}
@Override
public void extendedBolusStop(long time) {
activeTreatments.extendedBolusStop(time);
public void addToHistoryExtendedBolusStop(long time) {
activeTreatments.addToHistoryExtendedBolusStop(time);
}
@Override
public OverlappingIntervals<ExtendedBolus> getExtendedBoluses() {
return activeTreatments.getExtendedBoluses();
public OverlappingIntervals<ExtendedBolus> getExtendedBolusesFromHistory() {
return activeTreatments.getExtendedBolusesFromHistory();
}
@Override
public TempTarget getTempTarget(long time) {
return activeTreatments.getTempTarget(time);
public TempTarget getTempTargetFromHistory(long time) {
return activeTreatments.getTempTargetFromHistory(time);
}
@Override
public OverlappingIntervals<TempTarget> getTempTargets() {
return activeTreatments.getTempTargets();
public OverlappingIntervals<TempTarget> getTempTargetsFromHistory() {
return activeTreatments.getTempTargetsFromHistory();
}
@Override

View file

@ -279,7 +279,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
double bgi = -iob.activity * sens * 5;
double deviation = delta - bgi;
List<Treatment> recentTreatments = MainApp.getConfigBuilder().getTreatments5MinBack(bgTime);
List<Treatment> recentTreatments = MainApp.getConfigBuilder().getTreatments5MinBackFromHistory(bgTime);
for (int ir = 0; ir < recentTreatments.size(); ir++) {
autosensData.carbsFromBolus += recentTreatments.get(ir).carbs;
}

View file

@ -228,11 +228,11 @@ public class DetermineBasalAdapterAMAJS {
mCurrentTemp = new V8Object(mV8rt);
mCurrentTemp.add("temp", "absolute");
mCurrentTemp.add("duration", MainApp.getConfigBuilder().getTempBasalRemainingMinutes());
mCurrentTemp.add("rate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate());
mCurrentTemp.add("duration", MainApp.getConfigBuilder().getTempBasalRemainingMinutesFromHistory());
mCurrentTemp.add("rate", MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory());
// as we have non default temps longer than 30 mintues
TemporaryBasal tempBasal = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
TemporaryBasal tempBasal = MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime());
if(tempBasal != null){
mCurrentTemp.add("minutesrunning", tempBasal.getRealDuration());
}

View file

@ -201,7 +201,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
targetBg = verifyHardLimits(targetBg, "targetBg", Constants.VERY_HARD_LIMIT_TARGET_BG[0], Constants.VERY_HARD_LIMIT_TARGET_BG[1]);
boolean isTempTarget = false;
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTarget(new Date().getTime());
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(new Date().getTime());
if (tempTarget != null) {
isTempTarget = true;
minBg = verifyHardLimits(tempTarget.low, "minBg", Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[0], Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[1]);
@ -250,7 +250,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
determineBasalResultAMA.changeRequested = false;
// limit requests on openloop mode
if (!MainApp.getConfigBuilder().isClosedModeEnabled()) {
if (MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultAMA.rate - MainApp.getConfigBuilder().getTempBasalAbsoluteRate()) < 0.1)
if (MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultAMA.rate - MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory()) < 0.1)
determineBasalResultAMA.changeRequested = false;
if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultAMA.rate - MainApp.getConfigBuilder().getBaseBasalRate()) < 0.1)
determineBasalResultAMA.changeRequested = false;

View file

@ -242,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", MainApp.getConfigBuilder().getTempBasalRemainingMinutes());
mCurrentTemp.add("rate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate());
mCurrentTemp.add("duration", MainApp.getConfigBuilder().getTempBasalRemainingMinutesFromHistory());
mCurrentTemp.add("rate", MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory());
mIobData.add("iob", iobData.iob); //netIob
mIobData.add("activity", iobData.activity); //netActivity

View file

@ -18,7 +18,6 @@ import info.nightscout.androidaps.db.TempTarget;
import info.nightscout.androidaps.interfaces.APSInterface;
import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpInterface;
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
import info.nightscout.androidaps.plugins.Loop.APSResult;
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
@ -201,7 +200,7 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
maxBg = verifyHardLimits(maxBg, "maxBg", Constants.VERY_HARD_LIMIT_MAX_BG[0], Constants.VERY_HARD_LIMIT_MAX_BG[1]);
targetBg = verifyHardLimits(targetBg, "targetBg", Constants.VERY_HARD_LIMIT_TARGET_BG[0], Constants.VERY_HARD_LIMIT_TARGET_BG[1]);
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTarget(new Date().getTime());
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(new Date().getTime());
if (tempTarget != null) {
minBg = verifyHardLimits(tempTarget.low, "minBg", Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[0], Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[1]);
maxBg = verifyHardLimits(tempTarget.high, "maxBg", Constants.VERY_HARD_LIMIT_TEMP_MAX_BG[0], Constants.VERY_HARD_LIMIT_TEMP_MAX_BG[1]);
@ -228,7 +227,7 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
determineBasalResultMA.changeRequested = false;
// limit requests on openloop mode
if (!MainApp.getConfigBuilder().isClosedModeEnabled()) {
if (MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultMA.rate - MainApp.getConfigBuilder().getTempBasalAbsoluteRate()) < 0.1)
if (MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultMA.rate - MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory()) < 0.1)
determineBasalResultMA.changeRequested = false;
if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultMA.rate - MainApp.getConfigBuilder().getBaseBasalRate()) < 0.1)
determineBasalResultMA.changeRequested = false;

View file

@ -896,7 +896,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// temp target
NSProfile profile = MainApp.getConfigBuilder().getActiveProfile().getProfile();
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTarget(new Date().getTime());
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(new Date().getTime());
if (tempTarget != null) {
tempTargetView.setTextColor(Color.BLACK);
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetBackground));
@ -936,7 +936,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
calibrationButton.setVisibility(View.GONE);
}
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime());
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
cancelTempButton.setVisibility(View.VISIBLE);
cancelTempButton.setText(MainApp.instance().getString(R.string.cancel) + "\n" + activeTemp.toStringShort());
@ -1122,7 +1122,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
double lastBaseBasal = 0;
double lastTempBasal = 0;
for (long time = fromTime; time < now; time += 1 * 60 * 1000L) {
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasal(time);
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasalFromHistory(time);
double baseBasalValue = profile.getBasal(NSProfile.secondsFromMidnight(new Date(time)));
double baseLineValue = baseBasalValue;
double tempBasalValue = 0;
@ -1411,7 +1411,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
// Treatments
List<Treatment> treatments = MainApp.getConfigBuilder().getTreatments();
List<Treatment> treatments = MainApp.getConfigBuilder().getTreatmentsFromHistory();
List<Treatment> filteredTreatments = new ArrayList<Treatment>();
for (int tx = 0; tx < treatments.size(); tx++) {

View file

@ -140,7 +140,7 @@ public class PersistentNotificationPlugin implements PluginBase{
PumpInterface pump = MainApp.getConfigBuilder();
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime());
line1 += " " + activeTemp.toStringShort();
}

View file

@ -229,13 +229,13 @@ public class DanaRFragment extends Fragment {
dailyUnitsView.setText(DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U");
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().isRealTempBasalInProgress()) {
tempBasalView.setText(MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime()).toString());
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
tempBasalView.setText(MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime()).toString());
} else {
tempBasalView.setText("");
}
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress()) {
extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()).toString());
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString());
} else {
extendedBolusView.setText("");
}

View file

@ -132,7 +132,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
pumpDescription.highTempBasalStyle = useExtendedBoluses ? PumpDescription.EXTENDED : PumpDescription.PERCENT;
if (useExtendedBoluses != previousValue && MainApp.getConfigBuilder().isExtendedBoluslInProgress()) {
if (useExtendedBoluses != previousValue && MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
sExecutionService.extendedBolusStop();
}
}
@ -351,13 +351,13 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
if (doTempOff) {
// If extended in progress
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress() && useExtendedBoluses) {
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping extended bolus (doTempOff)");
return cancelExtendedBolus();
}
// If temp in progress
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) {
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
return cancelRealTempBasal();
@ -380,7 +380,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
percentRate = getPumpDescription().maxHighTempPercent;
}
// If extended in progress
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress() && useExtendedBoluses) {
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping extended bolus (doLowTemp || doHighTemp)");
result = cancelExtendedBolus();
@ -390,14 +390,14 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
}
}
// Check if some temp is already in progress
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) {
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
// Correct basal already set ?
if (MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime()).percentRate == percentRate) {
if (MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime()).percentRate == percentRate) {
result.success = true;
result.percent = percentRate;
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRate();
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory();
result.enacted = false;
result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutes()).intValue();
result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutesFromHistory()).intValue();
result.isPercent = true;
result.isTempCancel = false;
if (Config.logPumpActions)
@ -421,7 +421,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
}
if (doExtendedTemp) {
// Check if some temp is already in progress
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) {
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)");
result = cancelRealTempBasal();
@ -442,12 +442,12 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
// What is current rate of extended bolusing in u/h?
if (Config.logPumpActions) {
log.debug("setTempBasalAbsolute: Extended bolus in progress: " + MainApp.getConfigBuilder().isExtendedBoluslInProgress() + " rate: " + pump.extendedBolusAbsoluteRate + "U/h duration remaining: " + pump.extendedBolusRemainingMinutes + "min");
log.debug("setTempBasalAbsolute: Extended bolus in progress: " + MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() + " rate: " + pump.extendedBolusAbsoluteRate + "U/h duration remaining: " + pump.extendedBolusRemainingMinutes + "min");
log.debug("setTempBasalAbsolute: Rate to set: " + extendedRateToSet + "U/h");
}
// Compare with extended rate in progress
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress() && Math.abs(pump.extendedBolusAbsoluteRate - extendedRateToSet) < getPumpDescription().extendedBolusStep) {
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && Math.abs(pump.extendedBolusAbsoluteRate - extendedRateToSet) < getPumpDescription().extendedBolusStep) {
// correct extended already set
result.success = true;
result.absolute = pump.extendedBolusAbsoluteRate;
@ -574,9 +574,9 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
@Override
public PumpEnactResult cancelTempBasal() {
if (MainApp.getConfigBuilder().isRealTempBasalInProgress())
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress())
return cancelRealTempBasal();
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress() && useExtendedBoluses) {
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
PumpEnactResult cancelEx = cancelExtendedBolus();
cancelEx.isFakedTempBasal = true;
return cancelEx;
@ -669,13 +669,13 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
extended.put("LastBolus", pump.lastBolusTime.toLocaleString());
extended.put("LastBolusAmount", pump.lastBolusAmount);
}
TemporaryBasal tb = MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime());
TemporaryBasal tb = MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime());
if (tb != null) {
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(new Date().getTime()));
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
}
ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime());
ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime());
if (eb != null) {
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date));
@ -801,11 +801,11 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
if (pump.lastBolusTime.getTime() != 0) {
ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n";
}
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) {
ret += "Temp: " + MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime()).toString() + "\n";
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
ret += "Temp: " + MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime()).toString() + "\n";
}
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress()) {
ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()).toString() + "\n";
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString() + "\n";
}
if (!veryShort) {
ret += "TDD: " + DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U\n";

View file

@ -68,22 +68,22 @@ public class MsgStatusBolusExtended extends MessageBase {
DanaRPump pump = DanaRPump.getInstance();
long now = new Date().getTime();
if (treatmentsInterface.isExtendedBoluslInProgress()) {
ExtendedBolus extendedBolus = treatmentsInterface.getExtendedBolus(new Date().getTime());
if (treatmentsInterface.isInHistoryExtendedBoluslInProgress()) {
ExtendedBolus extendedBolus = treatmentsInterface.getExtendedBolusFromHistory(new Date().getTime());
if (pump.isExtendedInProgress) {
if (extendedBolus.absoluteRate() != pump.extendedBolusAbsoluteRate) {
// Close current extended
treatmentsInterface.extendedBolusStop(now - 1000);
treatmentsInterface.addToHistoryExtendedBolusStop(now - 1000);
// Create new
ExtendedBolus newExtended = new ExtendedBolus();
newExtended.date = new Date(now).getTime();
newExtended.insulin = pump.extendedBolusAmount;
newExtended.durationInMinutes = pump.extendedBolusMinutes;
treatmentsInterface.extendedBolusStart(newExtended);
treatmentsInterface.addToHistoryExtendedBolusStart(newExtended);
}
} else {
// Close curent temp basal
treatmentsInterface.extendedBolusStop(now);
treatmentsInterface.addToHistoryExtendedBolusStop(now);
}
} else {
if (pump.isExtendedInProgress) {
@ -92,7 +92,7 @@ public class MsgStatusBolusExtended extends MessageBase {
newExtended.date = new Date(now).getTime();
newExtended.insulin = pump.extendedBolusAmount;
newExtended.durationInMinutes = pump.extendedBolusMinutes;
treatmentsInterface.extendedBolusStart(newExtended);
treatmentsInterface.addToHistoryExtendedBolusStart(newExtended);
}
}
}

View file

@ -62,23 +62,23 @@ public class MsgStatusTempBasal extends MessageBase {
DanaRPump danaRPump = DanaRPump.getInstance();
long now = new Date().getTime();
if (treatmentsInterface.isRealTempBasalInProgress()) {
TemporaryBasal tempBasal = treatmentsInterface.getRealTempBasal(new Date().getTime());
if (treatmentsInterface.isInHistoryRealTempBasalInProgress()) {
TemporaryBasal tempBasal = treatmentsInterface.getRealTempBasalFromHistory(new Date().getTime());
if (danaRPump.isTempBasalInProgress) {
if (tempBasal.percentRate != danaRPump.tempBasalPercent) {
// Close current temp basal
treatmentsInterface.tempBasalStop(now - 1000);
treatmentsInterface.addToHistoryTempBasalStop(now - 1000);
// Create new
TemporaryBasal newTempBasal = new TemporaryBasal();
newTempBasal.date = new Date(now).getTime();
newTempBasal.percentRate = danaRPump.tempBasalPercent;
newTempBasal.isAbsolute = false;
newTempBasal.durationInMinutes = danaRPump.tempBasalTotalSec / 60;
treatmentsInterface.tempBasalStart(newTempBasal);
treatmentsInterface.addToHistoryTempBasalStart(newTempBasal);
}
} else {
// Close current temp basal
treatmentsInterface.tempBasalStop(now);
treatmentsInterface.addToHistoryTempBasalStop(now);
}
} else {
if (danaRPump.isTempBasalInProgress) {
@ -88,7 +88,7 @@ public class MsgStatusTempBasal extends MessageBase {
newTempBasal.percentRate = danaRPump.tempBasalPercent;
newTempBasal.isAbsolute = false;
newTempBasal.durationInMinutes = danaRPump.tempBasalTotalSec / 60;
treatmentsInterface.tempBasalStart(newTempBasal);
treatmentsInterface.addToHistoryTempBasalStart(newTempBasal);
}
}
}

View file

@ -228,13 +228,13 @@ public class DanaRKoreanFragment extends Fragment {
dailyUnitsView.setText(DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U");
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().isRealTempBasalInProgress()) {
tempBasalView.setText(MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime()).toString());
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
tempBasalView.setText(MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime()).toString());
} else {
tempBasalView.setText("");
}
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress()) {
extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()).toString());
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString());
} else {
extendedBolusView.setText("");
}

View file

@ -135,7 +135,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
pumpDescription.highTempBasalStyle = useExtendedBoluses ? PumpDescription.EXTENDED : PumpDescription.PERCENT;
if (useExtendedBoluses != previousValue && MainApp.getConfigBuilder().isExtendedBoluslInProgress()) {
if (useExtendedBoluses != previousValue && MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
sExecutionService.extendedBolusStop();
}
}
@ -354,13 +354,13 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
if (doTempOff) {
// If extended in progress
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress() && useExtendedBoluses) {
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping extended bolus (doTempOff)");
return cancelExtendedBolus();
}
// If temp in progress
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) {
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
return cancelRealTempBasal();
@ -383,7 +383,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
percentRate = 200;
}
// If extended in progress
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress() && useExtendedBoluses) {
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping extended bolus (doLowTemp || doHighTemp)");
result = cancelExtendedBolus();
@ -393,14 +393,14 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
}
}
// Check if some temp is already in progress
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) {
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
// Correct basal already set ?
if (MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime()).percentRate == percentRate) {
if (MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime()).percentRate == percentRate) {
result.success = true;
result.percent = percentRate;
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRate();
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory();
result.enacted = false;
result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutes()).intValue();
result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutesFromHistory()).intValue();
result.isPercent = true;
result.isTempCancel = false;
if (Config.logPumpActions)
@ -424,7 +424,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
}
if (doExtendedTemp) {
// Check if some temp is already in progress
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) {
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)");
result = cancelRealTempBasal();
@ -445,12 +445,12 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
// What is current rate of extended bolusing in u/h?
if (Config.logPumpActions) {
log.debug("setTempBasalAbsolute: Extended bolus in progress: " + MainApp.getConfigBuilder().isExtendedBoluslInProgress() + " rate: " + pump.extendedBolusAbsoluteRate + "U/h duration remaining: " + pump.extendedBolusRemainingMinutes + "min");
log.debug("setTempBasalAbsolute: Extended bolus in progress: " + MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() + " rate: " + pump.extendedBolusAbsoluteRate + "U/h duration remaining: " + pump.extendedBolusRemainingMinutes + "min");
log.debug("setTempBasalAbsolute: Rate to set: " + extendedRateToSet + "U/h");
}
// Compare with extended rate in progress
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress() && Math.abs(pump.extendedBolusAbsoluteRate - extendedRateToSet) < getPumpDescription().extendedBolusStep) {
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && Math.abs(pump.extendedBolusAbsoluteRate - extendedRateToSet) < getPumpDescription().extendedBolusStep) {
// correct extended already set
result.success = true;
result.absolute = pump.extendedBolusAbsoluteRate;
@ -577,9 +577,9 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
@Override
public PumpEnactResult cancelTempBasal() {
if (MainApp.getConfigBuilder().isRealTempBasalInProgress())
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress())
return cancelRealTempBasal();
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress() && useExtendedBoluses) {
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
PumpEnactResult cancelEx = cancelExtendedBolus();
cancelEx.isFakedTempBasal = true;
return cancelEx;
@ -672,13 +672,13 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
extended.put("LastBolus", pump.lastBolusTime.toLocaleString());
extended.put("LastBolusAmount", pump.lastBolusAmount);
}
TemporaryBasal tb = MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime());
TemporaryBasal tb = MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime());
if (tb != null) {
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(new Date().getTime()));
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
}
ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime());
ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime());
if (eb != null) {
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date));
@ -804,11 +804,11 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
if (pump.lastBolusTime.getTime() != 0) {
ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n";
}
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) {
ret += "Temp: " + MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime()).toString() + "\n";
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
ret += "Temp: " + MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime()).toString() + "\n";
}
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress()) {
ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()).toString() + "\n";
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString() + "\n";
}
if (!veryShort) {
ret += "TDD: " + DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U\n";

View file

@ -227,12 +227,12 @@ public class DanaRv2Fragment 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().getTempBasalFromHistory(new Date().getTime()).toString());
} else {
tempBasalView.setText("");
}
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress()) {
extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()).toString());
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString());
} else {
extendedBolusView.setText("");
}

View file

@ -43,7 +43,6 @@ import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaRv2.services.DanaRv2ExecutionService;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.Round;
@ -361,12 +360,12 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, ConstraintsInte
// Check if some temp is already in progress
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
// Correct basal already set ?
if (MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).percentRate == percentRate) {
if (MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime()).percentRate == percentRate) {
result.success = true;
result.percent = percentRate;
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRate();
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory();
result.enacted = false;
result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutes()).intValue();
result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutesFromHistory()).intValue();
result.isPercent = true;
result.isTempCancel = false;
if (Config.logPumpActions)
@ -588,13 +587,13 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, ConstraintsInte
extended.put("LastBolus", pump.lastBolusTime.toLocaleString());
extended.put("LastBolusAmount", pump.lastBolusAmount);
}
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime());
if (tb != null) {
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(new Date().getTime()));
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
}
ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime());
ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime());
if (eb != null) {
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date));
@ -721,10 +720,10 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, ConstraintsInte
ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n";
}
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
ret += "Temp: " + MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).toString() + "\n";
ret += "Temp: " + MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime()).toString() + "\n";
}
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress()) {
ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()).toString() + "\n";
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString() + "\n";
}
if (!veryShort) {
ret += "TDD: " + DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U\n";

View file

@ -95,12 +95,12 @@ public class VirtualPumpFragment extends Fragment {
basaBasalRateView.setText(virtualPumpPlugin.getBaseBasalRate() + "U");
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
tempBasalView.setText(MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).toString());
tempBasalView.setText(MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime()).toString());
} else {
tempBasalView.setText("");
}
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress()) {
extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()).toString());
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString());
} else {
extendedBolusView.setText("");
}

View file

@ -27,7 +27,6 @@ import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil;
import info.nightscout.utils.NSUpload;
@ -249,7 +248,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
result.absolute = absoluteRate;
result.duration = durationInMinutes;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
treatmentsInterface.tempBasalStart(tempBasal);
treatmentsInterface.addToHistoryTempBasalStart(tempBasal);
if (Config.logPumpComm)
log.debug("Setting temp basal absolute: " + result);
MainApp.bus().post(new EventVirtualPumpUpdateGui());
@ -278,7 +277,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
result.isTempCancel = false;
result.duration = durationInMinutes;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
treatmentsInterface.tempBasalStart(tempBasal);
treatmentsInterface.addToHistoryTempBasalStart(tempBasal);
if (Config.logPumpComm)
log.debug("Settings temp basal percent: " + result);
MainApp.bus().post(new EventVirtualPumpUpdateGui());
@ -302,7 +301,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
result.isTempCancel = false;
result.duration = durationInMinutes;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
treatmentsInterface.extendedBolusStart(extendedBolus);
treatmentsInterface.addToHistoryExtendedBolusStart(extendedBolus);
if (Config.logPumpComm)
log.debug("Setting extended bolus: " + result);
MainApp.bus().post(new EventVirtualPumpUpdateGui());
@ -319,7 +318,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
if (treatmentsInterface.isTempBasalInProgress()) {
result.enacted = true;
treatmentsInterface.tempBasalStop(new Date().getTime());
treatmentsInterface.addToHistoryTempBasalStop(new Date().getTime());
//tempBasal = null;
if (Config.logPumpComm)
log.debug("Canceling temp basal: " + result);
@ -333,8 +332,8 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
public PumpEnactResult cancelExtendedBolus() {
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
PumpEnactResult result = new PumpEnactResult();
if (treatmentsInterface.isExtendedBoluslInProgress()) {
treatmentsInterface.extendedBolusStop(new Date().getTime());
if (treatmentsInterface.isInHistoryExtendedBoluslInProgress()) {
treatmentsInterface.addToHistoryExtendedBolusStop(new Date().getTime());
}
result.success = true;
result.enacted = true;
@ -364,13 +363,13 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
try {
extended.put("ActiveProfile", MainApp.getConfigBuilder().getActiveProfile().getProfile().getActiveProfile());
} catch (Exception e) {}
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasal(new Date().getTime());
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime());
if (tb != null) {
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(new Date().getTime()));
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
}
ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime());
ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime());
if (eb != null) {
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date));

View file

@ -238,12 +238,12 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
}
@Override
public List<Treatment> getTreatments() {
public List<Treatment> getTreatmentsFromHistory() {
return treatments;
}
@Override
public List<Treatment> getTreatments5MinBack(long time) {
public List<Treatment> getTreatments5MinBackFromHistory(long time) {
List<Treatment> in5minback = new ArrayList<>();
for (Integer pos = 0; pos < treatments.size(); pos++) {
Treatment t = treatments.get(pos);
@ -254,23 +254,23 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
}
@Override
public boolean isRealTempBasalInProgress() {
return getRealTempBasal(new Date().getTime()) != null;
public boolean isInHistoryRealTempBasalInProgress() {
return getRealTempBasalFromHistory(new Date().getTime()) != null;
}
@Override
public TemporaryBasal getRealTempBasal(long time) {
public TemporaryBasal getRealTempBasalFromHistory(long time) {
return (TemporaryBasal) tempBasals.getValueByInterval(time);
}
@Override
public boolean isTempBasalInProgress() {
return getTempBasal(new Date().getTime()) != null;
return getTempBasalFromHistory(new Date().getTime()) != null;
}
@Override
public boolean isExtendedBoluslInProgress() {
return getExtendedBolus(new Date().getTime()) != null; //TODO: crosscheck here
public boolean isInHistoryExtendedBoluslInProgress() {
return getExtendedBolusFromHistory(new Date().getTime()) != null; //TODO: crosscheck here
}
@Subscribe
@ -333,28 +333,28 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
@Nullable
@Override
public TemporaryBasal getTempBasal(long time) {
TemporaryBasal tb = getRealTempBasal(time);
public TemporaryBasal getTempBasalFromHistory(long time) {
TemporaryBasal tb = getRealTempBasalFromHistory(time);
if (tb != null)
return tb;
ExtendedBolus eb = getExtendedBolus(time);
ExtendedBolus eb = getExtendedBolusFromHistory(time);
if (eb != null && MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses())
return new TemporaryBasal(eb);
return null;
}
@Override
public ExtendedBolus getExtendedBolus(long time) {
public ExtendedBolus getExtendedBolusFromHistory(long time) {
return (ExtendedBolus) extendedBoluses.getValueByInterval(time);
}
@Override
public void extendedBolusStart(ExtendedBolus extendedBolus) {
public void addToHistoryExtendedBolusStart(ExtendedBolus extendedBolus) {
MainApp.getDbHelper().createOrUpdate(extendedBolus);
}
@Override
public void extendedBolusStop(long time) {
public void addToHistoryExtendedBolusStop(long time) {
ExtendedBolus extendedBolus = new ExtendedBolus();
extendedBolus.date = time;
extendedBolus.durationInMinutes = 0;
@ -362,15 +362,15 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
}
@Override
public OverlappingIntervals<ExtendedBolus> getExtendedBoluses() {
public OverlappingIntervals<ExtendedBolus> getExtendedBolusesFromHistory() {
return extendedBoluses;
}
@Override
public double getTempBasalAbsoluteRate() {
public double getTempBasalAbsoluteRateHistory() {
PumpInterface pump = MainApp.getConfigBuilder();
TemporaryBasal tb = getTempBasal(new Date().getTime());
TemporaryBasal tb = getTempBasalFromHistory(new Date().getTime());
if (tb != null) {
if (tb.isAbsolute) {
return tb.absoluteRate;
@ -384,24 +384,24 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
}
@Override
public double getTempBasalRemainingMinutes() {
public double getTempBasalRemainingMinutesFromHistory() {
if (isTempBasalInProgress())
return getTempBasal(new Date().getTime()).getPlannedRemainingMinutes();
return getTempBasalFromHistory(new Date().getTime()).getPlannedRemainingMinutes();
return 0;
}
@Override
public OverlappingIntervals<TemporaryBasal> getTemporaryBasals() {
public OverlappingIntervals<TemporaryBasal> getTemporaryBasalsFromHistory() {
return tempBasals;
}
@Override
public void tempBasalStart(TemporaryBasal tempBasal) {
public void addToHistoryTempBasalStart(TemporaryBasal tempBasal) {
MainApp.getDbHelper().createOrUpdate(tempBasal);
}
@Override
public void tempBasalStop(long time) {
public void addToHistoryTempBasalStop(long time) {
TemporaryBasal temporaryBasal = new TemporaryBasal();
temporaryBasal.date = time;
temporaryBasal.durationInMinutes = 0;
@ -429,12 +429,12 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
@Nullable
@Override
public TempTarget getTempTarget(long time) {
public TempTarget getTempTargetFromHistory(long time) {
return (TempTarget) tempTargets.getValueByInterval(time);
}
@Override
public OverlappingIntervals<TempTarget> getTempTargets() {
public OverlappingIntervals<TempTarget> getTempTargetsFromHistory() {
return tempTargets;
}

View file

@ -167,7 +167,7 @@ public class TreatmentsExtendedBolusesFragment extends Fragment {
llm = new LinearLayoutManager(view.getContext());
recyclerView.setLayoutManager(llm);
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getConfigBuilder().getExtendedBoluses());
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getConfigBuilder().getExtendedBolusesFromHistory());
recyclerView.setAdapter(adapter);
context = getContext();
@ -204,7 +204,7 @@ public class TreatmentsExtendedBolusesFragment extends Fragment {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
recyclerView.swapAdapter(new RecyclerViewAdapter(MainApp.getConfigBuilder().getExtendedBoluses()), false);
recyclerView.swapAdapter(new RecyclerViewAdapter(MainApp.getConfigBuilder().getExtendedBolusesFromHistory()), false);
}
});
}

View file

@ -159,7 +159,7 @@ public class TreatmentsTempTargetFragment extends Fragment implements View.OnCli
llm = new LinearLayoutManager(view.getContext());
recyclerView.setLayoutManager(llm);
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getConfigBuilder().getTempTargets());
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getConfigBuilder().getTempTargetsFromHistory());
recyclerView.setAdapter(adapter);
refreshFromNS = (Button) view.findViewById(R.id.temptargetrange_refreshfromnightscout);
@ -219,7 +219,7 @@ public class TreatmentsTempTargetFragment extends Fragment implements View.OnCli
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
recyclerView.swapAdapter(new RecyclerViewAdapter(MainApp.getConfigBuilder().getTempTargets()), false);
recyclerView.swapAdapter(new RecyclerViewAdapter(MainApp.getConfigBuilder().getTempTargetsFromHistory()), false);
}
});
}

View file

@ -183,7 +183,7 @@ public class TreatmentsTemporaryBasalsFragment extends Fragment {
llm = new LinearLayoutManager(view.getContext());
recyclerView.setLayoutManager(llm);
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getConfigBuilder().getTemporaryBasals());
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getConfigBuilder().getTemporaryBasalsFromHistory());
recyclerView.setAdapter(adapter);
tempBasalTotalView = (TextView) view.findViewById(R.id.tempbasals_totaltempiob);
@ -222,7 +222,7 @@ public class TreatmentsTemporaryBasalsFragment extends Fragment {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
recyclerView.swapAdapter(new RecyclerViewAdapter(MainApp.getConfigBuilder().getTemporaryBasals()), false);
recyclerView.swapAdapter(new RecyclerViewAdapter(MainApp.getConfigBuilder().getTemporaryBasalsFromHistory()), false);
if (MainApp.getConfigBuilder().getLastCalculationTempBasals() != null) {
String totalText = DecimalFormatter.to2Decimal(MainApp.getConfigBuilder().getLastCalculationTempBasals().basaliob) + " U";
tempBasalTotalView.setText(totalText);

View file

@ -275,7 +275,7 @@ public class ActionStringHandler {
}
//Check for Temp-Target:
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTarget(new Date().getTime());
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(new Date().getTime());
if (tempTarget != null) {
ret += "Temp Target: " + NSProfile.toUnitsString(tempTarget.low, NSProfile.fromMgdlToUnits(tempTarget.low, profile.getUnits()), profile.getUnits()) + " - " + NSProfile.toUnitsString(tempTarget.high, NSProfile.fromMgdlToUnits(tempTarget.high, profile.getUnits()), profile.getUnits());
ret += "\nuntil: " + DateUtil.timeString(tempTarget.originalEnd());

View file

@ -351,8 +351,8 @@ public class WatchUpdaterService extends WearableListenerService implements
double beginBasalValue = profile.getBasal(NSProfile.secondsFromMidnight(new Date(beginBasalSegmentTime)));
double endBasalValue = beginBasalValue;
TemporaryBasal tb1 = MainApp.getConfigBuilder().getTempBasal(runningTime);
TemporaryBasal tb2 = MainApp.getConfigBuilder().getTempBasal(runningTime);
TemporaryBasal tb1 = MainApp.getConfigBuilder().getTempBasalFromHistory(runningTime);
TemporaryBasal tb2 = MainApp.getConfigBuilder().getTempBasalFromHistory(runningTime);
double tb_before = beginBasalValue;
double tb_amount = beginBasalValue;
long tb_start = runningTime;
@ -378,7 +378,7 @@ public class WatchUpdaterService extends WearableListenerService implements
}
//temps
tb2 = MainApp.getConfigBuilder().getTempBasal(runningTime);
tb2 = MainApp.getConfigBuilder().getTempBasalFromHistory(runningTime);
if (tb1 == null && tb2 == null) {
//no temp stays no temp
@ -411,7 +411,7 @@ public class WatchUpdaterService extends WearableListenerService implements
basals.add(basalMap(beginBasalSegmentTime, runningTime, beginBasalValue));
}
if (tb1 != null) {
tb2 = MainApp.getConfigBuilder().getTempBasal(now); //use "now" to express current situation
tb2 = MainApp.getConfigBuilder().getTempBasalFromHistory(now); //use "now" to express current situation
if (tb2 == null) {
//express the cancelled temp by painting it down one minute early
temps.add(tempDatamap(tb_start, tb_before, now - 1 * 60 * 1000, endBasalValue, tb_amount));
@ -426,7 +426,7 @@ public class WatchUpdaterService extends WearableListenerService implements
}
}
} else {
tb2 = MainApp.getConfigBuilder().getTempBasal(now); //use "now" to express current situation
tb2 = MainApp.getConfigBuilder().getTempBasalFromHistory(now); //use "now" to express current situation
if (tb2 != null) {
//onset at the end
double currentAmount = tb2.tempBasalConvertedToAbsolute(runningTime);
@ -541,7 +541,7 @@ public class WatchUpdaterService extends WearableListenerService implements
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
if (treatmentsInterface.isTempBasalInProgress()) {
TemporaryBasal activeTemp = treatmentsInterface.getTempBasal(new Date().getTime());
TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(new Date().getTime());
if (shortString) {
status += activeTemp.toStringShort();
} else {

View file

@ -165,7 +165,7 @@ public class StatuslinePlugin implements PluginBase {
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
if (treatmentsInterface.isTempBasalInProgress()) {
TemporaryBasal activeTemp = treatmentsInterface.getTempBasal(new Date().getTime());
TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(new Date().getTime());
if (shortString) {
status += activeTemp.toStringShort();
} else {