From cdd3c259296976a945a8a834da7c7479e1f3992a Mon Sep 17 00:00:00 2001 From: Adrian AndroidAPS Date: Thu, 28 Mar 2019 17:25:57 +0100 Subject: [PATCH] only run DST helper on certain pumps --- .../androidaps/interfaces/PumpInterface.java | 1 + .../constraints/dstHelper/DstHelperPlugin.java | 11 ++++++++++- .../androidaps/plugins/pump/combo/ComboPlugin.java | 5 +++++ .../plugins/pump/danaR/AbstractDanaRPlugin.java | 8 ++++++++ .../androidaps/plugins/pump/danaRS/DanaRSPlugin.java | 5 +++++ .../plugins/pump/insight/LocalInsightPlugin.java | 5 +++++ .../androidaps/plugins/pump/mdi/MDIPlugin.java | 5 +++++ .../plugins/pump/virtual/VirtualPumpPlugin.java | 5 +++++ 8 files changed, 44 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java index 7e8f2ef181..3690312cf8 100644 --- a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java +++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java @@ -65,6 +65,7 @@ public interface PumpInterface { PumpEnactResult loadTDDs(); + public boolean canHandleDST(); List getCustomActions(); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/dstHelper/DstHelperPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/dstHelper/DstHelperPlugin.java index 2862cc3d7a..5c24427e40 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/dstHelper/DstHelperPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/dstHelper/DstHelperPlugin.java @@ -12,8 +12,10 @@ import info.nightscout.androidaps.interfaces.ConstraintsInterface; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginType; +import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.logging.L; import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin; +import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.general.overview.notifications.Notification; import info.nightscout.androidaps.utils.T; @@ -92,12 +94,19 @@ public class DstHelperPlugin extends PluginBase implements ConstraintsInterface //Return false if time to DST change is less than 91 and positive @Override public Constraint isLoopInvocationAllowed(Constraint value) { + + PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump(); + if (pump == null || pump.canHandleDST()) { + log.debug("Pump can handle DST"); + return value; + } + try { this.dstTest(Calendar.getInstance()); } catch (Exception e) { e.printStackTrace(); } - if (this.minutesToChange <= 90 && minutesToChange > 0 && value.value()) { + if (this.minutesToChange <= 180 && minutesToChange > 0 && value.value()) { try { LoopPlugin loopPlugin = LoopPlugin.getPlugin(); if (loopPlugin.suspendedTo() == 0L) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java index a84e3db9a8..557ba42168 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/combo/ComboPlugin.java @@ -1391,4 +1391,9 @@ public class ComboPlugin extends PluginBase implements PumpInterface, Constraint } + @Override + public boolean canHandleDST() { + return false; + } + } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java index d6f25f9c02..749307e1a7 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaR/AbstractDanaRPlugin.java @@ -488,4 +488,12 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte } + @Override + public boolean canHandleDST() { + return false; + } + + + + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java index d2eb132f61..ddbb8547ae 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/danaRS/DanaRSPlugin.java @@ -827,4 +827,9 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte } + @Override + public boolean canHandleDST() { + return false; + } + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java index 22b329edbb..ccc38c1b9b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/insight/LocalInsightPlugin.java @@ -1569,4 +1569,9 @@ public class LocalInsightPlugin extends PluginBase implements PumpInterface, Con Notification notification = new Notification(Notification.INSIGHT_TIMEOUT_DURING_HANDSHAKE, MainApp.gs(R.string.timeout_during_handshake), Notification.URGENT); new Handler(Looper.getMainLooper()).post(() -> MainApp.bus().post(new EventNewNotification(notification))); } + + @Override + public boolean canHandleDST() { + return true; + } } \ No newline at end of file diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java index bdd060183b..89d1184581 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/mdi/MDIPlugin.java @@ -260,4 +260,9 @@ public class MDIPlugin extends PluginBase implements PumpInterface { } + @Override + public boolean canHandleDST() { + return true; + } + } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.java index e60cd78a64..461f71c31d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/pump/virtual/VirtualPumpPlugin.java @@ -455,6 +455,11 @@ public class VirtualPumpPlugin extends PluginBase implements PumpInterface { return pumpType; } + @Override + public boolean canHandleDST() { + return true; + } + public void refreshConfiguration() { String pumptype = SP.getString(R.string.key_virtualpump_type, "Generic AAPS");