remove static ConfigBuilderPlugin.activePump

This commit is contained in:
Milos Kozak 2018-09-17 17:43:42 +02:00
parent 0504619b39
commit bc19973ce0
66 changed files with 136 additions and 138 deletions

View file

@ -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);

View file

@ -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) {

View file

@ -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<TDD> 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);

View file

@ -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);

View file

@ -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);
}
});

View file

@ -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);

View file

@ -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);

View file

@ -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;

View file

@ -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);
}
/**

View file

@ -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;
}

View file

@ -52,7 +52,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
**/
@Override
public Constraint<Boolean> isLoopInvocationAllowed(Constraint<Boolean> 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);

View file

@ -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) {

View file

@ -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);

View file

@ -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;
}

View file

@ -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
);

View file

@ -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);
}

View file

@ -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(),

View file

@ -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;

View file

@ -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() {

View file

@ -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() {

View file

@ -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 {

View file

@ -303,7 +303,7 @@ public class GraphData {
}
// Extended bolus
if (!ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) {
if (!ConfigBuilderPlugin.getPlugin().getActivePump().isFakingTempsByExtendedBoluses()) {
List<ExtendedBolus> extendedBoluses = TreatmentsPlugin.getPlugin().getExtendedBolusesFromHistory().getList();
for (int tx = 0; tx < extendedBoluses.size(); tx++) {

View file

@ -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();

View file

@ -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);
}

View file

@ -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);

View file

@ -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 {

View file

@ -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());

View file

@ -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());

View file

@ -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());

View file

@ -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

View file

@ -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());

View file

@ -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()));
}
}

View file

@ -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() {

View file

@ -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 {

View file

@ -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);

View file

@ -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<TDD> dummies = new LinkedList<TDD>();
@ -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<TDD> 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() {

View file

@ -209,7 +209,7 @@ public class WatchUpdaterService extends WearableListenerService implements
}
private void cancelBolus() {
ConfigBuilderPlugin.getActivePump().stopBolusDelivering();
ConfigBuilderPlugin.getPlugin().getActivePump().stopBolusDelivering();
}
private void sendData() {

View file

@ -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);

View file

@ -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");

View file

@ -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));

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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();

View file

@ -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);

View file

@ -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);

View file

@ -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();

View file

@ -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))

View file

@ -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)

View file

@ -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();

View file

@ -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)

View file

@ -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)

View file

@ -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();

View file

@ -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)

View file

@ -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());

View file

@ -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");
}

View file

@ -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();

View file

@ -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() {

View file

@ -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<ProfileSwitch> list = new ProfileIntervals<>();
@ -89,5 +90,6 @@ public class ProfileIntervalsTest {
AAPSMocker.mockMainApp();
AAPSMocker.mockStrings();
AAPSMocker.mockBus();
AAPSMocker.mockConfigBuilder();
}
}

View file

@ -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(""));

View file

@ -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);

View file

@ -231,7 +231,7 @@ public class SafetyPluginTest {
AAPSMocker.mockBus();
when(MainApp.getConfigBuilder().getActivePump()).thenReturn(pump);
when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(pump);
safetyPlugin = SafetyPlugin.getPlugin();
}

View file

@ -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);

View file

@ -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 {

View file

@ -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<Double> bolusConstraint = new Constraint<>(0d);
when(MainApp.getConstraintChecker().applyBolusConstraints(any())).thenReturn(bolusConstraint);
when(MainApp.getConstraintChecker().applyExtendedBolusConstraints(any())).thenReturn(bolusConstraint);

View file

@ -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;
}