From 7f4888978ea2f1e7ce143bcc9c7c437617604c45 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 18 Sep 2017 13:28:00 +0200 Subject: [PATCH] warn if basal step is not 0.01 --- .../androidaps/plugins/Overview/Notification.java | 1 + .../androidaps/plugins/PumpDanaR/DanaRPlugin.java | 6 +++++- .../plugins/PumpDanaR/comm/MsgSettingMeal.java | 7 +++++++ .../plugins/PumpDanaRKorean/DanaRKoreanPlugin.java | 6 +++++- .../comm/DanaRS_Packet_Basal_Get_Basal_Rate.java | 13 +++++++++++++ .../DanaRS_Packet_Bolus_Set_Extended_Bolus.java | 2 +- .../plugins/PumpDanaRS/services/DanaRSService.java | 3 +-- .../plugins/PumpDanaRv2/DanaRv2Plugin.java | 6 +++++- app/src/main/res/values/strings.xml | 1 + 9 files changed, 39 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java index 13b85e08fc..0407f52110 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java @@ -49,6 +49,7 @@ public class Notification { public static final int NSURGENTALARM = 20; public static final int SHORT_DIA = 21; public static final int TOAST_ALARM = 22; + public static final int WRONGBASALSTEP = 23; public int id; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java index 9b85807cd1..faeb06f416 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java @@ -645,7 +645,11 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C } public static void doConnect(String from) { - if (sExecutionService != null) sExecutionService.connect(from); + if (sExecutionService != null) { + sExecutionService.connect(from); + pumpDescription.basalStep = pump.basalStep; + pumpDescription.bolusStep = pump.bolusStep; + } } public static boolean isConnected() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMeal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMeal.java index 4ed5de2920..727b6cd7fb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMeal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgSettingMeal.java @@ -40,6 +40,13 @@ public class MsgSettingMeal extends MessageBase { log.debug("Is Config U/d: " + pump.isConfigUD); } + if (pump.basalStep != 0.01d) { + Notification notification = new Notification(Notification.WRONGBASALSTEP, MainApp.sResources.getString(R.string.danar_setbasalstep001), Notification.URGENT); + MainApp.bus().post(new EventNewNotification(notification)); + } else { + MainApp.bus().post(new EventDismissNotification(Notification.WRONGBASALSTEP)); + } + if (pump.isConfigUD) { Notification notification = new Notification(Notification.UD_MODE_ENABLED, MainApp.sResources.getString(R.string.danar_switchtouhmode), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java index d688010de6..487a37b360 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java @@ -642,7 +642,11 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf } public static void doConnect(String from) { - if (sExecutionService != null) sExecutionService.connect(from); + if (sExecutionService != null) { + sExecutionService.connect(from); + pumpDescription.basalStep = pump.basalStep; + pumpDescription.bolusStep = pump.bolusStep; + } } public static boolean isConnected() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java index 74e97edd22..efc87d3834 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Get_Basal_Rate.java @@ -5,6 +5,11 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; +import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; +import info.nightscout.androidaps.plugins.Overview.Notification; +import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; +import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import com.cozmo.danar.util.BleCommandUtil; @@ -46,6 +51,14 @@ public class DanaRS_Packet_Basal_Get_Basal_Rate extends DanaRS_Packet { for (int index = 0; index < 24; index++) log.debug("Basal " + String.format("%02d", index) + "h: " + pump.pumpProfiles[pump.activeProfile][index]); } + + if (pump.basalStep != 0.01d) { + Notification notification = new Notification(Notification.WRONGBASALSTEP, MainApp.sResources.getString(R.string.danar_setbasalstep001), Notification.URGENT); + MainApp.bus().post(new EventNewNotification(notification)); + } else { + MainApp.bus().post(new EventDismissNotification(Notification.WRONGBASALSTEP)); + } + } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java index b663b3bf72..d5f61c0946 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus.java @@ -29,7 +29,7 @@ public class DanaRS_Packet_Bolus_Set_Extended_Bolus extends DanaRS_Packet { @Override public byte[] getRequestParams() { - int extendedBolusRate = (int) (extendedAmount / 100d); + int extendedBolusRate = (int) (extendedAmount * 100d); byte[] request = new byte[3]; request[0] = (byte) (extendedBolusRate & 0xff); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java index 047ed86e04..3687601a42 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/DanaRSService.java @@ -144,9 +144,8 @@ public class DanaRSService extends Service { sendMessage(new DanaRS_Packet_General_Get_Shipping_Information()); sendMessage(new DanaRS_Packet_Basal_Get_Profile_Number()); sendMessage(new DanaRS_Packet_Bolus_Get_Bolus_Option()); // isExtendedEnabled - sendMessage(new DanaRS_Packet_Basal_Get_Basal_Rate()); // basal profile sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information()); // bolusStep, maxBolus - sendMessage(new DanaRS_Packet_Basal_Get_Basal_Rate()); // basalStep, maxBasal + sendMessage(new DanaRS_Packet_Basal_Get_Basal_Rate()); // basal profile, basalStep, maxBasal sendMessage(new DanaRS_Packet_Bolus_Get_Calculation_Information()); // target sendMessage(new DanaRS_Packet_Bolus_Get_CIR_CF_Array()); sendMessage(new DanaRS_Packet_Option_Get_Pump_Time()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java index eb08a06b96..9bcf3ad319 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java @@ -574,7 +574,11 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface, } public static void doConnect(String from) { - if (sExecutionService != null) sExecutionService.connect(from); + if (sExecutionService != null) { + sExecutionService.connect(from); + pumpDescription.basalStep = pump.basalStep; + pumpDescription.bolusStep = pump.bolusStep; + } } public static boolean isConnected() { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index de6f756cb7..58b4f59a92 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -718,5 +718,6 @@ Pair new pump Bolus speed danars_bolusspeed + Set basal step to 0.01 U/h