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

View file

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

View file

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

View file

@ -279,7 +279,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
double bgi = -iob.activity * sens * 5; double bgi = -iob.activity * sens * 5;
double deviation = delta - bgi; 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++) { for (int ir = 0; ir < recentTreatments.size(); ir++) {
autosensData.carbsFromBolus += recentTreatments.get(ir).carbs; autosensData.carbsFromBolus += recentTreatments.get(ir).carbs;
} }

View file

@ -228,11 +228,11 @@ public class DetermineBasalAdapterAMAJS {
mCurrentTemp = new V8Object(mV8rt); mCurrentTemp = new V8Object(mV8rt);
mCurrentTemp.add("temp", "absolute"); mCurrentTemp.add("temp", "absolute");
mCurrentTemp.add("duration", MainApp.getConfigBuilder().getTempBasalRemainingMinutes()); mCurrentTemp.add("duration", MainApp.getConfigBuilder().getTempBasalRemainingMinutesFromHistory());
mCurrentTemp.add("rate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate()); mCurrentTemp.add("rate", MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory());
// as we have non default temps longer than 30 mintues // 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){ if(tempBasal != null){
mCurrentTemp.add("minutesrunning", tempBasal.getRealDuration()); 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]); targetBg = verifyHardLimits(targetBg, "targetBg", Constants.VERY_HARD_LIMIT_TARGET_BG[0], Constants.VERY_HARD_LIMIT_TARGET_BG[1]);
boolean isTempTarget = false; boolean isTempTarget = false;
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTarget(new Date().getTime()); TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(new Date().getTime());
if (tempTarget != null) { if (tempTarget != null) {
isTempTarget = true; isTempTarget = true;
minBg = verifyHardLimits(tempTarget.low, "minBg", Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[0], Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[1]); 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; determineBasalResultAMA.changeRequested = false;
// limit requests on openloop mode // limit requests on openloop mode
if (!MainApp.getConfigBuilder().isClosedModeEnabled()) { 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; determineBasalResultAMA.changeRequested = false;
if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultAMA.rate - MainApp.getConfigBuilder().getBaseBasalRate()) < 0.1) if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultAMA.rate - MainApp.getConfigBuilder().getBaseBasalRate()) < 0.1)
determineBasalResultAMA.changeRequested = false; 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("sens", NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()).doubleValue(), units));
mProfile.add("current_basal", pump.getBaseBasalRate()); mProfile.add("current_basal", pump.getBaseBasalRate());
mCurrentTemp.add("duration", MainApp.getConfigBuilder().getTempBasalRemainingMinutes()); mCurrentTemp.add("duration", MainApp.getConfigBuilder().getTempBasalRemainingMinutesFromHistory());
mCurrentTemp.add("rate", MainApp.getConfigBuilder().getTempBasalAbsoluteRate()); mCurrentTemp.add("rate", MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory());
mIobData.add("iob", iobData.iob); //netIob mIobData.add("iob", iobData.iob); //netIob
mIobData.add("activity", iobData.activity); //netActivity 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.APSInterface;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PumpInterface; 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.APSResult;
import info.nightscout.androidaps.plugins.Loop.ScriptReader; import info.nightscout.androidaps.plugins.Loop.ScriptReader;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile; 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]); 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]); 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) { if (tempTarget != null) {
minBg = verifyHardLimits(tempTarget.low, "minBg", Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[0], Constants.VERY_HARD_LIMIT_TEMP_MIN_BG[1]); 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]); 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; determineBasalResultMA.changeRequested = false;
// limit requests on openloop mode // limit requests on openloop mode
if (!MainApp.getConfigBuilder().isClosedModeEnabled()) { 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; determineBasalResultMA.changeRequested = false;
if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultMA.rate - MainApp.getConfigBuilder().getBaseBasalRate()) < 0.1) if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultMA.rate - MainApp.getConfigBuilder().getBaseBasalRate()) < 0.1)
determineBasalResultMA.changeRequested = false; determineBasalResultMA.changeRequested = false;

View file

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

View file

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

View file

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

View file

