diff --git a/app/src/main/java/info/nightscout/androidaps/MainApp.java b/app/src/main/java/info/nightscout/androidaps/MainApp.java index 91e516f87b..ffe20ca746 100644 --- a/app/src/main/java/info/nightscout/androidaps/MainApp.java +++ b/app/src/main/java/info/nightscout/androidaps/MainApp.java @@ -196,7 +196,7 @@ public class MainApp extends Application { NSUpload.uploadAppStart(); - final PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (pump != null) { new Thread(() -> { SystemClock.sleep(5000); diff --git a/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.java b/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.java index 0e4535a778..7303eb9d97 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/activities/HistoryBrowseActivity.java @@ -229,7 +229,7 @@ public class HistoryBrowseActivity extends AppCompatActivity { if (noProfile == null || buttonDate == null || buttonZoom == null || bgGraph == null || iobGraph == null || seekBar == null) return; - final PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); final Profile profile = ProfileFunctions.getInstance().getProfile(); if (profile == null) { diff --git a/app/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java b/app/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java index e18e2552eb..f608ab675f 100644 --- a/app/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java +++ b/app/src/main/java/info/nightscout/androidaps/activities/TDDStatsActivity.java @@ -130,7 +130,7 @@ public class TDDStatsActivity extends Activity { } totalBaseBasal.setText(TBB); - if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().needsManualTDDLoad) + if (!ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().needsManualTDDLoad) reloadButton.setVisibility(View.GONE); // stats table @@ -440,7 +440,7 @@ public class TDDStatsActivity extends Activity { TableLayout.LayoutParams.WRAP_CONTENT)); } - if (isOldData(historyList) && ConfigBuilderPlugin.getActivePump().getPumpDescription().needsManualTDDLoad) { + if (isOldData(historyList) && ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().needsManualTDDLoad) { statsMessage.setVisibility(View.VISIBLE); statsMessage.setText(MainApp.gs(R.string.danar_stats_olddata_Message)); @@ -545,7 +545,7 @@ public class TDDStatsActivity extends Activity { public static boolean isOldData(List historyList) { - Object activePump = MainApp.getConfigBuilder().getActivePump(); + Object activePump = ConfigBuilderPlugin.getPlugin().getActivePump(); PumpInterface dana = MainApp.getSpecificPlugin(DanaRPlugin.class); PumpInterface danaRS = MainApp.getSpecificPlugin(DanaRSPlugin.class); PumpInterface danaV2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class); diff --git a/app/src/main/java/info/nightscout/androidaps/data/Profile.java b/app/src/main/java/info/nightscout/androidaps/data/Profile.java index 748710f17a..8d78ca19b6 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/Profile.java +++ b/app/src/main/java/info/nightscout/androidaps/data/Profile.java @@ -12,12 +12,12 @@ import java.text.DecimalFormat; import java.util.Calendar; import java.util.TimeZone; -import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; +import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.utils.DateUtil; @@ -221,7 +221,7 @@ public class Profile { if (isValid) { // Check for hours alignment - PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (pump != null && !pump.getPumpDescription().is30minBasalRatesCapable) { for (int index = 0; index < basal_v.size(); index++) { long secondsFromMidnight = basal_v.keyAt(index); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java index ea17a30218..1075a9459f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/ActionsFragment.java @@ -142,7 +142,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL return; } - final PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); final boolean basalprofileEnabled = MainApp.isEngineeringModeOrRelease() && pump.getPumpDescription().isSetBasalProfileCapable; @@ -192,7 +192,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL else tempTarget.setVisibility(View.VISIBLE); - if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().supportsTDDs) tddStats.setVisibility(View.GONE); + if (!ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().supportsTDDs) tddStats.setVisibility(View.GONE); else tddStats.setVisibility(View.VISIBLE); } }); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java index 4f83465e7d..283a069199 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java @@ -103,7 +103,7 @@ public class FillDialog extends DialogFragment implements OnClickListener { insulinCartridgeChangeCheckbox = view.findViewById(R.id.fill_cartridge_change); Double maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value(); - double bolusstep = ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep; + double bolusstep = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep; editInsulin = view.findViewById(R.id.fill_insulinamount); editInsulin.setParams(0d, 0d, maxInsulin, bolusstep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java index 80939e639c..06ab8d2982 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java @@ -48,8 +48,8 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli editInsulin = (NumberPicker) view.findViewById(R.id.overview_newextendedbolus_insulin); editInsulin.setParams(0d, 0d, maxInsulin, 0.1d, new DecimalFormat("0.00"), false); - double extendedDurationStep = ConfigBuilderPlugin.getActivePump().getPumpDescription().extendedBolusDurationStep; - double extendedMaxDuration = ConfigBuilderPlugin.getActivePump().getPumpDescription().extendedBolusMaxDuration; + double extendedDurationStep = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().extendedBolusDurationStep; + double extendedMaxDuration = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().extendedBolusMaxDuration; editDuration = (NumberPicker) view.findViewById(R.id.overview_newextendedbolus_duration); editDuration.setParams(extendedDurationStep, extendedDurationStep, extendedMaxDuration, extendedDurationStep, new DecimalFormat("0"), false); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java index 359e0e4877..3f14170fc3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java @@ -64,7 +64,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi absoluteRadio = (RadioButton) view.findViewById(R.id.overview_newtempbasal_absolute_radio); typeSelectorLayout = (LinearLayout) view.findViewById(R.id.overview_newtempbasal_typeselector_layout); - PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription(); + PumpDescription pumpDescription = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription(); basalPercent = (NumberPicker) view.findViewById(R.id.overview_newtempbasal_basalpercentinput); double maxTempPercent = pumpDescription.maxTempPercent; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index b4c2abf3da..86ccb02a6f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -19,7 +19,6 @@ import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.ProfileInterface; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.SensitivityInterface; -import info.nightscout.androidaps.interfaces.TreatmentsInterface; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.Insulin.InsulinOrefRapidActingPlugin; import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin; @@ -42,9 +41,8 @@ public class ConfigBuilderPlugin extends PluginBase { } private BgSourceInterface activeBgSource; - private static PumpInterface activePump; + private PumpInterface activePump; private static ProfileInterface activeProfile; - private static TreatmentsInterface activeTreatments; private static APSInterface activeAPS; private static InsulinInterface activeInsulin; private static SensitivityInterface activeSensitivity; @@ -250,7 +248,7 @@ public class ConfigBuilderPlugin extends PluginBase { return activeAPS; } - public static PumpInterface getActivePump() { + public PumpInterface getActivePump() { return activePump; } @@ -322,7 +320,6 @@ public class ConfigBuilderPlugin extends PluginBase { this.setFragmentVisiblities(((PluginBase) activePump).getName(), pluginsInCategory, PluginType.PUMP); // PluginType.TREATMENT - activeTreatments = this.determineActivePlugin(PluginType.TREATMENT); } /** diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java index aae2d1f029..cc50189346 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java @@ -65,7 +65,7 @@ public class ObjectivesPlugin extends PluginBase implements ConstraintsInterface @Override public boolean specialEnableCondition() { - PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); return pump == null || pump.getPumpDescription().isTempBasalCapable; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPlugin.java index 59f44c77c7..e1c7f6317e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPlugin.java @@ -52,7 +52,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface { **/ @Override public Constraint isLoopInvocationAllowed(Constraint value) { - if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) + if (!ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().isTempBasalCapable) value.set(false, MainApp.gs(R.string.pumpisnottempbasalcapable), this); return value; } @@ -124,7 +124,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface { absoluteRate.setIfSmaller(HardLimits.maxBasal(), String.format(MainApp.gs(R.string.limitingbasalratio), HardLimits.maxBasal(), MainApp.gs(R.string.hardlimit)), this); - PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); // check for pump max if (pump != null && pump.getPumpDescription().tempBasalStyle == PumpDescription.ABSOLUTE) { double pumpLimit = pump.getPumpDescription().pumpType.getTbrSettings().getMaxDose(); @@ -150,7 +150,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface { applyBasalConstraints(absoluteConstraint, profile); percentRate.copyReasons(absoluteConstraint); - PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); Integer percentRateAfterConst = Double.valueOf(absoluteConstraint.value() / currentBasal * 100).intValue(); if (pump != null) { @@ -179,7 +179,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface { insulin.setIfSmaller(HardLimits.maxBolus(), String.format(MainApp.gs(R.string.limitingbolus), HardLimits.maxBolus(), MainApp.gs(R.string.hardlimit)), this); - PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (pump != null) { double rounded = Round.roundTo(insulin.value(), pump.getPumpDescription().pumpType.determineCorrectBolusSize(insulin.value())); insulin.setIfDifferent(rounded, MainApp.gs(R.string.pumplimit), this); @@ -196,7 +196,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface { insulin.setIfSmaller(HardLimits.maxBolus(), String.format(MainApp.gs(R.string.limitingextendedbolus), HardLimits.maxBolus(), MainApp.gs(R.string.hardlimit)), this); - PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (pump != null) { double rounded = Round.roundTo(insulin.value(), pump.getPumpDescription().pumpType.determineCorrectExtendedBolusSize(insulin.value())); insulin.setIfDifferent(rounded, MainApp.gs(R.string.pumplimit), this); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java index 62d2bc3a7d..5135c6b87b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/APSResult.java @@ -86,7 +86,7 @@ public class APSResult { @Override public String toString() { - final PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (isChangeRequested()) { String ret; // rate @@ -115,7 +115,7 @@ public class APSResult { } public Spanned toSpanned() { - final PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (isChangeRequested()) { String ret; // rate @@ -304,7 +304,7 @@ public class APSResult { long now = System.currentTimeMillis(); TemporaryBasal activeTemp = TreatmentsPlugin.getPlugin().getTempBasalFromHistory(now); - PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); Profile profile = ProfileFunctions.getInstance().getProfile(); if (usePercent) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java index 9a2a72746e..a57547bd4a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java @@ -140,7 +140,7 @@ public class LoopPlugin extends PluginBase { @Override public boolean specialEnableCondition() { - PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); return pump == null || pump.getPumpDescription().isTempBasalCapable; } @@ -275,7 +275,7 @@ public class LoopPlugin extends PluginBase { MainApp.bus().post(new EventLoopSetLastRunGui(message)); return; } - final PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); APSResult result = null; if (!isEnabled(PluginType.LOOP)) @@ -489,7 +489,7 @@ public class LoopPlugin extends PluginBase { return; } - PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin(); if (!pump.isInitialized()) { @@ -583,7 +583,7 @@ public class LoopPlugin extends PluginBase { return; } - PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin(); long lastBolusTime = activeTreatments.getLastBolusTime(); @@ -633,7 +633,7 @@ public class LoopPlugin extends PluginBase { } public void disconnectPump(int durationInMinutes, Profile profile) { - PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin(); LoopPlugin.getPlugin().disconnectTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000L); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSUpload.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSUpload.java index 5a1f06a247..8f3f31f6e7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSUpload.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/NSUpload.java @@ -249,7 +249,7 @@ public class NSUpload { log.debug("OpenAPS data too old to upload"); } deviceStatus.device = "openaps://" + Build.MANUFACTURER + " " + Build.MODEL; - JSONObject pumpstatus = ConfigBuilderPlugin.getActivePump().getJSONStatus(profile, profileName); + JSONObject pumpstatus = ConfigBuilderPlugin.getPlugin().getActivePump().getJSONStatus(profile, profileName); if (pumpstatus != null) { deviceStatus.pump = pumpstatus; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java index 413b75cd1a..3bf1301416 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/OpenAPSAMAPlugin.java @@ -67,13 +67,13 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface { @Override public boolean specialEnableCondition() { - PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); return pump == null || pump.getPumpDescription().isTempBasalCapable; } @Override public boolean specialShowInListCondition() { - PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); return pump == null || pump.getPumpDescription().isTempBasalCapable; } @@ -97,7 +97,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface { GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData(); Profile profile = ProfileFunctions.getInstance().getProfile(); - PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (profile == null) { MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected))); @@ -188,7 +188,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface { start = System.currentTimeMillis(); try { - determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, ConfigBuilderPlugin.getActivePump().getBaseBasalRate(), iobArray, glucoseStatus, mealData, + determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, ConfigBuilderPlugin.getPlugin().getActivePump().getBaseBasalRate(), iobArray, glucoseStatus, mealData, lastAutosensResult.ratio, //autosensDataRatio isTempTarget ); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java index 954204e47a..5b59252ea1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java @@ -66,13 +66,13 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface { @Override public boolean specialEnableCondition() { - PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); return pump == null || pump.getPumpDescription().isTempBasalCapable; } @Override public boolean specialShowInListCondition() { - PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); return pump == null || pump.getPumpDescription().isTempBasalCapable; } @@ -96,7 +96,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface { GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData(); Profile profile = ProfileFunctions.getInstance().getProfile(); - PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (profile == null) { MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected))); @@ -168,7 +168,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface { start = System.currentTimeMillis(); try { - determineBasalAdapterMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, ConfigBuilderPlugin.getActivePump().getBaseBasalRate(), iobTotal, glucoseStatus, mealData); + determineBasalAdapterMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, ConfigBuilderPlugin.getPlugin().getActivePump().getBaseBasalRate(), iobTotal, glucoseStatus, mealData); } catch (JSONException e) { log.error("Unhandled exception", e); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java index 9390b9b588..d42ca9e89f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/OpenAPSSMBPlugin.java @@ -72,13 +72,13 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface { @Override public boolean specialEnableCondition() { - PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); return pump == null || pump.getPumpDescription().isTempBasalCapable; } @Override public boolean specialShowInListCondition() { - PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); return pump == null || pump.getPumpDescription().isTempBasalCapable; } @@ -102,7 +102,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface { GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData(); Profile profile = ProfileFunctions.getInstance().getProfile(); - PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (profile == null) { MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.noprofileselected))); @@ -205,7 +205,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface { start = System.currentTimeMillis(); try { - determineBasalAdapterSMBJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, ConfigBuilderPlugin.getActivePump().getBaseBasalRate(), iobArray, glucoseStatus, mealData, + determineBasalAdapterSMBJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, ConfigBuilderPlugin.getPlugin().getActivePump().getBaseBasalRate(), iobArray, glucoseStatus, mealData, lastAutosensResult.ratio, //autosensDataRatio isTempTarget, smbAllowed.value(), diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewInsulinDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewInsulinDialog.java index 942fde95fb..453048a3ec 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewInsulinDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewInsulinDialog.java @@ -133,7 +133,7 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value(); editInsulin = view.findViewById(R.id.newinsulin_amount); - editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher); + editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher); Button plus1Button = view.findViewById(R.id.newinsulin_plus05); plus1Button.setOnClickListener(this); @@ -212,7 +212,7 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener try { Profile currentProfile = ProfileFunctions.getInstance().getProfile(); - final PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (currentProfile == null || pump == null) return; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTreatmentDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTreatmentDialog.java index df85279592..909ced9542 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTreatmentDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTreatmentDialog.java @@ -105,7 +105,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_insulinamount); editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher); - editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher); + editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher); recordOnlyCheckbox = (CheckBox) view.findViewById(R.id.newtreatment_record_only); @@ -126,7 +126,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene okClicked = true; try { - final PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (pump == null) return; @@ -177,7 +177,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene detailedBolusInfo.carbs = finalCarbsAfterConstraints; detailedBolusInfo.context = context; detailedBolusInfo.source = Source.USER; - if (!(recordOnlyCheckbox.isChecked() && (detailedBolusInfo.insulin > 0 || ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo))) { + if (!(recordOnlyCheckbox.isChecked() && (detailedBolusInfo.insulin > 0 || ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().storesCarbInfo))) { ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() { @Override public void run() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java index ed66fe7b2f..819c46dc7e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java @@ -270,7 +270,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com editBg.setParams(0d, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false, textWatcher); editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher); - double bolusstep = ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep; + double bolusstep = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep; editCorr.setParams(0d, -maxCorrection, maxCorrection, bolusstep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher); editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false); initDialog(); @@ -327,7 +327,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com } okClicked = true; final Profile profile = ProfileFunctions.getInstance().getProfile(); - final PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (pump != null && profile != null && (calculatedTotalInsulin > 0d || calculatedCarbs > 0d)) { String confirmMessage = MainApp.gs(R.string.entertreatmentquestion); @@ -394,7 +394,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com detailedBolusInfo.boluscalc = boluscalcJSON; detailedBolusInfo.source = Source.USER; detailedBolusInfo.notes = finalNotes; - if (detailedBolusInfo.insulin > 0 || ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo) { + if (detailedBolusInfo.insulin > 0 || ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().storesCarbInfo) { ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() { @Override public void run() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index f01c90423e..7859fa1c80 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -446,7 +446,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, super.onCreateContextMenu(menu, v, menuInfo); if (v == apsModeView) { final LoopPlugin loopPlugin = LoopPlugin.getPlugin(); - final PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription(); + final PumpDescription pumpDescription = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription(); if (!ProfileFunctions.getInstance().isProfileValid("ContexMenuCreation")) return; menu.setHeaderTitle(MainApp.gs(R.string.loop)); @@ -681,7 +681,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, new NewCarbsDialog().show(manager, "CarbsDialog"); break; case R.id.overview_pumpstatus: - if (ConfigBuilderPlugin.getActivePump().isSuspended() || !ConfigBuilderPlugin.getActivePump().isInitialized()) + if (ConfigBuilderPlugin.getPlugin().getActivePump().isSuspended() || !ConfigBuilderPlugin.getPlugin().getActivePump().isInitialized()) ConfigBuilderPlugin.getCommandQueue().readStatus("RefreshClicked", null); break; } @@ -836,7 +836,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, detailedBolusInfo.context = context; detailedBolusInfo.boluscalc = boluscalcJSON; detailedBolusInfo.source = Source.USER; - if (finalInsulinAfterConstraints > 0 || ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo) { + if (finalInsulinAfterConstraints > 0 || ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().storesCarbInfo) { ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() { @Override public void run() { @@ -1043,7 +1043,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, BgReading actualBG = DatabaseHelper.actualBg(); BgReading lastBG = DatabaseHelper.lastBg(); - final PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); final Profile profile = ProfileFunctions.getInstance().getProfile(); @@ -1248,7 +1248,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, // **** Various treatment buttons **** if (carbsButton != null) { if (SP.getBoolean(R.string.key_show_carbs_button, true) - && (!ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo || + && (!ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().storesCarbInfo || (pump.isInitialized() && !pump.isSuspended()))) { carbsButton.setVisibility(View.VISIBLE); } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java index 948e0e1ef4..a4b3fc597a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/graphData/GraphData.java @@ -303,7 +303,7 @@ public class GraphData { } // Extended bolus - if (!ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) { + if (!ConfigBuilderPlugin.getPlugin().getActivePump().isFakingTempsByExtendedBoluses()) { List extendedBoluses = TreatmentsPlugin.getPlugin().getExtendedBolusesFromHistory().getList(); for (int tx = 0; tx < extendedBoluses.size(); tx++) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java index a8263b541f..f7a49c95c2 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Persistentnotification/PersistentNotificationPlugin.java @@ -145,7 +145,7 @@ public class PersistentNotificationPlugin extends PluginBase { String line2 = MainApp.gs(R.string.treatments_iob_label_string) + " " + DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U " + MainApp.gs(R.string.cob)+": " + IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "PersistentNotificationPlugin").generateCOBString();; - String line3 = DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) + " U/h"; + String line3 = DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getPlugin().getActivePump().getBaseBasalRate()) + " U/h"; line3 += " - " + ProfileFunctions.getInstance().getProfileName(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java index 3fab80855a..fc45928f89 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfileFragment.java @@ -79,7 +79,7 @@ public class LocalProfileFragment extends SubscriberFragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { - PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription(); + PumpDescription pumpDescription = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription(); View layout = inflater.inflate(R.layout.localprofile_fragment, container, false); diaView = (NumberPicker) layout.findViewById(R.id.localprofile_dia); diaView.setParams(LocalProfilePlugin.getPlugin().dia, 2d, 48d, 0.1d, new DecimalFormat("0.0"), false, textWatch); @@ -96,7 +96,7 @@ public class LocalProfileFragment extends SubscriberFragment { invalidProfile = (TextView) layout.findViewById(R.id.invalidprofile); - if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) { + if (!ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().isTempBasalCapable) { layout.findViewById(R.id.localprofile_basal).setVisibility(View.GONE); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java index 5e090cd9ba..b4338366bd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfileFragment.java @@ -55,7 +55,7 @@ public class SimpleProfileFragment extends SubscriberFragment { profileswitchButton = (Button) layout.findViewById(R.id.simpleprofile_profileswitch); invalidProfile = (TextView) layout.findViewById(R.id.invalidprofile); - if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) { + if (!ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().isTempBasalCapable) { layout.findViewById(R.id.simpleprofile_basalrate).setVisibility(View.GONE); layout.findViewById(R.id.simpleprofile_basalrate_label).setVisibility(View.GONE); } @@ -136,7 +136,7 @@ public class SimpleProfileFragment extends SubscriberFragment { if (activity != null) activity.runOnUiThread(() -> { boolean isValid = SimpleProfilePlugin.getPlugin().getProfile() != null && SimpleProfilePlugin.getPlugin().getProfile().getDefaultProfile().isValid(MainApp.gs(R.string.simpleprofile)); - if (!ConfigBuilderPlugin.getActivePump().isInitialized() || ConfigBuilderPlugin.getActivePump().isSuspended() || !isValid) { + if (!ConfigBuilderPlugin.getPlugin().getActivePump().isInitialized() || ConfigBuilderPlugin.getPlugin().getActivePump().isSuspended() || !isValid) { profileswitchButton.setVisibility(View.GONE); } else { profileswitchButton.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java index 83e27806d1..b0cc64467c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java @@ -228,9 +228,9 @@ public class DanaRFragment extends SubscriberFragment { dailyUnitsView.setText(DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U"); SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d); - basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) + " U/h"); + basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getPlugin().getActivePump().getBaseBasalRate()) + " U/h"); // DanaRPlugin, DanaRKoreanPlugin - if (ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) { + if (ConfigBuilderPlugin.getPlugin().getActivePump().isFakingTempsByExtendedBoluses()) { if (TreatmentsPlugin.getPlugin().isInHistoryRealTempBasalInProgress()) { tempBasalView.setText(TreatmentsPlugin.getPlugin().getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull()); } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/Dialogs/ProfileViewDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/Dialogs/ProfileViewDialog.java index e44ffd8c57..a00b8003f1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/Dialogs/ProfileViewDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/Dialogs/ProfileViewDialog.java @@ -71,13 +71,13 @@ public class ProfileViewDialog extends DialogFragment { } private void setContent() { - ProfileStore store = ((ProfileInterface)MainApp.getConfigBuilder().getActivePump()).getProfile(); + ProfileStore store = ((ProfileInterface)ConfigBuilderPlugin.getPlugin().getActivePump()).getProfile(); if (store != null) { noProfile.setVisibility(View.GONE); Profile profile = store.getDefaultProfile(); units.setText(profile.getUnits()); dia.setText(DecimalFormatter.to2Decimal(profile.getDia()) + " h"); - activeProfile.setText(((ProfileInterface) MainApp.getConfigBuilder().getActivePump()).getProfileName()); + activeProfile.setText(((ProfileInterface) ConfigBuilderPlugin.getPlugin().getActivePump()).getProfileName()); ic.setText(profile.getIcList()); isf.setText(profile.getIsfList()); basal.setText(profile.getBasalList()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java index 1e13250db3..20db668159 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java @@ -160,7 +160,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService { mDanaRPump.lastConnection = now; Profile profile = ProfileFunctions.getInstance().getProfile(); - PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (profile != null && Math.abs(mDanaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) { MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings))); mSerialIOThread.sendMessage(new MsgSettingBasal()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java index 8adc954aa4..456bf2a40e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/services/DanaRKoreanExecutionService.java @@ -164,7 +164,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService { mDanaRPump.lastConnection = now; Profile profile = ProfileFunctions.getInstance().getProfile(); - PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (profile != null && Math.abs(mDanaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) { MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings))); mSerialIOThread.sendMessage(new MsgSettingBasal()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java index ce63eb9859..a52926aa1f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java @@ -144,7 +144,7 @@ public class DanaRSService extends Service { danaRPump.lastConnection = System.currentTimeMillis(); Profile profile = ProfileFunctions.getInstance().getProfile(); - PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (profile != null && Math.abs(danaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) { MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings))); bleComm.sendMessage(new DanaRS_Packet_Basal_Get_Basal_Rate()); // basal profile, basalStep, maxBasal diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java index 59f0ba9330..1c1046180c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java @@ -182,7 +182,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService { mDanaRPump.lastConnection = System.currentTimeMillis(); Profile profile = ProfileFunctions.getInstance().getProfile(); - PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (profile != null && Math.abs(mDanaRPump.currentBasal - profile.getBasal()) >= pump.getPumpDescription().basalStep) { MainApp.bus().post(new EventPumpStatusChanged(MainApp.gs(R.string.gettingpumpsettings))); mSerialIOThread.sendMessage(new MsgSettingBasal()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java index e5b8b76c9b..37c1aeb1f0 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java @@ -348,7 +348,7 @@ public class SmsCommunicatorPlugin extends PluginBase { ConfigBuilderPlugin.getCommandQueue().readStatus("SMS", new Callback() { @Override public void run() { - PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (result.success) { if (pump != null) { String reply = pump.shortStatus(true); @@ -405,7 +405,7 @@ public class SmsCommunicatorPlugin extends PluginBase { if (System.currentTimeMillis() - lastRemoteBolusTime.getTime() < Constants.remoteBolusMinDistance) { reply = MainApp.gs(R.string.smscommunicator_remotebolusnotallowed); sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis())); - } else if (ConfigBuilderPlugin.getActivePump().isSuspended()) { + } else if (ConfigBuilderPlugin.getPlugin().getActivePump().isSuspended()) { reply = MainApp.gs(R.string.pumpsuspended); sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis())); } else if (splited.length > 1) { @@ -452,7 +452,7 @@ public class SmsCommunicatorPlugin extends PluginBase { ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() { @Override public void run() { - PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (result.success) { SystemClock.sleep(T.secs(15).msecs()); // wait some time to get history String reply = String.format(MainApp.gs(R.string.smscommunicator_bolusdelivered), result.bolusDelivered); @@ -479,11 +479,11 @@ public class SmsCommunicatorPlugin extends PluginBase { public void run() { if (result.success) { String reply = String.format(MainApp.gs(R.string.smscommunicator_tempbasalset), result.absolute, result.duration); - reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true); + reply += "\n" + ConfigBuilderPlugin.getPlugin().getActivePump().shortStatus(true); sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis())); } else { String reply = MainApp.gs(R.string.smscommunicator_tempbasalfailed); - reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true); + reply += "\n" + ConfigBuilderPlugin.getPlugin().getActivePump().shortStatus(true); sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis())); } } @@ -496,11 +496,11 @@ public class SmsCommunicatorPlugin extends PluginBase { public void run() { if (result.success) { String reply = MainApp.gs(R.string.smscommunicator_tempbasalcanceled); - reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true); + reply += "\n" + ConfigBuilderPlugin.getPlugin().getActivePump().shortStatus(true); sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis())); } else { String reply = MainApp.gs(R.string.smscommunicator_tempbasalcancelfailed); - reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true); + reply += "\n" + ConfigBuilderPlugin.getPlugin().getActivePump().shortStatus(true); sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis())); } } @@ -531,7 +531,7 @@ public class SmsCommunicatorPlugin extends PluginBase { sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis())); } else { String reply = MainApp.gs(R.string.smscommunicator_tempbasalcancelfailed); - reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true); + reply += "\n" + ConfigBuilderPlugin.getPlugin().getActivePump().shortStatus(true); sendSMS(new Sms(receivedSms.phoneNumber, reply, System.currentTimeMillis())); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/CarbsGenerator.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/CarbsGenerator.java index 01eeee3662..568aa4e1ec 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/CarbsGenerator.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/CarbsGenerator.java @@ -35,7 +35,7 @@ public class CarbsGenerator { carbInfo.context = MainApp.instance(); carbInfo.source = Source.USER; carbInfo.notes = notes; - if (ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo && carbInfo.date <= now()) { + if (ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().storesCarbInfo && carbInfo.date <= now()) { ConfigBuilderPlugin.getCommandQueue().bolus(carbInfo, new Callback() { @Override public void run() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java index 550522313d..32feb9fe7f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsFragment.java @@ -121,7 +121,7 @@ public class TreatmentsFragment extends SubscriberFragment implements View.OnCli @Override protected void updateGUI() { - if (ConfigBuilderPlugin.getActivePump().getPumpDescription().isExtendedBolusCapable + if (ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().isExtendedBolusCapable || TreatmentsPlugin.getPlugin().getExtendedBolusesFromHistory().size() > 0) { extendedBolusesTab.setVisibility(View.VISIBLE); } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java index 1967cc369b..15cef992c1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java @@ -209,7 +209,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface } } - if (!ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) + if (!ConfigBuilderPlugin.getPlugin().getActivePump().isFakingTempsByExtendedBoluses()) synchronized (extendedBoluses) { for (Integer pos = 0; pos < extendedBoluses.size(); pos++) { ExtendedBolus e = extendedBoluses.get(pos); @@ -391,7 +391,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface total.plus(calc); } } - if (ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) { + if (ConfigBuilderPlugin.getPlugin().getActivePump().isFakingTempsByExtendedBoluses()) { IobTotal totalExt = new IobTotal(time); synchronized (extendedBoluses) { for (Integer pos = 0; pos < extendedBoluses.size(); pos++) { @@ -433,7 +433,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface if (tb != null) return tb; ExtendedBolus eb = getExtendedBolusFromHistory(time); - if (eb != null && ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) + if (eb != null && ConfigBuilderPlugin.getPlugin().getActivePump().isFakingTempsByExtendedBoluses()) return new TemporaryBasal(eb); return null; } @@ -451,11 +451,11 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface boolean newRecordCreated = MainApp.getDbHelper().createOrUpdate(extendedBolus); if (newRecordCreated) { if (extendedBolus.durationInMinutes == 0) { - if (MainApp.getConfigBuilder().getActivePump().isFakingTempsByExtendedBoluses()) + if (ConfigBuilderPlugin.getPlugin().getActivePump().isFakingTempsByExtendedBoluses()) NSUpload.uploadTempBasalEnd(extendedBolus.date, true, extendedBolus.pumpId); else NSUpload.uploadExtendedBolusEnd(extendedBolus.date, extendedBolus.pumpId); - } else if (MainApp.getConfigBuilder().getActivePump().isFakingTempsByExtendedBoluses()) + } else if (ConfigBuilderPlugin.getPlugin().getActivePump().isFakingTempsByExtendedBoluses()) NSUpload.uploadTempBasalStartAbsolute(new TemporaryBasal(extendedBolus), extendedBolus.insulin); else NSUpload.uploadExtendedBolus(extendedBolus); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java index 0fd1c557b1..5c2a00ac02 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/ActionStringHandler.java @@ -295,7 +295,7 @@ public class ActionStringHandler { } } else if ("tddstats".equals(act[0])) { - Object activePump = MainApp.getConfigBuilder().getActivePump(); + Object activePump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (activePump != null) { // check if DB up to date List dummies = new LinkedList(); @@ -307,7 +307,7 @@ public class ActionStringHandler { rMessage = "OLD DATA - "; //if pump is not busy: try to fetch data - final PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (pump.isBusy()) { rMessage += MainApp.gs(R.string.pumpbusy); } else { @@ -398,7 +398,7 @@ public class ActionStringHandler { double refTDD = profile.baseBasalSum() * 2; - PumpInterface pump = MainApp.getConfigBuilder().getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (df.format(new Date(historyList.get(0).date)).equals(df.format(new Date()))) { double tdd = historyList.get(0).getTotal(); historyList.remove(0); @@ -447,7 +447,7 @@ public class ActionStringHandler { } public static boolean isOldData(List historyList) { - Object activePump = MainApp.getConfigBuilder().getActivePump(); + Object activePump = ConfigBuilderPlugin.getPlugin().getActivePump(); PumpInterface dana = MainApp.getSpecificPlugin(DanaRPlugin.class); PumpInterface danaRS = MainApp.getSpecificPlugin(DanaRSPlugin.class); PumpInterface danaV2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class); @@ -498,7 +498,7 @@ public class ActionStringHandler { @NonNull private static String getPumpStatus() { - return ConfigBuilderPlugin.getActivePump().shortStatus(false); + return ConfigBuilderPlugin.getPlugin().getActivePump().shortStatus(false); } @NonNull @@ -582,7 +582,7 @@ public class ActionStringHandler { ret += MainApp.gs(R.string.canceltemp) + "\n"; } else { ret += MainApp.gs(R.string.rate) + ": " + DecimalFormatter.to2Decimal(result.rate) + " U/h " + - "(" + DecimalFormatter.to2Decimal(result.rate / ConfigBuilderPlugin.getActivePump().getBaseBasalRate() * 100) + "%)\n" + + "(" + DecimalFormatter.to2Decimal(result.rate / ConfigBuilderPlugin.getPlugin().getActivePump().getBaseBasalRate() * 100) + "%)\n" + MainApp.gs(R.string.duration) + ": " + DecimalFormatter.to0Decimal(result.duration) + " min\n"; } ret += "\n" + MainApp.gs(R.string.reason) + ": " + result.reason; @@ -732,7 +732,7 @@ public class ActionStringHandler { detailedBolusInfo.insulin = amount; detailedBolusInfo.carbs = carbs; detailedBolusInfo.source = Source.USER; - if (detailedBolusInfo.insulin > 0 || ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo) { + if (detailedBolusInfo.insulin > 0 || ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().storesCarbInfo) { ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() { @Override public void run() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java index 4b4d1c4854..8007e03164 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Wear/wearintegration/WatchUpdaterService.java @@ -209,7 +209,7 @@ public class WatchUpdaterService extends WearableListenerService implements } private void cancelBolus() { - ConfigBuilderPlugin.getActivePump().stopBolusDelivering(); + ConfigBuilderPlugin.getPlugin().getActivePump().stopBolusDelivering(); } private void sendData() { diff --git a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java index 0e74ec8185..2ef2d5198a 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/CommandQueue.java @@ -245,7 +245,7 @@ public class CommandQueue { } removeAll(Command.CommandType.BOLUS); removeAll(Command.CommandType.SMB_BOLUS); - ConfigBuilderPlugin.getActivePump().stopBolusDelivering(); + ConfigBuilderPlugin.getPlugin().getActivePump().stopBolusDelivering(); } // returns true if command is queued @@ -369,7 +369,7 @@ public class CommandQueue { // Compare with pump limits Profile.BasalValue[] basalValues = profile.getBasalValues(); - PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); for (Profile.BasalValue basalValue : basalValues) { if (basalValue.value < pump.getPumpDescription().basalMinimumRate) { @@ -508,7 +508,7 @@ public class CommandQueue { } public boolean isThisProfileSet(Profile profile) { - PumpInterface activePump = ConfigBuilderPlugin.getActivePump(); + PumpInterface activePump = ConfigBuilderPlugin.getPlugin().getActivePump(); Profile current = ProfileFunctions.getInstance().getProfile(); if (activePump != null && current != null) { boolean result = activePump.isThisProfileSet(profile); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java b/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java index d59a83a4f4..7c95498db4 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/QueueThread.java @@ -54,7 +54,7 @@ public class QueueThread extends Thread { try { while (true) { - PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (pump == null) { if (L.isEnabled(L.PUMPQUEUE)) log.debug("pump == null"); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.java index 7e17e831e9..c239502187 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandBolus.java @@ -30,7 +30,7 @@ public class CommandBolus extends Command { @Override public void execute() { - PumpEnactResult r = ConfigBuilderPlugin.getActivePump().deliverTreatment(detailedBolusInfo); + PumpEnactResult r = ConfigBuilderPlugin.getPlugin().getActivePump().deliverTreatment(detailedBolusInfo); BolusProgressDialog.bolusEnded = true; MainApp.bus().post(new EventDismissBolusprogressIfRunning(r)); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.java index 164a049647..8dca488890 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelExtendedBolus.java @@ -22,7 +22,7 @@ public class CommandCancelExtendedBolus extends Command { @Override public void execute() { - PumpEnactResult r = ConfigBuilderPlugin.getActivePump().cancelExtendedBolus(); + PumpEnactResult r = ConfigBuilderPlugin.getPlugin().getActivePump().cancelExtendedBolus(); if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result success: " + r.success + " enacted: " + r.enacted); if (callback != null) diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.java index 5daa0e38e4..241ae015fb 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandCancelTempBasal.java @@ -25,7 +25,7 @@ public class CommandCancelTempBasal extends Command { @Override public void execute() { - PumpEnactResult r = ConfigBuilderPlugin.getActivePump().cancelTempBasal(enforceNew); + PumpEnactResult r = ConfigBuilderPlugin.getPlugin().getActivePump().cancelTempBasal(enforceNew); if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result success: " + r.success + " enacted: " + r.enacted); if (callback != null) diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.java index ea329c04d7..ea513bbb6c 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandExtendedBolus.java @@ -27,7 +27,7 @@ public class CommandExtendedBolus extends Command { @Override public void execute() { - PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setExtendedBolus(insulin, durationInMinutes); + PumpEnactResult r = ConfigBuilderPlugin.getPlugin().getActivePump().setExtendedBolus(insulin, durationInMinutes); if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result rate: " + insulin + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted); if (callback != null) diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.java index 5cc954f5ff..0742075035 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadEvents.java @@ -24,7 +24,7 @@ public class CommandLoadEvents extends Command { @Override public void execute() { - PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (pump instanceof DanaRInterface) { DanaRInterface danaPump = (DanaRInterface) pump; PumpEnactResult r = danaPump.loadEvents(); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.java index 1259812676..01ec6e1f16 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadHistory.java @@ -27,7 +27,7 @@ public class CommandLoadHistory extends Command { @Override public void execute() { - PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (pump instanceof DanaRInterface) { DanaRInterface danaPump = (DanaRInterface) pump; PumpEnactResult r = danaPump.loadHistory(type); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.java index 1212303e82..c072766310 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandLoadTDDs.java @@ -24,7 +24,7 @@ public class CommandLoadTDDs extends Command { @Override public void execute() { - PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); PumpEnactResult r = pump.loadTDDs(); if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result success: " + r.success + " enacted: " + r.enacted); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.java index a303375a49..7e5bded5ee 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandReadStatus.java @@ -28,11 +28,11 @@ public class CommandReadStatus extends Command { @Override public void execute() { - ConfigBuilderPlugin.getActivePump().getPumpStatus(); + ConfigBuilderPlugin.getPlugin().getActivePump().getPumpStatus(); LocalAlertUtils.notifyPumpStatusRead(); if (L.isEnabled(L.PUMPQUEUE)) log.debug("CommandReadStatus executed. Reason: " + reason); - final PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); PumpEnactResult result = new PumpEnactResult().success(false); if (pump != null) { long lastConnection = pump.lastDataTime(); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.java index affc7aed22..1bd958866e 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSMBBolus.java @@ -37,7 +37,7 @@ public class CommandSMBBolus extends Command { log.debug("SMB requsted but still in 3 min interval"); r = new PumpEnactResult().enacted(false).success(false).comment("SMB requsted but still in 3 min interval"); } else if (detailedBolusInfo.deliverAt != 0 && detailedBolusInfo.deliverAt + T.mins(1).msecs() > System.currentTimeMillis()) { - r = ConfigBuilderPlugin.getActivePump().deliverTreatment(detailedBolusInfo); + r = ConfigBuilderPlugin.getPlugin().getActivePump().deliverTreatment(detailedBolusInfo); } else { r = new PumpEnactResult().enacted(false).success(false).comment("SMB request too old"); if (L.isEnabled(L.PUMPQUEUE)) diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java index 2a5e4a275a..f23d7ae34a 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetProfile.java @@ -41,7 +41,7 @@ public class CommandSetProfile extends Command { return; } - PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setNewBasalProfile(profile); + PumpEnactResult r = ConfigBuilderPlugin.getPlugin().getActivePump().setNewBasalProfile(profile); if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result success: " + r.success + " enacted: " + r.enacted + " profile: " + profile.toString()); if (callback != null) diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java index 8a9ae21c70..c1bf69ce01 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandSetUserSettings.java @@ -24,7 +24,7 @@ public class CommandSetUserSettings extends Command { @Override public void execute() { - PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); if (pump instanceof DanaRInterface) { DanaRInterface danaPump = (DanaRInterface) pump; PumpEnactResult r = danaPump.setUserOptions(); diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.java index a2787cabb6..9e75fd0713 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalAbsolute.java @@ -32,7 +32,7 @@ public class CommandTempBasalAbsolute extends Command { @Override public void execute() { - PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setTempBasalAbsolute(absoluteRate, durationInMinutes, profile, enforceNew); + PumpEnactResult r = ConfigBuilderPlugin.getPlugin().getActivePump().setTempBasalAbsolute(absoluteRate, durationInMinutes, profile, enforceNew); if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result rate: " + absoluteRate + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted); if (callback != null) diff --git a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.java b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.java index efdfca0a69..2bc44e269e 100644 --- a/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.java +++ b/app/src/main/java/info/nightscout/androidaps/queue/commands/CommandTempBasalPercent.java @@ -32,7 +32,7 @@ public class CommandTempBasalPercent extends Command { @Override public void execute() { - PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setTempBasalPercent(percent, durationInMinutes, profile, enforceNew); + PumpEnactResult r = ConfigBuilderPlugin.getPlugin().getActivePump().setTempBasalPercent(percent, durationInMinutes, profile, enforceNew); if (L.isEnabled(L.PUMPQUEUE)) log.debug("Result percent: " + percent + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted); if (callback != null) diff --git a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java index 6b51fc1418..9d6423772c 100644 --- a/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java +++ b/app/src/main/java/info/nightscout/androidaps/receivers/KeepAliveReceiver.java @@ -60,7 +60,7 @@ public class KeepAliveReceiver extends BroadcastReceiver { } private void checkPump() { - final PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); final Profile profile = ProfileFunctions.getInstance().getProfile(); if (pump != null && profile != null) { long lastConnection = pump.lastDataTime(); diff --git a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java index be95f3e3ac..e0f1badbc5 100644 --- a/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java +++ b/app/src/main/java/info/nightscout/androidaps/setupwizard/SWDefinition.java @@ -317,18 +317,18 @@ public class SWDefinition { .add(new SWButton() .text(R.string.pumpsetup) .action(() -> { - final PluginBase plugin = (PluginBase) MainApp.getConfigBuilder().getActivePump(); + final PluginBase plugin = (PluginBase) ConfigBuilderPlugin.getPlugin().getActivePump(); PasswordProtection.QueryPassword(activity, R.string.settings_password, "settings_password", () -> { Intent i = new Intent(activity, PreferencesActivity.class); i.putExtra("id", plugin.getPreferencesId()); activity.startActivity(i); }, null); }) - .visibility(() -> ((PluginBase) MainApp.getConfigBuilder().getActivePump()).getPreferencesId() > 0)) + .visibility(() -> ((PluginBase) ConfigBuilderPlugin.getPlugin().getActivePump()).getPreferencesId() > 0)) .add(new SWButton() .text(R.string.readstatus) .action(() -> ConfigBuilderPlugin.getCommandQueue().readStatus("Clicked connect to pump", null)) - .visibility(() -> MainApp.getConfigBuilder().getActivePump() != null)) + .visibility(() -> ConfigBuilderPlugin.getPlugin().getActivePump() != null)) .add(new SWEventListener(this) .listener(new Object() { @Subscribe @@ -337,7 +337,7 @@ public class SWDefinition { } }) ) - .validator(() -> MainApp.getConfigBuilder().getActivePump() != null && MainApp.getConfigBuilder().getActivePump().isInitialized()) + .validator(() -> ConfigBuilderPlugin.getPlugin().getActivePump() != null && ConfigBuilderPlugin.getPlugin().getActivePump().isInitialized()) ) .add(new SWScreen(R.string.configbuilder_aps) .skippable(false) diff --git a/app/src/main/java/info/nightscout/utils/BolusWizard.java b/app/src/main/java/info/nightscout/utils/BolusWizard.java index cfdd670f51..d20827ce9e 100644 --- a/app/src/main/java/info/nightscout/utils/BolusWizard.java +++ b/app/src/main/java/info/nightscout/utils/BolusWizard.java @@ -136,7 +136,7 @@ public class BolusWizard { calculatedTotalInsulin = 0d; } - double bolusStep = ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep; + double bolusStep = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep; calculatedTotalInsulin = Round.roundTo(calculatedTotalInsulin, bolusStep); log.debug(log()); diff --git a/app/src/main/java/info/nightscout/utils/DecimalFormatter.java b/app/src/main/java/info/nightscout/utils/DecimalFormatter.java index 84a40de84b..620e636843 100644 --- a/app/src/main/java/info/nightscout/utils/DecimalFormatter.java +++ b/app/src/main/java/info/nightscout/utils/DecimalFormatter.java @@ -46,13 +46,13 @@ public class DecimalFormatter { } public static String toPumpSupportedBolus(double value) { - return ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep <= 0.051 + return ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep <= 0.051 ? to2Decimal(value) : to1Decimal(value); } public static DecimalFormat pumpSupportedBolusFormat() { - return ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep <= 0.051 + return ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep <= 0.051 ? new DecimalFormat("0.00") : new DecimalFormat("0.0"); } diff --git a/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java b/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java index 2e180365aa..89c422ec53 100644 --- a/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java +++ b/app/src/main/java/info/nightscout/utils/LocalAlertUtils.java @@ -78,7 +78,7 @@ public class LocalAlertUtils { public static void notifyPumpStatusRead() { //TODO: persist the actual time the pump is read and simplify the whole logic when to alarm - final PumpInterface pump = ConfigBuilderPlugin.getActivePump(); + final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); final Profile profile = ProfileFunctions.getInstance().getProfile(); if (pump != null && profile != null) { long lastConnection = pump.lastDataTime(); diff --git a/app/src/test/java/info/AAPSMocker.java b/app/src/test/java/info/AAPSMocker.java index 81c8b99597..666097b588 100644 --- a/app/src/test/java/info/AAPSMocker.java +++ b/app/src/test/java/info/AAPSMocker.java @@ -114,6 +114,7 @@ public class AAPSMocker { PowerMockito.mockStatic(ConfigBuilderPlugin.class); ConfigBuilderPlugin configBuilderPlugin = mock(ConfigBuilderPlugin.class); when(MainApp.getConfigBuilder()).thenReturn(configBuilderPlugin); + when(ConfigBuilderPlugin.getPlugin()).thenReturn(configBuilderPlugin); } public static ConstraintChecker mockConstraintsChecker() { diff --git a/app/src/test/java/info/nightscout/androidaps/data/ProfileIntervalsTest.java b/app/src/test/java/info/nightscout/androidaps/data/ProfileIntervalsTest.java index 12f81c66fe..9483cb95ef 100644 --- a/app/src/test/java/info/nightscout/androidaps/data/ProfileIntervalsTest.java +++ b/app/src/test/java/info/nightscout/androidaps/data/ProfileIntervalsTest.java @@ -15,6 +15,7 @@ import java.util.List; import info.AAPSMocker; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.db.ProfileSwitch; +import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.utils.DateUtil; import info.nightscout.utils.T; @@ -23,7 +24,7 @@ import info.nightscout.utils.T; */ @RunWith(PowerMockRunner.class) -@PrepareForTest({MainApp.class, Bus.class}) +@PrepareForTest({MainApp.class, Bus.class, ConfigBuilderPlugin.class}) public class ProfileIntervalsTest { private final long startDate = DateUtil.now(); ProfileIntervals list = new ProfileIntervals<>(); @@ -89,5 +90,6 @@ public class ProfileIntervalsTest { AAPSMocker.mockMainApp(); AAPSMocker.mockStrings(); AAPSMocker.mockBus(); + AAPSMocker.mockConfigBuilder(); } } diff --git a/app/src/test/java/info/nightscout/androidaps/data/ProfileTest.java b/app/src/test/java/info/nightscout/androidaps/data/ProfileTest.java index 78a5a338aa..7e7ab7e530 100644 --- a/app/src/test/java/info/nightscout/androidaps/data/ProfileTest.java +++ b/app/src/test/java/info/nightscout/androidaps/data/ProfileTest.java @@ -137,7 +137,7 @@ public class ProfileTest { "03:00 110.0 mmol/U", p.getIsfList()); // Test hour alignment - MainApp.getConfigBuilder().getActivePump().getPumpDescription().is30minBasalRatesCapable = false; + ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().is30minBasalRatesCapable = false; ((AAPSMocker.MockedBus) MainApp.bus()).notificationSent = false; p = new Profile(new JSONObject(notAllignedBasalValidProfile), 100, 0); p.isValid("Test"); @@ -151,7 +151,7 @@ public class ProfileTest { AAPSMocker.mockStrings(); AAPSMocker.prepareMockedBus(); - when(MainApp.getConfigBuilder().getActivePump()).thenReturn(pump); + when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(pump); PowerMockito.mockStatic(FabricPrivacy.class); // PowerMockito.doNothing().when(FabricPrivacy.log("")); diff --git a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java index 205ceed465..0376bd3f0c 100644 --- a/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java +++ b/app/src/test/java/info/nightscout/androidaps/interfaces/ConstraintsCheckerTest.java @@ -280,7 +280,7 @@ public class ConstraintsCheckerTest { when(SP.getString(R.string.key_danars_address, "")).thenReturn(""); //SafetyPlugin - when(MainApp.getConfigBuilder().getActivePump()).thenReturn(pump); + when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(pump); constraintChecker = new ConstraintChecker(mainApp); diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPluginTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPluginTest.java index ae350c4fe6..f5c439291c 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPluginTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/ConstraintsSafety/SafetyPluginTest.java @@ -231,7 +231,7 @@ public class SafetyPluginTest { AAPSMocker.mockBus(); - when(MainApp.getConfigBuilder().getActivePump()).thenReturn(pump); + when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(pump); safetyPlugin = SafetyPlugin.getPlugin(); } diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/Loop/APSResultTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/Loop/APSResultTest.java index d5fe95c49d..c9e082ed43 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/Loop/APSResultTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/Loop/APSResultTest.java @@ -187,7 +187,7 @@ public class APSResultTest { ConstraintChecker constraintChecker = AAPSMocker.mockConstraintsChecker(); virtualPumpPlugin = VirtualPumpPlugin.getPlugin(); - when(ConfigBuilderPlugin.getActivePump()).thenReturn(virtualPumpPlugin); + when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(virtualPumpPlugin); when(constraintChecker.isClosedLoopAllowed()).thenReturn(closedLoopEnabled); diff --git a/app/src/test/java/info/nightscout/androidaps/plugins/Loop/LoopPluginTest.java b/app/src/test/java/info/nightscout/androidaps/plugins/Loop/LoopPluginTest.java index 0a37ba5df5..0aa92342cf 100644 --- a/app/src/test/java/info/nightscout/androidaps/plugins/Loop/LoopPluginTest.java +++ b/app/src/test/java/info/nightscout/androidaps/plugins/Loop/LoopPluginTest.java @@ -97,7 +97,7 @@ public class LoopPluginTest { loopPlugin = LoopPlugin.getPlugin(); virtualPumpPlugin = VirtualPumpPlugin.getPlugin(); - when(ConfigBuilderPlugin.getActivePump()).thenReturn(virtualPumpPlugin); + when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(virtualPumpPlugin); } class MockedBus extends Bus { diff --git a/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.java b/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.java index fcbd4b55f2..e149d39008 100644 --- a/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.java +++ b/app/src/test/java/info/nightscout/androidaps/queue/CommandQueueTest.java @@ -17,6 +17,7 @@ import org.powermock.modules.junit4.PowerMockRunner; import java.util.Date; +import info.AAPSMocker; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.data.ConstraintChecker; @@ -115,19 +116,15 @@ public class CommandQueueTest extends CommandQueue { } private void prepareMock(Double insulin, Integer carbs) throws Exception { - ConfigBuilderPlugin configBuilderPlugin = mock(ConfigBuilderPlugin.class); ConstraintChecker constraintChecker = mock(ConstraintChecker.class); - PowerMockito.mockStatic(ConfigBuilderPlugin.class); + AAPSMocker.mockMainApp(); + AAPSMocker.mockConfigBuilder(); PumpInterface pump = MDIPlugin.getPlugin(); - when(ConfigBuilderPlugin.getActivePump()).thenReturn(pump); + when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(pump); - PowerMockito.mockStatic(MainApp.class); - MainApp mainApp = mock(MainApp.class); - when(MainApp.getConfigBuilder()).thenReturn(configBuilderPlugin); when(MainApp.getConstraintChecker()).thenReturn(constraintChecker); when(MainApp.isEngineeringModeOrRelease()).thenReturn(true); - when(MainApp.instance()).thenReturn(mainApp); Constraint bolusConstraint = new Constraint<>(0d); when(MainApp.getConstraintChecker().applyBolusConstraints(any())).thenReturn(bolusConstraint); when(MainApp.getConstraintChecker().applyExtendedBolusConstraints(any())).thenReturn(bolusConstraint); diff --git a/app/src/test/java/info/nightscout/utils/BolusWizardTest.java b/app/src/test/java/info/nightscout/utils/BolusWizardTest.java index be386e5eba..d8c1a0e497 100644 --- a/app/src/test/java/info/nightscout/utils/BolusWizardTest.java +++ b/app/src/test/java/info/nightscout/utils/BolusWizardTest.java @@ -7,6 +7,7 @@ import org.powermock.api.mockito.PowerMockito; 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.data.GlucoseStatus; import info.nightscout.androidaps.data.IobTotal; @@ -76,10 +77,10 @@ public class BolusWizardTest { PowerMockito.mockStatic(MainApp.class); when(TreatmentsPlugin.getPlugin()).thenReturn(treatment); - PowerMockito.mockStatic(ConfigBuilderPlugin.class); + AAPSMocker.mockConfigBuilder(); PumpInterface pump = MDIPlugin.getPlugin(); pump.getPumpDescription().bolusStep = PUMP_BOLUS_STEP; - when(ConfigBuilderPlugin.getActivePump()).thenReturn(pump); + when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(pump); return profile; }