From ba8c436136fff97a277714291a98cf2b43544d79 Mon Sep 17 00:00:00 2001 From: Andy Rozman Date: Thu, 18 Mar 2021 00:08:04 +0000 Subject: [PATCH 1/8] - added battery display, should be done --- .../pump/medtronic/MedtronicFragment.kt | 26 +++++++++- .../medtronic/driver/MedtronicPumpStatus.java | 12 ++--- .../service/RileyLinkMedtronicService.java | 2 + .../main/res/layout/medtronic_fragment.xml | 52 +++++++++++++++++++ medtronic/src/main/res/values/strings.xml | 6 +-- .../common/hw/rileylink/RileyLinkConst.java | 1 + 6 files changed, 88 insertions(+), 11 deletions(-) diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicFragment.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicFragment.kt index 1e9976fa74..a81e572441 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicFragment.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/MedtronicFragment.kt @@ -207,7 +207,7 @@ class MedtronicFragment : DaggerFragment() { when (medtronicPumpStatus.pumpDeviceState) { null, - PumpDeviceState.Sleeping -> binding.pumpStatusIcon.text = "{fa-bed} " // + pumpStatus.pumpDeviceState.name()); + PumpDeviceState.Sleeping -> binding.pumpStatusIcon.text = "{fa-bed} " // + pumpStatus.pumpDeviceState.name()); PumpDeviceState.NeverContacted, PumpDeviceState.WakingUp, PumpDeviceState.PumpUnreachable, @@ -215,7 +215,7 @@ class MedtronicFragment : DaggerFragment() { PumpDeviceState.TimeoutWhenCommunicating, PumpDeviceState.InvalidConfiguration -> binding.pumpStatusIcon.text = " " + resourceHelper.gs(medtronicPumpStatus.pumpDeviceState.resourceId) - PumpDeviceState.Active -> { + PumpDeviceState.Active -> { val cmd = medtronicUtil.currentCommand if (cmd == null) binding.pumpStatusIcon.text = " " + resourceHelper.gs(medtronicPumpStatus.pumpDeviceState.resourceId) @@ -328,5 +328,27 @@ class MedtronicFragment : DaggerFragment() { medtronicPumpPlugin.rileyLinkService?.verifyConfiguration() binding.errors.text = medtronicPumpStatus.errorInfo + + var showRileyLinkBatteryLevel: Boolean = medtronicPumpStatus.showRileyLinkBatteryLevel + + if (showRileyLinkBatteryLevel) { + binding.rlBatteryView.visibility = View.VISIBLE + binding.rlBatteryLabel.visibility = View.VISIBLE + binding.rlBatteryState.visibility = View.VISIBLE + binding.rlBatteryLayout.visibility = View.VISIBLE + binding.rlBatterySemicolon.visibility = View.VISIBLE + if (rileyLinkServiceData.batteryLevel == null) { + binding.rlBatteryState.text = " ?" + } else { + binding.rlBatteryState.text = "{fa-battery-" + rileyLinkServiceData.batteryLevel / 25 + "} " + rileyLinkServiceData.batteryLevel + "%" + } + } else { + binding.rlBatteryView.visibility = View.GONE + binding.rlBatteryLabel.visibility = View.GONE + binding.rlBatteryState.visibility = View.GONE + binding.rlBatteryLayout.visibility = View.GONE + binding.rlBatterySemicolon.visibility = View.GONE + } + } } diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/driver/MedtronicPumpStatus.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/driver/MedtronicPumpStatus.java index 9f1d2a092b..390668cdb2 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/driver/MedtronicPumpStatus.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/driver/MedtronicPumpStatus.java @@ -14,25 +14,24 @@ import javax.inject.Singleton; import info.nightscout.androidaps.plugins.bus.RxBusWrapper; import info.nightscout.androidaps.plugins.pump.common.defs.PumpDeviceState; import info.nightscout.androidaps.plugins.pump.common.defs.PumpType; +import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.RileyLinkUtil; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.data.RLHistoryItem; import info.nightscout.androidaps.plugins.pump.common.hw.rileylink.defs.RileyLinkTargetDevice; import info.nightscout.androidaps.plugins.pump.medtronic.defs.BasalProfileStatus; import info.nightscout.androidaps.plugins.pump.medtronic.defs.BatteryType; import info.nightscout.androidaps.plugins.pump.medtronic.defs.MedtronicDeviceType; -import info.nightscout.androidaps.plugins.pump.common.events.EventRileyLinkDeviceStatusChange; import info.nightscout.androidaps.plugins.pump.medtronic.util.MedtronicConst; import info.nightscout.androidaps.utils.resources.ResourceHelper; import info.nightscout.androidaps.utils.sharedPreferences.SP; - /** * Created by andy on 4/28/18. */ @Singleton -public class MedtronicPumpStatus extends info.nightscout.androidaps.plugins.pump.common.data.PumpStatus { +public class MedtronicPumpStatus extends info.nightscout.androidaps.plugins.pump.common.data.PumpStatus { private final ResourceHelper resourceHelper; private final SP sp; @@ -44,6 +43,7 @@ public class MedtronicPumpStatus extends info.nightscout.androidaps.plugins.pump public String pumpFrequency = null; public Double maxBolus; public Double maxBasal; + public boolean showRileyLinkBatteryLevel; // statuses private PumpDeviceState pumpDeviceState = PumpDeviceState.NeverContacted; @@ -62,9 +62,9 @@ public class MedtronicPumpStatus extends info.nightscout.androidaps.plugins.pump @Inject public MedtronicPumpStatus(ResourceHelper resourceHelper, - SP sp, - RxBusWrapper rxBus, - RileyLinkUtil rileyLinkUtil + SP sp, + RxBusWrapper rxBus, + RileyLinkUtil rileyLinkUtil ) { super(PumpType.Medtronic_522_722); this.resourceHelper = resourceHelper; diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java index 5447240b04..5fd8e30086 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/service/RileyLinkMedtronicService.java @@ -317,6 +317,8 @@ public class RileyLinkMedtronicService extends RileyLinkService { //boolean bolusDebug = bolusDebugEnabled != null && bolusDebugEnabled.equals(resourceHelper.gs(R.string.common_on)); //MedtronicHistoryData.doubleBolusDebug = bolusDebug; + medtronicPumpStatus.showRileyLinkBatteryLevel = sp.getBoolean(RileyLinkConst.Prefs.ShowBatteryLevel, false); + reconfigureService(forceRileyLinkAddressRenewal); return true; diff --git a/medtronic/src/main/res/layout/medtronic_fragment.xml b/medtronic/src/main/res/layout/medtronic_fragment.xml index 2be4848f46..bd30507a75 100644 --- a/medtronic/src/main/res/layout/medtronic_fragment.xml +++ b/medtronic/src/main/res/layout/medtronic_fragment.xml @@ -86,6 +86,58 @@ + + + + + + + + + + + + + + NiMH (Extended view) Bolus/Treatments Debugging - + + RileyLink Battery Errors @@ -79,8 +80,6 @@ Medtronic Pump History - - You cancelled Bolus, after it was already set on Pump. Since Medtronic Pump doesn\'t support cancel, you will need to manually cancel it. Put the Pump into Suspend mode and then do Resume (if you still want to cancel). Application will pick up changes, on next update (in less than 5 minutes). Could not read current TBR. @@ -117,6 +116,7 @@ Set neutral temp basals If enabled, it will cancel a temporary basal before the end of each hour. This method can help stop some pumps beeping/vibrating on the hour. + ^\\d{6} \ No newline at end of file diff --git a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkConst.java b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkConst.java index 28f551e188..2d6c93a0a9 100644 --- a/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkConst.java +++ b/rileylink/src/main/java/info/nightscout/androidaps/plugins/pump/common/hw/rileylink/RileyLinkConst.java @@ -37,6 +37,7 @@ public class RileyLinkConst { public static final String LastGoodDeviceCommunicationTime = Prefix + "lastGoodDeviceCommunicationTime"; public static final String LastGoodDeviceFrequency = Prefix + "LastGoodDeviceFrequency"; public static final int Encoding = R.string.key_medtronic_encoding; + public static final int ShowBatteryLevel = R.string.key_riley_link_show_battery_level; } public static class IPC { From 7d2e364c7795fb3306af2580e8b5b4551507b01e Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Fri, 19 Mar 2021 21:32:12 +0100 Subject: [PATCH 2/8] use UploadQueue through interface --- .idea/codeStyles/Project.xml | 16 +++++++++++++++ .../dependencyInjection/AppModule.kt | 18 ++++++++++++++--- .../historyBrowser/TreatmentsPluginHistory.kt | 4 ++-- .../general/nsclient/NSClientFragment.java | 3 ++- .../plugins/general/nsclient/UploadQueue.java | 17 ++++++++-------- .../nsclient/services/NSClientService.java | 20 +++++++++---------- .../plugins/treatments/TreatmentsPlugin.java | 8 ++++---- .../fragments/TreatmentsBolusFragment.kt | 8 ++++---- .../fragments/TreatmentsCareportalFragment.kt | 8 ++++---- .../TreatmentsExtendedBolusesFragment.kt | 6 +++--- .../TreatmentsProfileSwitchFragment.kt | 6 +++--- .../fragments/TreatmentsTempTargetFragment.kt | 6 +++--- .../androidaps/utils/stats/TddCalculator.kt | 4 ++-- .../interfaces/ConstraintsCheckerTest.kt | 3 +-- .../treatments/TreatmentsPluginTest.kt | 4 ++-- .../interfaces/UploadQueueAdminInterface.kt | 6 ++++++ .../interfaces/UploadQueueInterface.java | 11 +++++++++- .../pump/insight/LocalInsightPlugin.java | 4 ++-- 18 files changed, 98 insertions(+), 54 deletions(-) create mode 100644 core/src/main/java/info/nightscout/androidaps/interfaces/UploadQueueAdminInterface.kt diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml index ff53f4004f..3542887fac 100644 --- a/.idea/codeStyles/Project.xml +++ b/.idea/codeStyles/Project.xml @@ -2,6 +2,22 @@