Inherit from HardLimits class

This commit is contained in:
Tim Gunn 2020-05-02 01:50:35 +12:00
parent b54e1a0af3
commit 560a081c7c
No known key found for this signature in database
GPG key ID: C9BC1E9D0D0AED8C

View file

@ -68,6 +68,7 @@ import info.nightscout.androidaps.utils.FabricPrivacy;
import info.nightscout.androidaps.utils.T; import info.nightscout.androidaps.utils.T;
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;
import info.nightscout.androidaps.utils.HardLimits;
import io.reactivex.disposables.CompositeDisposable; import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.schedulers.Schedulers; import io.reactivex.schedulers.Schedulers;
@ -88,6 +89,7 @@ public class LoopPlugin extends PluginBase {
private final IobCobCalculatorPlugin iobCobCalculatorPlugin; private final IobCobCalculatorPlugin iobCobCalculatorPlugin;
private final ReceiverStatusStore receiverStatusStore; private final ReceiverStatusStore receiverStatusStore;
private final FabricPrivacy fabricPrivacy; private final FabricPrivacy fabricPrivacy;
private final HardLimits hardLimits;
private CompositeDisposable disposable = new CompositeDisposable(); private CompositeDisposable disposable = new CompositeDisposable();
@ -132,7 +134,8 @@ public class LoopPlugin extends PluginBase {
Lazy<ActionStringHandler> actionStringHandler, // TODO Adrian use RxBus instead of Lazy Lazy<ActionStringHandler> actionStringHandler, // TODO Adrian use RxBus instead of Lazy
IobCobCalculatorPlugin iobCobCalculatorPlugin, IobCobCalculatorPlugin iobCobCalculatorPlugin,
ReceiverStatusStore receiverStatusStore, ReceiverStatusStore receiverStatusStore,
FabricPrivacy fabricPrivacy FabricPrivacy fabricPrivacy,
HardLimits hardLimits
) { ) {
super(new PluginDescription() super(new PluginDescription()
.mainType(PluginType.LOOP) .mainType(PluginType.LOOP)
@ -158,6 +161,7 @@ public class LoopPlugin extends PluginBase {
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin; this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
this.receiverStatusStore = receiverStatusStore; this.receiverStatusStore = receiverStatusStore;
this.fabricPrivacy = fabricPrivacy; this.fabricPrivacy = fabricPrivacy;
this.hardLimits = hardLimits;
loopSuspendedTill = sp.getLong("loopSuspendedTill", 0L); loopSuspendedTill = sp.getLong("loopSuspendedTill", 0L);
isSuperBolus = sp.getBoolean("isSuperBolus", false); isSuperBolus = sp.getBoolean("isSuperBolus", false);
@ -292,12 +296,12 @@ public class LoopPlugin extends PluginBase {
Constraint<Boolean> closedLoopEnabled = constraintChecker.isClosedLoopAllowed(); Constraint<Boolean> closedLoopEnabled = constraintChecker.isClosedLoopAllowed();
Double MaxIOBallowed = constraintChecker.getMaxIOBAllowed().value(); Double MaxIOBallowed = constraintChecker.getMaxIOBAllowed().value();
String APSmode = sp.getString(R.string.key_aps_mode, "open"); String APSmode = sp.getString(R.string.key_aps_mode, "open");
Double LGSthreshold = 0d;
PumpInterface pump = activePlugin.getActivePump(); PumpInterface pump = activePlugin.getActivePump();
boolean isLGS = false; boolean isLGS = false;
if (!isSuspended() && !pump.isSuspended()) if (!isSuspended() && !pump.isSuspended())
if (closedLoopEnabled.value()) if (closedLoopEnabled.value())
if ((MaxIOBallowed.equals(LGSthreshold)) || (APSmode.equals("lgs"))) if ((MaxIOBallowed.equals(hardLimits.getMAXIOB_LGS())) || (APSmode.equals("lgs")))
isLGS = true; isLGS = true;
return isLGS; return isLGS;