From d7200d1e8e261e5a03d702053ec96e71aad9687f Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 4 Jan 2018 11:06:57 +0100 Subject: [PATCH 01/11] warn if wrong profile is detected --- .../java/info/nightscout/androidaps/data/Profile.java | 10 +++++++++- .../plugins/Overview/notifications/Notification.java | 2 ++ app/src/main/res/values/strings.xml | 2 ++ 3 files changed, 13 insertions(+), 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 e022969e32..c1e0f05885 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/Profile.java +++ b/app/src/main/java/info/nightscout/androidaps/data/Profile.java @@ -172,8 +172,16 @@ public class Profile { tas = getShitfTimeSecs(DateUtil.toSeconds(time)); //log.debug(">>>>>>>>>>>> Used recalculated timeAsSecons: " + time + " " + tas); } - Double value = o.getDouble("value") * multiplier; + double value = o.getDouble("value") * multiplier; sparse.put(tas, value); + if (tas % 3600 != 0) { + Notification notification = new Notification(Notification.BASAL_PROFILE_NOT_ALIGNED_TO_HOURS, MainApp.sResources.getString(R.string.basalprofilenotaligned), Notification.URGENT); + MainApp.bus().post(new EventNewNotification(notification)); + } + if (value == 0) { + Notification notification = new Notification(Notification.ZERO_VALUE_IN_PROFILE, MainApp.sResources.getString(R.string.zerovalueinprofile), Notification.URGENT); + MainApp.bus().post(new EventNewNotification(notification)); + } } catch (JSONException e) { log.error("Unhandled exception", e); log.error(json.toString()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java index e54ff80772..7f8b94cfa9 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/notifications/Notification.java @@ -57,6 +57,8 @@ public class Notification { public static final int BG_READINGS_MISSED = 27; public static final int UNSUPPORTED_FIRMWARE = 28; public static final int MINIMAL_BASAL_VALUE_REPLACED = 29; + public static final int BASAL_PROFILE_NOT_ALIGNED_TO_HOURS = 30; + public static final int ZERO_VALUE_IN_PROFILE = 31; public int id; public Date date; diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d203674c5d..650a95abe0 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -806,5 +806,7 @@ NSClient has write permission Closed mode enabled Maximal IOB set properly + Basal values not aligned to hours + Zero value in profile From 95bca1a92db8bc3fb3871dbc0149b19b65c5899e Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Thu, 4 Jan 2018 18:53:38 +0100 Subject: [PATCH 02/11] actual bg in objective 1 --- .../ConstraintsObjectives/ObjectivesPlugin.java | 15 +++++++++------ app/src/main/res/values/strings.xml | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java index 1f0e6704c3..794f66ef60 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConstraintsObjectives/ObjectivesPlugin.java @@ -14,6 +14,7 @@ import info.nightscout.androidaps.BuildConfig; import info.nightscout.androidaps.Config; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.db.DatabaseHelper; import info.nightscout.androidaps.interfaces.APSInterface; import info.nightscout.androidaps.interfaces.ConstraintsInterface; import info.nightscout.androidaps.interfaces.PluginBase; @@ -160,19 +161,21 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface { boolean isVirtualPump = VirtualPumpPlugin.getPlugin().isEnabled(PluginBase.PUMP); boolean vpUploadEnabled = SP.getBoolean("virtualpump_uploadstatus", false); boolean vpUploadNeeded = !isVirtualPump || vpUploadEnabled; + boolean hasBGData = DatabaseHelper.lastBg()!=null; boolean apsEnabled = false; APSInterface usedAPS = ConfigBuilderPlugin.getActiveAPS(); if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginBase.APS)) apsEnabled = true; - return new RequirementResult(bgIsAvailableInNS && pumpStatusIsAvailableInNS && NSClientInternalPlugin.getPlugin().hasWritePermission() && LoopPlugin.getPlugin().isEnabled(PluginBase.LOOP) && apsEnabled && vpUploadNeeded, + return new RequirementResult(hasBGData&&bgIsAvailableInNS && pumpStatusIsAvailableInNS && NSClientInternalPlugin.getPlugin().hasWritePermission() && LoopPlugin.getPlugin().isEnabled(PluginBase.LOOP) && apsEnabled && vpUploadNeeded, MainApp.sResources.getString(R.string.objectives_bgavailableinns) + ": " + yesOrNo(bgIsAvailableInNS) - + " " + MainApp.sResources.getString(R.string.nsclienthaswritepermission) + ": " + yesOrNo(NSClientInternalPlugin.getPlugin().hasWritePermission()) - + (isVirtualPump ? " " + MainApp.sResources.getString(R.string.virtualpump_uploadstatus_title) + ": " + yesOrNo(vpUploadEnabled) : "") - + " " + MainApp.sResources.getString(R.string.objectives_pumpstatusavailableinns) + ": " + yesOrNo(pumpStatusIsAvailableInNS) - + " " + MainApp.sResources.getString(R.string.loopenabled) + ": " + yesOrNo(LoopPlugin.getPlugin().isEnabled(PluginBase.LOOP)) - + " " + MainApp.sResources.getString(R.string.apsselected) + ": " + yesOrNo(apsEnabled) + + "\n" + MainApp.sResources.getString(R.string.nsclienthaswritepermission) + ": " + yesOrNo(NSClientInternalPlugin.getPlugin().hasWritePermission()) + + (isVirtualPump ? "\n" + MainApp.sResources.getString(R.string.virtualpump_uploadstatus_title) + ": " + yesOrNo(vpUploadEnabled) : "") + + "\n" + MainApp.sResources.getString(R.string.objectives_pumpstatusavailableinns) + ": " + yesOrNo(pumpStatusIsAvailableInNS) + + "\n" + MainApp.sResources.getString(R.string.hasbgdata) + ": " + yesOrNo(hasBGData) + + "\n" + MainApp.sResources.getString(R.string.loopenabled) + ": " + yesOrNo(LoopPlugin.getPlugin().isEnabled(PluginBase.LOOP)) + + "\n" + MainApp.sResources.getString(R.string.apsselected) + ": " + yesOrNo(apsEnabled) ); case 1: return new RequirementResult(manualEnacts >= manualEnactsNeeded, diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index d203674c5d..66606bd598 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -806,5 +806,6 @@ NSClient has write permission Closed mode enabled Maximal IOB set properly + BG available from selected source From 955ecc6d64f3b46049bd27412c6d109327463842 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 4 Jan 2018 21:33:18 +0100 Subject: [PATCH 03/11] set defaults for display range --- .../plugins/Overview/OverviewFragment.java | 12 ++++++++++-- .../plugins/SourceDexcomG5/BGSourceFragment.java | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java index ccef69a17b..8e4ba0b332 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/OverviewFragment.java @@ -940,8 +940,16 @@ public class OverviewFragment extends Fragment implements View.OnClickListener, return; } - final double lowLine = SP.getDouble("low_mark", Profile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units)); - final double highLine = SP.getDouble("high_mark", Profile.fromMgdlToUnits(OverviewPlugin.bgTargetHigh, units)); + double lowLineSetting = SP.getDouble("low_mark", Profile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units)); + double highLineSetting = SP.getDouble("high_mark", Profile.fromMgdlToUnits(OverviewPlugin.bgTargetHigh, units)); + + if (lowLineSetting < 1) + lowLineSetting = Profile.fromMgdlToUnits(76d, units); + if (highLineSetting < 1) + highLineSetting = Profile.fromMgdlToUnits(180d, units); + + final double lowLine = lowLineSetting; + final double highLine = highLineSetting; //Start with updating the BG as it is unaffected by loop. // **** BG value **** diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SourceDexcomG5/BGSourceFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/SourceDexcomG5/BGSourceFragment.java index bd686ec96c..0b001b8b80 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/SourceDexcomG5/BGSourceFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/SourceDexcomG5/BGSourceFragment.java @@ -149,12 +149,13 @@ public class BGSourceFragment extends SubscriberFragment { builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(bgReading.date) + "\n" + bgReading.valueToUnitsToString(profile.getUnits())); builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { - final String _id = bgReading._id; +/* final String _id = bgReading._id; if (NSUpload.isIdValid(_id)) { NSUpload.removeFoodFromNS(_id); } else { UploadQueue.removeID("dbAdd", _id); } +*/ bgReading.isValid = false; MainApp.getDbHelper().update(bgReading); updateGUI(); From b7df21c7d061d60149f46fa0bac6d232ec1801e3 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 4 Jan 2018 23:12:35 +0100 Subject: [PATCH 04/11] prevent processing incomplete profiles --- .../CircadianPercentageProfilePlugin.java | 9 ++++++--- .../plugins/ProfileLocal/LocalProfilePlugin.java | 5 ++++- .../plugins/ProfileSimple/SimpleProfilePlugin.java | 7 ++++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfilePlugin.java index 5315910899..ec9c6d1e40 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfilePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileCircadianPercentage/CircadianPercentageProfilePlugin.java @@ -162,9 +162,6 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte baseic[i] = SP.getDouble(SETTINGS_PREFIX + "baseic" + i, baseic[i]); baseisf[i] = SP.getDouble(SETTINGS_PREFIX + "baseisf" + i, baseisf[i]); } - - - createConvertedProfile(); } public String externallySetParameters(int timeshift, int percentage) { @@ -347,6 +344,9 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte @Override public ProfileStore getProfile() { + if (convertedProfile == null) + createConvertedProfile(); + performLimitCheck(); return convertedProfile; } @@ -358,6 +358,9 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte @Override public String getProfileName() { + if (convertedProfile == null) + createConvertedProfile(); + performLimitCheck(); return convertedProfileName; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfilePlugin.java index b9780d7493..b13945ae03 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfilePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileLocal/LocalProfilePlugin.java @@ -178,7 +178,6 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface { } catch (JSONException ignored) { } } - createConvertedProfile(); } /* @@ -244,6 +243,8 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface { @Override public ProfileStore getProfile() { + if (convertedProfile == null) + createConvertedProfile(); return convertedProfile; } @@ -254,6 +255,8 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface { @Override public String getProfileName() { + if (convertedProfile == null) + createConvertedProfile(); return DecimalFormatter.to2Decimal(convertedProfile.getDefaultProfile().percentageBasalSum()) + "U "; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfilePlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfilePlugin.java index d0b36d34ca..fbc9cf6b4c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfilePlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ProfileSimple/SimpleProfilePlugin.java @@ -13,9 +13,9 @@ import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; +import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.ProfileInterface; -import info.nightscout.androidaps.data.ProfileStore; import info.nightscout.utils.SP; /** @@ -28,7 +28,7 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface { public static SimpleProfilePlugin getPlugin() { if (simpleProfilePlugin == null) - simpleProfilePlugin = new SimpleProfilePlugin(); + simpleProfilePlugin = new SimpleProfilePlugin(); return simpleProfilePlugin; } @@ -146,7 +146,6 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface { basal = SP.getDouble("SimpleProfile" + "basal", 1d); targetLow = SP.getDouble("SimpleProfile" + "targetlow", 80d); targetHigh = SP.getDouble("SimpleProfile" + "targethigh", 120d); - createConvertedProfile(); } /* @@ -211,6 +210,8 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface { @Override public ProfileStore getProfile() { + if (convertedProfile == null) + createConvertedProfile(); return convertedProfile; } From 02e7752c3ec8a78d3dcf2a59a8b43285d58ce428 Mon Sep 17 00:00:00 2001 From: Andrew Warrington Date: Fri, 5 Jan 2018 11:58:57 +0100 Subject: [PATCH 05/11] Cockpit watch face: Double-tap opens MainMenuActivity --- .../androidaps/watchfaces/Cockpit.java | 20 ++++++------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Cockpit.java b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Cockpit.java index a275752cf9..b949e3832a 100644 --- a/wear/src/main/java/info/nightscout/androidaps/watchfaces/Cockpit.java +++ b/wear/src/main/java/info/nightscout/androidaps/watchfaces/Cockpit.java @@ -27,21 +27,13 @@ public class Cockpit extends BaseWatchFace { @Override protected void onTapCommand(int tapType, int x, int y, long eventTime) { - if (mSgv != null) { - - int extra = (mSgv.getRight() - mSgv.getLeft()) / 2; - if (tapType == TAP_TYPE_TAP && - x + extra >= mSgv.getLeft() && - x - extra <= mSgv.getRight() && - y >= mSgv.getTop() && - y <= mSgv.getBottom()) { - if (eventTime - sgvTapTime < 800) { - Intent intent = new Intent(this, MainMenuActivity.class); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - } - sgvTapTime = eventTime; + if (tapType == TAP_TYPE_TAP ) { + if (eventTime - sgvTapTime < 800) { + Intent intent = new Intent(this, MainMenuActivity.class); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + startActivity(intent); } + sgvTapTime = eventTime; } } From b9ad3a71fdf0b4324977a54c54acdaf5652040b9 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 6 Jan 2018 06:52:30 +0100 Subject: [PATCH 06/11] Dialogs usability tweaks --- .../androidaps/plugins/Actions/dialogs/FillDialog.java | 3 ++- .../plugins/Actions/dialogs/NewExtendedBolusDialog.java | 3 ++- .../androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java | 3 ++- .../plugins/Careportal/Dialogs/NewNSTreatmentDialog.java | 3 ++- .../androidaps/plugins/Overview/Dialogs/CalibrationDialog.java | 3 ++- .../plugins/Overview/Dialogs/NewTreatmentDialog.java | 3 ++- .../androidaps/plugins/Overview/Dialogs/WizardDialog.java | 3 ++- 7 files changed, 14 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java index 2901ad862f..23fa39066f 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/FillDialog.java @@ -101,7 +101,8 @@ public class FillDialog extends DialogFragment implements OnClickListener { divider.setVisibility(View.GONE); } - setCancelable(false); + setCancelable(true); + getDialog().setCanceledOnTouchOutside(false); return view; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java index aea4f4f4aa..dc6a356f1d 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewExtendedBolusDialog.java @@ -55,7 +55,8 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli view.findViewById(R.id.ok).setOnClickListener(this); view.findViewById(R.id.cancel).setOnClickListener(this); - setCancelable(false); + setCancelable(true); + getDialog().setCanceledOnTouchOutside(false); return view; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java index 0337166fd6..ce3d45fc71 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Actions/dialogs/NewTempBasalDialog.java @@ -103,7 +103,8 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi view.findViewById(R.id.cancel).setOnClickListener(this); basalTypeRadioGroup.setOnCheckedChangeListener(this); - setCancelable(false); + setCancelable(true); + getDialog().setCanceledOnTouchOutside(false); return view; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java index af9440bff1..58d0603301 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Careportal/Dialogs/NewNSTreatmentDialog.java @@ -360,7 +360,8 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_reuse_layout), options.profile && ps != null && ps.isCPP); showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_temptarget_layout), options.tempTarget); - setCancelable(false); + setCancelable(true); + getDialog().setCanceledOnTouchOutside(false); return view; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/CalibrationDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/CalibrationDialog.java index 32b34b6f85..d5053c9317 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/CalibrationDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/CalibrationDialog.java @@ -76,7 +76,8 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis unitsView = (TextView) view.findViewById(R.id.overview_calibration_units); unitsView.setText(units); - setCancelable(false); + setCancelable(true); + getDialog().setCanceledOnTouchOutside(false); return view; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTreatmentDialog.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTreatmentDialog.java index 55dc39fc11..775c97d810 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTreatmentDialog.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Dialogs/NewTreatmentDialog.java @@ -102,7 +102,8 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher); editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, new DecimalFormat("0.00"), false, textWatcher); - setCancelable(false); + setCancelable(true); + getDialog().setCanceledOnTouchOutside(false); return view; } 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 af2266582b..c8a00053b2 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 @@ -233,7 +233,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false); initDialog(); - setCancelable(false); + setCancelable(true); + getDialog().setCanceledOnTouchOutside(false); return view; } From 4dd238097f642d65c9de29d48ee9768c82720884 Mon Sep 17 00:00:00 2001 From: AdrianLxM Date: Sat, 6 Jan 2018 07:37:39 +0100 Subject: [PATCH 07/11] basal updated notification --- .../androidaps/plugins/PumpDanaRS/DanaRSPlugin.java | 2 ++ .../androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java | 2 ++ .../androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java | 4 ++++ 3 files changed, 8 insertions(+) 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 dceb7e66bc..ed9f98651f 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 @@ -405,6 +405,8 @@ public class DanaRSPlugin implements PluginBase, PumpInterface, DanaRInterface, } else { MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE)); + Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60); + MainApp.bus().post(new EventNewNotification(notification)); result.success = true; result.enacted = true; result.comment = "OK"; 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 deb1594c28..b4eb969852 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 @@ -257,6 +257,8 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface, } else { MainApp.bus().post(new EventDismissNotification(Notification.PROFILE_NOT_SET_NOT_INITIALIZED)); MainApp.bus().post(new EventDismissNotification(Notification.FAILED_UDPATE_PROFILE)); + Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60); + MainApp.bus().post(new EventNewNotification(notification)); result.success = true; result.enacted = true; result.comment = "OK"; diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java index c543fe39bd..7c777a5652 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java @@ -23,7 +23,9 @@ import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.interfaces.TreatmentsInterface; +import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification; import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress; +import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui; import info.nightscout.utils.DateUtil; import info.nightscout.utils.NSUpload; @@ -218,6 +220,8 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface { // Do nothing here. we are using MainApp.getConfigBuilder().getActiveProfile().getProfile(); PumpEnactResult result = new PumpEnactResult(); result.success = true; + Notification notification = new Notification(Notification.PROFILE_SET_OK, MainApp.sResources.getString(R.string.profile_set_ok), Notification.INFO, 60); + MainApp.bus().post(new EventNewNotification(notification)); return result; } From 8cf69006b2a72fbee68baa1efb546a51854557da Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sun, 7 Jan 2018 11:13:02 +0100 Subject: [PATCH 08/11] check 30min interval only for basal rates --- .../info/nightscout/androidaps/data/Profile.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) 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 c1e0f05885..b2e5d0d9dc 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/Profile.java +++ b/app/src/main/java/info/nightscout/androidaps/data/Profile.java @@ -174,10 +174,6 @@ public class Profile { } double value = o.getDouble("value") * multiplier; sparse.put(tas, value); - if (tas % 3600 != 0) { - Notification notification = new Notification(Notification.BASAL_PROFILE_NOT_ALIGNED_TO_HOURS, MainApp.sResources.getString(R.string.basalprofilenotaligned), Notification.URGENT); - MainApp.bus().post(new EventNewNotification(notification)); - } if (value == 0) { Notification notification = new Notification(Notification.ZERO_VALUE_IN_PROFILE, MainApp.sResources.getString(R.string.zerovalueinprofile), Notification.URGENT); MainApp.bus().post(new EventNewNotification(notification)); @@ -345,6 +341,14 @@ public class Profile { public Double getBasal(Integer timeAsSeconds) { if (basal_v == null) { basal_v = convertToSparseArray(basal); + for (int index = 0; index < basal_v.size(); index++) { + long secondsFromMidnight = basal_v.keyAt(index); + if (secondsFromMidnight % 3600 != 0) { + Notification notification = new Notification(Notification.BASAL_PROFILE_NOT_ALIGNED_TO_HOURS, MainApp.sResources.getString(R.string.basalprofilenotaligned), Notification.URGENT); + MainApp.bus().post(new EventNewNotification(notification)); + } + } + // Check for minimal basal value PumpInterface pump = ConfigBuilderPlugin.getActivePump(); if (pump != null) { From 836abd74ab803b6c7a9786e6ce7c076024261bbc Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sun, 7 Jan 2018 11:16:43 +0100 Subject: [PATCH 09/11] Read reservoir level. --- .../plugins/PumpCombo/ComboFragment.java | 5 ++--- .../androidaps/plugins/PumpCombo/ComboPlugin.java | 15 ++++++++------- .../androidaps/plugins/PumpCombo/ComboPump.java | 1 + 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java index 506bce7be5..bb5f5f89e8 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java @@ -172,17 +172,16 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis } // reservoir + int reservoirLevel = plugin.getPump().reservoirLevel; + reservoirView.setText(reservoirLevel == -1 ? "" : "" + reservoirLevel + " U"); if (ps.insulinState == PumpState.LOW) { reservoirView.setTextColor(Color.YELLOW); - reservoirView.setText(R.string.combo_reservoir_low); reservoirView.setTypeface(null, Typeface.BOLD); } else if (ps.insulinState == PumpState.EMPTY) { reservoirView.setTextColor(Color.RED); - reservoirView.setText(R.string.combo_reservoir_empty); reservoirView.setTypeface(null, Typeface.BOLD); } else { reservoirView.setTextColor(Color.WHITE); - reservoirView.setText(R.string.combo_reservoir_normal); reservoirView.setTypeface(null, Typeface.NORMAL); } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index bc27a3ebbc..224852cf7e 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -339,7 +339,7 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf if (!pump.initialized) { initializePump(); } else { - runCommand(MainApp.sResources.getString(R.string.combo_pump_action_refreshing), 1, ruffyScripter::readPumpState); + runCommand(MainApp.sResources.getString(R.string.combo_pump_action_refreshing), 1, ruffyScripter::readReservoirLevelAndLastBolus); } } @@ -379,10 +379,13 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf MainApp.bus().post(new EventInitializationChanged()); // ComboFragment updates state fully only after the pump has initialized, so run this manually here - updateLocalData(readBasalResult); + updateLocalData(runCommand(null, 1, ruffyScripter::readReservoirLevelAndLastBolus)); } private void updateLocalData(CommandResult result) { + if (result.reservoirLevel != PumpState.UNKNOWN) { + pump.reservoirLevel = result.reservoirLevel; + } if (result.state.menu != null) { pump.state = result.state; } @@ -1026,11 +1029,9 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf try { JSONObject pumpJson = new JSONObject(); pumpJson.put("clock", DateUtil.toISOString(pump.lastSuccessfulCmdTime)); - - int level = 150; - if (pump.state.insulinState == PumpState.LOW) level = 8; - else if (pump.state.insulinState == PumpState.EMPTY) level = 0; - pumpJson.put("reservoir", level); + if (pump.reservoirLevel != -1) { + pumpJson.put("reservoir", pump.reservoirLevel); + } JSONObject statusJson = new JSONObject(); statusJson.put("status", getStateSummary()); diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java index 5980cf11eb..0455fa3ada 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPump.java @@ -17,6 +17,7 @@ class ComboPump { public volatile String activity; @NonNull volatile PumpState state = new PumpState(); + volatile int reservoirLevel = -1; @NonNull volatile BasalProfile basalProfile = new BasalProfile(); From 117b79619b27ee65a6b52720b4dc364e786eb94c Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sun, 7 Jan 2018 11:23:54 +0100 Subject: [PATCH 10/11] Check reservoir level before bolus and abort if not enough left. --- .../androidaps/plugins/PumpCombo/ComboPlugin.java | 7 ++++++- app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java index 224852cf7e..93b2e0af8c 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboPlugin.java @@ -470,13 +470,18 @@ public class ComboPlugin implements PluginBase, PumpInterface, ConstraintsInterf } lastRequestedBolus = new Bolus(System.currentTimeMillis(), detailedBolusInfo.insulin, true); - CommandResult stateResult = runCommand(null, 1, ruffyScripter::readPumpState); + CommandResult stateResult = runCommand(null, 1, ruffyScripter::readReservoirLevelAndLastBolus); long pumpTimeWhenBolusWasRequested = stateResult .state.pumpTime; if (!stateResult.success || pumpTimeWhenBolusWasRequested == 0) { return new PumpEnactResult().success(false).enacted(false) .comment(MainApp.sResources.getString(R.string.combo_error_no_bolus_delivered)); } + if (stateResult.reservoirLevel < detailedBolusInfo.insulin) { + return new PumpEnactResult().success(false).enacted(false) + .comment(MainApp.sResources.getString(R.string.combo_reservoir_level_insufficient_for_bolus)); + } + try { pump.activity = MainApp.sResources.getString(R.string.combo_pump_action_bolusing, detailedBolusInfo.insulin); MainApp.bus().post(new EventComboPumpUpdateGUI()); diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 8edea19afe..9438e06d19 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -778,4 +778,5 @@ Standarwert: 2\nBolus snooze (\"Bolus-Schlummer\") bremst den Loop nach einem Mahleiten-Bolus, damit dieser nicht mit niedrigen TBR reagiert, wenn Du gerade gegessen hast. Beispiel: Der Standardwert 2 bewirkt, dass bei einem 3 Stunden DIA der Bolus snooze während 1.5 Stunden nach dem Bolus linear ausläuft (3 h Dia / 2 = 1.5 h Bolus snooze). Standardwert: 3.0\nDies ist eine Einstellung für die Standard-Kohlenhydrat-Absorptionswirkung pro 5 Minuten. Der Standardwert ist 3mg/dl/5min. Dies wirkt sich darauf aus, wie schnell der COB-Wert fällt und wieviel KH-Absorption bei der Berechnung des vorhergesagten BZ angenommen wird, wenn der BZ stärker als erwartet fällt oder nicht so stark wie erwartet steigt. Achtung! Normalerweise musst Du diese Werte nicht ändern. Bitte KLICKE HIER und LESE den Text. Verändere Werte erst, wenn Du den Inhalt des Textes verstanden hast. + Nicht mehr genug Insulin im Reservoir für den Bolus diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ade1033316..03e37403f3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -864,5 +864,6 @@ Only %.2f U of the requested bolus of %.2f U was delivered due to an error. Please check the pump to verify this and take appropriate actions. Delivering the bolus and verifying the pump\'s history failed, please check the pump and manually create a bolus record using the Careportal tab if a bolus was delivered. Recovering from connection loss + Not enough insulin left in reservoir for bolus From 968431d931fd534618a16f8732c405e11a7eef88 Mon Sep 17 00:00:00 2001 From: Johannes Mockenhaupt Date: Sun, 7 Jan 2018 13:02:50 +0100 Subject: [PATCH 11/11] i18n reservoir unit. --- .../nightscout/androidaps/plugins/PumpCombo/ComboFragment.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java index bb5f5f89e8..7b72ee5d04 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpCombo/ComboFragment.java @@ -173,7 +173,8 @@ public class ComboFragment extends SubscriberFragment implements View.OnClickLis // reservoir int reservoirLevel = plugin.getPump().reservoirLevel; - reservoirView.setText(reservoirLevel == -1 ? "" : "" + reservoirLevel + " U"); + reservoirView.setText(reservoirLevel == -1 ? "" : "" + reservoirLevel + " " + + MainApp.sResources.getString(R.string.treatments_wizard_unit_label)); if (ps.insulinState == PumpState.LOW) { reservoirView.setTextColor(Color.YELLOW); reservoirView.setTypeface(null, Typeface.BOLD);