From a617d591b03aafe355cee20767d93554d2db9f1d Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 7 Oct 2017 22:29:55 +0200 Subject: [PATCH 01/26] fix NPE --- .../plugins/IobCobCalculator/IobCobCalculatorPlugin.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java index 445eda93cd..a76e694372 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/IobCobCalculatorPlugin.java @@ -366,6 +366,9 @@ public class IobCobCalculatorPlugin implements PluginBase { continue; } + if (profile.getIsf(bgTime) == null) + return; // profile not set yet + double sens = Profile.toMgdl(profile.getIsf(bgTime), profile.getUnits()); AutosensData autosensData = new AutosensData(); From d77fa9b0cf540c19c9763c7e7e4f66404e3b8fa5 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Mon, 16 Oct 2017 21:48:08 +0200 Subject: [PATCH 02/26] Revert "NDK filters to work around j2v8 vs. libBleCommandUtil issue." This reverts commit 7c0478700496f4deb0ee28f6b12ab10b049f8f74. --- app/build.gradle | 1 - gradle.properties | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 30158bf591..c9df240616 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -50,7 +50,6 @@ android { buildConfigField "String", "BUILDVERSION", generateGitBuild() ndk { - abiFilters "armeabi-v7a", "x86", "armeabi", "mips" moduleName "BleCommandUtil" } } diff --git a/gradle.properties b/gradle.properties index c8d0d56109..1d3591c8a4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -15,6 +15,4 @@ # When configured, Gradle will run in incubating parallel mode. # This option should only be used with decoupled projects. More details, visit # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects -# org.gradle.parallel=true - -android.useDeprecatedNdk=true \ No newline at end of file +# org.gradle.parallel=true \ No newline at end of file From f7a46d386e60335d8e04db433d7c40cc773a44d5 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Mon, 16 Oct 2017 21:52:06 +0200 Subject: [PATCH 03/26] Remove j2v8. --- app/build.gradle | 1 - .../androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java | 2 -- 2 files changed, 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index c9df240616..0294d49f9c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -151,7 +151,6 @@ dependencies { } compile 'org.slf4j:slf4j-api:1.7.12' compile 'com.jjoe64:graphview:4.0.1' - compile 'com.eclipsesource.j2v8:j2v8:3.1.6@aar' compile 'com.joanzapata.iconify:android-iconify-fontawesome:2.1.1' compile 'com.google.android.gms:play-services-wearable:7.5.0' compile 'junit:junit:4.12' diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java index 774ff55401..e4c23ae043 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSAMA/DetermineBasalResultAMA.java @@ -1,7 +1,5 @@ package info.nightscout.androidaps.plugins.OpenAPSAMA; -import com.eclipsesource.v8.V8Object; - import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; From a35262840f246fd6d276ccedb33c98adda45e1c7 Mon Sep 17 00:00:00 2001 From: warstar2187 Date: Wed, 18 Oct 2017 13:49:17 +0900 Subject: [PATCH 04/26] Update strings.xml --- app/src/main/res/values-ko/strings.xml | 41 +++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index a591ac5c27..034565119a 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -342,10 +342,10 @@ NS에 업로드만 하기. 로컬소스(xDrip)가 선택되지 않으면 SGV에는 효력이 없습니다. NS프로파일이 사용중이라면 프로파일에는 효력이 없습니다. 펌프가 초기화 되지 않았습니다! 펌프가 초기화와 프로파일 설정이 되지 않았습니다! - 공기/채움 + 교체/채움 양이 인퓨전세트의 사양과 일치하는지 확인하세요! 기타 - 공기/채움 기본 인슐린양 + 교체/채움 기본 인슐린양 버튼1 버튼2 버튼3 @@ -411,7 +411,7 @@ 비율 #일 가중 - 공기/채움을 위해 식사주입을 사용한 경우 부정확할 수 있습니다!! + 교체/채움을 위해 식사주입을 사용한 경우 부정확할 수 있습니다!! 오래된 데이터입니다. "새로고침"을 누르세요. 총기초량 총기초량 * 2 @@ -648,5 +648,38 @@ ACTIVATE PROFILE Date INVALID - AndroidAPS + + 펌프연동위해 대기중 + 연동완료 + 연동시간초과 + 연동중 + 현재까지 발견된 기기가 없습니다. + 빈 주사기 + 혈당측정알람 + 남아있는 인슐린 양 + 다나RS + Dana + 선택된 펌프 + 새 펌프와 연동 + 식사주입 속도 + 기초주입 단위를 0.01 U/h로 설정하세요 + 시리얼번호 + 퍼센트 + 시간 이동 + 임시목표 기본값 + eatingsoon 기간 + eatingsoon 목표 + activity 기간 + activity 목표 + 교체 + 확장식사주입 상태 가져오는중 + 식사주입 상태 가져오는중 + 임시기초주입 상태 가져오는중 + 펌프 설정 가져오는중 + 펌프시간 가져오는중 + 재사용 + 워치로 작동하기 + 임시목표와 관리입력을 워치로 설정합니다. + 연결시간초과 + From e3d3664ac29c24887c428c7e342c7a6ea79639d9 Mon Sep 17 00:00:00 2001 From: warstar2187 Date: Wed, 18 Oct 2017 16:39:55 +0900 Subject: [PATCH 05/26] Update strings.xml --- app/src/main/res/values-ko/strings.xml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 034565119a..003f16edb7 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -541,7 +541,7 @@ Superbolus 앱시작을 NS에 기록하기 설정을 적용하기위해 앱을 종료합니다. - DanaRv2 + 다나Rv2 인슐린 Fast Acting Insulin Novorapid, Novolog, Humalog @@ -557,7 +557,7 @@ 펌웨어 최근 연결 블루투스 상태 - About + 버전정보 SMS 권한 누락 DEV xDrip 상태(워치) @@ -649,14 +649,14 @@ Date INVALID - 펌프연동위해 대기중 + 펌프연동 대기중 연동완료 연동시간초과 연동중 현재까지 발견된 기기가 없습니다. 빈 주사기 혈당측정알람 - 남아있는 인슐린 양 + 남은 인슐린 양 다나RS Dana 선택된 펌프 @@ -673,9 +673,9 @@ activity 목표 교체 확장식사주입 상태 가져오는중 - 식사주입 상태 가져오는중 - 임시기초주입 상태 가져오는중 - 펌프 설정 가져오는중 + 식사주입상태 가져오는중 + 임시기초주입상태 가져오는중 + 펌프설정 가져오는중 펌프시간 가져오는중 재사용 워치로 작동하기 From 434f4474b5a7f1daaf0f0c5d11b7fd357ba9b393 Mon Sep 17 00:00:00 2001 From: McHoffi Date: Wed, 18 Oct 2017 11:11:41 +0200 Subject: [PATCH 06/26] DE_translations --- app/src/main/res/values-de/strings.xml | 58 +++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index c01c25b549..919f2fa693 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -231,7 +231,7 @@ Kein Bluetoothadapter gefunden Remote Bolus ist nicht erlaubt Um Bolus %.2fU bitte mit %s antworten - Korean + Koreanisch Limit erreicht Falsches Pumpen-Passwort! Warte auf Pumpe. Klicke zum aktualisieren. @@ -512,7 +512,7 @@ Restart Beende Applikation um neue Einstellungen zu laden. Fortsetzten - Russian + Russisch Kalibrierung %.1f an xDrip senden? Passwort für die Einstellungen Setzte temp Basal @@ -619,4 +619,58 @@ DIA von %s ist zu kurz - aaps nutzt stattdessen %s! Möglicherweise ungenau, wenn zum Befüllen ein Bolus verwendet wurde! Verhältnis + aktiviere Profil + Aktivitätsdauer + Aktivitätsziel + BZ-Messung + Bolus Geschwindigkeit + Prozentsatz + Zeitverschiebung + BAT + CircadianPercantage + Verbindungs-Unterbrechungs-Dauer + Füllen + DE Bolus + DS Bolus + E Bolus + Basalschritt setzen zu 0.01 U/h + Tägl. Basalmenge + Tägl. Basalmenge * 2 + Tägl. Gesamtdosis + Gerät nicht gefunden + DanaRS + Dana + Datum + Standard Temp. Ziele + Eating Soon Dauer + Eating Soon Ziel + Reservoir leer + Ausgeführt + Ermittle Bolus Status + Ermittle verz. Bolus Status + Ermittle Pumpen Einstell. + Ermittle Pumpenzeit + Ermittle temp. Basal Status + Ungültig + Langes durchschn. Delta + ICT + integrierter NSClient + Basaltyp + Verbindung Zeit überschritten + Verbinde neue Pumpe + Delta Einstellungen + Restinsulin + erneut verwenden + ausgewählte Pumpe + Seriennummer + auf Verbindung warten + Setze temp. Ziele und Behandlungen auf Uhr + Steuerung von der Uhr + SENS + SEN + Verbindung OK + Verbindung + PRE + Interner NSClient + NSCI From f0ee2b8bedde9ff37fe647bb58a3ef8143a8b625 Mon Sep 17 00:00:00 2001 From: Radoslav Radev Date: Wed, 18 Oct 2017 14:25:34 +0300 Subject: [PATCH 07/26] Update strings.xml --- app/src/main/res/values-bg/strings.xml | 38 ++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index 98969b41c0..df333a105a 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -11,7 +11,7 @@ Сигурни ли сте че искате да изтриете всички данни? Изход Използвай удължен болус за над 200% - DanaR Bluetooth устройство + DanaR Bluetooth устройство Използване на абсолютни стойности за базал Рестартирайте телефона или AndroidAPS от системните настройки или Android APS няма да записва проблемите (което е важно за работата на алгоритъма)! Цел: @@ -71,7 +71,7 @@ Стойност Срок Основание - КЗ + Кръвна захар Промяна Delta: Средна промяна @@ -448,7 +448,7 @@ По подразбиране: разрешено\nТова позволява на autosens да променя и целевите КЗ(освен чувствителност и базал). По подразбиране: 2\nBolus snooze се активира след като поставите болус за основно хранене, така Loop няма да пуснка/намаля базалите веднага след като сте се хранили. Примерът тук е с 2; така при 3 часа DIA това ще означава че bolus snooze ще бъде внимателно изместен 1.5 часа (3DIA/2). По подразбиране: 3.0\nТова е настройка на количеството на покачване на КЗ при усвояване на въглехидратите за всеки 5 минути. По подразбиране 3мг/дл/5мин. Това се отразява на това колко бързо се усвояват COB според алгоритъма, и как това се отразява в предвиждането на КЗ, когато тя не се покачва или пада с различен темп от очакваното. - Attention!\nNormally you do not have to change these values below. Please CLICK HERE and READ the text and make sure you UNDERSTAND it before change any of these values. + Внимание! Обикновенно вие не трябва да променяте тези стойности. Моля НАТИСНЕТЕ ТУК, ПРОЧЕТЕТЕ текста и бъдете сигурни, че вие го РАЗБИРАТЕ преди да направите промени на тези стойности! http://openaps.readthedocs.io/en/latest/docs/walkthrough/phase-3/beyond-low-glucose-suspend.html Позволени са само числа Позволени са числа между %1$s - %2$s @@ -649,4 +649,36 @@ Swedish Fiasp Ултра бързодействащ по Oref + време за физ. активност + Целева КЗ при физ. активност + Скорост на болус + % промяна + Време на отместване + Все още устройството не е намерено + DanaRS + Dana + Временна цел по подразбиране + Време за \"Преди хранене\" + Цел за \"Преди хранене\" + Празен резервоар + Получава болус статус + Получава статус на удължен болус + Получава настройки на помпа + Получава време на помпата + Получава статус на временен базал + СДВОЯВАНЕ + Сдвоени + Времето за сдвояване изтече + Сдвояване с нова помпа + опитва отново + Избрана помпа + Сериен номер + ЛЕЧ + Очаква сдвояване с помпа + Времето за връзка изтече + Преглед на известията + Изпращай известията като съобщения към часовника + Настройки на часовник + Задаване временни цели и въвеждане Лечения от часовник Android wear + Контролиране от часовник From fe9fefa6010d968367dd5ebc7123f7792ebea499 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 18 Oct 2017 20:06:35 +0200 Subject: [PATCH 08/26] Update strings.xml --- app/src/main/res/values-bg/strings.xml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index df333a105a..ab3a2bb64f 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -72,9 +72,9 @@ Срок Основание Кръвна захар - Промяна + Изменение (Δ) Delta: - Средна промяна + Средно изменение (Δ), Конфигурация Цели OpenAPS MA @@ -85,8 +85,6 @@ Лечения Виртуална помпа Careportal - - Помпа Treatments Временен базал @@ -140,7 +138,7 @@ Несъвместима версия на Nightscout NSClient не е открит. Записът е загубен! КЗ да се вижда в NS - Статуса на помпа да е достъпен в NS + Статуса на помпата да е достъпен в NS Ръчно приложени LOOP Е СПРЯН ОТ ОГРАНИЧЕНИЯТА Czech @@ -370,7 +368,7 @@ Отвори настройките на часовника Грешка в промпата Изтощена батерия - Помпа изключена + Помпата е изключена Батерията на помпата е изтощена DanaR Korean Избран е грешен тип помпа @@ -448,7 +446,7 @@ По подразбиране: разрешено\nТова позволява на autosens да променя и целевите КЗ(освен чувствителност и базал). По подразбиране: 2\nBolus snooze се активира след като поставите болус за основно хранене, така Loop няма да пуснка/намаля базалите веднага след като сте се хранили. Примерът тук е с 2; така при 3 часа DIA това ще означава че bolus snooze ще бъде внимателно изместен 1.5 часа (3DIA/2). По подразбиране: 3.0\nТова е настройка на количеството на покачване на КЗ при усвояване на въглехидратите за всеки 5 минути. По подразбиране 3мг/дл/5мин. Това се отразява на това колко бързо се усвояват COB според алгоритъма, и как това се отразява в предвиждането на КЗ, когато тя не се покачва или пада с различен темп от очакваното. - Внимание! Обикновенно вие не трябва да променяте тези стойности. Моля НАТИСНЕТЕ ТУК, ПРОЧЕТЕТЕ текста и бъдете сигурни, че вие го РАЗБИРАТЕ преди да направите промени на тези стойности! + Внимание! Обикновено Вие не трябва да променяте тези стойности. Моля НАТИСНЕТЕ ТУК, прочетете текста и бъдете сигурни, че го РАЗБИРАТЕ преди да направите каквито и да е промени! http://openaps.readthedocs.io/en/latest/docs/walkthrough/phase-3/beyond-low-glucose-suspend.html Позволени са само числа Позволени са числа между %1$s - %2$s @@ -529,7 +527,7 @@ Wrong duration Loop suspended Loop resumed - промяна за 15мин + Δ за 15мин COB Суперболус Записвай всяко стартиране на AndroidAPS в NS @@ -652,7 +650,7 @@ време за физ. активност Целева КЗ при физ. активност Скорост на болус - % промяна + % на изменение Време на отместване Все още устройството не е намерено DanaRS @@ -663,8 +661,8 @@ Празен резервоар Получава болус статус Получава статус на удължен болус - Получава настройки на помпа - Получава време на помпата + Получава настройките на помпата + Получава времето на помпата Получава статус на временен базал СДВОЯВАНЕ Сдвоени From 28430d117d029536c2dc0fb271a8429b8c1cfeb5 Mon Sep 17 00:00:00 2001 From: Simon Pauwels <18055382+boysim@users.noreply.github.com> Date: Wed, 18 Oct 2017 21:19:12 +0200 Subject: [PATCH 09/26] Update dutch --- app/src/main/res/values-nl/strings.xml | 32 ++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index eb6b45b33a..f1388b4af7 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -649,4 +649,36 @@ Snel-werkende Oref Fiasp Ultra-Rapid Oref + Periode van inspanning + Activiteits doel + Bloed glucose meetpunt alarm + Bolus snelheid + Percentage + Tijd verschuiving + Connectie verlopen + Vullen + Zet de basale stap op 0,01 E/u + Geen toestel gevonden + DanaRS + Dana + Standaart tijdelijk basaal + Eet binnenkort periode + Eet binnenkort doel + Bolus status ophalen + Vertraagde bolus status ophalen + Pomp instellingen ophalen + Pomp tijd ophalen + Ophalen van tijdelijke basaal status + Koppelen + Koppeling geslaagd + Koppeling verlopen + Koppel nieuwe pomp + Resterende insuline hoeveelheid + Herbruik + Geselecteerde pomp + Serie nummer + Stel tijdelijke doelen en bolussen in vanop je horloge. + Bedieningen via horloge + Ampull leeg + Wachten op koppelen van de pomp From 17eec803f4e9adf48bbaea36d76a7e6467beb09e Mon Sep 17 00:00:00 2001 From: diabetesdt1 Date: Thu, 19 Oct 2017 16:03:31 +0200 Subject: [PATCH 10/26] Update strings.xml --- app/src/main/res/values-de/strings.xml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 919f2fa693..e0ebb8e2f9 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -165,7 +165,7 @@ LOOP DEAKTIVIERT DURCH DIE BESCHRÄNKUNG Nach Beschränkungen Loop - Manual enacts + Manuelle Eingriffe Kohlenhydrate Beschränkung erreicht Reset Datenbanken Minimale Dauer @@ -231,7 +231,7 @@ Kein Bluetoothadapter gefunden Remote Bolus ist nicht erlaubt Um Bolus %.2fU bitte mit %s antworten - Koreanisch + Korean Limit erreicht Falsches Pumpen-Passwort! Warte auf Pumpe. Klicke zum aktualisieren. @@ -314,8 +314,8 @@ LOOP LP DANA - "CONF" - "CPP" + CONF + CPP CP Bitte verwenden Sie nur Ziffern. Pflichtfeld @@ -591,7 +591,7 @@ Empfindlichkeitserkennung COB Aktiviere die SuperBolus-Funktion im Wizard. Nicht aktivieren, wenn du nicht weißt, was es macht! ES KANN ZU EINER ÜBERDOSIERUNG AN INSULIN KOMMEN, WENN DU ES BLIND BENUTZT! - "Verstehen des OpenLoops und der Temp-Basal-Empfehlungen + Verstehen des OpenLoops und der Temp-Basal-Empfehlungen Verwende AMA Autosense Um Basal mit %.2fU/h zu starten, antworte mit dem Code %s Fiasp @@ -673,4 +673,5 @@ PRE Interner NSClient NSCI + Aktivitätsdauer From 51caffa5915f649abad407e3143b4f1b6ee9d9d3 Mon Sep 17 00:00:00 2001 From: diabetesdt1 Date: Thu, 19 Oct 2017 16:40:36 +0200 Subject: [PATCH 11/26] Update strings.xml --- app/src/main/res/values-de/strings.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index e0ebb8e2f9..b8c561c6c6 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -673,5 +673,4 @@ PRE Interner NSClient NSCI - Aktivitätsdauer From 0b7832ec60ebb49576072aeff2c31b493127fd7d Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 19 Oct 2017 19:23:19 +0200 Subject: [PATCH 12/26] getUnits from active profile not interface --- .../androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b60ab20d88..b9e13f0426 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 @@ -961,7 +961,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain } public String getProfileUnits() { - return activeProfile.getUnits(); + return getProfile().getUnits(); } public Profile getProfile(long time) { From c258b41f11f30d990d0f824a3084ce3cafdbfb52 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 19 Oct 2017 19:35:35 +0200 Subject: [PATCH 13/26] allow to use actual profile in wizard --- .../plugins/Overview/Dialogs/WizardDialog.java | 13 +++++++------ app/src/main/res/values/strings.xml | 1 + 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java index 308965a5ea..dbe16c0a9b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/WizardDialog.java @@ -32,6 +32,7 @@ import com.squareup.otto.Subscribe; import org.json.JSONException; import org.json.JSONObject; +import org.mozilla.javascript.tools.debugger.Main; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -401,15 +402,11 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com ArrayList profileList; profileList = profileStore.getProfileList(); + profileList.add(0, MainApp.sResources.getString(R.string.active)); ArrayAdapter adapter = new ArrayAdapter(getContext(), R.layout.spinner_centered, profileList); profileSpinner.setAdapter(adapter); - // set selected to actual profile - for (int p = 0; p < profileList.size(); p++) { - if (profileList.get(p).equals(MainApp.getConfigBuilder().getProfileName())) - profileSpinner.setSelection(p); - } String units = profile.getUnits(); bgUnits.setText(units); @@ -451,7 +448,11 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com if (profileSpinner == null || profileSpinner.getSelectedItem() == null) return; // not initialized yet String selectedAlternativeProfile = profileSpinner.getSelectedItem().toString(); - Profile specificProfile = profile.getSpecificProfile(selectedAlternativeProfile); + Profile specificProfile; + if (selectedAlternativeProfile.equals(MainApp.sResources.getString(R.string.active))) + specificProfile = MainApp.getConfigBuilder().getProfile(); + else + specificProfile = profile.getSpecificProfile(selectedAlternativeProfile); // Entered values Double c_bg = SafeParse.stringToDouble(editBg.getText()); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b5f3037145..3b25c78dd2 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -746,5 +746,6 @@ Controls from Watch Set Temp-Targets and enter Treatments from the watch. Connection timed out + ]]> From b76cb755e053781ee68d726726620e77d2fdd621 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 19 Oct 2017 20:37:37 +0200 Subject: [PATCH 14/26] CS translations --- app/src/main/res/values-cs/strings.xml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index beb7c370e4..d8d486603c 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -659,4 +659,8 @@ Nastavování dočasných cílů a vkládání ošetření na hodinkách Wear Řízení z hodinek Wear Model: %02X Protokol: %02X Kód: %02X + ]]> + Výstraha měření glykémie + Vypršel čas připojování + DC From e545f75d6975934592ecb75eba347c3ee94918df Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 20 Oct 2017 11:34:33 +0200 Subject: [PATCH 15/26] fix displaying XX:30 time intervals --- app/src/main/java/info/nightscout/androidaps/data/Profile.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/data/Profile.java b/app/src/main/java/info/nightscout/androidaps/data/Profile.java index 1ec6f54b71..61c7397694 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/Profile.java +++ b/app/src/main/java/info/nightscout/androidaps/data/Profile.java @@ -256,7 +256,7 @@ public class Profile { private String format_HH_MM(Integer timeAsSeconds) { String time; int hour = timeAsSeconds / 60 / 60; - int minutes = timeAsSeconds - hour * 60 * 60; + int minutes = (timeAsSeconds - hour * 60 * 60) / 60; DecimalFormat df = new DecimalFormat("00"); time = df.format(hour) + ":" + df.format(minutes); return time; From 01d6f1594ad2165296b99278603e0c0f9b937e0a Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 20 Oct 2017 17:37:06 +0200 Subject: [PATCH 16/26] RS synchronized change --- .../plugins/PumpDanaRS/DanaRSPlugin.java | 44 ++++++++++++++----- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java index 04a82ed1bd..f26bdb6fad 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java @@ -49,6 +49,7 @@ import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.plugins.PumpDanaRS.events.EventDanaRSDeviceChange; import info.nightscout.androidaps.plugins.PumpDanaRS.services.DanaRSService; import info.nightscout.utils.DateUtil; +import info.nightscout.utils.DecimalFormatter; import info.nightscout.utils.Round; import info.nightscout.utils.SP; @@ -218,7 +219,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, connect(from); } - public static synchronized void connect(String from) { + public static void connect(String from) { log.debug("RS connect from: " + from); if (danaRSService != null && !mDeviceAddress.equals("") && !mDeviceName.equals("")) { final Object o = new Object(); @@ -375,7 +376,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, } @Override - public int setNewBasalProfile(Profile profile) { + public synchronized int setNewBasalProfile(Profile profile) { if (danaRSService == null) { log.error("setNewBasalProfile sExecutionService is null"); return FAILED; @@ -426,7 +427,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, } @Override - public void refreshDataFromPump(String reason) { + public synchronized void refreshDataFromPump(String reason) { log.debug("Refreshing data from pump"); if (!isConnected() && !isConnecting()) { connect(reason); @@ -440,7 +441,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, } @Override - public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) { + public synchronized PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) { ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin); if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) { @@ -504,7 +505,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, // This is called from APS @Override - public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean enforceNew) { + public synchronized PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean enforceNew) { // Recheck pump status if older than 30 min if (pump.lastConnection.getTime() + 30 * 60 * 1000L < System.currentTimeMillis()) { connect("setTempBasalAbsolute old data"); @@ -581,7 +582,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, } @Override - public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) { + public synchronized PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) { PumpEnactResult result = new PumpEnactResult(); ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); percent = configBuilderPlugin.applyBasalConstraints(percent); @@ -632,7 +633,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, return result; } - public PumpEnactResult setHighTempBasalPercent(Integer percent) { + public synchronized PumpEnactResult setHighTempBasalPercent(Integer percent) { PumpEnactResult result = new PumpEnactResult(); connectIfNotConnected("hightempbasal"); boolean connectionOK = danaRSService.highTempBasal(percent); @@ -656,7 +657,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, } @Override - public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) { + public synchronized PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) { ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); insulin = configBuilderPlugin.applyBolusConstraints(insulin); // needs to be rounded @@ -699,7 +700,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, } @Override - public PumpEnactResult cancelTempBasal(boolean force) { + public synchronized PumpEnactResult cancelTempBasal(boolean force) { PumpEnactResult result = new PumpEnactResult(); TemporaryBasal runningTB = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()); if (runningTB != null) { @@ -725,7 +726,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, } @Override - public PumpEnactResult cancelExtendedBolus() { + public synchronized PumpEnactResult cancelExtendedBolus() { PumpEnactResult result = new PumpEnactResult(); ExtendedBolus runningEB = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis()); if (runningEB != null) { @@ -808,7 +809,28 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, @Override public String shortStatus(boolean veryShort) { - return null; + String ret = ""; + if (pump.lastConnection.getTime() != 0) { + Long agoMsec = System.currentTimeMillis() - pump.lastConnection.getTime(); + int agoMin = (int) (agoMsec / 60d / 1000d); + ret += "LastConn: " + agoMin + " minago\n"; + } + if (pump.lastBolusTime.getTime() != 0) { + ret += "LastBolus: " + DecimalFormatter.to2Decimal(pump.lastBolusAmount) + "U @" + android.text.format.DateFormat.format("HH:mm", pump.lastBolusTime) + "\n"; + } + if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) { + ret += "Temp: " + MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull() + "\n"; + } + if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) { + ret += "Extended: " + MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis()).toString() + "\n"; + } + if (!veryShort) { + ret += "TDD: " + DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U\n"; + } + ret += "IOB: " + pump.iob + "U\n"; + ret += "Reserv: " + DecimalFormatter.to0Decimal(pump.reservoirRemainingUnits) + "U\n"; + ret += "Batt: " + pump.batteryRemaining + "\n"; + return ret; } @Override From dbf5a5e577af9e5f6fa87b9edbd08bea82b9812e Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 21 Oct 2017 13:14:06 +0200 Subject: [PATCH 17/26] Sensitivity logging optional --- .../SensitivityWeightedAveragePlugin.java | 26 +++++++++++-------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java index 258ea09b33..68537cf47c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SensitivityWeightedAverage/SensitivityWeightedAveragePlugin.java @@ -5,11 +5,9 @@ import android.support.v4.util.LongSparseArray; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.util.ArrayList; -import java.util.Arrays; import java.util.Date; -import java.util.List; +import info.nightscout.androidaps.Config; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.Profile; @@ -32,7 +30,7 @@ public class SensitivityWeightedAveragePlugin implements PluginBase, Sensitivity private boolean fragmentEnabled = true; private boolean fragmentVisible = false; - static SensitivityWeightedAveragePlugin plugin = null; + private static SensitivityWeightedAveragePlugin plugin = null; public static SensitivityWeightedAveragePlugin getPlugin() { if (plugin == null) @@ -108,13 +106,15 @@ public class SensitivityWeightedAveragePlugin implements PluginBase, Sensitivity int hoursForDetection = SP.getInt(R.string.key_openapsama_autosens_period, defaultHours); if (autosensDataTable == null || autosensDataTable.size() < 4) { - log.debug("No autosens data available"); + if (Config.logAutosensData) + log.debug("No autosens data available"); return new AutosensResult(); } AutosensData current = IobCobCalculatorPlugin.getAutosensData(toTime); if (current == null) { - log.debug("No autosens data available"); + if (Config.logAutosensData) + log.debug("No autosens data available"); return new AutosensResult(); } @@ -181,9 +181,10 @@ public class SensitivityWeightedAveragePlugin implements PluginBase, Sensitivity double sens = profile.getIsf(); String ratioLimit = ""; - String sensResult = ""; + String sensResult; - log.debug("Records: " + index + " " + pastSensitivity); + if (Config.logAutosensData) + log.debug("Records: " + index + " " + pastSensitivity); double average = weightedsum / weights; double basalOff = average * (60 / 5) / Profile.toMgdl(sens, profile.getUnits()); @@ -197,7 +198,8 @@ public class SensitivityWeightedAveragePlugin implements PluginBase, Sensitivity sensResult = "Sensitivity normal"; } - log.debug(sensResult); + if (Config.logAutosensData) + log.debug(sensResult); double rawRatio = ratio; ratio = Math.max(ratio, SafeParse.stringToDouble(SP.getString("openapsama_autosens_min", "0.7"))); @@ -205,10 +207,12 @@ public class SensitivityWeightedAveragePlugin implements PluginBase, Sensitivity if (ratio != rawRatio) { ratioLimit = "Ratio limited from " + rawRatio + " to " + ratio; - log.debug(ratioLimit); + if (Config.logAutosensData) + log.debug(ratioLimit); } - log.debug("Sensitivity to: " + new Date(toTime).toLocaleString() + " weightedaverage: " + average + " ratio: " + ratio); + if (Config.logAutosensData) + log.debug("Sensitivity to: " + new Date(toTime).toLocaleString() + " weightedaverage: " + average + " ratio: " + ratio); AutosensResult output = new AutosensResult(); output.ratio = Round.roundTo(ratio, 0.01); From 075b74ec84ac66eea7eb1cdc0d23e71c6c677986 Mon Sep 17 00:00:00 2001 From: Radoslav Radev Date: Sat, 21 Oct 2017 17:11:25 +0300 Subject: [PATCH 18/26] Update strings.xml --- app/src/main/res/values-bg/strings.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/res/values-bg/strings.xml b/app/src/main/res/values-bg/strings.xml index ab3a2bb64f..03266a5b4a 100644 --- a/app/src/main/res/values-bg/strings.xml +++ b/app/src/main/res/values-bg/strings.xml @@ -650,7 +650,7 @@ време за физ. активност Целева КЗ при физ. активност Скорост на болус - % на изменение + % от профила Време на отместване Все още устройството не е намерено DanaRS @@ -668,7 +668,7 @@ Сдвоени Времето за сдвояване изтече Сдвояване с нова помпа - опитва отново + отново Избрана помпа Сериен номер ЛЕЧ From 9c7c583aed80b84beff66a30780ddaab38615ef5 Mon Sep 17 00:00:00 2001 From: McHoffi Date: Sat, 21 Oct 2017 17:41:01 +0200 Subject: [PATCH 19/26] Split to smaller pieces --- .../plugins/NSClientInternal/broadcasts/BroadcastTreatment.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java index 9dd63a83fe..c6158be296 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/broadcasts/BroadcastTreatment.java @@ -183,7 +183,7 @@ public class BroadcastTreatment { ret.add(newarr); } newarr = new JSONArray(); - count = 50; + count = 20; } newarr.put(array.get(i)); --count; From a8751bf35a27591e245f5412c24644f308e89084 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 21 Oct 2017 18:05:19 +0200 Subject: [PATCH 20/26] Detailed onscreen history logging --- .../DanaRS_Packet_APS_History_Events.java | 35 +++++++++++++++---- .../PumpDanaRv2/comm/MsgHistoryEvents_v2.java | 25 ++++++++++++- 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java index fe010eb72f..8e58dc2cb5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_History_Events.java @@ -10,15 +10,14 @@ import java.util.Date; import java.util.GregorianCalendar; import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; -import info.nightscout.androidaps.db.DanaRHistoryRecord; import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.TemporaryBasal; +import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; -import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes; -import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRSyncStatus; import info.nightscout.utils.DateUtil; public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { @@ -32,11 +31,11 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { private int sec = 0; public boolean done; - public int totalCount; + private int totalCount; public static long lastEventTimeLoaded = 0; - public DanaRS_Packet_APS_History_Events() { + DanaRS_Packet_APS_History_Events() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE__APS_HISTORY_EVENTS; done = false; @@ -97,70 +96,87 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime()); if (detailedBolusInfo == null) { - log.debug("DetailedBolusInfo not found for " + datetime.toLocaleString()); + log.debug("Detailed bolus info not found for " + datetime.toLocaleString()); detailedBolusInfo = new DetailedBolusInfo(); + } else { + log.debug("Detailed bolus info found: " + detailedBolusInfo); } detailedBolusInfo.date = datetime.getTime(); detailedBolusInfo.source = Source.PUMP; detailedBolusInfo.pumpId = datetime.getTime(); + String status; + switch (recordCode) { case DanaRPump.TEMPSTART: log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min"); temporaryBasal.percentRate = param1; temporaryBasal.durationInMinutes = param2; MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal); + status = "TEMPSTART " + DateUtil.timeString(datetime); break; case DanaRPump.TEMPSTOP: log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString()); MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal); + status = "TEMPSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.EXTENDEDSTART: log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); extendedBolus.insulin = param1 / 100d; extendedBolus.durationInMinutes = param2; MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); + status = "EXTENDEDSTART " + DateUtil.timeString(datetime); break; case DanaRPump.EXTENDEDSTOP: log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); + status = "EXTENDEDSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.BOLUS: detailedBolusInfo.insulin = param1 / 100d; boolean newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); DetailedBolusInfoStorage.remove(detailedBolusInfo.date); + status = "BOLUS " + DateUtil.timeString(datetime); break; case DanaRPump.DUALBOLUS: detailedBolusInfo.insulin = param1 / 100d; newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); DetailedBolusInfoStorage.remove(detailedBolusInfo.date); + status = "DUALBOLUS " + DateUtil.timeString(datetime); break; case DanaRPump.DUALEXTENDEDSTART: log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); extendedBolus.insulin = param1 / 100d; extendedBolus.durationInMinutes = param2; MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); + status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime); break; case DanaRPump.DUALEXTENDEDSTOP: log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); + status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.SUSPENDON: log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString()); + status = "SUSPENDON " + DateUtil.timeString(datetime); break; case DanaRPump.SUSPENDOFF: log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString()); + status = "SUSPENDOFF " + DateUtil.timeString(datetime); break; case DanaRPump.REFILL: log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); + status = "REFILL " + DateUtil.timeString(datetime); break; case DanaRPump.PRIME: log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); + status = "PRIME " + DateUtil.timeString(datetime); break; case DanaRPump.PROFILECHANGE: log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h"); + status = "PROFILECHANGE " + DateUtil.timeString(datetime); break; case DanaRPump.CARBS: DetailedBolusInfo emptyCarbsInfo = new DetailedBolusInfo(); @@ -170,17 +186,22 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet { emptyCarbsInfo.pumpId = datetime.getTime(); newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(emptyCarbsInfo); log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g"); + status = "CARBS " + DateUtil.timeString(datetime); break; case DanaRPump.PRIMECANNULA: - log.debug("EVENT PRIME CANNULA(" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); + log.debug("EVENT PRIMECANNULA(" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); + status = "PRIMECANNULA " + DateUtil.timeString(datetime); break; default: log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2); + status = "UNKNOWN " + DateUtil.timeString(datetime); break; } if (datetime.getTime() > lastEventTimeLoaded) lastEventTimeLoaded = datetime.getTime(); + + MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.processinghistory) + ": " + status)); } @Override diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java index f04218ac61..922047e5cb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/comm/MsgHistoryEvents_v2.java @@ -7,13 +7,16 @@ import java.util.Date; import java.util.GregorianCalendar; import info.nightscout.androidaps.MainApp; +import info.nightscout.androidaps.R; import info.nightscout.androidaps.data.DetailedBolusInfo; import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.Source; import info.nightscout.androidaps.db.TemporaryBasal; +import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.MessageBase; +import info.nightscout.utils.DateUtil; public class MsgHistoryEvents_v2 extends MessageBase { private static Logger log = LoggerFactory.getLogger(MsgHistoryEvents_v2.class); @@ -65,70 +68,87 @@ public class MsgHistoryEvents_v2 extends MessageBase { DetailedBolusInfo detailedBolusInfo = DetailedBolusInfoStorage.findDetailedBolusInfo(datetime.getTime()); if (detailedBolusInfo == null) { - log.debug("DetailedBolusInfo not found for " + datetime.toLocaleString()); + log.debug("Detailed bolus info not found for " + datetime.toLocaleString()); detailedBolusInfo = new DetailedBolusInfo(); + } else { + log.debug("Detailed bolus info found: " + detailedBolusInfo); } detailedBolusInfo.date = datetime.getTime(); detailedBolusInfo.source = Source.PUMP; detailedBolusInfo.pumpId = datetime.getTime(); + String status = ""; + switch (recordCode) { case DanaRPump.TEMPSTART: log.debug("EVENT TEMPSTART (" + recordCode + ") " + datetime.toLocaleString() + " Ratio: " + param1 + "% Duration: " + param2 + "min"); temporaryBasal.percentRate = param1; temporaryBasal.durationInMinutes = param2; MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal); + status = "TEMPSTART " + DateUtil.timeString(datetime); break; case DanaRPump.TEMPSTOP: log.debug("EVENT TEMPSTOP (" + recordCode + ") " + datetime.toLocaleString()); MainApp.getConfigBuilder().addToHistoryTempBasal(temporaryBasal); + status = "TEMPSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.EXTENDEDSTART: log.debug("EVENT EXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); extendedBolus.insulin = param1 / 100d; extendedBolus.durationInMinutes = param2; MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); + status = "EXTENDEDSTART " + DateUtil.timeString(datetime); break; case DanaRPump.EXTENDEDSTOP: log.debug("EVENT EXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); + status = "EXTENDEDSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.BOLUS: detailedBolusInfo.insulin = param1 / 100d; boolean newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); log.debug((newRecord ? "**NEW** " : "") + "EVENT BOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); DetailedBolusInfoStorage.remove(detailedBolusInfo.date); + status = "BOLUS " + DateUtil.timeString(datetime); break; case DanaRPump.DUALBOLUS: detailedBolusInfo.insulin = param1 / 100d; newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(detailedBolusInfo); log.debug((newRecord ? "**NEW** " : "") + "EVENT DUALBOLUS (" + recordCode + ") " + datetime.toLocaleString() + " Bolus: " + (param1 / 100d) + "U Duration: " + param2 + "min"); DetailedBolusInfoStorage.remove(detailedBolusInfo.date); + status = "DUALBOLUS " + DateUtil.timeString(datetime); break; case DanaRPump.DUALEXTENDEDSTART: log.debug("EVENT DUALEXTENDEDSTART (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + (param1 / 100d) + "U Duration: " + param2 + "min"); extendedBolus.insulin = param1 / 100d; extendedBolus.durationInMinutes = param2; MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); + status = "DUALEXTENDEDSTART " + DateUtil.timeString(datetime); break; case DanaRPump.DUALEXTENDEDSTOP: log.debug("EVENT DUALEXTENDEDSTOP (" + recordCode + ") " + datetime.toLocaleString() + " Delivered: " + (param1 / 100d) + "U RealDuration: " + param2 + "min"); MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus); + status = "DUALEXTENDEDSTOP " + DateUtil.timeString(datetime); break; case DanaRPump.SUSPENDON: log.debug("EVENT SUSPENDON (" + recordCode + ") " + datetime.toLocaleString()); + status = "SUSPENDON " + DateUtil.timeString(datetime); break; case DanaRPump.SUSPENDOFF: log.debug("EVENT SUSPENDOFF (" + recordCode + ") " + datetime.toLocaleString()); + status = "SUSPENDOFF " + DateUtil.timeString(datetime); break; case DanaRPump.REFILL: log.debug("EVENT REFILL (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); + status = "REFILL " + DateUtil.timeString(datetime); break; case DanaRPump.PRIME: log.debug("EVENT PRIME (" + recordCode + ") " + datetime.toLocaleString() + " Amount: " + param1 / 100d + "U"); + status = "PRIME " + DateUtil.timeString(datetime); break; case DanaRPump.PROFILECHANGE: log.debug("EVENT PROFILECHANGE (" + recordCode + ") " + datetime.toLocaleString() + " No: " + param1 + " CurrentRate: " + (param2 / 100d) + "U/h"); + status = "PROFILECHANGE " + DateUtil.timeString(datetime); break; case DanaRPump.CARBS: DetailedBolusInfo emptyCarbsInfo = new DetailedBolusInfo(); @@ -138,14 +158,17 @@ public class MsgHistoryEvents_v2 extends MessageBase { emptyCarbsInfo.pumpId = datetime.getTime(); newRecord = MainApp.getConfigBuilder().addToHistoryTreatment(emptyCarbsInfo); log.debug((newRecord ? "**NEW** " : "") + "EVENT CARBS (" + recordCode + ") " + datetime.toLocaleString() + " Carbs: " + param1 + "g"); + status = "CARBS " + DateUtil.timeString(datetime); break; default: log.debug("Event: " + recordCode + " " + datetime.toLocaleString() + " Param1: " + param1 + " Param2: " + param2); + status = "UNKNOWN " + DateUtil.timeString(datetime); break; } if (datetime.getTime() > lastEventTimeLoaded) lastEventTimeLoaded = datetime.getTime(); + MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.processinghistory) + ": " + status)); } } From 7dd678c917100db2632a4d9774bc3500e0923b04 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 21 Oct 2017 18:55:56 +0200 Subject: [PATCH 21/26] Better bolusing with different speeds (R & Rv2) --- .../androidaps/data/DetailedBolusInfo.java | 10 ++++ .../DetailedBolusInfoStorage.java | 6 +- .../plugins/PumpDanaR/SerialIOThread.java | 4 +- .../services/DanaRExecutionService.java | 43 +++++++++++--- .../plugins/PumpDanaRv2/DanaRv2Plugin.java | 7 ++- .../plugins/PumpDanaRv2/SerialIOThread.java | 4 +- .../services/DanaRv2ExecutionService.java | 56 +++++++++++++------ app/src/main/res/values/arrays.xml | 6 +- app/src/main/res/values/strings.xml | 3 + 9 files changed, 101 insertions(+), 38 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java b/app/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java index 2d928a5541..7720b03d3e 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java +++ b/app/src/main/java/info/nightscout/androidaps/data/DetailedBolusInfo.java @@ -29,4 +29,14 @@ public class DetailedBolusInfo { public Context context = null; // context for progress dialog public long pumpId = 0; // id of record if comming from pump history (not a newly created treatment) public boolean isSMB = false; // is a Super-MicroBolus + + @Override + public String toString() { + return new Date(date).toLocaleString() + + " insulin: " + insulin + + " carbs: " + carbs + + " isValid: " + isValid + + " carbTime: " + carbTime + + " isSMB: " + isSMB; + } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java index d6352cdb18..abe3c75c73 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/DetailedBolusInfoStorage.java @@ -20,7 +20,7 @@ public class DetailedBolusInfoStorage { private static List store = new ArrayList<>(); public static void add(DetailedBolusInfo detailedBolusInfo) { - log.debug("Bolus info stored: " + new Date(detailedBolusInfo.date).toLocaleString()); + log.debug("Stored bolus info: " + detailedBolusInfo); store.add(detailedBolusInfo); } @@ -29,7 +29,7 @@ public class DetailedBolusInfoStorage { DetailedBolusInfo found = null; for (int i = 0; i < store.size(); i++) { long infoTime = store.get(i).date; - log.debug("Existing info: " + new Date(infoTime).toLocaleString()); + log.debug("Existing bolus info: " + store.get(i)); if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) { found = store.get(i); break; @@ -42,7 +42,7 @@ public class DetailedBolusInfoStorage { for (int i = 0; i < store.size(); i++) { long infoTime = store.get(i).date; if (bolustime > infoTime - 60 * 1000 && bolustime < infoTime + 60 * 1000) { - log.debug("Removing info: " + new Date(infoTime).toLocaleString()); + log.debug("Removing bolus info: " + store.get(i)); store.remove(i); break; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java index af3b852aa6..b6a54f4ec1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/SerialIOThread.java @@ -187,12 +187,12 @@ public class SerialIOThread extends Thread { scheduledDisconnection = null; } } - // prepare task for execution in 5 sec + // prepare task for execution in 10 sec // cancel waiting task to prevent sending multiple disconnections if (scheduledDisconnection != null) scheduledDisconnection.cancel(false); Runnable task = new DisconnectRunnable(); - final int sec = 5; + final int sec = 10; scheduledDisconnection = worker.schedule(task, sec, TimeUnit.SECONDS); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java index 9d94634094..1ef5349f25 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/services/DanaRExecutionService.java @@ -34,6 +34,7 @@ import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.data.Profile; +import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.SerialIOThread; @@ -410,12 +411,12 @@ public class DanaRExecutionService extends Service { public boolean bolus(double amount, int carbs, Treatment t) { bolusingTreatment = t; - int speed = SP.getInt(R.string.key_danars_bolusspeed, 0); + int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0); MessageBase start; - if (speed == 0) + if (preferencesSpeed == 0) start = new MsgBolusStart(amount); else - start = new MsgBolusStartWithSpeed(amount, speed); + start = new MsgBolusStartWithSpeed(amount, preferencesSpeed); MsgBolusStop stop = new MsgBolusStop(amount, t); connect("bolus"); @@ -426,7 +427,7 @@ public class DanaRExecutionService extends Service { } MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables - long startTime = System.currentTimeMillis(); + long bolusStart = System.currentTimeMillis(); if (!stop.stopped) { mSerialIOThread.sendMessage(start); @@ -436,23 +437,47 @@ public class DanaRExecutionService extends Service { } while (!stop.stopped && !start.failed) { waitMsec(100); - if ((System.currentTimeMillis() - progress.lastReceive) > 5 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm + if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm stop.stopped = true; stop.forced = true; log.debug("Communication stopped"); } } waitMsec(300); + + EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); + bolusingEvent.t = t; + bolusingEvent.percent = 99; + bolusingTreatment = null; + + int speed = 12; + switch (preferencesSpeed) { + case 0: + speed = 12; + break; + case 1: + speed = 30; + break; + case 2: + speed = 60; + break; + } // try to find real amount if bolusing was interrupted or comm failed if (t.insulin != amount) { disconnect("bolusingInterrupted"); - long now = System.currentTimeMillis(); - long estimatedBolusEnd = (long) (startTime + amount / 5d * 60 * 1000); // std delivery rate 5 U/min - waitMsec(Math.max(5000, estimatedBolusEnd - now + 3000)); + long bolusDurationInMSec = (long) (amount * speed * 1000); + long expectedEnd = bolusStart + bolusDurationInMSec + 3000; + + while (System.currentTimeMillis() < expectedEnd) { + long waitTime = expectedEnd - System.currentTimeMillis(); + bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.waitingforestimatedbolusend), waitTime / 1000); + MainApp.bus().post(bolusingEvent); + SystemClock.sleep(1000); + } connect("bolusingInterrupted"); getPumpStatus(); - if (danaRPump.lastBolusTime.getTime() > now - 60 * 1000L) { // last bolus max 1 min old + if (danaRPump.lastBolusTime.getTime() > System.currentTimeMillis() - 60 * 1000L) { // last bolus max 1 min old t.insulin = danaRPump.lastBolusAmount; log.debug("Used bolus amount from history: " + danaRPump.lastBolusAmount); } else { 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 ea174e4608..4a224bd57b 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 @@ -293,9 +293,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface, ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin); if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) { - DetailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history // v2 stores end time for bolus, we need to adjust time - // default delivery speed is 12 U/min + // default delivery speed is 12 sec/U int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0); int speed = 12; switch (preferencesSpeed) { @@ -309,7 +308,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface, speed = 60; break; } - detailedBolusInfo.date += detailedBolusInfo.insulin / speed * 60d * 1000; + detailedBolusInfo.date += speed * detailedBolusInfo.insulin * 1000; // clean carbs to prevent counting them as twice because they will picked up as another record // I don't think it's necessary to copy DetailedBolusInfo right now for carbs records double carbs = detailedBolusInfo.carbs; @@ -317,6 +316,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface, int carbTime = detailedBolusInfo.carbTime; detailedBolusInfo.carbTime = 0; + DetailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history + Treatment t = new Treatment(); boolean connectionOK = false; if (detailedBolusInfo.insulin > 0 || carbs > 0) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java index 244014f3d0..da9e44f925 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/SerialIOThread.java @@ -188,12 +188,12 @@ public class SerialIOThread extends Thread { scheduledDisconnection = null; } } - // prepare task for execution in 5 sec + // prepare task for execution in 10 sec // cancel waiting task to prevent sending multiple disconnections if (scheduledDisconnection != null) scheduledDisconnection.cancel(false); Runnable task = new DisconnectRunnable(); - final int sec = 5; + final int sec = 10; scheduledDisconnection = worker.schedule(task, sec, TimeUnit.SECONDS); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java index fc3df19296..75f9893bc9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java @@ -36,6 +36,7 @@ import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.plugins.Overview.Notification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; +import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.*; import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus; @@ -400,14 +401,15 @@ public class DanaRv2ExecutionService extends Service { return true; } - public boolean bolus(double amount, int carbs, long carbtime, Treatment t) { + public boolean bolus(final double amount, int carbs, long carbtime, Treatment t) { + MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.startingbolus))); bolusingTreatment = t; - int speed = SP.getInt(R.string.key_danars_bolusspeed, 0); + final int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0); MessageBase start; - if (speed == 0) + if (preferencesSpeed == 0) start = new MsgBolusStart(amount); else - start = new MsgBolusStartWithSpeed(amount, speed); + start = new MsgBolusStartWithSpeed(amount, preferencesSpeed); MsgBolusStop stop = new MsgBolusStop(amount, t); connect("bolus"); @@ -420,6 +422,8 @@ public class DanaRv2ExecutionService extends Service { mSerialIOThread.sendMessage(msgSetHistoryEntry_v2); lastHistoryFetched = carbtime - 60000; } + + final long bolusStart = System.currentTimeMillis(); if (amount > 0) { MsgBolusProgress progress = new MsgBolusProgress(amount, t); // initialize static variables @@ -431,26 +435,46 @@ public class DanaRv2ExecutionService extends Service { } while (!stop.stopped && !start.failed) { waitMsec(100); - if ((System.currentTimeMillis() - progress.lastReceive) > 5 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm + if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm stop.stopped = true; stop.forced = true; log.debug("Communication stopped"); } } } + + EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); + bolusingEvent.t = t; + bolusingEvent.percent = 99; + bolusingTreatment = null; - // run loading history in separate thread and allow bolus dialog to be closed - new Thread(new Runnable() { - @Override - public void run() { - waitMsec(4000); - if (!(isConnected())) - connect("loadEvents"); - loadEvents(); - } - }).start(); + int speed = 12; + switch (preferencesSpeed) { + case 0: + speed = 12; + break; + case 1: + speed = 30; + break; + case 2: + speed = 60; + break; + } + long bolusDurationInMSec = (long) (amount * speed * 1000); + long expectedEnd = bolusStart + bolusDurationInMSec + 2000; + while (System.currentTimeMillis() < expectedEnd) { + long waitTime = expectedEnd - System.currentTimeMillis(); + bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.waitingforestimatedbolusend), waitTime / 1000); + MainApp.bus().post(bolusingEvent); + SystemClock.sleep(1000); + } + if (!(isConnected())) + connect("loadEvents"); + loadEvents(); + bolusingEvent.percent = 100; + MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.disconnecting))); return true; - } +} public void bolusStop() { if (Config.logDanaBTComm) diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index efa2d31c4d..c8bdc47ec9 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -49,9 +49,9 @@ - 12s 1U - 30s 1U - 60s 1U + 12 s/U + 30 s/U + 60 s/U 0 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 3b25c78dd2..0c0e9060d4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -747,5 +747,8 @@ Set Temp-Targets and enter Treatments from the watch. Connection timed out ]]> + Waiting for estimated bolus end. Remaining %d sec. + Processing event + Starting bolus delivery From 3cdca93b30340d5ae65ceb200d5982fe06f52b1d Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 21 Oct 2017 20:09:21 +0200 Subject: [PATCH 22/26] RS connectivity & bolus improvement --- .../plugins/PumpDanaRS/DanaRSPlugin.java | 21 ++++++-- .../DanaRS_Packet_Basal_Set_Basal_Rate.java | 11 +++-- ...cket_Basal_Set_Cancel_Temporary_Basal.java | 9 ++-- ...S_Packet_Basal_Set_Profile_Basal_Rate.java | 10 ++-- ...anaRS_Packet_Basal_Set_Profile_Number.java | 10 ++-- .../DanaRS_Packet_Basal_Set_Suspend_Off.java | 10 ++-- .../DanaRS_Packet_Basal_Set_Suspend_On.java | 10 ++-- ...naRS_Packet_Basal_Set_Temporary_Basal.java | 10 ++-- .../DanaRS_Packet_Bolus_Set_Bolus_Option.java | 10 ++-- .../DanaRS_Packet_Bolus_Set_CIR_CF_Array.java | 10 ++-- .../DanaRS_Packet_Bolus_Set_Dual_Bolus.java | 10 ++-- ...anaRS_Packet_Bolus_Set_Extended_Bolus.java | 10 ++-- ...acket_Bolus_Set_Extended_Bolus_Cancel.java | 10 ++-- ...DanaRS_Packet_Bolus_Set_Initial_Bolus.java | 10 ++-- ...aRS_Packet_Bolus_Set_Step_Bolus_Start.java | 12 ++--- ...naRS_Packet_Bolus_Set_Step_Bolus_Stop.java | 11 +++-- ...acket_General_Set_History_Upload_Mode.java | 10 ++-- ...neral_Set_User_Time_Change_Flag_Clear.java | 10 ++-- .../DanaRS_Packet_Option_Set_Pump_Time.java | 5 +- .../DanaRS_Packet_Option_Set_User_Option.java | 5 +- .../plugins/PumpDanaRS/services/BLEComm.java | 26 +++++----- .../PumpDanaRS/services/DanaRSService.java | 48 +++++++++++++++---- 22 files changed, 161 insertions(+), 117 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java index f26bdb6fad..468626fe26 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/DanaRSPlugin.java @@ -265,7 +265,9 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, @Override public boolean loadHistory(byte type) { connectIfNotConnected("loadHistory"); - return danaRSService.loadHistory(type); + danaRSService.loadHistory(type); + disconnect("LoadHistory"); + return true; } // Constraints interface @@ -393,10 +395,12 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, if (!danaRSService.updateBasalsInPump(profile)) { Notification notification = new Notification(Notification.FAILED_UDPATE_PROFILE, MainApp.sResources.getString(R.string.failedupdatebasalprofile), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); + disconnect("SetNewBasalProfile"); return FAILED; } else { MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE)); + disconnect("SetNewBasalProfile"); return SUCCESS; } } @@ -431,6 +435,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, log.debug("Refreshing data from pump"); if (!isConnected() && !isConnecting()) { connect(reason); + disconnect("RefreshDataFromPump"); } else log.debug("Already connecting ..."); } @@ -445,7 +450,6 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, ConfigBuilderPlugin configBuilderPlugin = MainApp.getConfigBuilder(); detailedBolusInfo.insulin = configBuilderPlugin.applyBolusConstraints(detailedBolusInfo.insulin); if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) { - DetailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0); int speed = 12; switch (preferencesSpeed) { @@ -460,8 +464,8 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, break; } // v2 stores end time for bolus, we need to adjust time - // default delivery speed is 12 U/min - detailedBolusInfo.date += detailedBolusInfo.insulin / speed * 60d * 1000; + // default delivery speed is 12 sec/U + detailedBolusInfo.date += detailedBolusInfo.insulin * speed * 1000; // clean carbs to prevent counting them as twice because they will picked up as another record // I don't think it's necessary to copy DetailedBolusInfo right now for carbs records double carbs = detailedBolusInfo.carbs; @@ -469,6 +473,8 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, int carbTime = detailedBolusInfo.carbTime; detailedBolusInfo.carbTime = 0; + DetailedBolusInfoStorage.add(detailedBolusInfo); // will be picked up on reading history + Treatment t = new Treatment(); boolean connectionOK = false; connectIfNotConnected("bolus"); @@ -481,7 +487,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); if (Config.logPumpActions) log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); - // remove carbs because it's get from history seprately + disconnect("DeliverTreatment"); return result; } else { PumpEnactResult result = new PumpEnactResult(); @@ -624,6 +630,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, result.isPercent = true; if (Config.logPumpActions) log.debug("setTempBasalPercent: OK"); + disconnect("setTempBasalPercent"); return result; } result.enacted = false; @@ -647,6 +654,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, result.isPercent = true; if (Config.logPumpActions) log.debug("setHighTempBasalPercent: OK"); + disconnect("setHighTempBasalPercent"); return result; } result.enacted = false; @@ -690,6 +698,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, result.isPercent = false; if (Config.logPumpActions) log.debug("setExtendedBolus: OK"); + disconnect("setExtendedBolus"); return result; } result.enacted = false; @@ -708,6 +717,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, danaRSService.tempBasalStop(); result.enacted = true; result.isTempCancel = true; + disconnect("cancelTempBasal"); } if (!pump.isTempBasalInProgress) { result.success = true; @@ -734,6 +744,7 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, danaRSService.extendedBolusStop(); result.enacted = true; result.isTempCancel = true; + disconnect("extendedBolusStop"); } if (!pump.isExtendedInProgress) { result.success = true; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java index 6f56464c51..a64da24bf3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Basal_Rate.java @@ -4,13 +4,13 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import info.nightscout.androidaps.Config; + import com.cozmo.danar.util.BleCommandUtil; public class DanaRS_Packet_Basal_Set_Basal_Rate extends DanaRS_Packet { private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Basal_Rate.class); private double[] profileBasalRate; - public int error; public DanaRS_Packet_Basal_Set_Basal_Rate() { super(); @@ -38,11 +38,12 @@ public class DanaRS_Packet_Basal_Set_Basal_Rate extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + error); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java index 70a8b02826..538750a45b 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.java @@ -10,8 +10,6 @@ import com.cozmo.danar.util.BleCommandUtil; public class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal extends DanaRS_Packet { private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal.class); - public int error; - public DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal() { super(); opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BASAL__CANCEL_TEMPORARY_BASAL; @@ -22,9 +20,12 @@ public class DanaRS_Packet_Basal_Set_Cancel_Temporary_Basal extends DanaRS_Packe @Override public void handleMessage(byte[] data) { - error = byteArrayToInt(getBytes(data, DATA_START, 1)); + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result " + error); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java index 82a63f0ca7..66d0e7b4bb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Basal_Rate.java @@ -11,7 +11,6 @@ public class DanaRS_Packet_Basal_Set_Profile_Basal_Rate extends DanaRS_Packet { private int profileNumber; // 0 - 4 private double[] profileBasalRate; - public int error; public DanaRS_Packet_Basal_Set_Profile_Basal_Rate() { super(); @@ -41,11 +40,12 @@ public class DanaRS_Packet_Basal_Set_Profile_Basal_Rate extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + error); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java index fe47f89dfc..69f7eae8dd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Profile_Number.java @@ -10,7 +10,6 @@ import com.cozmo.danar.util.BleCommandUtil; public class DanaRS_Packet_Basal_Set_Profile_Number extends DanaRS_Packet { private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Profile_Number.class); private int profileNumber; - public int error; public DanaRS_Packet_Basal_Set_Profile_Number() { super(); @@ -33,11 +32,12 @@ public class DanaRS_Packet_Basal_Set_Profile_Number extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + error); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java index 1b9444c2d3..4c78038162 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_Off.java @@ -8,7 +8,6 @@ import com.cozmo.danar.util.BleCommandUtil; public class DanaRS_Packet_Basal_Set_Suspend_Off extends DanaRS_Packet { private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Suspend_Off.class); - public int error; public DanaRS_Packet_Basal_Set_Suspend_Off() { super(); @@ -20,11 +19,12 @@ public class DanaRS_Packet_Basal_Set_Suspend_Off extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + error); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java index 01e90e026c..75a2a5fada 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Suspend_On.java @@ -8,7 +8,6 @@ import com.cozmo.danar.util.BleCommandUtil; public class DanaRS_Packet_Basal_Set_Suspend_On extends DanaRS_Packet { private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Basal_Set_Suspend_On.class); - public int error; public DanaRS_Packet_Basal_Set_Suspend_On() { super(); @@ -20,11 +19,12 @@ public class DanaRS_Packet_Basal_Set_Suspend_On extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + error); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java index a81d85f016..d2f68ff864 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Basal_Set_Temporary_Basal.java @@ -11,7 +11,6 @@ public class DanaRS_Packet_Basal_Set_Temporary_Basal extends DanaRS_Packet { private int temporaryBasalRatio; private int temporaryBasalDuration; - public int error; public DanaRS_Packet_Basal_Set_Temporary_Basal() { super(); @@ -37,11 +36,12 @@ public class DanaRS_Packet_Basal_Set_Temporary_Basal extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + error); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java index e20baeaee6..103bac3ecf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Bolus_Option.java @@ -111,12 +111,12 @@ public class DanaRS_Packet_Bolus_Set_Bolus_Option extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java index cf6a459d83..062ae00712 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_CIR_CF_Array.java @@ -83,12 +83,12 @@ public class DanaRS_Packet_Bolus_Set_CIR_CF_Array extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java index 31c80a702a..e769bea195 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Dual_Bolus.java @@ -44,12 +44,12 @@ public class DanaRS_Packet_Bolus_Set_Dual_Bolus extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } 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 d5f61c0946..887a9d852a 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 @@ -40,12 +40,12 @@ public class DanaRS_Packet_Bolus_Set_Extended_Bolus extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java index 10aa5f4979..132de649cf 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel.java @@ -19,12 +19,12 @@ public class DanaRS_Packet_Bolus_Set_Extended_Bolus_Cancel extends DanaRS_Packet @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java index a475e7675d..a174d39b53 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Initial_Bolus.java @@ -44,12 +44,12 @@ public class DanaRS_Packet_Bolus_Set_Initial_Bolus extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java index 1263aeb629..4c5cc23ef3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Start.java @@ -48,14 +48,12 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Start extends DanaRS_Packet { } @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - - failed = status != 0x00; - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java index 61ddd05c9b..5383fca413 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Bolus_Set_Step_Bolus_Stop.java @@ -35,13 +35,14 @@ public class DanaRS_Packet_Bolus_Set_Step_Bolus_Stop extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } + EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); stopped = true; if (!forced) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java index 7d9ec07ff1..878cfd64dd 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_History_Upload_Mode.java @@ -31,12 +31,12 @@ public class DanaRS_Packet_General_Set_History_Upload_Mode extends DanaRS_Packet @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java index 9cc6b7b2e0..3917f31050 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear.java @@ -17,12 +17,12 @@ public class DanaRS_Packet_General_Set_User_Time_Change_Flag_Clear extends DanaR @Override public void handleMessage(byte[] data) { - int dataIndex = DATA_START; - int dataSize = 1; - int status = byteArrayToInt(getBytes(data, dataIndex, dataSize)); - + int result = intFromBuff(data, 0, 1); if (Config.logDanaMessageDetail) { - log.debug("Result: " + status); + if (result == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + result); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java index e93e18796d..007623afca 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_Pump_Time.java @@ -45,7 +45,10 @@ public class DanaRS_Packet_Option_Set_Pump_Time extends DanaRS_Packet { int dataSize = 1; error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); if (Config.logDanaMessageDetail) { - log.debug("Result: " + error); + if (error == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + error); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java index 49c6d35708..e5d9374f32 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_Option_Set_User_Option.java @@ -47,7 +47,10 @@ public class DanaRS_Packet_Option_Set_User_Option extends DanaRS_Packet { int dataSize = 1; error = byteArrayToInt(getBytes(data, dataIndex, dataSize)); if (Config.logDanaMessageDetail) { - log.debug("Result: " + error); + if (error == 0) + log.debug("Result OK"); + else + log.error("Result Error: " + error); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java index dde50a93e1..42f077887d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/services/BLEComm.java @@ -165,19 +165,6 @@ public class BLEComm { MainApp.bus().post(new EventPumpStatusChanged(EventPumpStatusChanged.CONNECTING)); isConnecting = true; - // Following should be removed later because we close Gatt on disconnect and this should never happen - if ((mBluetoothDeviceAddress != null) && (address.equals(mBluetoothDeviceAddress)) && (mBluetoothGatt != null)) { - log.debug("Trying to use an existing mBluetoothGatt for connection."); - sHandler.post(updateProgress); - if (mBluetoothGatt.connect()) { - setCharacteristicNotification(getUARTReadBTGattChar(), true); - return true; - } - sHandler.removeCallbacks(updateProgress); - return false; - } - // end - BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address); if (device == null) { log.debug("Device not found. Unable to connect."); @@ -201,12 +188,19 @@ public class BLEComm { public void disconnect(String from) { log.debug("disconnect from: " + from); + + // cancel previous scheduled disconnection to prevent closing upcomming connection + if (scheduledDisconnection != null) + scheduledDisconnection.cancel(false); + scheduledDisconnection = null; + if ((mBluetoothAdapter == null) || (mBluetoothGatt == null)) { return; } setCharacteristicNotification(getUARTReadBTGattChar(), false); mBluetoothGatt.disconnect(); isConnected = false; + SystemClock.sleep(2000); } public void close() { @@ -214,6 +208,7 @@ public class BLEComm { if (mBluetoothGatt == null) { return; } + mBluetoothGatt.close(); mBluetoothGatt = null; } @@ -687,18 +682,19 @@ public class BLEComm { } public void scheduleDisconnection() { + class DisconnectRunnable implements Runnable { public void run() { disconnect("scheduleDisconnection"); scheduledDisconnection = null; } } - // prepare task for execution in 5 sec + // prepare task for execution in 30 sec // cancel waiting task to prevent sending multiple disconnections if (scheduledDisconnection != null) scheduledDisconnection.cancel(false); Runnable task = new DisconnectRunnable(); - final int sec = 5; + final int sec = 30; scheduledDisconnection = worker.schedule(task, sec, TimeUnit.SECONDS); log.debug("Disconnection scheduled"); } 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 6b39788342..e3baf10870 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 @@ -26,6 +26,7 @@ import info.nightscout.androidaps.events.EventInitializationChanged; import info.nightscout.androidaps.events.EventPumpStatusChanged; import info.nightscout.androidaps.plugins.Overview.Notification; import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; +import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump; import info.nightscout.androidaps.plugins.PumpDanaR.comm.RecordTypes; import info.nightscout.androidaps.plugins.PumpDanaR.events.EventDanaRNewStatus; @@ -188,16 +189,16 @@ public class DanaRSService extends Service { while (!msg.done && bleComm.isConnected()) { SystemClock.sleep(100); } - SystemClock.sleep(200); lastHistoryFetched = DanaRS_Packet_APS_History_Events.lastEventTimeLoaded; return true; } - public boolean bolus(double insulin, int carbs, long carbtime, Treatment t) { + public boolean bolus(final double insulin, int carbs, long carbtime, Treatment t) { + MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.startingbolus))); bolusingTreatment = t; - int speed = SP.getInt(R.string.key_danars_bolusspeed, 0); - DanaRS_Packet_Bolus_Set_Step_Bolus_Start start = new DanaRS_Packet_Bolus_Set_Step_Bolus_Start(insulin, speed); + final int preferencesSpeed = SP.getInt(R.string.key_danars_bolusspeed, 0); + DanaRS_Packet_Bolus_Set_Step_Bolus_Start start = new DanaRS_Packet_Bolus_Set_Step_Bolus_Start(insulin, preferencesSpeed); DanaRS_Packet_Bolus_Set_Step_Bolus_Stop stop = new DanaRS_Packet_Bolus_Set_Step_Bolus_Stop(insulin, t); // initialize static variables DanaRS_Packet_Notify_Delivery_Complete complete = new DanaRS_Packet_Notify_Delivery_Complete(insulin, t); // initialize static variables @@ -210,28 +211,57 @@ public class DanaRSService extends Service { bleComm.sendMessage(msgSetHistoryEntry_v2); lastHistoryFetched = carbtime - 60000; } - if (insulin > 0) { - DanaRS_Packet_Notify_Delivery_Rate_Display progress = new DanaRS_Packet_Notify_Delivery_Rate_Display(insulin, t); // initialize static variables + final long bolusStart = System.currentTimeMillis(); + if (insulin > 0) { if (!stop.stopped) { bleComm.sendMessage(start); } else { t.insulin = 0d; return false; } + DanaRS_Packet_Notify_Delivery_Rate_Display progress = new DanaRS_Packet_Notify_Delivery_Rate_Display(insulin, t); // initialize static variables + while (!stop.stopped && !start.failed && !complete.done) { SystemClock.sleep(100); - if ((System.currentTimeMillis() - progress.lastReceive) > 5 * 1000L) { // if i didn't receive status for more than 5 sec expecting broken comm + if ((System.currentTimeMillis() - progress.lastReceive) > 15 * 1000L) { // if i didn't receive status for more than 20 sec expecting broken comm stop.stopped = true; stop.forced = true; log.debug("Communication stopped"); } } } - SystemClock.sleep(3000); + + EventOverviewBolusProgress bolusingEvent = EventOverviewBolusProgress.getInstance(); + bolusingEvent.t = t; + bolusingEvent.percent = 99; + bolusingTreatment = null; - DanaRSPlugin.connectIfNotConnected("ReadHistoryAfterBolus"); + int speed = 12; + switch (preferencesSpeed) { + case 0: + speed = 12; + break; + case 1: + speed = 30; + break; + case 2: + speed = 60; + break; + } + long bolusDurationInMSec = (long) (insulin * speed * 1000); + long expectedEnd = bolusStart + bolusDurationInMSec + 2000; + while (System.currentTimeMillis() < expectedEnd) { + long waitTime = expectedEnd - System.currentTimeMillis(); + bolusingEvent.status = String.format(MainApp.sResources.getString(R.string.waitingforestimatedbolusend), waitTime / 1000); + MainApp.bus().post(bolusingEvent); + SystemClock.sleep(1000); + } + if (!(isConnected())) + DanaRSPlugin.getPlugin().connect("loadEvents"); loadEvents(); + bolusingEvent.percent = 100; + MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.disconnecting))); return true; } From 441c2beffcda7391ed7a7b11507bc5444f278037 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 24 Oct 2017 09:19:03 +0200 Subject: [PATCH 23/26] read status after bolus --- .../plugins/PumpDanaRS/services/DanaRSService.java | 3 +++ .../PumpDanaRv2/services/DanaRv2ExecutionService.java | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) 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 e3baf10870..399254f84b 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 @@ -260,6 +260,9 @@ public class DanaRSService extends Service { if (!(isConnected())) DanaRSPlugin.getPlugin().connect("loadEvents"); loadEvents(); + // reread bolus status + MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingbolusstatus))); + bleComm.sendMessage(new DanaRS_Packet_Bolus_Get_Step_Bolus_Information()); // last bolus bolusingEvent.percent = 100; MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.disconnecting))); return true; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java index 75f9893bc9..6eabb668fb 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRv2/services/DanaRv2ExecutionService.java @@ -262,13 +262,13 @@ public class DanaRv2ExecutionService extends Service { } } + MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingbolusstatus))); mSerialIOThread.sendMessage(statusMsg); mSerialIOThread.sendMessage(statusBasicMsg); MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingtempbasalstatus))); mSerialIOThread.sendMessage(tempStatusMsg); MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingextendedbolusstatus))); mSerialIOThread.sendMessage(exStatusMsg); - MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingbolusstatus))); if (!statusMsg.received) { mSerialIOThread.sendMessage(statusMsg); @@ -471,6 +471,9 @@ public class DanaRv2ExecutionService extends Service { if (!(isConnected())) connect("loadEvents"); loadEvents(); + // load last bolus status + MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.gettingbolusstatus))); + mSerialIOThread.sendMessage(new MsgStatus()); bolusingEvent.percent = 100; MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.disconnecting))); return true; From 2fb707b9edd97b1da739a26d1a6c8d3646e9f1f8 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 24 Oct 2017 21:08:03 +0200 Subject: [PATCH 24/26] log.debug -> log.error on RS comm --- .../comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java | 2 +- .../PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java index 7ce847dc58..d46805c28f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java @@ -53,7 +53,7 @@ public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet { int result = byteArrayToInt(getBytes(data, DATA_START, 1)); if (result != 1) { failed = true; - log.debug("Set APS temp basal start result: " + result + " FAILED!!!"); + log.error("Set APS temp basal start result: " + result + " FAILED!!!"); } else { if (Config.logDanaMessageDetail) log.debug("Set APS temp basal start result: " + result); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java index 0f102090a7..d6b47e9579 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java @@ -63,7 +63,7 @@ public class DanaRS_Packet_APS_Set_Event_History extends DanaRS_Packet { int result = intFromBuff(data, 0, 1); if (result != 1) { failed = true; - log.debug("Set history entry result: " + result + " FAILED!!!"); + log.error("Set history entry result: " + result + " FAILED!!!"); } else { if (Config.logDanaMessageDetail) log.debug("Set history entry result: " + result); From 606973d4ad017858c742730ae28ad201aeeda03e Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 25 Oct 2017 11:37:05 +0200 Subject: [PATCH 25/26] use max absorption time for AAPS and weighted average sensitivity detection --- .../androidaps/plugins/IobCobCalculator/AutosensData.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java index 9939bd44d1..e6d58178f5 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/IobCobCalculator/AutosensData.java @@ -13,6 +13,7 @@ import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.db.Treatment; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin; +import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin; import info.nightscout.utils.SP; /** @@ -32,7 +33,7 @@ public class AutosensData { time = t.date; carbs = t.carbs; remaining = t.carbs; - if (MainApp.getSpecificPlugin(SensitivityAAPSPlugin.class) != null && MainApp.getSpecificPlugin(SensitivityAAPSPlugin.class).isEnabled(PluginBase.SENSITIVITY)) { + if (SensitivityAAPSPlugin.getPlugin().isEnabled(PluginBase.SENSITIVITY) || SensitivityWeightedAveragePlugin.getPlugin().isEnabled(PluginBase.SENSITIVITY)) { double maxAbsorptionHours = SP.getDouble(R.string.key_absorption_maxtime, 4d); Profile profile = MainApp.getConfigBuilder().getProfile(t.date); double sens = Profile.toMgdl(profile.getIsf(t.date), profile.getUnits()); From 26b216a8eeb4b0b5744bf6c2d233e6c194d0f6e6 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 26 Oct 2017 20:40:24 +0200 Subject: [PATCH 26/26] fix RS response code --- .../plugins/NSClientInternal/data/NSDeviceStatus.java | 2 +- .../comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java | 2 +- .../PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java index 2a2e1b8044..2df50b2bd1 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSDeviceStatus.java @@ -254,7 +254,7 @@ public class NSDeviceStatus { long clockEnacted = 0L; JSONObject suggested = null; - JSONObject enacted = null; + public JSONObject enacted = null; } public void updateOpenApsData(JSONObject object) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java index d46805c28f..06608b5a74 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Basal_Set_Temporary_Basal.java @@ -51,7 +51,7 @@ public class DanaRS_Packet_APS_Basal_Set_Temporary_Basal extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = byteArrayToInt(getBytes(data, DATA_START, 1)); - if (result != 1) { + if (result != 0) { failed = true; log.error("Set APS temp basal start result: " + result + " FAILED!!!"); } else { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java index d6b47e9579..4e559a77df 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRS/comm/DanaRS_Packet_APS_Set_Event_History.java @@ -61,7 +61,7 @@ public class DanaRS_Packet_APS_Set_Event_History extends DanaRS_Packet { @Override public void handleMessage(byte[] data) { int result = intFromBuff(data, 0, 1); - if (result != 1) { + if (result != 0) { failed = true; log.error("Set history entry result: " + result + " FAILED!!!"); } else {