@ -132,7 +132,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
pumpDescription.highTempBasalStyle = useExtendedBoluses ? PumpDescription.EXTENDED : PumpDescription.PERCENT; pumpDescription.highTempBasalStyle = useExtendedBoluses ? PumpDescription.EXTENDED : PumpDescription.PERCENT;
if (useExtendedBoluses != previousValue && MainApp.getConfigBuilder().isExtendedBoluslInProgress()) { if (useExtendedBoluses != previousValue && MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
sExecutionService.extendedBolusStop(); sExecutionService.extendedBolusStop();
} }
} }
@ -351,13 +351,13 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
if (doTempOff) { if (doTempOff) {
// If extended in progress // If extended in progress
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress() && useExtendedBoluses) { if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping extended bolus (doTempOff)"); log.debug("setTempBasalAbsolute: Stopping extended bolus (doTempOff)");
return cancelExtendedBolus(); return cancelExtendedBolus();
} }
// If temp in progress // If temp in progress
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) { if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)"); log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
return cancelRealTempBasal(); return cancelRealTempBasal();
@ -380,7 +380,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
percentRate = getPumpDescription().maxHighTempPercent; percentRate = getPumpDescription().maxHighTempPercent;
} }
// If extended in progress // If extended in progress
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress() && useExtendedBoluses) { if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping extended bolus (doLowTemp || doHighTemp)"); log.debug("setTempBasalAbsolute: Stopping extended bolus (doLowTemp || doHighTemp)");
result = cancelExtendedBolus(); result = cancelExtendedBolus();
@ -390,14 +390,14 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
} }
} }
// Check if some temp is already in progress // Check if some temp is already in progress
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) { if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
// Correct basal already set ? // 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.success = true;
result.percent = percentRate; result.percent = percentRate;
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRate(); result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory();
result.enacted = false; result.enacted = false;
result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutes()).intValue(); result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutesFromHistory()).intValue();
result.isPercent = true; result.isPercent = true;
result.isTempCancel = false; result.isTempCancel = false;
if (Config.logPumpActions) if (Config.logPumpActions)
@ -421,7 +421,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
} }
if (doExtendedTemp) { if (doExtendedTemp) {
// Check if some temp is already in progress // Check if some temp is already in progress
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) { if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)"); log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)");
result = cancelRealTempBasal(); result = cancelRealTempBasal();
@ -442,12 +442,12 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
// What is current rate of extended bolusing in u/h? // What is current rate of extended bolusing in u/h?
if (Config.logPumpActions) { 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"); log.debug("setTempBasalAbsolute: Rate to set: " + extendedRateToSet + "U/h");
} }
// Compare with extended rate in progress // 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 // correct extended already set
result.success = true; result.success = true;
result.absolute = pump.extendedBolusAbsoluteRate; result.absolute = pump.extendedBolusAbsoluteRate;
@ -574,9 +574,9 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
@Override @Override
public PumpEnactResult cancelTempBasal() { public PumpEnactResult cancelTempBasal() {
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress())
return cancelRealTempBasal(); return cancelRealTempBasal();
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress() && useExtendedBoluses) { if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
PumpEnactResult cancelEx = cancelExtendedBolus(); PumpEnactResult cancelEx = cancelExtendedBolus();
cancelEx.isFakedTempBasal = true; cancelEx.isFakedTempBasal = true;
return cancelEx; return cancelEx;
@ -669,13 +669,13 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
extended.put("LastBolus", pump.lastBolusTime.toLocaleString()); extended.put("LastBolus", pump.lastBolusTime.toLocaleString());
extended.put("LastBolusAmount", pump.lastBolusAmount); extended.put("LastBolusAmount", pump.lastBolusAmount);
} }
TemporaryBasal tb = MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime()); TemporaryBasal tb = MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime());
if (tb != null) { if (tb != null) {
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(new Date().getTime())); extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(new Date().getTime()));
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)); extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes()); extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
} }
ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()); ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime());
if (eb != null) { if (eb != null) {
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()); extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)); extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date));
@ -801,11 +801,11 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
if (pump.lastBolusTime.getTime() != 0) { if (pump.lastBolusTime.getTime() != 0) {
ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n"; ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n";
} }
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) { if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
ret += "Temp: " + MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime()).toString() + "\n"; ret += "Temp: " + MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime()).toString() + "\n";
} }
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress()) { if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()).toString() + "\n"; ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString() + "\n";
} }
if (!veryShort) { if (!veryShort) {
ret += "TDD: " + DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U\n"; 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(); DanaRPump pump = DanaRPump.getInstance();
long now = new Date().getTime(); long now = new Date().getTime();
if (treatmentsInterface.isExtendedBoluslInProgress()) { if (treatmentsInterface.isInHistoryExtendedBoluslInProgress()) {
ExtendedBolus extendedBolus = treatmentsInterface.getExtendedBolus(new Date().getTime()); ExtendedBolus extendedBolus = treatmentsInterface.getExtendedBolusFromHistory(new Date().getTime());
if (pump.isExtendedInProgress) { if (pump.isExtendedInProgress) {
if (extendedBolus.absoluteRate() != pump.extendedBolusAbsoluteRate) { if (extendedBolus.absoluteRate() != pump.extendedBolusAbsoluteRate) {
// Close current extended // Close current extended
treatmentsInterface.extendedBolusStop(now - 1000); treatmentsInterface.addToHistoryExtendedBolusStop(now - 1000);
// Create new // Create new
ExtendedBolus newExtended = new ExtendedBolus(); ExtendedBolus newExtended = new ExtendedBolus();
newExtended.date = new Date(now).getTime(); newExtended.date = new Date(now).getTime();
newExtended.insulin = pump.extendedBolusAmount; newExtended.insulin = pump.extendedBolusAmount;
newExtended.durationInMinutes = pump.extendedBolusMinutes; newExtended.durationInMinutes = pump.extendedBolusMinutes;
treatmentsInterface.extendedBolusStart(newExtended); treatmentsInterface.addToHistoryExtendedBolusStart(newExtended);
} }
} else { } else {
// Close curent temp basal // Close curent temp basal
treatmentsInterface.extendedBolusStop(now); treatmentsInterface.addToHistoryExtendedBolusStop(now);
} }
} else { } else {
if (pump.isExtendedInProgress) { if (pump.isExtendedInProgress) {
@ -92,7 +92,7 @@ public class MsgStatusBolusExtended extends MessageBase {
newExtended.date = new Date(now).getTime(); newExtended.date = new Date(now).getTime();
newExtended.insulin = pump.extendedBolusAmount; newExtended.insulin = pump.extendedBolusAmount;
newExtended.durationInMinutes = pump.extendedBolusMinutes; 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(); DanaRPump danaRPump = DanaRPump.getInstance();
long now = new Date().getTime(); long now = new Date().getTime();
if (treatmentsInterface.isRealTempBasalInProgress()) { if (treatmentsInterface.isInHistoryRealTempBasalInProgress()) {
TemporaryBasal tempBasal = treatmentsInterface.getRealTempBasal(new Date().getTime()); TemporaryBasal tempBasal = treatmentsInterface.getRealTempBasalFromHistory(new Date().getTime());
if (danaRPump.isTempBasalInProgress) { if (danaRPump.isTempBasalInProgress) {
if (tempBasal.percentRate != danaRPump.tempBasalPercent) { if (tempBasal.percentRate != danaRPump.tempBasalPercent) {
// Close current temp basal // Close current temp basal
treatmentsInterface.tempBasalStop(now - 1000); treatmentsInterface.addToHistoryTempBasalStop(now - 1000);
// Create new // Create new
TemporaryBasal newTempBasal = new TemporaryBasal(); TemporaryBasal newTempBasal = new TemporaryBasal();
newTempBasal.date = new Date(now).getTime(); newTempBasal.date = new Date(now).getTime();
newTempBasal.percentRate = danaRPump.tempBasalPercent; newTempBasal.percentRate = danaRPump.tempBasalPercent;
newTempBasal.isAbsolute = false; newTempBasal.isAbsolute = false;
newTempBasal.durationInMinutes = danaRPump.tempBasalTotalSec / 60; newTempBasal.durationInMinutes = danaRPump.tempBasalTotalSec / 60;
treatmentsInterface.tempBasalStart(newTempBasal); treatmentsInterface.addToHistoryTempBasalStart(newTempBasal);
} }
} else { } else {
// Close current temp basal // Close current temp basal
treatmentsInterface.tempBasalStop(now); treatmentsInterface.addToHistoryTempBasalStop(now);
} }
} else { } else {
if (danaRPump.isTempBasalInProgress) { if (danaRPump.isTempBasalInProgress) {
@ -88,7 +88,7 @@ public class MsgStatusTempBasal extends MessageBase {
newTempBasal.percentRate = danaRPump.tempBasalPercent; newTempBasal.percentRate = danaRPump.tempBasalPercent;
newTempBasal.isAbsolute = false; newTempBasal.isAbsolute = false;
newTempBasal.durationInMinutes = danaRPump.tempBasalTotalSec / 60; 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"); dailyUnitsView.setText(DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U");
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().isRealTempBasalInProgress()) { if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
tempBasalView.setText(MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime()).toString()); tempBasalView.setText(MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime()).toString());
} else { } else {
tempBasalView.setText(""); tempBasalView.setText("");
} }
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress()) { if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()).toString()); extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString());
} else { } else {
extendedBolusView.setText(""); extendedBolusView.setText("");
} }

View file

@ -135,7 +135,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
pumpDescription.highTempBasalStyle = useExtendedBoluses ? PumpDescription.EXTENDED : PumpDescription.PERCENT; pumpDescription.highTempBasalStyle = useExtendedBoluses ? PumpDescription.EXTENDED : PumpDescription.PERCENT;
if (useExtendedBoluses != previousValue && MainApp.getConfigBuilder().isExtendedBoluslInProgress()) { if (useExtendedBoluses != previousValue && MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
sExecutionService.extendedBolusStop(); sExecutionService.extendedBolusStop();
} }
} }
@ -354,13 +354,13 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
if (doTempOff) { if (doTempOff) {
// If extended in progress // If extended in progress
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress() && useExtendedBoluses) { if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping extended bolus (doTempOff)"); log.debug("setTempBasalAbsolute: Stopping extended bolus (doTempOff)");
return cancelExtendedBolus(); return cancelExtendedBolus();
} }
// If temp in progress // If temp in progress
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) { if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)"); log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
return cancelRealTempBasal(); return cancelRealTempBasal();
@ -383,7 +383,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
percentRate = 200; percentRate = 200;
} }
// If extended in progress // If extended in progress
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress() && useExtendedBoluses) { if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping extended bolus (doLowTemp || doHighTemp)"); log.debug("setTempBasalAbsolute: Stopping extended bolus (doLowTemp || doHighTemp)");
result = cancelExtendedBolus(); result = cancelExtendedBolus();
@ -393,14 +393,14 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
} }
} }
// Check if some temp is already in progress // Check if some temp is already in progress
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) { if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
// Correct basal already set ? // 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.success = true;
result.percent = percentRate; result.percent = percentRate;
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRate(); result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory();
result.enacted = false; result.enacted = false;
result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutes()).intValue(); result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutesFromHistory()).intValue();
result.isPercent = true; result.isPercent = true;
result.isTempCancel = false; result.isTempCancel = false;
if (Config.logPumpActions) if (Config.logPumpActions)
@ -424,7 +424,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
} }
if (doExtendedTemp) { if (doExtendedTemp) {
// Check if some temp is already in progress // Check if some temp is already in progress
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) { if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)"); log.debug("setTempBasalAbsolute: Stopping temp basal (doExtendedTemp)");
result = cancelRealTempBasal(); result = cancelRealTempBasal();
@ -445,12 +445,12 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
// What is current rate of extended bolusing in u/h? // What is current rate of extended bolusing in u/h?
if (Config.logPumpActions) { 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"); log.debug("setTempBasalAbsolute: Rate to set: " + extendedRateToSet + "U/h");
} }
// Compare with extended rate in progress // 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 // correct extended already set
result.success = true; result.success = true;
result.absolute = pump.extendedBolusAbsoluteRate; result.absolute = pump.extendedBolusAbsoluteRate;
@ -577,9 +577,9 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
@Override @Override
public PumpEnactResult cancelTempBasal() { public PumpEnactResult cancelTempBasal() {
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress())
return cancelRealTempBasal(); return cancelRealTempBasal();
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress() && useExtendedBoluses) { if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
PumpEnactResult cancelEx = cancelExtendedBolus(); PumpEnactResult cancelEx = cancelExtendedBolus();
cancelEx.isFakedTempBasal = true; cancelEx.isFakedTempBasal = true;
return cancelEx; return cancelEx;
@ -672,13 +672,13 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
extended.put("LastBolus", pump.lastBolusTime.toLocaleString()); extended.put("LastBolus", pump.lastBolusTime.toLocaleString());
extended.put("LastBolusAmount", pump.lastBolusAmount); extended.put("LastBolusAmount", pump.lastBolusAmount);
} }
TemporaryBasal tb = MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime()); TemporaryBasal tb = MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime());
if (tb != null) { if (tb != null) {
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(new Date().getTime())); extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(new Date().getTime()));
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)); extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes()); extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
} }
ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()); ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime());
if (eb != null) { if (eb != null) {
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()); extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)); extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date));
@ -804,11 +804,11 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, Constraints
if (pump.lastBolusTime.getTime() != 0) { if (pump.lastBolusTime.getTime() != 0) {
ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n"; ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n";
} }
if (MainApp.getConfigBuilder().isRealTempBasalInProgress()) { if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
ret += "Temp: " + MainApp.getConfigBuilder().getRealTempBasal(new Date().getTime()).toString() + "\n"; ret += "Temp: " + MainApp.getConfigBuilder().getRealTempBasalFromHistory(new Date().getTime()).toString() + "\n";
} }
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress()) { if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()).toString() + "\n"; ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString() + "\n";
} }
if (!veryShort) { if (!veryShort) {
ret += "TDD: " + DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U\n"; 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); 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().getTempBasalFromHistory(new Date().getTime()).toString());
} else { } else {
tempBasalView.setText(""); tempBasalView.setText("");
} }
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress()) { if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()).toString()); extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString());
} else { } else {
extendedBolusView.setText(""); 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.ProfileNS.NSProfilePlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
import info.nightscout.androidaps.plugins.PumpDanaRv2.services.DanaRv2ExecutionService; import info.nightscout.androidaps.plugins.PumpDanaRv2.services.DanaRv2ExecutionService;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.Round; import info.nightscout.utils.Round;
@ -361,12 +360,12 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, ConstraintsInte
// Check if some temp is already in progress // Check if some temp is already in progress
if (MainApp.getConfigBuilder().isTempBasalInProgress()) { if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
// Correct basal already set ? // 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.success = true;
result.percent = percentRate; result.percent = percentRate;
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRate(); result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory();
result.enacted = false; result.enacted = false;
result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutes()).intValue(); result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutesFromHistory()).intValue();
result.isPercent = true; result.isPercent = true;
result.isTempCancel = false; result.isTempCancel = false;
if (Config.logPumpActions) if (Config.logPumpActions)
@ -588,13 +587,13 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, ConstraintsInte
extended.put("LastBolus", pump.lastBolusTime.toLocaleString()); extended.put("LastBolus", pump.lastBolusTime.toLocaleString());
extended.put("LastBolusAmount", pump.lastBolusAmount); extended.put("LastBolusAmount", pump.lastBolusAmount);
} }
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasal(new Date().getTime()); TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime());
if (tb != null) { if (tb != null) {
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(new Date().getTime())); extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(new Date().getTime()));
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)); extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes()); extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
} }
ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()); ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime());
if (eb != null) { if (eb != null) {
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()); extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)); 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"; ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n";
} }
if (MainApp.getConfigBuilder().isTempBasalInProgress()) { 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()) { if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()).toString() + "\n"; ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString() + "\n";
} }
if (!veryShort) { if (!veryShort) {
ret += "TDD: " + DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U\n"; 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"); basaBasalRateView.setText(virtualPumpPlugin.getBaseBasalRate() + "U");
if (MainApp.getConfigBuilder().isTempBasalInProgress()) { if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
tempBasalView.setText(MainApp.getConfigBuilder().getTempBasal(new Date().getTime()).toString()); tempBasalView.setText(MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime()).toString());
} else { } else {
tempBasalView.setText(""); tempBasalView.setText("");
} }
if (MainApp.getConfigBuilder().isExtendedBoluslInProgress()) { if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()).toString()); extendedBolusView.setText(MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime()).toString());
} else { } else {
extendedBolusView.setText(""); 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.Overview.events.EventOverviewBolusProgress;
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui; import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile; import info.nightscout.androidaps.plugins.NSClientInternal.data.NSProfile;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.NSUpload; import info.nightscout.utils.NSUpload;
@ -249,7 +248,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
result.absolute = absoluteRate; result.absolute = absoluteRate;
result.duration = durationInMinutes; result.duration = durationInMinutes;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
treatmentsInterface.tempBasalStart(tempBasal); treatmentsInterface.addToHistoryTempBasalStart(tempBasal);
if (Config.logPumpComm) if (Config.logPumpComm)
log.debug("Setting temp basal absolute: " + result); log.debug("Setting temp basal absolute: " + result);
MainApp.bus().post(new EventVirtualPumpUpdateGui()); MainApp.bus().post(new EventVirtualPumpUpdateGui());
@ -278,7 +277,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
result.isTempCancel = false; result.isTempCancel = false;
result.duration = durationInMinutes; result.duration = durationInMinutes;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
treatmentsInterface.tempBasalStart(tempBasal); treatmentsInterface.addToHistoryTempBasalStart(tempBasal);
if (Config.logPumpComm) if (Config.logPumpComm)
log.debug("Settings temp basal percent: " + result); log.debug("Settings temp basal percent: " + result);
MainApp.bus().post(new EventVirtualPumpUpdateGui()); MainApp.bus().post(new EventVirtualPumpUpdateGui());
@ -302,7 +301,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
result.isTempCancel = false; result.isTempCancel = false;
result.duration = durationInMinutes; result.duration = durationInMinutes;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
treatmentsInterface.extendedBolusStart(extendedBolus); treatmentsInterface.addToHistoryExtendedBolusStart(extendedBolus);
if (Config.logPumpComm) if (Config.logPumpComm)
log.debug("Setting extended bolus: " + result); log.debug("Setting extended bolus: " + result);
MainApp.bus().post(new EventVirtualPumpUpdateGui()); MainApp.bus().post(new EventVirtualPumpUpdateGui());
@ -319,7 +318,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
if (treatmentsInterface.isTempBasalInProgress()) { if (treatmentsInterface.isTempBasalInProgress()) {
result.enacted = true; result.enacted = true;
treatmentsInterface.tempBasalStop(new Date().getTime()); treatmentsInterface.addToHistoryTempBasalStop(new Date().getTime());
//tempBasal = null; //tempBasal = null;
if (Config.logPumpComm) if (Config.logPumpComm)
log.debug("Canceling temp basal: " + result); log.debug("Canceling temp basal: " + result);
@ -333,8 +332,8 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
public PumpEnactResult cancelExtendedBolus() { public PumpEnactResult cancelExtendedBolus() {
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder(); TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
if (treatmentsInterface.isExtendedBoluslInProgress()) { if (treatmentsInterface.isInHistoryExtendedBoluslInProgress()) {
treatmentsInterface.extendedBolusStop(new Date().getTime()); treatmentsInterface.addToHistoryExtendedBolusStop(new Date().getTime());
} }
result.success = true; result.success = true;
result.enacted = true; result.enacted = true;
@ -364,13 +363,13 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
try { try {
extended.put("ActiveProfile", MainApp.getConfigBuilder().getActiveProfile().getProfile().getActiveProfile()); extended.put("ActiveProfile", MainApp.getConfigBuilder().getActiveProfile().getProfile().getActiveProfile());
} catch (Exception e) {} } catch (Exception e) {}
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasal(new Date().getTime()); TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasalFromHistory(new Date().getTime());
if (tb != null) { if (tb != null) {
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(new Date().getTime())); extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(new Date().getTime()));
extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date)); extended.put("TempBasalStart", DateUtil.dateAndTimeString(tb.date));
extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes()); extended.put("TempBasalRemaining", tb.getPlannedRemainingMinutes());
} }
ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolus(new Date().getTime()); ExtendedBolus eb = MainApp.getConfigBuilder().getExtendedBolusFromHistory(new Date().getTime());
if (eb != null) { if (eb != null) {
extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate()); extended.put("ExtendedBolusAbsoluteRate", eb.absoluteRate());
extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date)); extended.put("ExtendedBolusStart", DateUtil.dateAndTimeString(eb.date));

