proper danar errors detection

This commit is contained in:
Milos Kozak 2016-11-29 18:28:36 +01:00
parent 9c0c41f4f0
commit 36d5f1dc29
12 changed files with 74 additions and 70 deletions

View file

@ -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() {

View file

@ -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

View file

@ -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);
}
}

View file

@ -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();
}
}

View file

@ -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;

View file

@ -240,7 +240,7 @@
<string name="careportal_temporarytargetcancel">Отакажи временна цел</string>
<string name="comment">Коментар</string>
<string name="absolute">Абсолютна</string>
<string name="overview_bolusiprogress_occlusion">Запушване</string>
<string name="occlusion">Запушване</string>
<string name="overview_bolusprogress_delivered">Доставено</string>
<string name="overview_bolusprogress_goingtodeliver" formatted="false">Подаване на %.2fU Е инсулин</string>
<string name="overview_bolusprogress_stop">Стоп</string>

View file

@ -272,7 +272,7 @@
<string name="wrongpumppassword">Špatné heslo k pumpě</string>
<string name="mm640g">MM 640g</string>
<string name="danar_password">Heslo k pumpě</string>
<string name="overview_bolusiprogress_occlusion">Okluze</string>
<string name="occlusion">Okluze</string>
<string name="overview_bolusprogress_delivered">Podáno</string>
<string name="overview_bolusprogress_stop">Stop</string>
<string name="overview_bolusprogress_stoped">Zastaveno</string>

View file

@ -287,7 +287,7 @@
<string name="ns_upload_only_enabled">Bitte deaktivieren Sie \"Zu NightScout nur hochladen\" um dieses Feature zu nutzen.</string>
<string name="ns_upload_only_summary">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.</string>
<string name="othersettings_title">Andere</string>
<string name="overview_bolusiprogress_occlusion">Verstopfung</string>
<string name="occlusion">Verstopfung</string>
<string name="overview_bolusprogress_delivered">Abgegeben</string>
<string name="overview_bolusprogress_goingtodeliver">%.2fU werden abgegeben werden</string>
<string name="primefill">Füllen</string>

View file

@ -283,7 +283,7 @@
<string name="pumpbusy">Bomba ocupada</string>
<string name="overview_bolusprogress_delivered">Entregado</string>
<string name="overview_bolusprogress_stoped">Detenido</string>
<string name="overview_bolusiprogress_occlusion">Oclusión</string>
<string name="occlusion">Oclusión</string>
<string name="overview_bolusprogress_stop">Detener</string>
<string name="overview_bolusprogress_stoppressed">Parar pulsado</string>
<string name="waitingforpump">Esperando bomba</string>

View file

@ -286,7 +286,7 @@
<string name="pumpbusy">펌프가 바쁩니다</string>
<string name="overview_bolusprogress_delivered">주입됨</string>
<string name="overview_bolusprogress_stoped">정지됨</string>
<string name="overview_bolusiprogress_occlusion">Occlusion</string>
<string name="occlusion">Occlusion</string>
<string name="overview_bolusprogress_stop">정지</string>
<string name="overview_bolusprogress_stoppressed">정지 누름</string>
<string name="waitingforpump">펌프를 기다리고 있습니다.</string>

View file

@ -289,7 +289,7 @@
<string name="pumpbusy">Pump is busy</string>
<string name="overview_bolusprogress_delivered">Delivered</string>
<string name="overview_bolusprogress_stoped">Stopped</string>
<string name="overview_bolusiprogress_occlusion">Occlusion</string>
<string name="occlusion">Occlusion</string>
<string name="overview_bolusprogress_stop">Stop</string>
<string name="overview_bolusprogress_stoppressed">STOP PRESSED</string>
<string name="waitingforpump">Waiting for pump</string>
@ -371,4 +371,8 @@
<string name="wear">Wear</string>
<string name="resend_all_data">Resend All Data</string>
<string name="open_settings_on_wear">Open Settings on Wear</string>
<string name="pumperror">Pump Error</string>
<string name="lowbattery">Low Battery</string>
<string name="pumpshutdown">Pump Shutdown</string>
<string name="batterydischarged">Pump Battery Discharged</string>
</resources>

View file

@ -106,14 +106,6 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
@ -122,10 +114,15 @@
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/dependency-cache" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.1/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.google.android.gms/play-services-base/7.3.0/jars" />
@ -134,17 +131,11 @@
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/me.denley.wearpreferenceactivity/wearpreferenceactivity/0.5.0/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/ustwo-clockwise-debug/jars" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental-safeguard" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/pre-dexed" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />