Add BatteryReplaceable PumpCapability and hide Battery change button in Actions tab for pumps without this capability (Omnipod); create battery change and insulin change careportal event after activating new Pod

This commit is contained in:
Bart Sopers 2020-09-03 23:35:03 +02:00
parent 4f6e31a784
commit cd5bc21b17
5 changed files with 33 additions and 24 deletions

View file

@ -25,7 +25,6 @@ import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction
import info.nightscout.androidaps.plugins.general.overview.StatusLightHandler
import info.nightscout.androidaps.queue.Callback
import info.nightscout.androidaps.utils.FabricPrivacy
import info.nightscout.androidaps.utils.ui.SingleClickButton
import info.nightscout.androidaps.utils.alertDialogs.OKDialog
import info.nightscout.androidaps.utils.buildHelper.BuildHelper
import info.nightscout.androidaps.utils.extensions.plusAssign
@ -33,6 +32,7 @@ import info.nightscout.androidaps.utils.extensions.toVisibility
import info.nightscout.androidaps.utils.protection.ProtectionCheck
import info.nightscout.androidaps.utils.resources.ResourceHelper
import info.nightscout.androidaps.utils.sharedPreferences.SP
import info.nightscout.androidaps.utils.ui.SingleClickButton
import info.nightscout.androidaps.utils.ui.UIRunnable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.disposables.CompositeDisposable
@ -236,6 +236,7 @@ class ActionsFragment : DaggerFragment() {
actions_historybrowser.visibility = (profile != null).toVisibility()
actions_fill?.visibility = (pump.pumpDescription.isRefillingCapable && pump.isInitialized && !pump.isSuspended).toVisibility()
actions_pumpbatterychange?.visibility = pump.pumpDescription.isBatteryReplaceable.toVisibility()
actions_temptarget?.visibility = (profile != null && config.APS).toVisibility()
actions_tddstats?.visibility = pump.pumpDescription.supportsTDDs.toVisibility()

View file

@ -11,7 +11,6 @@ import javax.inject.Inject;
import javax.inject.Singleton;
import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.DetailedBolusInfo;
import info.nightscout.androidaps.data.Profile;
@ -69,6 +68,7 @@ public class MDIPlugin extends PumpPluginBase implements PumpInterface {
pumpDescription.isTempBasalCapable = false;
pumpDescription.isSetBasalProfileCapable = false;
pumpDescription.isRefillingCapable = false;
pumpDescription.isBatteryReplaceable = false;
}
@Override

View file

@ -11,11 +11,11 @@ import info.nightscout.androidaps.plugins.pump.common.defs.PumpType;
public class PumpDescription {
public PumpType pumpType = PumpType.GenericAAPS;
public PumpDescription () {
public PumpDescription() {
resetSettings();
}
public PumpDescription (PumpType pumpType) {
public PumpDescription(PumpType pumpType) {
this();
setPumpDescription(pumpType);
}
@ -52,6 +52,7 @@ public class PumpDescription {
public double basalMaximumRate;
public boolean isRefillingCapable;
public boolean isBatteryReplaceable;
public boolean storesCarbInfo;
@ -88,7 +89,8 @@ public class PumpDescription {
basalMaximumRate = 25d;
is30minBasalRatesCapable = false;
isRefillingCapable = false;
isRefillingCapable = true;
isBatteryReplaceable = true;
storesCarbInfo = true;
supportsTDDs = false;
@ -136,6 +138,7 @@ public class PumpDescription {
basalMinimumRate = pumpType.getBaseBasalMinValue();
isRefillingCapable = pumpCapability.hasCapability(PumpCapability.Refill);
isBatteryReplaceable = pumpCapability.hasCapability(PumpCapability.ReplaceBattery);
storesCarbInfo = pumpCapability.hasCapability(PumpCapability.StoreCarbInfo);
supportsTDDs = pumpCapability.hasCapability(PumpCapability.TDD);

View file

@ -11,18 +11,19 @@ public enum PumpCapability {
TempBasal, // isTempBasalCapable
BasalProfileSet, // isSetBasalProfileCapable
Refill, // isRefillingCapable
ReplaceBattery, // isBatteryReplaceable
StoreCarbInfo, // storesCarbInfo
TDD, // supportsTDDs
ManualTDDLoad, // needsManualTDDLoad
BasalRate30min, // is30minBasalRatesCapable
// grouped by pump
VirtualPumpCapabilities(Bolus, ExtendedBolus, TempBasal, BasalProfileSet, Refill), //
ComboCapabilities(Bolus, TempBasal, BasalProfileSet, Refill, TDD, ManualTDDLoad), //
DanaCapabilities(Bolus, ExtendedBolus, TempBasal, BasalProfileSet, Refill, TDD, ManualTDDLoad), //
DanaWithHistoryCapabilities(Bolus, ExtendedBolus, TempBasal, BasalProfileSet, Refill, StoreCarbInfo, TDD, ManualTDDLoad), //
InsightCapabilities(Bolus, ExtendedBolus, TempBasal, BasalProfileSet, Refill,TDD,BasalRate30min), //
MedtronicCapabilities(Bolus, TempBasal, BasalProfileSet, Refill, TDD), //
VirtualPumpCapabilities(Bolus, ExtendedBolus, TempBasal, BasalProfileSet, Refill, ReplaceBattery), //
ComboCapabilities(Bolus, TempBasal, BasalProfileSet, Refill, ReplaceBattery, TDD, ManualTDDLoad), //
DanaCapabilities(Bolus, ExtendedBolus, TempBasal, BasalProfileSet, Refill, ReplaceBattery, TDD, ManualTDDLoad), //
DanaWithHistoryCapabilities(Bolus, ExtendedBolus, TempBasal, BasalProfileSet, Refill, ReplaceBattery, StoreCarbInfo, TDD, ManualTDDLoad), //
InsightCapabilities(Bolus, ExtendedBolus, TempBasal, BasalProfileSet, Refill, ReplaceBattery, TDD, BasalRate30min), //
MedtronicCapabilities(Bolus, TempBasal, BasalProfileSet, Refill, ReplaceBattery, TDD), //
OmnipodCapabilities(Bolus, TempBasal, BasalProfileSet, BasalRate30min), //
// BasalRates (separately grouped)
@ -35,19 +36,16 @@ public enum PumpCapability {
PumpCapability[] children;
PumpCapability()
{
PumpCapability() {
}
PumpCapability(PumpCapability...children)
{
PumpCapability(PumpCapability... children) {
this.children = children;
}
public boolean hasCapability(PumpCapability capability)
{
public boolean hasCapability(PumpCapability capability) {
// we can only check presense of simple capabilities
if (capability.children != null)
return false;
@ -55,19 +53,16 @@ public enum PumpCapability {
if (this == capability)
return true;
if (this.children!=null)
{
if (this.children != null) {
for (PumpCapability child : children) {
if (child == capability)
return true;
}
return false;
}
else
} else
return false;
}
}

View file

@ -12,6 +12,7 @@ import dagger.android.HasAndroidInjector;
import info.nightscout.androidaps.db.CareportalEvent;
import info.nightscout.androidaps.db.Source;
import info.nightscout.androidaps.interfaces.DatabaseHelperInterface;
import info.nightscout.androidaps.interfaces.ProfileFunction;
import info.nightscout.androidaps.logging.AAPSLogger;
import info.nightscout.androidaps.logging.LTag;
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
@ -27,14 +28,17 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
public class InitPodRefreshAction extends AbstractCancelAction implements FinishActionInterface {
private final PodActionType actionType;
private final HasAndroidInjector injector;
@Inject PodStateManager podStateManager;
@Inject AAPSLogger aapsLogger;
@Inject SP sp;
@Inject NSUpload nsUpload;
@Inject DatabaseHelperInterface databaseHelper;
@Inject ProfileFunction profileFunction;
public InitPodRefreshAction(HasAndroidInjector injector, PodActionType actionType) {
this.injector = injector;
injector.androidInjector().inject(this);
this.actionType = actionType;
}
@ -50,6 +54,8 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish
public void execute() {
if (actionType == PodActionType.INIT_POD) {
if (podStateManager.isPodRunning()) {
uploadCareportalEvent(System.currentTimeMillis() - 2000, CareportalEvent.PUMPBATTERYCHANGE);
uploadCareportalEvent(System.currentTimeMillis() - 1000, CareportalEvent.INSULINCHANGE);
uploadCareportalEvent(System.currentTimeMillis(), CareportalEvent.SITECHANGE);
}
}
@ -61,10 +67,14 @@ public class InitPodRefreshAction extends AbstractCancelAction implements Finish
try {
JSONObject data = new JSONObject();
String enteredBy = sp.getString("careportal_enteredby", "");
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
if (enteredBy.isEmpty()) {
data.put("enteredBy", enteredBy);
}
data.put("created_at", DateUtil.toISOString(date));
data.put("mills", date);
data.put("eventType", event);
CareportalEvent careportalEvent = new CareportalEvent();
data.put("units", profileFunction.getUnits());
CareportalEvent careportalEvent = new CareportalEvent(injector);
careportalEvent.date = date;
careportalEvent.source = Source.USER;
careportalEvent.eventType = event;