From 416bd2ff4182a85524224bdbb912b85ce2008edb Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Wed, 2 May 2018 23:59:33 +0100 Subject: [PATCH 1/7] Feature Request/Bug #863 - added package PumpCommon for common pump files - added DoseSettings, DoseStepSize, PumpTempBasalType which are needed for PumpType - added PumpType which contains all definitions for pumps - extended fragement to display Pump Type and Pump Type definitions - extended plugin to read configuration and set pumpDescription object - extended pref_virtualpump to add pump type selection --- .../interfaces/PumpDescription.java | 36 +++ .../plugins/PumpCommon/data/DoseSettings.java | 49 ++++ .../plugins/PumpCommon/defs/DoseStepSize.java | 84 ++++++ .../PumpCommon/defs/PumpTempBasalType.java | 10 + .../plugins/PumpCommon/defs/PumpType.java | 271 ++++++++++++++++++ .../plugins/PumpCommon/utils/PumpUtil.java | 49 ++++ .../PumpVirtual/VirtualPumpFragment.java | 20 ++ .../PumpVirtual/VirtualPumpPlugin.java | 32 +++ .../main/res/layout/virtualpump_fragment.xml | 94 ++++++ app/src/main/res/values/arrays.xml | 21 ++ app/src/main/res/values/strings.xml | 4 + app/src/main/res/xml/pref_virtualpump.xml | 8 + 12 files changed, 678 insertions(+) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/data/DoseSettings.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/DoseStepSize.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpTempBasalType.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtil.java diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java index 701b226031..10b0b3f453 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java @@ -37,4 +37,40 @@ public class PumpDescription { public boolean isRefillingCapable = false; public boolean storesCarbInfo = true; + + + public void resetSettings() + { + isBolusCapable = true; + bolusStep = 0.1d; + + isExtendedBolusCapable = true; + extendedBolusStep = 0.1d; + extendedBolusDurationStep = 30; + extendedBolusMaxDuration = 12 * 60; + + isTempBasalCapable = true; + tempBasalStyle = PERCENT; + + maxTempPercent = 200; + tempPercentStep = 10; + + maxTempAbsolute = 10; + tempAbsoluteStep = 0.05d; + + tempDurationStep = 60; + tempMaxDuration = 12 * 60; + + + isSetBasalProfileCapable = true; + basalStep = 0.01d; + basalMinimumRate = 0.04d; + + isRefillingCapable = false; + + storesCarbInfo = true; + + } + + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/data/DoseSettings.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/data/DoseSettings.java new file mode 100644 index 0000000000..36ee4e5845 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/data/DoseSettings.java @@ -0,0 +1,49 @@ +package info.nightscout.androidaps.plugins.PumpCommon.data; + +/** + * Created by andy on 02/05/2018. + */ + +public class DoseSettings { + + private float step; + private int durationStep; + private int maxDuration; + private float minDose; + private Float maxDose; + + public DoseSettings(float step, int durationStep, int maxDuration, float minDose, Float maxDose) + { + this.step = step; + this.durationStep = durationStep; + this.maxDuration = maxDuration; + this.minDose = minDose; + this.maxDose = maxDose; + } + + public DoseSettings(float step, int durationStep, int maxDuration, float minDose) + { + this(step, durationStep, maxDuration, minDose, null); + } + + + public float getStep() { + return step; + } + + public int getDurationStep() { + return durationStep; + } + + public int getMaxDuration() { + return maxDuration; + } + + public float getMinDose() { + return minDose; + } + + public Float getMaxDose() { + return maxDose; + } +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/DoseStepSize.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/DoseStepSize.java new file mode 100644 index 0000000000..84293a0192 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/DoseStepSize.java @@ -0,0 +1,84 @@ +package info.nightscout.androidaps.plugins.PumpCommon.defs; + +/** + * Created by andy on 02/05/2018. + */ + +public enum DoseStepSize +{ + + ComboBasal( // + new DoseStepSizeEntry(0f, 1f, 0.01f), // + new DoseStepSizeEntry(1f, 10f, 0.05f), // + new DoseStepSizeEntry(10f, Float.MAX_VALUE, 0.1f)), // + + MedtronicVeoBasal( // + new DoseStepSizeEntry(0f, 1f, 0.025f), // + new DoseStepSizeEntry(1f, 10f, 0.05f), // + new DoseStepSizeEntry(10f, Float.MAX_VALUE, 0.1f)), // + + ; + + + DoseStepSizeEntry[] entries; + + + DoseStepSize(DoseStepSizeEntry...entries) + { + this.entries = entries; + } + + + public float getStepSizeForAmount(float amount) + { + for (DoseStepSizeEntry entry : entries) { + if (entry.from <= amount && entry.to > amount) + return entry.value; + } + + // should never come to this + return entries[entries.length-1].value; + } + + + public String getDescription() { + StringBuilder sb = new StringBuilder(); + + for (DoseStepSizeEntry entry : entries) { + + sb.append(entry.value); + sb.append(" {"); + sb.append(entry.from); + sb.append("-"); + + if (entry.to == Float.MAX_VALUE) + { + sb.append("~}"); + } + else + { + sb.append(entry.to); + sb.append("}, "); + } + } + + return sb.toString(); + } + + + static class DoseStepSizeEntry + { + float from; + float to; + float value; + + // to = this value is not included, but would actually mean <, so for rates between 0.025-0.975 u/h, we would have [from=0, to=10] + DoseStepSizeEntry(float from, float to, float value) + { + this.from = from; + this.to = to; + this.value = value; + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpTempBasalType.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpTempBasalType.java new file mode 100644 index 0000000000..167e886ea7 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpTempBasalType.java @@ -0,0 +1,10 @@ +package info.nightscout.androidaps.plugins.PumpCommon.defs; + +/** + * Created by andy on 02/05/2018. + */ + +public enum PumpTempBasalType { + Percent, // + Absolute, +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java new file mode 100644 index 0000000000..eac100cf0b --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java @@ -0,0 +1,271 @@ +package info.nightscout.androidaps.plugins.PumpCommon.defs; + + +import java.util.HashMap; +import java.util.Map; + +import info.nightscout.androidaps.plugins.PumpCommon.data.DoseSettings; + +/** + * Created by andy on 02/05/2018. + * + * Most of this defintions is intended for VirtualPump only, but they can be used by other plugins. + */ + +public enum PumpType { + + GenericAAPS("Generic AAPS", 0.1f, null, // + new DoseSettings(0.05f, 30, 8*60, 0.05f), // + PumpTempBasalType.Percent, // + new DoseSettings(10,30, 24*60, 0f, 500f), // + 0.01f, 0.01f, null), // + + // Cellnovo + + Cellnovo1("Cellnovo", 0.05f, null, // + new DoseSettings(0.05f, 30, 24*60, 1f, null), + PumpTempBasalType.Percent, + new DoseSettings(5,30, 24*60, 0f, 200f), // + 0.05f, 0.05f, null), // + + // Accu-Chek + + AccuChekCombo("Accu-Chek Combo", 0.1f, null, // + new DoseSettings(0.1f, 15, 12*60, 0.1f), // + PumpTempBasalType.Percent, + new DoseSettings(10, 15, 12*60,0f, 500f), // + 0.01f, 0.1f, DoseStepSize.ComboBasal), // + + AccuChekSpirit("Accu-Chek Spirit", AccuChekCombo), // + + + // Animas + AnimasVibe("Animas Vibe", 0.05f, null, // AnimasBolus? + new DoseSettings(0.05f, 30, 12*60, 0.05f), // + PumpTempBasalType.Percent, // + new DoseSettings(10, 30, 24*60, 0f, 200f), // + 0.025f, 5f, 0f, null), // + + AnimasPing("Animas Ping", AnimasVibe), + + // Insulet + Insulet_Omnipod("Insulet Omnipod", 0.05f, null, // + new DoseSettings(0.05f, 30, 8*60, 0.05f), // + PumpTempBasalType.Absolute, // + new DoseSettings(0.05f, 30, 12*60, 0f, 5.0f), // cannot exceed max basal rate 30u/hr + 0.05f, 0.05f, null), + + // Medtronic + Minimed_512_712("Medtronic 512/712", 0.05f, null, // + new DoseSettings(0.05f, 30, 8*60, 0.05f), // + PumpTempBasalType.Absolute, // + new DoseSettings(0.05f, 30, 24*60, 0f, 35f), // + 0.05f, 0.05f, null), // TODO + + Minimed_515_715("Medtronic 515/715", Minimed_512_712), // TODO + Minimed_522_722("Medtronic 522/722", Minimed_512_712), // TODO + Minimed_523_723("Medtronic 523/723", Minimed_512_712), // TODO + + Minimed_553_753_Revel("Medtronic 553/753 (Revel)", 0.05f, null, // + new DoseSettings(0.05f, 30, 8*60, 0.05f), // + PumpTempBasalType.Absolute, // + new DoseSettings(0.05f, 30, 24*60, 0f, 35f), // + 0.025f, 0.025f, DoseStepSize.MedtronicVeoBasal), // + + Minimed_554_754_Veo("Medtronic 554/754 (Veo)", Minimed_553_753_Revel), // TODO + + Minimed_640G("Medtronic 640G", 0.025f, null, // + new DoseSettings(0.05f, 30, 8*60, 0.05f), // + PumpTempBasalType.Absolute, // + new DoseSettings(0.05f, 30, 24*60, 0f, 35f), // + 0.025f, 0.025f, DoseStepSize.MedtronicVeoBasal), // + + // Tandem + TandemTSlim("Tandem t:slim", 0.01f, null, // + new DoseSettings(0.01f,15, 8*60, 0.4f) , + PumpTempBasalType.Percent, + new DoseSettings(1,15, 8*60, 0f, 250f), // + 0.1f, 0.001f, null), + + TandemTFlex("Tandem t:flex", TandemTSlim), // + TandemTSlimG4("Tandem t:slim G4", TandemTSlim), // + TandemTSlimX2("Tandem t:slim X2", TandemTSlim), // + ; + + private String description; + private float bolusSize; + private DoseStepSize specialBolusSize; + private DoseSettings extendedBolusSettings; + private PumpTempBasalType pumpTempBasalType; + private DoseSettings tbrSettings; + private float baseBasalMinValue; // + private float baseBasalMaxValue; + private float baseBasalStep; // + private DoseStepSize baseBasalSpecialSteps; // + + private PumpType parent; + private static Map mapByDescription; + + static + { + mapByDescription = new HashMap<>(); + + for (PumpType pumpType : values()) { + mapByDescription.put(pumpType.getDescription(), pumpType); + } + } + + + PumpType(String description, PumpType parent) + { + this.description = description; + this.parent = parent; + } + + + PumpType(String description, float bolusSize, DoseStepSize specialBolusSize, // + DoseSettings extendedBolusSettings, // + PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, // + float baseBasalMinValue, float baseBasalStep, DoseStepSize baseBasalSpecialSteps) + { + this.description = description; + this.bolusSize = bolusSize; + this.specialBolusSize = specialBolusSize; + this.extendedBolusSettings = extendedBolusSettings; + this.pumpTempBasalType = pumpTempBasalType; + this.tbrSettings = tbrSettings; + this.baseBasalMinValue = baseBasalMinValue; + this.baseBasalStep = baseBasalStep; + this.baseBasalSpecialSteps = baseBasalSpecialSteps; + } + + PumpType(String description, float bolusSize, DoseStepSize specialBolusSize, // + DoseSettings extendedBolusSettings, // + PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, // + float baseBasalMinValue, float baseBasalMaxValue, float baseBasalStep, DoseStepSize baseBasalSpecialSteps) + { + this.description = description; + this.bolusSize = bolusSize; + this.specialBolusSize = specialBolusSize; + this.extendedBolusSettings = extendedBolusSettings; + this.pumpTempBasalType = pumpTempBasalType; + this.tbrSettings = tbrSettings; + this.baseBasalMinValue = baseBasalMinValue; + this.baseBasalMaxValue = baseBasalMaxValue; + this.baseBasalStep = baseBasalStep; + this.baseBasalSpecialSteps = baseBasalSpecialSteps; + } + + + public String getDescription() { + return description; + } + + + public float getBolusSize() { + return isParentSet() ? parent.bolusSize : bolusSize; + } + + + public DoseStepSize getSpecialBolusSize() { + return isParentSet() ? parent.specialBolusSize : specialBolusSize; + } + + + public DoseSettings getExtendedBolusSettings() { + return isParentSet() ? parent.extendedBolusSettings : extendedBolusSettings; + } + + + public PumpTempBasalType getPumpTempBasalType() { + return isParentSet() ? parent.pumpTempBasalType : pumpTempBasalType; + } + + + public DoseSettings getTbrSettings() { + return isParentSet() ? parent.tbrSettings : tbrSettings; + } + + + public float getBaseBasalMinValue() { + return isParentSet() ? parent.baseBasalMinValue : baseBasalMinValue; + } + + + public Float getBaseBasalMaxValue() { + return isParentSet() ? parent.baseBasalMaxValue : baseBasalMaxValue; + } + + + public float getBaseBasalStep() { + return isParentSet() ? parent.baseBasalStep : baseBasalStep; + } + + + public DoseStepSize getBaseBasalSpecialSteps() { + return isParentSet() ? parent.baseBasalSpecialSteps : baseBasalSpecialSteps; + } + + + public PumpType getParent() { + return parent; + } + + + private boolean isParentSet() + { + return this.parent!=null; + } + + + public static PumpType getByDescription(String desc) + { + if (mapByDescription.containsKey(desc)) + { + return mapByDescription.get(desc); + } + else + { + return PumpType.GenericAAPS; + } + } + + + public String getFullDescription(String i18nTemplate) { + + String unit = getPumpTempBasalType()==PumpTempBasalType.Percent ? "%" : ""; + + DoseSettings eb = getExtendedBolusSettings(); + DoseSettings tbr = getTbrSettings(); + + return String.format(i18nTemplate, // + getStep("" + getBolusSize(), getSpecialBolusSize()), // + eb.getStep(), eb.getDurationStep(), eb.getMaxDuration()/60, // + getStep(getBaseBasalRange(), getBaseBasalSpecialSteps()), // + tbr.getMinDose() + unit + "-" + tbr.getMaxDose() + unit, tbr.getStep() + unit, tbr.getDurationStep(), tbr.getMaxDuration()/60); + } + + + private String getBaseBasalRange() + { + Float maxValue = getBaseBasalMaxValue(); + + return maxValue==null ? "" + getBaseBasalMinValue() : getBaseBasalMinValue() + "-" + maxValue; + } + + + private String getStep(String step, DoseStepSize stepSize) + { + if (stepSize!=null) + return step + " [" + stepSize.getDescription() + "] *"; + else + return "" + step; + } + + + public boolean hasExtendedBasals() { + return ((getBaseBasalSpecialSteps() !=null) || (getSpecialBolusSize() != null)); + } + + +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtil.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtil.java new file mode 100644 index 0000000000..87c7f07ba4 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtil.java @@ -0,0 +1,49 @@ +package info.nightscout.androidaps.plugins.PumpCommon.utils; + +import info.nightscout.androidaps.interfaces.PumpDescription; +import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpTempBasalType; +import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType; + +/** + * Created by andy on 02/05/2018. + */ + +public class PumpUtil { + + // for now used only by VirtualPump, but with small changes could be used by any constructor + public static void setPumpDescription(PumpDescription pumpDescription, PumpType pumpType) + { + pumpDescription.isBolusCapable = true; + pumpDescription.bolusStep = pumpType.getBolusSize(); + + pumpDescription.isExtendedBolusCapable = true; + pumpDescription.extendedBolusStep = pumpType.getExtendedBolusSettings().getStep(); + pumpDescription.extendedBolusDurationStep = pumpType.getExtendedBolusSettings().getDurationStep(); + pumpDescription.extendedBolusMaxDuration = pumpType.getExtendedBolusSettings().getMaxDuration(); + + pumpDescription.isTempBasalCapable = true; + + if (pumpType.getPumpTempBasalType()==PumpTempBasalType.Percent) + { + pumpDescription.tempBasalStyle = PumpDescription.PERCENT; + pumpDescription.maxTempPercent = pumpType.getTbrSettings().getMaxDose().intValue(); + pumpDescription.tempPercentStep = (int)pumpType.getTbrSettings().getStep(); + } + else + { + pumpDescription.tempBasalStyle = PumpDescription.ABSOLUTE; + pumpDescription.maxTempAbsolute = pumpType.getTbrSettings().getMaxDose(); + pumpDescription.tempAbsoluteStep = pumpType.getTbrSettings().getStep(); + } + + pumpDescription.tempDurationStep = pumpType.getTbrSettings().getDurationStep(); + pumpDescription.tempMaxDuration = pumpType.getTbrSettings().getMaxDuration(); + + + pumpDescription.isSetBasalProfileCapable = true; + pumpDescription.basalStep = pumpType.getBaseBasalStep(); + pumpDescription.basalMinimumRate = pumpType.getBaseBasalMinValue(); + } + + +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java index ebaf2b19dd..a5c2b4dd93 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java @@ -19,6 +19,7 @@ import org.slf4j.LoggerFactory; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; +import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType; import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui; public class VirtualPumpFragment extends SubscriberFragment { @@ -29,6 +30,9 @@ public class VirtualPumpFragment extends SubscriberFragment { TextView extendedBolusView; TextView batteryView; TextView reservoirView; + TextView pumpTypeView; + TextView pumpSettingsView; + private static Handler sLoopHandler = new Handler(); private static Runnable sRefreshLoop = null; @@ -58,6 +62,8 @@ public class VirtualPumpFragment extends SubscriberFragment { extendedBolusView = (TextView) view.findViewById(R.id.virtualpump_extendedbolus); batteryView = (TextView) view.findViewById(R.id.virtualpump_battery); reservoirView = (TextView) view.findViewById(R.id.virtualpump_reservoir); + pumpTypeView = (TextView) view.findViewById(R.id.virtualpump_type); + pumpSettingsView = (TextView) view.findViewById(R.id.virtualpump_type_def); return view; } catch (Exception e) { @@ -93,6 +99,20 @@ public class VirtualPumpFragment extends SubscriberFragment { } batteryView.setText(virtualPump.batteryPercent + "%"); reservoirView.setText(virtualPump.reservoirInUnits + "U"); + + virtualPump.refreshConfiguration(); + + PumpType pumpType = virtualPump.getPumpType(); + + pumpTypeView.setText(pumpType.getDescription()); + + String template = MainApp.gs(R.string.virtualpump_pump_def); + + template = template.replace("EXTENDED_NOTE", pumpType.hasExtendedBasals() ? // + MainApp.gs(R.string.virtualpump_pump_def_extended_note) : ""); + + pumpSettingsView.setText(pumpType.getFullDescription(template)); + } }); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java index 1c9fdaaaf7..cf89e81093 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java @@ -26,6 +26,8 @@ import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; +import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType; +import info.nightscout.androidaps.plugins.PumpCommon.utils.PumpUtil; import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui; import info.nightscout.utils.DateUtil; import info.nightscout.utils.NSUpload; @@ -51,6 +53,9 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface { private PumpDescription pumpDescription = new PumpDescription(); + PumpType pumpType = null; + + private static void loadFakingStatus() { fromNSAreCommingFakedExtendedBoluses = SP.getBoolean("fromNSAreCommingFakedExtendedBoluses", false); } @@ -460,4 +465,31 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface { return "Virtual Pump"; } + public PumpType getPumpType() + { + return pumpType; + } + + + public void refreshConfiguration() + { + String pumptype = SP.getString("virtualpump_type", "Generic AAPS"); + + PumpType pumpTypeNew = PumpType.getByDescription(pumptype); + + if (pumpType == pumpTypeNew) + return; + + // reset + pumpDescription.resetSettings(); + + // virtual pump specific (not configurable) + pumpDescription.isRefillingCapable = false; + + PumpUtil.setPumpDescription(pumpDescription, pumpTypeNew); + + this.pumpType = pumpTypeNew; + + } + } diff --git a/app/src/main/res/layout/virtualpump_fragment.xml b/app/src/main/res/layout/virtualpump_fragment.xml index 3643c95bf5..0cc6e739ff 100644 --- a/app/src/main/res/layout/virtualpump_fragment.xml +++ b/app/src/main/res/layout/virtualpump_fragment.xml @@ -189,6 +189,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 660f6ee00e..aee358981e 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -100,4 +100,25 @@ @string/yes + + Generic AAPS + Cellnovo + Accu-Chek Spirit + Accu-Chek Combo + Animas Ping + Animas Vibe + Insulet Omnipod + Medtronic 512/712 + Medtronic 515/715 + Medtronic 522/722 + Medtronic 523/723 + Medtronic 553/753 (Revel) + Medtronic 554/754 (Veo) + Medtronic 640G + Tandem t:slim + Tandem t:flex + Tandem t:slim G4 + Tandem t:slim X2 + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 554b7f759f..27726bf7ab 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -861,5 +861,9 @@ Recovering from connection loss Not enough insulin for bolus left in reservoir Extended bolus delivery error + Virtual Pump Type + Pump Definition + Bolus: Step=%s\nExtended Bolus: [Step=%s, Duration=%smin-%sh]\nBasal: Step=%s\nTBR: %s (by %s), Duration=%smin-%sh\nEXTENDED_NOTE + * Ranged basal/bolus values are not supported by Virtual Pump. diff --git a/app/src/main/res/xml/pref_virtualpump.xml b/app/src/main/res/xml/pref_virtualpump.xml index 23d39114b4..ac65f5e228 100644 --- a/app/src/main/res/xml/pref_virtualpump.xml +++ b/app/src/main/res/xml/pref_virtualpump.xml @@ -8,6 +8,14 @@ android:defaultValue="false" android:key="virtualpump_uploadstatus" android:title="@string/virtualpump_uploadstatus_title" /> + + + \ No newline at end of file From 5b8779f8a7db88e3dd0a3dc6c0e179e683a8f763 Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Thu, 3 May 2018 15:10:34 +0100 Subject: [PATCH 2/7] Feature Request/Bug #863 - added PumpCapability (to set boolean values) - added Dana Pumps to PumpType and to VirtulaPumps array --- .../PumpCommon/defs/PumpCapability.java | 63 +++++++++++++ .../plugins/PumpCommon/defs/PumpType.java | 88 +++++++++++++------ .../plugins/PumpCommon/utils/PumpUtil.java | 20 +++-- .../PumpVirtual/VirtualPumpPlugin.java | 5 +- app/src/main/res/values/arrays.xml | 4 + 5 files changed, 143 insertions(+), 37 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpCapability.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpCapability.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpCapability.java new file mode 100644 index 0000000000..3ee41c67ec --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpCapability.java @@ -0,0 +1,63 @@ +package info.nightscout.androidaps.plugins.PumpCommon.defs; + +/** + * Created by andy on 03/05/2018. + */ + +public enum PumpCapability { + + Bolus, // + ExtendedBolus, // + TBR, // + BasalProfileSet, // + Refill, // + StoreCarbInfo, // + + // grouped + VirtualPump(Bolus, ExtendedBolus, TBR, BasalProfileSet, StoreCarbInfo), // + + Bolus_TBR_Basal_Refill_Carb(Bolus, TBR, BasalProfileSet, Refill, StoreCarbInfo), // + Bolus_Extended_TBR_Basal_Carb(Bolus, ExtendedBolus, TBR, BasalProfileSet, StoreCarbInfo), // + Bolus_Extended_TBR_Basal_Refill_Carb(Bolus, ExtendedBolus, TBR, BasalProfileSet, Refill, StoreCarbInfo), // + + ; + + PumpCapability[] children; + + + PumpCapability() + { + } + + + PumpCapability(PumpCapability...children) + { + this.children = children; + } + + + public boolean hasCapability(PumpCapability capability) + { + // we can only check presense of simple capabilities + if (capability.children != null) + return false; + + if (this == capability) + return true; + + if (this.children!=null) + { + for (PumpCapability child : children) { + if (child == capability) + return true; + } + + return false; + } + else + return false; + } + + + +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java index eac100cf0b..0c74ef38ab 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java @@ -4,8 +4,11 @@ package info.nightscout.androidaps.plugins.PumpCommon.defs; import java.util.HashMap; import java.util.Map; +import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.plugins.PumpCommon.data.DoseSettings; + + /** * Created by andy on 02/05/2018. * @@ -18,7 +21,7 @@ public enum PumpType { new DoseSettings(0.05f, 30, 8*60, 0.05f), // PumpTempBasalType.Percent, // new DoseSettings(10,30, 24*60, 0f, 500f), // - 0.01f, 0.01f, null), // + 0.01f, 0.01f, null, PumpCapability.VirtualPump), // // Cellnovo @@ -26,7 +29,7 @@ public enum PumpType { new DoseSettings(0.05f, 30, 24*60, 1f, null), PumpTempBasalType.Percent, new DoseSettings(5,30, 24*60, 0f, 200f), // - 0.05f, 0.05f, null), // + 0.05f, 0.05f, null, PumpCapability.VirtualPump), // // Accu-Chek @@ -34,9 +37,13 @@ public enum PumpType { new DoseSettings(0.1f, 15, 12*60, 0.1f), // PumpTempBasalType.Percent, new DoseSettings(10, 15, 12*60,0f, 500f), // - 0.01f, 0.1f, DoseStepSize.ComboBasal), // + 0.01f, 0.1f, DoseStepSize.ComboBasal, PumpCapability.Bolus_TBR_Basal_Refill_Carb), // - AccuChekSpirit("Accu-Chek Spirit", AccuChekCombo), // + AccuChekSpirit("Accu-Chek Spirit", 0.1f, null, // + new DoseSettings(0.1f, 15, 12*60, 0.1f), // + PumpTempBasalType.Percent, + new DoseSettings(10, 15, 12*60,0f, 500f), // + 0.01f, 0.1f, null, PumpCapability.VirtualPump), // // Animas @@ -44,33 +51,50 @@ public enum PumpType { new DoseSettings(0.05f, 30, 12*60, 0.05f), // PumpTempBasalType.Percent, // new DoseSettings(10, 30, 24*60, 0f, 200f), // - 0.025f, 5f, 0f, null), // + 0.025f, 5f, 0f, null, PumpCapability.VirtualPump), // AnimasPing("Animas Ping", AnimasVibe), + // Dana + DanaR("DanaR", 0.05f, null, // + new DoseSettings(0.05f, 30, 8*60, 0.05f), // + PumpTempBasalType.Percent, // + new DoseSettings(10f, 60, 24*60, 0f, 200f), // + 0.04f, 0.01f, null, PumpCapability.Bolus_Extended_TBR_Basal_Refill_Carb), + + DanaRKorean("DanaR Korean", 0.05f, null, // + new DoseSettings(0.05f, 30, 8*60, 0.05f), // + PumpTempBasalType.Percent, // + new DoseSettings(10f, 60, 24*60, 0f, 200f), // + 0.1f, 0.01f, null, PumpCapability.Bolus_Extended_TBR_Basal_Refill_Carb), + + DanaRS("DanaRS", DanaR), + DanaRv2("DanaRv2", DanaR), + + // Insulet Insulet_Omnipod("Insulet Omnipod", 0.05f, null, // new DoseSettings(0.05f, 30, 8*60, 0.05f), // PumpTempBasalType.Absolute, // new DoseSettings(0.05f, 30, 12*60, 0f, 5.0f), // cannot exceed max basal rate 30u/hr - 0.05f, 0.05f, null), + 0.05f, 0.05f, null, PumpCapability.VirtualPump), // Medtronic Minimed_512_712("Medtronic 512/712", 0.05f, null, // new DoseSettings(0.05f, 30, 8*60, 0.05f), // PumpTempBasalType.Absolute, // new DoseSettings(0.05f, 30, 24*60, 0f, 35f), // - 0.05f, 0.05f, null), // TODO + 0.05f, 0.05f, null, PumpCapability.VirtualPump), // TODO - Minimed_515_715("Medtronic 515/715", Minimed_512_712), // TODO - Minimed_522_722("Medtronic 522/722", Minimed_512_712), // TODO - Minimed_523_723("Medtronic 523/723", Minimed_512_712), // TODO + Minimed_515_715("Medtronic 515/715", Minimed_512_712), + Minimed_522_722("Medtronic 522/722", Minimed_512_712), + Minimed_523_723("Medtronic 523/723", Minimed_512_712), Minimed_553_753_Revel("Medtronic 553/753 (Revel)", 0.05f, null, // new DoseSettings(0.05f, 30, 8*60, 0.05f), // PumpTempBasalType.Absolute, // new DoseSettings(0.05f, 30, 24*60, 0f, 35f), // - 0.025f, 0.025f, DoseStepSize.MedtronicVeoBasal), // + 0.025f, 0.025f, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPump), // Minimed_554_754_Veo("Medtronic 554/754 (Veo)", Minimed_553_753_Revel), // TODO @@ -78,14 +102,14 @@ public enum PumpType { new DoseSettings(0.05f, 30, 8*60, 0.05f), // PumpTempBasalType.Absolute, // new DoseSettings(0.05f, 30, 24*60, 0f, 35f), // - 0.025f, 0.025f, DoseStepSize.MedtronicVeoBasal), // + 0.025f, 0.025f, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPump), // // Tandem TandemTSlim("Tandem t:slim", 0.01f, null, // new DoseSettings(0.01f,15, 8*60, 0.4f) , PumpTempBasalType.Percent, new DoseSettings(1,15, 8*60, 0f, 250f), // - 0.1f, 0.001f, null), + 0.1f, 0.001f, null, PumpCapability.VirtualPump), TandemTFlex("Tandem t:flex", TandemTSlim), // TandemTSlimG4("Tandem t:slim G4", TandemTSlim), // @@ -99,9 +123,10 @@ public enum PumpType { private PumpTempBasalType pumpTempBasalType; private DoseSettings tbrSettings; private float baseBasalMinValue; // - private float baseBasalMaxValue; + private Float baseBasalMaxValue; private float baseBasalStep; // private DoseStepSize baseBasalSpecialSteps; // + private PumpCapability pumpCapability; private PumpType parent; private static Map mapByDescription; @@ -122,27 +147,25 @@ public enum PumpType { this.parent = parent; } - - PumpType(String description, float bolusSize, DoseStepSize specialBolusSize, // - DoseSettings extendedBolusSettings, // - PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, // - float baseBasalMinValue, float baseBasalStep, DoseStepSize baseBasalSpecialSteps) + PumpType(String description, PumpType parent, PumpCapability pumpCapability) { this.description = description; - this.bolusSize = bolusSize; - this.specialBolusSize = specialBolusSize; - this.extendedBolusSettings = extendedBolusSettings; - this.pumpTempBasalType = pumpTempBasalType; - this.tbrSettings = tbrSettings; - this.baseBasalMinValue = baseBasalMinValue; - this.baseBasalStep = baseBasalStep; - this.baseBasalSpecialSteps = baseBasalSpecialSteps; + this.parent = parent; + this.pumpCapability = pumpCapability; } PumpType(String description, float bolusSize, DoseStepSize specialBolusSize, // DoseSettings extendedBolusSettings, // PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, // - float baseBasalMinValue, float baseBasalMaxValue, float baseBasalStep, DoseStepSize baseBasalSpecialSteps) + float baseBasalMinValue, float baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability) + { + this(description, bolusSize, specialBolusSize, extendedBolusSettings, pumpTempBasalType, tbrSettings, baseBasalMinValue, null, baseBasalStep, baseBasalSpecialSteps, pumpCapability); + } + + PumpType(String description, float bolusSize, DoseStepSize specialBolusSize, // + DoseSettings extendedBolusSettings, // + PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, // + float baseBasalMinValue, Float baseBasalMaxValue, float baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability) { this.description = description; this.bolusSize = bolusSize; @@ -154,6 +177,7 @@ public enum PumpType { this.baseBasalMaxValue = baseBasalMaxValue; this.baseBasalStep = baseBasalStep; this.baseBasalSpecialSteps = baseBasalSpecialSteps; + this.pumpCapability = pumpCapability; } @@ -161,6 +185,13 @@ public enum PumpType { return description; } + public PumpCapability getPumpCapability() { + + if (isParentSet()) + return this.pumpCapability == null ? parent.pumpCapability : pumpCapability; + else + return this.pumpCapability; + } public float getBolusSize() { return isParentSet() ? parent.bolusSize : bolusSize; @@ -268,4 +299,5 @@ public enum PumpType { } + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtil.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtil.java index 87c7f07ba4..a18ff6f7bf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtil.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtil.java @@ -1,6 +1,7 @@ package info.nightscout.androidaps.plugins.PumpCommon.utils; import info.nightscout.androidaps.interfaces.PumpDescription; +import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpCapability; import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpTempBasalType; import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType; @@ -10,18 +11,24 @@ import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType; public class PumpUtil { - // for now used only by VirtualPump, but with small changes could be used by any constructor public static void setPumpDescription(PumpDescription pumpDescription, PumpType pumpType) { - pumpDescription.isBolusCapable = true; + setPumpDescription(pumpDescription, pumpType, false); + } + + public static void setPumpDescription(PumpDescription pumpDescription, PumpType pumpType, boolean isVirtualPump) + { + PumpCapability pumpCapability = isVirtualPump ? PumpCapability.VirtualPump : pumpType.getPumpCapability(); + + pumpDescription.isBolusCapable = pumpCapability.hasCapability(PumpCapability.Bolus); pumpDescription.bolusStep = pumpType.getBolusSize(); - pumpDescription.isExtendedBolusCapable = true; + pumpDescription.isExtendedBolusCapable = pumpCapability.hasCapability(PumpCapability.ExtendedBolus); pumpDescription.extendedBolusStep = pumpType.getExtendedBolusSettings().getStep(); pumpDescription.extendedBolusDurationStep = pumpType.getExtendedBolusSettings().getDurationStep(); pumpDescription.extendedBolusMaxDuration = pumpType.getExtendedBolusSettings().getMaxDuration(); - pumpDescription.isTempBasalCapable = true; + pumpDescription.isTempBasalCapable = pumpCapability.hasCapability(PumpCapability.TBR); if (pumpType.getPumpTempBasalType()==PumpTempBasalType.Percent) { @@ -40,9 +47,12 @@ public class PumpUtil { pumpDescription.tempMaxDuration = pumpType.getTbrSettings().getMaxDuration(); - pumpDescription.isSetBasalProfileCapable = true; + pumpDescription.isSetBasalProfileCapable = pumpCapability.hasCapability(PumpCapability.BasalProfileSet); pumpDescription.basalStep = pumpType.getBaseBasalStep(); pumpDescription.basalMinimumRate = pumpType.getBaseBasalMinValue(); + + pumpDescription.isRefillingCapable = pumpCapability.hasCapability(PumpCapability.Refill); + pumpDescription.storesCarbInfo = pumpCapability.hasCapability(PumpCapability.StoreCarbInfo); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java index cf89e81093..57f4d5fe79 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java @@ -483,10 +483,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface { // reset pumpDescription.resetSettings(); - // virtual pump specific (not configurable) - pumpDescription.isRefillingCapable = false; - - PumpUtil.setPumpDescription(pumpDescription, pumpTypeNew); + PumpUtil.setPumpDescription(pumpDescription, pumpTypeNew, true); this.pumpType = pumpTypeNew; diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index aee358981e..208833ab01 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -107,6 +107,10 @@ Accu-Chek Combo Animas Ping Animas Vibe + DanaR + DanaR Korean + DanaRS + DanaRv2 Insulet Omnipod Medtronic 512/712 Medtronic 515/715 From 4fb8e899c213f744397761379a78dbf0b9967ebc Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Fri, 4 May 2018 15:48:46 +0100 Subject: [PATCH 3/7] Feature Request/Bug #863 - merged with dev - extended PumpType with new setting in PumpDescription - added Insight pump settings for VirtualPump --- .../interfaces/PumpDescription.java | 11 +-- .../plugins/PumpCommon/defs/DoseStepSize.java | 6 ++ .../PumpCommon/defs/PumpCapability.java | 33 +++++--- .../plugins/PumpCommon/defs/PumpType.java | 77 +++++++++++-------- .../plugins/PumpCommon/utils/PumpUtil.java | 18 +++-- .../PumpVirtual/VirtualPumpFragment.java | 1 + .../PumpVirtual/VirtualPumpPlugin.java | 2 +- app/src/main/res/values/arrays.xml | 3 +- 8 files changed, 94 insertions(+), 57 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java index f3d93b7c65..27fa818528 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpDescription.java @@ -58,24 +58,25 @@ public class PumpDescription { isTempBasalCapable = true; tempBasalStyle = PERCENT; - maxTempPercent = 200; tempPercentStep = 10; - maxTempAbsolute = 10; tempAbsoluteStep = 0.05d; - tempDurationStep = 60; tempMaxDuration = 12 * 60; - + tempDurationStep15mAllowed = false; + tempDurationStep30mAllowed = false; isSetBasalProfileCapable = true; basalStep = 0.01d; basalMinimumRate = 0.04d; + is30minBasalRatesCapable = false; isRefillingCapable = false; - storesCarbInfo = true; + supportsTDDs = false; + needsManualTDDLoad = true; + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/DoseStepSize.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/DoseStepSize.java index 84293a0192..69691886e2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/DoseStepSize.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/DoseStepSize.java @@ -12,6 +12,12 @@ public enum DoseStepSize new DoseStepSizeEntry(1f, 10f, 0.05f), // new DoseStepSizeEntry(10f, Float.MAX_VALUE, 0.1f)), // + InsightBolus( + new DoseStepSizeEntry(0f, 2f, 0.05f), // + new DoseStepSizeEntry(2f, 5f, 0.1f), // + new DoseStepSizeEntry(5f, 10f, 0.2f), // + new DoseStepSizeEntry(10f, Float.MAX_VALUE, 0.5f)), + MedtronicVeoBasal( // new DoseStepSizeEntry(0f, 1f, 0.025f), // new DoseStepSizeEntry(1f, 10f, 0.05f), // diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpCapability.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpCapability.java index 3ee41c67ec..e38df6f4e0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpCapability.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpCapability.java @@ -6,19 +6,30 @@ package info.nightscout.androidaps.plugins.PumpCommon.defs; public enum PumpCapability { - Bolus, // - ExtendedBolus, // - TBR, // - BasalProfileSet, // - Refill, // - StoreCarbInfo, // + Bolus, // isBolusCapable + ExtendedBolus, // isExtendedBolusCapable + TempBasal, // isTempBasalCapable + BasalProfileSet, // isSetBasalProfileCapable + Refill, // isRefillingCapable + StoreCarbInfo, // storesCarbInfo + TDD, // supportsTDDs + ManualTDDLoad, // needsManualTDDLoad + BasalRate30min, // is30minBasalRatesCapable + + // grouped by pump + VirtualPumpCapabilities(Bolus, ExtendedBolus, TempBasal, BasalProfileSet, Refill), // + ComboCapabilities(Bolus, TempBasal, BasalProfileSet, Refill, StoreCarbInfo, TDD, ManualTDDLoad), // + DanaCapabilities(Bolus, ExtendedBolus, TempBasal, BasalProfileSet, Refill, StoreCarbInfo, TDD, ManualTDDLoad), // + InsightCapabilities(Bolus, ExtendedBolus, TempBasal, BasalProfileSet, Refill,TDD,BasalRate30min), // + + + // BasalRates (separately grouped) + BasalRate_Duration15minAllowed, // + BasalRate_Duration30minAllowed, // + BasalRate_Duration15and30minAllowed(BasalRate_Duration15minAllowed, BasalRate_Duration30minAllowed), // + BasalRate_Duration15and30minNotAllowed, // - // grouped - VirtualPump(Bolus, ExtendedBolus, TBR, BasalProfileSet, StoreCarbInfo), // - Bolus_TBR_Basal_Refill_Carb(Bolus, TBR, BasalProfileSet, Refill, StoreCarbInfo), // - Bolus_Extended_TBR_Basal_Carb(Bolus, ExtendedBolus, TBR, BasalProfileSet, StoreCarbInfo), // - Bolus_Extended_TBR_Basal_Refill_Carb(Bolus, ExtendedBolus, TBR, BasalProfileSet, Refill, StoreCarbInfo), // ; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java index 0c74ef38ab..bc6d3f061e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java @@ -4,7 +4,6 @@ package info.nightscout.androidaps.plugins.PumpCommon.defs; import java.util.HashMap; import java.util.Map; -import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.plugins.PumpCommon.data.DoseSettings; @@ -20,38 +19,43 @@ public enum PumpType { GenericAAPS("Generic AAPS", 0.1f, null, // new DoseSettings(0.05f, 30, 8*60, 0.05f), // PumpTempBasalType.Percent, // - new DoseSettings(10,30, 24*60, 0f, 500f), // - 0.01f, 0.01f, null, PumpCapability.VirtualPump), // + new DoseSettings(10,30, 24*60, 0f, 500f), PumpCapability.BasalRate_Duration15and30minAllowed, // + 0.01f, 0.01f, null, PumpCapability.VirtualPumpCapabilities), // // Cellnovo Cellnovo1("Cellnovo", 0.05f, null, // new DoseSettings(0.05f, 30, 24*60, 1f, null), PumpTempBasalType.Percent, - new DoseSettings(5,30, 24*60, 0f, 200f), // - 0.05f, 0.05f, null, PumpCapability.VirtualPump), // + new DoseSettings(5,30, 24*60, 0f, 200f), PumpCapability.BasalRate_Duration30minAllowed, // + 0.05f, 0.05f, null, PumpCapability.VirtualPumpCapabilities), // // Accu-Chek AccuChekCombo("Accu-Chek Combo", 0.1f, null, // new DoseSettings(0.1f, 15, 12*60, 0.1f), // PumpTempBasalType.Percent, - new DoseSettings(10, 15, 12*60,0f, 500f), // - 0.01f, 0.1f, DoseStepSize.ComboBasal, PumpCapability.Bolus_TBR_Basal_Refill_Carb), // + new DoseSettings(10, 15, 12*60,0f, 500f), PumpCapability.BasalRate_Duration15and30minAllowed, // + 0.01f, 0.1f, DoseStepSize.ComboBasal, PumpCapability.ComboCapabilities), // AccuChekSpirit("Accu-Chek Spirit", 0.1f, null, // new DoseSettings(0.1f, 15, 12*60, 0.1f), // PumpTempBasalType.Percent, - new DoseSettings(10, 15, 12*60,0f, 500f), // - 0.01f, 0.1f, null, PumpCapability.VirtualPump), // + new DoseSettings(10, 15, 12*60,0f, 500f), PumpCapability.BasalRate_Duration15and30minAllowed, // + 0.01f, 0.1f, null, PumpCapability.VirtualPumpCapabilities), // + AccuChekInsight("Accu-Chek Insight", 0.05f, DoseStepSize.InsightBolus, // + new DoseSettings(0.05f, 15, 24*60, 0.05f), // + PumpTempBasalType.Percent, + new DoseSettings(10, 15, 12*60,0f, 250f), PumpCapability.BasalRate_Duration15and30minAllowed, // + 0.02f, 0.1f, null, PumpCapability.InsightCapabilities), // // Animas AnimasVibe("Animas Vibe", 0.05f, null, // AnimasBolus? new DoseSettings(0.05f, 30, 12*60, 0.05f), // PumpTempBasalType.Percent, // - new DoseSettings(10, 30, 24*60, 0f, 200f), // - 0.025f, 5f, 0f, null, PumpCapability.VirtualPump), // + new DoseSettings(10, 30, 24*60, 0f, 200f), PumpCapability.BasalRate_Duration30minAllowed, // + 0.025f, 5f, 0f, null, PumpCapability.VirtualPumpCapabilities), // AnimasPing("Animas Ping", AnimasVibe), @@ -59,32 +63,37 @@ public enum PumpType { DanaR("DanaR", 0.05f, null, // new DoseSettings(0.05f, 30, 8*60, 0.05f), // PumpTempBasalType.Percent, // - new DoseSettings(10f, 60, 24*60, 0f, 200f), // - 0.04f, 0.01f, null, PumpCapability.Bolus_Extended_TBR_Basal_Refill_Carb), + new DoseSettings(10f, 60, 24*60, 0f, 200f), PumpCapability.BasalRate_Duration15and30minNotAllowed, // + 0.04f, 0.01f, null, PumpCapability.DanaCapabilities), DanaRKorean("DanaR Korean", 0.05f, null, // new DoseSettings(0.05f, 30, 8*60, 0.05f), // PumpTempBasalType.Percent, // - new DoseSettings(10f, 60, 24*60, 0f, 200f), // - 0.1f, 0.01f, null, PumpCapability.Bolus_Extended_TBR_Basal_Refill_Carb), + new DoseSettings(10f, 60, 24*60, 0f, 200f), PumpCapability.BasalRate_Duration15and30minNotAllowed, // + 0.1f, 0.01f, null, PumpCapability.DanaCapabilities), - DanaRS("DanaRS", DanaR), - DanaRv2("DanaRv2", DanaR), + DanaRS("DanaRS", 0.05f, null, // + new DoseSettings(0.05f, 30, 8*60, 0.05f), // + PumpTempBasalType.Percent, // + new DoseSettings(10f, 60, 24*60, 0f, 200f), PumpCapability.BasalRate_Duration15and30minAllowed, // + 0.04f, 0.01f, null, PumpCapability.DanaCapabilities), + + DanaRv2("DanaRv2", DanaRS), // Insulet Insulet_Omnipod("Insulet Omnipod", 0.05f, null, // new DoseSettings(0.05f, 30, 8*60, 0.05f), // PumpTempBasalType.Absolute, // - new DoseSettings(0.05f, 30, 12*60, 0f, 5.0f), // cannot exceed max basal rate 30u/hr - 0.05f, 0.05f, null, PumpCapability.VirtualPump), + new DoseSettings(0.05f, 30, 12*60, 0f, 5.0f), PumpCapability.BasalRate_Duration30minAllowed, // cannot exceed max basal rate 30u/hr + 0.05f, 0.05f, null, PumpCapability.VirtualPumpCapabilities), // Medtronic Minimed_512_712("Medtronic 512/712", 0.05f, null, // new DoseSettings(0.05f, 30, 8*60, 0.05f), // PumpTempBasalType.Absolute, // - new DoseSettings(0.05f, 30, 24*60, 0f, 35f), // - 0.05f, 0.05f, null, PumpCapability.VirtualPump), // TODO + new DoseSettings(0.05f, 30, 24*60, 0f, 35f), PumpCapability.BasalRate_Duration30minAllowed, // + 0.05f, 0.05f, null, PumpCapability.VirtualPumpCapabilities), // TODO Minimed_515_715("Medtronic 515/715", Minimed_512_712), Minimed_522_722("Medtronic 522/722", Minimed_512_712), @@ -93,23 +102,23 @@ public enum PumpType { Minimed_553_753_Revel("Medtronic 553/753 (Revel)", 0.05f, null, // new DoseSettings(0.05f, 30, 8*60, 0.05f), // PumpTempBasalType.Absolute, // - new DoseSettings(0.05f, 30, 24*60, 0f, 35f), // - 0.025f, 0.025f, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPump), // + new DoseSettings(0.05f, 30, 24*60, 0f, 35f), PumpCapability.BasalRate_Duration30minAllowed, // + 0.025f, 0.025f, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPumpCapabilities), // Minimed_554_754_Veo("Medtronic 554/754 (Veo)", Minimed_553_753_Revel), // TODO Minimed_640G("Medtronic 640G", 0.025f, null, // new DoseSettings(0.05f, 30, 8*60, 0.05f), // PumpTempBasalType.Absolute, // - new DoseSettings(0.05f, 30, 24*60, 0f, 35f), // - 0.025f, 0.025f, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPump), // + new DoseSettings(0.05f, 30, 24*60, 0f, 35f), PumpCapability.BasalRate_Duration30minAllowed, // + 0.025f, 0.025f, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPumpCapabilities), // // Tandem TandemTSlim("Tandem t:slim", 0.01f, null, // - new DoseSettings(0.01f,15, 8*60, 0.4f) , + new DoseSettings(0.01f,15, 8*60, 0.4f), PumpTempBasalType.Percent, - new DoseSettings(1,15, 8*60, 0f, 250f), // - 0.1f, 0.001f, null, PumpCapability.VirtualPump), + new DoseSettings(1,15, 8*60, 0f, 250f), PumpCapability.BasalRate_Duration15and30minAllowed, // + 0.1f, 0.001f, null, PumpCapability.VirtualPumpCapabilities), TandemTFlex("Tandem t:flex", TandemTSlim), // TandemTSlimG4("Tandem t:slim G4", TandemTSlim), // @@ -122,6 +131,7 @@ public enum PumpType { private DoseSettings extendedBolusSettings; private PumpTempBasalType pumpTempBasalType; private DoseSettings tbrSettings; + private PumpCapability specialBasalDurations; private float baseBasalMinValue; // private Float baseBasalMaxValue; private float baseBasalStep; // @@ -156,15 +166,15 @@ public enum PumpType { PumpType(String description, float bolusSize, DoseStepSize specialBolusSize, // DoseSettings extendedBolusSettings, // - PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, // + PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, PumpCapability specialBasalDurations, // float baseBasalMinValue, float baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability) { - this(description, bolusSize, specialBolusSize, extendedBolusSettings, pumpTempBasalType, tbrSettings, baseBasalMinValue, null, baseBasalStep, baseBasalSpecialSteps, pumpCapability); + this(description, bolusSize, specialBolusSize, extendedBolusSettings, pumpTempBasalType, tbrSettings, specialBasalDurations, baseBasalMinValue, null, baseBasalStep, baseBasalSpecialSteps, pumpCapability); } PumpType(String description, float bolusSize, DoseStepSize specialBolusSize, // DoseSettings extendedBolusSettings, // - PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, // + PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, PumpCapability specialBasalDurations, // float baseBasalMinValue, Float baseBasalMaxValue, float baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability) { this.description = description; @@ -173,6 +183,7 @@ public enum PumpType { this.extendedBolusSettings = extendedBolusSettings; this.pumpTempBasalType = pumpTempBasalType; this.tbrSettings = tbrSettings; + this.specialBasalDurations = specialBasalDurations; this.baseBasalMinValue = baseBasalMinValue; this.baseBasalMaxValue = baseBasalMaxValue; this.baseBasalStep = baseBasalStep; @@ -299,5 +310,7 @@ public enum PumpType { } - + public PumpCapability getSpecialBasalDurations() { + return specialBasalDurations; + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtil.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtil.java index a18ff6f7bf..afecccc5e5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtil.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtil.java @@ -11,14 +11,10 @@ import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType; public class PumpUtil { + public static void setPumpDescription(PumpDescription pumpDescription, PumpType pumpType) { - setPumpDescription(pumpDescription, pumpType, false); - } - - public static void setPumpDescription(PumpDescription pumpDescription, PumpType pumpType, boolean isVirtualPump) - { - PumpCapability pumpCapability = isVirtualPump ? PumpCapability.VirtualPump : pumpType.getPumpCapability(); + PumpCapability pumpCapability = pumpType.getPumpCapability(); pumpDescription.isBolusCapable = pumpCapability.hasCapability(PumpCapability.Bolus); pumpDescription.bolusStep = pumpType.getBolusSize(); @@ -28,7 +24,7 @@ public class PumpUtil { pumpDescription.extendedBolusDurationStep = pumpType.getExtendedBolusSettings().getDurationStep(); pumpDescription.extendedBolusMaxDuration = pumpType.getExtendedBolusSettings().getMaxDuration(); - pumpDescription.isTempBasalCapable = pumpCapability.hasCapability(PumpCapability.TBR); + pumpDescription.isTempBasalCapable = pumpCapability.hasCapability(PumpCapability.TempBasal); if (pumpType.getPumpTempBasalType()==PumpTempBasalType.Percent) { @@ -46,6 +42,8 @@ public class PumpUtil { pumpDescription.tempDurationStep = pumpType.getTbrSettings().getDurationStep(); pumpDescription.tempMaxDuration = pumpType.getTbrSettings().getMaxDuration(); + pumpDescription.tempDurationStep15mAllowed = pumpType.getSpecialBasalDurations().hasCapability(PumpCapability.BasalRate_Duration15minAllowed); + pumpDescription.tempDurationStep30mAllowed = pumpType.getSpecialBasalDurations().hasCapability(PumpCapability.BasalRate_Duration30minAllowed); pumpDescription.isSetBasalProfileCapable = pumpCapability.hasCapability(PumpCapability.BasalProfileSet); pumpDescription.basalStep = pumpType.getBaseBasalStep(); @@ -53,6 +51,12 @@ public class PumpUtil { pumpDescription.isRefillingCapable = pumpCapability.hasCapability(PumpCapability.Refill); pumpDescription.storesCarbInfo = pumpCapability.hasCapability(PumpCapability.StoreCarbInfo); + + pumpDescription.supportsTDDs = pumpCapability.hasCapability(PumpCapability.TDD); + pumpDescription.needsManualTDDLoad = pumpCapability.hasCapability(PumpCapability.ManualTDDLoad); + + pumpDescription.is30minBasalRatesCapable = pumpCapability.hasCapability(PumpCapability.BasalRate30min); + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java index 5a42af3811..f01fb0f379 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java @@ -15,6 +15,7 @@ import com.squareup.otto.Subscribe; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.TemporaryBasal; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java index e129786a58..95f27d1707 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java @@ -426,7 +426,7 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface { // reset pumpDescription.resetSettings(); - PumpUtil.setPumpDescription(pumpDescription, pumpTypeNew, true); + PumpUtil.setPumpDescription(pumpDescription, pumpTypeNew); this.pumpType = pumpTypeNew; diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 30fd658c79..9aea30d324 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -108,11 +108,12 @@ Generic AAPS - Cellnovo Accu-Chek Spirit Accu-Chek Combo + Accu-Chek Insight Animas Ping Animas Vibe + Cellnovo DanaR DanaR Korean DanaRS From 6f19ad1407ff78b30b708dccbdfa30cdcefc5c6c Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Thu, 10 May 2018 12:40:31 +0100 Subject: [PATCH 4/7] Wrong handling of specialBasalDurations (Duration15 and Duartion30 flags), and added some logging. --- .../androidaps/plugins/PumpCommon/defs/PumpType.java | 11 ++++++++++- .../plugins/PumpVirtual/VirtualPumpPlugin.java | 4 ++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java index bc6d3f061e..f22c07fa8a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java @@ -311,6 +311,15 @@ public enum PumpType { public PumpCapability getSpecialBasalDurations() { - return specialBasalDurations; + + if (isParentSet()) + { + return parent.getSpecialBasalDurations(); + } + else + { + return specialBasalDurations == null ? // + PumpCapability.BasalRate_Duration15and30minNotAllowed : specialBasalDurations; + } } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java index 4a85b5d462..361f52dd87 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java @@ -420,9 +420,13 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface { PumpType pumpTypeNew = PumpType.getByDescription(pumptype); + log.debug("Pump in configuration: {}, PumpType object: {}", pumptype, pumpTypeNew); + if (pumpType == pumpTypeNew) return; + log.debug("New pump configuration found ({}), changing from previous ({})", pumpTypeNew, pumpType); + // reset pumpDescription.resetSettings(); From 2600a7009b363ae4f85f72434bb4a4bb19c5ef2b Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Sun, 13 May 2018 18:40:53 +0100 Subject: [PATCH 5/7] Added UTests for PumpUtil and VirualPlugin (new methods) --- .../PumpCommon/utils/PumpUtilUTest.java | 45 +++++++++++ .../PumpVirtual/VirtualPumpPluginUTest.java | 78 +++++++++++++++++++ 2 files changed, 123 insertions(+) create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtilUTest.java create mode 100644 app/src/test/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPluginUTest.java diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtilUTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtilUTest.java new file mode 100644 index 0000000000..86b030b801 --- /dev/null +++ b/app/src/test/java/info/nightscout/androidaps/plugins/PumpCommon/utils/PumpUtilUTest.java @@ -0,0 +1,45 @@ +package info.nightscout.androidaps.plugins.PumpCommon.utils; + +import org.junit.Assert; +import org.junit.Test; + +import info.nightscout.androidaps.interfaces.PumpDescription; +import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpCapability; +import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpTempBasalType; +import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType; + +import static org.junit.Assert.*; + +/** + * Created by andy on 5/13/18. + */ +public class PumpUtilUTest { + + @Test + public void setPumpDescription() throws Exception { + + PumpDescription pumpDescription = new PumpDescription(); + + PumpUtil.setPumpDescription(pumpDescription, PumpType.AccuChekCombo); + + Assert.assertEquals(pumpDescription.bolusStep, PumpType.AccuChekCombo.getBolusSize(), 0.1d); + Assert.assertEquals(pumpDescription.basalMinimumRate, PumpType.AccuChekCombo.getBaseBasalStep(), 0.1d); + Assert.assertEquals(pumpDescription.basalStep, PumpType.AccuChekCombo.getBaseBasalStep(), 0.1d); + Assert.assertEquals(pumpDescription.extendedBolusDurationStep, PumpType.AccuChekCombo.getExtendedBolusSettings().getDurationStep(), 0.1d); + Assert.assertEquals(pumpDescription.extendedBolusMaxDuration, PumpType.AccuChekCombo.getExtendedBolusSettings().getMaxDuration(), 0.1d); + Assert.assertEquals(pumpDescription.extendedBolusStep, PumpType.AccuChekCombo.getExtendedBolusSettings().getStep(), 0.1d); + Assert.assertEquals(pumpDescription.isExtendedBolusCapable, PumpType.AccuChekCombo.getPumpCapability().hasCapability(PumpCapability.ExtendedBolus)); + Assert.assertEquals(pumpDescription.isBolusCapable, PumpType.AccuChekCombo.getPumpCapability().hasCapability(PumpCapability.Bolus)); + Assert.assertEquals(pumpDescription.isRefillingCapable, PumpType.AccuChekCombo.getPumpCapability().hasCapability(PumpCapability.Refill)); + Assert.assertEquals(pumpDescription.isSetBasalProfileCapable, PumpType.AccuChekCombo.getPumpCapability().hasCapability(PumpCapability.BasalProfileSet)); + Assert.assertEquals(pumpDescription.isTempBasalCapable, PumpType.AccuChekCombo.getPumpCapability().hasCapability(PumpCapability.TempBasal)); + Assert.assertEquals(pumpDescription.maxTempPercent, PumpType.AccuChekCombo.getTbrSettings().getMaxDose(), 0.1d); + Assert.assertEquals(pumpDescription.tempPercentStep, PumpType.AccuChekCombo.getTbrSettings().getStep(), 0.1d); + Assert.assertEquals(pumpDescription.tempBasalStyle, PumpType.AccuChekCombo.getPumpTempBasalType()== PumpTempBasalType.Percent ? PumpDescription.PERCENT : PumpDescription.ABSOLUTE); + Assert.assertEquals(pumpDescription.tempDurationStep, PumpType.AccuChekCombo.getTbrSettings().getDurationStep()); + Assert.assertEquals(pumpDescription.tempDurationStep15mAllowed, PumpType.AccuChekCombo.getSpecialBasalDurations().hasCapability(PumpCapability.BasalRate_Duration15minAllowed)); + Assert.assertEquals(pumpDescription.tempDurationStep30mAllowed, PumpType.AccuChekCombo.getSpecialBasalDurations().hasCapability(PumpCapability.BasalRate_Duration30minAllowed)); + + } + +} \ No newline at end of file diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPluginUTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPluginUTest.java new file mode 100644 index 0000000000..4e2da58e06 --- /dev/null +++ b/app/src/test/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPluginUTest.java @@ -0,0 +1,78 @@ +package info.nightscout.androidaps.plugins.PumpVirtual; + +import android.content.Context; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mock; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +import info.AAPSMocker; +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; +import info.nightscout.androidaps.plugins.PumpCommon.defs.PumpType; +import info.nightscout.androidaps.plugins.PumpInsight.InsightPlugin; +import info.nightscout.utils.SP; +import info.nightscout.utils.ToastUtils; + +import static org.junit.Assert.*; +import static org.powermock.api.mockito.PowerMockito.when; + +/** + * Created by andy on 5/13/18. + */ +@RunWith(PowerMockRunner.class) +@PrepareForTest({MainApp.class, ConfigBuilderPlugin.class, ToastUtils.class, Context.class, SP.class}) +public class VirtualPumpPluginUTest { + + + VirtualPumpPlugin virtualPumpPlugin; + + + + @Before + public void prepareMocks() throws Exception { + AAPSMocker.mockMainApp(); + AAPSMocker.mockConfigBuilder(); + AAPSMocker.mockBus(); + AAPSMocker.mockStrings(); + AAPSMocker.mockCommandQueue(); + AAPSMocker.mockSP(); + + virtualPumpPlugin = VirtualPumpPlugin.getPlugin(); + } + + + @Test + public void getPumpType() throws Exception { + } + + @Test + public void refreshConfiguration() throws Exception { + + when(SP.getString("virtualpump_type", "Generic AAPS")).thenReturn("Accu-Chek Combo"); + + virtualPumpPlugin.refreshConfiguration(); + + Assert.assertEquals(PumpType.AccuChekCombo, virtualPumpPlugin.getPumpType()); + } + + + @Test + public void refreshConfigurationTwice() throws Exception { + + when(SP.getString("virtualpump_type", "Generic AAPS")).thenReturn("Accu-Chek Combo"); + + virtualPumpPlugin.refreshConfiguration(); + + when(SP.getString("virtualpump_type", "Generic AAPS")).thenReturn("Accu-Chek Combo"); + + virtualPumpPlugin.refreshConfiguration(); + + Assert.assertEquals(PumpType.AccuChekCombo, virtualPumpPlugin.getPumpType()); + } + +} \ No newline at end of file From 5d4dc7ea6107dbe9ad7d63e70a957973710b5b01 Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Wed, 1 Aug 2018 16:19:57 +0100 Subject: [PATCH 6/7] Changes requested after review. - added additional parameter for extended_note - changed how extended_note is set - created positional formatting --- .../androidaps/plugins/PumpCommon/defs/PumpType.java | 9 +++++++-- .../plugins/PumpVirtual/VirtualPumpFragment.java | 4 +--- app/src/main/res/values/strings.xml | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java index f22c07fa8a..55a7ee98f4 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java @@ -4,6 +4,8 @@ package info.nightscout.androidaps.plugins.PumpCommon.defs; import java.util.HashMap; import java.util.Map; +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.PumpCommon.data.DoseSettings; @@ -273,18 +275,21 @@ public enum PumpType { } - public String getFullDescription(String i18nTemplate) { + public String getFullDescription(String i18nTemplate, boolean hasExtendedBasals) { String unit = getPumpTempBasalType()==PumpTempBasalType.Percent ? "%" : ""; DoseSettings eb = getExtendedBolusSettings(); DoseSettings tbr = getTbrSettings(); + String extendedNote = hasExtendedBasals ? MainApp.gs(R.string.virtualpump_pump_def_extended_note) : ""; + return String.format(i18nTemplate, // getStep("" + getBolusSize(), getSpecialBolusSize()), // eb.getStep(), eb.getDurationStep(), eb.getMaxDuration()/60, // getStep(getBaseBasalRange(), getBaseBasalSpecialSteps()), // - tbr.getMinDose() + unit + "-" + tbr.getMaxDose() + unit, tbr.getStep() + unit, tbr.getDurationStep(), tbr.getMaxDuration()/60); + tbr.getMinDose() + unit + "-" + tbr.getMaxDose() + unit, tbr.getStep() + unit, + tbr.getDurationStep(), tbr.getMaxDuration()/60, extendedNote); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java index f01fb0f379..ef4c85e0a7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpFragment.java @@ -113,10 +113,8 @@ public class VirtualPumpFragment extends SubscriberFragment { String template = MainApp.gs(R.string.virtualpump_pump_def); - template = template.replace("EXTENDED_NOTE", pumpType.hasExtendedBasals() ? // - MainApp.gs(R.string.virtualpump_pump_def_extended_note) : ""); - pumpSettingsView.setText(pumpType.getFullDescription(template)); + pumpSettingsView.setText(pumpType.getFullDescription(template, pumpType.hasExtendedBasals())); } }); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b26344179f..93ef50cd36 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1087,7 +1087,7 @@ n/a Virtual Pump Type Pump Definition - Bolus: Step=%s\nExtended Bolus: [Step=%s, Duration=%smin-%sh]\nBasal: Step=%s\nTBR: %s (by %s), Duration=%smin-%sh\nEXTENDED_NOTE + Bolus: Step=%1$s\nExtended Bolus: [Step=%2$s, Duration=%3$smin-%4$sh]\nBasal: Step=%5$s\nTBR: %6$s (by %7$s), Duration=%8$smin-%9$sh\n%10$s * Ranged basal/bolus values are not supported by Virtual Pump. Autobackfill BG Irish From fa1a08367f9bdaac215f7208b51ef44e1ccd6471 Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Thu, 9 Aug 2018 15:11:34 +0100 Subject: [PATCH 7/7] - Changed one string - Removed one pump that was just wrongly named (553 doesn't exists, 523 is actually Revel one) --- .../plugins/PumpCommon/defs/PumpType.java | 13 ++++++------- app/src/main/res/values/arrays.xml | 3 +-- app/src/main/res/values/strings.xml | 2 +- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java index f22c07fa8a..ace874485c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCommon/defs/PumpType.java @@ -89,25 +89,24 @@ public enum PumpType { 0.05f, 0.05f, null, PumpCapability.VirtualPumpCapabilities), // Medtronic - Minimed_512_712("Medtronic 512/712", 0.05f, null, // + Medtronic_512_712("Medtronic 512/712", 0.05f, null, // new DoseSettings(0.05f, 30, 8*60, 0.05f), // PumpTempBasalType.Absolute, // new DoseSettings(0.05f, 30, 24*60, 0f, 35f), PumpCapability.BasalRate_Duration30minAllowed, // 0.05f, 0.05f, null, PumpCapability.VirtualPumpCapabilities), // TODO - Minimed_515_715("Medtronic 515/715", Minimed_512_712), - Minimed_522_722("Medtronic 522/722", Minimed_512_712), - Minimed_523_723("Medtronic 523/723", Minimed_512_712), + Medtronic_515_715("Medtronic 515/715", Medtronic_512_712), + Medtronic_522_722("Medtronic 522/722", Medtronic_512_712), - Minimed_553_753_Revel("Medtronic 553/753 (Revel)", 0.05f, null, // + Medtronic_523_723_Revel("Medtronic 523/723 (Revel)", 0.05f, null, // new DoseSettings(0.05f, 30, 8*60, 0.05f), // PumpTempBasalType.Absolute, // new DoseSettings(0.05f, 30, 24*60, 0f, 35f), PumpCapability.BasalRate_Duration30minAllowed, // 0.025f, 0.025f, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPumpCapabilities), // - Minimed_554_754_Veo("Medtronic 554/754 (Veo)", Minimed_553_753_Revel), // TODO + Medtronic_554_754_Veo("Medtronic 554/754 (Veo)", Medtronic_523_723_Revel), // TODO - Minimed_640G("Medtronic 640G", 0.025f, null, // + Medtronic_640G("Medtronic 640G", 0.025f, null, // new DoseSettings(0.05f, 30, 8*60, 0.05f), // PumpTempBasalType.Absolute, // new DoseSettings(0.05f, 30, 24*60, 0f, 35f), PumpCapability.BasalRate_Duration30minAllowed, // diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 571f5f04a2..03cf25236e 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -126,8 +126,7 @@ Medtronic 512/712 Medtronic 515/715 Medtronic 522/722 - Medtronic 523/723 - Medtronic 553/753 (Revel) + Medtronic 523/723 (Revel) Medtronic 554/754 (Veo) Medtronic 640G Tandem t:slim diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b26344179f..959a0a2974 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1087,7 +1087,7 @@ n/a Virtual Pump Type Pump Definition - Bolus: Step=%s\nExtended Bolus: [Step=%s, Duration=%smin-%sh]\nBasal: Step=%s\nTBR: %s (by %s), Duration=%smin-%sh\nEXTENDED_NOTE + Bolus: Step=%s\nExtended Bolus: [Step=%s, Duration=%smin-%sh]\nBasal: Step=%s\nTBR: %s (by %s), Duration=%smin-%sh\nEXTENDED_NOTE * Ranged basal/bolus values are not supported by Virtual Pump. Autobackfill BG Irish