Merge pull request #2340 from MilosKozak/dagger3_0601a
pluginDescription as constructor declaration only
This commit is contained in:
commit
3a77fb70fe
65 changed files with 540 additions and 422 deletions
|
@ -202,7 +202,7 @@ public class MainActivity extends NoSplashAppCompatActivity {
|
||||||
menu.clear();
|
menu.clear();
|
||||||
for (PluginBase p : MainApp.getPluginsList()) {
|
for (PluginBase p : MainApp.getPluginsList()) {
|
||||||
pageAdapter.registerNewFragment(p);
|
pageAdapter.registerNewFragment(p);
|
||||||
if (p.hasFragment() && !p.isFragmentVisible() && p.isEnabled(p.pluginDescription.getType()) && !p.pluginDescription.neverVisible) {
|
if (p.hasFragment() && !p.isFragmentVisible() && p.isEnabled(p.getPluginDescription().getType()) && !p.getPluginDescription().neverVisible) {
|
||||||
MenuItem menuItem = menu.add(p.getName());
|
MenuItem menuItem = menu.add(p.getName());
|
||||||
menuItem.setCheckable(true);
|
menuItem.setCheckable(true);
|
||||||
menuItem.setOnMenuItemClickListener(item -> {
|
menuItem.setOnMenuItemClickListener(item -> {
|
||||||
|
|
|
@ -128,9 +128,9 @@ public class MainApp extends DaggerApplication {
|
||||||
public static boolean devBranch;
|
public static boolean devBranch;
|
||||||
public static boolean engineeringMode;
|
public static boolean engineeringMode;
|
||||||
|
|
||||||
private String CHANNEL_ID = "AndroidAPS-Ongoing";
|
private String CHANNEL_ID = "AndroidAPS-Ongoing"; // TODO: move to OngoingNotificationProvider (and dagger)
|
||||||
private int ONGOING_NOTIFICATION_ID = 4711;
|
private int ONGOING_NOTIFICATION_ID = 4711; // TODO: move to OngoingNotificationProvider (and dagger)
|
||||||
private Notification notification;
|
private Notification notification; // TODO: move to OngoingNotificationProvider (and dagger)
|
||||||
|
|
||||||
@Inject AAPSLogger aapsLogger;
|
@Inject AAPSLogger aapsLogger;
|
||||||
@Inject ActivityMonitor activityMonitor;
|
@Inject ActivityMonitor activityMonitor;
|
||||||
|
|
|
@ -8,9 +8,11 @@ import info.nightscout.androidaps.MainApp
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.events.EventConfigBuilderChange
|
import info.nightscout.androidaps.events.EventConfigBuilderChange
|
||||||
import info.nightscout.androidaps.events.EventRebuildTabs
|
import info.nightscout.androidaps.events.EventRebuildTabs
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.L
|
import info.nightscout.androidaps.logging.L
|
||||||
import info.nightscout.androidaps.logging.L.isEnabled
|
import info.nightscout.androidaps.logging.L.isEnabled
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.EventConfigBuilderUpdateGui
|
import info.nightscout.androidaps.plugins.configBuilder.EventConfigBuilderUpdateGui
|
||||||
import info.nightscout.androidaps.utils.OKDialog.showConfirmation
|
import info.nightscout.androidaps.utils.OKDialog.showConfirmation
|
||||||
|
@ -20,7 +22,8 @@ import org.slf4j.LoggerFactory
|
||||||
/**
|
/**
|
||||||
* Created by mike on 09.06.2016.
|
* Created by mike on 09.06.2016.
|
||||||
*/
|
*/
|
||||||
abstract class PluginBase(pluginDesc: PluginDescription) {
|
abstract class PluginBase(val pluginDescription: PluginDescription, val rxBus: RxBusWrapper, val aapsLogger: AAPSLogger ) {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private val log = LoggerFactory.getLogger(L.CORE)
|
private val log = LoggerFactory.getLogger(L.CORE)
|
||||||
}
|
}
|
||||||
|
@ -29,17 +32,11 @@ abstract class PluginBase(pluginDesc: PluginDescription) {
|
||||||
NOT_INITIALIZED, ENABLED, DISABLED
|
NOT_INITIALIZED, ENABLED, DISABLED
|
||||||
}
|
}
|
||||||
|
|
||||||
lateinit var pluginDescription: PluginDescription // TODO: workaround to have pluginDescription accessible in child classes
|
|
||||||
|
|
||||||
private var state = State.NOT_INITIALIZED
|
private var state = State.NOT_INITIALIZED
|
||||||
private var fragmentVisible = false
|
private var fragmentVisible = false
|
||||||
// Specific plugin with more Interfaces
|
// Specific plugin with more Interfaces
|
||||||
protected var isProfileInterfaceEnabled = false
|
protected var isProfileInterfaceEnabled = false
|
||||||
|
|
||||||
init {
|
|
||||||
pluginDescription = pluginDesc
|
|
||||||
}
|
|
||||||
|
|
||||||
// Default always calls invoke
|
// Default always calls invoke
|
||||||
// Plugins that have special constraints if they get switched to may override this method
|
// Plugins that have special constraints if they get switched to may override this method
|
||||||
open fun switchAllowed(newState: Boolean, activity: FragmentActivity?, type: PluginType) {
|
open fun switchAllowed(newState: Boolean, activity: FragmentActivity?, type: PluginType) {
|
||||||
|
|
|
@ -68,8 +68,6 @@ import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class LoopPlugin extends PluginBase {
|
public class LoopPlugin extends PluginBase {
|
||||||
private final AAPSLogger aapsLogger;
|
|
||||||
private final RxBusWrapper rxBus;
|
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
private final ConstraintChecker constraintChecker;
|
private final ConstraintChecker constraintChecker;
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
|
@ -106,7 +104,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
@Inject
|
@Inject
|
||||||
public LoopPlugin(
|
public LoopPlugin(
|
||||||
AAPSLogger aapsLogger,
|
AAPSLogger aapsLogger,
|
||||||
RxBusWrapper rxBus,
|
RxBusWrapper rxBusWrapper,
|
||||||
SP sp,
|
SP sp,
|
||||||
ConstraintChecker constraintChecker,
|
ConstraintChecker constraintChecker,
|
||||||
ResourceHelper resourceHelper,
|
ResourceHelper resourceHelper,
|
||||||
|
@ -123,10 +121,9 @@ public class LoopPlugin extends PluginBase {
|
||||||
.pluginName(R.string.loop)
|
.pluginName(R.string.loop)
|
||||||
.shortName(R.string.loop_shortname)
|
.shortName(R.string.loop_shortname)
|
||||||
.preferencesId(R.xml.pref_loop)
|
.preferencesId(R.xml.pref_loop)
|
||||||
.description(R.string.description_loop)
|
.description(R.string.description_loop),
|
||||||
|
rxBusWrapper, aapsLogger
|
||||||
);
|
);
|
||||||
this.aapsLogger = aapsLogger;
|
|
||||||
this.rxBus = rxBus;
|
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
this.constraintChecker = constraintChecker;
|
this.constraintChecker = constraintChecker;
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
|
@ -146,7 +143,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
createNotificationChannel();
|
createNotificationChannel();
|
||||||
super.onStart();
|
super.onStart();
|
||||||
disposable.add(rxBus
|
disposable.add(getRxBus()
|
||||||
.toObservable(EventTempTargetChange.class)
|
.toObservable(EventTempTargetChange.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> invoke("EventTempTargetChange", true), exception -> FabricPrivacy.getInstance().logException(exception))
|
.subscribe(event -> invoke("EventTempTargetChange", true), exception -> FabricPrivacy.getInstance().logException(exception))
|
||||||
|
@ -158,7 +155,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
* the event causing the calculation is not EventNewBg.
|
* the event causing the calculation is not EventNewBg.
|
||||||
* <p>
|
* <p>
|
||||||
*/
|
*/
|
||||||
disposable.add(rxBus
|
disposable.add(getRxBus()
|
||||||
.toObservable(EventAutosensCalculationFinished.class)
|
.toObservable(EventAutosensCalculationFinished.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
|
@ -294,13 +291,13 @@ public class LoopPlugin extends PluginBase {
|
||||||
|
|
||||||
public synchronized void invoke(String initiator, boolean allowNotification, boolean tempBasalFallback) {
|
public synchronized void invoke(String initiator, boolean allowNotification, boolean tempBasalFallback) {
|
||||||
try {
|
try {
|
||||||
aapsLogger.debug(LTag.APS, "invoke from " + initiator);
|
getAapsLogger().debug(LTag.APS, "invoke from " + initiator);
|
||||||
Constraint<Boolean> loopEnabled = constraintChecker.isLoopInvocationAllowed();
|
Constraint<Boolean> loopEnabled = constraintChecker.isLoopInvocationAllowed();
|
||||||
|
|
||||||
if (!loopEnabled.value()) {
|
if (!loopEnabled.value()) {
|
||||||
String message = resourceHelper.gs(R.string.loopdisabled) + "\n" + loopEnabled.getReasons();
|
String message = resourceHelper.gs(R.string.loopdisabled) + "\n" + loopEnabled.getReasons();
|
||||||
aapsLogger.debug(LTag.APS, message);
|
getAapsLogger().debug(LTag.APS, message);
|
||||||
rxBus.send(new EventLoopSetLastRunGui(message));
|
getRxBus().send(new EventLoopSetLastRunGui(message));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final PumpInterface pump = configBuilderPlugin.getActivePump();
|
final PumpInterface pump = configBuilderPlugin.getActivePump();
|
||||||
|
@ -315,8 +312,8 @@ public class LoopPlugin extends PluginBase {
|
||||||
|
|
||||||
if (profile == null || !profileFunction.isProfileValid("Loop")) {
|
if (profile == null || !profileFunction.isProfileValid("Loop")) {
|
||||||
if (L.isEnabled(L.APS))
|
if (L.isEnabled(L.APS))
|
||||||
aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected));
|
||||||
rxBus.send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.noprofileselected)));
|
getRxBus().send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.noprofileselected)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +328,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
|
|
||||||
// Check if we have any result
|
// Check if we have any result
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
rxBus.send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.noapsselected)));
|
getRxBus().send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.noapsselected)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -355,7 +352,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
// safety check for multiple SMBs
|
// safety check for multiple SMBs
|
||||||
long lastBolusTime = treatmentsPlugin.getLastBolusTime();
|
long lastBolusTime = treatmentsPlugin.getLastBolusTime();
|
||||||
if (lastBolusTime != 0 && lastBolusTime + T.mins(3).msecs() > System.currentTimeMillis()) {
|
if (lastBolusTime != 0 && lastBolusTime + T.mins(3).msecs() > System.currentTimeMillis()) {
|
||||||
aapsLogger.debug(LTag.APS, "SMB requsted but still in 3 min interval");
|
getAapsLogger().debug(LTag.APS, "SMB requsted but still in 3 min interval");
|
||||||
resultAfterConstraints.smb = 0;
|
resultAfterConstraints.smb = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,14 +367,14 @@ public class LoopPlugin extends PluginBase {
|
||||||
NSUpload.uploadDeviceStatus(this);
|
NSUpload.uploadDeviceStatus(this);
|
||||||
|
|
||||||
if (isSuspended()) {
|
if (isSuspended()) {
|
||||||
aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.loopsuspended));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.loopsuspended));
|
||||||
rxBus.send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.loopsuspended)));
|
getRxBus().send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.loopsuspended)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pump.isSuspended()) {
|
if (pump.isSuspended()) {
|
||||||
aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.pumpsuspended));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.pumpsuspended));
|
||||||
rxBus.send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.pumpsuspended)));
|
getRxBus().send(new EventLoopSetLastRunGui(resourceHelper.gs(R.string.pumpsuspended)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -393,7 +390,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
lastRun.tbrSetByPump = waiting;
|
lastRun.tbrSetByPump = waiting;
|
||||||
if (resultAfterConstraints.bolusRequested)
|
if (resultAfterConstraints.bolusRequested)
|
||||||
lastRun.smbSetByPump = waiting;
|
lastRun.smbSetByPump = waiting;
|
||||||
rxBus.send(new EventLoopUpdateGui());
|
getRxBus().send(new EventLoopUpdateGui());
|
||||||
FabricPrivacy.getInstance().logCustom("APSRequest");
|
FabricPrivacy.getInstance().logCustom("APSRequest");
|
||||||
applyTBRRequest(resultAfterConstraints, profile, new Callback() {
|
applyTBRRequest(resultAfterConstraints, profile, new Callback() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -414,11 +411,11 @@ public class LoopPlugin extends PluginBase {
|
||||||
invoke("tempBasalFallback", allowNotification, true);
|
invoke("tempBasalFallback", allowNotification, true);
|
||||||
}).start();
|
}).start();
|
||||||
}
|
}
|
||||||
rxBus.send(new EventLoopUpdateGui());
|
getRxBus().send(new EventLoopUpdateGui());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
rxBus.send(new EventLoopUpdateGui());
|
getRxBus().send(new EventLoopUpdateGui());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
@ -459,7 +456,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
(NotificationManager) mainApp.getSystemService(Context.NOTIFICATION_SERVICE);
|
(NotificationManager) mainApp.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||||
// mId allows you to update the notification later on.
|
// mId allows you to update the notification later on.
|
||||||
mNotificationManager.notify(Constants.notificationID, builder.build());
|
mNotificationManager.notify(Constants.notificationID, builder.build());
|
||||||
rxBus.send(new EventNewOpenLoopNotification());
|
getRxBus().send(new EventNewOpenLoopNotification());
|
||||||
|
|
||||||
// Send to Wear
|
// Send to Wear
|
||||||
actionStringHandler.get().handleInitiate("changeRequest");
|
actionStringHandler.get().handleInitiate("changeRequest");
|
||||||
|
@ -472,9 +469,9 @@ public class LoopPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rxBus.send(new EventLoopUpdateGui());
|
getRxBus().send(new EventLoopUpdateGui());
|
||||||
} finally {
|
} finally {
|
||||||
aapsLogger.debug(LTag.APS, "invoke end");
|
getAapsLogger().debug(LTag.APS, "invoke end");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,7 +488,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
NSUpload.uploadDeviceStatus(lp);
|
NSUpload.uploadDeviceStatus(lp);
|
||||||
sp.incInt(R.string.key_ObjectivesmanualEnacts);
|
sp.incInt(R.string.key_ObjectivesmanualEnacts);
|
||||||
}
|
}
|
||||||
rxBus.send(new EventAcceptOpenLoopChange());
|
getRxBus().send(new EventAcceptOpenLoopChange());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
FabricPrivacy.getInstance().logCustom("AcceptTemp");
|
FabricPrivacy.getInstance().logCustom("AcceptTemp");
|
||||||
|
@ -520,7 +517,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pump.isInitialized()) {
|
if (!pump.isInitialized()) {
|
||||||
aapsLogger.debug(LTag.APS, "applyAPSRequest: " + resourceHelper.gs(R.string.pumpNotInitialized));
|
getAapsLogger().debug(LTag.APS, "applyAPSRequest: " + resourceHelper.gs(R.string.pumpNotInitialized));
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.result(new PumpEnactResult().comment(resourceHelper.gs(R.string.pumpNotInitialized)).enacted(false).success(false)).run();
|
callback.result(new PumpEnactResult().comment(resourceHelper.gs(R.string.pumpNotInitialized)).enacted(false).success(false)).run();
|
||||||
}
|
}
|
||||||
|
@ -528,24 +525,24 @@ public class LoopPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pump.isSuspended()) {
|
if (pump.isSuspended()) {
|
||||||
aapsLogger.debug(LTag.APS, "applyAPSRequest: " + resourceHelper.gs(R.string.pumpsuspended));
|
getAapsLogger().debug(LTag.APS, "applyAPSRequest: " + resourceHelper.gs(R.string.pumpsuspended));
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.result(new PumpEnactResult().comment(resourceHelper.gs(R.string.pumpsuspended)).enacted(false).success(false)).run();
|
callback.result(new PumpEnactResult().comment(resourceHelper.gs(R.string.pumpsuspended)).enacted(false).success(false)).run();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
aapsLogger.debug(LTag.APS, "applyAPSRequest: " + request.toString());
|
getAapsLogger().debug(LTag.APS, "applyAPSRequest: " + request.toString());
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
TemporaryBasal activeTemp = treatmentsPlugin.getTempBasalFromHistory(now);
|
TemporaryBasal activeTemp = treatmentsPlugin.getTempBasalFromHistory(now);
|
||||||
if (request.usePercent && allowPercentage) {
|
if (request.usePercent && allowPercentage) {
|
||||||
if (request.percent == 100 && request.duration == 0) {
|
if (request.percent == 100 && request.duration == 0) {
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
aapsLogger.debug(LTag.APS, "applyAPSRequest: cancelTempBasal()");
|
getAapsLogger().debug(LTag.APS, "applyAPSRequest: cancelTempBasal()");
|
||||||
configBuilderPlugin.getCommandQueue().cancelTempBasal(false, callback);
|
configBuilderPlugin.getCommandQueue().cancelTempBasal(false, callback);
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.debug(LTag.APS, "applyAPSRequest: Basal set correctly");
|
getAapsLogger().debug(LTag.APS, "applyAPSRequest: Basal set correctly");
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.result(new PumpEnactResult().percent(request.percent).duration(0)
|
callback.result(new PumpEnactResult().percent(request.percent).duration(0)
|
||||||
.enacted(false).success(true).comment(resourceHelper.gs(R.string.basal_set_correctly))).run();
|
.enacted(false).success(true).comment(resourceHelper.gs(R.string.basal_set_correctly))).run();
|
||||||
|
@ -555,23 +552,23 @@ public class LoopPlugin extends PluginBase {
|
||||||
&& activeTemp.getPlannedRemainingMinutes() > 5
|
&& activeTemp.getPlannedRemainingMinutes() > 5
|
||||||
&& request.duration - activeTemp.getPlannedRemainingMinutes() < 30
|
&& request.duration - activeTemp.getPlannedRemainingMinutes() < 30
|
||||||
&& request.percent == activeTemp.percentRate) {
|
&& request.percent == activeTemp.percentRate) {
|
||||||
aapsLogger.debug(LTag.APS, "applyAPSRequest: Temp basal set correctly");
|
getAapsLogger().debug(LTag.APS, "applyAPSRequest: Temp basal set correctly");
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.result(new PumpEnactResult().percent(request.percent)
|
callback.result(new PumpEnactResult().percent(request.percent)
|
||||||
.enacted(false).success(true).duration(activeTemp.getPlannedRemainingMinutes())
|
.enacted(false).success(true).duration(activeTemp.getPlannedRemainingMinutes())
|
||||||
.comment(resourceHelper.gs(R.string.let_temp_basal_run))).run();
|
.comment(resourceHelper.gs(R.string.let_temp_basal_run))).run();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.debug(LTag.APS, "applyAPSRequest: tempBasalPercent()");
|
getAapsLogger().debug(LTag.APS, "applyAPSRequest: tempBasalPercent()");
|
||||||
configBuilderPlugin.getCommandQueue().tempBasalPercent(request.percent, request.duration, false, profile, callback);
|
configBuilderPlugin.getCommandQueue().tempBasalPercent(request.percent, request.duration, false, profile, callback);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - pump.getBaseBasalRate()) < pump.getPumpDescription().basalStep) {
|
if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - pump.getBaseBasalRate()) < pump.getPumpDescription().basalStep) {
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
aapsLogger.debug(LTag.APS, "applyAPSRequest: cancelTempBasal()");
|
getAapsLogger().debug(LTag.APS, "applyAPSRequest: cancelTempBasal()");
|
||||||
configBuilderPlugin.getCommandQueue().cancelTempBasal(false, callback);
|
configBuilderPlugin.getCommandQueue().cancelTempBasal(false, callback);
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.debug(LTag.APS, "applyAPSRequest: Basal set correctly");
|
getAapsLogger().debug(LTag.APS, "applyAPSRequest: Basal set correctly");
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.result(new PumpEnactResult().absolute(request.rate).duration(0)
|
callback.result(new PumpEnactResult().absolute(request.rate).duration(0)
|
||||||
.enacted(false).success(true).comment(resourceHelper.gs(R.string.basal_set_correctly))).run();
|
.enacted(false).success(true).comment(resourceHelper.gs(R.string.basal_set_correctly))).run();
|
||||||
|
@ -581,14 +578,14 @@ public class LoopPlugin extends PluginBase {
|
||||||
&& activeTemp.getPlannedRemainingMinutes() > 5
|
&& activeTemp.getPlannedRemainingMinutes() > 5
|
||||||
&& request.duration - activeTemp.getPlannedRemainingMinutes() < 30
|
&& request.duration - activeTemp.getPlannedRemainingMinutes() < 30
|
||||||
&& Math.abs(request.rate - activeTemp.tempBasalConvertedToAbsolute(now, profile)) < pump.getPumpDescription().basalStep) {
|
&& Math.abs(request.rate - activeTemp.tempBasalConvertedToAbsolute(now, profile)) < pump.getPumpDescription().basalStep) {
|
||||||
aapsLogger.debug(LTag.APS, "applyAPSRequest: Temp basal set correctly");
|
getAapsLogger().debug(LTag.APS, "applyAPSRequest: Temp basal set correctly");
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.result(new PumpEnactResult().absolute(activeTemp.tempBasalConvertedToAbsolute(now, profile))
|
callback.result(new PumpEnactResult().absolute(activeTemp.tempBasalConvertedToAbsolute(now, profile))
|
||||||
.enacted(false).success(true).duration(activeTemp.getPlannedRemainingMinutes())
|
.enacted(false).success(true).duration(activeTemp.getPlannedRemainingMinutes())
|
||||||
.comment(resourceHelper.gs(R.string.let_temp_basal_run))).run();
|
.comment(resourceHelper.gs(R.string.let_temp_basal_run))).run();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.debug(LTag.APS, "applyAPSRequest: setTempBasalAbsolute()");
|
getAapsLogger().debug(LTag.APS, "applyAPSRequest: setTempBasalAbsolute()");
|
||||||
configBuilderPlugin.getCommandQueue().tempBasalAbsolute(request.rate, request.duration, false, profile, callback);
|
configBuilderPlugin.getCommandQueue().tempBasalAbsolute(request.rate, request.duration, false, profile, callback);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -608,7 +605,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
|
|
||||||
long lastBolusTime = treatmentsPlugin.getLastBolusTime();
|
long lastBolusTime = treatmentsPlugin.getLastBolusTime();
|
||||||
if (lastBolusTime != 0 && lastBolusTime + 3 * 60 * 1000 > System.currentTimeMillis()) {
|
if (lastBolusTime != 0 && lastBolusTime + 3 * 60 * 1000 > System.currentTimeMillis()) {
|
||||||
aapsLogger.debug(LTag.APS, "SMB requested but still in 3 min interval");
|
getAapsLogger().debug(LTag.APS, "SMB requested but still in 3 min interval");
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.result(new PumpEnactResult()
|
callback.result(new PumpEnactResult()
|
||||||
.comment(resourceHelper.gs(R.string.smb_frequency_exceeded))
|
.comment(resourceHelper.gs(R.string.smb_frequency_exceeded))
|
||||||
|
@ -618,7 +615,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pump.isInitialized()) {
|
if (!pump.isInitialized()) {
|
||||||
aapsLogger.debug(LTag.APS, "applySMBRequest: " + resourceHelper.gs(R.string.pumpNotInitialized));
|
getAapsLogger().debug(LTag.APS, "applySMBRequest: " + resourceHelper.gs(R.string.pumpNotInitialized));
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.result(new PumpEnactResult().comment(resourceHelper.gs(R.string.pumpNotInitialized)).enacted(false).success(false)).run();
|
callback.result(new PumpEnactResult().comment(resourceHelper.gs(R.string.pumpNotInitialized)).enacted(false).success(false)).run();
|
||||||
}
|
}
|
||||||
|
@ -626,14 +623,14 @@ public class LoopPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pump.isSuspended()) {
|
if (pump.isSuspended()) {
|
||||||
aapsLogger.debug(LTag.APS, "applySMBRequest: " + resourceHelper.gs(R.string.pumpsuspended));
|
getAapsLogger().debug(LTag.APS, "applySMBRequest: " + resourceHelper.gs(R.string.pumpsuspended));
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.result(new PumpEnactResult().comment(resourceHelper.gs(R.string.pumpsuspended)).enacted(false).success(false)).run();
|
callback.result(new PumpEnactResult().comment(resourceHelper.gs(R.string.pumpsuspended)).enacted(false).success(false)).run();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
aapsLogger.debug(LTag.APS, "applySMBRequest: " + request.toString());
|
getAapsLogger().debug(LTag.APS, "applySMBRequest: " + request.toString());
|
||||||
|
|
||||||
// deliver SMB
|
// deliver SMB
|
||||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||||
|
@ -643,7 +640,7 @@ public class LoopPlugin extends PluginBase {
|
||||||
detailedBolusInfo.isSMB = true;
|
detailedBolusInfo.isSMB = true;
|
||||||
detailedBolusInfo.source = Source.USER;
|
detailedBolusInfo.source = Source.USER;
|
||||||
detailedBolusInfo.deliverAt = request.deliverAt;
|
detailedBolusInfo.deliverAt = request.deliverAt;
|
||||||
aapsLogger.debug(LTag.APS, "applyAPSRequest: bolus()");
|
getAapsLogger().debug(LTag.APS, "applyAPSRequest: bolus()");
|
||||||
configBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, callback);
|
configBuilderPlugin.getCommandQueue().bolus(detailedBolusInfo, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,8 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
||||||
.pluginName(R.string.openapsama)
|
.pluginName(R.string.openapsama)
|
||||||
.shortName(R.string.oaps_shortname)
|
.shortName(R.string.oaps_shortname)
|
||||||
.preferencesId(R.xml.pref_openapsama)
|
.preferencesId(R.xml.pref_openapsama)
|
||||||
.description(R.string.description_ama)
|
.description(R.string.description_ama),
|
||||||
|
rxBus, aapsLogger
|
||||||
);
|
);
|
||||||
this.aapsLogger = aapsLogger;
|
this.aapsLogger = aapsLogger;
|
||||||
this.rxBus = rxBus;
|
this.rxBus = rxBus;
|
||||||
|
|
|
@ -41,8 +41,6 @@ import static info.nightscout.androidaps.utils.HardLimits.verifyHardLimits;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||||
private final AAPSLogger aapsLogger;
|
|
||||||
private final RxBusWrapper rxBus;
|
|
||||||
private final ConstraintChecker constraintChecker;
|
private final ConstraintChecker constraintChecker;
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
private final ProfileFunction profileFunction;
|
private final ProfileFunction profileFunction;
|
||||||
|
@ -59,7 +57,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||||
@Inject
|
@Inject
|
||||||
public OpenAPSMAPlugin(
|
public OpenAPSMAPlugin(
|
||||||
AAPSLogger aapsLogger,
|
AAPSLogger aapsLogger,
|
||||||
RxBusWrapper rxBus,
|
RxBusWrapper rxBusWrapper,
|
||||||
ConstraintChecker constraintChecker,
|
ConstraintChecker constraintChecker,
|
||||||
ResourceHelper resourceHelper,
|
ResourceHelper resourceHelper,
|
||||||
ProfileFunction profileFunction,
|
ProfileFunction profileFunction,
|
||||||
|
@ -69,15 +67,15 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||||
IobCobCalculatorPlugin iobCobCalculatorPlugin
|
IobCobCalculatorPlugin iobCobCalculatorPlugin
|
||||||
) {
|
) {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.APS)
|
.mainType(PluginType.APS)
|
||||||
.fragmentClass(OpenAPSMAFragment.class.getName())
|
.fragmentClass(OpenAPSMAFragment.class.getName())
|
||||||
.pluginName(R.string.openapsma)
|
.pluginName(R.string.openapsma)
|
||||||
.shortName(R.string.oaps_shortname)
|
.shortName(R.string.oaps_shortname)
|
||||||
.preferencesId(R.xml.pref_openapsma)
|
.preferencesId(R.xml.pref_openapsma)
|
||||||
.description(R.string.description_ma)
|
.description(R.string.description_ma),
|
||||||
|
rxBusWrapper, aapsLogger
|
||||||
);
|
);
|
||||||
this.aapsLogger = aapsLogger;
|
|
||||||
this.rxBus = rxBus;
|
|
||||||
this.constraintChecker = constraintChecker;
|
this.constraintChecker = constraintChecker;
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
this.profileFunction = profileFunction;
|
this.profileFunction = profileFunction;
|
||||||
|
@ -111,36 +109,36 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invoke(String initiator, boolean tempBasalFallback) {
|
public void invoke(String initiator, boolean tempBasalFallback) {
|
||||||
aapsLogger.debug(LTag.APS, "invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback);
|
getAapsLogger().debug(LTag.APS, "invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback);
|
||||||
lastAPSResult = null;
|
lastAPSResult = null;
|
||||||
DetermineBasalAdapterMAJS determineBasalAdapterMAJS;
|
DetermineBasalAdapterMAJS determineBasalAdapterMAJS;
|
||||||
determineBasalAdapterMAJS = new DetermineBasalAdapterMAJS(new ScriptReader(mainApp), aapsLogger);
|
determineBasalAdapterMAJS = new DetermineBasalAdapterMAJS(new ScriptReader(mainApp), getAapsLogger());
|
||||||
|
|
||||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||||
Profile profile = profileFunction.getProfile();
|
Profile profile = profileFunction.getProfile();
|
||||||
PumpInterface pump = configBuilderPlugin.getActivePump();
|
PumpInterface pump = configBuilderPlugin.getActivePump();
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.noprofileselected)));
|
getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.noprofileselected)));
|
||||||
aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pump == null) {
|
if (pump == null) {
|
||||||
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.nopumpselected)));
|
getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.nopumpselected)));
|
||||||
aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.nopumpselected));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.nopumpselected));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isEnabled(PluginType.APS)) {
|
if (!isEnabled(PluginType.APS)) {
|
||||||
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_disabled)));
|
getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_disabled)));
|
||||||
aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.openapsma_disabled));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.openapsma_disabled));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glucoseStatus == null) {
|
if (glucoseStatus == null) {
|
||||||
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_noglucosedata)));
|
getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_noglucosedata)));
|
||||||
aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.openapsma_noglucosedata));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.openapsma_noglucosedata));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -164,7 +162,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||||
MealData mealData = iobCobCalculatorPlugin.getMealData();
|
MealData mealData = iobCobCalculatorPlugin.getMealData();
|
||||||
|
|
||||||
double maxIob = constraintChecker.getMaxIOBAllowed().value();
|
double maxIob = constraintChecker.getMaxIOBAllowed().value();
|
||||||
Profiler.log(aapsLogger, LTag.APS, "MA data gathering", start);
|
Profiler.log(getAapsLogger(), LTag.APS, "MA data gathering", start);
|
||||||
|
|
||||||
minBg = verifyHardLimits(minBg, "minBg", HardLimits.VERY_HARD_LIMIT_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_MIN_BG[1]);
|
minBg = verifyHardLimits(minBg, "minBg", HardLimits.VERY_HARD_LIMIT_MIN_BG[0], HardLimits.VERY_HARD_LIMIT_MIN_BG[1]);
|
||||||
maxBg = verifyHardLimits(maxBg, "maxBg", HardLimits.VERY_HARD_LIMIT_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_MAX_BG[1]);
|
maxBg = verifyHardLimits(maxBg, "maxBg", HardLimits.VERY_HARD_LIMIT_MAX_BG[0], HardLimits.VERY_HARD_LIMIT_MAX_BG[1]);
|
||||||
|
@ -195,14 +193,14 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||||
FabricPrivacy.getInstance().logException(e);
|
FabricPrivacy.getInstance().logException(e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Profiler.log(aapsLogger, LTag.APS, "MA calculation", start);
|
Profiler.log(getAapsLogger(), LTag.APS, "MA calculation", start);
|
||||||
|
|
||||||
|
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
|
|
||||||
DetermineBasalResultMA determineBasalResultMA = determineBasalAdapterMAJS.invoke();
|
DetermineBasalResultMA determineBasalResultMA = determineBasalAdapterMAJS.invoke();
|
||||||
if (determineBasalResultMA == null) {
|
if (determineBasalResultMA == null) {
|
||||||
aapsLogger.error(LTag.APS, "MA calculation returned null");
|
getAapsLogger().error(LTag.APS, "MA calculation returned null");
|
||||||
lastDetermineBasalAdapterMAJS = null;
|
lastDetermineBasalAdapterMAJS = null;
|
||||||
lastAPSResult = null;
|
lastAPSResult = null;
|
||||||
lastAPSRun = 0;
|
lastAPSRun = 0;
|
||||||
|
@ -216,14 +214,14 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||||
try {
|
try {
|
||||||
determineBasalResultMA.json.put("timestamp", DateUtil.toISOString(now));
|
determineBasalResultMA.json.put("timestamp", DateUtil.toISOString(now));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
aapsLogger.error(LTag.APS, "Unhandled exception", e);
|
getAapsLogger().error(LTag.APS, "Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
lastDetermineBasalAdapterMAJS = determineBasalAdapterMAJS;
|
lastDetermineBasalAdapterMAJS = determineBasalAdapterMAJS;
|
||||||
lastAPSResult = determineBasalResultMA;
|
lastAPSResult = determineBasalResultMA;
|
||||||
lastAPSRun = now;
|
lastAPSRun = now;
|
||||||
}
|
}
|
||||||
rxBus.send(new EventOpenAPSUpdateGui());
|
getRxBus().send(new EventOpenAPSUpdateGui());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,6 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, ConstraintsInterface {
|
public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, ConstraintsInterface {
|
||||||
private final AAPSLogger aapsLogger;
|
|
||||||
private final RxBusWrapper rxBus;
|
|
||||||
private final ConstraintChecker constraintChecker;
|
private final ConstraintChecker constraintChecker;
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
private final ProfileFunction profileFunction;
|
private final ProfileFunction profileFunction;
|
||||||
|
@ -76,7 +74,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
@Inject
|
@Inject
|
||||||
public OpenAPSSMBPlugin(
|
public OpenAPSSMBPlugin(
|
||||||
AAPSLogger aapsLogger,
|
AAPSLogger aapsLogger,
|
||||||
RxBusWrapper rxBus,
|
RxBusWrapper rxBusWrapper,
|
||||||
ConstraintChecker constraintChecker,
|
ConstraintChecker constraintChecker,
|
||||||
ResourceHelper resourceHelper,
|
ResourceHelper resourceHelper,
|
||||||
ProfileFunction profileFunction,
|
ProfileFunction profileFunction,
|
||||||
|
@ -84,19 +82,18 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
ConfigBuilderPlugin configBuilderPlugin,
|
ConfigBuilderPlugin configBuilderPlugin,
|
||||||
TreatmentsPlugin treatmentsPlugin,
|
TreatmentsPlugin treatmentsPlugin,
|
||||||
IobCobCalculatorPlugin iobCobCalculatorPlugin
|
IobCobCalculatorPlugin iobCobCalculatorPlugin
|
||||||
|
) {
|
||||||
) {
|
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.APS)
|
.mainType(PluginType.APS)
|
||||||
.fragmentClass(OpenAPSSMBFragment.class.getName())
|
.fragmentClass(OpenAPSSMBFragment.class.getName())
|
||||||
.pluginName(R.string.openapssmb)
|
.pluginName(R.string.openapssmb)
|
||||||
.shortName(R.string.smb_shortname)
|
.shortName(R.string.smb_shortname)
|
||||||
.preferencesId(R.xml.pref_openapssmb)
|
.preferencesId(R.xml.pref_openapssmb)
|
||||||
.description(R.string.description_smb)
|
.description(R.string.description_smb),
|
||||||
|
rxBusWrapper, aapsLogger
|
||||||
);
|
);
|
||||||
this.openAPSSMBPlugin = this; // TODO: only while transitioning to Dagger
|
this.openAPSSMBPlugin = this; // TODO: only while transitioning to Dagger
|
||||||
this.aapsLogger = aapsLogger;
|
|
||||||
this.rxBus = rxBus;
|
|
||||||
this.constraintChecker = constraintChecker;
|
this.constraintChecker = constraintChecker;
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
this.profileFunction = profileFunction;
|
this.profileFunction = profileFunction;
|
||||||
|
@ -130,36 +127,36 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invoke(String initiator, boolean tempBasalFallback) {
|
public void invoke(String initiator, boolean tempBasalFallback) {
|
||||||
aapsLogger.debug(LTag.APS, "invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback);
|
getAapsLogger().debug(LTag.APS, "invoke from " + initiator + " tempBasalFallback: " + tempBasalFallback);
|
||||||
lastAPSResult = null;
|
lastAPSResult = null;
|
||||||
DetermineBasalAdapterSMBJS determineBasalAdapterSMBJS;
|
DetermineBasalAdapterSMBJS determineBasalAdapterSMBJS;
|
||||||
determineBasalAdapterSMBJS = new DetermineBasalAdapterSMBJS(new ScriptReader(mainApp), aapsLogger);
|
determineBasalAdapterSMBJS = new DetermineBasalAdapterSMBJS(new ScriptReader(mainApp), getAapsLogger());
|
||||||
|
|
||||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||||
Profile profile = profileFunction.getProfile();
|
Profile profile = profileFunction.getProfile();
|
||||||
PumpInterface pump = configBuilderPlugin.getActivePump();
|
PumpInterface pump = configBuilderPlugin.getActivePump();
|
||||||
|
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.noprofileselected)));
|
getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.noprofileselected)));
|
||||||
aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.noprofileselected));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pump == null) {
|
if (pump == null) {
|
||||||
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.nopumpselected)));
|
getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.nopumpselected)));
|
||||||
aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.nopumpselected));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.nopumpselected));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isEnabled(PluginType.APS)) {
|
if (!isEnabled(PluginType.APS)) {
|
||||||
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_disabled)));
|
getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_disabled)));
|
||||||
aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.openapsma_disabled));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.openapsma_disabled));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (glucoseStatus == null) {
|
if (glucoseStatus == null) {
|
||||||
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_noglucosedata)));
|
getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openapsma_noglucosedata)));
|
||||||
aapsLogger.debug(LTag.APS, resourceHelper.gs(R.string.openapsma_noglucosedata));
|
getAapsLogger().debug(LTag.APS, resourceHelper.gs(R.string.openapsma_noglucosedata));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -179,7 +176,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
long startPart = System.currentTimeMillis();
|
long startPart = System.currentTimeMillis();
|
||||||
|
|
||||||
MealData mealData = iobCobCalculatorPlugin.getMealData();
|
MealData mealData = iobCobCalculatorPlugin.getMealData();
|
||||||
Profiler.log(aapsLogger, LTag.APS, "getMealData()", startPart);
|
Profiler.log(getAapsLogger(), LTag.APS, "getMealData()", startPart);
|
||||||
|
|
||||||
Constraint<Double> maxIOBAllowedConstraint = constraintChecker.getMaxIOBAllowed();
|
Constraint<Double> maxIOBAllowedConstraint = constraintChecker.getMaxIOBAllowed();
|
||||||
inputConstraints.copyReasons(maxIOBAllowedConstraint);
|
inputConstraints.copyReasons(maxIOBAllowedConstraint);
|
||||||
|
@ -214,7 +211,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
if (constraintChecker.isAutosensModeEnabled().value()) {
|
if (constraintChecker.isAutosensModeEnabled().value()) {
|
||||||
AutosensData autosensData = iobCobCalculatorPlugin.getLastAutosensDataSynchronized("OpenAPSPlugin");
|
AutosensData autosensData = iobCobCalculatorPlugin.getLastAutosensDataSynchronized("OpenAPSPlugin");
|
||||||
if (autosensData == null) {
|
if (autosensData == null) {
|
||||||
rxBus.send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openaps_noasdata)));
|
getRxBus().send(new EventOpenAPSUpdateResultGui(resourceHelper.gs(R.string.openaps_noasdata)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
lastAutosensResult = autosensData.autosensResult;
|
lastAutosensResult = autosensData.autosensResult;
|
||||||
|
@ -224,7 +221,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
}
|
}
|
||||||
|
|
||||||
IobTotal[] iobArray = iobCobCalculatorPlugin.calculateIobArrayForSMB(lastAutosensResult, SMBDefaults.exercise_mode, SMBDefaults.half_basal_exercise_target, isTempTarget);
|
IobTotal[] iobArray = iobCobCalculatorPlugin.calculateIobArrayForSMB(lastAutosensResult, SMBDefaults.exercise_mode, SMBDefaults.half_basal_exercise_target, isTempTarget);
|
||||||
Profiler.log(aapsLogger, LTag.APS, "calculateIobArrayInDia()", startPart);
|
Profiler.log(getAapsLogger(), LTag.APS, "calculateIobArrayInDia()", startPart);
|
||||||
|
|
||||||
startPart = System.currentTimeMillis();
|
startPart = System.currentTimeMillis();
|
||||||
Constraint<Boolean> smbAllowed = new Constraint<>(!tempBasalFallback);
|
Constraint<Boolean> smbAllowed = new Constraint<>(!tempBasalFallback);
|
||||||
|
@ -239,8 +236,8 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
constraintChecker.isUAMEnabled(uam);
|
constraintChecker.isUAMEnabled(uam);
|
||||||
inputConstraints.copyReasons(uam);
|
inputConstraints.copyReasons(uam);
|
||||||
|
|
||||||
Profiler.log(aapsLogger, LTag.APS, "detectSensitivityandCarbAbsorption()", startPart);
|
Profiler.log(getAapsLogger(), LTag.APS, "detectSensitivityandCarbAbsorption()", startPart);
|
||||||
Profiler.log(aapsLogger, LTag.APS, "SMB data gathering", start);
|
Profiler.log(getAapsLogger(), LTag.APS, "SMB data gathering", start);
|
||||||
|
|
||||||
start = System.currentTimeMillis();
|
start = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
|
@ -259,9 +256,9 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
|
|
||||||
DetermineBasalResultSMB determineBasalResultSMB = determineBasalAdapterSMBJS.invoke();
|
DetermineBasalResultSMB determineBasalResultSMB = determineBasalAdapterSMBJS.invoke();
|
||||||
Profiler.log(aapsLogger, LTag.APS, "SMB calculation", start);
|
Profiler.log(getAapsLogger(), LTag.APS, "SMB calculation", start);
|
||||||
if (determineBasalResultSMB == null) {
|
if (determineBasalResultSMB == null) {
|
||||||
aapsLogger.error(LTag.APS, "SMB calculation returned null");
|
getAapsLogger().error(LTag.APS, "SMB calculation returned null");
|
||||||
lastDetermineBasalAdapterSMBJS = null;
|
lastDetermineBasalAdapterSMBJS = null;
|
||||||
lastAPSResult = null;
|
lastAPSResult = null;
|
||||||
lastAPSRun = 0;
|
lastAPSRun = 0;
|
||||||
|
@ -276,7 +273,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
try {
|
try {
|
||||||
determineBasalResultSMB.json.put("timestamp", DateUtil.toISOString(now));
|
determineBasalResultSMB.json.put("timestamp", DateUtil.toISOString(now));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
aapsLogger.error(LTag.APS, "Unhandled exception", e);
|
getAapsLogger().error(LTag.APS, "Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
determineBasalResultSMB.inputConstraints = inputConstraints;
|
determineBasalResultSMB.inputConstraints = inputConstraints;
|
||||||
|
@ -285,7 +282,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
lastAPSResult = determineBasalResultSMB;
|
lastAPSResult = determineBasalResultSMB;
|
||||||
lastAPSRun = now;
|
lastAPSRun = now;
|
||||||
}
|
}
|
||||||
rxBus.send(new EventOpenAPSUpdateGui());
|
getRxBus().send(new EventOpenAPSUpdateGui());
|
||||||
|
|
||||||
//deviceStatus.suggested = determineBasalResultAMA.json;
|
//deviceStatus.suggested = determineBasalResultAMA.json;
|
||||||
}
|
}
|
||||||
|
@ -303,7 +300,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
String msg = String.format(resourceHelper.gs(R.string.valueoutofrange), valueName);
|
String msg = String.format(resourceHelper.gs(R.string.valueoutofrange), valueName);
|
||||||
msg += ".\n";
|
msg += ".\n";
|
||||||
msg += String.format(resourceHelper.gs(R.string.valuelimitedto), value, newvalue);
|
msg += String.format(resourceHelper.gs(R.string.valuelimitedto), value, newvalue);
|
||||||
aapsLogger.error(LTag.APS, msg);
|
getAapsLogger().error(LTag.APS, msg);
|
||||||
NSUpload.uploadError(msg);
|
NSUpload.uploadError(msg);
|
||||||
ToastUtils.showToastInUiThread(mainApp, msg, R.raw.error);
|
ToastUtils.showToastInUiThread(mainApp, msg, R.raw.error);
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,7 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class ConfigBuilderPlugin extends PluginBase {
|
public class ConfigBuilderPlugin extends PluginBase {
|
||||||
private static ConfigBuilderPlugin configBuilderPlugin;
|
private static ConfigBuilderPlugin configBuilderPlugin;
|
||||||
private final AAPSLogger aapsLogger; // TODO move to plugin base
|
private final SP sp;
|
||||||
private final SP sp;
|
|
||||||
private final RxBusWrapper rxBus;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -66,7 +64,6 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
|
|
||||||
private CommandQueue commandQueue = new CommandQueue();
|
private CommandQueue commandQueue = new CommandQueue();
|
||||||
|
|
||||||
private final Lazy<MainApp> mainApp;
|
|
||||||
private final Lazy<InsulinOrefRapidActingPlugin> insulinOrefRapidActingPlugin;
|
private final Lazy<InsulinOrefRapidActingPlugin> insulinOrefRapidActingPlugin;
|
||||||
private final Lazy<LocalProfilePlugin> localProfilePlugin;
|
private final Lazy<LocalProfilePlugin> localProfilePlugin;
|
||||||
private final Lazy<VirtualPumpPlugin> virtualPumpPlugin;
|
private final Lazy<VirtualPumpPlugin> virtualPumpPlugin;
|
||||||
|
@ -80,31 +77,27 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
* */
|
* */
|
||||||
@Inject
|
@Inject
|
||||||
public ConfigBuilderPlugin(
|
public ConfigBuilderPlugin(
|
||||||
Lazy<MainApp> mainApp,
|
|
||||||
Lazy<InsulinOrefRapidActingPlugin> insulinOrefRapidActingPlugin,
|
Lazy<InsulinOrefRapidActingPlugin> insulinOrefRapidActingPlugin,
|
||||||
Lazy<LocalProfilePlugin> localProfilePlugin,
|
Lazy<LocalProfilePlugin> localProfilePlugin,
|
||||||
Lazy<VirtualPumpPlugin> virtualPumpPlugin,
|
Lazy<VirtualPumpPlugin> virtualPumpPlugin,
|
||||||
AAPSLogger aapsLogger,
|
|
||||||
SP sp,
|
SP sp,
|
||||||
RxBusWrapper rxBus
|
RxBusWrapper rxBus,
|
||||||
) {
|
AAPSLogger aapsLogger) {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
.fragmentClass(ConfigBuilderFragment.class.getName())
|
.fragmentClass(ConfigBuilderFragment.class.getName())
|
||||||
.showInList(true)
|
.showInList(true)
|
||||||
.alwaysEnabled(true)
|
.alwaysEnabled(true)
|
||||||
.alwaysVisible(false)
|
.alwaysVisible(false)
|
||||||
.pluginName(R.string.configbuilder)
|
.pluginName(R.string.configbuilder)
|
||||||
.shortName(R.string.configbuilder_shortname)
|
.shortName(R.string.configbuilder_shortname)
|
||||||
.description(R.string.description_config_builder)
|
.description(R.string.description_config_builder),
|
||||||
|
rxBus, aapsLogger
|
||||||
);
|
);
|
||||||
this.mainApp = mainApp;
|
|
||||||
this.insulinOrefRapidActingPlugin = insulinOrefRapidActingPlugin;
|
this.insulinOrefRapidActingPlugin = insulinOrefRapidActingPlugin;
|
||||||
this.localProfilePlugin = localProfilePlugin;
|
this.localProfilePlugin = localProfilePlugin;
|
||||||
this.virtualPumpPlugin = virtualPumpPlugin;
|
this.virtualPumpPlugin = virtualPumpPlugin;
|
||||||
this.aapsLogger = aapsLogger;
|
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
this.rxBus =rxBus;
|
|
||||||
configBuilderPlugin = this; // TODO: only while transitioning to Dagger
|
configBuilderPlugin = this; // TODO: only while transitioning to Dagger
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +111,7 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
|
|
||||||
private void setAlwaysEnabledPluginsEnabled() {
|
private void setAlwaysEnabledPluginsEnabled() {
|
||||||
for (PluginBase plugin : pluginList) {
|
for (PluginBase plugin : pluginList) {
|
||||||
if (plugin.pluginDescription.alwaysEnabled)
|
if (plugin.getPluginDescription().alwaysEnabled)
|
||||||
plugin.setPluginEnabled(plugin.getType(), true);
|
plugin.setPluginEnabled(plugin.getType(), true);
|
||||||
}
|
}
|
||||||
storeSettings("setAlwaysEnabledPluginsEnabled");
|
storeSettings("setAlwaysEnabledPluginsEnabled");
|
||||||
|
@ -126,15 +119,15 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
|
|
||||||
public void storeSettings(String from) {
|
public void storeSettings(String from) {
|
||||||
if (pluginList != null) {
|
if (pluginList != null) {
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Storing settings from: " + from);
|
getAapsLogger().debug(LTag.CONFIGBUILDER, "Storing settings from: " + from);
|
||||||
|
|
||||||
verifySelectionInCategories();
|
verifySelectionInCategories();
|
||||||
|
|
||||||
for (PluginBase p : pluginList) {
|
for (PluginBase p : pluginList) {
|
||||||
PluginType type = p.getType();
|
PluginType type = p.getType();
|
||||||
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.alwaysVisible)
|
if (p.getPluginDescription().alwaysEnabled && p.getPluginDescription().alwaysVisible)
|
||||||
continue;
|
continue;
|
||||||
if (p.pluginDescription.alwaysEnabled && p.pluginDescription.neverVisible)
|
if (p.getPluginDescription().alwaysEnabled && p.getPluginDescription().neverVisible)
|
||||||
continue;
|
continue;
|
||||||
savePref(p, type, true);
|
savePref(p, type, true);
|
||||||
if (type == PluginType.PUMP) {
|
if (type == PluginType.PUMP) {
|
||||||
|
@ -149,16 +142,16 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
private void savePref(PluginBase p, PluginType type, boolean storeVisible) {
|
private void savePref(PluginBase p, PluginType type, boolean storeVisible) {
|
||||||
String settingEnabled = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Enabled";
|
String settingEnabled = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Enabled";
|
||||||
sp.putBoolean(settingEnabled, p.isEnabled(type));
|
sp.putBoolean(settingEnabled, p.isEnabled(type));
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Storing: " + settingEnabled + ":" + p.isEnabled(type));
|
getAapsLogger().debug(LTag.CONFIGBUILDER, "Storing: " + settingEnabled + ":" + p.isEnabled(type));
|
||||||
if (storeVisible) {
|
if (storeVisible) {
|
||||||
String settingVisible = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Visible";
|
String settingVisible = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Visible";
|
||||||
sp.putBoolean(settingVisible, p.isFragmentVisible());
|
sp.putBoolean(settingVisible, p.isFragmentVisible());
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Storing: " + settingVisible + ":" + p.isFragmentVisible());
|
getAapsLogger().debug(LTag.CONFIGBUILDER, "Storing: " + settingVisible + ":" + p.isFragmentVisible());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadSettings() {
|
private void loadSettings() {
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Loading stored settings");
|
getAapsLogger().debug(LTag.CONFIGBUILDER, "Loading stored settings");
|
||||||
for (PluginBase p : pluginList) {
|
for (PluginBase p : pluginList) {
|
||||||
PluginType type = p.getType();
|
PluginType type = p.getType();
|
||||||
loadPref(p, type, true);
|
loadPref(p, type, true);
|
||||||
|
@ -175,18 +168,18 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
String settingEnabled = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Enabled";
|
String settingEnabled = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Enabled";
|
||||||
if (sp.contains(settingEnabled))
|
if (sp.contains(settingEnabled))
|
||||||
p.setPluginEnabled(type, sp.getBoolean(settingEnabled, false));
|
p.setPluginEnabled(type, sp.getBoolean(settingEnabled, false));
|
||||||
else if (p.getType() == type && (p.pluginDescription.enableByDefault || p.pluginDescription.alwaysEnabled)) {
|
else if (p.getType() == type && (p.getPluginDescription().enableByDefault || p.getPluginDescription().alwaysEnabled)) {
|
||||||
p.setPluginEnabled(type, true);
|
p.setPluginEnabled(type, true);
|
||||||
}
|
}
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Loaded: " + settingEnabled + ":" + p.isEnabled(type));
|
getAapsLogger().debug(LTag.CONFIGBUILDER, "Loaded: " + settingEnabled + ":" + p.isEnabled(type));
|
||||||
if (loadVisible) {
|
if (loadVisible) {
|
||||||
String settingVisible = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Visible";
|
String settingVisible = "ConfigBuilder_" + type.name() + "_" + p.getClass().getSimpleName() + "_Visible";
|
||||||
if (sp.contains(settingVisible))
|
if (sp.contains(settingVisible))
|
||||||
p.setFragmentVisible(type, sp.getBoolean(settingVisible, false) && sp.getBoolean(settingEnabled, false));
|
p.setFragmentVisible(type, sp.getBoolean(settingVisible, false) && sp.getBoolean(settingEnabled, false));
|
||||||
else if (p.getType() == type && p.pluginDescription.visibleByDefault) {
|
else if (p.getType() == type && p.getPluginDescription().visibleByDefault) {
|
||||||
p.setFragmentVisible(type, true);
|
p.setFragmentVisible(type, true);
|
||||||
}
|
}
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Loaded: " + settingVisible + ":" + p.isFragmentVisible());
|
getAapsLogger().debug(LTag.CONFIGBUILDER, "Loaded: " + settingVisible + ":" + p.isFragmentVisible());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,9 +187,9 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
private void upgradeSettings() {
|
private void upgradeSettings() {
|
||||||
if (!sp.contains("ConfigBuilder_1_NSProfilePlugin_Enabled"))
|
if (!sp.contains("ConfigBuilder_1_NSProfilePlugin_Enabled"))
|
||||||
return;
|
return;
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Upgrading stored settings");
|
getAapsLogger().debug(LTag.CONFIGBUILDER, "Upgrading stored settings");
|
||||||
for (PluginBase p : pluginList) {
|
for (PluginBase p : pluginList) {
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Processing " + p.getName());
|
getAapsLogger().debug(LTag.CONFIGBUILDER, "Processing " + p.getName());
|
||||||
for (int type = 1; type < 11; type++) {
|
for (int type = 1; type < 11; type++) {
|
||||||
PluginType newType;
|
PluginType newType;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
@ -288,7 +281,7 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
|
|
||||||
public void logPluginStatus() {
|
public void logPluginStatus() {
|
||||||
for (PluginBase p : pluginList) {
|
for (PluginBase p : pluginList) {
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, p.getName() + ":" +
|
getAapsLogger().debug(LTag.CONFIGBUILDER, p.getName() + ":" +
|
||||||
(p.isEnabled(PluginType.GENERAL) ? " GENERAL" : "") +
|
(p.isEnabled(PluginType.GENERAL) ? " GENERAL" : "") +
|
||||||
(p.isEnabled(PluginType.TREATMENT) ? " TREATMENT" : "") +
|
(p.isEnabled(PluginType.TREATMENT) ? " TREATMENT" : "") +
|
||||||
(p.isEnabled(PluginType.SENSITIVITY) ? " SENSITIVITY" : "") +
|
(p.isEnabled(PluginType.SENSITIVITY) ? " SENSITIVITY" : "") +
|
||||||
|
@ -315,7 +308,7 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
if (activeInsulin == null) {
|
if (activeInsulin == null) {
|
||||||
activeInsulin = insulinOrefRapidActingPlugin.get();
|
activeInsulin = insulinOrefRapidActingPlugin.get();
|
||||||
insulinOrefRapidActingPlugin.get().setPluginEnabled(PluginType.INSULIN, true);
|
insulinOrefRapidActingPlugin.get().setPluginEnabled(PluginType.INSULIN, true);
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting InsulinOrefRapidActingPlugin");
|
getAapsLogger().debug(LTag.CONFIGBUILDER, "Defaulting InsulinOrefRapidActingPlugin");
|
||||||
}
|
}
|
||||||
this.setFragmentVisiblities(((PluginBase) activeInsulin).getName(), pluginsInCategory, PluginType.INSULIN);
|
this.setFragmentVisiblities(((PluginBase) activeInsulin).getName(), pluginsInCategory, PluginType.INSULIN);
|
||||||
|
|
||||||
|
@ -325,7 +318,7 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
if (activeSensitivity == null) {
|
if (activeSensitivity == null) {
|
||||||
activeSensitivity = SensitivityOref0Plugin.getPlugin();
|
activeSensitivity = SensitivityOref0Plugin.getPlugin();
|
||||||
SensitivityOref0Plugin.getPlugin().setPluginEnabled(PluginType.SENSITIVITY, true);
|
SensitivityOref0Plugin.getPlugin().setPluginEnabled(PluginType.SENSITIVITY, true);
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting SensitivityOref0Plugin");
|
getAapsLogger().debug(LTag.CONFIGBUILDER, "Defaulting SensitivityOref0Plugin");
|
||||||
}
|
}
|
||||||
this.setFragmentVisiblities(((PluginBase) activeSensitivity).getName(), pluginsInCategory, PluginType.SENSITIVITY);
|
this.setFragmentVisiblities(((PluginBase) activeSensitivity).getName(), pluginsInCategory, PluginType.SENSITIVITY);
|
||||||
|
|
||||||
|
@ -341,7 +334,7 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
if (activePump == null) {
|
if (activePump == null) {
|
||||||
activePump = virtualPumpPlugin.get();
|
activePump = virtualPumpPlugin.get();
|
||||||
virtualPumpPlugin.get().setPluginEnabled(PluginType.PUMP, true);
|
virtualPumpPlugin.get().setPluginEnabled(PluginType.PUMP, true);
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Defaulting VirtualPumpPlugin");
|
getAapsLogger().debug(LTag.CONFIGBUILDER, "Defaulting VirtualPumpPlugin");
|
||||||
}
|
}
|
||||||
this.setFragmentVisiblities(((PluginBase) activePump).getName(), pluginsInCategory, PluginType.PUMP);
|
this.setFragmentVisiblities(((PluginBase) activePump).getName(), pluginsInCategory, PluginType.PUMP);
|
||||||
|
|
||||||
|
@ -399,7 +392,7 @@ public class ConfigBuilderPlugin extends PluginBase {
|
||||||
|
|
||||||
private void setFragmentVisiblities(String activePluginName, ArrayList<PluginBase> pluginsInCategory,
|
private void setFragmentVisiblities(String activePluginName, ArrayList<PluginBase> pluginsInCategory,
|
||||||
PluginType pluginType) {
|
PluginType pluginType) {
|
||||||
aapsLogger.debug(LTag.CONFIGBUILDER, "Selected interface: " + activePluginName);
|
getAapsLogger().debug(LTag.CONFIGBUILDER, "Selected interface: " + activePluginName);
|
||||||
for (PluginBase p : pluginsInCategory) {
|
for (PluginBase p : pluginsInCategory) {
|
||||||
if (!p.getName().equals(activePluginName)) {
|
if (!p.getName().equals(activePluginName)) {
|
||||||
p.setFragmentVisible(pluginType, false);
|
p.setFragmentVisible(pluginType, false);
|
||||||
|
|
|
@ -23,22 +23,23 @@ import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class DstHelperPlugin @Inject constructor(): PluginBase(PluginDescription()
|
class DstHelperPlugin @Inject constructor(
|
||||||
|
aapsLogger: AAPSLogger,
|
||||||
|
rxBus: RxBusWrapper,
|
||||||
|
var resourceHelper: ResourceHelper,
|
||||||
|
var mainApp: MainApp,
|
||||||
|
var sp: SP,
|
||||||
|
var configBuilderPlugin: ConfigBuilderPlugin,
|
||||||
|
var loopPlugin: LoopPlugin
|
||||||
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.CONSTRAINTS)
|
.mainType(PluginType.CONSTRAINTS)
|
||||||
.neverVisible(true)
|
.neverVisible(true)
|
||||||
.alwaysEnabled(true)
|
.alwaysEnabled(true)
|
||||||
.showInList(false)
|
.showInList(false)
|
||||||
.pluginName(R.string.dst_plugin_name)
|
.pluginName(R.string.dst_plugin_name),
|
||||||
|
rxBus, aapsLogger
|
||||||
), ConstraintsInterface {
|
), ConstraintsInterface {
|
||||||
|
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
|
||||||
@Inject lateinit var mainApp: MainApp
|
|
||||||
@Inject lateinit var sp : SP
|
|
||||||
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
|
||||||
@Inject lateinit var loopPlugin: LoopPlugin
|
|
||||||
|
|
||||||
private val DISABLE_TIMEFRAME_HOURS = -3
|
private val DISABLE_TIMEFRAME_HOURS = -3
|
||||||
private val WARN_PRIOR_TIMEFRAME_HOURS = 12
|
private val WARN_PRIOR_TIMEFRAME_HOURS = 12
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,8 @@ import info.nightscout.androidaps.interfaces.ConstraintsInterface
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.*
|
import info.nightscout.androidaps.plugins.constraints.objectives.objectives.*
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
|
@ -25,7 +27,9 @@ import javax.inject.Singleton
|
||||||
class ObjectivesPlugin @Inject constructor(
|
class ObjectivesPlugin @Inject constructor(
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val resourceHelper: ResourceHelper,
|
private val resourceHelper: ResourceHelper,
|
||||||
private val configBuilderPlugin: ConfigBuilderPlugin
|
private val configBuilderPlugin: ConfigBuilderPlugin,
|
||||||
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
|
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.CONSTRAINTS)
|
.mainType(PluginType.CONSTRAINTS)
|
||||||
.fragmentClass(ObjectivesFragment::class.qualifiedName)
|
.fragmentClass(ObjectivesFragment::class.qualifiedName)
|
||||||
|
@ -33,7 +37,9 @@ class ObjectivesPlugin @Inject constructor(
|
||||||
.showInList(Config.APS)
|
.showInList(Config.APS)
|
||||||
.pluginName(R.string.objectives)
|
.pluginName(R.string.objectives)
|
||||||
.shortName(R.string.objectives_shortname)
|
.shortName(R.string.objectives_shortname)
|
||||||
.description(R.string.description_objectives)), ConstraintsInterface {
|
.description(R.string.description_objectives),
|
||||||
|
rxBus, aapsLogger
|
||||||
|
), ConstraintsInterface {
|
||||||
|
|
||||||
var objectives: MutableList<Objective> = ArrayList()
|
var objectives: MutableList<Objective> = ArrayList()
|
||||||
|
|
||||||
|
|
|
@ -15,10 +15,12 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||||
|
@ -32,6 +34,8 @@ import info.nightscout.androidaps.utils.SP;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
|
|
||||||
|
//TODO: dagger
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
OpenAPSAMAPlugin openAPSAMAPlugin;
|
OpenAPSAMAPlugin openAPSAMAPlugin;
|
||||||
|
|
||||||
|
@ -42,14 +46,14 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
OpenAPSSMBPlugin openAPSSMBPlugin;
|
OpenAPSSMBPlugin openAPSSMBPlugin;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public SafetyPlugin() {
|
public SafetyPlugin(RxBusWrapper rxBusWrapper, AAPSLogger aapsLogger) {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.CONSTRAINTS)
|
.mainType(PluginType.CONSTRAINTS)
|
||||||
.neverVisible(true)
|
.neverVisible(true)
|
||||||
.alwaysEnabled(true)
|
.alwaysEnabled(true)
|
||||||
.showInList(false)
|
.showInList(false)
|
||||||
.pluginName(R.string.safety)
|
.pluginName(R.string.safety)
|
||||||
.preferencesId(R.xml.pref_safety)
|
.preferencesId(R.xml.pref_safety), rxBusWrapper, aapsLogger
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ import info.nightscout.androidaps.interfaces.ConstraintsInterface
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.L
|
import info.nightscout.androidaps.logging.L
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||||
|
@ -34,15 +35,17 @@ import javax.inject.Singleton
|
||||||
@Singleton
|
@Singleton
|
||||||
class SignatureVerifierPlugin @Inject constructor(
|
class SignatureVerifierPlugin @Inject constructor(
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val rxBus: RxBusWrapper,
|
|
||||||
private val resourceHelper: ResourceHelper,
|
private val resourceHelper: ResourceHelper,
|
||||||
private val mainApp: MainApp
|
private val mainApp: MainApp,
|
||||||
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.CONSTRAINTS)
|
.mainType(PluginType.CONSTRAINTS)
|
||||||
.neverVisible(true)
|
.neverVisible(true)
|
||||||
.alwaysEnabled(true)
|
.alwaysEnabled(true)
|
||||||
.showInList(false)
|
.showInList(false)
|
||||||
.pluginName(R.string.signature_verifier)), ConstraintsInterface {
|
.pluginName(R.string.signature_verifier),
|
||||||
|
rxBus, aapsLogger
|
||||||
|
), ConstraintsInterface {
|
||||||
|
|
||||||
private val REVOKED_CERTS_URL = "https://raw.githubusercontent.com/MilosKozak/AndroidAPS/master/app/src/main/assets/revoked_certs.txt"
|
private val REVOKED_CERTS_URL = "https://raw.githubusercontent.com/MilosKozak/AndroidAPS/master/app/src/main/assets/revoked_certs.txt"
|
||||||
private val UPDATE_INTERVAL = TimeUnit.DAYS.toMillis(1)
|
private val UPDATE_INTERVAL = TimeUnit.DAYS.toMillis(1)
|
||||||
|
|
|
@ -16,8 +16,10 @@ import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLoggerProduction;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||||
|
@ -36,13 +38,16 @@ public class StorageConstraintPlugin extends PluginBase implements ConstraintsIn
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: dagger
|
||||||
|
|
||||||
public StorageConstraintPlugin() {
|
public StorageConstraintPlugin() {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.CONSTRAINTS)
|
.mainType(PluginType.CONSTRAINTS)
|
||||||
.neverVisible(true)
|
.neverVisible(true)
|
||||||
.alwaysEnabled(true)
|
.alwaysEnabled(true)
|
||||||
.showInList(false)
|
.showInList(false)
|
||||||
.pluginName(R.string.storage)
|
.pluginName(R.string.storage),
|
||||||
|
new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import info.nightscout.androidaps.interfaces.ConstraintsInterface
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification
|
||||||
|
@ -20,16 +21,18 @@ import kotlin.math.roundToInt
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class VersionCheckerPlugin @Inject constructor(
|
class VersionCheckerPlugin @Inject constructor(
|
||||||
private val rxBus: RxBusWrapper,
|
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val resourceHelper: ResourceHelper,
|
private val resourceHelper: ResourceHelper,
|
||||||
private val versionCheckerUtils: VersionCheckerUtils
|
private val versionCheckerUtils: VersionCheckerUtils,
|
||||||
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.CONSTRAINTS)
|
.mainType(PluginType.CONSTRAINTS)
|
||||||
.neverVisible(true)
|
.neverVisible(true)
|
||||||
.alwaysEnabled(true)
|
.alwaysEnabled(true)
|
||||||
.showInList(false)
|
.showInList(false)
|
||||||
.pluginName(R.string.versionChecker)), ConstraintsInterface {
|
.pluginName(R.string.versionChecker),
|
||||||
|
rxBus, aapsLogger
|
||||||
|
), ConstraintsInterface {
|
||||||
|
|
||||||
enum class GracePeriod(val warning: Long, val old: Long, val veryOld: Long) {
|
enum class GracePeriod(val warning: Long, val old: Long, val veryOld: Long) {
|
||||||
RELEASE(30, 60, 90),
|
RELEASE(30, 60, 90),
|
||||||
|
|
|
@ -5,15 +5,20 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class ActionsPlugin @Inject constructor(): PluginBase(PluginDescription()
|
class ActionsPlugin @Inject constructor(rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
.mainType(PluginType.GENERAL)
|
) : PluginBase(PluginDescription()
|
||||||
.fragmentClass(ActionsFragment::class.qualifiedName)
|
.mainType(PluginType.GENERAL)
|
||||||
.enableByDefault(Config.APS || Config.PUMPCONTROL)
|
.fragmentClass(ActionsFragment::class.qualifiedName)
|
||||||
.visibleByDefault(Config.APS || Config.PUMPCONTROL)
|
.enableByDefault(Config.APS || Config.PUMPCONTROL)
|
||||||
.pluginName(R.string.actions)
|
.visibleByDefault(Config.APS || Config.PUMPCONTROL)
|
||||||
.shortName(R.string.actions_shortname)
|
.pluginName(R.string.actions)
|
||||||
.description(R.string.description_actions))
|
.shortName(R.string.actions_shortname)
|
||||||
|
.description(R.string.description_actions),
|
||||||
|
rxBus, aapsLogger
|
||||||
|
)
|
||||||
|
|
|
@ -40,20 +40,20 @@ import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class AutomationPlugin @Inject constructor(
|
class AutomationPlugin @Inject constructor(
|
||||||
private val rxBus: RxBusWrapper,
|
|
||||||
private val aapsLogger: AAPSLogger,
|
|
||||||
private val resourceHelper: ResourceHelper,
|
private val resourceHelper: ResourceHelper,
|
||||||
private val mainApp: MainApp,
|
private val mainApp: MainApp,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val fabricPrivacy: FabricPrivacy,
|
private val fabricPrivacy: FabricPrivacy,
|
||||||
private val loopPlugin: LoopPlugin
|
private val loopPlugin: LoopPlugin,
|
||||||
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
.fragmentClass(AutomationFragment::class.qualifiedName)
|
.fragmentClass(AutomationFragment::class.qualifiedName)
|
||||||
.pluginName(R.string.automation)
|
.pluginName(R.string.automation)
|
||||||
.shortName(R.string.automation_short)
|
.shortName(R.string.automation_short)
|
||||||
.preferencesId(R.xml.pref_automation)
|
.preferencesId(R.xml.pref_automation)
|
||||||
.description(R.string.automation_description)) {
|
.description(R.string.automation_description), rxBus, aapsLogger
|
||||||
|
) {
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ import info.nightscout.androidaps.plugins.general.automation.events.EventTrigger
|
||||||
import info.nightscout.androidaps.plugins.general.automation.events.EventTriggerRemove
|
import info.nightscout.androidaps.plugins.general.automation.events.EventTriggerRemove
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
|
import info.nightscout.androidaps.services.LastLocationDataContainer
|
||||||
import info.nightscout.androidaps.services.LocationService
|
import info.nightscout.androidaps.services.LocationService
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
@ -34,7 +35,7 @@ abstract class Trigger(val mainApp: MainApp) {
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
@Inject lateinit var resourceHelper: ResourceHelper
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
@Inject lateinit var profileFunction: ProfileFunction
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var locationService: LocationService
|
@Inject lateinit var locationDataContainer: LastLocationDataContainer
|
||||||
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
||||||
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
||||||
@Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin
|
@Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin
|
||||||
|
|
|
@ -20,10 +20,9 @@ class TriggerLocation(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
|
|
||||||
var lastMode = InputLocationMode.Mode.INSIDE
|
var lastMode = InputLocationMode.Mode.INSIDE
|
||||||
private val buttonAction = Runnable {
|
private val buttonAction = Runnable {
|
||||||
val location = locationService.lastLocation
|
locationDataContainer.lastLocation?.let {
|
||||||
if (location != null) {
|
latitude.value = it.latitude
|
||||||
latitude.value = location.latitude
|
longitude.value = it.longitude
|
||||||
longitude.value = location.longitude
|
|
||||||
aapsLogger.debug(LTag.AUTOMATION, String.format("Grabbed location: %f %f", latitude.value, longitude.value))
|
aapsLogger.debug(LTag.AUTOMATION, String.format("Grabbed location: %f %f", latitude.value, longitude.value))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,7 +38,7 @@ class TriggerLocation(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Synchronized override fun shouldRun(): Boolean {
|
@Synchronized override fun shouldRun(): Boolean {
|
||||||
val location: Location = locationService.lastLocation ?: return false
|
val location: Location = locationDataContainer.lastLocation ?: return false
|
||||||
val a = Location("Trigger")
|
val a = Location("Trigger")
|
||||||
a.latitude = latitude.value
|
a.latitude = latitude.value
|
||||||
a.longitude = longitude.value
|
a.longitude = longitude.value
|
||||||
|
@ -98,7 +97,7 @@ class TriggerLocation(mainApp: MainApp) : Trigger(mainApp) {
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.longitude_short), "", longitude))
|
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.longitude_short), "", longitude))
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.distance_short), "", distance))
|
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.distance_short), "", distance))
|
||||||
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.location_mode), "", modeSelected))
|
.add(LabelWithElement(mainApp, resourceHelper.gs(R.string.location_mode), "", modeSelected))
|
||||||
.add(InputButton(mainApp, resourceHelper.gs(R.string.currentlocation), buttonAction), locationService.lastLocation != null)
|
.add(InputButton(mainApp, resourceHelper.gs(R.string.currentlocation), buttonAction), locationDataContainer.lastLocation != null)
|
||||||
.build(root)
|
.build(root)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,18 +5,23 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class CareportalPlugin @Inject constructor() : PluginBase(PluginDescription()
|
class CareportalPlugin @Inject constructor(rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
.fragmentClass(CareportalFragment::class.java.name)
|
.fragmentClass(CareportalFragment::class.java.name)
|
||||||
.pluginName(R.string.careportal)
|
.pluginName(R.string.careportal)
|
||||||
.shortName(R.string.careportal_shortname)
|
.shortName(R.string.careportal_shortname)
|
||||||
.visibleByDefault(Config.NSCLIENT)
|
.visibleByDefault(Config.NSCLIENT)
|
||||||
.enableByDefault(Config.NSCLIENT)
|
.enableByDefault(Config.NSCLIENT)
|
||||||
.description(R.string.description_careportal)
|
.description(R.string.description_careportal),
|
||||||
|
rxBus, aapsLogger
|
||||||
|
|
||||||
) {
|
) {
|
||||||
|
|
||||||
override fun specialEnableCondition(): Boolean {
|
override fun specialEnableCondition(): Boolean {
|
||||||
|
|
|
@ -4,16 +4,20 @@ import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class FoodPlugin @Inject constructor() : PluginBase(PluginDescription()
|
class FoodPlugin @Inject constructor(rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
.fragmentClass(FoodFragment::class.java.name)
|
.fragmentClass(FoodFragment::class.java.name)
|
||||||
.pluginName(R.string.food)
|
.pluginName(R.string.food)
|
||||||
.shortName(R.string.food_short)
|
.shortName(R.string.food_short)
|
||||||
.description(R.string.description_food)
|
.description(R.string.description_food),
|
||||||
|
rxBus, aapsLogger
|
||||||
) {
|
) {
|
||||||
|
|
||||||
var service: FoodService? = null
|
var service: FoodService? = null
|
||||||
|
|
|
@ -11,6 +11,7 @@ import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
@ -23,11 +24,11 @@ import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class MaintenancePlugin @Inject constructor(
|
class MaintenancePlugin @Inject constructor(
|
||||||
private val aapsLogger: AAPSLogger,
|
|
||||||
private val mainApp: MainApp,
|
private val mainApp: MainApp,
|
||||||
private val resourceHelper: ResourceHelper,
|
private val resourceHelper: ResourceHelper,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val nsSettingsStatus: NSSettingsStatus
|
private val nsSettingsStatus: NSSettingsStatus,
|
||||||
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
.fragmentClass(MaintenanceFragment::class.java.name)
|
.fragmentClass(MaintenanceFragment::class.java.name)
|
||||||
|
@ -36,7 +37,8 @@ class MaintenancePlugin @Inject constructor(
|
||||||
.pluginName(R.string.maintenance)
|
.pluginName(R.string.maintenance)
|
||||||
.shortName(R.string.maintenance_shortname)
|
.shortName(R.string.maintenance_shortname)
|
||||||
.preferencesId(R.xml.pref_maintenance)
|
.preferencesId(R.xml.pref_maintenance)
|
||||||
.description(R.string.description_maintenance)
|
.description(R.string.description_maintenance),
|
||||||
|
rxBus, aapsLogger
|
||||||
) {
|
) {
|
||||||
|
|
||||||
fun sendLogs() {
|
fun sendLogs() {
|
||||||
|
|
|
@ -30,8 +30,10 @@ import info.nightscout.androidaps.events.EventPreferenceChange;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLoggerProduction;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.data.AlarmAck;
|
import info.nightscout.androidaps.plugins.general.nsclient.data.AlarmAck;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSAlarm;
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSAlarm;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientNewLog;
|
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientNewLog;
|
||||||
|
@ -71,6 +73,8 @@ public class NSClientPlugin extends PluginBase {
|
||||||
|
|
||||||
private NsClientReceiverDelegate nsClientReceiverDelegate;
|
private NsClientReceiverDelegate nsClientReceiverDelegate;
|
||||||
|
|
||||||
|
// TODO: dagger
|
||||||
|
|
||||||
private NSClientPlugin() {
|
private NSClientPlugin() {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
|
@ -78,11 +82,12 @@ public class NSClientPlugin extends PluginBase {
|
||||||
.pluginName(R.string.nsclientinternal)
|
.pluginName(R.string.nsclientinternal)
|
||||||
.shortName(R.string.nsclientinternal_shortname)
|
.shortName(R.string.nsclientinternal_shortname)
|
||||||
.preferencesId(R.xml.pref_nsclientinternal)
|
.preferencesId(R.xml.pref_nsclientinternal)
|
||||||
.description(R.string.description_ns_client)
|
.description(R.string.description_ns_client),
|
||||||
|
new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Config.NSCLIENT) {
|
if (Config.NSCLIENT) {
|
||||||
pluginDescription.alwaysEnabled(true).visibleByDefault(true);
|
getPluginDescription().alwaysEnabled(true).visibleByDefault(true);
|
||||||
}
|
}
|
||||||
paused = SP.getBoolean(R.string.key_nsclientinternal_paused, false);
|
paused = SP.getBoolean(R.string.key_nsclientinternal_paused, false);
|
||||||
autoscroll = SP.getBoolean(R.string.key_nsclientinternal_autoscroll, true);
|
autoscroll = SP.getBoolean(R.string.key_nsclientinternal_autoscroll, true);
|
||||||
|
|
|
@ -5,6 +5,7 @@ import info.nightscout.androidaps.events.EventRefreshOverview
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
|
import info.nightscout.androidaps.plugins.general.overview.events.EventDismissNotification
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||||
|
@ -18,9 +19,9 @@ import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class OverviewPlugin @Inject constructor(
|
class OverviewPlugin @Inject constructor(
|
||||||
private val rxBus: RxBusWrapper,
|
|
||||||
private val notificationStore: NotificationStore,
|
private val notificationStore: NotificationStore,
|
||||||
private val fabricPrivacy: FabricPrivacy
|
private val fabricPrivacy: FabricPrivacy,
|
||||||
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
.fragmentClass(OverviewFragment::class.qualifiedName)
|
.fragmentClass(OverviewFragment::class.qualifiedName)
|
||||||
|
@ -29,7 +30,8 @@ class OverviewPlugin @Inject constructor(
|
||||||
.pluginName(R.string.overview)
|
.pluginName(R.string.overview)
|
||||||
.shortName(R.string.overview_shortname)
|
.shortName(R.string.overview_shortname)
|
||||||
.preferencesId(R.xml.pref_overview)
|
.preferencesId(R.xml.pref_overview)
|
||||||
.description(R.string.description_overview)) {
|
.description(R.string.description_overview), rxBus, aapsLogger
|
||||||
|
) {
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.general.persistentNotification
|
package info.nightscout.androidaps.plugins.general.persistentNotification
|
||||||
|
|
||||||
import android.app.Notification
|
|
||||||
import android.app.NotificationChannel
|
import android.app.NotificationChannel
|
||||||
import android.app.NotificationManager
|
import android.app.NotificationManager
|
||||||
import android.app.PendingIntent
|
import android.app.PendingIntent
|
||||||
|
@ -20,6 +19,7 @@ import info.nightscout.androidaps.events.*
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
|
@ -36,25 +36,27 @@ import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class PersistentNotificationPlugin @Inject constructor() : PluginBase(PluginDescription()
|
class PersistentNotificationPlugin @Inject constructor(
|
||||||
|
var mainApp: MainApp,
|
||||||
|
var resourceHelper: ResourceHelper,
|
||||||
|
var profileFunction: ProfileFunction,
|
||||||
|
var fabricPrivacy: FabricPrivacy,
|
||||||
|
var configBuilderPlugin: ConfigBuilderPlugin,
|
||||||
|
var treatmentsPlugin: TreatmentsPlugin,
|
||||||
|
var iobCobCalculatorPlugin: IobCobCalculatorPlugin,
|
||||||
|
rxBus: RxBusWrapper,
|
||||||
|
aapsLogger: AAPSLogger
|
||||||
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
.neverVisible(true)
|
.neverVisible(true)
|
||||||
.pluginName(R.string.ongoingnotificaction)
|
.pluginName(R.string.ongoingnotificaction)
|
||||||
.enableByDefault(true)
|
.enableByDefault(true)
|
||||||
.alwaysEnabled(true)
|
.alwaysEnabled(true)
|
||||||
.showInList(false)
|
.showInList(false)
|
||||||
.description(R.string.description_persistent_notification)
|
.description(R.string.description_persistent_notification),
|
||||||
|
rxBus, aapsLogger
|
||||||
) {
|
) {
|
||||||
|
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
|
||||||
@Inject lateinit var mainApp: MainApp
|
|
||||||
@Inject lateinit var resourceHelper: ResourceHelper
|
|
||||||
@Inject lateinit var profileFunction: ProfileFunction
|
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
|
||||||
@Inject lateinit var configBuilderPlugin: ConfigBuilderPlugin
|
|
||||||
@Inject lateinit var treatmentsPlugin: TreatmentsPlugin
|
|
||||||
@Inject lateinit var iobCobCalculatorPlugin: IobCobCalculatorPlugin
|
|
||||||
|
|
||||||
// For Android Auto
|
// For Android Auto
|
||||||
// Intents are not declared in manifest and not consumed, this is intentionally because actually we can't do anything with
|
// Intents are not declared in manifest and not consumed, this is intentionally because actually we can't do anything with
|
||||||
private val PACKAGE = "info.nightscout"
|
private val PACKAGE = "info.nightscout"
|
||||||
|
@ -66,7 +68,7 @@ class PersistentNotificationPlugin @Inject constructor() : PluginBase(PluginDesc
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
super.onStart()
|
super.onStart()
|
||||||
createNotificationChannel() // make sure channels exist before triggering updates through the bus
|
createNotificationChannel() // make sure channels exist before triggering updates through the bus
|
||||||
disposable.add(rxBus
|
disposable.add(rxBus
|
||||||
|
|
|
@ -55,8 +55,8 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val resourceHelper: ResourceHelper,
|
private val resourceHelper: ResourceHelper,
|
||||||
private val constraintChecker: ConstraintChecker,
|
private val constraintChecker: ConstraintChecker,
|
||||||
private val aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
private val rxBus: RxBusWrapper,
|
rxBus: RxBusWrapper,
|
||||||
private val profileFunction: ProfileFunction,
|
private val profileFunction: ProfileFunction,
|
||||||
private val fabricPrivacy: FabricPrivacy,
|
private val fabricPrivacy: FabricPrivacy,
|
||||||
private val configBuilderPlugin: ConfigBuilderPlugin,
|
private val configBuilderPlugin: ConfigBuilderPlugin,
|
||||||
|
@ -69,7 +69,8 @@ class SmsCommunicatorPlugin @Inject constructor(
|
||||||
.pluginName(R.string.smscommunicator)
|
.pluginName(R.string.smscommunicator)
|
||||||
.shortName(R.string.smscommunicator_shortname)
|
.shortName(R.string.smscommunicator_shortname)
|
||||||
.preferencesId(R.xml.pref_smscommunicator)
|
.preferencesId(R.xml.pref_smscommunicator)
|
||||||
.description(R.string.description_sms_communicator)
|
.description(R.string.description_sms_communicator),
|
||||||
|
rxBus, aapsLogger
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
|
@ -40,8 +40,8 @@ import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class TidepoolPlugin @Inject constructor(
|
class TidepoolPlugin @Inject constructor(
|
||||||
private val aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
private val rxBus: RxBusWrapper,
|
rxBus: RxBusWrapper,
|
||||||
private val mainApp: MainApp,
|
private val mainApp: MainApp,
|
||||||
private val resourceHelper: ResourceHelper,
|
private val resourceHelper: ResourceHelper,
|
||||||
private val fabricPrivacy: FabricPrivacy,
|
private val fabricPrivacy: FabricPrivacy,
|
||||||
|
@ -54,7 +54,8 @@ class TidepoolPlugin @Inject constructor(
|
||||||
.shortName(R.string.tidepool_shortname)
|
.shortName(R.string.tidepool_shortname)
|
||||||
.fragmentClass(TidepoolFragment::class.qualifiedName)
|
.fragmentClass(TidepoolFragment::class.qualifiedName)
|
||||||
.preferencesId(R.xml.pref_tidepool)
|
.preferencesId(R.xml.pref_tidepool)
|
||||||
.description(R.string.description_tidepool)
|
.description(R.string.description_tidepool),
|
||||||
|
rxBus, aapsLogger
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private var disposable: CompositeDisposable = CompositeDisposable()
|
private var disposable: CompositeDisposable = CompositeDisposable()
|
||||||
|
|
|
@ -8,6 +8,7 @@ import info.nightscout.androidaps.events.*
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui
|
import info.nightscout.androidaps.plugins.aps.openAPSMA.events.EventOpenAPSUpdateGui
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
|
@ -25,19 +26,21 @@ import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class WearPlugin @Inject constructor(
|
class WearPlugin @Inject constructor(
|
||||||
private val rxBus: RxBusWrapper,
|
|
||||||
private val resourceHelper: ResourceHelper,
|
private val resourceHelper: ResourceHelper,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val mainApp: MainApp,
|
private val mainApp: MainApp,
|
||||||
private val fabricPrivacy: FabricPrivacy,
|
private val fabricPrivacy: FabricPrivacy,
|
||||||
private val loopPlugin: Lazy<LoopPlugin>
|
private val loopPlugin: Lazy<LoopPlugin>,
|
||||||
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
|
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
.fragmentClass(WearFragment::class.java.name)
|
.fragmentClass(WearFragment::class.java.name)
|
||||||
.pluginName(R.string.wear)
|
.pluginName(R.string.wear)
|
||||||
.shortName(R.string.wear_shortname)
|
.shortName(R.string.wear_shortname)
|
||||||
.preferencesId(R.xml.pref_wear)
|
.preferencesId(R.xml.pref_wear)
|
||||||
.description(R.string.description_wear)
|
.description(R.string.description_wear),
|
||||||
|
rxBus, aapsLogger
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
|
|
|
@ -9,6 +9,7 @@ import info.nightscout.androidaps.events.*
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
|
@ -29,7 +30,6 @@ import javax.inject.Singleton
|
||||||
@Singleton
|
@Singleton
|
||||||
class StatusLinePlugin @Inject constructor(
|
class StatusLinePlugin @Inject constructor(
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val rxBus: RxBusWrapper,
|
|
||||||
private val profileFunction: ProfileFunction,
|
private val profileFunction: ProfileFunction,
|
||||||
private val resourceHelper: ResourceHelper,
|
private val resourceHelper: ResourceHelper,
|
||||||
private val mainApp: MainApp,
|
private val mainApp: MainApp,
|
||||||
|
@ -37,7 +37,8 @@ class StatusLinePlugin @Inject constructor(
|
||||||
private val configBuilderPlugin: ConfigBuilderPlugin,
|
private val configBuilderPlugin: ConfigBuilderPlugin,
|
||||||
private val treatmentsPlugin: TreatmentsPlugin,
|
private val treatmentsPlugin: TreatmentsPlugin,
|
||||||
private val loopPlugin: LoopPlugin,
|
private val loopPlugin: LoopPlugin,
|
||||||
private val iobCobCalculatorPlugin: IobCobCalculatorPlugin
|
private val iobCobCalculatorPlugin: IobCobCalculatorPlugin,
|
||||||
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
) : PluginBase(
|
) : PluginBase(
|
||||||
PluginDescription()
|
PluginDescription()
|
||||||
.mainType(PluginType.GENERAL)
|
.mainType(PluginType.GENERAL)
|
||||||
|
@ -45,7 +46,7 @@ class StatusLinePlugin @Inject constructor(
|
||||||
.shortName(R.string.xdripstatus_shortname)
|
.shortName(R.string.xdripstatus_shortname)
|
||||||
.neverVisible(true)
|
.neverVisible(true)
|
||||||
.preferencesId(R.xml.pref_xdripstatus)
|
.preferencesId(R.xml.pref_xdripstatus)
|
||||||
.description(R.string.description_xdrip_status_line)) {
|
.description(R.string.description_xdrip_status_line), rxBus, aapsLogger) {
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
private var lastLoopStatus = false
|
private var lastLoopStatus = false
|
||||||
|
|
|
@ -6,6 +6,7 @@ import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase
|
import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification
|
||||||
|
@ -20,14 +21,15 @@ import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
abstract class InsulinOrefBasePlugin(
|
abstract class InsulinOrefBasePlugin(
|
||||||
val rxBus: RxBusWrapper,
|
|
||||||
val resourceHelper: ResourceHelper,
|
val resourceHelper: ResourceHelper,
|
||||||
val profileFunction: ProfileFunction
|
val profileFunction: ProfileFunction,
|
||||||
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.INSULIN)
|
.mainType(PluginType.INSULIN)
|
||||||
.fragmentClass(InsulinFragment::class.java.name)
|
.fragmentClass(InsulinFragment::class.java.name)
|
||||||
.shortName(R.string.insulin_shortname)
|
.shortName(R.string.insulin_shortname)
|
||||||
.visibleByDefault(false)
|
.visibleByDefault(false),
|
||||||
|
rxBus, aapsLogger
|
||||||
), InsulinInterface {
|
), InsulinInterface {
|
||||||
|
|
||||||
private var lastWarned: Long = 0
|
private var lastWarned: Long = 0
|
||||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.plugins.insulin
|
||||||
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface
|
import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
@ -16,9 +17,9 @@ import javax.inject.Singleton
|
||||||
class InsulinOrefFreePeakPlugin @Inject constructor(
|
class InsulinOrefFreePeakPlugin @Inject constructor(
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
rxBus: RxBusWrapper,
|
profileFunction: ProfileFunction,
|
||||||
profileFunction: ProfileFunction
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
) : InsulinOrefBasePlugin(rxBus, resourceHelper, profileFunction) {
|
) : InsulinOrefBasePlugin(resourceHelper, profileFunction, rxBus, aapsLogger) {
|
||||||
|
|
||||||
override fun getId(): Int {
|
override fun getId(): Int {
|
||||||
return InsulinInterface.OREF_FREE_PEAK
|
return InsulinInterface.OREF_FREE_PEAK
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
package info.nightscout.androidaps.plugins.insulin
|
package info.nightscout.androidaps.plugins.insulin
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface
|
import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
@ -16,9 +15,9 @@ import javax.inject.Singleton
|
||||||
@Singleton
|
@Singleton
|
||||||
class InsulinOrefRapidActingPlugin @Inject constructor(
|
class InsulinOrefRapidActingPlugin @Inject constructor(
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
rxBus: RxBusWrapper,
|
profileFunction: ProfileFunction,
|
||||||
profileFunction: ProfileFunction
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
) : InsulinOrefBasePlugin(rxBus, resourceHelper, profileFunction) {
|
) : InsulinOrefBasePlugin(resourceHelper, profileFunction, rxBus, aapsLogger) {
|
||||||
|
|
||||||
|
|
||||||
override fun getId(): Int {
|
override fun getId(): Int {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package info.nightscout.androidaps.plugins.insulin
|
package info.nightscout.androidaps.plugins.insulin
|
||||||
|
|
||||||
import info.nightscout.androidaps.MainApp
|
|
||||||
import info.nightscout.androidaps.R
|
import info.nightscout.androidaps.R
|
||||||
import info.nightscout.androidaps.interfaces.InsulinInterface
|
import info.nightscout.androidaps.interfaces.InsulinInterface
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
import info.nightscout.androidaps.utils.resources.ResourceHelper
|
||||||
|
@ -15,11 +15,10 @@ import javax.inject.Singleton
|
||||||
*/
|
*/
|
||||||
@Singleton
|
@Singleton
|
||||||
class InsulinOrefUltraRapidActingPlugin @Inject constructor(
|
class InsulinOrefUltraRapidActingPlugin @Inject constructor(
|
||||||
private val sp: SP,
|
|
||||||
resourceHelper: ResourceHelper,
|
resourceHelper: ResourceHelper,
|
||||||
rxBus: RxBusWrapper,
|
profileFunction: ProfileFunction,
|
||||||
profileFunction: ProfileFunction
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
) : InsulinOrefBasePlugin(rxBus, resourceHelper, profileFunction) {
|
) : InsulinOrefBasePlugin(resourceHelper, profileFunction, rxBus, aapsLogger) {
|
||||||
|
|
||||||
|
|
||||||
override fun getId(): Int {
|
override fun getId(): Int {
|
||||||
|
|
|
@ -55,8 +55,6 @@ import static info.nightscout.androidaps.utils.DateUtil.now;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class IobCobCalculatorPlugin extends PluginBase {
|
public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
private final AAPSLogger aapsLogger;
|
|
||||||
private final RxBusWrapper rxBus;
|
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
private final ProfileFunction profileFunction;
|
private final ProfileFunction profileFunction;
|
||||||
|
@ -101,11 +99,10 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
.pluginName(R.string.iobcobcalculator)
|
.pluginName(R.string.iobcobcalculator)
|
||||||
.showInList(false)
|
.showInList(false)
|
||||||
.neverVisible(true)
|
.neverVisible(true)
|
||||||
.alwaysEnabled(true)
|
.alwaysEnabled(true),
|
||||||
|
rxBus, aapsLogger
|
||||||
);
|
);
|
||||||
this.plugin = this;
|
this.plugin = this;
|
||||||
this.aapsLogger = aapsLogger;
|
|
||||||
this.rxBus = rxBus;
|
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
this.profileFunction = profileFunction;
|
this.profileFunction = profileFunction;
|
||||||
|
@ -117,13 +114,13 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
// EventConfigBuilderChange
|
// EventConfigBuilderChange
|
||||||
disposable.add(rxBus
|
disposable.add(getRxBus()
|
||||||
.toObservable(EventConfigBuilderChange.class)
|
.toObservable(EventConfigBuilderChange.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
stopCalculation("onEventConfigBuilderChange");
|
stopCalculation("onEventConfigBuilderChange");
|
||||||
synchronized (dataLock) {
|
synchronized (dataLock) {
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Invalidating cached data because of configuration change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records");
|
getAapsLogger().debug(LTag.AUTOSENS, "Invalidating cached data because of configuration change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records");
|
||||||
iobTable = new LongSparseArray<>();
|
iobTable = new LongSparseArray<>();
|
||||||
autosensDataTable = new LongSparseArray<>();
|
autosensDataTable = new LongSparseArray<>();
|
||||||
}
|
}
|
||||||
|
@ -131,7 +128,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
}, exception -> FabricPrivacy.getInstance().logException(exception))
|
}, exception -> FabricPrivacy.getInstance().logException(exception))
|
||||||
);
|
);
|
||||||
// EventNewBasalProfile
|
// EventNewBasalProfile
|
||||||
disposable.add(rxBus
|
disposable.add(getRxBus()
|
||||||
.toObservable(EventNewBasalProfile.class)
|
.toObservable(EventNewBasalProfile.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
|
@ -140,7 +137,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
stopCalculation("onNewProfile");
|
stopCalculation("onNewProfile");
|
||||||
synchronized (dataLock) {
|
synchronized (dataLock) {
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Invalidating cached data because of new profile. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records");
|
getAapsLogger().debug(LTag.AUTOSENS, "Invalidating cached data because of new profile. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records");
|
||||||
iobTable = new LongSparseArray<>();
|
iobTable = new LongSparseArray<>();
|
||||||
autosensDataTable = new LongSparseArray<>();
|
autosensDataTable = new LongSparseArray<>();
|
||||||
basalDataTable = new LongSparseArray<>();
|
basalDataTable = new LongSparseArray<>();
|
||||||
|
@ -149,7 +146,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
}, exception -> FabricPrivacy.getInstance().logException(exception))
|
}, exception -> FabricPrivacy.getInstance().logException(exception))
|
||||||
);
|
);
|
||||||
// EventNewBG
|
// EventNewBG
|
||||||
disposable.add(rxBus
|
disposable.add(getRxBus()
|
||||||
.toObservable(EventNewBG.class)
|
.toObservable(EventNewBG.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
|
@ -158,7 +155,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
}, exception -> FabricPrivacy.getInstance().logException(exception))
|
}, exception -> FabricPrivacy.getInstance().logException(exception))
|
||||||
);
|
);
|
||||||
// EventPreferenceChange
|
// EventPreferenceChange
|
||||||
disposable.add(rxBus
|
disposable.add(getRxBus()
|
||||||
.toObservable(EventPreferenceChange.class)
|
.toObservable(EventPreferenceChange.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
|
@ -173,7 +170,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
) {
|
) {
|
||||||
stopCalculation("onEventPreferenceChange");
|
stopCalculation("onEventPreferenceChange");
|
||||||
synchronized (dataLock) {
|
synchronized (dataLock) {
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Invalidating cached data because of preference change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records" + " BasalData: " + basalDataTable.size() + " records");
|
getAapsLogger().debug(LTag.AUTOSENS, "Invalidating cached data because of preference change. IOB: " + iobTable.size() + " Autosens: " + autosensDataTable.size() + " records" + " BasalData: " + basalDataTable.size() + " records");
|
||||||
iobTable = new LongSparseArray<>();
|
iobTable = new LongSparseArray<>();
|
||||||
autosensDataTable = new LongSparseArray<>();
|
autosensDataTable = new LongSparseArray<>();
|
||||||
basalDataTable = new LongSparseArray<>();
|
basalDataTable = new LongSparseArray<>();
|
||||||
|
@ -183,13 +180,13 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
}, exception -> FabricPrivacy.getInstance().logException(exception))
|
}, exception -> FabricPrivacy.getInstance().logException(exception))
|
||||||
);
|
);
|
||||||
// EventAppInitialized
|
// EventAppInitialized
|
||||||
disposable.add(rxBus
|
disposable.add(getRxBus()
|
||||||
.toObservable(EventAppInitialized.class)
|
.toObservable(EventAppInitialized.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> runCalculation("onEventAppInitialized", System.currentTimeMillis(), true, true, event), exception -> FabricPrivacy.getInstance().logException(exception))
|
.subscribe(event -> runCalculation("onEventAppInitialized", System.currentTimeMillis(), true, true, event), exception -> FabricPrivacy.getInstance().logException(exception))
|
||||||
);
|
);
|
||||||
// EventNewHistoryData
|
// EventNewHistoryData
|
||||||
disposable.add(rxBus
|
disposable.add(getRxBus()
|
||||||
.toObservable(EventNewHistoryData.class)
|
.toObservable(EventNewHistoryData.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> newHistoryData(event), exception -> FabricPrivacy.getInstance().logException(exception))
|
.subscribe(event -> newHistoryData(event), exception -> FabricPrivacy.getInstance().logException(exception))
|
||||||
|
@ -239,10 +236,10 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
// if close to now expect there can be some readings with time in close future (caused by wrong time setting)
|
// if close to now expect there can be some readings with time in close future (caused by wrong time setting)
|
||||||
// so read all records
|
// so read all records
|
||||||
bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, false);
|
bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, false);
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "BG data loaded. Size: " + bgReadings.size() + " Start date: " + DateUtil.dateAndTimeString(start));
|
getAapsLogger().debug(LTag.AUTOSENS, "BG data loaded. Size: " + bgReadings.size() + " Start date: " + DateUtil.dateAndTimeString(start));
|
||||||
} else {
|
} else {
|
||||||
bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, to, false);
|
bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(start, to, false);
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "BG data loaded. Size: " + bgReadings.size() + " Start date: " + DateUtil.dateAndTimeString(start) + " End date: " + DateUtil.dateAndTimeString(to));
|
getAapsLogger().debug(LTag.AUTOSENS, "BG data loaded. Size: " + bgReadings.size() + " Start date: " + DateUtil.dateAndTimeString(start) + " End date: " + DateUtil.dateAndTimeString(to));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -262,13 +259,13 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
totalDiff += diff;
|
totalDiff += diff;
|
||||||
diff = Math.abs(diff);
|
diff = Math.abs(diff);
|
||||||
if (diff > T.secs(30).msecs()) {
|
if (diff > T.secs(30).msecs()) {
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Interval detection: values: " + bgReadings.size() + " diff: " + (diff / 1000) + "[s] is5minData: " + false);
|
getAapsLogger().debug(LTag.AUTOSENS, "Interval detection: values: " + bgReadings.size() + " diff: " + (diff / 1000) + "[s] is5minData: " + false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
long averageDiff = totalDiff / bgReadings.size() / 1000;
|
long averageDiff = totalDiff / bgReadings.size() / 1000;
|
||||||
boolean is5mindata = averageDiff < 1;
|
boolean is5mindata = averageDiff < 1;
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Interval detection: values: " + bgReadings.size() + " averageDiff: " + averageDiff + "[s] is5minData: " + is5mindata);
|
getAapsLogger().debug(LTag.AUTOSENS, "Interval detection: values: " + bgReadings.size() + " averageDiff: " + averageDiff + "[s] is5minData: " + is5mindata);
|
||||||
return is5mindata;
|
return is5mindata;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -350,7 +347,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
|
|
||||||
bucketed_data = new ArrayList<>();
|
bucketed_data = new ArrayList<>();
|
||||||
bucketed_data.add(bgReadings.get(0));
|
bucketed_data.add(bgReadings.get(0));
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgReadings.get(0).date) + " lastbgTime: " + "none-first-value" + " " + bgReadings.get(0).toString());
|
getAapsLogger().debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgReadings.get(0).date) + " lastbgTime: " + "none-first-value" + " " + bgReadings.get(0).toString());
|
||||||
int j = 0;
|
int j = 0;
|
||||||
for (int i = 1; i < bgReadings.size(); ++i) {
|
for (int i = 1; i < bgReadings.size(); ++i) {
|
||||||
long bgTime = bgReadings.get(i).date;
|
long bgTime = bgReadings.get(i).date;
|
||||||
|
@ -378,7 +375,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
newBgreading.value = Math.round(nextbg);
|
newBgreading.value = Math.round(nextbg);
|
||||||
//console.error("Interpolated", bucketed_data[j]);
|
//console.error("Interpolated", bucketed_data[j]);
|
||||||
bucketed_data.add(newBgreading);
|
bucketed_data.add(newBgreading);
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: " + DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString());
|
getAapsLogger().debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: " + DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString());
|
||||||
|
|
||||||
elapsed_minutes = elapsed_minutes - 5;
|
elapsed_minutes = elapsed_minutes - 5;
|
||||||
lastbg = nextbg;
|
lastbg = nextbg;
|
||||||
|
@ -389,14 +386,14 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
newBgreading.value = bgReadings.get(i).value;
|
newBgreading.value = bgReadings.get(i).value;
|
||||||
newBgreading.date = bgTime;
|
newBgreading.date = bgTime;
|
||||||
bucketed_data.add(newBgreading);
|
bucketed_data.add(newBgreading);
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: " + DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString());
|
getAapsLogger().debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: " + DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString());
|
||||||
} else if (Math.abs(elapsed_minutes) > 2) {
|
} else if (Math.abs(elapsed_minutes) > 2) {
|
||||||
j++;
|
j++;
|
||||||
BgReading newBgreading = new BgReading();
|
BgReading newBgreading = new BgReading();
|
||||||
newBgreading.value = bgReadings.get(i).value;
|
newBgreading.value = bgReadings.get(i).value;
|
||||||
newBgreading.date = bgTime;
|
newBgreading.date = bgTime;
|
||||||
bucketed_data.add(newBgreading);
|
bucketed_data.add(newBgreading);
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: " + DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString());
|
getAapsLogger().debug(LTag.AUTOSENS, "Adding. bgTime: " + DateUtil.toISOString(bgTime) + " lastbgTime: " + DateUtil.toISOString(lastbgTime) + " " + newBgreading.toString());
|
||||||
} else {
|
} else {
|
||||||
bucketed_data.get(j).value = (bucketed_data.get(j).value + bgReadings.get(i).value) / 2;
|
bucketed_data.get(j).value = (bucketed_data.get(j).value + bgReadings.get(i).value) / 2;
|
||||||
//log.error("***** Average");
|
//log.error("***** Average");
|
||||||
|
@ -409,17 +406,17 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
BgReading previous = bucketed_data.get(i + 1);
|
BgReading previous = bucketed_data.get(i + 1);
|
||||||
long msecDiff = current.date - previous.date;
|
long msecDiff = current.date - previous.date;
|
||||||
long adjusted = (msecDiff - T.mins(5).msecs()) / 1000;
|
long adjusted = (msecDiff - T.mins(5).msecs()) / 1000;
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Adjusting bucketed data time. Current: " + DateUtil.toISOString(current.date) + " to: " + DateUtil.toISOString(previous.date + T.mins(5).msecs()) + " by " + adjusted + " sec");
|
getAapsLogger().debug(LTag.AUTOSENS, "Adjusting bucketed data time. Current: " + DateUtil.toISOString(current.date) + " to: " + DateUtil.toISOString(previous.date + T.mins(5).msecs()) + " by " + adjusted + " sec");
|
||||||
if (Math.abs(adjusted) > 90) {
|
if (Math.abs(adjusted) > 90) {
|
||||||
// too big adjustment, fallback to non 5 min data
|
// too big adjustment, fallback to non 5 min data
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Fallback to non 5 min data");
|
getAapsLogger().debug(LTag.AUTOSENS, "Fallback to non 5 min data");
|
||||||
createBucketedDataRecalculated();
|
createBucketedDataRecalculated();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
current.date = previous.date + T.mins(5).msecs();
|
current.date = previous.date + T.mins(5).msecs();
|
||||||
}
|
}
|
||||||
|
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Bucketed data created. Size: " + bucketed_data.size());
|
getAapsLogger().debug(LTag.AUTOSENS, "Bucketed data created. Size: " + bucketed_data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
long calculateDetectionStart(long from, boolean limitDataToOldestAvailable) {
|
long calculateDetectionStart(long from, boolean limitDataToOldestAvailable) {
|
||||||
|
@ -432,7 +429,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
if (limitDataToOldestAvailable) {
|
if (limitDataToOldestAvailable) {
|
||||||
getBGDataFrom = Math.max(oldestDataAvailable, (long) (from - T.hours(1).msecs() * (24 + dia)));
|
getBGDataFrom = Math.max(oldestDataAvailable, (long) (from - T.hours(1).msecs() * (24 + dia)));
|
||||||
if (getBGDataFrom == oldestDataAvailable)
|
if (getBGDataFrom == oldestDataAvailable)
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Limiting data to oldest available temps: " + DateUtil.dateAndTimeFullString(oldestDataAvailable));
|
getAapsLogger().debug(LTag.AUTOSENS, "Limiting data to oldest available temps: " + DateUtil.dateAndTimeFullString(oldestDataAvailable));
|
||||||
} else
|
} else
|
||||||
getBGDataFrom = (long) (from - T.hours(1).msecs() * (24 + dia));
|
getBGDataFrom = (long) (from - T.hours(1).msecs() * (24 + dia));
|
||||||
return getBGDataFrom;
|
return getBGDataFrom;
|
||||||
|
@ -571,12 +568,12 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
@Nullable
|
@Nullable
|
||||||
public AutosensData getLastAutosensDataSynchronized(String reason) {
|
public AutosensData getLastAutosensDataSynchronized(String reason) {
|
||||||
if (thread != null && thread.isAlive()) {
|
if (thread != null && thread.isAlive()) {
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA is waiting for calculation thread: " + reason);
|
getAapsLogger().debug(LTag.AUTOSENS, "AUTOSENSDATA is waiting for calculation thread: " + reason);
|
||||||
try {
|
try {
|
||||||
thread.join(5000);
|
thread.join(5000);
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
}
|
}
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA finished waiting for calculation thread: " + reason);
|
getAapsLogger().debug(LTag.AUTOSENS, "AUTOSENSDATA finished waiting for calculation thread: " + reason);
|
||||||
}
|
}
|
||||||
synchronized (dataLock) {
|
synchronized (dataLock) {
|
||||||
return getLastAutosensData(reason);
|
return getLastAutosensData(reason);
|
||||||
|
@ -628,7 +625,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
@Nullable
|
@Nullable
|
||||||
public AutosensData getLastAutosensData(String reason) {
|
public AutosensData getLastAutosensData(String reason) {
|
||||||
if (autosensDataTable.size() < 1) {
|
if (autosensDataTable.size() < 1) {
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA null: autosensDataTable empty (" + reason + ")");
|
getAapsLogger().debug(LTag.AUTOSENS, "AUTOSENSDATA null: autosensDataTable empty (" + reason + ")");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
AutosensData data;
|
AutosensData data;
|
||||||
|
@ -638,18 +635,18 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
// data can be processed on the background
|
// data can be processed on the background
|
||||||
// in this rare case better return null and do not block UI
|
// in this rare case better return null and do not block UI
|
||||||
// APS plugin should use getLastAutosensDataSynchronized where the blocking is not an issue
|
// APS plugin should use getLastAutosensDataSynchronized where the blocking is not an issue
|
||||||
aapsLogger.error("AUTOSENSDATA null: Exception catched (" + reason + ")");
|
getAapsLogger().error("AUTOSENSDATA null: Exception catched (" + reason + ")");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
aapsLogger.error("AUTOSENSDATA null: data==null");
|
getAapsLogger().error("AUTOSENSDATA null: data==null");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (data.time < System.currentTimeMillis() - 11 * 60 * 1000) {
|
if (data.time < System.currentTimeMillis() - 11 * 60 * 1000) {
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA null: data is old (" + reason + ") size()=" + autosensDataTable.size() + " lastdata=" + DateUtil.dateAndTimeString(data.time));
|
getAapsLogger().debug(LTag.AUTOSENS, "AUTOSENSDATA null: data is old (" + reason + ") size()=" + autosensDataTable.size() + " lastdata=" + DateUtil.dateAndTimeString(data.time));
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "AUTOSENSDATA (" + reason + ") " + data.toString());
|
getAapsLogger().debug(LTag.AUTOSENS, "AUTOSENSDATA (" + reason + ") " + data.toString());
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -769,16 +766,16 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
public void stopCalculation(String from) {
|
public void stopCalculation(String from) {
|
||||||
if (thread != null && thread.getState() != Thread.State.TERMINATED) {
|
if (thread != null && thread.getState() != Thread.State.TERMINATED) {
|
||||||
stopCalculationTrigger = true;
|
stopCalculationTrigger = true;
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Stopping calculation thread: " + from);
|
getAapsLogger().debug(LTag.AUTOSENS, "Stopping calculation thread: " + from);
|
||||||
while (thread.getState() != Thread.State.TERMINATED) {
|
while (thread.getState() != Thread.State.TERMINATED) {
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
}
|
}
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Calculation thread stopped: " + from);
|
getAapsLogger().debug(LTag.AUTOSENS, "Calculation thread stopped: " + from);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runCalculation(String from, long end, boolean bgDataReload, boolean limitDataToOldestAvailable, Event cause) {
|
public void runCalculation(String from, long end, boolean bgDataReload, boolean limitDataToOldestAvailable, Event cause) {
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Starting calculation thread: " + from + " to " + DateUtil.dateAndTimeString(end));
|
getAapsLogger().debug(LTag.AUTOSENS, "Starting calculation thread: " + from + " to " + DateUtil.dateAndTimeString(end));
|
||||||
if (thread == null || thread.getState() == Thread.State.TERMINATED) {
|
if (thread == null || thread.getState() == Thread.State.TERMINATED) {
|
||||||
if (SensitivityOref1Plugin.getPlugin().isEnabled(PluginType.SENSITIVITY))
|
if (SensitivityOref1Plugin.getPlugin().isEnabled(PluginType.SENSITIVITY))
|
||||||
thread = new IobCobOref1Thread(this, from, end, bgDataReload, limitDataToOldestAvailable, cause);
|
thread = new IobCobOref1Thread(this, from, end, bgDataReload, limitDataToOldestAvailable, cause);
|
||||||
|
@ -795,10 +792,10 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
synchronized (dataLock) {
|
synchronized (dataLock) {
|
||||||
// clear up 5 min back for proper COB calculation
|
// clear up 5 min back for proper COB calculation
|
||||||
long time = ev.getTime() - 5 * 60 * 1000L;
|
long time = ev.getTime() - 5 * 60 * 1000L;
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Invalidating cached data to: " + DateUtil.dateAndTimeFullString(time));
|
getAapsLogger().debug(LTag.AUTOSENS, "Invalidating cached data to: " + DateUtil.dateAndTimeFullString(time));
|
||||||
for (int index = iobTable.size() - 1; index >= 0; index--) {
|
for (int index = iobTable.size() - 1; index >= 0; index--) {
|
||||||
if (iobTable.keyAt(index) > time) {
|
if (iobTable.keyAt(index) > time) {
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Removing from iobTable: " + DateUtil.dateAndTimeFullString(iobTable.keyAt(index)));
|
getAapsLogger().debug(LTag.AUTOSENS, "Removing from iobTable: " + DateUtil.dateAndTimeFullString(iobTable.keyAt(index)));
|
||||||
iobTable.removeAt(index);
|
iobTable.removeAt(index);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -806,7 +803,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
for (int index = autosensDataTable.size() - 1; index >= 0; index--) {
|
for (int index = autosensDataTable.size() - 1; index >= 0; index--) {
|
||||||
if (autosensDataTable.keyAt(index) > time) {
|
if (autosensDataTable.keyAt(index) > time) {
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Removing from autosensDataTable: " + DateUtil.dateAndTimeFullString(autosensDataTable.keyAt(index)));
|
getAapsLogger().debug(LTag.AUTOSENS, "Removing from autosensDataTable: " + DateUtil.dateAndTimeFullString(autosensDataTable.keyAt(index)));
|
||||||
autosensDataTable.removeAt(index);
|
autosensDataTable.removeAt(index);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -814,7 +811,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
}
|
}
|
||||||
for (int index = basalDataTable.size() - 1; index >= 0; index--) {
|
for (int index = basalDataTable.size() - 1; index >= 0; index--) {
|
||||||
if (basalDataTable.keyAt(index) > time) {
|
if (basalDataTable.keyAt(index) > time) {
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Removing from basalDataTable: " + DateUtil.dateAndTimeFullString(basalDataTable.keyAt(index)));
|
getAapsLogger().debug(LTag.AUTOSENS, "Removing from basalDataTable: " + DateUtil.dateAndTimeFullString(basalDataTable.keyAt(index)));
|
||||||
basalDataTable.removeAt(index);
|
basalDataTable.removeAt(index);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -827,7 +824,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
|
||||||
|
|
||||||
public void clearCache() {
|
public void clearCache() {
|
||||||
synchronized (dataLock) {
|
synchronized (dataLock) {
|
||||||
aapsLogger.debug(LTag.AUTOSENS, "Clearing cached data.");
|
getAapsLogger().debug(LTag.AUTOSENS, "Clearing cached data.");
|
||||||
iobTable = new LongSparseArray<>();
|
iobTable = new LongSparseArray<>();
|
||||||
autosensDataTable = new LongSparseArray<>();
|
autosensDataTable = new LongSparseArray<>();
|
||||||
basalDataTable = new LongSparseArray<>();
|
basalDataTable = new LongSparseArray<>();
|
||||||
|
|
|
@ -14,7 +14,6 @@ import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunction
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter
|
import info.nightscout.androidaps.utils.DecimalFormatter
|
||||||
|
@ -31,8 +30,8 @@ import kotlin.collections.ArrayList
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class LocalProfilePlugin @Inject constructor(
|
class LocalProfilePlugin @Inject constructor(
|
||||||
private val aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
private val rxBus: RxBusWrapper,
|
rxBus: RxBusWrapper,
|
||||||
private val resourceHelper: ResourceHelper,
|
private val resourceHelper: ResourceHelper,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val profileFunction: ProfileFunction
|
private val profileFunction: ProfileFunction
|
||||||
|
@ -42,7 +41,7 @@ class LocalProfilePlugin @Inject constructor(
|
||||||
.enableByDefault(true)
|
.enableByDefault(true)
|
||||||
.pluginName(R.string.localprofile)
|
.pluginName(R.string.localprofile)
|
||||||
.shortName(R.string.localprofile_shortname)
|
.shortName(R.string.localprofile_shortname)
|
||||||
.description(R.string.description_profile_local)), ProfileInterface {
|
.description(R.string.description_profile_local), rxBus, aapsLogger), ProfileInterface {
|
||||||
|
|
||||||
var rawProfile: ProfileStore? = null
|
var rawProfile: ProfileStore? = null
|
||||||
|
|
||||||
|
|
|
@ -19,8 +19,10 @@ import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLoggerProduction;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart;
|
import info.nightscout.androidaps.plugins.general.nsclient.events.EventNSClientRestart;
|
||||||
import info.nightscout.androidaps.plugins.profile.ns.events.EventNSProfileUpdateGUI;
|
import info.nightscout.androidaps.plugins.profile.ns.events.EventNSProfileUpdateGUI;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
@ -50,7 +52,8 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface {
|
||||||
.alwaysEnabled(Config.NSCLIENT)
|
.alwaysEnabled(Config.NSCLIENT)
|
||||||
.alwaysVisible(Config.NSCLIENT)
|
.alwaysVisible(Config.NSCLIENT)
|
||||||
.showInList(!Config.NSCLIENT)
|
.showInList(!Config.NSCLIENT)
|
||||||
.description(R.string.description_profile_nightscout)
|
.description(R.string.description_profile_nightscout),
|
||||||
|
new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger
|
||||||
);
|
);
|
||||||
loadNSProfile();
|
loadNSProfile();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,10 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLoggerProduction;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
|
@ -130,13 +132,16 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint
|
||||||
private static final PumpEnactResult OPERATION_NOT_SUPPORTED = new PumpEnactResult()
|
private static final PumpEnactResult OPERATION_NOT_SUPPORTED = new PumpEnactResult()
|
||||||
.success(false).enacted(false).comment(MainApp.gs(R.string.combo_pump_unsupported_operation));
|
.success(false).enacted(false).comment(MainApp.gs(R.string.combo_pump_unsupported_operation));
|
||||||
|
|
||||||
|
// TODO: dagger
|
||||||
|
|
||||||
private ComboPlugin() {
|
private ComboPlugin() {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.PUMP)
|
.mainType(PluginType.PUMP)
|
||||||
.fragmentClass(ComboFragment.class.getName())
|
.fragmentClass(ComboFragment.class.getName())
|
||||||
.pluginName(R.string.combopump)
|
.pluginName(R.string.combopump)
|
||||||
.shortName(R.string.combopump_shortname)
|
.shortName(R.string.combopump_shortname)
|
||||||
.description(R.string.description_pump_combo)
|
.description(R.string.description_pump_combo),
|
||||||
|
new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger
|
||||||
);
|
);
|
||||||
ruffyScripter = new RuffyScripter(MainApp.instance().getApplicationContext());
|
ruffyScripter = new RuffyScripter(MainApp.instance().getApplicationContext());
|
||||||
pumpDescription.setPumpDescription(PumpType.AccuChekCombo);
|
pumpDescription.setPumpDescription(PumpType.AccuChekCombo);
|
||||||
|
|
|
@ -28,8 +28,10 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventOverviewBolusProgress;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
import info.nightscout.androidaps.plugins.pump.common.data.PumpStatus;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpDriverState;
|
||||||
|
@ -68,9 +70,9 @@ public abstract class PumpPluginAbstract extends PluginBase implements PumpInter
|
||||||
protected boolean displayConnectionMessages = false;
|
protected boolean displayConnectionMessages = false;
|
||||||
|
|
||||||
|
|
||||||
protected PumpPluginAbstract(PluginDescription pluginDescription, PumpType pumpType) {
|
protected PumpPluginAbstract(PluginDescription pluginDescription, PumpType pumpType, RxBusWrapper rxBusWrapper, AAPSLogger aapsLogger) {
|
||||||
|
|
||||||
super(pluginDescription);
|
super(pluginDescription, rxBusWrapper, aapsLogger);
|
||||||
|
|
||||||
pumpDescription.setPumpDescription(pumpType);
|
pumpDescription.setPumpDescription(pumpType);
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,10 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
import info.nightscout.androidaps.plugins.configBuilder.ConstraintChecker;
|
||||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
||||||
|
@ -56,14 +58,15 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
|
||||||
|
|
||||||
public PumpDescription pumpDescription = new PumpDescription();
|
public PumpDescription pumpDescription = new PumpDescription();
|
||||||
|
|
||||||
protected AbstractDanaRPlugin() {
|
protected AbstractDanaRPlugin(RxBusWrapper rxBus, AAPSLogger aapsLogger) {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.PUMP)
|
.mainType(PluginType.PUMP)
|
||||||
.fragmentClass(DanaRFragment.class.getName())
|
.fragmentClass(DanaRFragment.class.getName())
|
||||||
.pluginName(R.string.danarspump)
|
.pluginName(R.string.danarspump)
|
||||||
.shortName(R.string.danarpump_shortname)
|
.shortName(R.string.danarpump_shortname)
|
||||||
.preferencesId(R.xml.pref_danars)
|
.preferencesId(R.xml.pref_danars)
|
||||||
.description(R.string.description_pump_dana_r)
|
.description(R.string.description_pump_dana_r),
|
||||||
|
rxBus, aapsLogger
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
|
||||||
TreatmentsPlugin treatmentsPlugin,
|
TreatmentsPlugin treatmentsPlugin,
|
||||||
SP sp
|
SP sp
|
||||||
) {
|
) {
|
||||||
super();
|
super(rxBus, aapsLogger);
|
||||||
plugin = this;
|
plugin = this;
|
||||||
this.aapsLogger = aapsLogger;
|
this.aapsLogger = aapsLogger;
|
||||||
this.rxBus = rxBus;
|
this.rxBus = rxBus;
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
||||||
TreatmentsPlugin treatmentsPlugin,
|
TreatmentsPlugin treatmentsPlugin,
|
||||||
SP sp
|
SP sp
|
||||||
) {
|
) {
|
||||||
super();
|
super(rxBus, aapsLogger);
|
||||||
plugin = this;
|
plugin = this;
|
||||||
this.aapsLogger = aapsLogger;
|
this.aapsLogger = aapsLogger;
|
||||||
this.rxBus = rxBus;
|
this.rxBus = rxBus;
|
||||||
|
@ -80,7 +80,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
|
||||||
this.constraintChecker = constraintChecker;
|
this.constraintChecker = constraintChecker;
|
||||||
this.treatmentsPlugin = treatmentsPlugin;
|
this.treatmentsPlugin = treatmentsPlugin;
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
pluginDescription.description(R.string.description_pump_dana_r_korean);
|
getPluginDescription().description(R.string.description_pump_dana_r_korean);
|
||||||
|
|
||||||
useExtendedBoluses = sp.getBoolean(R.string.key_danar_useextended, false);
|
useExtendedBoluses = sp.getBoolean(R.string.key_danar_useextended, false);
|
||||||
pumpDescription.setPumpDescription(PumpType.DanaRKorean);
|
pumpDescription.setPumpDescription(PumpType.DanaRKorean);
|
||||||
|
|
|
@ -70,9 +70,7 @@ import io.reactivex.schedulers.Schedulers;
|
||||||
@Singleton
|
@Singleton
|
||||||
public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInterface, ConstraintsInterface {
|
public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInterface, ConstraintsInterface {
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
private final AAPSLogger aapsLogger;
|
|
||||||
private final RxBusWrapper rxBus;
|
|
||||||
private final MainApp mainApp;
|
private final MainApp mainApp;
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
private final ConstraintChecker constraintChecker;
|
private final ConstraintChecker constraintChecker;
|
||||||
|
@ -113,11 +111,10 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
.pluginName(R.string.danarspump)
|
.pluginName(R.string.danarspump)
|
||||||
.shortName(R.string.danarspump_shortname)
|
.shortName(R.string.danarspump_shortname)
|
||||||
.preferencesId(R.xml.pref_danars)
|
.preferencesId(R.xml.pref_danars)
|
||||||
.description(R.string.description_pump_dana_rs)
|
.description(R.string.description_pump_dana_rs),
|
||||||
|
rxBus, aapsLogger
|
||||||
);
|
);
|
||||||
plugin = this;
|
plugin = this;
|
||||||
this.aapsLogger = aapsLogger;
|
|
||||||
this.rxBus = rxBus;
|
|
||||||
this.mainApp = maiApp;
|
this.mainApp = maiApp;
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
this.constraintChecker = constraintChecker;
|
this.constraintChecker = constraintChecker;
|
||||||
|
@ -141,12 +138,12 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
Intent intent = new Intent(mainApp, DanaRSService.class);
|
Intent intent = new Intent(mainApp, DanaRSService.class);
|
||||||
mainApp.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
mainApp.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
|
||||||
|
|
||||||
disposable.add(rxBus
|
disposable.add(getRxBus()
|
||||||
.toObservable(EventAppExit.class)
|
.toObservable(EventAppExit.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> mainApp.unbindService(mConnection), exception -> FabricPrivacy.getInstance().logException(exception))
|
.subscribe(event -> mainApp.unbindService(mConnection), exception -> FabricPrivacy.getInstance().logException(exception))
|
||||||
);
|
);
|
||||||
disposable.add(rxBus
|
disposable.add(getRxBus()
|
||||||
.toObservable(EventDanaRSDeviceChange.class)
|
.toObservable(EventDanaRSDeviceChange.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> loadAddress(), exception -> FabricPrivacy.getInstance().logException(exception))
|
.subscribe(event -> loadAddress(), exception -> FabricPrivacy.getInstance().logException(exception))
|
||||||
|
@ -171,12 +168,12 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
private ServiceConnection mConnection = new ServiceConnection() {
|
private ServiceConnection mConnection = new ServiceConnection() {
|
||||||
|
|
||||||
public void onServiceDisconnected(ComponentName name) {
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
aapsLogger.debug(LTag.PUMP, "Service is disconnected");
|
getAapsLogger().debug(LTag.PUMP, "Service is disconnected");
|
||||||
danaRSService = null;
|
danaRSService = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
aapsLogger.debug(LTag.PUMP, "Service is connected");
|
getAapsLogger().debug(LTag.PUMP, "Service is connected");
|
||||||
DanaRSService.LocalBinder mLocalBinder = (DanaRSService.LocalBinder) service;
|
DanaRSService.LocalBinder mLocalBinder = (DanaRSService.LocalBinder) service;
|
||||||
danaRSService = mLocalBinder.getServiceInstance();
|
danaRSService = mLocalBinder.getServiceInstance();
|
||||||
}
|
}
|
||||||
|
@ -189,7 +186,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connect(String from) {
|
public void connect(String from) {
|
||||||
aapsLogger.debug(LTag.PUMP, "RS connect from: " + from);
|
getAapsLogger().debug(LTag.PUMP, "RS connect from: " + from);
|
||||||
if (danaRSService != null && !mDeviceAddress.equals("") && !mDeviceName.equals("")) {
|
if (danaRSService != null && !mDeviceAddress.equals("") && !mDeviceName.equals("")) {
|
||||||
final Object o = new Object();
|
final Object o = new Object();
|
||||||
|
|
||||||
|
@ -218,7 +215,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnect(String from) {
|
public void disconnect(String from) {
|
||||||
aapsLogger.debug(LTag.PUMP, "RS disconnect from: " + from);
|
getAapsLogger().debug(LTag.PUMP, "RS disconnect from: " + from);
|
||||||
if (danaRSService != null) danaRSService.disconnect(from);
|
if (danaRSService != null) danaRSService.disconnect(from);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,29 +305,29 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
|
|
||||||
if (danaRSService == null) {
|
if (danaRSService == null) {
|
||||||
aapsLogger.error("setNewBasalProfile sExecutionService is null");
|
getAapsLogger().error("setNewBasalProfile sExecutionService is null");
|
||||||
result.comment = "setNewBasalProfile sExecutionService is null";
|
result.comment = "setNewBasalProfile sExecutionService is null";
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (!isInitialized()) {
|
if (!isInitialized()) {
|
||||||
aapsLogger.error("setNewBasalProfile not initialized");
|
getAapsLogger().error("setNewBasalProfile not initialized");
|
||||||
Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, resourceHelper.gs(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT);
|
Notification notification = new Notification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED, resourceHelper.gs(R.string.pumpNotInitializedProfileNotSet), Notification.URGENT);
|
||||||
rxBus.send(new EventNewNotification(notification));
|
getRxBus().send(new EventNewNotification(notification));
|
||||||
result.comment = resourceHelper.gs(R.string.pumpNotInitializedProfileNotSet);
|
result.comment = resourceHelper.gs(R.string.pumpNotInitializedProfileNotSet);
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
|
getRxBus().send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
|
||||||
}
|
}
|
||||||
if (!danaRSService.updateBasalsInPump(profile)) {
|
if (!danaRSService.updateBasalsInPump(profile)) {
|
||||||
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, resourceHelper.gs(R.string.failedupdatebasalprofile), Notification.URGENT);
|
Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, resourceHelper.gs(R.string.failedupdatebasalprofile), Notification.URGENT);
|
||||||
rxBus.send(new EventNewNotification(notification));
|
getRxBus().send(new EventNewNotification(notification));
|
||||||
result.comment = resourceHelper.gs(R.string.failedupdatebasalprofile);
|
result.comment = resourceHelper.gs(R.string.failedupdatebasalprofile);
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
rxBus.send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
|
getRxBus().send(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED));
|
||||||
rxBus.send(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
|
getRxBus().send(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE));
|
||||||
Notification notification = new Notification(Notification.PROFILE_SET_OK, resourceHelper.gs(R.string.profile_set_ok), Notification.INFO, 60);
|
Notification notification = new Notification(Notification.PROFILE_SET_OK, resourceHelper.gs(R.string.profile_set_ok), Notification.INFO, 60);
|
||||||
rxBus.send(new EventNewNotification(notification));
|
getRxBus().send(new EventNewNotification(notification));
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.enacted = true;
|
result.enacted = true;
|
||||||
result.comment = "OK";
|
result.comment = "OK";
|
||||||
|
@ -351,7 +348,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
Double pumpValue = pump.pumpProfiles[pump.activeProfile][h];
|
Double pumpValue = pump.pumpProfiles[pump.activeProfile][h];
|
||||||
Double profileValue = profile.getBasalTimeFromMidnight(h * basalIncrement);
|
Double profileValue = profile.getBasalTimeFromMidnight(h * basalIncrement);
|
||||||
if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) {
|
if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) {
|
||||||
aapsLogger.debug(LTag.PUMP, "Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue);
|
getAapsLogger().debug(LTag.PUMP, "Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -437,7 +434,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
result.comment = String.format(resourceHelper.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, error);
|
result.comment = String.format(resourceHelper.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, error);
|
||||||
} else
|
} else
|
||||||
result.comment = resourceHelper.gs(R.string.virtualpump_resultok);
|
result.comment = resourceHelper.gs(R.string.virtualpump_resultok);
|
||||||
aapsLogger.debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
|
getAapsLogger().debug(LTag.PUMP, "deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
PumpEnactResult result = new PumpEnactResult();
|
PumpEnactResult result = new PumpEnactResult();
|
||||||
|
@ -445,7 +442,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
result.bolusDelivered = 0d;
|
result.bolusDelivered = 0d;
|
||||||
result.carbsDelivered = 0d;
|
result.carbsDelivered = 0d;
|
||||||
result.comment = resourceHelper.gs(R.string.danar_invalidinput);
|
result.comment = resourceHelper.gs(R.string.danar_invalidinput);
|
||||||
aapsLogger.error("deliverTreatment: Invalid input");
|
getAapsLogger().error("deliverTreatment: Invalid input");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -453,7 +450,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
@Override
|
@Override
|
||||||
public void stopBolusDelivering() {
|
public void stopBolusDelivering() {
|
||||||
if (danaRSService == null) {
|
if (danaRSService == null) {
|
||||||
aapsLogger.error("stopBolusDelivering sExecutionService is null");
|
getAapsLogger().error("stopBolusDelivering sExecutionService is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
danaRSService.bolusStop();
|
danaRSService.bolusStop();
|
||||||
|
@ -480,7 +477,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
if (doTempOff) {
|
if (doTempOff) {
|
||||||
// If temp in progress
|
// If temp in progress
|
||||||
if (treatmentsPlugin.isTempBasalInProgress()) {
|
if (treatmentsPlugin.isTempBasalInProgress()) {
|
||||||
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Stopping temp basal (doTempOff)");
|
getAapsLogger().debug(LTag.PUMP, "setTempBasalAbsolute: Stopping temp basal (doTempOff)");
|
||||||
return cancelTempBasal(false);
|
return cancelTempBasal(false);
|
||||||
}
|
}
|
||||||
result.success = true;
|
result.success = true;
|
||||||
|
@ -488,7 +485,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
result.percent = 100;
|
result.percent = 100;
|
||||||
result.isPercent = true;
|
result.isPercent = true;
|
||||||
result.isTempCancel = true;
|
result.isTempCancel = true;
|
||||||
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: doTempOff OK");
|
getAapsLogger().debug(LTag.PUMP, "setTempBasalAbsolute: doTempOff OK");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -501,7 +498,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
// Check if some temp is already in progress
|
// Check if some temp is already in progress
|
||||||
TemporaryBasal activeTemp = treatmentsPlugin.getTempBasalFromHistory(System.currentTimeMillis());
|
TemporaryBasal activeTemp = treatmentsPlugin.getTempBasalFromHistory(System.currentTimeMillis());
|
||||||
if (activeTemp != null) {
|
if (activeTemp != null) {
|
||||||
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: currently running: " + activeTemp.toString());
|
getAapsLogger().debug(LTag.PUMP, "setTempBasalAbsolute: currently running: " + activeTemp.toString());
|
||||||
// Correct basal already set ?
|
// Correct basal already set ?
|
||||||
if (activeTemp.percentRate == percentRate && activeTemp.getPlannedRemainingMinutes() > 4) {
|
if (activeTemp.percentRate == percentRate && activeTemp.getPlannedRemainingMinutes() > 4) {
|
||||||
if (!enforceNew) {
|
if (!enforceNew) {
|
||||||
|
@ -511,13 +508,13 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
result.duration = activeTemp.getPlannedRemainingMinutes();
|
result.duration = activeTemp.getPlannedRemainingMinutes();
|
||||||
result.isPercent = true;
|
result.isPercent = true;
|
||||||
result.isTempCancel = false;
|
result.isTempCancel = false;
|
||||||
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)");
|
getAapsLogger().debug(LTag.PUMP, "setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Convert duration from minutes to hours
|
// Convert duration from minutes to hours
|
||||||
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
|
getAapsLogger().debug(LTag.PUMP, "setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
|
||||||
if (percentRate == 0 && durationInMinutes > 30) {
|
if (percentRate == 0 && durationInMinutes > 30) {
|
||||||
result = setTempBasalPercent(percentRate, durationInMinutes, profile, enforceNew);
|
result = setTempBasalPercent(percentRate, durationInMinutes, profile, enforceNew);
|
||||||
} else {
|
} else {
|
||||||
|
@ -525,14 +522,14 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
result = setHighTempBasalPercent(percentRate);
|
result = setHighTempBasalPercent(percentRate);
|
||||||
}
|
}
|
||||||
if (!result.success) {
|
if (!result.success) {
|
||||||
aapsLogger.error("setTempBasalAbsolute: Failed to set hightemp basal");
|
getAapsLogger().error("setTempBasalAbsolute: Failed to set hightemp basal");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
aapsLogger.debug(LTag.PUMP, "setTempBasalAbsolute: hightemp basal set ok");
|
getAapsLogger().debug(LTag.PUMP, "setTempBasalAbsolute: hightemp basal set ok");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
// We should never end here
|
// We should never end here
|
||||||
aapsLogger.error("setTempBasalAbsolute: Internal error");
|
getAapsLogger().error("setTempBasalAbsolute: Internal error");
|
||||||
result.success = false;
|
result.success = false;
|
||||||
result.comment = "Internal error";
|
result.comment = "Internal error";
|
||||||
return result;
|
return result;
|
||||||
|
@ -548,7 +545,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = false;
|
result.success = false;
|
||||||
result.comment = resourceHelper.gs(R.string.danar_invalidinput);
|
result.comment = resourceHelper.gs(R.string.danar_invalidinput);
|
||||||
aapsLogger.error("setTempBasalPercent: Invalid input");
|
getAapsLogger().error("setTempBasalPercent: Invalid input");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (percent > getPumpDescription().maxTempPercent)
|
if (percent > getPumpDescription().maxTempPercent)
|
||||||
|
@ -563,7 +560,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
result.duration = pump.tempBasalRemainingMin;
|
result.duration = pump.tempBasalRemainingMin;
|
||||||
result.percent = pump.tempBasalPercent;
|
result.percent = pump.tempBasalPercent;
|
||||||
result.isPercent = true;
|
result.isPercent = true;
|
||||||
aapsLogger.debug(LTag.PUMP, "setTempBasalPercent: Correct value already set");
|
getAapsLogger().debug(LTag.PUMP, "setTempBasalPercent: Correct value already set");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
boolean connectionOK;
|
boolean connectionOK;
|
||||||
|
@ -581,13 +578,13 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
result.duration = pump.tempBasalRemainingMin;
|
result.duration = pump.tempBasalRemainingMin;
|
||||||
result.percent = pump.tempBasalPercent;
|
result.percent = pump.tempBasalPercent;
|
||||||
result.isPercent = true;
|
result.isPercent = true;
|
||||||
aapsLogger.debug(LTag.PUMP, "setTempBasalPercent: OK");
|
getAapsLogger().debug(LTag.PUMP, "setTempBasalPercent: OK");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = false;
|
result.success = false;
|
||||||
result.comment = resourceHelper.gs(R.string.tempbasaldeliveryerror);
|
result.comment = resourceHelper.gs(R.string.tempbasaldeliveryerror);
|
||||||
aapsLogger.error("setTempBasalPercent: Failed to set temp basal");
|
getAapsLogger().error("setTempBasalPercent: Failed to set temp basal");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -603,13 +600,13 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
result.duration = pump.tempBasalRemainingMin;
|
result.duration = pump.tempBasalRemainingMin;
|
||||||
result.percent = pump.tempBasalPercent;
|
result.percent = pump.tempBasalPercent;
|
||||||
result.isPercent = true;
|
result.isPercent = true;
|
||||||
aapsLogger.debug(LTag.PUMP, "setHighTempBasalPercent: OK");
|
getAapsLogger().debug(LTag.PUMP, "setHighTempBasalPercent: OK");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = false;
|
result.success = false;
|
||||||
result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly);
|
result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly);
|
||||||
aapsLogger.error("setHighTempBasalPercent: Failed to set temp basal");
|
getAapsLogger().error("setHighTempBasalPercent: Failed to set temp basal");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,7 +627,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
result.absolute = pump.extendedBolusAbsoluteRate;
|
result.absolute = pump.extendedBolusAbsoluteRate;
|
||||||
result.isPercent = false;
|
result.isPercent = false;
|
||||||
result.isTempCancel = false;
|
result.isTempCancel = false;
|
||||||
aapsLogger.debug(LTag.PUMP, "setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulin);
|
getAapsLogger().debug(LTag.PUMP, "setExtendedBolus: Correct extended bolus already set. Current: " + pump.extendedBolusAmount + " Asked: " + insulin);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
boolean connectionOK = danaRSService.extendedBolus(insulin, durationInHalfHours);
|
boolean connectionOK = danaRSService.extendedBolus(insulin, durationInHalfHours);
|
||||||
|
@ -643,13 +640,13 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
result.absolute = pump.extendedBolusAbsoluteRate;
|
result.absolute = pump.extendedBolusAbsoluteRate;
|
||||||
result.bolusDelivered = pump.extendedBolusAmount;
|
result.bolusDelivered = pump.extendedBolusAmount;
|
||||||
result.isPercent = false;
|
result.isPercent = false;
|
||||||
aapsLogger.debug(LTag.PUMP, "setExtendedBolus: OK");
|
getAapsLogger().debug(LTag.PUMP, "setExtendedBolus: OK");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
result.enacted = false;
|
result.enacted = false;
|
||||||
result.success = false;
|
result.success = false;
|
||||||
result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly);
|
result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly);
|
||||||
aapsLogger.error("setExtendedBolus: Failed to extended bolus");
|
getAapsLogger().error("setExtendedBolus: Failed to extended bolus");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -666,13 +663,13 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.isTempCancel = true;
|
result.isTempCancel = true;
|
||||||
result.comment = resourceHelper.gs(R.string.virtualpump_resultok);
|
result.comment = resourceHelper.gs(R.string.virtualpump_resultok);
|
||||||
aapsLogger.debug(LTag.PUMP, "cancelRealTempBasal: OK");
|
getAapsLogger().debug(LTag.PUMP, "cancelRealTempBasal: OK");
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
result.success = false;
|
result.success = false;
|
||||||
result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly);
|
result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly);
|
||||||
result.isTempCancel = true;
|
result.isTempCancel = true;
|
||||||
aapsLogger.error("cancelRealTempBasal: Failed to cancel temp basal");
|
getAapsLogger().error("cancelRealTempBasal: Failed to cancel temp basal");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -689,12 +686,12 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
if (!DanaRPump.getInstance().isExtendedInProgress) {
|
if (!DanaRPump.getInstance().isExtendedInProgress) {
|
||||||
result.success = true;
|
result.success = true;
|
||||||
result.comment = resourceHelper.gs(R.string.virtualpump_resultok);
|
result.comment = resourceHelper.gs(R.string.virtualpump_resultok);
|
||||||
aapsLogger.debug(LTag.PUMP, "cancelExtendedBolus: OK");
|
getAapsLogger().debug(LTag.PUMP, "cancelExtendedBolus: OK");
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
result.success = false;
|
result.success = false;
|
||||||
result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly);
|
result.comment = resourceHelper.gs(R.string.danar_valuenotsetproperly);
|
||||||
aapsLogger.error("cancelExtendedBolus: Failed to cancel extended bolus");
|
getAapsLogger().error("cancelExtendedBolus: Failed to cancel extended bolus");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -736,7 +733,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
try {
|
try {
|
||||||
extended.put("ActiveProfile", profileFunction.getProfileName());
|
extended.put("ActiveProfile", profileFunction.getProfileName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
aapsLogger.error("Unhandled exception", e);
|
getAapsLogger().error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
pumpjson.put("battery", battery);
|
pumpjson.put("battery", battery);
|
||||||
|
@ -745,7 +742,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
pumpjson.put("reservoir", (int) pump.reservoirRemainingUnits);
|
pumpjson.put("reservoir", (int) pump.reservoirRemainingUnits);
|
||||||
pumpjson.put("clock", DateUtil.toISOString(now));
|
pumpjson.put("clock", DateUtil.toISOString(now));
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
aapsLogger.error("Unhandled exception", e);
|
getAapsLogger().error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
return pumpjson;
|
return pumpjson;
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
TreatmentsPlugin treatmentsPlugin,
|
TreatmentsPlugin treatmentsPlugin,
|
||||||
SP sp
|
SP sp
|
||||||
) {
|
) {
|
||||||
super();
|
super(rxBus, aapsLogger);
|
||||||
plugin = this;
|
plugin = this;
|
||||||
this.aapsLogger = aapsLogger;
|
this.aapsLogger = aapsLogger;
|
||||||
this.rxBus = rxBus;
|
this.rxBus = rxBus;
|
||||||
|
@ -80,7 +80,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
|
||||||
this.constraintChecker = constraintChecker;
|
this.constraintChecker = constraintChecker;
|
||||||
this.treatmentsPlugin = treatmentsPlugin;
|
this.treatmentsPlugin = treatmentsPlugin;
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
pluginDescription.description(R.string.description_pump_dana_r_v2);
|
getPluginDescription().description(R.string.description_pump_dana_r_v2);
|
||||||
|
|
||||||
useExtendedBoluses = false;
|
useExtendedBoluses = false;
|
||||||
pumpDescription.setPumpDescription(PumpType.DanaRv2);
|
pumpDescription.setPumpDescription(PumpType.DanaRv2);
|
||||||
|
|
|
@ -42,8 +42,10 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLoggerProduction;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
|
@ -195,7 +197,10 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con
|
||||||
.description(R.string.description_pump_insight_local)
|
.description(R.string.description_pump_insight_local)
|
||||||
.fragmentClass(LocalInsightFragment.class.getName())
|
.fragmentClass(LocalInsightFragment.class.getName())
|
||||||
.preferencesId(MainApp.instance().getPackageName().equals("info.nightscout.androidaps")
|
.preferencesId(MainApp.instance().getPackageName().equals("info.nightscout.androidaps")
|
||||||
? R.xml.pref_insight_local_full : R.xml.pref_insight_local_pumpcontrol));
|
? R.xml.pref_insight_local_full : R.xml.pref_insight_local_pumpcontrol),
|
||||||
|
new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger
|
||||||
|
|
||||||
|
);
|
||||||
|
|
||||||
pumpDescription = new PumpDescription();
|
pumpDescription = new PumpDescription();
|
||||||
pumpDescription.setPumpDescription(PumpType.AccuChekInsightBluetooth);
|
pumpDescription.setPumpDescription(PumpType.AccuChekInsightBluetooth);
|
||||||
|
|
|
@ -18,7 +18,10 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLoggerProduction;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
||||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
||||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
|
import info.nightscout.androidaps.plugins.general.actions.defs.CustomActionType;
|
||||||
|
@ -45,11 +48,14 @@ public class MDIPlugin extends PluginBase implements PumpInterface {
|
||||||
|
|
||||||
private PumpDescription pumpDescription = new PumpDescription();
|
private PumpDescription pumpDescription = new PumpDescription();
|
||||||
|
|
||||||
|
//TODO dagger
|
||||||
|
|
||||||
private MDIPlugin() {
|
private MDIPlugin() {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.PUMP)
|
.mainType(PluginType.PUMP)
|
||||||
.pluginName(R.string.mdi)
|
.pluginName(R.string.mdi)
|
||||||
.description(R.string.description_pump_mdi)
|
.description(R.string.description_pump_mdi),
|
||||||
|
new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger
|
||||||
);
|
);
|
||||||
pumpDescription.isBolusCapable = true;
|
pumpDescription.isBolusCapable = true;
|
||||||
pumpDescription.bolusStep = 0.5d;
|
pumpDescription.bolusStep = 0.5d;
|
||||||
|
|
|
@ -37,8 +37,10 @@ import info.nightscout.androidaps.events.EventRefreshOverview;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLoggerProduction;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
import info.nightscout.androidaps.plugins.common.ManufacturerType;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
import info.nightscout.androidaps.plugins.general.actions.defs.CustomAction;
|
||||||
|
@ -117,7 +119,8 @@ public class MedtronicPumpPlugin extends PumpPluginAbstract implements PumpInter
|
||||||
.pluginName(R.string.medtronic_name) //
|
.pluginName(R.string.medtronic_name) //
|
||||||
.shortName(R.string.medtronic_name_short) //
|
.shortName(R.string.medtronic_name_short) //
|
||||||
.preferencesId(R.xml.pref_medtronic).description(R.string.description_pump_medtronic), //
|
.preferencesId(R.xml.pref_medtronic).description(R.string.description_pump_medtronic), //
|
||||||
PumpType.Medtronic_522_722 // we default to most basic model, correct model from config is loaded later
|
PumpType.Medtronic_522_722, // we default to most basic model, correct model from config is loaded later
|
||||||
|
new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger
|
||||||
);
|
);
|
||||||
|
|
||||||
displayConnectionMessages = false;
|
displayConnectionMessages = false;
|
||||||
|
|
|
@ -45,8 +45,8 @@ import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class VirtualPumpPlugin @Inject constructor(
|
class VirtualPumpPlugin @Inject constructor(
|
||||||
private val aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
private val rxBus: RxBusWrapper,
|
rxBus: RxBusWrapper,
|
||||||
private var fabricPrivacy: FabricPrivacy,
|
private var fabricPrivacy: FabricPrivacy,
|
||||||
private val resourceHelper: ResourceHelper,
|
private val resourceHelper: ResourceHelper,
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
|
@ -59,7 +59,8 @@ class VirtualPumpPlugin @Inject constructor(
|
||||||
.shortName(R.string.virtualpump_shortname)
|
.shortName(R.string.virtualpump_shortname)
|
||||||
.preferencesId(R.xml.pref_virtualpump)
|
.preferencesId(R.xml.pref_virtualpump)
|
||||||
.neverVisible(Config.NSCLIENT)
|
.neverVisible(Config.NSCLIENT)
|
||||||
.description(R.string.description_pump_virtual)
|
.description(R.string.description_pump_virtual),
|
||||||
|
rxBus, aapsLogger
|
||||||
), PumpInterface {
|
), PumpInterface {
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,9 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
import info.nightscout.androidaps.interfaces.SensitivityInterface;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLogger;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.utils.Round;
|
import info.nightscout.androidaps.utils.Round;
|
||||||
|
@ -18,8 +20,8 @@ public abstract class AbstractSensitivityPlugin extends PluginBase implements Se
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(L.AUTOSENS);
|
private static final Logger log = LoggerFactory.getLogger(L.AUTOSENS);
|
||||||
|
|
||||||
public AbstractSensitivityPlugin(PluginDescription pluginDescription) {
|
public AbstractSensitivityPlugin(PluginDescription pluginDescription, RxBusWrapper rxBusWrapper, AAPSLogger aapsLogger) {
|
||||||
super(pluginDescription);
|
super(pluginDescription, rxBusWrapper, aapsLogger);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -17,7 +17,9 @@ import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLoggerProduction;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
||||||
|
@ -41,13 +43,16 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: dagger
|
||||||
|
|
||||||
public SensitivityAAPSPlugin() {
|
public SensitivityAAPSPlugin() {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.SENSITIVITY)
|
.mainType(PluginType.SENSITIVITY)
|
||||||
.pluginName(R.string.sensitivityaaps)
|
.pluginName(R.string.sensitivityaaps)
|
||||||
.shortName(R.string.sensitivity_shortname)
|
.shortName(R.string.sensitivity_shortname)
|
||||||
.preferencesId(R.xml.pref_absorption_aaps)
|
.preferencesId(R.xml.pref_absorption_aaps)
|
||||||
.description(R.string.description_sensitivity_aaps)
|
.description(R.string.description_sensitivity_aaps),
|
||||||
|
new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,9 @@ import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLoggerProduction;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
||||||
|
@ -40,13 +42,16 @@ public class SensitivityOref0Plugin extends AbstractSensitivityPlugin {
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: dagger
|
||||||
|
|
||||||
public SensitivityOref0Plugin() {
|
public SensitivityOref0Plugin() {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.SENSITIVITY)
|
.mainType(PluginType.SENSITIVITY)
|
||||||
.pluginName(R.string.sensitivityoref0)
|
.pluginName(R.string.sensitivityoref0)
|
||||||
.shortName(R.string.sensitivity_shortname)
|
.shortName(R.string.sensitivity_shortname)
|
||||||
.preferencesId(R.xml.pref_absorption_oref0)
|
.preferencesId(R.xml.pref_absorption_oref0)
|
||||||
.description(R.string.description_sensitivity_oref0)
|
.description(R.string.description_sensitivity_oref0),
|
||||||
|
new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,9 @@ import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLoggerProduction;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
||||||
|
@ -46,7 +48,8 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
|
||||||
.pluginName(R.string.sensitivityoref1)
|
.pluginName(R.string.sensitivityoref1)
|
||||||
.shortName(R.string.sensitivity_shortname)
|
.shortName(R.string.sensitivity_shortname)
|
||||||
.preferencesId(R.xml.pref_absorption_oref1)
|
.preferencesId(R.xml.pref_absorption_oref1)
|
||||||
.description(R.string.description_sensitivity_oref1)
|
.description(R.string.description_sensitivity_oref1),
|
||||||
|
new RxBusWrapper(), new AAPSLoggerProduction() // TODO: Dagger
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,9 @@ import info.nightscout.androidaps.db.CareportalEvent;
|
||||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription;
|
import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
import info.nightscout.androidaps.interfaces.PluginType;
|
||||||
|
import info.nightscout.androidaps.logging.AAPSLoggerProduction;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensData;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.AutosensResult;
|
||||||
|
@ -39,13 +41,16 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
|
||||||
return plugin;
|
return plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: dagger
|
||||||
|
|
||||||
public SensitivityWeightedAveragePlugin() {
|
public SensitivityWeightedAveragePlugin() {
|
||||||
super(new PluginDescription()
|
super(new PluginDescription()
|
||||||
.mainType(PluginType.SENSITIVITY)
|
.mainType(PluginType.SENSITIVITY)
|
||||||
.pluginName(R.string.sensitivityweightedaverage)
|
.pluginName(R.string.sensitivityweightedaverage)
|
||||||
.shortName(R.string.sensitivity_shortname)
|
.shortName(R.string.sensitivity_shortname)
|
||||||
.preferencesId(R.xml.pref_absorption_aaps)
|
.preferencesId(R.xml.pref_absorption_aaps)
|
||||||
.description(R.string.description_sensitivity_weighted_average)
|
.description(R.string.description_sensitivity_weighted_average),
|
||||||
|
new RxBusWrapper(), new AAPSLoggerProduction() // TODO: dagger
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,26 +14,29 @@ import info.nightscout.androidaps.interfaces.PluginBase
|
||||||
import info.nightscout.androidaps.interfaces.PluginDescription
|
import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import org.json.JSONObject
|
import org.json.JSONObject
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class DexcomPlugin @Inject constructor(
|
class DexcomPlugin @Inject constructor(
|
||||||
private val aapsLogger: AAPSLogger,
|
|
||||||
private val sp: SP,
|
private val sp: SP,
|
||||||
private val mainApp: MainApp
|
private val mainApp: MainApp,
|
||||||
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginName(R.string.dexcom_app_patched)
|
.pluginName(R.string.dexcom_app_patched)
|
||||||
.shortName(R.string.dexcom_short)
|
.shortName(R.string.dexcom_short)
|
||||||
.preferencesId(R.xml.pref_bgsourcedexcom)
|
.preferencesId(R.xml.pref_bgsourcedexcom)
|
||||||
.description(R.string.description_source_dexcom)), BgSourceInterface {
|
.description(R.string.description_source_dexcom),
|
||||||
|
rxBus,
|
||||||
|
aapsLogger), BgSourceInterface {
|
||||||
|
|
||||||
private val PACKAGE_NAMES = arrayOf("com.dexcom.cgm.region1.mgdl", "com.dexcom.cgm.region1.mmol",
|
private val PACKAGE_NAMES = arrayOf("com.dexcom.cgm.region1.mgdl", "com.dexcom.cgm.region1.mmol",
|
||||||
"com.dexcom.cgm.region2.mgdl", "com.dexcom.cgm.region2.mmol",
|
"com.dexcom.cgm.region2.mgdl", "com.dexcom.cgm.region2.mmol",
|
||||||
|
|
|
@ -14,6 +14,7 @@ import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.L
|
import info.nightscout.androidaps.logging.L
|
||||||
import info.nightscout.androidaps.logging.L.isEnabled
|
import info.nightscout.androidaps.logging.L.isEnabled
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
@ -25,15 +26,17 @@ import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class EversensePlugin @Inject constructor(
|
class EversensePlugin @Inject constructor(
|
||||||
private val aapsLogger: AAPSLogger,
|
private val sp: SP,
|
||||||
private val sp: SP
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginName(R.string.eversense)
|
.pluginName(R.string.eversense)
|
||||||
.shortName(R.string.eversense_shortname)
|
.shortName(R.string.eversense_shortname)
|
||||||
.preferencesId(R.xml.pref_bgsource)
|
.preferencesId(R.xml.pref_bgsource)
|
||||||
.description(R.string.description_source_eversense)
|
.description(R.string.description_source_eversense),
|
||||||
|
rxBus,
|
||||||
|
aapsLogger
|
||||||
), BgSourceInterface {
|
), BgSourceInterface {
|
||||||
|
|
||||||
override fun advancedFilteringSupported(): Boolean {
|
override fun advancedFilteringSupported(): Boolean {
|
||||||
|
|
|
@ -11,18 +11,21 @@ import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.BundleLogger
|
import info.nightscout.androidaps.logging.BundleLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class GlimpPlugin @Inject constructor(
|
class GlimpPlugin @Inject constructor(
|
||||||
private val aapsLogger: AAPSLogger
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginName(R.string.Glimp)
|
.pluginName(R.string.Glimp)
|
||||||
.preferencesId(R.xml.pref_bgsource)
|
.preferencesId(R.xml.pref_bgsource)
|
||||||
.description(R.string.description_source_glimp)
|
.description(R.string.description_source_glimp),
|
||||||
|
rxBus,
|
||||||
|
aapsLogger
|
||||||
), BgSourceInterface {
|
), BgSourceInterface {
|
||||||
|
|
||||||
override fun advancedFilteringSupported(): Boolean {
|
override fun advancedFilteringSupported(): Boolean {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import org.json.JSONArray
|
import org.json.JSONArray
|
||||||
import org.json.JSONException
|
import org.json.JSONException
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -17,12 +18,14 @@ import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class MM640gPlugin @Inject constructor(
|
class MM640gPlugin @Inject constructor(
|
||||||
private val aapsLogger: AAPSLogger
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginName(R.string.MM640g)
|
.pluginName(R.string.MM640g)
|
||||||
.description(R.string.description_source_mm640g)
|
.description(R.string.description_source_mm640g),
|
||||||
|
rxBus,
|
||||||
|
aapsLogger
|
||||||
), BgSourceInterface {
|
), BgSourceInterface {
|
||||||
|
|
||||||
override fun advancedFilteringSupported(): Boolean {
|
override fun advancedFilteringSupported(): Boolean {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSgv
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSgv
|
||||||
import info.nightscout.androidaps.utils.JsonHelper.safeGetLong
|
import info.nightscout.androidaps.utils.JsonHelper.safeGetLong
|
||||||
import info.nightscout.androidaps.utils.JsonHelper.safeGetString
|
import info.nightscout.androidaps.utils.JsonHelper.safeGetString
|
||||||
|
@ -21,13 +22,15 @@ import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class NSClientSourcePlugin @Inject constructor(
|
class NSClientSourcePlugin @Inject constructor(
|
||||||
private val aapsLogger: AAPSLogger,
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger,
|
||||||
private val sp: SP
|
private val sp: SP
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginName(R.string.nsclientbg)
|
.pluginName(R.string.nsclientbg)
|
||||||
.description(R.string.description_source_ns_client)
|
.description(R.string.description_source_ns_client),
|
||||||
|
rxBus,
|
||||||
|
aapsLogger
|
||||||
), BgSourceInterface {
|
), BgSourceInterface {
|
||||||
|
|
||||||
private var lastBGTimeStamp: Long = 0
|
private var lastBGTimeStamp: Long = 0
|
||||||
|
|
|
@ -11,6 +11,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
import info.nightscout.androidaps.utils.JsonHelper.safeGetString
|
import info.nightscout.androidaps.utils.JsonHelper.safeGetString
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
|
@ -21,14 +22,16 @@ import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class PoctechPlugin @Inject constructor(
|
class PoctechPlugin @Inject constructor(
|
||||||
private val aapsLogger: AAPSLogger,
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger,
|
||||||
private val sp: SP
|
private val sp: SP
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginName(R.string.poctech)
|
.pluginName(R.string.poctech)
|
||||||
.preferencesId(R.xml.pref_bgsource)
|
.preferencesId(R.xml.pref_bgsource)
|
||||||
.description(R.string.description_source_poctech)
|
.description(R.string.description_source_poctech),
|
||||||
|
rxBus,
|
||||||
|
aapsLogger
|
||||||
), BgSourceInterface {
|
), BgSourceInterface {
|
||||||
|
|
||||||
override fun advancedFilteringSupported(): Boolean {
|
override fun advancedFilteringSupported(): Boolean {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
import info.nightscout.androidaps.plugins.pump.virtual.VirtualPumpPlugin
|
||||||
import info.nightscout.androidaps.utils.DateUtil
|
import info.nightscout.androidaps.utils.DateUtil
|
||||||
import info.nightscout.androidaps.utils.T
|
import info.nightscout.androidaps.utils.T
|
||||||
|
@ -23,14 +24,16 @@ import kotlin.math.sin
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class RandomBgPlugin @Inject constructor(
|
class RandomBgPlugin @Inject constructor(
|
||||||
private val aapsLogger: AAPSLogger,
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger,
|
||||||
private var virtualPumpPlugin: VirtualPumpPlugin
|
private var virtualPumpPlugin: VirtualPumpPlugin
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginName(R.string.randombg)
|
.pluginName(R.string.randombg)
|
||||||
.shortName(R.string.randombg_short)
|
.shortName(R.string.randombg_short)
|
||||||
.description(R.string.description_source_randombg)), BgSourceInterface {
|
.description(R.string.description_source_randombg),
|
||||||
|
rxBus,
|
||||||
|
aapsLogger), BgSourceInterface {
|
||||||
|
|
||||||
private val loopHandler = Handler()
|
private val loopHandler = Handler()
|
||||||
private lateinit var refreshLoop: Runnable
|
private lateinit var refreshLoop: Runnable
|
||||||
|
|
|
@ -10,6 +10,7 @@ import info.nightscout.androidaps.interfaces.PluginDescription
|
||||||
import info.nightscout.androidaps.interfaces.PluginType
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload
|
||||||
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
@ -17,7 +18,7 @@ import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class TomatoPlugin @Inject constructor(
|
class TomatoPlugin @Inject constructor(
|
||||||
private val aapsLogger: AAPSLogger,
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger,
|
||||||
private val sp: SP
|
private val sp: SP
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
|
@ -25,7 +26,9 @@ class TomatoPlugin @Inject constructor(
|
||||||
.pluginName(R.string.tomato)
|
.pluginName(R.string.tomato)
|
||||||
.preferencesId(R.xml.pref_bgsource)
|
.preferencesId(R.xml.pref_bgsource)
|
||||||
.shortName(R.string.tomato_short)
|
.shortName(R.string.tomato_short)
|
||||||
.description(R.string.description_source_tomato)
|
.description(R.string.description_source_tomato),
|
||||||
|
rxBus,
|
||||||
|
aapsLogger
|
||||||
), BgSourceInterface {
|
), BgSourceInterface {
|
||||||
|
|
||||||
override fun advancedFilteringSupported(): Boolean {
|
override fun advancedFilteringSupported(): Boolean {
|
||||||
|
|
|
@ -11,18 +11,21 @@ import info.nightscout.androidaps.interfaces.PluginType
|
||||||
import info.nightscout.androidaps.logging.AAPSLogger
|
import info.nightscout.androidaps.logging.AAPSLogger
|
||||||
import info.nightscout.androidaps.logging.BundleLogger
|
import info.nightscout.androidaps.logging.BundleLogger
|
||||||
import info.nightscout.androidaps.logging.LTag
|
import info.nightscout.androidaps.logging.LTag
|
||||||
|
import info.nightscout.androidaps.plugins.bus.RxBusWrapper
|
||||||
import info.nightscout.androidaps.services.Intents
|
import info.nightscout.androidaps.services.Intents
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
import javax.inject.Singleton
|
import javax.inject.Singleton
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
class XdripPlugin @Inject constructor(
|
class XdripPlugin @Inject constructor(
|
||||||
private val aapsLogger: AAPSLogger
|
rxBus: RxBusWrapper, aapsLogger: AAPSLogger
|
||||||
) : PluginBase(PluginDescription()
|
) : PluginBase(PluginDescription()
|
||||||
.mainType(PluginType.BGSOURCE)
|
.mainType(PluginType.BGSOURCE)
|
||||||
.fragmentClass(BGSourceFragment::class.java.name)
|
.fragmentClass(BGSourceFragment::class.java.name)
|
||||||
.pluginName(R.string.xdrip)
|
.pluginName(R.string.xdrip)
|
||||||
.description(R.string.description_source_xdrip)
|
.description(R.string.description_source_xdrip),
|
||||||
|
rxBus,
|
||||||
|
aapsLogger
|
||||||
), BgSourceInterface {
|
), BgSourceInterface {
|
||||||
|
|
||||||
var advancedFiltering = false
|
var advancedFiltering = false
|
||||||
|
|
|
@ -64,8 +64,7 @@ import io.reactivex.schedulers.Schedulers;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface {
|
public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface {
|
||||||
private final AAPSLogger aapsLogger;
|
|
||||||
private final RxBusWrapper rxBus;
|
|
||||||
private final MainApp mainApp;
|
private final MainApp mainApp;
|
||||||
private final SP sp;
|
private final SP sp;
|
||||||
private final ResourceHelper resourceHelper;
|
private final ResourceHelper resourceHelper;
|
||||||
|
@ -112,10 +111,10 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
.pluginName(R.string.treatments)
|
.pluginName(R.string.treatments)
|
||||||
.shortName(R.string.treatments_shortname)
|
.shortName(R.string.treatments_shortname)
|
||||||
.alwaysEnabled(true)
|
.alwaysEnabled(true)
|
||||||
.description(R.string.description_treatments)
|
.description(R.string.description_treatments),
|
||||||
|
rxBus,
|
||||||
|
aapsLogger
|
||||||
);
|
);
|
||||||
this.aapsLogger = aapsLogger;
|
|
||||||
this.rxBus = rxBus;
|
|
||||||
this.resourceHelper = resourceHelper;
|
this.resourceHelper = resourceHelper;
|
||||||
this.mainApp = mainApp;
|
this.mainApp = mainApp;
|
||||||
this.sp = sp;
|
this.sp = sp;
|
||||||
|
@ -129,35 +128,35 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
this.service = new TreatmentService();
|
this.service = new TreatmentService();
|
||||||
initializeData(range());
|
initializeData(range());
|
||||||
super.onStart();
|
super.onStart();
|
||||||
disposable.add(rxBus
|
disposable.add(getRxBus()
|
||||||
.toObservable(EventReloadTreatmentData.class)
|
.toObservable(EventReloadTreatmentData.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
aapsLogger.debug(LTag.DATATREATMENTS, "EventReloadTreatmentData");
|
getAapsLogger().debug(LTag.DATATREATMENTS, "EventReloadTreatmentData");
|
||||||
initializeTreatmentData(range());
|
initializeTreatmentData(range());
|
||||||
initializeExtendedBolusData(range());
|
initializeExtendedBolusData(range());
|
||||||
updateTotalIOBTreatments();
|
updateTotalIOBTreatments();
|
||||||
rxBus.send(event.getNext());
|
getRxBus().send(event.getNext());
|
||||||
},
|
},
|
||||||
exception -> FabricPrivacy.getInstance().logException(exception)
|
exception -> FabricPrivacy.getInstance().logException(exception)
|
||||||
));
|
));
|
||||||
disposable.add(rxBus
|
disposable.add(getRxBus()
|
||||||
.toObservable(EventReloadProfileSwitchData.class)
|
.toObservable(EventReloadProfileSwitchData.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> initializeProfileSwitchData(range()),
|
.subscribe(event -> initializeProfileSwitchData(range()),
|
||||||
exception -> FabricPrivacy.getInstance().logException(exception)
|
exception -> FabricPrivacy.getInstance().logException(exception)
|
||||||
));
|
));
|
||||||
disposable.add(rxBus
|
disposable.add(getRxBus()
|
||||||
.toObservable(EventTempTargetChange.class)
|
.toObservable(EventTempTargetChange.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> initializeTempTargetData(range()),
|
.subscribe(event -> initializeTempTargetData(range()),
|
||||||
exception -> FabricPrivacy.getInstance().logException(exception)
|
exception -> FabricPrivacy.getInstance().logException(exception)
|
||||||
));
|
));
|
||||||
disposable.add(rxBus
|
disposable.add(getRxBus()
|
||||||
.toObservable(EventReloadTempBasalData.class)
|
.toObservable(EventReloadTempBasalData.class)
|
||||||
.observeOn(Schedulers.io())
|
.observeOn(Schedulers.io())
|
||||||
.subscribe(event -> {
|
.subscribe(event -> {
|
||||||
aapsLogger.debug(LTag.DATATREATMENTS, "EventReloadTempBasalData");
|
getAapsLogger().debug(LTag.DATATREATMENTS, "EventReloadTempBasalData");
|
||||||
initializeTempBasalData(range());
|
initializeTempBasalData(range());
|
||||||
updateTotalIOBTempBasals();
|
updateTotalIOBTempBasals();
|
||||||
},
|
},
|
||||||
|
@ -191,7 +190,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeTreatmentData(long range) {
|
private void initializeTreatmentData(long range) {
|
||||||
aapsLogger.debug(LTag.DATATREATMENTS, "initializeTreatmentData");
|
getAapsLogger().debug(LTag.DATATREATMENTS, "initializeTreatmentData");
|
||||||
synchronized (treatments) {
|
synchronized (treatments) {
|
||||||
treatments.clear();
|
treatments.clear();
|
||||||
treatments.addAll(getService().getTreatmentDataFromTime(DateUtil.now() - range, false));
|
treatments.addAll(getService().getTreatmentDataFromTime(DateUtil.now() - range, false));
|
||||||
|
@ -199,7 +198,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeTempBasalData(long range) {
|
private void initializeTempBasalData(long range) {
|
||||||
aapsLogger.debug(LTag.DATATREATMENTS, "initializeTempBasalData");
|
getAapsLogger().debug(LTag.DATATREATMENTS, "initializeTempBasalData");
|
||||||
synchronized (tempBasals) {
|
synchronized (tempBasals) {
|
||||||
tempBasals.reset().add(MainApp.getDbHelper().getTemporaryBasalsDataFromTime(DateUtil.now() - range, false));
|
tempBasals.reset().add(MainApp.getDbHelper().getTemporaryBasalsDataFromTime(DateUtil.now() - range, false));
|
||||||
}
|
}
|
||||||
|
@ -207,7 +206,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeExtendedBolusData(long range) {
|
private void initializeExtendedBolusData(long range) {
|
||||||
aapsLogger.debug(LTag.DATATREATMENTS, "initializeExtendedBolusData");
|
getAapsLogger().debug(LTag.DATATREATMENTS, "initializeExtendedBolusData");
|
||||||
synchronized (extendedBoluses) {
|
synchronized (extendedBoluses) {
|
||||||
extendedBoluses.reset().add(MainApp.getDbHelper().getExtendedBolusDataFromTime(DateUtil.now() - range, false));
|
extendedBoluses.reset().add(MainApp.getDbHelper().getExtendedBolusDataFromTime(DateUtil.now() - range, false));
|
||||||
}
|
}
|
||||||
|
@ -215,14 +214,14 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeTempTargetData(long range) {
|
private void initializeTempTargetData(long range) {
|
||||||
aapsLogger.debug(LTag.DATATREATMENTS, "initializeTempTargetData");
|
getAapsLogger().debug(LTag.DATATREATMENTS, "initializeTempTargetData");
|
||||||
synchronized (tempTargets) {
|
synchronized (tempTargets) {
|
||||||
tempTargets.reset().add(MainApp.getDbHelper().getTemptargetsDataFromTime(DateUtil.now() - range, false));
|
tempTargets.reset().add(MainApp.getDbHelper().getTemptargetsDataFromTime(DateUtil.now() - range, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initializeProfileSwitchData(long range) {
|
private void initializeProfileSwitchData(long range) {
|
||||||
aapsLogger.debug(LTag.DATATREATMENTS, "initializeProfileSwitchData");
|
getAapsLogger().debug(LTag.DATATREATMENTS, "initializeProfileSwitchData");
|
||||||
synchronized (profiles) {
|
synchronized (profiles) {
|
||||||
profiles.reset().add(MainApp.getDbHelper().getProfileSwitchData(DateUtil.now() - range, false));
|
profiles.reset().add(MainApp.getDbHelper().getProfileSwitchData(DateUtil.now() - range, false));
|
||||||
}
|
}
|
||||||
|
@ -310,13 +309,13 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
|
|
||||||
long time = System.currentTimeMillis();
|
long time = System.currentTimeMillis();
|
||||||
synchronized (treatments) {
|
synchronized (treatments) {
|
||||||
aapsLogger.debug(MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: AllTreatmentsInDb: " + MedtronicUtil.getGsonInstanceCore().toJson(treatments));
|
getAapsLogger().debug(MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: AllTreatmentsInDb: " + MedtronicUtil.getGsonInstanceCore().toJson(treatments));
|
||||||
|
|
||||||
for (Treatment t : treatments) {
|
for (Treatment t : treatments) {
|
||||||
if (t.date <= time && t.date >= fromTimestamp)
|
if (t.date <= time && t.date >= fromTimestamp)
|
||||||
in5minback.add(t);
|
in5minback.add(t);
|
||||||
}
|
}
|
||||||
aapsLogger.debug(MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: FilteredTreatments: AfterTime={}, Items={} " + fromTimestamp + " " + MedtronicUtil.getGsonInstanceCore().toJson(in5minback));
|
getAapsLogger().debug(MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: FilteredTreatments: AfterTime={}, Items={} " + fromTimestamp + " " + MedtronicUtil.getGsonInstanceCore().toJson(in5minback));
|
||||||
return in5minback;
|
return in5minback;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -348,7 +347,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
last = t.date;
|
last = t.date;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
aapsLogger.debug(LTag.DATATREATMENTS, "Last bolus time: " + DateUtil.dateAndTimeString(last));
|
getAapsLogger().debug(LTag.DATATREATMENTS, "Last bolus time: " + DateUtil.dateAndTimeString(last));
|
||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,7 +362,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
last = t.date;
|
last = t.date;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
aapsLogger.debug(LTag.DATATREATMENTS, "Last manual bolus time: " + DateUtil.dateAndTimeString(last));
|
getAapsLogger().debug(LTag.DATATREATMENTS, "Last manual bolus time: " + DateUtil.dateAndTimeString(last));
|
||||||
return last;
|
return last;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -597,7 +596,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
public boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo, boolean allowUpdate) {
|
public boolean addToHistoryTreatment(DetailedBolusInfo detailedBolusInfo, boolean allowUpdate) {
|
||||||
boolean medtronicPump = MedtronicUtil.isMedtronicPump();
|
boolean medtronicPump = MedtronicUtil.isMedtronicPump();
|
||||||
|
|
||||||
aapsLogger.debug(MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: addToHistoryTreatment::isMedtronicPump={} " + medtronicPump);
|
getAapsLogger().debug(MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: addToHistoryTreatment::isMedtronicPump={} " + medtronicPump);
|
||||||
|
|
||||||
Treatment treatment = new Treatment();
|
Treatment treatment = new Treatment();
|
||||||
treatment.date = detailedBolusInfo.date;
|
treatment.date = detailedBolusInfo.date;
|
||||||
|
@ -612,7 +611,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
treatment.boluscalc = detailedBolusInfo.boluscalc != null ? detailedBolusInfo.boluscalc.toString() : null;
|
treatment.boluscalc = detailedBolusInfo.boluscalc != null ? detailedBolusInfo.boluscalc.toString() : null;
|
||||||
TreatmentService.UpdateReturn creatOrUpdateResult;
|
TreatmentService.UpdateReturn creatOrUpdateResult;
|
||||||
|
|
||||||
aapsLogger.debug(medtronicPump && MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: addToHistoryTreatment::treatment={} " + treatment);
|
getAapsLogger().debug(medtronicPump && MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: addToHistoryTreatment::treatment={} " + treatment);
|
||||||
|
|
||||||
if (!medtronicPump)
|
if (!medtronicPump)
|
||||||
creatOrUpdateResult = getService().createOrUpdate(treatment);
|
creatOrUpdateResult = getService().createOrUpdate(treatment);
|
||||||
|
@ -629,7 +628,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
carbsTreatment.date = detailedBolusInfo.date + detailedBolusInfo.carbTime * 60 * 1000L + 1000L; // add 1 sec to make them different records
|
carbsTreatment.date = detailedBolusInfo.date + detailedBolusInfo.carbTime * 60 * 1000L + 1000L; // add 1 sec to make them different records
|
||||||
carbsTreatment.carbs = detailedBolusInfo.carbs;
|
carbsTreatment.carbs = detailedBolusInfo.carbs;
|
||||||
|
|
||||||
aapsLogger.debug(medtronicPump && MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: carbTime!=0, creating second treatment. CarbsTreatment={}" + carbsTreatment);
|
getAapsLogger().debug(medtronicPump && MedtronicHistoryData.doubleBolusDebug, LTag.DATATREATMENTS, "DoubleBolusDebug: carbTime!=0, creating second treatment. CarbsTreatment={}" + carbsTreatment);
|
||||||
|
|
||||||
if (!medtronicPump)
|
if (!medtronicPump)
|
||||||
getService().createOrUpdate(carbsTreatment);
|
getService().createOrUpdate(carbsTreatment);
|
||||||
|
@ -641,7 +640,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
NSUpload.uploadTreatmentRecord(detailedBolusInfo);
|
NSUpload.uploadTreatmentRecord(detailedBolusInfo);
|
||||||
|
|
||||||
if (!allowUpdate && !creatOrUpdateResult.success) {
|
if (!allowUpdate && !creatOrUpdateResult.success) {
|
||||||
aapsLogger.error("Treatment could not be added to DB", new Exception());
|
getAapsLogger().error("Treatment could not be added to DB", new Exception());
|
||||||
|
|
||||||
String status = String.format(resourceHelper.gs(R.string.error_adding_treatment_message), treatment.insulin, (int) treatment.carbs, DateUtil.dateAndTimeString(treatment.date));
|
String status = String.format(resourceHelper.gs(R.string.error_adding_treatment_message), treatment.insulin, (int) treatment.carbs, DateUtil.dateAndTimeString(treatment.date));
|
||||||
|
|
||||||
|
@ -728,7 +727,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
@Override
|
@Override
|
||||||
public void addToHistoryProfileSwitch(ProfileSwitch profileSwitch) {
|
public void addToHistoryProfileSwitch(ProfileSwitch profileSwitch) {
|
||||||
//log.debug("Adding new TemporaryBasal record" + profileSwitch.log());
|
//log.debug("Adding new TemporaryBasal record" + profileSwitch.log());
|
||||||
rxBus.send(new EventDismissNotification(Notification.PROFILE_SWITCH_MISSING));
|
getRxBus().send(new EventDismissNotification(Notification.PROFILE_SWITCH_MISSING));
|
||||||
MainApp.getDbHelper().createOrUpdate(profileSwitch);
|
MainApp.getDbHelper().createOrUpdate(profileSwitch);
|
||||||
NSUpload.uploadProfileSwitch(profileSwitch);
|
NSUpload.uploadProfileSwitch(profileSwitch);
|
||||||
}
|
}
|
||||||
|
@ -757,7 +756,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
|
||||||
profileSwitch.percentage = percentage;
|
profileSwitch.percentage = percentage;
|
||||||
treatmentsPlugin.addToHistoryProfileSwitch(profileSwitch);
|
treatmentsPlugin.addToHistoryProfileSwitch(profileSwitch);
|
||||||
} else {
|
} else {
|
||||||
aapsLogger.error(LTag.PROFILE, "No profile switch exists");
|
getAapsLogger().error(LTag.PROFILE, "No profile switch exists");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
package info.nightscout.androidaps.services
|
||||||
|
|
||||||
|
import android.location.Location
|
||||||
|
import javax.inject.Inject
|
||||||
|
import javax.inject.Singleton
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by adrian on 2020-01-06.
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Singleton
|
||||||
|
class LastLocationDataContainer @Inject constructor() {
|
||||||
|
var lastLocation: Location? = null
|
||||||
|
}
|
|
@ -26,12 +26,14 @@ import io.reactivex.disposables.CompositeDisposable
|
||||||
import io.reactivex.schedulers.Schedulers
|
import io.reactivex.schedulers.Schedulers
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class LocationService @Inject constructor(): DaggerService() {
|
class LocationService : DaggerService() {
|
||||||
|
|
||||||
@Inject lateinit var aapsLogger: AAPSLogger
|
@Inject lateinit var aapsLogger: AAPSLogger
|
||||||
@Inject lateinit var rxBus: RxBusWrapper
|
@Inject lateinit var rxBus: RxBusWrapper
|
||||||
@Inject lateinit var sp: SP
|
@Inject lateinit var sp: SP
|
||||||
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
@Inject lateinit var fabricPrivacy: FabricPrivacy
|
||||||
@Inject lateinit var mainApp: MainApp
|
@Inject lateinit var mainApp: MainApp
|
||||||
|
@Inject lateinit var lastLocationDataContainer: LastLocationDataContainer
|
||||||
|
|
||||||
private val disposable = CompositeDisposable()
|
private val disposable = CompositeDisposable()
|
||||||
private var locationManager: LocationManager? = null
|
private var locationManager: LocationManager? = null
|
||||||
|
@ -40,8 +42,6 @@ class LocationService @Inject constructor(): DaggerService() {
|
||||||
private val LOCATION_INTERVAL_ACTIVE = T.mins(5).msecs()
|
private val LOCATION_INTERVAL_ACTIVE = T.mins(5).msecs()
|
||||||
private val LOCATION_INTERVAL_PASSIVE = T.mins(1).msecs() // this doesn't cost more power
|
private val LOCATION_INTERVAL_PASSIVE = T.mins(1).msecs() // this doesn't cost more power
|
||||||
|
|
||||||
var lastLocation: Location? = null
|
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val LOCATION_DISTANCE = 10f
|
private const val LOCATION_DISTANCE = 10f
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ class LocationService @Inject constructor(): DaggerService() {
|
||||||
|
|
||||||
override fun onLocationChanged(location: Location) {
|
override fun onLocationChanged(location: Location) {
|
||||||
aapsLogger.debug(LTag.LOCATION, "onLocationChanged: $location")
|
aapsLogger.debug(LTag.LOCATION, "onLocationChanged: $location")
|
||||||
lastLocation = location
|
lastLocationDataContainer.lastLocation = location
|
||||||
rxBus.send(EventLocationChange(location))
|
rxBus.send(EventLocationChange(location))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,17 +73,17 @@ class LocationService @Inject constructor(): DaggerService() {
|
||||||
|
|
||||||
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
override fun onStartCommand(intent: Intent, flags: Int, startId: Int): Int {
|
||||||
super.onStartCommand(intent, flags, startId)
|
super.onStartCommand(intent, flags, startId)
|
||||||
startForeground(mainApp.notificationId(), mainApp.getNotification())
|
startForeground(mainApp.notificationId(), mainApp.notification)
|
||||||
return Service.START_STICKY
|
return Service.START_STICKY
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate() {
|
override fun onCreate() {
|
||||||
super.onCreate()
|
super.onCreate()
|
||||||
startForeground(mainApp.notificationId(), mainApp.getNotification())
|
startForeground(mainApp.notificationId(), mainApp.notification)
|
||||||
|
|
||||||
// Get last location once until we get regular update
|
// Get last location once until we get regular update
|
||||||
LocationServices.getFusedLocationProviderClient(this).lastLocation.addOnSuccessListener {
|
LocationServices.getFusedLocationProviderClient(this).lastLocation.addOnSuccessListener {
|
||||||
lastLocation = it
|
lastLocationDataContainer.lastLocation = it
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeLocationManager()
|
initializeLocationManager()
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class TabPageAdapter extends FragmentPagerAdapter {
|
||||||
@Nullable
|
@Nullable
|
||||||
public Fragment getItem(int position) {
|
public Fragment getItem(int position) {
|
||||||
//Fragment fragment = (Fragment) visibleFragmentList.get(position);
|
//Fragment fragment = (Fragment) visibleFragmentList.get(position);
|
||||||
return Fragment.instantiate(context, visibleFragmentList.get(position).pluginDescription.getFragmentClass());
|
return Fragment.instantiate(context, visibleFragmentList.get(position).getPluginDescription().getFragmentClass());
|
||||||
}
|
}
|
||||||
|
|
||||||
public PluginBase getPluginAt(int position) {
|
public PluginBase getPluginAt(int position) {
|
||||||
|
|
|
@ -21,8 +21,8 @@ import info.nightscout.androidaps.utils.sharedPreferences.SP
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
class TddCalculator @Inject constructor(
|
class TddCalculator @Inject constructor(
|
||||||
val aapsLogger: AAPSLogger,
|
aapsLogger: AAPSLogger,
|
||||||
val rxBus: RxBusWrapper,
|
rxBus: RxBusWrapper,
|
||||||
val resourceHelper: ResourceHelper,
|
val resourceHelper: ResourceHelper,
|
||||||
val mainApp: MainApp,
|
val mainApp: MainApp,
|
||||||
val sp: SP,
|
val sp: SP,
|
||||||
|
|
Loading…
Reference in a new issue