View file

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

View file

@ -167,7 +167,7 @@ public class TreatmentsExtendedBolusesFragment extends Fragment {
llm = new LinearLayoutManager(view.getContext()); llm = new LinearLayoutManager(view.getContext());
recyclerView.setLayoutManager(llm); recyclerView.setLayoutManager(llm);
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getConfigBuilder().getExtendedBoluses()); RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getConfigBuilder().getExtendedBolusesFromHistory());
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);
context = getContext(); context = getContext();
@ -204,7 +204,7 @@ public class TreatmentsExtendedBolusesFragment extends Fragment {
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override @Override
public void run() { 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()); llm = new LinearLayoutManager(view.getContext());
recyclerView.setLayoutManager(llm); recyclerView.setLayoutManager(llm);
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getConfigBuilder().getTempTargets()); RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getConfigBuilder().getTempTargetsFromHistory());
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);
refreshFromNS = (Button) view.findViewById(R.id.temptargetrange_refreshfromnightscout); refreshFromNS = (Button) view.findViewById(R.id.temptargetrange_refreshfromnightscout);
@ -219,7 +219,7 @@ public class TreatmentsTempTargetFragment extends Fragment implements View.OnCli
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override @Override
public void run() { 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()); llm = new LinearLayoutManager(view.getContext());
recyclerView.setLayoutManager(llm); recyclerView.setLayoutManager(llm);
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getConfigBuilder().getTemporaryBasals()); RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getConfigBuilder().getTemporaryBasalsFromHistory());
recyclerView.setAdapter(adapter); recyclerView.setAdapter(adapter);
tempBasalTotalView = (TextView) view.findViewById(R.id.tempbasals_totaltempiob); tempBasalTotalView = (TextView) view.findViewById(R.id.tempbasals_totaltempiob);
@ -222,7 +222,7 @@ public class TreatmentsTemporaryBasalsFragment extends Fragment {
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {
recyclerView.swapAdapter(new RecyclerViewAdapter(MainApp.getConfigBuilder().getTemporaryBasals()), false); recyclerView.swapAdapter(new RecyclerViewAdapter(MainApp.getConfigBuilder().getTemporaryBasalsFromHistory()), false);
if (MainApp.getConfigBuilder().getLastCalculationTempBasals() != null) { if (MainApp.getConfigBuilder().getLastCalculationTempBasals() != null) {
String totalText = DecimalFormatter.to2Decimal(MainApp.getConfigBuilder().getLastCalculationTempBasals().basaliob) + " U"; String totalText = DecimalFormatter.to2Decimal(MainApp.getConfigBuilder().getLastCalculationTempBasals().basaliob) + " U";
tempBasalTotalView.setText(totalText); tempBasalTotalView.setText(totalText);

View file

@ -275,7 +275,7 @@ public class ActionStringHandler {
} }
//Check for Temp-Target: //Check for Temp-Target:
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTarget(new Date().getTime()); TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(new Date().getTime());
if (tempTarget != null) { 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 += "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()); 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 beginBasalValue = profile.getBasal(NSProfile.secondsFromMidnight(new Date(beginBasalSegmentTime)));
double endBasalValue = beginBasalValue; double endBasalValue = beginBasalValue;
TemporaryBasal tb1 = MainApp.getConfigBuilder().getTempBasal(runningTime); TemporaryBasal tb1 = MainApp.getConfigBuilder().getTempBasalFromHistory(runningTime);
TemporaryBasal tb2 = MainApp.getConfigBuilder().getTempBasal(runningTime); TemporaryBasal tb2 = MainApp.getConfigBuilder().getTempBasalFromHistory(runningTime);
double tb_before = beginBasalValue; double tb_before = beginBasalValue;
double tb_amount = beginBasalValue; double tb_amount = beginBasalValue;
long tb_start = runningTime; long tb_start = runningTime;
@ -378,7 +378,7 @@ public class WatchUpdaterService extends WearableListenerService implements
} }
//temps //temps
tb2 = MainApp.getConfigBuilder().getTempBasal(runningTime); tb2 = MainApp.getConfigBuilder().getTempBasalFromHistory(runningTime);
if (tb1 == null && tb2 == null) { if (tb1 == null && tb2 == null) {
//no temp stays no temp //no temp stays no temp
@ -411,7 +411,7 @@ public class WatchUpdaterService extends WearableListenerService implements
basals.add(basalMap(beginBasalSegmentTime, runningTime, beginBasalValue)); basals.add(basalMap(beginBasalSegmentTime, runningTime, beginBasalValue));
} }
if (tb1 != null) { 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) { if (tb2 == null) {
//express the cancelled temp by painting it down one minute early //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)); 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 { } 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) { if (tb2 != null) {
//onset at the end //onset at the end
double currentAmount = tb2.tempBasalConvertedToAbsolute(runningTime); double currentAmount = tb2.tempBasalConvertedToAbsolute(runningTime);
@ -541,7 +541,7 @@ public class WatchUpdaterService extends WearableListenerService implements
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder(); TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
if (treatmentsInterface.isTempBasalInProgress()) { if (treatmentsInterface.isTempBasalInProgress()) {
TemporaryBasal activeTemp = treatmentsInterface.getTempBasal(new Date().getTime()); TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(new Date().getTime());
if (shortString) { if (shortString) {
status += activeTemp.toStringShort(); status += activeTemp.toStringShort();
} else { } else {

View file

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