move treatments interface out of ConfigBuilder
This commit is contained in:
parent
8d35a89870
commit
0a03798de9
49 changed files with 367 additions and 492 deletions
|
@ -7,7 +7,6 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
|
@ -16,6 +15,7 @@ import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.BolusWizard;
|
import info.nightscout.utils.BolusWizard;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
@ -102,7 +102,7 @@ public class QuickWizardEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Basal IOB
|
// Basal IOB
|
||||||
TreatmentsInterface treatments = MainApp.getConfigBuilder();
|
TreatmentsInterface treatments = TreatmentsPlugin.getPlugin();
|
||||||
treatments.updateTotalIOBTempBasals();
|
treatments.updateTotalIOBTempBasals();
|
||||||
IobTotal basalIob = treatments.getLastCalculationTempBasals().round();
|
IobTotal basalIob = treatments.getLastCalculationTempBasals().round();
|
||||||
boolean basalIOB = false;
|
boolean basalIOB = false;
|
||||||
|
|
|
@ -10,7 +10,6 @@ import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
|
@ -18,6 +17,7 @@ import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.HistoryBrowseActivity;
|
import info.nightscout.androidaps.HistoryBrowseActivity;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.TDDStatsActivity;
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||||
|
@ -33,7 +33,7 @@ import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialo
|
||||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.TDDStatsActivity;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.FabricPrivacy;
|
import info.nightscout.utils.FabricPrivacy;
|
||||||
import info.nightscout.utils.SingleClickButton;
|
import info.nightscout.utils.SingleClickButton;
|
||||||
|
|
||||||
|
@ -155,7 +155,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
||||||
extendedBolus.setVisibility(View.GONE);
|
extendedBolus.setVisibility(View.GONE);
|
||||||
extendedBolusCancel.setVisibility(View.GONE);
|
extendedBolusCancel.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
ExtendedBolus activeExtendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
ExtendedBolus activeExtendedBolus = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||||
if (activeExtendedBolus != null) {
|
if (activeExtendedBolus != null) {
|
||||||
extendedBolus.setVisibility(View.GONE);
|
extendedBolus.setVisibility(View.GONE);
|
||||||
extendedBolusCancel.setVisibility(View.VISIBLE);
|
extendedBolusCancel.setVisibility(View.VISIBLE);
|
||||||
|
@ -171,7 +171,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
||||||
tempBasal.setVisibility(View.GONE);
|
tempBasal.setVisibility(View.GONE);
|
||||||
tempBasalCancel.setVisibility(View.GONE);
|
tempBasalCancel.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
final TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
tempBasal.setVisibility(View.GONE);
|
tempBasal.setVisibility(View.GONE);
|
||||||
tempBasalCancel.setVisibility(View.VISIBLE);
|
tempBasalCancel.setVisibility(View.VISIBLE);
|
||||||
|
@ -219,13 +219,13 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
||||||
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().isInHistoryExtendedBoluslInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress()) {
|
||||||
ConfigBuilderPlugin.getCommandQueue().cancelExtended(null);
|
ConfigBuilderPlugin.getCommandQueue().cancelExtended(null);
|
||||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("CancelExtended"));
|
FabricPrivacy.getInstance().logCustom(new CustomEvent("CancelExtended"));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case R.id.actions_canceltempbasal:
|
case R.id.actions_canceltempbasal:
|
||||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
|
||||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, null);
|
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, null);
|
||||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("CancelTemp"));
|
FabricPrivacy.getInstance().logCustom(new CustomEvent("CancelTemp"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.Careportal.Dialogs;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.DialogFragment;
|
import android.support.v4.app.DialogFragment;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
|
@ -50,11 +49,8 @@ import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
|
||||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.FabricPrivacy;
|
import info.nightscout.utils.FabricPrivacy;
|
||||||
import info.nightscout.utils.HardLimits;
|
import info.nightscout.utils.HardLimits;
|
||||||
|
@ -348,7 +344,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
editTimeshift = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_timeshift);
|
editTimeshift = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_timeshift);
|
||||||
editTimeshift.setParams(0d, (double) Constants.CPP_MIN_TIMESHIFT, (double) Constants.CPP_MAX_TIMESHIFT, 1d, new DecimalFormat("0"), false);
|
editTimeshift.setParams(0d, (double) Constants.CPP_MIN_TIMESHIFT, (double) Constants.CPP_MAX_TIMESHIFT, 1d, new DecimalFormat("0"), false);
|
||||||
|
|
||||||
ProfileSwitch ps = MainApp.getConfigBuilder().getProfileSwitchFromHistory(DateUtil.now());
|
ProfileSwitch ps = TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(DateUtil.now());
|
||||||
if (ps != null && ps.isCPP) {
|
if (ps != null && ps.isCPP) {
|
||||||
final int percentage = ps.percentage;
|
final int percentage = ps.percentage;
|
||||||
final int timeshift = ps.timeshift;
|
final int timeshift = ps.timeshift;
|
||||||
|
@ -740,12 +736,12 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
profileSwitch.isCPP = percentage != 100 || timeshift != 0;
|
profileSwitch.isCPP = percentage != 100 || timeshift != 0;
|
||||||
profileSwitch.timeshift = timeshift;
|
profileSwitch.timeshift = timeshift;
|
||||||
profileSwitch.percentage = percentage;
|
profileSwitch.percentage = percentage;
|
||||||
MainApp.getConfigBuilder().addToHistoryProfileSwitch(profileSwitch);
|
TreatmentsPlugin.getPlugin().addToHistoryProfileSwitch(profileSwitch);
|
||||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ProfileSwitch"));
|
FabricPrivacy.getInstance().logCustom(new CustomEvent("ProfileSwitch"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void doProfileSwitch(final int duration, final int percentage, final int timeshift) {
|
public static void doProfileSwitch(final int duration, final int percentage, final int timeshift) {
|
||||||
ProfileSwitch profileSwitch = MainApp.getConfigBuilder().getProfileSwitchFromHistory(System.currentTimeMillis());
|
ProfileSwitch profileSwitch = TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(System.currentTimeMillis());
|
||||||
if (profileSwitch != null) {
|
if (profileSwitch != null) {
|
||||||
profileSwitch = new ProfileSwitch();
|
profileSwitch = new ProfileSwitch();
|
||||||
profileSwitch.date = System.currentTimeMillis();
|
profileSwitch.date = System.currentTimeMillis();
|
||||||
|
@ -757,7 +753,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
profileSwitch.isCPP = percentage != 100 || timeshift != 0;
|
profileSwitch.isCPP = percentage != 100 || timeshift != 0;
|
||||||
profileSwitch.timeshift = timeshift;
|
profileSwitch.timeshift = timeshift;
|
||||||
profileSwitch.percentage = percentage;
|
profileSwitch.percentage = percentage;
|
||||||
MainApp.getConfigBuilder().addToHistoryProfileSwitch(profileSwitch);
|
TreatmentsPlugin.getPlugin().addToHistoryProfileSwitch(profileSwitch);
|
||||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ProfileSwitch"));
|
FabricPrivacy.getInstance().logCustom(new CustomEvent("ProfileSwitch"));
|
||||||
} else {
|
} else {
|
||||||
log.error("No profile switch existing");
|
log.error("No profile switch existing");
|
||||||
|
|
|
@ -10,7 +10,6 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.BuildConfig;
|
import info.nightscout.androidaps.BuildConfig;
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
|
@ -18,20 +17,13 @@ import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
import info.nightscout.androidaps.data.Intervals;
|
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
|
||||||
import info.nightscout.androidaps.data.MealData;
|
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.ProfileIntervals;
|
|
||||||
import info.nightscout.androidaps.data.ProfileStore;
|
import info.nightscout.androidaps.data.ProfileStore;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.CareportalEvent;
|
import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
|
||||||
import info.nightscout.androidaps.events.EventAppInitialized;
|
import info.nightscout.androidaps.events.EventAppInitialized;
|
||||||
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||||
import info.nightscout.androidaps.events.EventProfileSwitchChange;
|
import info.nightscout.androidaps.events.EventProfileSwitchChange;
|
||||||
|
@ -50,8 +42,6 @@ import info.nightscout.androidaps.plugins.Insulin.InsulinOrefRapidActingPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||||
import info.nightscout.androidaps.plugins.SensitivityOref0.SensitivityOref0Plugin;
|
import info.nightscout.androidaps.plugins.SensitivityOref0.SensitivityOref0Plugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
|
@ -64,7 +54,7 @@ import info.nightscout.utils.ToastUtils;
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
*/
|
*/
|
||||||
public class ConfigBuilderPlugin extends PluginBase implements TreatmentsInterface {
|
public class ConfigBuilderPlugin extends PluginBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(ConfigBuilderPlugin.class);
|
private static Logger log = LoggerFactory.getLogger(ConfigBuilderPlugin.class);
|
||||||
|
|
||||||
private static ConfigBuilderPlugin configBuilderPlugin;
|
private static ConfigBuilderPlugin configBuilderPlugin;
|
||||||
|
@ -459,7 +449,7 @@ public class ConfigBuilderPlugin extends PluginBase implements TreatmentsInterfa
|
||||||
log.debug("applyAPSRequest: " + request.toString());
|
log.debug("applyAPSRequest: " + request.toString());
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
TemporaryBasal activeTemp = getTempBasalFromHistory(now);
|
TemporaryBasal activeTemp = activeTreatments.getTempBasalFromHistory(now);
|
||||||
if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - pump.getBaseBasalRate()) < pump.getPumpDescription().basalStep) {
|
if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - pump.getBaseBasalRate()) < pump.getPumpDescription().basalStep) {
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
if (Config.logCongigBuilderActions)
|
if (Config.logCongigBuilderActions)
|
||||||
|
@ -496,7 +486,7 @@ public class ConfigBuilderPlugin extends PluginBase implements TreatmentsInterfa
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long lastBolusTime = getLastBolusTime();
|
long lastBolusTime = activeTreatments.getLastBolusTime();
|
||||||
if (lastBolusTime != 0 && lastBolusTime + 3 * 60 * 1000 > System.currentTimeMillis()) {
|
if (lastBolusTime != 0 && lastBolusTime + 3 * 60 * 1000 > System.currentTimeMillis()) {
|
||||||
log.debug("SMB requested but still in 3 min interval");
|
log.debug("SMB requested but still in 3 min interval");
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
|
@ -540,175 +530,6 @@ public class ConfigBuilderPlugin extends PluginBase implements TreatmentsInterfa
|
||||||
getCommandQueue().bolus(detailedBolusInfo, callback);
|
getCommandQueue().bolus(detailedBolusInfo, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ****** Treatments interface *****
|
|
||||||
@Override
|
|
||||||
public void updateTotalIOBTreatments() {
|
|
||||||
activeTreatments.updateTotalIOBTreatments();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateTotalIOBTempBasals() {
|
|
||||||
activeTreatments.updateTotalIOBTempBasals();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IobTotal getLastCalculationTreatments() {
|
|
||||||
return activeTreatments.getLastCalculationTreatments();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IobTotal getCalculationToTimeTreatments(long time) {
|
|
||||||
return activeTreatments.getCalculationToTimeTreatments(time);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IobTotal getLastCalculationTempBasals() {
|
|
||||||
return activeTreatments.getLastCalculationTempBasals();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public IobTotal getCalculationToTimeTempBasals(long time) {
|
|
||||||
return activeTreatments.getCalculationToTimeTempBasals(time);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MealData getMealData() {
|
|
||||||
return activeTreatments.getMealData();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Treatment> getTreatmentsFromHistory() {
|
|
||||||
return activeTreatments.getTreatmentsFromHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<Treatment> getTreatments5MinBackFromHistory(long time) {
|
|
||||||
return activeTreatments.getTreatments5MinBackFromHistory(time);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getLastBolusTime() {
|
|
||||||
return activeTreatments.getLastBolusTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInHistoryRealTempBasalInProgress() {
|
|
||||||
return activeTreatments.isInHistoryRealTempBasalInProgress();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public TemporaryBasal getRealTempBasalFromHistory(long time) {
|
|
||||||
return activeTreatments.getRealTempBasalFromHistory(time);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isTempBasalInProgress() {
|
|
||||||
return activeTreatments != null && activeTreatments.isTempBasalInProgress();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public TemporaryBasal getTempBasalFromHistory(long time) {
|
|
||||||
return activeTreatments != null ? activeTreatments.getTempBasalFromHistory(time) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Intervals<TemporaryBasal> getTemporaryBasalsFromHistory() {
|
|
||||||
return activeTreatments.getTemporaryBasalsFromHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addToHistoryTempBasal(TemporaryBasal tempBasal) {
|
|
||||||
boolean newRecordCreated = activeTreatments.addToHistoryTempBasal(tempBasal);
|
|
||||||
if (newRecordCreated) {
|
|
||||||
if (tempBasal.durationInMinutes == 0)
|
|
||||||
NSUpload.uploadTempBasalEnd(tempBasal.date, false, tempBasal.pumpId);
|
|
||||||
else if (tempBasal.isAbsolute)
|
|
||||||
NSUpload.uploadTempBasalStartAbsolute(tempBasal, null);
|
|
||||||
else
|
|
||||||
NSUpload.uploadTempBasalStartPercent(tempBasal);
|
|
||||||
}
|
|
||||||
return newRecordCreated;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isInHistoryExtendedBoluslInProgress() {
|
|
||||||
return activeTreatments.isInHistoryExtendedBoluslInProgress();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public ExtendedBolus getExtendedBolusFromHistory(long time) {
|
|
||||||
return activeTreatments.getExtendedBolusFromHistory(time);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean addToHistoryExtendedBolus(ExtendedBolus extendedBolus) {
|
|
||||||
boolean newRecordCreated = activeTreatments.addToHistoryExtendedBolus(extendedBolus);
|
|
||||||
if (newRecordCreated) {
|
|
||||||
if (extendedBolus.durationInMinutes == 0) {
|
|
||||||
if (activePump.isFakingTempsByExtendedBoluses())
|
|
||||||
NSUpload.uploadTempBasalEnd(extendedBolus.date, true, extendedBolus.pumpId);
|
|
||||||
else
|
|
||||||
NSUpload.uploadExtendedBolusEnd(extendedBolus.date, extendedBolus.pumpId);
|
|
||||||
} else if (activePump.isFakingTempsByExtendedBoluses())
|
|
||||||
NSUpload.uploadTempBasalStartAbsolute(new TemporaryBasal(extendedBolus), extendedBolus.insulin);
|
|
||||||
else
|
|
||||||
NSUpload.uploadExtendedBolus(extendedBolus);
|
|
||||||
}
|
|
||||||
return newRecordCreated;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Intervals<ExtendedBolus> getExtendedBolusesFromHistory() {
|
|
||||||
return activeTreatments.getExtendedBolusesFromHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
// return true if new record is created
|
|
||||||
public boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo) {
|
|
||||||
boolean newRecordCreated = activeTreatments.addToHistoryTreatment(detailedBolusInfo);
|
|
||||||
if (newRecordCreated && detailedBolusInfo.isValid)
|
|
||||||
NSUpload.uploadBolusWizardRecord(detailedBolusInfo);
|
|
||||||
return newRecordCreated;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public TempTarget getTempTargetFromHistory() {
|
|
||||||
return activeTreatments.getTempTargetFromHistory(System.currentTimeMillis());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public TempTarget getTempTargetFromHistory(long time) {
|
|
||||||
return activeTreatments.getTempTargetFromHistory(time);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Intervals<TempTarget> getTempTargetsFromHistory() {
|
|
||||||
return activeTreatments.getTempTargetsFromHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Nullable
|
|
||||||
public ProfileSwitch getProfileSwitchFromHistory(long time) {
|
|
||||||
return activeTreatments.getProfileSwitchFromHistory(time);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ProfileIntervals<ProfileSwitch> getProfileSwitchesFromHistory() {
|
|
||||||
return activeTreatments.getProfileSwitchesFromHistory();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addToHistoryProfileSwitch(ProfileSwitch profileSwitch) {
|
|
||||||
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_SWITCH_MISSING));
|
|
||||||
activeTreatments.addToHistoryProfileSwitch(profileSwitch);
|
|
||||||
NSUpload.uploadProfileSwitch(profileSwitch);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onProfileSwitch(EventProfileSwitchChange ignored) {
|
public void onProfileSwitch(EventProfileSwitchChange ignored) {
|
||||||
getCommandQueue().setProfile(getProfile(), new Callback() {
|
getCommandQueue().setProfile(getProfile(), new Callback() {
|
||||||
|
@ -727,11 +548,6 @@ public class ConfigBuilderPlugin extends PluginBase implements TreatmentsInterfa
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public long oldestDataAvailable() {
|
|
||||||
return activeTreatments.oldestDataAvailable();
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getProfileName() {
|
public String getProfileName() {
|
||||||
return getProfileName(System.currentTimeMillis());
|
return getProfileName(System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
@ -745,7 +561,7 @@ public class ConfigBuilderPlugin extends PluginBase implements TreatmentsInterfa
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProfileName(long time, boolean customized) {
|
public String getProfileName(long time, boolean customized) {
|
||||||
ProfileSwitch profileSwitch = getProfileSwitchFromHistory(time);
|
ProfileSwitch profileSwitch = activeTreatments.getProfileSwitchFromHistory(time);
|
||||||
if (profileSwitch != null) {
|
if (profileSwitch != null) {
|
||||||
if (profileSwitch.profileJson != null) {
|
if (profileSwitch.profileJson != null) {
|
||||||
return customized ? profileSwitch.getCustomizedName() : profileSwitch.profileName;
|
return customized ? profileSwitch.getCustomizedName() : profileSwitch.profileName;
|
||||||
|
@ -782,7 +598,7 @@ public class ConfigBuilderPlugin extends PluginBase implements TreatmentsInterfa
|
||||||
return null; //app not initialized
|
return null; //app not initialized
|
||||||
}
|
}
|
||||||
//log.debug("Profile for: " + new Date(time).toLocaleString() + " : " + getProfileName(time));
|
//log.debug("Profile for: " + new Date(time).toLocaleString() + " : " + getProfileName(time));
|
||||||
ProfileSwitch profileSwitch = getProfileSwitchFromHistory(time);
|
ProfileSwitch profileSwitch = activeTreatments.getProfileSwitchFromHistory(time);
|
||||||
if (profileSwitch != null) {
|
if (profileSwitch != null) {
|
||||||
if (profileSwitch.profileJson != null) {
|
if (profileSwitch.profileJson != null) {
|
||||||
return profileSwitch.getProfileObject();
|
return profileSwitch.getProfileObject();
|
||||||
|
@ -792,12 +608,12 @@ public class ConfigBuilderPlugin extends PluginBase implements TreatmentsInterfa
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (getProfileSwitchesFromHistory().size() > 0) {
|
if (activeTreatments.getProfileSwitchesFromHistory().size() > 0) {
|
||||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("CatchedError")
|
FabricPrivacy.getInstance().logCustom(new CustomEvent("CatchedError")
|
||||||
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
.putCustomAttribute("buildversion", BuildConfig.BUILDVERSION)
|
||||||
.putCustomAttribute("version", BuildConfig.VERSION)
|
.putCustomAttribute("version", BuildConfig.VERSION)
|
||||||
.putCustomAttribute("time", time)
|
.putCustomAttribute("time", time)
|
||||||
.putCustomAttribute("getProfileSwitchesFromHistory", getProfileSwitchesFromHistory().toString())
|
.putCustomAttribute("getProfileSwitchesFromHistory", activeTreatments.getProfileSwitchesFromHistory().toString())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
log.debug("getProfile at the end: returning null");
|
log.debug("getProfile at the end: returning null");
|
||||||
|
@ -814,7 +630,7 @@ public class ConfigBuilderPlugin extends PluginBase implements TreatmentsInterfa
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (getActivePump().getPumpDescription().isExtendedBolusCapable && isInHistoryExtendedBoluslInProgress()) {
|
if (getActivePump().getPumpDescription().isExtendedBolusCapable && activeTreatments.isInHistoryExtendedBoluslInProgress()) {
|
||||||
getCommandQueue().cancelExtended(new Callback() {
|
getCommandQueue().cancelExtended(new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -26,6 +26,7 @@ import info.nightscout.androidaps.plugins.ConstraintsSafety.SafetyPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
|
import info.nightscout.androidaps.plugins.NSClientInternal.NSClientPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
|
@ -130,7 +131,7 @@ public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface
|
||||||
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginType.APS))
|
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginType.APS))
|
||||||
apsEnabled = true;
|
apsEnabled = true;
|
||||||
|
|
||||||
boolean profileSwitchExists = MainApp.getConfigBuilder().getProfileSwitchFromHistory(DateUtil.now()) != null;
|
boolean profileSwitchExists = TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(DateUtil.now()) != null;
|
||||||
|
|
||||||
return new RequirementResult(hasBGData && bgIsAvailableInNS && pumpStatusIsAvailableInNS && NSClientPlugin.getPlugin().hasWritePermission() && LoopPlugin.getPlugin().isEnabled(PluginType.LOOP) && apsEnabled && vpUploadNeeded && profileSwitchExists,
|
return new RequirementResult(hasBGData && bgIsAvailableInNS && pumpStatusIsAvailableInNS && NSClientPlugin.getPlugin().hasWritePermission() && LoopPlugin.getPlugin().isEnabled(PluginType.LOOP) && apsEnabled && vpUploadNeeded && profileSwitchExists,
|
||||||
MainApp.gs(R.string.objectives_bgavailableinns) + ": " + yesOrNo(bgIsAvailableInNS)
|
MainApp.gs(R.string.objectives_bgavailableinns) + ": " + yesOrNo(bgIsAvailableInNS)
|
||||||
|
|
|
@ -34,6 +34,7 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventNewHistoryData;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSSMB.OpenAPSSMBPlugin;
|
import info.nightscout.androidaps.plugins.OpenAPSSMB.OpenAPSSMBPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -286,7 +287,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
public long oldestDataAvailable() {
|
public long oldestDataAvailable() {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
|
|
||||||
long oldestDataAvailable = MainApp.getConfigBuilder().oldestDataAvailable();
|
long oldestDataAvailable = TreatmentsPlugin.getPlugin().oldestDataAvailable();
|
||||||
long getBGDataFrom = Math.max(oldestDataAvailable, (long) (now - 60 * 60 * 1000L * (24 + MainApp.getConfigBuilder().getProfile().getDia())));
|
long getBGDataFrom = Math.max(oldestDataAvailable, (long) (now - 60 * 60 * 1000L * (24 + MainApp.getConfigBuilder().getProfile().getDia())));
|
||||||
log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString());
|
log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString());
|
||||||
return getBGDataFrom;
|
return getBGDataFrom;
|
||||||
|
@ -307,8 +308,8 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
} else {
|
} else {
|
||||||
//log.debug(">>> calculateFromTreatmentsAndTemps Cache miss " + new Date(time).toLocaleString());
|
//log.debug(">>> calculateFromTreatmentsAndTemps Cache miss " + new Date(time).toLocaleString());
|
||||||
}
|
}
|
||||||
IobTotal bolusIob = MainApp.getConfigBuilder().getCalculationToTimeTreatments(time).round();
|
IobTotal bolusIob = TreatmentsPlugin.getPlugin().getCalculationToTimeTreatments(time).round();
|
||||||
IobTotal basalIob = MainApp.getConfigBuilder().getCalculationToTimeTempBasals(time).round();
|
IobTotal basalIob = TreatmentsPlugin.getPlugin().getCalculationToTimeTempBasals(time).round();
|
||||||
if (OpenAPSSMBPlugin.getPlugin().isEnabled(PluginType.APS)) {
|
if (OpenAPSSMBPlugin.getPlugin().isEnabled(PluginType.APS)) {
|
||||||
// Add expected zere temp basal for next 240 mins
|
// Add expected zere temp basal for next 240 mins
|
||||||
IobTotal basalIobWithZeroTemp = basalIob.copy();
|
IobTotal basalIobWithZeroTemp = basalIob.copy();
|
||||||
|
@ -349,7 +350,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
if (retval == null) {
|
if (retval == null) {
|
||||||
retval = new BasalData();
|
retval = new BasalData();
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile(time);
|
Profile profile = MainApp.getConfigBuilder().getProfile(time);
|
||||||
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasalFromHistory(time);
|
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(time);
|
||||||
retval.basal = profile.getBasal(time);
|
retval.basal = profile.getBasal(time);
|
||||||
if (tb != null) {
|
if (tb != null) {
|
||||||
retval.isTempBasalRunning = true;
|
retval.isTempBasalRunning = true;
|
||||||
|
|
|
@ -4,7 +4,6 @@ import android.content.Context;
|
||||||
import android.os.PowerManager;
|
import android.os.PowerManager;
|
||||||
import android.support.v4.util.LongSparseArray;
|
import android.support.v4.util.LongSparseArray;
|
||||||
|
|
||||||
import com.crashlytics.android.Crashlytics;
|
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -24,7 +23,7 @@ import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.events.Event;
|
import info.nightscout.androidaps.events.Event;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
||||||
import info.nightscout.androidaps.queue.QueueThread;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.FabricPrivacy;
|
import info.nightscout.utils.FabricPrivacy;
|
||||||
|
|
||||||
|
@ -33,7 +32,7 @@ import info.nightscout.utils.FabricPrivacy;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class IobCobThread extends Thread {
|
public class IobCobThread extends Thread {
|
||||||
private static Logger log = LoggerFactory.getLogger(QueueThread.class);
|
private static Logger log = LoggerFactory.getLogger(IobCobThread.class);
|
||||||
private final Event cause;
|
private final Event cause;
|
||||||
|
|
||||||
private IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
private IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
||||||
|
@ -145,8 +144,8 @@ public class IobCobThread extends Thread {
|
||||||
double deviation = delta - bgi;
|
double deviation = delta - bgi;
|
||||||
double avgDeviation = Math.round((avgDelta - bgi) * 1000) / 1000;
|
double avgDeviation = Math.round((avgDelta - bgi) * 1000) / 1000;
|
||||||
|
|
||||||
double slopeFromMaxDeviation = 0;
|
double slopeFromMaxDeviation = 0;
|
||||||
double slopeFromMinDeviation = 999;
|
double slopeFromMinDeviation = 999;
|
||||||
double maxDeviation = 0;
|
double maxDeviation = 0;
|
||||||
double minDeviation = 999;
|
double minDeviation = 999;
|
||||||
|
|
||||||
|
@ -188,7 +187,7 @@ public class IobCobThread extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Treatment> recentTreatments = MainApp.getConfigBuilder().getTreatments5MinBackFromHistory(bgTime);
|
List<Treatment> recentTreatments = TreatmentsPlugin.getPlugin().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;
|
||||||
autosensData.activeCarbsList.add(new AutosensData.CarbsInPast(recentTreatments.get(ir)));
|
autosensData.activeCarbsList.add(new AutosensData.CarbsInPast(recentTreatments.get(ir)));
|
||||||
|
|
|
@ -31,6 +31,7 @@ import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugi
|
||||||
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.LoggerCallback;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.LoggerCallback;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults;
|
import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
public class DetermineBasalAdapterAMAJS {
|
public class DetermineBasalAdapterAMAJS {
|
||||||
|
@ -220,7 +221,7 @@ public class DetermineBasalAdapterAMAJS {
|
||||||
}
|
}
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasalFromHistory(now);
|
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
||||||
|
|
||||||
mCurrentTemp = new JSONObject();
|
mCurrentTemp = new JSONObject();
|
||||||
mCurrentTemp.put("temp", "absolute");
|
mCurrentTemp.put("temp", "absolute");
|
||||||
|
@ -228,7 +229,7 @@ public class DetermineBasalAdapterAMAJS {
|
||||||
mCurrentTemp.put("rate", tb != null ? tb.tempBasalConvertedToAbsolute(now, profile) : 0d);
|
mCurrentTemp.put("rate", tb != null ? tb.tempBasalConvertedToAbsolute(now, profile) : 0d);
|
||||||
|
|
||||||
// as we have non default temps longer than 30 mintues
|
// as we have non default temps longer than 30 mintues
|
||||||
TemporaryBasal tempBasal = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal tempBasal = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (tempBasal != null) {
|
if (tempBasal != null) {
|
||||||
mCurrentTemp.put("minutesrunning", tempBasal.getRealDuration());
|
mCurrentTemp.put("minutesrunning", tempBasal.getRealDuration());
|
||||||
}
|
}
|
||||||
|
@ -255,14 +256,14 @@ public class DetermineBasalAdapterAMAJS {
|
||||||
mAutosensData = new JSONObject();
|
mAutosensData = new JSONObject();
|
||||||
mAutosensData.put("ratio", autosensDataRatio);
|
mAutosensData.put("ratio", autosensDataRatio);
|
||||||
} else {
|
} else {
|
||||||
mAutosensData = null;
|
mAutosensData = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Object makeParam(JSONObject jsonObject, Context rhino, Scriptable scope) {
|
public Object makeParam(JSONObject jsonObject, Context rhino, Scriptable scope) {
|
||||||
|
|
||||||
if(jsonObject == null) return Undefined.instance;
|
if (jsonObject == null) return Undefined.instance;
|
||||||
|
|
||||||
Object param = NativeJSON.parse(rhino, scope, jsonObject.toString(), new Callable() {
|
Object param = NativeJSON.parse(rhino, scope, jsonObject.toString(), new Callable() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -274,8 +275,8 @@ public class DetermineBasalAdapterAMAJS {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object makeParamArray(JSONArray jsonArray, Context rhino, Scriptable scope) {
|
public Object makeParamArray(JSONArray jsonArray, Context rhino, Scriptable scope) {
|
||||||
//Object param = NativeJSON.parse(rhino, scope, "{myarray: " + jsonArray.toString() + " }", new Callable() {
|
//Object param = NativeJSON.parse(rhino, scope, "{myarray: " + jsonArray.toString() + " }", new Callable() {
|
||||||
Object param = NativeJSON.parse(rhino, scope, jsonArray.toString(), new Callable() {
|
Object param = NativeJSON.parse(rhino, scope, jsonArray.toString(), new Callable() {
|
||||||
@Override
|
@Override
|
||||||
public Object call(Context context, Scriptable scriptable, Scriptable scriptable1, Object[] objects) {
|
public Object call(Context context, Scriptable scriptable, Scriptable scriptable1, Object[] objects) {
|
||||||
return objects[1];
|
return objects[1];
|
||||||
|
|
|
@ -28,6 +28,7 @@ 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.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.HardLimits;
|
import info.nightscout.utils.HardLimits;
|
||||||
import info.nightscout.utils.Profiler;
|
import info.nightscout.utils.Profiler;
|
||||||
|
@ -139,7 +140,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
||||||
Profiler.log(log, "calculateIobArrayInDia()", startPart);
|
Profiler.log(log, "calculateIobArrayInDia()", startPart);
|
||||||
|
|
||||||
startPart = new Date();
|
startPart = new Date();
|
||||||
MealData mealData = MainApp.getConfigBuilder().getMealData();
|
MealData mealData = TreatmentsPlugin.getPlugin().getMealData();
|
||||||
Profiler.log(log, "getMealData()", startPart);
|
Profiler.log(log, "getMealData()", startPart);
|
||||||
|
|
||||||
double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value();
|
double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value();
|
||||||
|
@ -149,7 +150,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
||||||
targetBg = HardLimits.verifyHardLimits(targetBg, "targetBg", HardLimits.VERY_HARD_LIMIT_TARGET_BG[0], HardLimits.VERY_HARD_LIMIT_TARGET_BG[1]);
|
targetBg = HardLimits.verifyHardLimits(targetBg, "targetBg", HardLimits.VERY_HARD_LIMIT_TARGET_BG[0], HardLimits.VERY_HARD_LIMIT_TARGET_BG[1]);
|
||||||
|
|
||||||
boolean isTempTarget = false;
|
boolean isTempTarget = false;
|
||||||
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(System.currentTimeMillis());
|
TempTarget tempTarget = TreatmentsPlugin.getPlugin().getTempTargetFromHistory(System.currentTimeMillis());
|
||||||
if (tempTarget != null) {
|
if (tempTarget != null) {
|
||||||
isTempTarget = true;
|
isTempTarget = true;
|
||||||
minBg = HardLimits.verifyHardLimits(tempTarget.low, "minBg", HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[1]);
|
minBg = HardLimits.verifyHardLimits(tempTarget.low, "minBg", HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[1]);
|
||||||
|
@ -193,12 +194,12 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
||||||
DetermineBasalResultAMA determineBasalResultAMA = determineBasalAdapterAMAJS.invoke();
|
DetermineBasalResultAMA determineBasalResultAMA = determineBasalAdapterAMAJS.invoke();
|
||||||
Profiler.log(log, "AMA calculation", start);
|
Profiler.log(log, "AMA calculation", start);
|
||||||
// Fix bug determine basal
|
// Fix bug determine basal
|
||||||
if (determineBasalResultAMA.rate == 0d && determineBasalResultAMA.duration == 0 && !MainApp.getConfigBuilder().isTempBasalInProgress())
|
if (determineBasalResultAMA.rate == 0d && determineBasalResultAMA.duration == 0 && !TreatmentsPlugin.getPlugin().isTempBasalInProgress())
|
||||||
determineBasalResultAMA.tempBasalRequested = false;
|
determineBasalResultAMA.tempBasalRequested = false;
|
||||||
// limit requests on openloop mode
|
// limit requests on openloop mode
|
||||||
if (!MainApp.getConstraintChecker().isClosedLoopAllowed().value()) {
|
if (!MainApp.getConstraintChecker().isClosedLoopAllowed().value()) {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(now);
|
TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
||||||
if (activeTemp != null && determineBasalResultAMA.rate == 0 && determineBasalResultAMA.duration == 0) {
|
if (activeTemp != null && determineBasalResultAMA.rate == 0 && determineBasalResultAMA.duration == 0) {
|
||||||
// going to cancel
|
// going to cancel
|
||||||
} else if (activeTemp != null && Math.abs(determineBasalResultAMA.rate - activeTemp.tempBasalConvertedToAbsolute(now, profile)) < 0.1) {
|
} else if (activeTemp != null && Math.abs(determineBasalResultAMA.rate - activeTemp.tempBasalConvertedToAbsolute(now, profile)) < 0.1) {
|
||||||
|
|
|
@ -18,13 +18,13 @@ import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.MealData;
|
import info.nightscout.androidaps.data.MealData;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
public class DetermineBasalAdapterMAJS {
|
public class DetermineBasalAdapterMAJS {
|
||||||
|
@ -181,7 +181,7 @@ public class DetermineBasalAdapterMAJS {
|
||||||
}
|
}
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasalFromHistory(now);
|
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
||||||
|
|
||||||
mCurrentTemp = new JSONObject();
|
mCurrentTemp = new JSONObject();
|
||||||
mCurrentTemp.put("duration", tb != null ? tb.getPlannedRemainingMinutes() : 0);
|
mCurrentTemp.put("duration", tb != null ? tb.getPlannedRemainingMinutes() : 0);
|
||||||
|
|
|
@ -26,6 +26,7 @@ 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.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.HardLimits;
|
import info.nightscout.utils.HardLimits;
|
||||||
import info.nightscout.utils.Profiler;
|
import info.nightscout.utils.Profiler;
|
||||||
|
@ -135,14 +136,14 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||||
maxBg = Round.roundTo(maxBg, 0.1d);
|
maxBg = Round.roundTo(maxBg, 0.1d);
|
||||||
|
|
||||||
Date start = new Date();
|
Date start = new Date();
|
||||||
MainApp.getConfigBuilder().updateTotalIOBTreatments();
|
TreatmentsPlugin.getPlugin().updateTotalIOBTreatments();
|
||||||
MainApp.getConfigBuilder().updateTotalIOBTempBasals();
|
TreatmentsPlugin.getPlugin().updateTotalIOBTempBasals();
|
||||||
IobTotal bolusIob = MainApp.getConfigBuilder().getLastCalculationTreatments();
|
IobTotal bolusIob = TreatmentsPlugin.getPlugin().getLastCalculationTreatments();
|
||||||
IobTotal basalIob = MainApp.getConfigBuilder().getLastCalculationTempBasals();
|
IobTotal basalIob = TreatmentsPlugin.getPlugin().getLastCalculationTempBasals();
|
||||||
|
|
||||||
IobTotal iobTotal = IobTotal.combine(bolusIob, basalIob).round();
|
IobTotal iobTotal = IobTotal.combine(bolusIob, basalIob).round();
|
||||||
|
|
||||||
MealData mealData = MainApp.getConfigBuilder().getMealData();
|
MealData mealData = TreatmentsPlugin.getPlugin().getMealData();
|
||||||
|
|
||||||
double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value();
|
double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value();
|
||||||
Profiler.log(log, "MA data gathering", start);
|
Profiler.log(log, "MA data gathering", start);
|
||||||
|
@ -151,7 +152,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||||
maxBg = verifyHardLimits(maxBg, "maxBg", HardLimits.VERY_HARD_LIMIT_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_MAX_BG[1]);
|
maxBg = verifyHardLimits(maxBg, "maxBg", HardLimits.VERY_HARD_LIMIT_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_MAX_BG[1]);
|
||||||
targetBg = verifyHardLimits(targetBg, "targetBg", HardLimits.VERY_HARD_LIMIT_TARGET_BG[0], HardLimits.VERY_HARD_LIMIT_TARGET_BG[1]);
|
targetBg = verifyHardLimits(targetBg, "targetBg", HardLimits.VERY_HARD_LIMIT_TARGET_BG[0], HardLimits.VERY_HARD_LIMIT_TARGET_BG[1]);
|
||||||
|
|
||||||
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(System.currentTimeMillis());
|
TempTarget tempTarget = TreatmentsPlugin.getPlugin().getTempTargetFromHistory(System.currentTimeMillis());
|
||||||
if (tempTarget != null) {
|
if (tempTarget != null) {
|
||||||
minBg = verifyHardLimits(tempTarget.low, "minBg", HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[1]);
|
minBg = verifyHardLimits(tempTarget.low, "minBg", HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[1]);
|
||||||
maxBg = verifyHardLimits(tempTarget.high, "maxBg", HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[1]);
|
maxBg = verifyHardLimits(tempTarget.high, "maxBg", HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MAX_BG[1]);
|
||||||
|
@ -182,11 +183,11 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||||
|
|
||||||
DetermineBasalResultMA determineBasalResultMA = determineBasalAdapterMAJS.invoke();
|
DetermineBasalResultMA determineBasalResultMA = determineBasalAdapterMAJS.invoke();
|
||||||
// Fix bug determinef basal
|
// Fix bug determinef basal
|
||||||
if (determineBasalResultMA.rate == 0d && determineBasalResultMA.duration == 0 && !MainApp.getConfigBuilder().isTempBasalInProgress())
|
if (determineBasalResultMA.rate == 0d && determineBasalResultMA.duration == 0 && !TreatmentsPlugin.getPlugin().isTempBasalInProgress())
|
||||||
determineBasalResultMA.tempBasalRequested = false;
|
determineBasalResultMA.tempBasalRequested = false;
|
||||||
// limit requests on openloop mode
|
// limit requests on openloop mode
|
||||||
if (!MainApp.getConstraintChecker().isClosedLoopAllowed().value()) {
|
if (!MainApp.getConstraintChecker().isClosedLoopAllowed().value()) {
|
||||||
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(now);
|
TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
||||||
if (activeTemp != null && determineBasalResultMA.rate == 0 && determineBasalResultMA.duration == 0) {
|
if (activeTemp != null && determineBasalResultMA.rate == 0 && determineBasalResultMA.duration == 0) {
|
||||||
// going to cancel
|
// going to cancel
|
||||||
} else if (activeTemp != null && Math.abs(determineBasalResultMA.rate - activeTemp.tempBasalConvertedToAbsolute(now, profile)) < 0.1) {
|
} else if (activeTemp != null && Math.abs(determineBasalResultMA.rate - activeTemp.tempBasalConvertedToAbsolute(now, profile)) < 0.1) {
|
||||||
|
|
|
@ -27,10 +27,10 @@ import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.MealData;
|
import info.nightscout.androidaps.data.MealData;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.LoggerCallback;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.LoggerCallback;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
import info.nightscout.utils.SafeParse;
|
import info.nightscout.utils.SafeParse;
|
||||||
|
|
||||||
|
@ -244,7 +244,8 @@ public class DetermineBasalAdapterSMBJS {
|
||||||
mProfile.put("maxCOB", SMBDefaults.maxCOB);
|
mProfile.put("maxCOB", SMBDefaults.maxCOB);
|
||||||
mProfile.put("skip_neutral_temps", SMBDefaults.skip_neutral_temps);
|
mProfile.put("skip_neutral_temps", SMBDefaults.skip_neutral_temps);
|
||||||
//TODO: align with max-absorption model in AMA sensitivity
|
//TODO: align with max-absorption model in AMA sensitivity
|
||||||
mProfile.put("min_5m_carbimpact", SP.getDouble("openapsama_min_5m_carbimpact", SMBDefaults.min_5m_carbimpact));;
|
mProfile.put("min_5m_carbimpact", SP.getDouble("openapsama_min_5m_carbimpact", SMBDefaults.min_5m_carbimpact));
|
||||||
|
;
|
||||||
mProfile.put("remainingCarbsCap", SMBDefaults.remainingCarbsCap);
|
mProfile.put("remainingCarbsCap", SMBDefaults.remainingCarbsCap);
|
||||||
mProfile.put("enableUAM", SP.getBoolean(R.string.key_use_uam, false));
|
mProfile.put("enableUAM", SP.getBoolean(R.string.key_use_uam, false));
|
||||||
mProfile.put("A52_risk_enable", SMBDefaults.A52_risk_enable);
|
mProfile.put("A52_risk_enable", SMBDefaults.A52_risk_enable);
|
||||||
|
@ -266,7 +267,7 @@ public class DetermineBasalAdapterSMBJS {
|
||||||
|
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasalFromHistory(now);
|
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
||||||
|
|
||||||
mCurrentTemp = new JSONObject();
|
mCurrentTemp = new JSONObject();
|
||||||
mCurrentTemp.put("temp", "absolute");
|
mCurrentTemp.put("temp", "absolute");
|
||||||
|
@ -274,7 +275,7 @@ public class DetermineBasalAdapterSMBJS {
|
||||||
mCurrentTemp.put("rate", tb != null ? tb.tempBasalConvertedToAbsolute(now, profile) : 0d);
|
mCurrentTemp.put("rate", tb != null ? tb.tempBasalConvertedToAbsolute(now, profile) : 0d);
|
||||||
|
|
||||||
// as we have non default temps longer than 30 mintues
|
// as we have non default temps longer than 30 mintues
|
||||||
TemporaryBasal tempBasal = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal tempBasal = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (tempBasal != null) {
|
if (tempBasal != null) {
|
||||||
mCurrentTemp.put("minutesrunning", tempBasal.getRealDuration());
|
mCurrentTemp.put("minutesrunning", tempBasal.getRealDuration());
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ 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.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
||||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
|
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.HardLimits;
|
import info.nightscout.utils.HardLimits;
|
||||||
import info.nightscout.utils.NSUpload;
|
import info.nightscout.utils.NSUpload;
|
||||||
|
@ -146,7 +147,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
|
||||||
Profiler.log(log, "calculateIobArrayInDia()", startPart);
|
Profiler.log(log, "calculateIobArrayInDia()", startPart);
|
||||||
|
|
||||||
startPart = new Date();
|
startPart = new Date();
|
||||||
MealData mealData = MainApp.getConfigBuilder().getMealData();
|
MealData mealData = TreatmentsPlugin.getPlugin().getMealData();
|
||||||
Profiler.log(log, "getMealData()", startPart);
|
Profiler.log(log, "getMealData()", startPart);
|
||||||
|
|
||||||
double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value();
|
double maxIob = MainApp.getConstraintChecker().getMaxIOBAllowed().value();
|
||||||
|
@ -156,7 +157,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
|
||||||
targetBg = verifyHardLimits(targetBg, "targetBg", HardLimits.VERY_HARD_LIMIT_TARGET_BG[0], HardLimits.VERY_HARD_LIMIT_TARGET_BG[1]);
|
targetBg = verifyHardLimits(targetBg, "targetBg", HardLimits.VERY_HARD_LIMIT_TARGET_BG[0], HardLimits.VERY_HARD_LIMIT_TARGET_BG[1]);
|
||||||
|
|
||||||
boolean isTempTarget = false;
|
boolean isTempTarget = false;
|
||||||
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(System.currentTimeMillis());
|
TempTarget tempTarget = TreatmentsPlugin.getPlugin().getTempTargetFromHistory(System.currentTimeMillis());
|
||||||
if (tempTarget != null) {
|
if (tempTarget != null) {
|
||||||
isTempTarget = true;
|
isTempTarget = true;
|
||||||
minBg = verifyHardLimits(tempTarget.low, "minBg", HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[1]);
|
minBg = verifyHardLimits(tempTarget.low, "minBg", HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_TEMP_MIN_BG[1]);
|
||||||
|
@ -213,11 +214,11 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface {
|
||||||
Profiler.log(log, "SMB calculation", start);
|
Profiler.log(log, "SMB calculation", start);
|
||||||
// TODO still needed with oref1?
|
// TODO still needed with oref1?
|
||||||
// Fix bug determine basal
|
// Fix bug determine basal
|
||||||
if (determineBasalResultSMB.rate == 0d && determineBasalResultSMB.duration == 0 && !MainApp.getConfigBuilder().isTempBasalInProgress())
|
if (determineBasalResultSMB.rate == 0d && determineBasalResultSMB.duration == 0 && !TreatmentsPlugin.getPlugin().isTempBasalInProgress())
|
||||||
determineBasalResultSMB.tempBasalRequested = false;
|
determineBasalResultSMB.tempBasalRequested = false;
|
||||||
// limit requests on openloop mode
|
// limit requests on openloop mode
|
||||||
if (!MainApp.getConstraintChecker().isClosedLoopAllowed().value()) {
|
if (!MainApp.getConstraintChecker().isClosedLoopAllowed().value()) {
|
||||||
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(now);
|
TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
||||||
if (activeTemp != null && determineBasalResultSMB.rate == 0 && determineBasalResultSMB.duration == 0) {
|
if (activeTemp != null && determineBasalResultSMB.rate == 0 && determineBasalResultSMB.duration == 0) {
|
||||||
// going to cancel
|
// going to cancel
|
||||||
} else if (activeTemp != null && Math.abs(determineBasalResultSMB.rate - activeTemp.tempBasalConvertedToAbsolute(now, profile)) < 0.1) {
|
} else if (activeTemp != null && Math.abs(determineBasalResultSMB.rate - activeTemp.tempBasalConvertedToAbsolute(now, profile)) < 0.1) {
|
||||||
|
|
|
@ -45,6 +45,7 @@ import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
@ -430,7 +431,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, D
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ import com.wdullaer.materialdatetimepicker.time.TimePickerDialog;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
@ -45,6 +44,7 @@ import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
@ -301,7 +301,7 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener,
|
||||||
detailedBolusInfo.date = eventTime.getTime();
|
detailedBolusInfo.date = eventTime.getTime();
|
||||||
detailedBolusInfo.eventType = CareportalEvent.CORRECTIONBOLUS;
|
detailedBolusInfo.eventType = CareportalEvent.CORRECTIONBOLUS;
|
||||||
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
||||||
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||||
} else {
|
} else {
|
||||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||||
detailedBolusInfo.eventType = CareportalEvent.CORRECTIONBOLUS;
|
detailedBolusInfo.eventType = CareportalEvent.CORRECTIONBOLUS;
|
||||||
|
|
|
@ -33,6 +33,7 @@ import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.utils.FabricPrivacy;
|
import info.nightscout.utils.FabricPrivacy;
|
||||||
import info.nightscout.utils.NumberPicker;
|
import info.nightscout.utils.NumberPicker;
|
||||||
|
@ -185,7 +186,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||||
}
|
}
|
||||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("Bolus"));
|
FabricPrivacy.getInstance().logCustom(new CustomEvent("Bolus"));
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,6 +58,7 @@ import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.utils.BolusWizard;
|
import info.nightscout.utils.BolusWizard;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
@ -255,7 +256,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
@Override
|
@Override
|
||||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
saveCheckedStates();
|
saveCheckedStates();
|
||||||
ttCheckbox.setEnabled(bgCheckbox.isChecked() && MainApp.getConfigBuilder().getTempTargetFromHistory() != null);
|
ttCheckbox.setEnabled(bgCheckbox.isChecked() && TreatmentsPlugin.getPlugin().getTempTargetFromHistory() != null);
|
||||||
calculateInsulin();
|
calculateInsulin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -377,7 +378,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||||
}
|
}
|
||||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("Wizard"));
|
FabricPrivacy.getInstance().logCustom(new CustomEvent("Wizard"));
|
||||||
}
|
}
|
||||||
|
@ -426,13 +427,13 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
} else {
|
} else {
|
||||||
editBg.setValue(0d);
|
editBg.setValue(0d);
|
||||||
}
|
}
|
||||||
ttCheckbox.setEnabled(MainApp.getConfigBuilder().getTempTargetFromHistory() != null);
|
ttCheckbox.setEnabled(TreatmentsPlugin.getPlugin().getTempTargetFromHistory() != null);
|
||||||
|
|
||||||
// IOB calculation
|
// IOB calculation
|
||||||
MainApp.getConfigBuilder().updateTotalIOBTreatments();
|
TreatmentsPlugin.getPlugin().updateTotalIOBTreatments();
|
||||||
IobTotal bolusIob = MainApp.getConfigBuilder().getLastCalculationTreatments().round();
|
IobTotal bolusIob = TreatmentsPlugin.getPlugin().getLastCalculationTreatments().round();
|
||||||
MainApp.getConfigBuilder().updateTotalIOBTempBasals();
|
TreatmentsPlugin.getPlugin().updateTotalIOBTempBasals();
|
||||||
IobTotal basalIob = MainApp.getConfigBuilder().getLastCalculationTempBasals().round();
|
IobTotal basalIob = TreatmentsPlugin.getPlugin().getLastCalculationTempBasals().round();
|
||||||
|
|
||||||
bolusIobInsulin.setText(DecimalFormatter.to2Decimal(-bolusIob.iob) + "U");
|
bolusIobInsulin.setText(DecimalFormatter.to2Decimal(-bolusIob.iob) + "U");
|
||||||
basalIobInsulin.setText(DecimalFormatter.to2Decimal(-basalIob.basaliob) + "U");
|
basalIobInsulin.setText(DecimalFormatter.to2Decimal(-basalIob.basaliob) + "U");
|
||||||
|
@ -457,7 +458,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
Double c_correction = SafeParse.stringToDouble(editCorr.getText());
|
Double c_correction = SafeParse.stringToDouble(editCorr.getText());
|
||||||
Double corrAfterConstraint = c_correction;
|
Double corrAfterConstraint = c_correction;
|
||||||
if (c_correction > 0)
|
if (c_correction > 0)
|
||||||
c_correction = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(c_correction)).value();
|
c_correction = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(c_correction)).value();
|
||||||
if (c_correction - corrAfterConstraint != 0) { // c_correction != corrAfterConstraint doesn't work
|
if (c_correction - corrAfterConstraint != 0) { // c_correction != corrAfterConstraint doesn't work
|
||||||
editCorr.setValue(0d);
|
editCorr.setValue(0d);
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), getString(R.string.bolusconstraintapplied));
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), getString(R.string.bolusconstraintapplied));
|
||||||
|
@ -471,14 +472,14 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
}
|
}
|
||||||
|
|
||||||
c_bg = bgCheckbox.isChecked() ? c_bg : 0d;
|
c_bg = bgCheckbox.isChecked() ? c_bg : 0d;
|
||||||
TempTarget tempTarget = ttCheckbox.isChecked() ? MainApp.getConfigBuilder().getTempTargetFromHistory() : null;
|
TempTarget tempTarget = ttCheckbox.isChecked() ? TreatmentsPlugin.getPlugin().getTempTargetFromHistory() : null;
|
||||||
|
|
||||||
// COB
|
// COB
|
||||||
Double c_cob = 0d;
|
Double c_cob = 0d;
|
||||||
if (cobCheckbox.isChecked()) {
|
if (cobCheckbox.isChecked()) {
|
||||||
AutosensData autosensData = IobCobCalculatorPlugin.getPlugin().getLastAutosensData("Wizard COB");
|
AutosensData autosensData = IobCobCalculatorPlugin.getPlugin().getLastAutosensData("Wizard COB");
|
||||||
|
|
||||||
if(autosensData != null) {
|
if (autosensData != null) {
|
||||||
c_cob = autosensData.cob;
|
c_cob = autosensData.cob;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -84,10 +84,10 @@ import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.events.EventTempTargetChange;
|
import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||||
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
|
||||||
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||||
|
@ -114,6 +114,7 @@ import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.NotificationStore;
|
import info.nightscout.androidaps.plugins.Overview.notifications.NotificationStore;
|
||||||
import info.nightscout.androidaps.plugins.Source.SourceDexcomG5Plugin;
|
import info.nightscout.androidaps.plugins.Source.SourceDexcomG5Plugin;
|
||||||
import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
|
import info.nightscout.androidaps.plugins.Source.SourceXdripPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Treatments.fragments.ProfileViewerDialog;
|
import info.nightscout.androidaps.plugins.Treatments.fragments.ProfileViewerDialog;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.utils.BolusWizard;
|
import info.nightscout.utils.BolusWizard;
|
||||||
|
@ -188,7 +189,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
|
|
||||||
final Object updateSync = new Object();
|
final Object updateSync = new Object();
|
||||||
|
|
||||||
public enum CHARTTYPE {PRE, BAS, IOB, COB, DEV, SEN};
|
public enum CHARTTYPE {PRE, BAS, IOB, COB, DEV, SEN}
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
|
private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
|
||||||
private static ScheduledFuture<?> scheduledUpdate = null;
|
private static ScheduledFuture<?> scheduledUpdate = null;
|
||||||
|
@ -709,7 +712,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
void onClickQuickwizard() {
|
void onClickQuickwizard() {
|
||||||
final BgReading actualBg = DatabaseHelper.actualBg();
|
final BgReading actualBg = DatabaseHelper.actualBg();
|
||||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
final TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory();
|
final TempTarget tempTarget = TreatmentsPlugin.getPlugin().getTempTargetFromHistory();
|
||||||
|
|
||||||
final QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
|
final QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
|
||||||
if (quickWizardEntry != null && actualBg != null && profile != null) {
|
if (quickWizardEntry != null && actualBg != null && profile != null) {
|
||||||
|
@ -1072,7 +1075,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
// temp target
|
// temp target
|
||||||
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory();
|
TempTarget tempTarget = TreatmentsPlugin.getPlugin().getTempTargetFromHistory();
|
||||||
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));
|
||||||
|
@ -1121,7 +1124,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
final TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
String basalText = "";
|
String basalText = "";
|
||||||
if (shorttextmode) {
|
if (shorttextmode) {
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
|
@ -1159,7 +1162,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
|
|
||||||
baseBasalView.setText(basalText);
|
baseBasalView.setText(basalText);
|
||||||
|
|
||||||
final ExtendedBolus extendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
final ExtendedBolus extendedBolus = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||||
String extendedBolusText = "";
|
String extendedBolusText = "";
|
||||||
if (extendedBolusView != null) { // must not exists in all layouts
|
if (extendedBolusView != null) { // must not exists in all layouts
|
||||||
if (shorttextmode) {
|
if (shorttextmode) {
|
||||||
|
@ -1265,10 +1268,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
timeAgoView.setText(DateUtil.minAgo(lastBG.date));
|
timeAgoView.setText(DateUtil.minAgo(lastBG.date));
|
||||||
|
|
||||||
// iob
|
// iob
|
||||||
MainApp.getConfigBuilder().updateTotalIOBTreatments();
|
TreatmentsPlugin.getPlugin().updateTotalIOBTreatments();
|
||||||
MainApp.getConfigBuilder().updateTotalIOBTempBasals();
|
TreatmentsPlugin.getPlugin().updateTotalIOBTempBasals();
|
||||||
final IobTotal bolusIob = MainApp.getConfigBuilder().getLastCalculationTreatments().round();
|
final IobTotal bolusIob = TreatmentsPlugin.getPlugin().getLastCalculationTreatments().round();
|
||||||
final IobTotal basalIob = MainApp.getConfigBuilder().getLastCalculationTempBasals().round();
|
final IobTotal basalIob = TreatmentsPlugin.getPlugin().getLastCalculationTempBasals().round();
|
||||||
|
|
||||||
if (shorttextmode) {
|
if (shorttextmode) {
|
||||||
String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U";
|
String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U";
|
||||||
|
|
|
@ -26,8 +26,8 @@ import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.db.Treatment;
|
import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.BasalData;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.BasalData;
|
||||||
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.AreaGraphSeries;
|
import info.nightscout.androidaps.plugins.Overview.graphExtensions.AreaGraphSeries;
|
||||||
|
@ -242,7 +242,7 @@ public class GraphData {
|
||||||
TempTarget tt = TreatmentsPlugin.getPlugin().getTempTargetFromHistory(time);
|
TempTarget tt = TreatmentsPlugin.getPlugin().getTempTargetFromHistory(time);
|
||||||
double value;
|
double value;
|
||||||
if (tt == null) {
|
if (tt == null) {
|
||||||
value = (profile.getTargetLow(time) + profile.getTargetHigh(time)) / 2;
|
value = (profile.getTargetLow(time) + profile.getTargetHigh(time)) / 2;
|
||||||
} else {
|
} else {
|
||||||
value = tt.target();
|
value = tt.target();
|
||||||
value = Profile.fromMgdlToUnits(value, profile.getUnits());
|
value = Profile.fromMgdlToUnits(value, profile.getUnits());
|
||||||
|
@ -268,7 +268,7 @@ public class GraphData {
|
||||||
public void addTreatments(long fromTime, long endTime) {
|
public void addTreatments(long fromTime, long endTime) {
|
||||||
List<DataPointWithLabelInterface> filteredTreatments = new ArrayList<>();
|
List<DataPointWithLabelInterface> filteredTreatments = new ArrayList<>();
|
||||||
|
|
||||||
List<Treatment> treatments = MainApp.getConfigBuilder().getTreatmentsFromHistory();
|
List<Treatment> treatments = TreatmentsPlugin.getPlugin().getTreatmentsFromHistory();
|
||||||
|
|
||||||
for (int tx = 0; tx < treatments.size(); tx++) {
|
for (int tx = 0; tx < treatments.size(); tx++) {
|
||||||
Treatment t = treatments.get(tx);
|
Treatment t = treatments.get(tx);
|
||||||
|
@ -278,7 +278,7 @@ public class GraphData {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ProfileSwitch
|
// ProfileSwitch
|
||||||
List<ProfileSwitch> profileSwitches = MainApp.getConfigBuilder().getProfileSwitchesFromHistory().getList();
|
List<ProfileSwitch> profileSwitches = TreatmentsPlugin.getPlugin().getProfileSwitchesFromHistory().getList();
|
||||||
|
|
||||||
for (int tx = 0; tx < profileSwitches.size(); tx++) {
|
for (int tx = 0; tx < profileSwitches.size(); tx++) {
|
||||||
DataPointWithLabelInterface t = profileSwitches.get(tx);
|
DataPointWithLabelInterface t = profileSwitches.get(tx);
|
||||||
|
@ -288,7 +288,7 @@ public class GraphData {
|
||||||
|
|
||||||
// Extended bolus
|
// Extended bolus
|
||||||
if (!ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) {
|
if (!ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) {
|
||||||
List<ExtendedBolus> extendedBoluses = MainApp.getConfigBuilder().getExtendedBolusesFromHistory().getList();
|
List<ExtendedBolus> extendedBoluses = TreatmentsPlugin.getPlugin().getExtendedBolusesFromHistory().getList();
|
||||||
|
|
||||||
for (int tx = 0; tx < extendedBoluses.size(); tx++) {
|
for (int tx = 0; tx < extendedBoluses.size(); tx++) {
|
||||||
DataPointWithLabelInterface t = extendedBoluses.get(tx);
|
DataPointWithLabelInterface t = extendedBoluses.get(tx);
|
||||||
|
@ -556,15 +556,15 @@ public class GraphData {
|
||||||
public void performUpdate() {
|
public void performUpdate() {
|
||||||
// clear old data
|
// clear old data
|
||||||
graph.getSeries().clear();
|
graph.getSeries().clear();
|
||||||
|
|
||||||
// add precalculated series
|
// add precalculated series
|
||||||
for (Series s: series) {
|
for (Series s : series) {
|
||||||
if (!s.isEmpty()) {
|
if (!s.isEmpty()) {
|
||||||
s.onGraphViewAttached(graph);
|
s.onGraphViewAttached(graph);
|
||||||
graph.getSeries().add(s);
|
graph.getSeries().add(s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// draw it
|
// draw it
|
||||||
graph.onDataChanged(false, false);
|
graph.onDataChanged(false, false);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -94,16 +95,16 @@ public class PersistentNotificationPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
line1 += " " + activeTemp.toStringShort();
|
line1 += " " + activeTemp.toStringShort();
|
||||||
}
|
}
|
||||||
|
|
||||||
//IOB
|
//IOB
|
||||||
MainApp.getConfigBuilder().updateTotalIOBTreatments();
|
TreatmentsPlugin.getPlugin().updateTotalIOBTreatments();
|
||||||
MainApp.getConfigBuilder().updateTotalIOBTempBasals();
|
TreatmentsPlugin.getPlugin().updateTotalIOBTempBasals();
|
||||||
IobTotal bolusIob = MainApp.getConfigBuilder().getLastCalculationTreatments().round();
|
IobTotal bolusIob = TreatmentsPlugin.getPlugin().getLastCalculationTreatments().round();
|
||||||
IobTotal basalIob = MainApp.getConfigBuilder().getLastCalculationTempBasals().round();
|
IobTotal basalIob = TreatmentsPlugin.getPlugin().getLastCalculationTempBasals().round();
|
||||||
|
|
||||||
String line2 = ctx.getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
|
String line2 = ctx.getString(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
|
||||||
+ ctx.getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
|
+ ctx.getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
|
||||||
|
|
|
@ -56,6 +56,7 @@ import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Bolus;
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistory;
|
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistory;
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistoryRequest;
|
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.PumpHistoryRequest;
|
||||||
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Tdd;
|
import info.nightscout.androidaps.plugins.PumpCombo.ruffyscripter.history.Tdd;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.androidaps.queue.CommandQueue;
|
import info.nightscout.androidaps.queue.CommandQueue;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
@ -462,7 +463,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
return deliverBolus(detailedBolusInfo);
|
return deliverBolus(detailedBolusInfo);
|
||||||
} else {
|
} else {
|
||||||
// no bolus required, carb only treatment
|
// no bolus required, carb only treatment
|
||||||
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||||
|
|
||||||
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance();
|
||||||
bolusingEvent.t = new Treatment();
|
bolusingEvent.t = new Treatment();
|
||||||
|
@ -651,7 +652,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
dbi.source = Source.PUMP;
|
dbi.source = Source.PUMP;
|
||||||
dbi.insulin = lastPumpBolus.amount;
|
dbi.insulin = lastPumpBolus.amount;
|
||||||
try {
|
try {
|
||||||
boolean treatmentCreated = MainApp.getConfigBuilder().addToHistoryTreatment(dbi);
|
boolean treatmentCreated = TreatmentsPlugin.getPlugin().addToHistoryTreatment(dbi);
|
||||||
if (!treatmentCreated) {
|
if (!treatmentCreated) {
|
||||||
log.error("Adding treatment record overrode an existing record: " + dbi);
|
log.error("Adding treatment record overrode an existing record: " + dbi);
|
||||||
if (dbi.isSMB) {
|
if (dbi.isSMB) {
|
||||||
|
@ -762,7 +763,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
.duration(state.tbrRemainingDuration)
|
.duration(state.tbrRemainingDuration)
|
||||||
.percent(state.tbrPercent)
|
.percent(state.tbrPercent)
|
||||||
.source(Source.USER);
|
.source(Source.USER);
|
||||||
MainApp.getConfigBuilder().addToHistoryTempBasal(tempStart);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStart);
|
||||||
|
|
||||||
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
||||||
}
|
}
|
||||||
|
@ -788,7 +789,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelTempBasal(boolean enforceNew) {
|
public PumpEnactResult cancelTempBasal(boolean enforceNew) {
|
||||||
log.debug("cancelTempBasal called");
|
log.debug("cancelTempBasal called");
|
||||||
final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
final TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (enforceNew) {
|
if (enforceNew) {
|
||||||
CommandResult stateResult = runCommand(MainApp.gs(R.string.combo_pump_action_refreshing), 2, ruffyScripter::readPumpState);
|
CommandResult stateResult = runCommand(MainApp.gs(R.string.combo_pump_action_refreshing), 2, ruffyScripter::readPumpState);
|
||||||
if (!stateResult.success) {
|
if (!stateResult.success) {
|
||||||
|
@ -807,7 +808,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
.date(cancelResult.state.timestamp)
|
.date(cancelResult.state.timestamp)
|
||||||
.duration(0)
|
.duration(0)
|
||||||
.source(Source.USER);
|
.source(Source.USER);
|
||||||
MainApp.getConfigBuilder().addToHistoryTempBasal(tempBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal);
|
||||||
return new PumpEnactResult().isTempCancel(true).success(true).enacted(true);
|
return new PumpEnactResult().isTempCancel(true).success(true).enacted(true);
|
||||||
} else {
|
} else {
|
||||||
return new PumpEnactResult().success(false).enacted(false);
|
return new PumpEnactResult().success(false).enacted(false);
|
||||||
|
@ -945,7 +946,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
TemporaryBasal aapsTbr = MainApp.getConfigBuilder().getTempBasalFromHistory(now);
|
TemporaryBasal aapsTbr = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
||||||
if (aapsTbr == null || aapsTbr.percentRate != 0) {
|
if (aapsTbr == null || aapsTbr.percentRate != 0) {
|
||||||
log.debug("Creating 15m zero temp since pump is suspended");
|
log.debug("Creating 15m zero temp since pump is suspended");
|
||||||
TemporaryBasal newTempBasal = new TemporaryBasal()
|
TemporaryBasal newTempBasal = new TemporaryBasal()
|
||||||
|
@ -953,7 +954,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
.percent(0)
|
.percent(0)
|
||||||
.duration(15)
|
.duration(15)
|
||||||
.source(Source.USER);
|
.source(Source.USER);
|
||||||
MainApp.getConfigBuilder().addToHistoryTempBasal(newTempBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(newTempBasal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1071,7 +1072,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
private void checkAndResolveTbrMismatch(PumpState state) {
|
private void checkAndResolveTbrMismatch(PumpState state) {
|
||||||
// compare with: info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgStatusTempBasal.updateTempBasalInDB()
|
// compare with: info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgStatusTempBasal.updateTempBasalInDB()
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
TemporaryBasal aapsTbr = MainApp.getConfigBuilder().getTempBasalFromHistory(now);
|
TemporaryBasal aapsTbr = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
||||||
if (aapsTbr == null && state.tbrActive && state.tbrRemainingDuration > 2) {
|
if (aapsTbr == null && state.tbrActive && state.tbrRemainingDuration > 2) {
|
||||||
log.debug("Creating temp basal from pump TBR");
|
log.debug("Creating temp basal from pump TBR");
|
||||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch")
|
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch")
|
||||||
|
@ -1083,7 +1084,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
.percent(state.tbrPercent)
|
.percent(state.tbrPercent)
|
||||||
.duration(state.tbrRemainingDuration)
|
.duration(state.tbrRemainingDuration)
|
||||||
.source(Source.USER);
|
.source(Source.USER);
|
||||||
MainApp.getConfigBuilder().addToHistoryTempBasal(newTempBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(newTempBasal);
|
||||||
} else if (aapsTbr != null && aapsTbr.getPlannedRemainingMinutes() > 2 && !state.tbrActive) {
|
} else if (aapsTbr != null && aapsTbr.getPlannedRemainingMinutes() > 2 && !state.tbrActive) {
|
||||||
log.debug("Ending AAPS-TBR since pump has no TBR active");
|
log.debug("Ending AAPS-TBR since pump has no TBR active");
|
||||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch")
|
FabricPrivacy.getInstance().logCustom(new CustomEvent("ComboTbrMismatch")
|
||||||
|
@ -1094,7 +1095,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
.date(now)
|
.date(now)
|
||||||
.duration(0)
|
.duration(0)
|
||||||
.source(Source.USER);
|
.source(Source.USER);
|
||||||
MainApp.getConfigBuilder().addToHistoryTempBasal(tempStop);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStop);
|
||||||
} else if (aapsTbr != null && state.tbrActive
|
} else if (aapsTbr != null && state.tbrActive
|
||||||
&& (aapsTbr.percentRate != state.tbrPercent ||
|
&& (aapsTbr.percentRate != state.tbrPercent ||
|
||||||
Math.abs(aapsTbr.getPlannedRemainingMinutes() - state.tbrRemainingDuration) > 2)) {
|
Math.abs(aapsTbr.getPlannedRemainingMinutes() - state.tbrRemainingDuration) > 2)) {
|
||||||
|
@ -1107,14 +1108,14 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
.date(now - 1000)
|
.date(now - 1000)
|
||||||
.duration(0)
|
.duration(0)
|
||||||
.source(Source.USER);
|
.source(Source.USER);
|
||||||
MainApp.getConfigBuilder().addToHistoryTempBasal(tempStop);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStop);
|
||||||
|
|
||||||
TemporaryBasal newTempBasal = new TemporaryBasal()
|
TemporaryBasal newTempBasal = new TemporaryBasal()
|
||||||
.date(now)
|
.date(now)
|
||||||
.percent(state.tbrPercent)
|
.percent(state.tbrPercent)
|
||||||
.duration(state.tbrRemainingDuration)
|
.duration(state.tbrRemainingDuration)
|
||||||
.source(Source.USER);
|
.source(Source.USER);
|
||||||
MainApp.getConfigBuilder().addToHistoryTempBasal(newTempBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(newTempBasal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1150,7 +1151,7 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
dbi.source = Source.PUMP;
|
dbi.source = Source.PUMP;
|
||||||
dbi.insulin = pumpBolus.amount;
|
dbi.insulin = pumpBolus.amount;
|
||||||
dbi.eventType = CareportalEvent.CORRECTIONBOLUS;
|
dbi.eventType = CareportalEvent.CORRECTIONBOLUS;
|
||||||
if (MainApp.getConfigBuilder().addToHistoryTreatment(dbi)) {
|
if (TreatmentsPlugin.getPlugin().addToHistoryTreatment(dbi)) {
|
||||||
updated = true;
|
updated = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
|
import info.nightscout.androidaps.plugins.ProfileNS.NSProfilePlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractDanaRExecutionService;
|
import info.nightscout.androidaps.plugins.PumpDanaR.services.AbstractDanaRExecutionService;
|
||||||
|
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;
|
||||||
|
@ -172,7 +173,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
|
||||||
if (percent > getPumpDescription().maxTempPercent)
|
if (percent > getPumpDescription().maxTempPercent)
|
||||||
percent = getPumpDescription().maxTempPercent;
|
percent = getPumpDescription().maxTempPercent;
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(now);
|
TemporaryBasal runningTB = TreatmentsPlugin.getPlugin().getRealTempBasalFromHistory(now);
|
||||||
if (runningTB != null && runningTB.percentRate == percent && !enforceNew) {
|
if (runningTB != null && runningTB.percentRate == percent && !enforceNew) {
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
|
@ -214,7 +215,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
|
||||||
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep);
|
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep);
|
||||||
|
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
ExtendedBolus runningEB = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||||
if (runningEB != null && Math.abs(runningEB.insulin - insulin) < getPumpDescription().extendedBolusStep) {
|
if (runningEB != null && Math.abs(runningEB.insulin - insulin) < getPumpDescription().extendedBolusStep) {
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
|
@ -252,7 +253,7 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelExtendedBolus() {
|
public PumpEnactResult cancelExtendedBolus() {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
ExtendedBolus runningEB = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||||
if (runningEB != null) {
|
if (runningEB != null) {
|
||||||
sExecutionService.extendedBolusStop();
|
sExecutionService.extendedBolusStop();
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
|
@ -326,13 +327,13 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
|
||||||
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().getRealTempBasalFromHistory(now);
|
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getRealTempBasalFromHistory(now);
|
||||||
if (tb != null) {
|
if (tb != null) {
|
||||||
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile));
|
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile));
|
||||||
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().getExtendedBolusFromHistory(now);
|
ExtendedBolus eb = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(now);
|
||||||
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));
|
||||||
|
@ -434,11 +435,11 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
|
||||||
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";
|
||||||
}
|
}
|
||||||
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getRealTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
ret += "Temp: " + activeTemp.toStringFull() + "\n";
|
ret += "Temp: " + activeTemp.toStringFull() + "\n";
|
||||||
}
|
}
|
||||||
ExtendedBolus activeExtendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
ExtendedBolus activeExtendedBolus = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||||
if (activeExtendedBolus != null) {
|
if (activeExtendedBolus != null) {
|
||||||
ret += "Extended: " + activeExtendedBolus.toString() + "\n";
|
ret += "Extended: " + activeExtendedBolus.toString() + "\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,6 @@ import android.view.ViewGroup;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -25,6 +24,7 @@ import butterknife.ButterKnife;
|
||||||
import butterknife.OnClick;
|
import butterknife.OnClick;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.TDDStatsActivity;
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
|
@ -33,8 +33,8 @@ import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog;
|
import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRHistoryActivity;
|
import info.nightscout.androidaps.plugins.PumpDanaR.activities.DanaRHistoryActivity;
|
||||||
import info.nightscout.androidaps.TDDStatsActivity;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus;
|
import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.queue.events.EventQueueChanged;
|
import info.nightscout.androidaps.queue.events.EventQueueChanged;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
@ -53,24 +53,41 @@ public class DanaRFragment extends SubscriberFragment {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@BindView(R.id.danar_lastconnection) TextView lastConnectionView;
|
@BindView(R.id.danar_lastconnection)
|
||||||
@BindView(R.id.danar_btconnection) TextView btConnectionView;
|
TextView lastConnectionView;
|
||||||
@BindView(R.id.danar_lastbolus) TextView lastBolusView;
|
@BindView(R.id.danar_btconnection)
|
||||||
@BindView(R.id.danar_dailyunits) TextView dailyUnitsView;
|
TextView btConnectionView;
|
||||||
@BindView(R.id.danar_basabasalrate) TextView basaBasalRateView;
|
@BindView(R.id.danar_lastbolus)
|
||||||
@BindView(R.id.danar_tempbasal) TextView tempBasalView;
|
TextView lastBolusView;
|
||||||
@BindView(R.id.danar_extendedbolus) TextView extendedBolusView;
|
@BindView(R.id.danar_dailyunits)
|
||||||
@BindView(R.id.danar_battery) TextView batteryView;
|
TextView dailyUnitsView;
|
||||||
@BindView(R.id.danar_reservoir) TextView reservoirView;
|
@BindView(R.id.danar_basabasalrate)
|
||||||
@BindView(R.id.danar_iob) TextView iobView;
|
TextView basaBasalRateView;
|
||||||
@BindView(R.id.danar_firmware) TextView firmwareView;
|
@BindView(R.id.danar_tempbasal)
|
||||||
@BindView(R.id.danar_basalstep) TextView basalStepView;
|
TextView tempBasalView;
|
||||||
@BindView(R.id.danar_bolusstep) TextView bolusStepView;
|
@BindView(R.id.danar_extendedbolus)
|
||||||
@BindView(R.id.danar_serialnumber) TextView serialNumberView;
|
TextView extendedBolusView;
|
||||||
@BindView(R.id.danar_queue) TextView queueView;
|
@BindView(R.id.danar_battery)
|
||||||
|
TextView batteryView;
|
||||||
|
@BindView(R.id.danar_reservoir)
|
||||||
|
TextView reservoirView;
|
||||||
|
@BindView(R.id.danar_iob)
|
||||||
|
TextView iobView;
|
||||||
|
@BindView(R.id.danar_firmware)
|
||||||
|
TextView firmwareView;
|
||||||
|
@BindView(R.id.danar_basalstep)
|
||||||
|
TextView basalStepView;
|
||||||
|
@BindView(R.id.danar_bolusstep)
|
||||||
|
TextView bolusStepView;
|
||||||
|
@BindView(R.id.danar_serialnumber)
|
||||||
|
TextView serialNumberView;
|
||||||
|
@BindView(R.id.danar_queue)
|
||||||
|
TextView queueView;
|
||||||
|
|
||||||
@BindView(R.id.overview_pumpstatuslayout) LinearLayout pumpStatusLayout;
|
@BindView(R.id.overview_pumpstatuslayout)
|
||||||
@BindView(R.id.overview_pumpstatus) TextView pumpStatusView;
|
LinearLayout pumpStatusLayout;
|
||||||
|
@BindView(R.id.overview_pumpstatus)
|
||||||
|
TextView pumpStatusView;
|
||||||
|
|
||||||
public DanaRFragment() {
|
public DanaRFragment() {
|
||||||
}
|
}
|
||||||
|
@ -104,21 +121,25 @@ public class DanaRFragment extends SubscriberFragment {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.danar_history) void onHistoryClick() {
|
@OnClick(R.id.danar_history)
|
||||||
|
void onHistoryClick() {
|
||||||
startActivity(new Intent(getContext(), DanaRHistoryActivity.class));
|
startActivity(new Intent(getContext(), DanaRHistoryActivity.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.danar_viewprofile) void onViewProfileClick() {
|
@OnClick(R.id.danar_viewprofile)
|
||||||
|
void onViewProfileClick() {
|
||||||
FragmentManager manager = getFragmentManager();
|
FragmentManager manager = getFragmentManager();
|
||||||
ProfileViewDialog profileViewDialog = new ProfileViewDialog();
|
ProfileViewDialog profileViewDialog = new ProfileViewDialog();
|
||||||
profileViewDialog.show(manager, "ProfileViewDialog");
|
profileViewDialog.show(manager, "ProfileViewDialog");
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.danar_stats) void onStatsClick() {
|
@OnClick(R.id.danar_stats)
|
||||||
|
void onStatsClick() {
|
||||||
startActivity(new Intent(getContext(), TDDStatsActivity.class));
|
startActivity(new Intent(getContext(), TDDStatsActivity.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClick(R.id.danar_btconnection) void onBtConnectionClick() {
|
@OnClick(R.id.danar_btconnection)
|
||||||
|
void onBtConnectionClick() {
|
||||||
log.debug("Clicked connect to pump");
|
log.debug("Clicked connect to pump");
|
||||||
DanaRPump.getInstance().lastConnection = 0;
|
DanaRPump.getInstance().lastConnection = 0;
|
||||||
ConfigBuilderPlugin.getCommandQueue().readStatus("Clicked connect to pump", null);
|
ConfigBuilderPlugin.getCommandQueue().readStatus("Clicked connect to pump", null);
|
||||||
|
@ -201,20 +222,20 @@ public class DanaRFragment extends SubscriberFragment {
|
||||||
basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) + " U/h");
|
basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) + " U/h");
|
||||||
// DanaRPlugin, DanaRKoreanPlugin
|
// DanaRPlugin, DanaRKoreanPlugin
|
||||||
if (ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) {
|
if (ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) {
|
||||||
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isInHistoryRealTempBasalInProgress()) {
|
||||||
tempBasalView.setText(MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
tempBasalView.setText(TreatmentsPlugin.getPlugin().getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
||||||
} else {
|
} else {
|
||||||
tempBasalView.setText("");
|
tempBasalView.setText("");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// v2 plugin
|
// v2 plugin
|
||||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
|
||||||
tempBasalView.setText(MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
tempBasalView.setText(TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
||||||
} else {
|
} else {
|
||||||
tempBasalView.setText("");
|
tempBasalView.setText("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ExtendedBolus activeExtendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
ExtendedBolus activeExtendedBolus = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||||
if (activeExtendedBolus != null) {
|
if (activeExtendedBolus != null) {
|
||||||
extendedBolusView.setText(activeExtendedBolus.toString());
|
extendedBolusView.setText(activeExtendedBolus.toString());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService;
|
import info.nightscout.androidaps.plugins.PumpDanaR.services.DanaRExecutionService;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.Round;
|
import info.nightscout.utils.Round;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
|
@ -79,7 +80,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
||||||
Intent intent = new Intent(context, DanaRExecutionService.class);
|
Intent intent = new Intent(context, DanaRExecutionService.class);
|
||||||
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||||
MainApp.bus().register(this);
|
MainApp.bus().register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
|
@ -115,7 +116,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
||||||
boolean previousValue = useExtendedBoluses;
|
boolean previousValue = useExtendedBoluses;
|
||||||
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
|
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
|
||||||
|
|
||||||
if (useExtendedBoluses != previousValue && MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
|
if (useExtendedBoluses != previousValue && TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress()) {
|
||||||
sExecutionService.extendedBolusStop();
|
sExecutionService.extendedBolusStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,7 +151,8 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
||||||
Treatment t = new Treatment();
|
Treatment t = new Treatment();
|
||||||
t.isSMB = detailedBolusInfo.isSMB;
|
t.isSMB = detailedBolusInfo.isSMB;
|
||||||
boolean connectionOK = false;
|
boolean connectionOK = false;
|
||||||
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, detailedBolusInfo.carbTime, t);
|
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
|
||||||
|
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, detailedBolusInfo.carbTime, t);
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
result.success = connectionOK;
|
result.success = connectionOK;
|
||||||
result.bolusDelivered = t.insulin;
|
result.bolusDelivered = t.insulin;
|
||||||
|
@ -160,7 +162,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
||||||
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
|
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
|
||||||
detailedBolusInfo.insulin = t.insulin;
|
detailedBolusInfo.insulin = t.insulin;
|
||||||
detailedBolusInfo.date = System.currentTimeMillis();
|
detailedBolusInfo.date = System.currentTimeMillis();
|
||||||
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
|
@ -192,8 +194,8 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
||||||
final boolean doExtendedTemp = absoluteRate > getBaseBasalRate() && useExtendedBoluses;
|
final boolean doExtendedTemp = absoluteRate > getBaseBasalRate() && useExtendedBoluses;
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getRealTempBasalFromHistory(now);
|
TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getRealTempBasalFromHistory(now);
|
||||||
ExtendedBolus activeExtended = MainApp.getConfigBuilder().getExtendedBolusFromHistory(now);
|
ExtendedBolus activeExtended = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(now);
|
||||||
|
|
||||||
if (doTempOff) {
|
if (doTempOff) {
|
||||||
// If extended in progress
|
// If extended in progress
|
||||||
|
@ -328,9 +330,9 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelTempBasal(boolean force) {
|
public PumpEnactResult cancelTempBasal(boolean force) {
|
||||||
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress())
|
if (TreatmentsPlugin.getPlugin().isInHistoryRealTempBasalInProgress())
|
||||||
return cancelRealTempBasal();
|
return cancelRealTempBasal();
|
||||||
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
|
if (TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
|
||||||
return cancelExtendedBolus();
|
return cancelExtendedBolus();
|
||||||
}
|
}
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
|
@ -343,7 +345,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
||||||
|
|
||||||
public PumpEnactResult cancelRealTempBasal() {
|
public PumpEnactResult cancelRealTempBasal() {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal runningTB = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (runningTB != null) {
|
if (runningTB != null) {
|
||||||
sExecutionService.tempBasalStop();
|
sExecutionService.tempBasalStop();
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
|
|
|
@ -8,11 +8,11 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
|
|
||||||
public class MsgStatusBolusExtended extends MessageBase {
|
public class MsgStatusBolusExtended extends MessageBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(MsgStatusBolusExtended.class);
|
private static Logger log = LoggerFactory.getLogger(MsgStatusBolusExtended.class);
|
||||||
|
@ -65,7 +65,7 @@ public class MsgStatusBolusExtended extends MessageBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateExtendedBolusInDB() {
|
public static void updateExtendedBolusInDB() {
|
||||||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
TreatmentsInterface treatmentsInterface = TreatmentsPlugin.getPlugin();
|
||||||
DanaRPump pump = DanaRPump.getInstance();
|
DanaRPump pump = DanaRPump.getInstance();
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
|
|
||||||
|
|
|
@ -8,11 +8,10 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
import info.nightscout.androidaps.Config;
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
|
|
||||||
public class MsgStatusTempBasal extends MessageBase {
|
public class MsgStatusTempBasal extends MessageBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(MsgStatusTempBasal.class);
|
private static Logger log = LoggerFactory.getLogger(MsgStatusTempBasal.class);
|
||||||
|
@ -59,29 +58,28 @@ public class MsgStatusTempBasal extends MessageBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void updateTempBasalInDB() {
|
public static void updateTempBasalInDB() {
|
||||||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
|
||||||
DanaRPump danaRPump = DanaRPump.getInstance();
|
DanaRPump danaRPump = DanaRPump.getInstance();
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
|
|
||||||
if (treatmentsInterface.isInHistoryRealTempBasalInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isInHistoryRealTempBasalInProgress()) {
|
||||||
TemporaryBasal tempBasal = treatmentsInterface.getRealTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal tempBasal = TreatmentsPlugin.getPlugin().getRealTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (danaRPump.isTempBasalInProgress) {
|
if (danaRPump.isTempBasalInProgress) {
|
||||||
if (tempBasal.percentRate != danaRPump.tempBasalPercent) {
|
if (tempBasal.percentRate != danaRPump.tempBasalPercent) {
|
||||||
// Close current temp basal
|
// Close current temp basal
|
||||||
TemporaryBasal tempStop = new TemporaryBasal().date(danaRPump.tempBasalStart.getTime() - 1000).source(Source.USER);
|
TemporaryBasal tempStop = new TemporaryBasal().date(danaRPump.tempBasalStart.getTime() - 1000).source(Source.USER);
|
||||||
treatmentsInterface.addToHistoryTempBasal(tempStop);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStop);
|
||||||
// Create new
|
// Create new
|
||||||
TemporaryBasal newTempBasal = new TemporaryBasal()
|
TemporaryBasal newTempBasal = new TemporaryBasal()
|
||||||
.date(danaRPump.tempBasalStart.getTime())
|
.date(danaRPump.tempBasalStart.getTime())
|
||||||
.percent(danaRPump.tempBasalPercent)
|
.percent(danaRPump.tempBasalPercent)
|
||||||
.duration(danaRPump.tempBasalTotalSec / 60)
|
.duration(danaRPump.tempBasalTotalSec / 60)
|
||||||
.source(Source.USER);
|
.source(Source.USER);
|
||||||
treatmentsInterface.addToHistoryTempBasal(newTempBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(newTempBasal);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Close current temp basal
|
// Close current temp basal
|
||||||
TemporaryBasal tempStop = new TemporaryBasal().date(now).source(Source.USER);
|
TemporaryBasal tempStop = new TemporaryBasal().date(now).source(Source.USER);
|
||||||
treatmentsInterface.addToHistoryTempBasal(tempStop);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStop);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (danaRPump.isTempBasalInProgress) {
|
if (danaRPump.isTempBasalInProgress) {
|
||||||
|
@ -91,7 +89,7 @@ public class MsgStatusTempBasal extends MessageBase {
|
||||||
.percent(danaRPump.tempBasalPercent)
|
.percent(danaRPump.tempBasalPercent)
|
||||||
.duration(danaRPump.tempBasalTotalSec / 60)
|
.duration(danaRPump.tempBasalTotalSec / 60)
|
||||||
.source(Source.USER);
|
.source(Source.USER);
|
||||||
treatmentsInterface.addToHistoryTempBasal(newTempBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(newTempBasal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,7 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRKorean.services.DanaRKoreanExecutionService;
|
import info.nightscout.androidaps.plugins.PumpDanaRKorean.services.DanaRKoreanExecutionService;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.events.EventDanaRSDeviceChange;
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.services.DanaRSService;
|
|
||||||
import info.nightscout.utils.Round;
|
import info.nightscout.utils.Round;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
|
@ -118,7 +117,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
||||||
boolean previousValue = useExtendedBoluses;
|
boolean previousValue = useExtendedBoluses;
|
||||||
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
|
useExtendedBoluses = SP.getBoolean("danar_useextended", false);
|
||||||
|
|
||||||
if (useExtendedBoluses != previousValue && MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
|
if (useExtendedBoluses != previousValue && TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress()) {
|
||||||
sExecutionService.extendedBolusStop();
|
sExecutionService.extendedBolusStop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -164,7 +163,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
||||||
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
|
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
|
||||||
detailedBolusInfo.insulin = t.insulin;
|
detailedBolusInfo.insulin = t.insulin;
|
||||||
detailedBolusInfo.date = System.currentTimeMillis();
|
detailedBolusInfo.date = System.currentTimeMillis();
|
||||||
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
|
@ -196,8 +195,8 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
||||||
final boolean doExtendedTemp = absoluteRate > getBaseBasalRate() && useExtendedBoluses;
|
final boolean doExtendedTemp = absoluteRate > getBaseBasalRate() && useExtendedBoluses;
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getRealTempBasalFromHistory(now);
|
TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getRealTempBasalFromHistory(now);
|
||||||
ExtendedBolus activeExtended = MainApp.getConfigBuilder().getExtendedBolusFromHistory(now);
|
ExtendedBolus activeExtended = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(now);
|
||||||
|
|
||||||
if (doTempOff) {
|
if (doTempOff) {
|
||||||
// If extended in progress
|
// If extended in progress
|
||||||
|
@ -332,9 +331,9 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelTempBasal(boolean force) {
|
public PumpEnactResult cancelTempBasal(boolean force) {
|
||||||
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress())
|
if (TreatmentsPlugin.getPlugin().isInHistoryRealTempBasalInProgress())
|
||||||
return cancelRealTempBasal();
|
return cancelRealTempBasal();
|
||||||
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
|
if (TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
|
||||||
return cancelExtendedBolus();
|
return cancelExtendedBolus();
|
||||||
}
|
}
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
|
@ -347,7 +346,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
||||||
|
|
||||||
public PumpEnactResult cancelRealTempBasal() {
|
public PumpEnactResult cancelRealTempBasal() {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal runningTB = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (runningTB != null) {
|
if (runningTB != null) {
|
||||||
sExecutionService.tempBasalStop();
|
sExecutionService.tempBasalStop();
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
|
|
|
@ -47,6 +47,7 @@ import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.events.EventDanaRSDeviceChange;
|
import info.nightscout.androidaps.plugins.PumpDanaRS.events.EventDanaRSDeviceChange;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.services.DanaRSService;
|
import info.nightscout.androidaps.plugins.PumpDanaRS.services.DanaRSService;
|
||||||
|
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;
|
||||||
|
@ -426,7 +427,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
|
|
||||||
if (doTempOff) {
|
if (doTempOff) {
|
||||||
// If temp in progress
|
// If temp in progress
|
||||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
|
||||||
if (Config.logPumpActions)
|
if (Config.logPumpActions)
|
||||||
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
|
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
|
||||||
return cancelTempBasal(false);
|
return cancelTempBasal(false);
|
||||||
|
@ -448,7 +449,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
if (percentRate > 500) // Special high temp 500/15min
|
if (percentRate > 500) // Special high temp 500/15min
|
||||||
percentRate = 500;
|
percentRate = 500;
|
||||||
// Check if some temp is already in progress
|
// Check if some temp is already in progress
|
||||||
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
if (Config.logPumpActions)
|
if (Config.logPumpActions)
|
||||||
log.debug("setTempBasalAbsolute: currently running: " + activeTemp.toString());
|
log.debug("setTempBasalAbsolute: currently running: " + activeTemp.toString());
|
||||||
|
@ -502,7 +503,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
if (percent > getPumpDescription().maxTempPercent)
|
if (percent > getPumpDescription().maxTempPercent)
|
||||||
percent = getPumpDescription().maxTempPercent;
|
percent = getPumpDescription().maxTempPercent;
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(now);
|
TemporaryBasal runningTB = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
||||||
if (runningTB != null && runningTB.percentRate == percent && !enforceNew) {
|
if (runningTB != null && runningTB.percentRate == percent && !enforceNew) {
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
|
@ -570,7 +571,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
|
int durationInHalfHours = Math.max(durationInMinutes / 30, 1);
|
||||||
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep);
|
insulin = Round.roundTo(insulin, getPumpDescription().extendedBolusStep);
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
ExtendedBolus runningEB = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||||
if (runningEB != null && Math.abs(runningEB.insulin - insulin) < getPumpDescription().extendedBolusStep) {
|
if (runningEB != null && Math.abs(runningEB.insulin - insulin) < getPumpDescription().extendedBolusStep) {
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
|
@ -607,7 +608,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
@Override
|
@Override
|
||||||
public synchronized PumpEnactResult cancelTempBasal(boolean force) {
|
public synchronized PumpEnactResult cancelTempBasal(boolean force) {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal runningTB = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (runningTB != null) {
|
if (runningTB != null) {
|
||||||
danaRSService.tempBasalStop();
|
danaRSService.tempBasalStop();
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
|
@ -632,7 +633,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
@Override
|
@Override
|
||||||
public synchronized PumpEnactResult cancelExtendedBolus() {
|
public synchronized PumpEnactResult cancelExtendedBolus() {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
ExtendedBolus runningEB = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||||
if (runningEB != null) {
|
if (runningEB != null) {
|
||||||
danaRSService.extendedBolusStop();
|
danaRSService.extendedBolusStop();
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
|
@ -672,13 +673,13 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
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().getTempBasalFromHistory(now);
|
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
||||||
if (tb != null) {
|
if (tb != null) {
|
||||||
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile));
|
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile));
|
||||||
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().getExtendedBolusFromHistory(now);
|
ExtendedBolus eb = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(now);
|
||||||
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));
|
||||||
|
@ -722,11 +723,11 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
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";
|
||||||
}
|
}
|
||||||
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getRealTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
ret += "Temp: " + activeTemp.toStringFull() + "\n";
|
ret += "Temp: " + activeTemp.toStringFull() + "\n";
|
||||||
}
|
}
|
||||||
ExtendedBolus activeExtendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
ExtendedBolus activeExtendedBolus = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||||
if (activeExtendedBolus != null) {
|
if (activeExtendedBolus != null) {
|
||||||
ret += "Extended: " + activeExtendedBolus.toString() + "\n";
|
ret += "Extended: " + activeExtendedBolus.toString() + "\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
|
||||||
public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
|
public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
|
||||||
|
@ -110,36 +111,36 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
|
||||||
log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min");
|
log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min");
|
||||||
temporaryBasal.percentRate = param1;
|
temporaryBasal.percentRate = param1;
|
||||||
temporaryBasal.durationInMinutes = param2;
|
temporaryBasal.durationInMinutes = param2;
|
||||||
MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal);
|
||||||
status = "TEMPSTART " + DateUtil.timeString(datetime);
|
status = "TEMPSTART " + DateUtil.timeString(datetime);
|
||||||
break;
|
break;
|
||||||
case DanaRPump.TEMPSTOP:
|
case DanaRPump.TEMPSTOP:
|
||||||
log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString());
|
log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString());
|
||||||
MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal);
|
||||||
status = "TEMPSTOP " + DateUtil.timeString(datetime);
|
status = "TEMPSTOP " + DateUtil.timeString(datetime);
|
||||||
break;
|
break;
|
||||||
case DanaRPump.EXTENDEDSTART:
|
case DanaRPump.EXTENDEDSTART:
|
||||||
log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||||
extendedBolus.insulin = param1 / 100d;
|
extendedBolus.insulin = param1 / 100d;
|
||||||
extendedBolus.durationInMinutes = param2;
|
extendedBolus.durationInMinutes = param2;
|
||||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
|
||||||
status = "EXTENDEDSTART " + DateUtil.timeString(datetime);
|
status = "EXTENDEDSTART " + DateUtil.timeString(datetime);
|
||||||
break;
|
break;
|
||||||
case DanaRPump.EXTENDEDSTOP:
|
case DanaRPump.EXTENDEDSTOP:
|
||||||
log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
|
log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
|
||||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
|
||||||
status = "EXTENDEDSTOP " + DateUtil.timeString(datetime);
|
status = "EXTENDEDSTOP " + DateUtil.timeString(datetime);
|
||||||
break;
|
break;
|
||||||
case DanaRPump.BOLUS:
|
case DanaRPump.BOLUS:
|
||||||
detailedBolusInfo.insulin = param1 / 100d;
|
detailedBolusInfo.insulin = param1 / 100d;
|
||||||
boolean newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||||
log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||||
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
|
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
|
||||||
status = "BOLUS " + DateUtil.timeString(datetime);
|
status = "BOLUS " + DateUtil.timeString(datetime);
|
||||||
break;
|
break;
|
||||||
case DanaRPump.DUALBOLUS:
|
case DanaRPump.DUALBOLUS:
|
||||||
detailedBolusInfo.insulin = param1 / 100d;
|
detailedBolusInfo.insulin = param1 / 100d;
|
||||||
newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||||
log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||||
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
|
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
|
||||||
status = "DUALBOLUS " + DateUtil.timeString(datetime);
|
status = "DUALBOLUS " + DateUtil.timeString(datetime);
|
||||||
|
@ -148,12 +149,12 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
|
||||||
log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||||
extendedBolus.insulin = param1 / 100d;
|
extendedBolus.insulin = param1 / 100d;
|
||||||
extendedBolus.durationInMinutes = param2;
|
extendedBolus.durationInMinutes = param2;
|
||||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
|
||||||
status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime);
|
status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime);
|
||||||
break;
|
break;
|
||||||
case DanaRPump.DUALEXTENDEDSTOP:
|
case DanaRPump.DUALEXTENDEDSTOP:
|
||||||
log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
|
log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
|
||||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
|
||||||
status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime);
|
status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime);
|
||||||
break;
|
break;
|
||||||
case DanaRPump.SUSPENDON:
|
case DanaRPump.SUSPENDON:
|
||||||
|
@ -182,7 +183,7 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
|
||||||
emptyCarbsInfo.date = datetime.getTime();
|
emptyCarbsInfo.date = datetime.getTime();
|
||||||
emptyCarbsInfo.source = Source.PUMP;
|
emptyCarbsInfo.source = Source.PUMP;
|
||||||
emptyCarbsInfo.pumpId = datetime.getTime();
|
emptyCarbsInfo.pumpId = datetime.getTime();
|
||||||
newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(emptyCarbsInfo);
|
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(emptyCarbsInfo);
|
||||||
log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g");
|
log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g");
|
||||||
status = "CARBS " + DateUtil.timeString(datetime);
|
status = "CARBS " + DateUtil.timeString(datetime);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -23,9 +23,8 @@ import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.events.EventDanaRSDeviceChange;
|
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.services.DanaRSService;
|
|
||||||
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.Round;
|
import info.nightscout.utils.Round;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
|
@ -216,7 +215,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
|
|
||||||
if (doTempOff) {
|
if (doTempOff) {
|
||||||
// If temp in progress
|
// If temp in progress
|
||||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
|
||||||
if (Config.logPumpActions)
|
if (Config.logPumpActions)
|
||||||
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
|
log.debug("setTempBasalAbsolute: Stopping temp basal (doTempOff)");
|
||||||
return cancelTempBasal(false);
|
return cancelTempBasal(false);
|
||||||
|
@ -238,7 +237,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
if (percentRate > 500) // Special high temp 500/15min
|
if (percentRate > 500) // Special high temp 500/15min
|
||||||
percentRate = 500;
|
percentRate = 500;
|
||||||
// Check if some temp is already in progress
|
// Check if some temp is already in progress
|
||||||
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
// Correct basal already set ?
|
// Correct basal already set ?
|
||||||
if (activeTemp.percentRate == percentRate) {
|
if (activeTemp.percentRate == percentRate) {
|
||||||
|
@ -290,7 +289,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
if (percent > getPumpDescription().maxTempPercent)
|
if (percent > getPumpDescription().maxTempPercent)
|
||||||
percent = getPumpDescription().maxTempPercent;
|
percent = getPumpDescription().maxTempPercent;
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
TemporaryBasal runningTB = MainApp.getConfigBuilder().getRealTempBasalFromHistory(now);
|
TemporaryBasal runningTB = TreatmentsPlugin.getPlugin().getRealTempBasalFromHistory(now);
|
||||||
if (runningTB != null && runningTB.percentRate == percent && !enforceNew) {
|
if (runningTB != null && runningTB.percentRate == percent && !enforceNew) {
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = true;
|
result.success = true;
|
||||||
|
@ -354,7 +353,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelTempBasal(boolean force) {
|
public PumpEnactResult cancelTempBasal(boolean force) {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal runningTB = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (runningTB != null) {
|
if (runningTB != null) {
|
||||||
sExecutionService.tempBasalStop();
|
sExecutionService.tempBasalStop();
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
|
|
|
@ -16,6 +16,7 @@ import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
|
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
|
||||||
public class MsgHistoryEvents_v2 extends MessageBase {
|
public class MsgHistoryEvents_v2 extends MessageBase {
|
||||||
|
@ -84,36 +85,36 @@ public class MsgHistoryEvents_v2 extends MessageBase {
|
||||||
log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min");
|
log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min");
|
||||||
temporaryBasal.percentRate = param1;
|
temporaryBasal.percentRate = param1;
|
||||||
temporaryBasal.durationInMinutes = param2;
|
temporaryBasal.durationInMinutes = param2;
|
||||||
MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal);
|
||||||
status = "TEMPSTART " + DateUtil.timeString(datetime);
|
status = "TEMPSTART " + DateUtil.timeString(datetime);
|
||||||
break;
|
break;
|
||||||
case DanaRPump.TEMPSTOP:
|
case DanaRPump.TEMPSTOP:
|
||||||
log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString());
|
log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString());
|
||||||
MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal);
|
||||||
status = "TEMPSTOP " + DateUtil.timeString(datetime);
|
status = "TEMPSTOP " + DateUtil.timeString(datetime);
|
||||||
break;
|
break;
|
||||||
case DanaRPump.EXTENDEDSTART:
|
case DanaRPump.EXTENDEDSTART:
|
||||||
log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||||
extendedBolus.insulin = param1 / 100d;
|
extendedBolus.insulin = param1 / 100d;
|
||||||
extendedBolus.durationInMinutes = param2;
|
extendedBolus.durationInMinutes = param2;
|
||||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
|
||||||
status = "EXTENDEDSTART " + DateUtil.timeString(datetime);
|
status = "EXTENDEDSTART " + DateUtil.timeString(datetime);
|
||||||
break;
|
break;
|
||||||
case DanaRPump.EXTENDEDSTOP:
|
case DanaRPump.EXTENDEDSTOP:
|
||||||
log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
|
log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
|
||||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
|
||||||
status = "EXTENDEDSTOP " + DateUtil.timeString(datetime);
|
status = "EXTENDEDSTOP " + DateUtil.timeString(datetime);
|
||||||
break;
|
break;
|
||||||
case DanaRPump.BOLUS:
|
case DanaRPump.BOLUS:
|
||||||
detailedBolusInfo.insulin = param1 / 100d;
|
detailedBolusInfo.insulin = param1 / 100d;
|
||||||
boolean newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
boolean newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||||
log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||||
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
|
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
|
||||||
status = "BOLUS " + DateUtil.timeString(datetime);
|
status = "BOLUS " + DateUtil.timeString(datetime);
|
||||||
break;
|
break;
|
||||||
case DanaRPump.DUALBOLUS:
|
case DanaRPump.DUALBOLUS:
|
||||||
detailedBolusInfo.insulin = param1 / 100d;
|
detailedBolusInfo.insulin = param1 / 100d;
|
||||||
newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||||
log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||||
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
|
DetailedBolusInfoStorage.remove(detailedBolusInfo.date);
|
||||||
status = "DUALBOLUS " + DateUtil.timeString(datetime);
|
status = "DUALBOLUS " + DateUtil.timeString(datetime);
|
||||||
|
@ -122,12 +123,12 @@ public class MsgHistoryEvents_v2 extends MessageBase {
|
||||||
log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min");
|
||||||
extendedBolus.insulin = param1 / 100d;
|
extendedBolus.insulin = param1 / 100d;
|
||||||
extendedBolus.durationInMinutes = param2;
|
extendedBolus.durationInMinutes = param2;
|
||||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
|
||||||
status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime);
|
status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime);
|
||||||
break;
|
break;
|
||||||
case DanaRPump.DUALEXTENDEDSTOP:
|
case DanaRPump.DUALEXTENDEDSTOP:
|
||||||
log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
|
log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min");
|
||||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
|
||||||
status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime);
|
status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime);
|
||||||
break;
|
break;
|
||||||
case DanaRPump.SUSPENDON:
|
case DanaRPump.SUSPENDON:
|
||||||
|
@ -156,7 +157,7 @@ public class MsgHistoryEvents_v2 extends MessageBase {
|
||||||
emptyCarbsInfo.date = datetime.getTime();
|
emptyCarbsInfo.date = datetime.getTime();
|
||||||
emptyCarbsInfo.source = Source.PUMP;
|
emptyCarbsInfo.source = Source.PUMP;
|
||||||
emptyCarbsInfo.pumpId = datetime.getTime();
|
emptyCarbsInfo.pumpId = datetime.getTime();
|
||||||
newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(emptyCarbsInfo);
|
newRecord = TreatmentsPlugin.getPlugin().addToHistoryTreatment(emptyCarbsInfo);
|
||||||
log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g");
|
log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g");
|
||||||
status = "CARBS " + DateUtil.timeString(datetime);
|
status = "CARBS " + DateUtil.timeString(datetime);
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -44,6 +44,7 @@ import info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.history.LiveHistory;
|
import info.nightscout.androidaps.plugins.PumpInsight.history.LiveHistory;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.utils.Helpers;
|
import info.nightscout.androidaps.plugins.PumpInsight.utils.Helpers;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.utils.StatusItem;
|
import info.nightscout.androidaps.plugins.PumpInsight.utils.StatusItem;
|
||||||
|
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;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
@ -426,7 +427,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
||||||
bolusingEvent.bolusId = bolusId;
|
bolusingEvent.bolusId = bolusId;
|
||||||
bolusingEvent.percent = 0;
|
bolusingEvent.percent = 0;
|
||||||
MainApp.bus().post(bolusingEvent);
|
MainApp.bus().post(bolusingEvent);
|
||||||
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||||
} else {
|
} else {
|
||||||
log.debug("Failure to deliver treatment");
|
log.debug("Failure to deliver treatment");
|
||||||
}
|
}
|
||||||
|
@ -530,7 +531,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
||||||
.percent(percent_amount)
|
.percent(percent_amount)
|
||||||
.duration(durationInMinutes)
|
.duration(durationInMinutes)
|
||||||
.source(Source.USER);
|
.source(Source.USER);
|
||||||
MainApp.getConfigBuilder().addToHistoryTempBasal(tempBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.logPumpComm)
|
if (Config.logPumpComm)
|
||||||
|
@ -579,7 +580,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
||||||
.percent(percent)
|
.percent(percent)
|
||||||
.duration(durationInMinutes)
|
.duration(durationInMinutes)
|
||||||
.source(Source.USER); // TODO check this is correct
|
.source(Source.USER); // TODO check this is correct
|
||||||
MainApp.getConfigBuilder().addToHistoryTempBasal(tempBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempBasal);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateGui();
|
updateGui();
|
||||||
|
@ -615,9 +616,9 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
||||||
// TODO isn't conditional on one apparently being in progress only the history change
|
// TODO isn't conditional on one apparently being in progress only the history change
|
||||||
final Mstatus ms = async.busyWaitForCommandResult(cmd, BUSY_WAIT_TIME);
|
final Mstatus ms = async.busyWaitForCommandResult(cmd, BUSY_WAIT_TIME);
|
||||||
|
|
||||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
|
||||||
TemporaryBasal tempStop = new TemporaryBasal().date(System.currentTimeMillis()).source(Source.USER);
|
TemporaryBasal tempStop = new TemporaryBasal().date(System.currentTimeMillis()).source(Source.USER);
|
||||||
MainApp.getConfigBuilder().addToHistoryTempBasal(tempStop);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStop);
|
||||||
}
|
}
|
||||||
lastDataTime = new Date();
|
lastDataTime = new Date();
|
||||||
updateGui();
|
updateGui();
|
||||||
|
@ -659,7 +660,7 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
||||||
extendedBolus.durationInMinutes = durationInMinutes;
|
extendedBolus.durationInMinutes = durationInMinutes;
|
||||||
extendedBolus.source = Source.USER;
|
extendedBolus.source = Source.USER;
|
||||||
extendedBolus.pumpId = getRecordUniqueID(ms.getResponseID());
|
extendedBolus.pumpId = getRecordUniqueID(ms.getResponseID());
|
||||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.logPumpComm)
|
if (Config.logPumpComm)
|
||||||
|
@ -688,10 +689,10 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
||||||
|
|
||||||
final Mstatus ms = async.busyWaitForCommandResult(cmd, BUSY_WAIT_TIME);
|
final Mstatus ms = async.busyWaitForCommandResult(cmd, BUSY_WAIT_TIME);
|
||||||
|
|
||||||
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress()) {
|
||||||
ExtendedBolus exStop = new ExtendedBolus(System.currentTimeMillis());
|
ExtendedBolus exStop = new ExtendedBolus(System.currentTimeMillis());
|
||||||
exStop.source = Source.USER;
|
exStop.source = Source.USER;
|
||||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(exStop);
|
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(exStop);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Config.logPumpComm)
|
if (Config.logPumpComm)
|
||||||
|
@ -741,13 +742,13 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
||||||
extended.put("ActiveProfile", MainApp.getConfigBuilder().getProfileName());
|
extended.put("ActiveProfile", MainApp.getConfigBuilder().getProfileName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasalFromHistory(now);
|
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
||||||
if (tb != null) {
|
if (tb != null) {
|
||||||
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile));
|
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile));
|
||||||
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().getExtendedBolusFromHistory(now);
|
ExtendedBolus eb = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(now);
|
||||||
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));
|
||||||
|
@ -847,9 +848,9 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
|
||||||
try {
|
try {
|
||||||
l.add(new StatusItem(gs(R.string.pump_tempbasal_label), MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull()));
|
l.add(new StatusItem(gs(R.string.pump_tempbasal_label), TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis()).toStringFull()));
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
@ -865,10 +866,10 @@ public class InsightPlugin extends PluginBase implements PumpInterface, Constrai
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress()) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
l.add(new StatusItem(gs(R.string.virtualpump_extendedbolus_label), MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis()).toString()));
|
l.add(new StatusItem(gs(R.string.virtualpump_extendedbolus_label), TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis()).toString()));
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by jamorham on 27/01/2018.
|
* Created by jamorham on 27/01/2018.
|
||||||
|
@ -26,7 +27,7 @@ class HistoryLogAdapter {
|
||||||
|
|
||||||
TemporaryBasal temporaryBasal = new TemporaryBasal().date(eventDate.getTime());
|
TemporaryBasal temporaryBasal = new TemporaryBasal().date(eventDate.getTime());
|
||||||
|
|
||||||
final TemporaryBasal temporaryBasalFromHistory = MainApp.getConfigBuilder().getTempBasalFromHistory(eventDate.getTime());
|
final TemporaryBasal temporaryBasalFromHistory = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(eventDate.getTime());
|
||||||
|
|
||||||
if (temporaryBasalFromHistory == null) {
|
if (temporaryBasalFromHistory == null) {
|
||||||
log("Create new TBR: " + eventDate + " " + percent + " " + duration);
|
log("Create new TBR: " + eventDate + " " + percent + " " + duration);
|
||||||
|
@ -54,7 +55,7 @@ class HistoryLogAdapter {
|
||||||
.percent(percent)
|
.percent(percent)
|
||||||
.duration(duration);
|
.duration(duration);
|
||||||
|
|
||||||
MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(temporaryBasal);
|
||||||
}
|
}
|
||||||
|
|
||||||
void createExtendedBolusRecord(Date eventDate, double insulin, int durationInMinutes, long record_id) {
|
void createExtendedBolusRecord(Date eventDate, double insulin, int durationInMinutes, long record_id) {
|
||||||
|
@ -68,7 +69,7 @@ class HistoryLogAdapter {
|
||||||
extendedBolus.source = Source.PUMP;
|
extendedBolus.source = Source.PUMP;
|
||||||
extendedBolus.pumpId = record_id;
|
extendedBolus.pumpId = record_id;
|
||||||
|
|
||||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(extendedBolus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void createStandardBolusRecord(Date eventDate, double insulin, long record_id) {
|
void createStandardBolusRecord(Date eventDate, double insulin, long record_id) {
|
||||||
|
@ -82,6 +83,6 @@ class HistoryLogAdapter {
|
||||||
detailedBolusInfo.source = Source.PUMP;
|
detailedBolusInfo.source = Source.PUMP;
|
||||||
detailedBolusInfo.pumpId = record_id;
|
detailedBolusInfo.pumpId = record_id;
|
||||||
detailedBolusInfo.insulin = insulin;
|
detailedBolusInfo.insulin = insulin;
|
||||||
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -134,7 +135,7 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
|
||||||
result.bolusDelivered = detailedBolusInfo.insulin;
|
result.bolusDelivered = detailedBolusInfo.insulin;
|
||||||
result.carbsDelivered = detailedBolusInfo.carbs;
|
result.carbsDelivered = detailedBolusInfo.carbs;
|
||||||
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
||||||
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,18 +10,17 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
|
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.FabricPrivacy;
|
import info.nightscout.utils.FabricPrivacy;
|
||||||
|
|
||||||
public class VirtualPumpFragment extends SubscriberFragment {
|
public class VirtualPumpFragment extends SubscriberFragment {
|
||||||
|
@ -84,13 +83,13 @@ public class VirtualPumpFragment extends SubscriberFragment {
|
||||||
public void run() {
|
public void run() {
|
||||||
VirtualPumpPlugin virtualPump = VirtualPumpPlugin.getPlugin();
|
VirtualPumpPlugin virtualPump = VirtualPumpPlugin.getPlugin();
|
||||||
basaBasalRateView.setText(virtualPump.getBaseBasalRate() + "U");
|
basaBasalRateView.setText(virtualPump.getBaseBasalRate() + "U");
|
||||||
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
tempBasalView.setText(activeTemp.toStringFull());
|
tempBasalView.setText(activeTemp.toStringFull());
|
||||||
} else {
|
} else {
|
||||||
tempBasalView.setText("");
|
tempBasalView.setText("");
|
||||||
}
|
}
|
||||||
ExtendedBolus activeExtendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
ExtendedBolus activeExtendedBolus = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||||
if (activeExtendedBolus != null) {
|
if (activeExtendedBolus != null) {
|
||||||
extendedBolusView.setText(activeExtendedBolus.toString());
|
extendedBolusView.setText(activeExtendedBolus.toString());
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -24,11 +24,11 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
|
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
|
||||||
|
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;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
@ -224,7 +224,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
log.debug("Delivering treatment insulin: " + detailedBolusInfo.insulin + "U carbs: " + detailedBolusInfo.carbs + "g " + result);
|
log.debug("Delivering treatment insulin: " + detailedBolusInfo.insulin + "U carbs: " + detailedBolusInfo.carbs + "g " + result);
|
||||||
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
MainApp.bus().post(new EventVirtualPumpUpdateGui());
|
||||||
lastDataTime = new Date();
|
lastDataTime = new Date();
|
||||||
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +235,6 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
||||||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
|
||||||
TemporaryBasal tempBasal = new TemporaryBasal()
|
TemporaryBasal tempBasal = new TemporaryBasal()
|
||||||
.date(System.currentTimeMillis())
|
.date(System.currentTimeMillis())
|
||||||
.absolute(absoluteRate)
|
.absolute(absoluteRate)
|
||||||
|
@ -248,7 +247,7 @@ public class VirtualPumpPlugin extends PluginBase implements 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.addToHistoryTempBasal(tempBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(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());
|
||||||
|
@ -258,9 +257,8 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes, Profile profile, boolean enforceNew) {
|
||||||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
|
||||||
result = cancelTempBasal(false);
|
result = cancelTempBasal(false);
|
||||||
if (!result.success)
|
if (!result.success)
|
||||||
return result;
|
return result;
|
||||||
|
@ -277,7 +275,7 @@ public class VirtualPumpPlugin extends PluginBase implements 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.addToHistoryTempBasal(tempBasal);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(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());
|
||||||
|
@ -287,7 +285,6 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
||||||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
|
||||||
PumpEnactResult result = cancelExtendedBolus();
|
PumpEnactResult result = cancelExtendedBolus();
|
||||||
if (!result.success)
|
if (!result.success)
|
||||||
return result;
|
return result;
|
||||||
|
@ -302,7 +299,7 @@ public class VirtualPumpPlugin extends PluginBase implements 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.addToHistoryExtendedBolus(extendedBolus);
|
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(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());
|
||||||
|
@ -312,15 +309,14 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelTempBasal(boolean force) {
|
public PumpEnactResult cancelTempBasal(boolean force) {
|
||||||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.isTempCancel = true;
|
result.isTempCancel = true;
|
||||||
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok);
|
||||||
if (treatmentsInterface.isTempBasalInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isTempBasalInProgress()) {
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
TemporaryBasal tempStop = new TemporaryBasal().date(System.currentTimeMillis()).source(Source.USER);
|
TemporaryBasal tempStop = new TemporaryBasal().date(System.currentTimeMillis()).source(Source.USER);
|
||||||
treatmentsInterface.addToHistoryTempBasal(tempStop);
|
TreatmentsPlugin.getPlugin().addToHistoryTempBasal(tempStop);
|
||||||
//tempBasal = null;
|
//tempBasal = null;
|
||||||
if (Config.logPumpComm)
|
if (Config.logPumpComm)
|
||||||
log.debug("Canceling temp basal: " + result);
|
log.debug("Canceling temp basal: " + result);
|
||||||
|
@ -332,12 +328,11 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelExtendedBolus() {
|
public PumpEnactResult cancelExtendedBolus() {
|
||||||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
if (treatmentsInterface.isInHistoryExtendedBoluslInProgress()) {
|
if (TreatmentsPlugin.getPlugin().isInHistoryExtendedBoluslInProgress()) {
|
||||||
ExtendedBolus exStop = new ExtendedBolus(System.currentTimeMillis());
|
ExtendedBolus exStop = new ExtendedBolus(System.currentTimeMillis());
|
||||||
exStop.source = Source.USER;
|
exStop.source = Source.USER;
|
||||||
treatmentsInterface.addToHistoryExtendedBolus(exStop);
|
TreatmentsPlugin.getPlugin().addToHistoryExtendedBolus(exStop);
|
||||||
}
|
}
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
|
@ -368,13 +363,13 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface {
|
||||||
extended.put("ActiveProfile", profileName);
|
extended.put("ActiveProfile", profileName);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
TemporaryBasal tb = MainApp.getConfigBuilder().getTempBasalFromHistory(now);
|
TemporaryBasal tb = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now);
|
||||||
if (tb != null) {
|
if (tb != null) {
|
||||||
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile));
|
extended.put("TempBasalAbsoluteRate", tb.tempBasalConvertedToAbsolute(now, profile));
|
||||||
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().getExtendedBolusFromHistory(now);
|
ExtendedBolus eb = TreatmentsPlugin.getPlugin().getExtendedBolusFromHistory(now);
|
||||||
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));
|
||||||
|
|
|
@ -40,6 +40,7 @@ import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS;
|
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventNewSMS;
|
||||||
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommunicatorUpdateGui;
|
import info.nightscout.androidaps.plugins.SmsCommunicator.events.EventSmsCommunicatorUpdateGui;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
import info.nightscout.utils.FabricPrivacy;
|
import info.nightscout.utils.FabricPrivacy;
|
||||||
|
@ -214,10 +215,10 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
||||||
if (glucoseStatus != null)
|
if (glucoseStatus != null)
|
||||||
reply += MainApp.sResources.getString(R.string.sms_delta) + " " + Profile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units + ", ";
|
reply += MainApp.sResources.getString(R.string.sms_delta) + " " + Profile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units + ", ";
|
||||||
|
|
||||||
MainApp.getConfigBuilder().updateTotalIOBTreatments();
|
TreatmentsPlugin.getPlugin().updateTotalIOBTreatments();
|
||||||
IobTotal bolusIob = MainApp.getConfigBuilder().getLastCalculationTreatments().round();
|
IobTotal bolusIob = TreatmentsPlugin.getPlugin().getLastCalculationTreatments().round();
|
||||||
MainApp.getConfigBuilder().updateTotalIOBTempBasals();
|
TreatmentsPlugin.getPlugin().updateTotalIOBTempBasals();
|
||||||
IobTotal basalIob = MainApp.getConfigBuilder().getLastCalculationTempBasals().round();
|
IobTotal basalIob = TreatmentsPlugin.getPlugin().getLastCalculationTempBasals().round();
|
||||||
|
|
||||||
reply += MainApp.sResources.getString(R.string.sms_iob) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
|
reply += MainApp.sResources.getString(R.string.sms_iob) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
|
||||||
+ MainApp.sResources.getString(R.string.sms_bolus) + " " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
|
+ MainApp.sResources.getString(R.string.sms_bolus) + " " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
|
||||||
|
|
|
@ -8,7 +8,6 @@ import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
@ -125,7 +124,7 @@ public class TreatmentsFragment extends SubscriberFragment implements View.OnCli
|
||||||
@Override
|
@Override
|
||||||
protected void updateGUI() {
|
protected void updateGUI() {
|
||||||
if (ConfigBuilderPlugin.getActivePump().getPumpDescription().isExtendedBolusCapable
|
if (ConfigBuilderPlugin.getActivePump().getPumpDescription().isExtendedBolusCapable
|
||||||
|| MainApp.getConfigBuilder().getExtendedBolusesFromHistory().size() > 0) {
|
|| TreatmentsPlugin.getPlugin().getExtendedBolusesFromHistory().size() > 0) {
|
||||||
extendedBolusesTab.setVisibility(View.VISIBLE);
|
extendedBolusesTab.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
extendedBolusesTab.setVisibility(View.GONE);
|
extendedBolusesTab.setVisibility(View.GONE);
|
||||||
|
|
|
@ -11,7 +11,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
@ -40,6 +39,9 @@ import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||||
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
|
import info.nightscout.utils.NSUpload;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,7 +105,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void initializeTempBasalData() {
|
private static void initializeTempBasalData() {
|
||||||
double dia = Constants.defaultDIA;
|
double dia = Constants.defaultDIA;
|
||||||
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
|
if (MainApp.getConfigBuilder() != null && MainApp.getConfigBuilder().getProfile() != null)
|
||||||
dia = MainApp.getConfigBuilder().getProfile().getDia();
|
dia = MainApp.getConfigBuilder().getProfile().getDia();
|
||||||
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
long fromMills = (long) (System.currentTimeMillis() - 60 * 60 * 1000L * (24 + dia));
|
||||||
|
@ -381,7 +383,19 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
@Override
|
@Override
|
||||||
public boolean addToHistoryExtendedBolus(ExtendedBolus extendedBolus) {
|
public boolean addToHistoryExtendedBolus(ExtendedBolus extendedBolus) {
|
||||||
//log.debug("Adding new ExtentedBolus record" + extendedBolus.log());
|
//log.debug("Adding new ExtentedBolus record" + extendedBolus.log());
|
||||||
return MainApp.getDbHelper().createOrUpdate(extendedBolus);
|
boolean newRecordCreated = MainApp.getDbHelper().createOrUpdate(extendedBolus);
|
||||||
|
if (newRecordCreated) {
|
||||||
|
if (extendedBolus.durationInMinutes == 0) {
|
||||||
|
if (MainApp.getConfigBuilder().getActivePump().isFakingTempsByExtendedBoluses())
|
||||||
|
NSUpload.uploadTempBasalEnd(extendedBolus.date, true, extendedBolus.pumpId);
|
||||||
|
else
|
||||||
|
NSUpload.uploadExtendedBolusEnd(extendedBolus.date, extendedBolus.pumpId);
|
||||||
|
} else if (MainApp.getConfigBuilder().getActivePump().isFakingTempsByExtendedBoluses())
|
||||||
|
NSUpload.uploadTempBasalStartAbsolute(new TemporaryBasal(extendedBolus), extendedBolus.insulin);
|
||||||
|
else
|
||||||
|
NSUpload.uploadExtendedBolus(extendedBolus);
|
||||||
|
}
|
||||||
|
return newRecordCreated;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -401,9 +415,19 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
@Override
|
@Override
|
||||||
public boolean addToHistoryTempBasal(TemporaryBasal tempBasal) {
|
public boolean addToHistoryTempBasal(TemporaryBasal tempBasal) {
|
||||||
//log.debug("Adding new TemporaryBasal record" + tempBasal.toString());
|
//log.debug("Adding new TemporaryBasal record" + tempBasal.toString());
|
||||||
return MainApp.getDbHelper().createOrUpdate(tempBasal);
|
boolean newRecordCreated = MainApp.getDbHelper().createOrUpdate(tempBasal);
|
||||||
|
if (newRecordCreated) {
|
||||||
|
if (tempBasal.durationInMinutes == 0)
|
||||||
|
NSUpload.uploadTempBasalEnd(tempBasal.date, false, tempBasal.pumpId);
|
||||||
|
else if (tempBasal.isAbsolute)
|
||||||
|
NSUpload.uploadTempBasalStartAbsolute(tempBasal, null);
|
||||||
|
else
|
||||||
|
NSUpload.uploadTempBasalStartPercent(tempBasal);
|
||||||
|
}
|
||||||
|
return newRecordCreated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// return true if new record is created
|
||||||
@Override
|
@Override
|
||||||
public boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo) {
|
public boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||||
Treatment treatment = new Treatment();
|
Treatment treatment = new Treatment();
|
||||||
|
@ -429,6 +453,8 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
MainApp.getDbHelper().createOrUpdate(carbsTreatment);
|
MainApp.getDbHelper().createOrUpdate(carbsTreatment);
|
||||||
//log.debug("Adding new Treatment record" + carbsTreatment);
|
//log.debug("Adding new Treatment record" + carbsTreatment);
|
||||||
}
|
}
|
||||||
|
if (newRecordCreated && detailedBolusInfo.isValid)
|
||||||
|
NSUpload.uploadBolusWizardRecord(detailedBolusInfo);
|
||||||
return newRecordCreated;
|
return newRecordCreated;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -503,7 +529,9 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
@Override
|
@Override
|
||||||
public void addToHistoryProfileSwitch(ProfileSwitch profileSwitch) {
|
public void addToHistoryProfileSwitch(ProfileSwitch profileSwitch) {
|
||||||
//log.debug("Adding new TemporaryBasal record" + profileSwitch.log());
|
//log.debug("Adding new TemporaryBasal record" + profileSwitch.log());
|
||||||
|
MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_SWITCH_MISSING));
|
||||||
MainApp.getDbHelper().createOrUpdate(profileSwitch);
|
MainApp.getDbHelper().createOrUpdate(profileSwitch);
|
||||||
|
NSUpload.uploadProfileSwitch(profileSwitch);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -15,11 +15,11 @@ import org.slf4j.LoggerFactory;
|
||||||
import butterknife.BindView;
|
import butterknife.BindView;
|
||||||
import butterknife.ButterKnife;
|
import butterknife.ButterKnife;
|
||||||
import butterknife.Unbinder;
|
import butterknife.Unbinder;
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog;
|
import info.nightscout.androidaps.plugins.PumpDanaR.Dialogs.ProfileViewDialog;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@ -114,8 +114,8 @@ public class ProfileViewerDialog extends DialogFragment {
|
||||||
|
|
||||||
private void setContent() {
|
private void setContent() {
|
||||||
Profile profile = null;
|
Profile profile = null;
|
||||||
ProfileSwitch profileSwitch = MainApp.getConfigBuilder().getProfileSwitchFromHistory(time);
|
ProfileSwitch profileSwitch = TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(time);
|
||||||
if(profileSwitch!=null && profileSwitch.profileJson != null){
|
if (profileSwitch != null && profileSwitch.profileJson != null) {
|
||||||
profile = profileSwitch.getProfileObject();
|
profile = profileSwitch.getProfileObject();
|
||||||
}
|
}
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
|
|
|
@ -5,7 +5,6 @@ import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.CardView;
|
import android.support.v7.widget.CardView;
|
||||||
|
@ -24,6 +23,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.data.Intervals;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.db.ExtendedBolus;
|
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
|
@ -31,11 +31,11 @@ import info.nightscout.androidaps.events.EventExtendedBolusChange;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
||||||
|
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.FabricPrivacy;
|
import info.nightscout.utils.FabricPrivacy;
|
||||||
import info.nightscout.utils.NSUpload;
|
import info.nightscout.utils.NSUpload;
|
||||||
import info.nightscout.androidaps.data.Intervals;
|
|
||||||
|
|
||||||
|
|
||||||
public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
|
public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
|
||||||
|
@ -176,7 +176,7 @@ public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
|
||||||
llm = new LinearLayoutManager(view.getContext());
|
llm = new LinearLayoutManager(view.getContext());
|
||||||
recyclerView.setLayoutManager(llm);
|
recyclerView.setLayoutManager(llm);
|
||||||
|
|
||||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getConfigBuilder().getExtendedBolusesFromHistory());
|
RecyclerViewAdapter adapter = new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getExtendedBolusesFromHistory());
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
context = getContext();
|
context = getContext();
|
||||||
|
@ -202,7 +202,7 @@ public class TreatmentsExtendedBolusesFragment extends SubscriberFragment {
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
recyclerView.swapAdapter(new RecyclerViewAdapter(MainApp.getConfigBuilder().getExtendedBolusesFromHistory()), false);
|
recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getExtendedBolusesFromHistory()), false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.CardView;
|
import android.support.v7.widget.CardView;
|
||||||
|
@ -23,15 +22,16 @@ import com.squareup.otto.Subscribe;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.Services.Intents;
|
import info.nightscout.androidaps.Services.Intents;
|
||||||
|
import info.nightscout.androidaps.data.Intervals;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.events.EventTempTargetChange;
|
import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
||||||
|
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.NSUpload;
|
import info.nightscout.utils.NSUpload;
|
||||||
import info.nightscout.androidaps.data.Intervals;
|
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -85,15 +85,14 @@ public class TreatmentsTempTargetFragment extends SubscriberFragment implements
|
||||||
holder.reasonColon.setText("");
|
holder.reasonColon.setText("");
|
||||||
}
|
}
|
||||||
if (tempTarget.isInProgress()) {
|
if (tempTarget.isInProgress()) {
|
||||||
if(tempTarget == currentlyActiveTarget){
|
if (tempTarget == currentlyActiveTarget) {
|
||||||
// active as newest
|
// active as newest
|
||||||
holder.date.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorInProgress));
|
holder.date.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorInProgress));
|
||||||
} else {
|
} else {
|
||||||
// other's that might become active again after the latest (overlapping) is over
|
// other's that might become active again after the latest (overlapping) is over
|
||||||
holder.date.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive));
|
holder.date.setTextColor(ContextCompat.getColor(MainApp.instance(), R.color.colorActive));
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
holder.date.setTextColor(holder.reasonColon.getCurrentTextColor());
|
holder.date.setTextColor(holder.reasonColon.getCurrentTextColor());
|
||||||
}
|
}
|
||||||
holder.remove.setTag(tempTarget);
|
holder.remove.setTag(tempTarget);
|
||||||
|
@ -176,7 +175,7 @@ public class TreatmentsTempTargetFragment extends SubscriberFragment implements
|
||||||
llm = new LinearLayoutManager(view.getContext());
|
llm = new LinearLayoutManager(view.getContext());
|
||||||
recyclerView.setLayoutManager(llm);
|
recyclerView.setLayoutManager(llm);
|
||||||
|
|
||||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getConfigBuilder().getTempTargetsFromHistory());
|
RecyclerViewAdapter adapter = new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getTempTargetsFromHistory());
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
refreshFromNS = (Button) view.findViewById(R.id.temptargetrange_refreshfromnightscout);
|
refreshFromNS = (Button) view.findViewById(R.id.temptargetrange_refreshfromnightscout);
|
||||||
|
@ -225,7 +224,7 @@ public class TreatmentsTempTargetFragment extends SubscriberFragment implements
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
recyclerView.swapAdapter(new RecyclerViewAdapter(MainApp.getConfigBuilder().getTempTargetsFromHistory()), false);
|
recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getTempTargetsFromHistory()), false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,6 @@ import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.v4.app.Fragment;
|
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.support.v7.app.AlertDialog;
|
import android.support.v7.app.AlertDialog;
|
||||||
import android.support.v7.widget.CardView;
|
import android.support.v7.widget.CardView;
|
||||||
|
@ -24,6 +23,7 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.data.Intervals;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
|
@ -32,11 +32,11 @@ import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
import info.nightscout.androidaps.plugins.NSClientInternal.UploadQueue;
|
||||||
|
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.FabricPrivacy;
|
import info.nightscout.utils.FabricPrivacy;
|
||||||
import info.nightscout.utils.NSUpload;
|
import info.nightscout.utils.NSUpload;
|
||||||
import info.nightscout.androidaps.data.Intervals;
|
|
||||||
|
|
||||||
|
|
||||||
public class TreatmentsTemporaryBasalsFragment extends SubscriberFragment {
|
public class TreatmentsTemporaryBasalsFragment extends SubscriberFragment {
|
||||||
|
@ -204,7 +204,7 @@ public class TreatmentsTemporaryBasalsFragment extends SubscriberFragment {
|
||||||
llm = new LinearLayoutManager(view.getContext());
|
llm = new LinearLayoutManager(view.getContext());
|
||||||
recyclerView.setLayoutManager(llm);
|
recyclerView.setLayoutManager(llm);
|
||||||
|
|
||||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getConfigBuilder().getTemporaryBasalsFromHistory());
|
RecyclerViewAdapter adapter = new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getTemporaryBasalsFromHistory());
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
tempBasalTotalView = (TextView) view.findViewById(R.id.tempbasals_totaltempiob);
|
tempBasalTotalView = (TextView) view.findViewById(R.id.tempbasals_totaltempiob);
|
||||||
|
@ -232,9 +232,9 @@ public class TreatmentsTemporaryBasalsFragment extends SubscriberFragment {
|
||||||
activity.runOnUiThread(new Runnable() {
|
activity.runOnUiThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
recyclerView.swapAdapter(new RecyclerViewAdapter(MainApp.getConfigBuilder().getTemporaryBasalsFromHistory()), false);
|
recyclerView.swapAdapter(new RecyclerViewAdapter(TreatmentsPlugin.getPlugin().getTemporaryBasalsFromHistory()), false);
|
||||||
if (MainApp.getConfigBuilder().getLastCalculationTempBasals() != null) {
|
if (TreatmentsPlugin.getPlugin().getLastCalculationTempBasals() != null) {
|
||||||
String totalText = DecimalFormatter.to2Decimal(MainApp.getConfigBuilder().getLastCalculationTempBasals().basaliob) + " U";
|
String totalText = DecimalFormatter.to2Decimal(TreatmentsPlugin.getPlugin().getLastCalculationTempBasals().basaliob) + " U";
|
||||||
tempBasalTotalView.setText(totalText);
|
tempBasalTotalView.setText(totalText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,9 @@ import android.support.annotation.NonNull;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.GregorianCalendar;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -42,6 +40,7 @@ import info.nightscout.androidaps.plugins.PumpDanaRKorean.DanaRKoreanPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
import info.nightscout.androidaps.plugins.PumpDanaRS.DanaRSPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
|
import info.nightscout.androidaps.plugins.PumpDanaRv2.DanaRv2Plugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.InsightPlugin;
|
import info.nightscout.androidaps.plugins.PumpInsight.InsightPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.utils.BolusWizard;
|
import info.nightscout.utils.BolusWizard;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
|
@ -245,7 +244,7 @@ public class ActionStringHandler {
|
||||||
lastBolusWizard = bolusWizard;
|
lastBolusWizard = bolusWizard;
|
||||||
|
|
||||||
} else if ("opencpp".equals(act[0])) {
|
} else if ("opencpp".equals(act[0])) {
|
||||||
ProfileSwitch activeProfileSwitch = MainApp.getConfigBuilder().getProfileSwitchFromHistory(System.currentTimeMillis());
|
ProfileSwitch activeProfileSwitch = TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(System.currentTimeMillis());
|
||||||
if (activeProfileSwitch == null) {
|
if (activeProfileSwitch == null) {
|
||||||
sendError("No active profile switch!");
|
sendError("No active profile switch!");
|
||||||
return;
|
return;
|
||||||
|
@ -257,7 +256,7 @@ public class ActionStringHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if ("cppset".equals(act[0])) {
|
} else if ("cppset".equals(act[0])) {
|
||||||
ProfileSwitch activeProfileSwitch = MainApp.getConfigBuilder().getProfileSwitchFromHistory(System.currentTimeMillis());
|
ProfileSwitch activeProfileSwitch = TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(System.currentTimeMillis());
|
||||||
if (activeProfileSwitch == null) {
|
if (activeProfileSwitch == null) {
|
||||||
sendError("No active profile switch!");
|
sendError("No active profile switch!");
|
||||||
return;
|
return;
|
||||||
|
@ -271,7 +270,7 @@ public class ActionStringHandler {
|
||||||
|
|
||||||
} else if ("tddstats".equals(act[0])) {
|
} else if ("tddstats".equals(act[0])) {
|
||||||
Object activePump = MainApp.getConfigBuilder().getActivePump();
|
Object activePump = MainApp.getConfigBuilder().getActivePump();
|
||||||
if (activePump!= null) {
|
if (activePump != null) {
|
||||||
// check if DB up to date
|
// check if DB up to date
|
||||||
List<TDD> dummies = new LinkedList<TDD>();
|
List<TDD> dummies = new LinkedList<TDD>();
|
||||||
List<TDD> historyList = getTDDList(dummies);
|
List<TDD> historyList = getTDDList(dummies);
|
||||||
|
@ -326,7 +325,7 @@ public class ActionStringHandler {
|
||||||
return "No profile loaded :(";
|
return "No profile loaded :(";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(historyList.isEmpty()){
|
if (historyList.isEmpty()) {
|
||||||
return "No history data!";
|
return "No history data!";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -336,7 +335,7 @@ public class ActionStringHandler {
|
||||||
double refTDD = profile.baseBasalSum() * 2;
|
double refTDD = profile.baseBasalSum() * 2;
|
||||||
|
|
||||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||||
if(df.format(new Date(historyList.get(0).date)).equals(df.format(new Date()))){
|
if (df.format(new Date(historyList.get(0).date)).equals(df.format(new Date()))) {
|
||||||
double tdd = historyList.get(0).getTotal();
|
double tdd = historyList.get(0).getTotal();
|
||||||
historyList.remove(0);
|
historyList.remove(0);
|
||||||
message += "Today: " + DecimalFormatter.to2Decimal(tdd) + "U " + (DecimalFormatter.to0Decimal(100 * tdd / refTDD) + "%") + "\n";
|
message += "Today: " + DecimalFormatter.to2Decimal(tdd) + "U " + (DecimalFormatter.to0Decimal(100 * tdd / refTDD) + "%") + "\n";
|
||||||
|
@ -394,7 +393,7 @@ public class ActionStringHandler {
|
||||||
boolean startsYesterday = activePump == dana || activePump == danaRS || activePump == danaV2 || activePump == danaKorean || activePump == insight;
|
boolean startsYesterday = activePump == dana || activePump == danaRS || activePump == danaV2 || activePump == danaKorean || activePump == insight;
|
||||||
|
|
||||||
DateFormat df = new SimpleDateFormat("dd.MM.");
|
DateFormat df = new SimpleDateFormat("dd.MM.");
|
||||||
return (historyList.size() < 3 || !(df.format(new Date(historyList.get(0).date)).equals(df.format(new Date(System.currentTimeMillis() - (startsYesterday?1000 * 60 * 60 * 24:0))))));
|
return (historyList.size() < 3 || !(df.format(new Date(historyList.get(0).date)).equals(df.format(new Date(System.currentTimeMillis() - (startsYesterday ? 1000 * 60 * 60 * 24 : 0))))));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
@ -480,7 +479,7 @@ public class ActionStringHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Check for Temp-Target:
|
//Check for Temp-Target:
|
||||||
TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory();
|
TempTarget tempTarget = TreatmentsPlugin.getPlugin().getTempTargetFromHistory();
|
||||||
if (tempTarget != null) {
|
if (tempTarget != null) {
|
||||||
ret += "Temp Target: " + Profile.toTargetRangeString(tempTarget.low, tempTarget.low, Constants.MGDL, profile.getUnits());
|
ret += "Temp Target: " + Profile.toTargetRangeString(tempTarget.low, tempTarget.low, Constants.MGDL, profile.getUnits());
|
||||||
ret += "\nuntil: " + DateUtil.timeString(tempTarget.originalEnd());
|
ret += "\nuntil: " + DateUtil.timeString(tempTarget.originalEnd());
|
||||||
|
@ -663,7 +662,7 @@ public class ActionStringHandler {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo);
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,6 +46,7 @@ import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugi
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus;
|
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus;
|
||||||
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Wear.ActionStringHandler;
|
import info.nightscout.androidaps.plugins.Wear.ActionStringHandler;
|
||||||
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
|
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
@ -374,8 +375,8 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
double beginBasalValue = profile.getBasal(beginBasalSegmentTime);
|
double beginBasalValue = profile.getBasal(beginBasalSegmentTime);
|
||||||
double endBasalValue = beginBasalValue;
|
double endBasalValue = beginBasalValue;
|
||||||
|
|
||||||
TemporaryBasal tb1 = MainApp.getConfigBuilder().getTempBasalFromHistory(runningTime);
|
TemporaryBasal tb1 = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(runningTime);
|
||||||
TemporaryBasal tb2 = MainApp.getConfigBuilder().getTempBasalFromHistory(runningTime);
|
TemporaryBasal tb2 = TreatmentsPlugin.getPlugin().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;
|
||||||
|
@ -404,7 +405,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
}
|
}
|
||||||
|
|
||||||
//temps
|
//temps
|
||||||
tb2 = MainApp.getConfigBuilder().getTempBasalFromHistory(runningTime);
|
tb2 = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(runningTime);
|
||||||
|
|
||||||
if (tb1 == null && tb2 == null) {
|
if (tb1 == null && tb2 == null) {
|
||||||
//no temp stays no temp
|
//no temp stays no temp
|
||||||
|
@ -437,7 +438,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().getTempBasalFromHistory(now); //use "now" to express current situation
|
tb2 = TreatmentsPlugin.getPlugin().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));
|
||||||
|
@ -453,7 +454,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
tb2 = MainApp.getConfigBuilder().getTempBasalFromHistory(now); //use "now" to express current situation
|
tb2 = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now); //use "now" to express current situation
|
||||||
if (tb2 != null) {
|
if (tb2 != null) {
|
||||||
//onset at the end
|
//onset at the end
|
||||||
Profile profileTB = MainApp.getConfigBuilder().getProfile(runningTime);
|
Profile profileTB = MainApp.getConfigBuilder().getProfile(runningTime);
|
||||||
|
@ -462,7 +463,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Treatment> treatments = MainApp.getConfigBuilder().getTreatmentsFromHistory();
|
List<Treatment> treatments = TreatmentsPlugin.getPlugin().getTreatmentsFromHistory();
|
||||||
for (Treatment treatment : treatments) {
|
for (Treatment treatment : treatments) {
|
||||||
if (treatment.date > startTimeWindow) {
|
if (treatment.date > startTimeWindow) {
|
||||||
boluses.add(treatmentMap(treatment.date, treatment.insulin, treatment.carbs, treatment.isSMB, treatment.isValid));
|
boluses.add(treatmentMap(treatment.date, treatment.insulin, treatment.carbs, treatment.isSMB, treatment.isValid));
|
||||||
|
@ -582,7 +583,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
String iobSum, iobDetail, cobString, currentBasal, bgiString;
|
String iobSum, iobDetail, cobString, currentBasal, bgiString;
|
||||||
iobSum = iobDetail = cobString = currentBasal = bgiString = "";
|
iobSum = iobDetail = cobString = currentBasal = bgiString = "";
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
TreatmentsInterface treatmentsInterface = TreatmentsPlugin.getPlugin();
|
||||||
treatmentsInterface.updateTotalIOBTreatments();
|
treatmentsInterface.updateTotalIOBTreatments();
|
||||||
IobTotal bolusIob = treatmentsInterface.getLastCalculationTreatments().round();
|
IobTotal bolusIob = treatmentsInterface.getLastCalculationTreatments().round();
|
||||||
treatmentsInterface.updateTotalIOBTempBasals();
|
treatmentsInterface.updateTotalIOBTempBasals();
|
||||||
|
|
|
@ -9,7 +9,6 @@ import android.support.annotation.NonNull;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Config;
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
|
@ -27,6 +26,7 @@ import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.utils.DecimalFormatter;
|
import info.nightscout.utils.DecimalFormatter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,7 +118,7 @@ public class StatuslinePlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Temp basal
|
//Temp basal
|
||||||
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
|
TreatmentsInterface treatmentsInterface = TreatmentsPlugin.getPlugin();
|
||||||
|
|
||||||
TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal activeTemp = treatmentsInterface.getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
|
|
|
@ -6,10 +6,10 @@ import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||||
import info.nightscout.androidaps.db.Source;
|
import info.nightscout.androidaps.db.Source;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
|
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
import info.nightscout.androidaps.queue.Callback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -32,7 +32,7 @@ public class CommandSetProfile extends Command {
|
||||||
callback.result(r).run();
|
callback.result(r).run();
|
||||||
|
|
||||||
// Send SMS notification if ProfileSwitch is comming from NS
|
// Send SMS notification if ProfileSwitch is comming from NS
|
||||||
ProfileSwitch profileSwitch = MainApp.getConfigBuilder().getProfileSwitchFromHistory(System.currentTimeMillis());
|
ProfileSwitch profileSwitch = TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(System.currentTimeMillis());
|
||||||
if (r.enacted && profileSwitch.source == Source.NIGHTSCOUT) {
|
if (r.enacted && profileSwitch.source == Source.NIGHTSCOUT) {
|
||||||
SmsCommunicatorPlugin smsCommunicatorPlugin = MainApp.getSpecificPlugin(SmsCommunicatorPlugin.class);
|
SmsCommunicatorPlugin smsCommunicatorPlugin = MainApp.getSpecificPlugin(SmsCommunicatorPlugin.class);
|
||||||
if (smsCommunicatorPlugin != null && smsCommunicatorPlugin.isEnabled(PluginType.GENERAL)) {
|
if (smsCommunicatorPlugin != null && smsCommunicatorPlugin.isEnabled(PluginType.GENERAL)) {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package info.nightscout.utils;
|
package info.nightscout.utils;
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
|
||||||
import info.nightscout.androidaps.data.GlucoseStatus;
|
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 11.10.2016.
|
* Created by mike on 11.10.2016.
|
||||||
|
@ -93,7 +93,7 @@ public class BolusWizard {
|
||||||
|
|
||||||
// Insulin from IOB
|
// Insulin from IOB
|
||||||
// IOB calculation
|
// IOB calculation
|
||||||
TreatmentsInterface treatments = MainApp.getConfigBuilder();
|
TreatmentsInterface treatments = TreatmentsPlugin.getPlugin();
|
||||||
treatments.updateTotalIOBTreatments();
|
treatments.updateTotalIOBTreatments();
|
||||||
IobTotal bolusIob = treatments.getLastCalculationTreatments().round();
|
IobTotal bolusIob = treatments.getLastCalculationTreatments().round();
|
||||||
treatments.updateTotalIOBTempBasals();
|
treatments.updateTotalIOBTempBasals();
|
||||||
|
|
|
@ -15,6 +15,7 @@ import info.nightscout.androidaps.db.Treatment;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.PumpMDI.MDIPlugin;
|
import info.nightscout.androidaps.plugins.PumpMDI.MDIPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
|
||||||
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
@ -23,7 +24,7 @@ import static org.mockito.Mockito.when;
|
||||||
* Created by kuchjir on 12/12/2017.
|
* Created by kuchjir on 12/12/2017.
|
||||||
*/
|
*/
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest( { MainApp.class, GlucoseStatus.class, ConfigBuilderPlugin.class })
|
@PrepareForTest( { MainApp.class, GlucoseStatus.class, ConfigBuilderPlugin.class, TreatmentsPlugin.class })
|
||||||
public class BolusWizardTest {
|
public class BolusWizardTest {
|
||||||
private static final double PUMP_BOLUS_STEP = 0.1;
|
private static final double PUMP_BOLUS_STEP = 0.1;
|
||||||
|
|
||||||
|
@ -68,12 +69,13 @@ public class BolusWizardTest {
|
||||||
PowerMockito.mockStatic(GlucoseStatus.class);
|
PowerMockito.mockStatic(GlucoseStatus.class);
|
||||||
when(GlucoseStatus.getGlucoseStatusData()).thenReturn(null);
|
when(GlucoseStatus.getGlucoseStatusData()).thenReturn(null);
|
||||||
|
|
||||||
ConfigBuilderPlugin treatment = mock(ConfigBuilderPlugin.class);
|
PowerMockito.mockStatic(TreatmentsPlugin.class);
|
||||||
|
TreatmentsPlugin treatment = mock(TreatmentsPlugin.class);
|
||||||
IobTotal iobTotalZero = new IobTotal(System.currentTimeMillis());
|
IobTotal iobTotalZero = new IobTotal(System.currentTimeMillis());
|
||||||
when(treatment.getLastCalculationTreatments()).thenReturn(iobTotalZero);
|
when(treatment.getLastCalculationTreatments()).thenReturn(iobTotalZero);
|
||||||
when(treatment.getLastCalculationTempBasals()).thenReturn(iobTotalZero);
|
when(treatment.getLastCalculationTempBasals()).thenReturn(iobTotalZero);
|
||||||
PowerMockito.mockStatic(MainApp.class);
|
PowerMockito.mockStatic(MainApp.class);
|
||||||
when(MainApp.getConfigBuilder()).thenReturn(treatment);
|
when(TreatmentsPlugin.getPlugin()).thenReturn(treatment);
|
||||||
|
|
||||||
PowerMockito.mockStatic(ConfigBuilderPlugin.class);
|
PowerMockito.mockStatic(ConfigBuilderPlugin.class);
|
||||||
PumpInterface pump = MDIPlugin.getPlugin();
|
PumpInterface pump = MDIPlugin.getPlugin();
|
||||||
|
|
Loading…
Reference in a new issue