Remove CB.getActiveLoop(), use LoopPlugin.getPlugin().
This commit is contained in:
parent
80be7fb586
commit
d0edd89b5b
11 changed files with 107 additions and 126 deletions
|
@ -11,7 +11,6 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
|
@ -119,8 +118,8 @@ public class QuickWizardEntry {
|
||||||
if (useSuperBolus() == YES && SP.getBoolean(R.string.key_usesuperbolus, false)) {
|
if (useSuperBolus() == YES && SP.getBoolean(R.string.key_usesuperbolus, false)) {
|
||||||
superBolus = true;
|
superBolus = true;
|
||||||
}
|
}
|
||||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||||
if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuperBolus())
|
if (loopPlugin.isEnabled(loopPlugin.getType()) && loopPlugin.isSuperBolus())
|
||||||
superBolus = false;
|
superBolus = false;
|
||||||
|
|
||||||
// Trend
|
// Trend
|
||||||
|
|
|
@ -264,11 +264,6 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
return activeAPS;
|
return activeAPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static LoopPlugin getActiveLoop() {
|
|
||||||
return activeLoop;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static PumpInterface getActivePump() {
|
public static PumpInterface getActivePump() {
|
||||||
return activePump;
|
return activePump;
|
||||||
}
|
}
|
||||||
|
@ -622,7 +617,7 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void disconnectPump(int durationInMinutes, Profile profile) {
|
public void disconnectPump(int durationInMinutes, Profile profile) {
|
||||||
getActiveLoop().disconnectTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000L);
|
LoopPlugin.getPlugin().disconnectTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000L);
|
||||||
getCommandQueue().tempBasalPercent(0, durationInMinutes, true, profile, new Callback() {
|
getCommandQueue().tempBasalPercent(0, durationInMinutes, true, profile, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
@ -645,7 +640,7 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void suspendLoop(int durationInMinutes) {
|
public void suspendLoop(int durationInMinutes) {
|
||||||
getActiveLoop().suspendTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000);
|
LoopPlugin.getPlugin().suspendTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000);
|
||||||
getCommandQueue().cancelTempBasal(true, new Callback() {
|
getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
|
|
@ -9,6 +9,7 @@ import android.app.TaskStackBuilder;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.app.NotificationCompat;
|
import android.support.v4.app.NotificationCompat;
|
||||||
|
|
||||||
import com.crashlytics.android.answers.CustomEvent;
|
import com.crashlytics.android.answers.CustomEvent;
|
||||||
|
@ -56,6 +57,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
|
|
||||||
protected static LoopPlugin loopPlugin;
|
protected static LoopPlugin loopPlugin;
|
||||||
|
|
||||||
|
@NonNull
|
||||||
public static LoopPlugin getPlugin() {
|
public static LoopPlugin getPlugin() {
|
||||||
if (loopPlugin == null) {
|
if (loopPlugin == null) {
|
||||||
loopPlugin = new LoopPlugin();
|
loopPlugin = new LoopPlugin();
|
||||||
|
|
|
@ -53,6 +53,7 @@ import info.nightscout.androidaps.events.EventFeatureRunning;
|
||||||
import info.nightscout.androidaps.events.EventNewBG;
|
import info.nightscout.androidaps.events.EventNewBG;
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||||
|
@ -334,9 +335,9 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
accepted = true;
|
accepted = true;
|
||||||
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
|
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
|
||||||
if (useSuperBolus) {
|
if (useSuperBolus) {
|
||||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||||
if (activeloop != null) {
|
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||||
activeloop.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
|
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
|
||||||
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
|
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
|
||||||
}
|
}
|
||||||
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 120, true, profile, new Callback() {
|
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 120, true, profile, new Callback() {
|
||||||
|
|
|
@ -457,16 +457,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
|
||||||
super.onCreateContextMenu(menu, v, menuInfo);
|
super.onCreateContextMenu(menu, v, menuInfo);
|
||||||
if (v == apsModeView) {
|
if (v == apsModeView) {
|
||||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||||
final PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
|
final PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
|
||||||
if (!MainApp.getConfigBuilder().isProfileValid("ContexMenuCreation"))
|
if (loopPlugin == null || !MainApp.getConfigBuilder().isProfileValid("ContexMenuCreation"))
|
||||||
return;
|
return;
|
||||||
menu.setHeaderTitle(MainApp.gs(R.string.loop));
|
menu.setHeaderTitle(MainApp.gs(R.string.loop));
|
||||||
if (activeloop == null) {
|
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||||
menu.add(MainApp.gs(R.string.enableloop));
|
|
||||||
} else {
|
|
||||||
menu.add(MainApp.gs(R.string.disableloop));
|
menu.add(MainApp.gs(R.string.disableloop));
|
||||||
if (!activeloop.isSuspended()) {
|
if (!loopPlugin.isSuspended()) {
|
||||||
menu.add(MainApp.gs(R.string.suspendloopfor1h));
|
menu.add(MainApp.gs(R.string.suspendloopfor1h));
|
||||||
menu.add(MainApp.gs(R.string.suspendloopfor2h));
|
menu.add(MainApp.gs(R.string.suspendloopfor2h));
|
||||||
menu.add(MainApp.gs(R.string.suspendloopfor3h));
|
menu.add(MainApp.gs(R.string.suspendloopfor3h));
|
||||||
|
@ -482,6 +480,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
menu.add(MainApp.gs(R.string.resume));
|
menu.add(MainApp.gs(R.string.resume));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!loopPlugin.isEnabled(PluginType.LOOP))
|
||||||
|
menu.add(MainApp.gs(R.string.enableloop));
|
||||||
} else if (v == activeProfileView) {
|
} else if (v == activeProfileView) {
|
||||||
menu.setHeaderTitle(MainApp.gs(R.string.profile));
|
menu.setHeaderTitle(MainApp.gs(R.string.profile));
|
||||||
menu.add(MainApp.gs(R.string.danar_viewprofile));
|
menu.add(MainApp.gs(R.string.danar_viewprofile));
|
||||||
|
@ -496,10 +496,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return true;
|
return true;
|
||||||
|
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||||
if (item.getTitle().equals(MainApp.gs(R.string.disableloop))) {
|
if (item.getTitle().equals(MainApp.gs(R.string.disableloop))) {
|
||||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
loopPlugin.setPluginEnabled(PluginType.LOOP, false);
|
||||||
activeloop.setPluginEnabled(PluginType.LOOP, false);
|
loopPlugin.setFragmentVisible(PluginType.LOOP, false);
|
||||||
activeloop.setFragmentVisible(PluginType.LOOP, false);
|
|
||||||
MainApp.getConfigBuilder().storeSettings("DisablingLoop");
|
MainApp.getConfigBuilder().storeSettings("DisablingLoop");
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||||
|
@ -513,7 +513,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
NSUpload.uploadOpenAPSOffline(24 * 60); // upload 24h, we don't know real duration
|
NSUpload.uploadOpenAPSOffline(24 * 60); // upload 24h, we don't know real duration
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.gs(R.string.enableloop))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.enableloop))) {
|
||||||
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
|
||||||
loopPlugin.setPluginEnabled(PluginType.LOOP, true);
|
loopPlugin.setPluginEnabled(PluginType.LOOP, true);
|
||||||
loopPlugin.setFragmentVisible(PluginType.LOOP, true);
|
loopPlugin.setFragmentVisible(PluginType.LOOP, true);
|
||||||
MainApp.getConfigBuilder().storeSettings("EnablingLoop");
|
MainApp.getConfigBuilder().storeSettings("EnablingLoop");
|
||||||
|
@ -521,8 +520,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
NSUpload.uploadOpenAPSOffline(0);
|
NSUpload.uploadOpenAPSOffline(0);
|
||||||
return true;
|
return true;
|
||||||
} else if (item.getTitle().equals(MainApp.gs(R.string.resume))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.resume))) {
|
||||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
loopPlugin.suspendTo(0L);
|
||||||
activeloop.suspendTo(0L);
|
|
||||||
updateGUI("suspendmenu");
|
updateGUI("suspendmenu");
|
||||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -675,36 +673,34 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
private void onClickAcceptTemp() {
|
private void onClickAcceptTemp() {
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
|
|
||||||
if (ConfigBuilderPlugin.getActiveLoop() != null && profile != null) {
|
if (LoopPlugin.getPlugin().isEnabled(PluginType.LOOP) && profile != null) {
|
||||||
ConfigBuilderPlugin.getActiveLoop().invoke("Accept temp button", false);
|
LoopPlugin.getPlugin().invoke("Accept temp button", false);
|
||||||
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
|
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
|
||||||
if (finalLastRun != null && finalLastRun.lastAPSRun != null && finalLastRun.constraintsProcessed.isChangeRequested()) {
|
if (finalLastRun != null && finalLastRun.lastAPSRun != null && finalLastRun.constraintsProcessed.isChangeRequested()) {
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||||
builder.setTitle(getContext().getString(R.string.confirmation));
|
builder.setTitle(getContext().getString(R.string.confirmation));
|
||||||
builder.setMessage(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
|
builder.setMessage(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
|
||||||
builder.setPositiveButton(getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(getContext().getString(R.string.ok), (dialog, id) -> {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
hideTempRecommendation();
|
||||||
hideTempRecommendation();
|
clearNotification();
|
||||||
clearNotification();
|
MainApp.getConfigBuilder().applyTBRRequest(finalLastRun.constraintsProcessed, profile, new Callback() {
|
||||||
MainApp.getConfigBuilder().applyTBRRequest(finalLastRun.constraintsProcessed, profile, new Callback() {
|
@Override
|
||||||
@Override
|
public void run() {
|
||||||
public void run() {
|
if (result.enacted) {
|
||||||
if (result.enacted) {
|
finalLastRun.tbrSetByPump = result;
|
||||||
finalLastRun.tbrSetByPump = result;
|
finalLastRun.lastEnact = new Date();
|
||||||
finalLastRun.lastEnact = new Date();
|
finalLastRun.lastOpenModeAccept = new Date();
|
||||||
finalLastRun.lastOpenModeAccept = new Date();
|
NSUpload.uploadDeviceStatus();
|
||||||
NSUpload.uploadDeviceStatus();
|
ObjectivesPlugin objectivesPlugin = MainApp.getSpecificPlugin(ObjectivesPlugin.class);
|
||||||
ObjectivesPlugin objectivesPlugin = MainApp.getSpecificPlugin(ObjectivesPlugin.class);
|
if (objectivesPlugin != null) {
|
||||||
if (objectivesPlugin != null) {
|
ObjectivesPlugin.manualEnacts++;
|
||||||
ObjectivesPlugin.manualEnacts++;
|
ObjectivesPlugin.saveProgress();
|
||||||
ObjectivesPlugin.saveProgress();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
scheduleUpdateGUI("onClickAcceptTemp");
|
|
||||||
}
|
}
|
||||||
});
|
scheduleUpdateGUI("onClickAcceptTemp");
|
||||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("AcceptTemp"));
|
}
|
||||||
}
|
});
|
||||||
|
FabricPrivacy.getInstance().logCustom(new CustomEvent("AcceptTemp"));
|
||||||
});
|
});
|
||||||
builder.setNegativeButton(getContext().getString(R.string.cancel), null);
|
builder.setNegativeButton(getContext().getString(R.string.cancel), null);
|
||||||
builder.show();
|
builder.show();
|
||||||
|
@ -770,57 +766,55 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
accepted = false;
|
accepted = false;
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
builder.setTitle(MainApp.gs(R.string.confirmation));
|
||||||
builder.setMessage(confirmMessage);
|
builder.setMessage(confirmMessage);
|
||||||
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(getString(R.string.ok), (dialog, id) -> {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
synchronized (builder) {
|
||||||
synchronized (builder) {
|
if (accepted) {
|
||||||
if (accepted) {
|
log.debug("guarding: already accepted");
|
||||||
log.debug("guarding: already accepted");
|
return;
|
||||||
return;
|
}
|
||||||
}
|
accepted = true;
|
||||||
accepted = true;
|
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
|
||||||
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
|
if (wizard.superBolus) {
|
||||||
if (wizard.superBolus) {
|
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||||
if (activeloop != null) {
|
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
|
||||||
activeloop.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
|
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
|
||||||
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
|
|
||||||
}
|
|
||||||
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 120, true, profile, new Callback() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (!result.success) {
|
|
||||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
|
||||||
i.putExtra("soundid", R.raw.boluserror);
|
|
||||||
i.putExtra("status", result.comment);
|
|
||||||
i.putExtra("title", MainApp.gs(R.string.tempbasaldeliveryerror));
|
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
MainApp.instance().startActivity(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(0, 120, true, profile, new Callback() {
|
||||||
detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD;
|
|
||||||
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
|
||||||
detailedBolusInfo.carbs = finalCarbsAfterConstraints;
|
|
||||||
detailedBolusInfo.context = context;
|
|
||||||
detailedBolusInfo.boluscalc = boluscalcJSON;
|
|
||||||
detailedBolusInfo.source = Source.USER;
|
|
||||||
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||||
i.putExtra("soundid", R.raw.boluserror);
|
i.putExtra("soundid", R.raw.boluserror);
|
||||||
i.putExtra("status", result.comment);
|
i.putExtra("status", result.comment);
|
||||||
i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror));
|
i.putExtra("title", MainApp.gs(R.string.tempbasaldeliveryerror));
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
MainApp.instance().startActivity(i);
|
MainApp.instance().startActivity(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("QuickWizard"));
|
|
||||||
}
|
}
|
||||||
|
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||||
|
detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD;
|
||||||
|
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
||||||
|
detailedBolusInfo.carbs = finalCarbsAfterConstraints;
|
||||||
|
detailedBolusInfo.context = context;
|
||||||
|
detailedBolusInfo.boluscalc = boluscalcJSON;
|
||||||
|
detailedBolusInfo.source = Source.USER;
|
||||||
|
ConfigBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!result.success) {
|
||||||
|
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||||
|
i.putExtra("soundid", R.raw.boluserror);
|
||||||
|
i.putExtra("status", result.comment);
|
||||||
|
i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror));
|
||||||
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||||
|
MainApp.instance().startActivity(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
FabricPrivacy.getInstance().logCustom(new CustomEvent("QuickWizard"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1026,24 +1020,24 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
apsModeView.setVisibility(View.VISIBLE);
|
apsModeView.setVisibility(View.VISIBLE);
|
||||||
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.loopenabled));
|
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.loopenabled));
|
||||||
apsModeView.setTextColor(Color.BLACK);
|
apsModeView.setTextColor(Color.BLACK);
|
||||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||||
if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuperBolus()) {
|
if (loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isSuperBolus()) {
|
||||||
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
||||||
apsModeView.setText(String.format(MainApp.gs(R.string.loopsuperbolusfor), activeloop.minutesToEndOfSuspend()));
|
apsModeView.setText(String.format(MainApp.gs(R.string.loopsuperbolusfor), loopPlugin.minutesToEndOfSuspend()));
|
||||||
apsModeView.setTextColor(Color.WHITE);
|
apsModeView.setTextColor(Color.WHITE);
|
||||||
} else if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isDisconnected()) {
|
} else if (loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isDisconnected()) {
|
||||||
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
||||||
apsModeView.setText(String.format(MainApp.gs(R.string.loopdisconnectedfor), activeloop.minutesToEndOfSuspend()));
|
apsModeView.setText(String.format(MainApp.gs(R.string.loopdisconnectedfor), loopPlugin.minutesToEndOfSuspend()));
|
||||||
apsModeView.setTextColor(Color.WHITE);
|
apsModeView.setTextColor(Color.WHITE);
|
||||||
} else if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuspended()) {
|
} else if (loopPlugin.isEnabled(PluginType.LOOP) && loopPlugin.isSuspended()) {
|
||||||
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
||||||
apsModeView.setText(String.format(MainApp.gs(R.string.loopsuspendedfor), activeloop.minutesToEndOfSuspend()));
|
apsModeView.setText(String.format(MainApp.gs(R.string.loopsuspendedfor), loopPlugin.minutesToEndOfSuspend()));
|
||||||
apsModeView.setTextColor(Color.WHITE);
|
apsModeView.setTextColor(Color.WHITE);
|
||||||
} else if (pump.isSuspended()) {
|
} else if (pump.isSuspended()) {
|
||||||
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
|
||||||
apsModeView.setText(MainApp.gs(R.string.pumpsuspended));
|
apsModeView.setText(MainApp.gs(R.string.pumpsuspended));
|
||||||
apsModeView.setTextColor(Color.WHITE);
|
apsModeView.setTextColor(Color.WHITE);
|
||||||
} else if (activeloop != null && activeloop.isEnabled(activeloop.getType())) {
|
} else if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||||
if (closedLoopEnabled.value()) {
|
if (closedLoopEnabled.value()) {
|
||||||
apsModeView.setText(MainApp.gs(R.string.closedloop));
|
apsModeView.setText(MainApp.gs(R.string.closedloop));
|
||||||
} else {
|
} else {
|
||||||
|
@ -1079,7 +1073,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
showAcceptButton = showAcceptButton && (finalLastRun.lastOpenModeAccept == null || finalLastRun.lastOpenModeAccept.getTime() < finalLastRun.lastAPSRun.getTime()); // never accepted or before last result
|
showAcceptButton = showAcceptButton && (finalLastRun.lastOpenModeAccept == null || finalLastRun.lastOpenModeAccept.getTime() < finalLastRun.lastAPSRun.getTime()); // never accepted or before last result
|
||||||
showAcceptButton = showAcceptButton && finalLastRun.constraintsProcessed.isChangeRequested(); // change is requested
|
showAcceptButton = showAcceptButton && finalLastRun.constraintsProcessed.isChangeRequested(); // change is requested
|
||||||
|
|
||||||
if (showAcceptButton && pump.isInitialized() && !pump.isSuspended() && ConfigBuilderPlugin.getActiveLoop() != null) {
|
if (showAcceptButton && pump.isInitialized() && !pump.isSuspended() && LoopPlugin.getPlugin().isEnabled(PluginType.LOOP)) {
|
||||||
acceptTempLayout.setVisibility(View.VISIBLE);
|
acceptTempLayout.setVisibility(View.VISIBLE);
|
||||||
acceptTempButton.setText(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
|
acceptTempButton.setText(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -279,8 +279,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
||||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Loop_Status"));
|
FabricPrivacy.getInstance().logCustom(new CustomEvent("SMS_Loop_Status"));
|
||||||
break;
|
break;
|
||||||
case "RESUME":
|
case "RESUME":
|
||||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
LoopPlugin.getPlugin().suspendTo(0);
|
||||||
activeloop.suspendTo(0);
|
|
||||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_RESUME"));
|
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_RESUME"));
|
||||||
NSUpload.uploadOpenAPSOffline(0);
|
NSUpload.uploadOpenAPSOffline(0);
|
||||||
reply = MainApp.sResources.getString(R.string.smscommunicator_loopresumed);
|
reply = MainApp.sResources.getString(R.string.smscommunicator_loopresumed);
|
||||||
|
@ -517,8 +516,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
LoopPlugin.getPlugin().suspendTo(System.currentTimeMillis() + suspendWaitingForConfirmation.duration * 60L * 1000);
|
||||||
activeloop.suspendTo(System.currentTimeMillis() + suspendWaitingForConfirmation.duration * 60L * 1000);
|
|
||||||
NSUpload.uploadOpenAPSOffline(suspendWaitingForConfirmation.duration * 60);
|
NSUpload.uploadOpenAPSOffline(suspendWaitingForConfirmation.duration * 60);
|
||||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_SUSPENDED"));
|
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_SUSPENDED"));
|
||||||
String reply = MainApp.sResources.getString(R.string.smscommunicator_loopsuspended) + " " +
|
String reply = MainApp.sResources.getString(R.string.smscommunicator_loopsuspended) + " " +
|
||||||
|
|
|
@ -441,21 +441,21 @@ public class ActionStringHandler {
|
||||||
private static String getLoopStatus() {
|
private static String getLoopStatus() {
|
||||||
String ret = "";
|
String ret = "";
|
||||||
// decide if enabled/disabled closed/open; what Plugin as APS?
|
// decide if enabled/disabled closed/open; what Plugin as APS?
|
||||||
final LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
|
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||||
if (activeloop != null && activeloop.isEnabled(activeloop.getType())) {
|
if (loopPlugin.isEnabled(loopPlugin.getType())) {
|
||||||
if (MainApp.getConstraintChecker().isClosedLoopAllowed().value()) {
|
if (MainApp.getConstraintChecker().isClosedLoopAllowed().value()) {
|
||||||
ret += "CLOSED LOOP\n";
|
ret += "CLOSED LOOP\n";
|
||||||
} else {
|
} else {
|
||||||
ret += "OPEN LOOP\n";
|
ret += "OPEN LOOP\n";
|
||||||
}
|
}
|
||||||
final APSInterface aps = MainApp.getConfigBuilder().getActiveAPS();
|
final APSInterface aps = ConfigBuilderPlugin.getActiveAPS();
|
||||||
ret += "APS: " + ((aps == null) ? "NO APS SELECTED!" : ((PluginBase) aps).getName());
|
ret += "APS: " + ((aps == null) ? "NO APS SELECTED!" : ((PluginBase) aps).getName());
|
||||||
if (activeloop.lastRun != null) {
|
if (LoopPlugin.lastRun != null) {
|
||||||
if (activeloop.lastRun.lastAPSRun != null)
|
if (LoopPlugin.lastRun.lastAPSRun != null)
|
||||||
ret += "\nLast Run: " + DateUtil.timeString(activeloop.lastRun.lastAPSRun);
|
ret += "\nLast Run: " + DateUtil.timeString(LoopPlugin.lastRun.lastAPSRun);
|
||||||
|
|
||||||
if (activeloop.lastRun.lastEnact != null)
|
if (LoopPlugin.lastRun.lastEnact != null)
|
||||||
ret += "\nLast Enact: " + DateUtil.timeString(activeloop.lastRun.lastEnact);
|
ret += "\nLast Enact: " + DateUtil.timeString(LoopPlugin.lastRun.lastEnact);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,7 +502,7 @@ public class ActionStringHandler {
|
||||||
return "No profile set :(";
|
return "No profile set :(";
|
||||||
}
|
}
|
||||||
|
|
||||||
APSInterface usedAPS = MainApp.getConfigBuilder().getActiveAPS();
|
APSInterface usedAPS = ConfigBuilderPlugin.getActiveAPS();
|
||||||
if (usedAPS == null) {
|
if (usedAPS == null) {
|
||||||
return "No active APS :(!";
|
return "No active APS :(!";
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,11 +140,7 @@ public class WearPlugin extends PluginBase {
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventRefreshOverview ev) {
|
public void onStatusEvent(final EventRefreshOverview ev) {
|
||||||
|
if (WatchUpdaterService.shouldReportLoopStatus(LoopPlugin.getPlugin().isEnabled(PluginType.LOOP))) {
|
||||||
LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
|
|
||||||
if (activeloop == null) return;
|
|
||||||
|
|
||||||
if (WatchUpdaterService.shouldReportLoopStatus(activeloop.isEnabled(PluginType.LOOP))) {
|
|
||||||
sendDataToWatch(true, false, false);
|
sendDataToWatch(true, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -666,12 +666,12 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoopPlugin activeloop = MainApp.getConfigBuilder().getActiveLoop();
|
LoopPlugin activeloop = LoopPlugin.getPlugin();
|
||||||
|
|
||||||
if (activeloop != null && !activeloop.isEnabled(PluginType.LOOP)) {
|
if (!activeloop.isEnabled(PluginType.LOOP)) {
|
||||||
status += getString(R.string.disabledloop) + "\n";
|
status += getString(R.string.disabledloop) + "\n";
|
||||||
lastLoopStatus = false;
|
lastLoopStatus = false;
|
||||||
} else if (activeloop != null && activeloop.isEnabled(PluginType.LOOP)) {
|
} else {
|
||||||
lastLoopStatus = true;
|
lastLoopStatus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -108,12 +108,12 @@ public class StatuslinePlugin extends PluginBase {
|
||||||
@NonNull
|
@NonNull
|
||||||
private String buildStatusString(Profile profile) {
|
private String buildStatusString(Profile profile) {
|
||||||
String status = "";
|
String status = "";
|
||||||
LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
||||||
|
|
||||||
if (activeloop != null && !activeloop.isEnabled(PluginType.LOOP)) {
|
if (!loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||||
status += ctx.getString(R.string.disabledloop) + "\n";
|
status += ctx.getString(R.string.disabledloop) + "\n";
|
||||||
lastLoopStatus = false;
|
lastLoopStatus = false;
|
||||||
} else if (activeloop != null && activeloop.isEnabled(PluginType.LOOP)) {
|
} else if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||||
lastLoopStatus = true;
|
lastLoopStatus = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,13 +179,8 @@ public class StatuslinePlugin extends PluginBase {
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventRefreshOverview ev) {
|
public void onStatusEvent(final EventRefreshOverview ev) {
|
||||||
|
|
||||||
//Filter events where loop is (de)activated
|
//Filter events where loop is (de)activated
|
||||||
|
if ((lastLoopStatus != LoopPlugin.getPlugin().isEnabled(PluginType.LOOP))) {
|
||||||
LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
|
||||||
if (activeloop == null) return;
|
|
||||||
|
|
||||||
if ((lastLoopStatus != activeloop.isEnabled(PluginType.LOOP))) {
|
|
||||||
sendStatus();
|
sendStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
import info.nightscout.androidaps.receivers.KeepAliveReceiver;
|
||||||
|
@ -38,7 +39,7 @@ public class LocalAlertUtils {
|
||||||
boolean nextAlarmOccurrenceReached = SP.getLong("nextPumpDisconnectedAlarm", 0L) < System.currentTimeMillis();
|
boolean nextAlarmOccurrenceReached = SP.getLong("nextPumpDisconnectedAlarm", 0L) < System.currentTimeMillis();
|
||||||
|
|
||||||
if (Config.APS && SP.getBoolean(MainApp.sResources.getString(R.string.key_enable_pump_unreachable_alert), true)
|
if (Config.APS && SP.getBoolean(MainApp.sResources.getString(R.string.key_enable_pump_unreachable_alert), true)
|
||||||
&& isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached && !ConfigBuilderPlugin.getActiveLoop().isDisconnected()) {
|
&& isStatusOutdated && alarmTimeoutExpired && nextAlarmOccurrenceReached && !LoopPlugin.getPlugin().isDisconnected()) {
|
||||||
log.debug("Generating pump unreachable alarm. lastConnection: " + DateUtil.dateAndTimeString(lastConnection) + " isStatusOutdated: " + isStatusOutdated);
|
log.debug("Generating pump unreachable alarm. lastConnection: " + DateUtil.dateAndTimeString(lastConnection) + " isStatusOutdated: " + isStatusOutdated);
|
||||||
Notification n = new Notification(Notification.PUMP_UNREACHABLE, MainApp.sResources.getString(R.string.pump_unreachable), Notification.URGENT);
|
Notification n = new Notification(Notification.PUMP_UNREACHABLE, MainApp.sResources.getString(R.string.pump_unreachable), Notification.URGENT);
|
||||||
n.soundId = R.raw.alarm;
|
n.soundId = R.raw.alarm;
|
||||||
|
|
Loading…
Reference in a new issue