From 4ff09a0125b4698ac4afe7099e88c559368bcaca Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Mon, 12 Mar 2018 22:16:10 +0100 Subject: [PATCH] show Dana model properly after communication error --- .../androidaps/plugins/PumpDanaR/DanaRFragment.java | 2 +- .../androidaps/plugins/PumpDanaR/DanaRPump.java | 10 +++++++--- .../plugins/PumpDanaR/comm/MsgInitConnStatusTime.java | 3 ++- .../PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java | 3 ++- .../plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java | 3 ++- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java index 06ec42fadc..833733e9de 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRFragment.java @@ -229,7 +229,7 @@ public class DanaRFragment extends SubscriberFragment { batteryView.setText("{fa-battery-" + (pump.batteryRemaining / 25) + "}"); SetWarnColor.setColorInverse(batteryView, pump.batteryRemaining, 51d, 26d); iobView.setText(pump.iob + " U"); - if (pump.isNewPump) { + if (pump.model != 0 || pump.protocol != 0 || pump.productCode != 0) { firmwareView.setText(String.format(MainApp.sResources.getString(R.string.danar_model), pump.model, pump.protocol, pump.productCode)); } else { firmwareView.setText("OLD"); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java index 0e1a9ceb75..520e12d454 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPump.java @@ -29,6 +29,10 @@ public class DanaRPump { return instance; } + public static void reset() { + instance = null; + } + public static final int UNITS_MGDL = 0; public static final int UNITS_MMOL = 1; @@ -69,9 +73,9 @@ public class DanaRPump { public static final int DOMESTIC_MODEL = 0x01; public static final int EXPORT_MODEL = 0x03; - public int model; - public int protocol; - public int productCode; + public int model = 0; + public int protocol = 0; + public int productCode = 0; public boolean isConfigUD; public boolean isExtendedBolusEnabled; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java index fe0d280113..ee0a9c8aaf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/comm/MsgInitConnStatusTime.java @@ -36,7 +36,8 @@ public class MsgInitConnStatusTime extends MessageBase { MainApp.getSpecificPlugin(DanaRPlugin.class).setFragmentEnabled(PluginBase.PUMP, false); MainApp.getSpecificPlugin(DanaRPlugin.class).setFragmentVisible(PluginBase.PUMP, false); - DanaRPump.getInstance().lastConnection = 0; // mark not initialized + DanaRPump.reset(); // mark not initialized + //If profile coming from pump, switch it as well if(MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginBase.PROFILE)){ (MainApp.getSpecificPlugin(DanaRPlugin.class)).setFragmentEnabled(PluginBase.PROFILE, false); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java index 3cf47b656f..89ccb7ae60 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/comm/MsgInitConnStatusTime_k.java @@ -37,7 +37,8 @@ public class MsgInitConnStatusTime_k extends MessageBase { MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginBase.PUMP, false); MainApp.getSpecificPlugin(DanaRPlugin.class).setFragmentEnabled(PluginBase.PUMP, true); MainApp.getSpecificPlugin(DanaRPlugin.class).setFragmentVisible(PluginBase.PUMP, true); - DanaRPump.getInstance().lastConnection = 0; // mark not initialized + + DanaRPump.reset(); // mark not initialized //If profile coming from pump, switch it as well if (MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).isEnabled(PluginBase.PROFILE)) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java index 60133d8d25..336230faf8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgCheckValue_v2.java @@ -49,7 +49,8 @@ public class MsgCheckValue_v2 extends MessageBase { MainApp.getSpecificPlugin(DanaRKoreanPlugin.class).setFragmentVisible(PluginBase.PUMP, true); MainApp.getSpecificPlugin(DanaRPlugin.class).setFragmentEnabled(PluginBase.PUMP, false); MainApp.getSpecificPlugin(DanaRPlugin.class).setFragmentVisible(PluginBase.PUMP, false); - DanaRPump.getInstance().lastConnection = 0; // mark not initialized + + DanaRPump.reset(); // mark not initialized //If profile coming from pump, switch it as well if(MainApp.getSpecificPlugin(DanaRPlugin.class).isEnabled(PluginBase.PROFILE)){