From 36d5f1dc296996ace371245ae3f90cc55231a8f8 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 29 Nov 2016 18:28:36 +0100 Subject: [PATCH] proper danar errors detection --- .../ConfigBuilder/ConfigBuilderPlugin.java | 8 +-- .../plugins/DanaR/comm/MessageHashTable.java | 2 +- .../plugins/DanaR/comm/MsgError.java | 51 +++++++++++++++++++ .../plugins/DanaR/comm/MsgOcclusion.java | 40 --------------- .../plugins/OpenAPSMA/OpenAPSMAPlugin.java | 2 - app/src/main/res/values-bg/strings.xml | 2 +- app/src/main/res/values-cs/strings.xml | 2 +- app/src/main/res/values-de/strings.xml | 2 +- app/src/main/res/values-es/strings.xml | 2 +- app/src/main/res/values-ko/strings.xml | 2 +- app/src/main/res/values/strings.xml | 6 ++- wear/wear.iml | 25 +++------ 12 files changed, 74 insertions(+), 70 deletions(-) create mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgError.java delete mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgOcclusion.java diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index c99bd18f37..00d6beafcf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -38,7 +38,7 @@ import info.nightscout.androidaps.interfaces.ProfileInterface; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.TempBasalsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface; -import info.nightscout.androidaps.plugins.DanaR.comm.MsgOcclusion; +import info.nightscout.androidaps.plugins.DanaR.comm.MsgError; import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.androidaps.plugins.Loop.DeviceStatus; import info.nightscout.androidaps.plugins.Loop.LoopPlugin; @@ -922,7 +922,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain } - public void uploadDanaROcclusion() { + public void uploadError(String error) { Context context = MainApp.instance().getApplicationContext(); Bundle bundle = new Bundle(); bundle.putString("action", "dbAdd"); @@ -931,7 +931,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain try { data.put("eventType", "Announcement"); data.put("created_at", DateUtil.toISOString(new Date())); - data.put("notes", MainApp.sResources.getString(R.string.overview_bolusiprogress_occlusion)); + data.put("notes", error); data.put("isAnnouncement", true); } catch (JSONException e) { e.printStackTrace(); @@ -941,7 +941,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain intent.putExtras(bundle); intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES); context.sendBroadcast(intent); - DbLogger.dbAdd(intent, data.toString(), MsgOcclusion.class); + DbLogger.dbAdd(intent, data.toString(), MsgError.class); } public void uploadAppStart() { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MessageHashTable.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MessageHashTable.java index c9079c1898..5081bf81d6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MessageHashTable.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MessageHashTable.java @@ -33,7 +33,7 @@ public class MessageHashTable { put(new MsgSetTempBasalStop()); // 0x0403 CMD_PUMPSET_EXERCISE_STOP put(new MsgSetExtendedBolusStop()); // 0x0406 CMD_PUMPSET_EXPANS_INS_STOP put(new MsgSetExtendedBolusStart()); // 0x0407 CMD_PUMPSET_EXPANS_INS_S - put(new MsgOcclusion()); // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS + put(new MsgError()); // 0x0601 CMD_PUMPOWAY_SYSTEM_STATUS put(new MsgPCCommStart()); // 0x3001 CMD_CONNECT put(new MsgPCCommStop()); // 0x3002 CMD_DISCONNECT put(new MsgHistoryBolus()); // 0x3101 CMD_HISTORY_MEAL_INS diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgError.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgError.java new file mode 100644 index 0000000000..020256d1c7 --- /dev/null +++ b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgError.java @@ -0,0 +1,51 @@ +package info.nightscout.androidaps.plugins.DanaR.comm; + +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.events.EventOverviewBolusProgress; + +public class MsgError extends MessageBase { + private static Logger log = LoggerFactory.getLogger(MsgError.class); + + public MsgError() { + SetCommand(0x0601); + } + + @Override + public void handleMessage(byte[] bytes) { + int errorCode = intFromBuff(bytes, 0, 1); + String errorString = ""; + + switch (errorCode) { + case 1: + case 2: + case 3: // Pump error + errorString = MainApp.sResources.getString(R.string.pumperror) + " " + errorCode; + break; + case 4: // Shutdown + errorString = MainApp.sResources.getString(R.string.pumpshutdown); + break; + case 5: // Occlusion + errorString = MainApp.sResources.getString(R.string.occlusion); + EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); + MsgBolusStop.stopped = true; + bolusingEvent.status = errorString; + MainApp.bus().post(bolusingEvent); + break; + case 7: // Low Battery + errorString = MainApp.sResources.getString(R.string.lowbattery); + break; + case 8: // Battery 0% + errorString = MainApp.sResources.getString(R.string.batterydischarged); + break; + } + if (Config.logDanaMessageDetail) + log.debug("Error detected: " + errorString); + MainApp.getConfigBuilder().uploadError(errorString); + } + +} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgOcclusion.java b/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgOcclusion.java deleted file mode 100644 index 464bce3578..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/DanaR/comm/MsgOcclusion.java +++ /dev/null @@ -1,40 +0,0 @@ -package info.nightscout.androidaps.plugins.DanaR.comm; - -import android.content.Context; -import android.content.Intent; -import android.os.Bundle; - -import org.json.JSONException; -import org.json.JSONObject; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.util.Date; - -import info.nightscout.androidaps.Config; -import info.nightscout.androidaps.MainApp; -import info.nightscout.androidaps.R; -import info.nightscout.androidaps.Services.Intents; -import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; -import info.nightscout.client.data.DbLogger; -import info.nightscout.utils.DateUtil; - -public class MsgOcclusion extends MessageBase { - private static Logger log = LoggerFactory.getLogger(MsgOcclusion.class); - - public MsgOcclusion() { - SetCommand(0x0601); - } - - @Override - public void handleMessage(byte[] bytes) { - if (Config.logDanaMessageDetail) - log.debug("Oclusion detected"); - EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); - MsgBolusStop.stopped = true; - bolusingEvent.status = MainApp.sResources.getString(R.string.overview_bolusiprogress_occlusion); - MainApp.bus().post(bolusingEvent); - MainApp.getConfigBuilder().uploadDanaROcclusion(); - } - -} diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java index fb3c2c616a..4e13e75d17 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSMA/OpenAPSMAPlugin.java @@ -13,7 +13,6 @@ import org.slf4j.LoggerFactory; import java.io.IOException; import java.util.Date; -import java.util.StringTokenizer; import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; @@ -26,7 +25,6 @@ import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.TempBasalsInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface; -import info.nightscout.androidaps.plugins.DanaR.comm.MsgOcclusion; import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.androidaps.plugins.Loop.ScriptReader; import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSMAUpdateGui; diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index da3c1d5361..45a11aece9 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -240,7 +240,7 @@ Отакажи временна цел Коментар Абсолютна - Запушване + Запушване Доставено Подаване на %.2fU Е инсулин Стоп diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index f8e4ee93c1..4513cc125e 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -272,7 +272,7 @@ Špatné heslo k pumpě MM 640g Heslo k pumpě - Okluze + Okluze Podáno Stop Zastaveno diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index ddb9fbce4d..f2fe65ec95 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -287,7 +287,7 @@ Bitte deaktivieren Sie \"Zu NightScout nur hochladen\" um dieses Feature zu nutzen. Zu NightScout nur hochladen. Nicht wirksam bei SGV wenn nicht eine lokale Quelle wie xDrip gewählt wird. Nicht wirksam bei Profilen, wenn NS-Profile verwendet werden. Andere - Verstopfung + Verstopfung Abgegeben %.2fU werden abgegeben werden Füllen diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 5af78b08cf..731f33e5d5 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -283,7 +283,7 @@ Bomba ocupada Entregado Detenido - Oclusión + Oclusión Detener Parar pulsado Esperando bomba diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index d81f82769c..eaad826298 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -286,7 +286,7 @@ 펌프가 바쁩니다 주입됨 정지됨 - Occlusion + Occlusion 정지 정지 누름 펌프를 기다리고 있습니다. diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 695dd8acad..587f67da6f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -289,7 +289,7 @@ Pump is busy Delivered Stopped - Occlusion + Occlusion Stop STOP PRESSED Waiting for pump @@ -371,4 +371,8 @@ Wear Resend All Data Open Settings on Wear + Pump Error + Low Battery + Pump Shutdown + Pump Battery Discharged diff --git a/wear/wear.iml b/wear/wear.iml index 20c1f89da7..a09c181fa1 100644 --- a/wear/wear.iml +++ b/wear/wear.iml @@ -106,14 +106,6 @@ - - - - - - - - @@ -122,10 +114,15 @@ - + + + + + + + + - - @@ -134,17 +131,11 @@ - - - - - -