From 74bb05a654f8881a43bcd1344cffd39b94f49da4 Mon Sep 17 00:00:00 2001
From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com>
Date: Thu, 3 Aug 2017 17:14:14 +0300
Subject: [PATCH 01/35] added staledataalarm
---
.../plugins/Overview/Notification.java | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java
index 6b15a9e17d..31783523c4 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java
@@ -111,9 +111,9 @@ public class Notification {
return true;
if (level == ANNOUNCEMENT)
return true;
- if (level == NORMAL && isAlarmForLow() && SP.getBoolean(R.string.key_nsalarm_low, false) || isAlarmForHigh() && SP.getBoolean(R.string.key_nsalarm_high, false))
+ if (level == NORMAL && isAlarmForLow() && SP.getBoolean(R.string.key_nsalarm_low, false) || isAlarmForHigh() && SP.getBoolean(R.string.key_nsalarm_high, false) || isAlarmForStaleData() && SP.getBoolean(R.string.key_nsalarm_staledata, false))
return true;
- if (level == URGENT && isAlarmForLow() && SP.getBoolean(R.string.key_nsalarm_urgent_low, false) || isAlarmForHigh() && SP.getBoolean(R.string.key_nsalarm_urgent_high, false))
+ if (level == URGENT && isAlarmForLow() && SP.getBoolean(R.string.key_nsalarm_urgent_low, false) || isAlarmForHigh() && SP.getBoolean(R.string.key_nsalarm_urgent_high, false) || isAlarmForStaleData() && SP.getBoolean(R.string.key_nsalarm_urgent_staledata, false))
return true;
return false;
}
@@ -141,4 +141,19 @@ public class Notification {
return true;
return false;
}
+
+ boolean isAlarmForStaleData(){
+ BgReading bgReading = MainApp.getDbHelper().lastBg();
+ if (bgReading == null)
+ return false;
+ long bgReadingAgo = System.currentTimeMillis() - bgReading.date;
+ int bgReadingAgoMin = (int) (bgReadingAgo / (1000 * 60));
+ //Integer staleDataThreshold = NSSettingsStatus.getInstance().getIntegerOrNull("alarmTimeagoWarnMins");
+ //if (staleDataThreshold == null)
+ // return false;
+ if(bgReadingAgoMin > SP.getInt(R.string.key_nsalarm_staledatavalue,16)){
+ return true;
+ }
+ return false;
+ }
}
From 450634418e5a02528ce55c6a9a6b6bbd62b1f07a Mon Sep 17 00:00:00 2001
From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com>
Date: Thu, 3 Aug 2017 18:47:51 +0300
Subject: [PATCH 02/35] added isAlarmForStaleData()
From 232590e7075ab5b103cde759066aa1651e1a7fb8 Mon Sep 17 00:00:00 2001
From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com>
Date: Thu, 3 Aug 2017 18:48:45 +0300
Subject: [PATCH 03/35] Added staleData
---
.../plugins/NSClientInternal/data/NSSettingsStatus.java | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java
index 4980b342e9..f7a2de3144 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java
@@ -188,6 +188,11 @@ public class NSSettingsStatus {
return result;
}
}
+ if (settingsO.has("alarmTimeagoWarnMins") && what == "alarmTimeagoWarnMins"){
+ JSONObject tObject = settingsO.getJSONObject("alarmTimeagoWarnMins");
+ Double result = tObject.getDouble(what);
+ return result;
+ }
}
} catch (JSONException e) {
e.printStackTrace();
@@ -271,7 +276,6 @@ public class NSSettingsStatus {
, warnBattP: sbx.extendedSettings.warnBattP || 30
, urgentBattP: sbx.extendedSettings.urgentBattP || 20
, enableAlerts: sbx.extendedSettings.enableAlerts || false
-
*/
public double extendedPumpSettings(String setting) {
From 529d267b9d37a78665ee855e82e16c6a2c035cb4 Mon Sep 17 00:00:00 2001
From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com>
Date: Fri, 4 Aug 2017 12:29:48 +0300
Subject: [PATCH 04/35] Added check for staleData and notification
with every loop
---
app/src/main/res/layout/overview_fragment.xml | 2304 +++++++++++++----
1 file changed, 1842 insertions(+), 462 deletions(-)
diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml
index 6432f0a998..0708ac5005 100644
--- a/app/src/main/res/layout/overview_fragment.xml
+++ b/app/src/main/res/layout/overview_fragment.xml
@@ -1,462 +1,1842 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
+package info.nightscout.androidaps.plugins.Overview;
+
+import android.annotation.SuppressLint;
+import android.app.Activity;
+import android.app.NotificationManager;
+import android.content.Context;
+import android.content.DialogInterface;
+import android.graphics.Color;
+import android.graphics.DashPathEffect;
+import android.graphics.Paint;
+import android.os.Bundle;
+import android.os.Handler;
+import android.os.HandlerThread;
+import android.support.v4.app.Fragment;
+import android.support.v4.app.FragmentManager;
+import android.support.v4.content.ContextCompat;
+import android.support.v7.app.AlertDialog;
+import android.support.v7.widget.CardView;
+import android.support.v7.widget.LinearLayoutManager;
+import android.support.v7.widget.RecyclerView;
+import android.util.DisplayMetrics;
+import android.util.TypedValue;
+import android.view.ContextMenu;
+import android.view.HapticFeedbackConstants;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.CheckBox;
+import android.widget.CompoundButton;
+import android.widget.LinearLayout;
+import android.widget.TextView;
+
+import com.crashlytics.android.answers.Answers;
+import com.crashlytics.android.answers.CustomEvent;
+import com.jjoe64.graphview.GraphView;
+import com.jjoe64.graphview.LabelFormatter;
+import com.jjoe64.graphview.ValueDependentColor;
+import com.jjoe64.graphview.Viewport;
+import com.jjoe64.graphview.series.BarGraphSeries;
+import com.jjoe64.graphview.series.DataPoint;
+import com.jjoe64.graphview.series.LineGraphSeries;
+import com.jjoe64.graphview.series.Series;
+import com.squareup.otto.Subscribe;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
+import info.nightscout.androidaps.BuildConfig;
+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.DetailedBolusInfo;
+import info.nightscout.androidaps.data.GlucoseStatus;
+import info.nightscout.androidaps.data.IobTotal;
+import info.nightscout.androidaps.data.Profile;
+import info.nightscout.androidaps.data.PumpEnactResult;
+import info.nightscout.androidaps.db.BgReading;
+import info.nightscout.androidaps.db.CareportalEvent;
+import info.nightscout.androidaps.db.DatabaseHelper;
+import info.nightscout.androidaps.db.ExtendedBolus;
+import info.nightscout.androidaps.db.ProfileSwitch;
+import info.nightscout.androidaps.db.Source;
+import info.nightscout.androidaps.db.TempTarget;
+import info.nightscout.androidaps.db.TemporaryBasal;
+import info.nightscout.androidaps.db.Treatment;
+import info.nightscout.androidaps.events.EventCareportalEventChange;
+import info.nightscout.androidaps.events.EventExtendedBolusChange;
+import info.nightscout.androidaps.events.EventInitializationChanged;
+import info.nightscout.androidaps.events.EventPreferenceChange;
+import info.nightscout.androidaps.events.EventPumpStatusChanged;
+import info.nightscout.androidaps.events.EventRefreshOverview;
+import info.nightscout.androidaps.events.EventTempBasalChange;
+import info.nightscout.androidaps.events.EventTempTargetChange;
+import info.nightscout.androidaps.events.EventTreatmentChange;
+import info.nightscout.androidaps.interfaces.PluginBase;
+import info.nightscout.androidaps.interfaces.PumpInterface;
+import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
+import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
+import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
+import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
+import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
+import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
+import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
+import info.nightscout.androidaps.plugins.IobCobCalculator.events.BasalData;
+import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
+import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
+import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
+import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastAckAlarm;
+import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus;
+import info.nightscout.androidaps.plugins.OpenAPSAMA.DetermineBasalResultAMA;
+import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
+import info.nightscout.androidaps.plugins.Overview.Dialogs.CalibrationDialog;
+import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTreatmentDialog;
+import info.nightscout.androidaps.plugins.Overview.Dialogs.WizardDialog;
+import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
+import info.nightscout.androidaps.plugins.Overview.events.EventSetWakeLock;
+import info.nightscout.androidaps.plugins.Overview.graphExtensions.AreaGraphSeries;
+import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
+import info.nightscout.androidaps.plugins.Overview.graphExtensions.DoubleDataPoint;
+import info.nightscout.androidaps.plugins.Overview.graphExtensions.FixedLineGraphSeries;
+import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
+import info.nightscout.androidaps.plugins.Overview.graphExtensions.TimeAsXAxisLabelFormatter;
+import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
+import info.nightscout.utils.BolusWizard;
+import info.nightscout.utils.DateUtil;
+import info.nightscout.utils.DecimalFormatter;
+import info.nightscout.utils.NSUpload;
+import info.nightscout.utils.OKDialog;
+import info.nightscout.utils.Profiler;
+import info.nightscout.utils.Round;
+import info.nightscout.utils.SP;
+import info.nightscout.utils.ToastUtils;
+//Added By Rumen for staledata alarm
+import info.nightscout.androidaps.plugins.Overview.Notification;
+import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
+import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
+
+public class OverviewFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
+ private static Logger log = LoggerFactory.getLogger(OverviewFragment.class);
+
+ private static OverviewPlugin overviewPlugin = new OverviewPlugin();
+
+ public static OverviewPlugin getPlugin() {
+ return overviewPlugin;
+ }
+
+ TextView timeView;
+ TextView bgView;
+ TextView arrowView;
+ TextView timeAgoView;
+ TextView deltaView;
+ TextView avgdeltaView;
+ TextView baseBasalView;
+ TextView extendedBolusView;
+ TextView activeProfileView;
+ TextView iobView;
+ TextView cobView;
+ TextView apsModeView;
+ TextView tempTargetView;
+ TextView pumpStatusView;
+ TextView pumpDeviceStatusView;
+ TextView openapsDeviceStatusView;
+ TextView uploaderDeviceStatusView;
+ LinearLayout loopStatusLayout;
+ LinearLayout pumpStatusLayout;
+ GraphView bgGraph;
+ GraphView iobGraph;
+
+ TextView iage;
+ TextView cage;
+ TextView sage;
+ TextView pbage;
+
+ CheckBox showPredictionView;
+ CheckBox showBasalsView;
+ CheckBox showIobView;
+ CheckBox showCobView;
+ CheckBox showDeviationsView;
+ CheckBox showRatiosView;
+
+ RecyclerView notificationsView;
+ LinearLayoutManager llm;
+
+ LinearLayout acceptTempLayout;
+ Button treatmentButton;
+ Button wizardButton;
+ Button calibrationButton;
+ Button acceptTempButton;
+ Button quickWizardButton;
+
+ CheckBox lockScreen;
+
+ boolean smallWidth;
+ boolean smallHeight;
+
+ public static boolean shorttextmode = false;
+
+ private int rangeToDisplay = 6; // for graph
+
+ Handler sLoopHandler = new Handler();
+ Runnable sRefreshLoop = null;
+
+ private static Handler sHandler;
+ private static HandlerThread sHandlerThread;
+
+ private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
+ private static ScheduledFuture> scheduledUpdate = null;
+
+ public OverviewFragment() {
+ super();
+ if (sHandlerThread == null) {
+ sHandlerThread = new HandlerThread(OverviewFragment.class.getSimpleName());
+ sHandlerThread.start();
+ sHandler = new Handler(sHandlerThread.getLooper());
+ }
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+
+ //check screen width
+ final DisplayMetrics dm = new DisplayMetrics();
+ getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
+ int screen_width = dm.widthPixels;
+ int screen_height = dm.heightPixels;
+ smallWidth = screen_width < Constants.SMALL_WIDTH;
+ smallHeight = screen_height < Constants.SMALL_HEIGHT;
+ boolean landscape = screen_height < screen_width;
+
+ View view;
+
+ if (MainApp.sResources.getBoolean(R.bool.isTablet) && BuildConfig.NSCLIENTOLNY) {
+ view = inflater.inflate(R.layout.overview_fragment_nsclient_tablet, container, false);
+ } else if (BuildConfig.NSCLIENTOLNY) {
+ view = inflater.inflate(R.layout.overview_fragment_nsclient, container, false);
+ shorttextmode = true;
+ } else if (smallHeight || landscape) {
+ view = inflater.inflate(R.layout.overview_fragment_smallheight, container, false);
+ } else {
+ view = inflater.inflate(R.layout.overview_fragment, container, false);
+ }
+
+ timeView = (TextView) view.findViewById(R.id.overview_time);
+ bgView = (TextView) view.findViewById(R.id.overview_bg);
+ arrowView = (TextView) view.findViewById(R.id.overview_arrow);
+ if (smallWidth) {
+ arrowView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 35);
+ }
+ timeAgoView = (TextView) view.findViewById(R.id.overview_timeago);
+ deltaView = (TextView) view.findViewById(R.id.overview_delta);
+ avgdeltaView = (TextView) view.findViewById(R.id.overview_avgdelta);
+ baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal);
+ extendedBolusView = (TextView) view.findViewById(R.id.overview_extendedbolus);
+ activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile);
+ pumpStatusView = (TextView) view.findViewById(R.id.overview_pumpstatus);
+ pumpDeviceStatusView = (TextView) view.findViewById(R.id.overview_pump);
+ openapsDeviceStatusView = (TextView) view.findViewById(R.id.overview_openaps);
+ uploaderDeviceStatusView = (TextView) view.findViewById(R.id.overview_uploader);
+ loopStatusLayout = (LinearLayout) view.findViewById(R.id.overview_looplayout);
+ pumpStatusLayout = (LinearLayout) view.findViewById(R.id.overview_pumpstatuslayout);
+
+ pumpStatusView.setBackgroundColor(MainApp.sResources.getColor(R.color.colorInitializingBorder));
+
+ iobView = (TextView) view.findViewById(R.id.overview_iob);
+ cobView = (TextView) view.findViewById(R.id.overview_cob);
+ apsModeView = (TextView) view.findViewById(R.id.overview_apsmode);
+ tempTargetView = (TextView) view.findViewById(R.id.overview_temptarget);
+
+ iage = (TextView) view.findViewById(R.id.careportal_insulinage);
+ cage = (TextView) view.findViewById(R.id.careportal_canulaage);
+ sage = (TextView) view.findViewById(R.id.careportal_sensorage);
+ pbage = (TextView) view.findViewById(R.id.careportal_pbage);
+
+ bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
+ iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph);
+
+ treatmentButton = (Button) view.findViewById(R.id.overview_treatmentbutton);
+ treatmentButton.setOnClickListener(this);
+ wizardButton = (Button) view.findViewById(R.id.overview_wizardbutton);
+ wizardButton.setOnClickListener(this);
+ acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton);
+ if (acceptTempButton != null)
+ acceptTempButton.setOnClickListener(this);
+ quickWizardButton = (Button) view.findViewById(R.id.overview_quickwizardbutton);
+ quickWizardButton.setOnClickListener(this);
+ calibrationButton = (Button) view.findViewById(R.id.overview_calibrationbutton);
+ if (calibrationButton != null)
+ calibrationButton.setOnClickListener(this);
+
+ acceptTempLayout = (LinearLayout) view.findViewById(R.id.overview_accepttemplayout);
+
+ showPredictionView = (CheckBox) view.findViewById(R.id.overview_showprediction);
+ showBasalsView = (CheckBox) view.findViewById(R.id.overview_showbasals);
+ showIobView = (CheckBox) view.findViewById(R.id.overview_showiob);
+ showCobView = (CheckBox) view.findViewById(R.id.overview_showcob);
+ showDeviationsView = (CheckBox) view.findViewById(R.id.overview_showdeviations);
+ showRatiosView = (CheckBox) view.findViewById(R.id.overview_showratios);
+ showPredictionView.setChecked(SP.getBoolean("showprediction", false));
+ showBasalsView.setChecked(SP.getBoolean("showbasals", true));
+ showIobView.setChecked(SP.getBoolean("showiob", false));
+ showCobView.setChecked(SP.getBoolean("showcob", false));
+ showDeviationsView.setChecked(SP.getBoolean("showdeviations", false));
+ showRatiosView.setChecked(SP.getBoolean("showratios", false));
+ showPredictionView.setOnCheckedChangeListener(this);
+ showBasalsView.setOnCheckedChangeListener(this);
+ showIobView.setOnCheckedChangeListener(this);
+ showCobView.setOnCheckedChangeListener(this);
+ showDeviationsView.setOnCheckedChangeListener(this);
+ showRatiosView.setOnCheckedChangeListener(this);
+
+ notificationsView = (RecyclerView) view.findViewById(R.id.overview_notifications);
+ notificationsView.setHasFixedSize(true);
+ llm = new LinearLayoutManager(view.getContext());
+ notificationsView.setLayoutManager(llm);
+
+ bgGraph.getGridLabelRenderer().setGridColor(MainApp.sResources.getColor(R.color.graphgrid));
+ bgGraph.getGridLabelRenderer().reloadStyles();
+ iobGraph.getGridLabelRenderer().setGridColor(MainApp.sResources.getColor(R.color.graphgrid));
+ iobGraph.getGridLabelRenderer().reloadStyles();
+ iobGraph.getGridLabelRenderer().setHorizontalLabelsVisible(false);
+ bgGraph.getGridLabelRenderer().setLabelVerticalWidth(50);
+ iobGraph.getGridLabelRenderer().setLabelVerticalWidth(50);
+ iobGraph.getGridLabelRenderer().setNumVerticalLabels(5);
+
+ rangeToDisplay = SP.getInt(R.string.key_rangetodisplay, 6);
+
+ bgGraph.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View v) {
+ rangeToDisplay += 6;
+ rangeToDisplay = rangeToDisplay > 24 ? 6 : rangeToDisplay;
+ SP.putInt(R.string.key_rangetodisplay, rangeToDisplay);
+ updateGUI("rangeChange");
+ return false;
+ }
+ });
+
+ lockScreen = (CheckBox) view.findViewById(R.id.overview_lockscreen);
+ if (lockScreen != null) {
+ lockScreen.setChecked(SP.getBoolean("lockscreen", false));
+ lockScreen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ SP.putBoolean("lockscreen", isChecked);
+ MainApp.bus().post(new EventSetWakeLock(isChecked));
+ }
+ });
+ }
+
+ return view;
+ }
+
+
+ @Override
+ public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
+ super.onCreateContextMenu(menu, v, menuInfo);
+ final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
+ if (activeloop == null)
+ return;
+ menu.setHeaderTitle(MainApp.sResources.getString(R.string.loop));
+ if (activeloop.isEnabled(PluginBase.LOOP)) {
+ menu.add(MainApp.sResources.getString(R.string.disableloop));
+ if (!activeloop.isSuspended()) {
+ menu.add(MainApp.sResources.getString(R.string.suspendloopfor1h));
+ menu.add(MainApp.sResources.getString(R.string.suspendloopfor2h));
+ menu.add(MainApp.sResources.getString(R.string.suspendloopfor3h));
+ menu.add(MainApp.sResources.getString(R.string.suspendloopfor10h));
+ menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor30m));
+ menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor1h));
+ menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor2h));
+ menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor3h));
+ } else {
+ menu.add(MainApp.sResources.getString(R.string.resume));
+ }
+ }
+ if (!activeloop.isEnabled(PluginBase.LOOP))
+ menu.add(MainApp.sResources.getString(R.string.enableloop));
+ }
+
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ switch (buttonView.getId()) {
+ case R.id.overview_showprediction:
+ case R.id.overview_showbasals:
+ case R.id.overview_showiob:
+ break;
+ case R.id.overview_showcob:
+ showDeviationsView.setOnCheckedChangeListener(null);
+ showDeviationsView.setChecked(false);
+ showDeviationsView.setOnCheckedChangeListener(this);
+ break;
+ case R.id.overview_showdeviations:
+ showCobView.setOnCheckedChangeListener(null);
+ showCobView.setChecked(false);
+ showCobView.setOnCheckedChangeListener(this);
+ break;
+ case R.id.overview_showratios:
+ break;
+ }
+ SP.putBoolean("showiob", showIobView.isChecked());
+ SP.putBoolean("showprediction", showPredictionView.isChecked());
+ SP.putBoolean("showbasals", showBasalsView.isChecked());
+ SP.putBoolean("showcob", showCobView.isChecked());
+ SP.putBoolean("showdeviations", showDeviationsView.isChecked());
+ SP.putBoolean("showratios", showRatiosView.isChecked());
+ scheduleUpdateGUI("onGraphCheckboxesCheckedChanged");
+ }
+
+ @Override
+ public boolean onContextItemSelected(MenuItem item) {
+ final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
+ if (item.getTitle().equals(MainApp.sResources.getString(R.string.disableloop))) {
+ activeloop.setFragmentEnabled(PluginBase.LOOP, false);
+ activeloop.setFragmentVisible(PluginBase.LOOP, false);
+ MainApp.getConfigBuilder().storeSettings();
+ updateGUI("suspendmenu");
+ sHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
+ if (!result.success) {
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
+ }
+ }
+ });
+ NSUpload.uploadOpenAPSOffline(60); // upload 60 min, we don;t know real duration
+ return true;
+ } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.enableloop))) {
+ activeloop.setFragmentEnabled(PluginBase.LOOP, true);
+ activeloop.setFragmentVisible(PluginBase.LOOP, true);
+ MainApp.getConfigBuilder().storeSettings();
+ updateGUI("suspendmenu");
+ NSUpload.uploadOpenAPSOffline(0);
+ return true;
+ } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.resume))) {
+ activeloop.suspendTo(0L);
+ updateGUI("suspendmenu");
+ sHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
+ if (!result.success) {
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
+ }
+ }
+ });
+ NSUpload.uploadOpenAPSOffline(0);
+ return true;
+ } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor1h))) {
+ activeloop.suspendTo(System.currentTimeMillis() + 60L * 60 * 1000);
+ updateGUI("suspendmenu");
+ sHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
+ if (!result.success) {
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
+ }
+ }
+ });
+ NSUpload.uploadOpenAPSOffline(60);
+ return true;
+ } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor2h))) {
+ activeloop.suspendTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
+ updateGUI("suspendmenu");
+ sHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
+ if (!result.success) {
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
+ }
+ }
+ });
+ NSUpload.uploadOpenAPSOffline(120);
+ return true;
+ } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor3h))) {
+ activeloop.suspendTo(System.currentTimeMillis() + 3 * 60L * 60 * 1000);
+ updateGUI("suspendmenu");
+ sHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
+ if (!result.success) {
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
+ }
+ }
+ });
+ NSUpload.uploadOpenAPSOffline(180);
+ return true;
+ } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor10h))) {
+ activeloop.suspendTo(System.currentTimeMillis() + 10 * 60L * 60 * 1000);
+ updateGUI("suspendmenu");
+ sHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
+ if (!result.success) {
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
+ }
+ }
+ });
+ NSUpload.uploadOpenAPSOffline(600);
+ return true;
+ } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor30m))) {
+ activeloop.suspendTo(System.currentTimeMillis() + 30L * 60 * 1000);
+ updateGUI("suspendmenu");
+ sHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ MainApp.getConfigBuilder().cancelTempBasal(true);
+ PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 30);
+ if (!result.success) {
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
+ }
+ }
+ });
+ NSUpload.uploadOpenAPSOffline(30);
+ return true;
+ } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor1h))) {
+ activeloop.suspendTo(System.currentTimeMillis() + 1 * 60L * 60 * 1000);
+ updateGUI("suspendmenu");
+ sHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ MainApp.getConfigBuilder().cancelTempBasal(true);
+ PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 60);
+ if (!result.success) {
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
+ }
+ }
+ });
+ NSUpload.uploadOpenAPSOffline(60);
+ return true;
+ } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor2h))) {
+ activeloop.suspendTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
+ updateGUI("suspendmenu");
+ sHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ MainApp.getConfigBuilder().cancelTempBasal(true);
+ PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 2 * 60);
+ if (!result.success) {
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
+ }
+ }
+ });
+ NSUpload.uploadOpenAPSOffline(120);
+ return true;
+ } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor3h))) {
+ activeloop.suspendTo(System.currentTimeMillis() + 3 * 60L * 60 * 1000);
+ updateGUI("suspendmenu");
+ sHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ MainApp.getConfigBuilder().cancelTempBasal(true);
+ PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 3 * 60);
+ if (!result.success) {
+ ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
+ }
+ }
+ });
+ NSUpload.uploadOpenAPSOffline(180);
+ return true;
+ }
+
+ return super.onContextItemSelected(item);
+ }
+
+ @Override
+ public void onClick(View v) {
+ FragmentManager manager = getFragmentManager();
+ switch (v.getId()) {
+ case R.id.overview_accepttempbutton:
+ onClickAcceptTemp();
+ break;
+ case R.id.overview_quickwizardbutton:
+ onClickQuickwizard();
+ break;
+ case R.id.overview_wizardbutton:
+ WizardDialog wizardDialog = new WizardDialog();
+ wizardDialog.show(manager, "WizardDialog");
+ break;
+ case R.id.overview_calibrationbutton:
+ CalibrationDialog calibrationDialog = new CalibrationDialog();
+ calibrationDialog.show(manager, "CalibrationDialog");
+ break;
+ case R.id.overview_treatmentbutton:
+ NewTreatmentDialog treatmentDialogFragment = new NewTreatmentDialog();
+ treatmentDialogFragment.show(manager, "TreatmentDialog");
+ break;
+ case R.id.overview_pumpstatus:
+ if (MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().isInitialized())
+ sHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ MainApp.getConfigBuilder().refreshDataFromPump("RefreshClicked");
+ }
+ });
+ break;
+ }
+
+ }
+
+ private void onClickAcceptTemp() {
+ if (ConfigBuilderPlugin.getActiveLoop() != null) {
+ ConfigBuilderPlugin.getActiveLoop().invoke("Accept temp button", false);
+ final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
+ if (finalLastRun != null && finalLastRun.lastAPSRun != null && finalLastRun.constraintsProcessed.changeRequested) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
+ builder.setTitle(getContext().getString(R.string.confirmation));
+ builder.setMessage(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
+ builder.setPositiveButton(getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ sHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ hideTempRecommendation();
+ clearNotification();
+ PumpEnactResult applyResult = MainApp.getConfigBuilder().applyAPSRequest(finalLastRun.constraintsProcessed);
+ if (applyResult.enacted) {
+ finalLastRun.setByPump = applyResult;
+ finalLastRun.lastEnact = new Date();
+ finalLastRun.lastOpenModeAccept = new Date();
+ NSUpload.uploadDeviceStatus();
+ ObjectivesPlugin objectivesPlugin = (ObjectivesPlugin) MainApp.getSpecificPlugin(ObjectivesPlugin.class);
+ if (objectivesPlugin != null) {
+ ObjectivesPlugin.manualEnacts++;
+ ObjectivesPlugin.saveProgress();
+ }
+ }
+ scheduleUpdateGUI("onClickAcceptTemp");
+ }
+ });
+ Answers.getInstance().logCustom(new CustomEvent("AcceptTemp"));
+ }
+ });
+ builder.setNegativeButton(getContext().getString(R.string.cancel), null);
+ builder.show();
+ }
+ }
+ }
+
+ void onClickQuickwizard() {
+ final BgReading actualBg = DatabaseHelper.actualBg();
+ final Profile profile = MainApp.getConfigBuilder().getProfile();
+
+ QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
+ if (quickWizardEntry != null && actualBg != null) {
+ quickWizardButton.setVisibility(View.VISIBLE);
+ BolusWizard wizard = new BolusWizard();
+ wizard.doCalc(profile, quickWizardEntry.carbs(), 0d, actualBg.valueToUnits(profile.getUnits()), 0d, true, true, false, false);
+
+ final JSONObject boluscalcJSON = new JSONObject();
+ try {
+ boluscalcJSON.put("eventTime", DateUtil.toISOString(new Date()));
+ boluscalcJSON.put("targetBGLow", wizard.targetBGLow);
+ boluscalcJSON.put("targetBGHigh", wizard.targetBGHigh);
+ boluscalcJSON.put("isf", wizard.sens);
+ boluscalcJSON.put("ic", wizard.ic);
+ boluscalcJSON.put("iob", -(wizard.insulingFromBolusIOB + wizard.insulingFromBasalsIOB));
+ boluscalcJSON.put("bolusiobused", true);
+ boluscalcJSON.put("basaliobused", true);
+ boluscalcJSON.put("bg", actualBg.valueToUnits(profile.getUnits()));
+ boluscalcJSON.put("insulinbg", wizard.insulinFromBG);
+ boluscalcJSON.put("insulinbgused", true);
+ boluscalcJSON.put("bgdiff", wizard.bgDiff);
+ boluscalcJSON.put("insulincarbs", wizard.insulinFromCarbs);
+ boluscalcJSON.put("carbs", quickWizardEntry.carbs());
+ boluscalcJSON.put("othercorrection", 0d);
+ boluscalcJSON.put("insulintrend", wizard.insulinFromTrend);
+ boluscalcJSON.put("insulin", wizard.calculatedTotalInsulin);
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ if (wizard.calculatedTotalInsulin > 0d && quickWizardEntry.carbs() > 0d) {
+ DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
+ String confirmMessage = getString(R.string.entertreatmentquestion);
+
+ Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(wizard.calculatedTotalInsulin);
+ Integer carbsAfterConstraints = MainApp.getConfigBuilder().applyCarbsConstraints(quickWizardEntry.carbs());
+
+ confirmMessage += "\n" + getString(R.string.bolus) + ": " + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U";
+ confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
+
+ if (!insulinAfterConstraints.equals(wizard.calculatedTotalInsulin) || !carbsAfterConstraints.equals(quickWizardEntry.carbs())) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
+ builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
+ builder.setMessage(getString(R.string.constraints_violation) + "\n" + getString(R.string.changeyourinput));
+ builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
+ builder.show();
+ return;
+ }
+
+ final Double finalInsulinAfterConstraints = insulinAfterConstraints;
+ final Integer finalCarbsAfterConstraints = carbsAfterConstraints;
+ final Context context = getContext();
+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
+ builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
+ builder.setMessage(confirmMessage);
+ builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
+ public void onClick(DialogInterface dialog, int id) {
+ if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
+ final ConfigBuilderPlugin pump = MainApp.getConfigBuilder();
+ sHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
+ detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD;
+ detailedBolusInfo.insulin = finalInsulinAfterConstraints;
+ detailedBolusInfo.carbs = finalCarbsAfterConstraints;
+ detailedBolusInfo.context = context;
+ detailedBolusInfo.boluscalc = boluscalcJSON;
+ detailedBolusInfo.source = Source.USER;
+ PumpEnactResult result = pump.deliverTreatment(detailedBolusInfo);
+ if (!result.success) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
+ builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
+ builder.setMessage(result.comment);
+ builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
+ builder.show();
+ }
+ }
+ });
+ Answers.getInstance().logCustom(new CustomEvent("QuickWizard"));
+ }
+ }
+ });
+ builder.setNegativeButton(getString(R.string.cancel), null);
+ builder.show();
+ }
+ }
+
+ }
+
+ @Override
+ public void onPause() {
+ super.onPause();
+ MainApp.bus().unregister(this);
+ sLoopHandler.removeCallbacksAndMessages(null);
+ unregisterForContextMenu(apsModeView);
+ }
+
+ @Override
+ public void onResume() {
+ super.onResume();
+ MainApp.bus().register(this);
+ sRefreshLoop = new Runnable() {
+ @Override
+ public void run() {
+ scheduleUpdateGUI("refreshLoop");
+ sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
+ // Added by Rumen for STALE DATA ALARM
+ boolean isThereStaleData = Notification.isAlarmForStaleData();
+ log.debug("isThereIsStaleData: "+isThereStaleData);
+ if(isThereStaleData){
+ Notification notification = new Notification(Notification.NSALARM, getString(R.string.nsalarm_staledata), Notification.URGENT);
+ MainApp.bus().post(new EventNewNotification(notification));
+ }
+ // end of insert
+ }
+ };
+ sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
+ registerForContextMenu(apsModeView);
+ updateGUI("onResume");
+ }
+
+ @Subscribe
+ public void onStatusEvent(final EventInitializationChanged ev) {
+ scheduleUpdateGUI("EventInitializationChanged");
+ }
+
+ @Subscribe
+ public void onStatusEvent(final EventPreferenceChange ev) {
+ scheduleUpdateGUI("EventPreferenceChange");
+ }
+
+ @Subscribe
+ public void onStatusEvent(final EventRefreshOverview ev) {
+ scheduleUpdateGUI(ev.from);
+ }
+
+ @Subscribe
+ public void onStatusEvent(final EventAutosensCalculationFinished ev) {
+ scheduleUpdateGUI("EventAutosensCalculationFinished");
+ }
+
+ @Subscribe
+ public void onStatusEvent(final EventTreatmentChange ev) {
+ scheduleUpdateGUI("EventTreatmentChange");
+ }
+
+ @Subscribe
+ public void onStatusEvent(final EventCareportalEventChange ev) {
+ scheduleUpdateGUI("EventCareportalEventChange");
+ }
+
+ @Subscribe
+ public void onStatusEvent(final EventTempBasalChange ev) {
+ scheduleUpdateGUI("EventTempBasalChange");
+ }
+
+ @Subscribe
+ public void onStatusEvent(final EventExtendedBolusChange ev) {
+ scheduleUpdateGUI("EventExtendedBolusChange");
+ }
+
+// Handled by EventAutosensCalculationFinished
+// @Subscribe
+// public void onStatusEvent(final EventNewBG ev) {
+// scheduleUpdateGUI("EventNewBG");
+// }
+
+ @Subscribe
+ public void onStatusEvent(final EventNewOpenLoopNotification ev) {
+ scheduleUpdateGUI("EventNewOpenLoopNotification");
+ }
+
+// Handled by EventAutosensCalculationFinished
+// @Subscribe
+// public void onStatusEvent(final EventNewBasalProfile ev) {
+// scheduleUpdateGUI("EventNewBasalProfile");
+// }
+
+ @Subscribe
+ public void onStatusEvent(final EventTempTargetChange ev) {
+ scheduleUpdateGUI("EventTempTargetChange");
+ }
+
+ @Subscribe
+ public void onStatusEvent(final EventPumpStatusChanged s) {
+ Activity activity = getActivity();
+ if (activity != null)
+ activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ updatePumpStatus(s.textStatus());
+ }
+ });
+ }
+
+ private void hideTempRecommendation() {
+ Activity activity = getActivity();
+ if (activity != null)
+ activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ if (acceptTempLayout != null)
+ acceptTempLayout.setVisibility(View.GONE);
+ }
+ });
+ }
+
+ private void clearNotification() {
+ NotificationManager notificationManager =
+ (NotificationManager) MainApp.instance().getSystemService(Context.NOTIFICATION_SERVICE);
+ notificationManager.cancel(Constants.notificationID);
+ }
+
+ private void updatePumpStatus(String status) {
+ if (!status.equals("")) {
+ pumpStatusView.setText(status);
+ pumpStatusLayout.setVisibility(View.VISIBLE);
+ loopStatusLayout.setVisibility(View.GONE);
+ } else {
+ pumpStatusLayout.setVisibility(View.GONE);
+ loopStatusLayout.setVisibility(View.VISIBLE);
+ }
+ }
+
+ public void scheduleUpdateGUI(final String from) {
+ class UpdateRunnable implements Runnable {
+ public void run() {
+ Activity activity = getActivity();
+ if (activity != null)
+ activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ updateGUI(from);
+ scheduledUpdate = null;
+ }
+ });
+ }
+ }
+ // prepare task for execution in 400 msec
+ // cancel waiting task to prevent multiple updates
+ if (scheduledUpdate != null)
+ scheduledUpdate.cancel(false);
+ Runnable task = new UpdateRunnable();
+ final int msec = 500;
+ scheduledUpdate = worker.schedule(task, msec, TimeUnit.MILLISECONDS);
+ }
+
+ @SuppressLint("SetTextI18n")
+ public void updateGUI(String from) {
+ log.debug("updateGUI entered from: " + from);
+ Date updateGUIStart = new Date();
+
+ if (getActivity() == null)
+ return;
+
+ if (timeView != null) { //must not exists
+ timeView.setText(DateUtil.timeString(new Date()));
+ }
+ if (MainApp.getConfigBuilder().getProfile() == null) {// app not initialized yet
+ pumpStatusView.setText(R.string.noprofileset);
+ pumpStatusLayout.setVisibility(View.VISIBLE);
+ loopStatusLayout.setVisibility(View.GONE);
+ return;
+ }
+ pumpStatusLayout.setVisibility(View.GONE);
+ loopStatusLayout.setVisibility(View.VISIBLE);
+
+ updateNotifications();
+ CareportalFragment.updateAge(getActivity(), sage, iage, cage, pbage);
+ BgReading actualBG = DatabaseHelper.actualBg();
+ BgReading lastBG = DatabaseHelper.lastBg();
+
+ PumpInterface pump = MainApp.getConfigBuilder();
+
+ Profile profile = MainApp.getConfigBuilder().getProfile();
+ String units = profile.getUnits();
+
+ if (units == null) {
+ pumpStatusView.setText(R.string.noprofileset);
+ pumpStatusLayout.setVisibility(View.VISIBLE);
+ loopStatusLayout.setVisibility(View.GONE);
+ return;
+ }
+
+ // open loop mode
+ final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
+ if (Config.APS && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable) {
+ apsModeView.setVisibility(View.VISIBLE);
+ apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.loopenabled));
+ apsModeView.setTextColor(Color.BLACK);
+ final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
+ if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuperBolus()) {
+ apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
+ apsModeView.setText(String.format(MainApp.sResources.getString(R.string.loopsuperbolusfor), activeloop.minutesToEndOfSuspend()));
+ apsModeView.setTextColor(Color.WHITE);
+ } else if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuspended()) {
+ apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
+ apsModeView.setText(String.format(MainApp.sResources.getString(R.string.loopsuspendedfor), activeloop.minutesToEndOfSuspend()));
+ apsModeView.setTextColor(Color.WHITE);
+ } else if (pump.isSuspended()) {
+ apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
+ apsModeView.setText(MainApp.sResources.getString(R.string.pumpsuspended));
+ apsModeView.setTextColor(Color.WHITE);
+ } else if (activeloop != null && activeloop.isEnabled(activeloop.getType())) {
+ if (MainApp.getConfigBuilder().isClosedModeEnabled()) {
+ apsModeView.setText(MainApp.sResources.getString(R.string.closedloop));
+ } else {
+ apsModeView.setText(MainApp.sResources.getString(R.string.openloop));
+ }
+ } else {
+ apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.loopdisabled));
+ apsModeView.setText(MainApp.sResources.getString(R.string.disabledloop));
+ apsModeView.setTextColor(Color.WHITE);
+ }
+ } else {
+ apsModeView.setVisibility(View.GONE);
+ }
+
+ // temp target
+ TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(System.currentTimeMillis());
+ if (tempTarget != null) {
+ tempTargetView.setTextColor(Color.BLACK);
+ tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetBackground));
+ tempTargetView.setVisibility(View.VISIBLE);
+ if (tempTarget.low == tempTarget.high)
+ tempTargetView.setText(Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, units), units));
+ else
+ tempTargetView.setText(Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, units), units) + " - " + Profile.toUnitsString(tempTarget.high, Profile.fromMgdlToUnits(tempTarget.high, units), units));
+ } else {
+ Double maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
+ Double minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
+ if (!units.equals(Constants.MGDL)) {
+ maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
+ minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
+ }
+ tempTargetView.setTextColor(Color.WHITE);
+ tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetDisabledBackground));
+ double low = SP.getDouble("openapsma_min_bg", minBgDefault);
+ double high = SP.getDouble("openapsma_max_bg", maxBgDefault);
+ if (low == high)
+ tempTargetView.setText("" + low);
+ else
+ tempTargetView.setText(low + " - " + high);
+ tempTargetView.setVisibility(View.VISIBLE);
+ }
+ if (Config.NSCLIENT && tempTarget == null) {
+ tempTargetView.setVisibility(View.GONE);
+ }
+
+ // **** Temp button ****
+ if (acceptTempLayout != null) {
+ boolean showAcceptButton = !MainApp.getConfigBuilder().isClosedModeEnabled(); // Open mode needed
+ showAcceptButton = showAcceptButton && finalLastRun != null && finalLastRun.lastAPSRun != null; // aps result must exist
+ showAcceptButton = showAcceptButton && (finalLastRun.lastOpenModeAccept == null || finalLastRun.lastOpenModeAccept.getTime() < finalLastRun.lastAPSRun.getTime()); // never accepted or before last result
+ showAcceptButton = showAcceptButton && finalLastRun.constraintsProcessed.changeRequested; // change is requested
+
+ if (showAcceptButton && pump.isInitialized() && !pump.isSuspended() && ConfigBuilderPlugin.getActiveLoop() != null) {
+ acceptTempLayout.setVisibility(View.VISIBLE);
+ acceptTempButton.setText(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
+ } else {
+ acceptTempLayout.setVisibility(View.GONE);
+ }
+ }
+
+ // **** Calibration button ****
+ if (calibrationButton != null) {
+ if (MainApp.getSpecificPlugin(SourceXdripPlugin.class) != null && MainApp.getSpecificPlugin(SourceXdripPlugin.class).isEnabled(PluginBase.BGSOURCE) && profile != null && DatabaseHelper.actualBg() != null) {
+ calibrationButton.setVisibility(View.VISIBLE);
+ } else {
+ calibrationButton.setVisibility(View.GONE);
+ }
+ }
+
+ final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
+ String basalText = "";
+ if (shorttextmode) {
+ if (activeTemp != null) {
+ basalText = "T: " + activeTemp.toStringVeryShort();
+ } else {
+ basalText = DecimalFormatter.to2Decimal(MainApp.getConfigBuilder().getProfile().getBasal()) + "U/h";
+ }
+ baseBasalView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ String fullText = MainApp.sResources.getString(R.string.virtualpump_basebasalrate_label) + ": " + DecimalFormatter.to2Decimal(MainApp.getConfigBuilder().getProfile().getBasal()) + "U/h\n";
+ if (activeTemp != null) {
+ fullText += MainApp.sResources.getString(R.string.virtualpump_tempbasal_label) + ": " + activeTemp.toStringFull();
+ }
+ OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.basal), fullText, null);
+ }
+ });
+
+ } else {
+ if (activeTemp != null) {
+ basalText = activeTemp.toStringFull() + " ";
+ }
+ if (Config.NSCLIENT)
+ basalText += "(" + DecimalFormatter.to2Decimal(MainApp.getConfigBuilder().getProfile().getBasal()) + " U/h)";
+ else if (pump.getPumpDescription().isTempBasalCapable) {
+ basalText += "(" + DecimalFormatter.to2Decimal(pump.getBaseBasalRate()) + "U/h)";
+ }
+ }
+ if (activeTemp != null) {
+ baseBasalView.setTextColor(MainApp.sResources.getColor(R.color.basal));
+ } else {
+ baseBasalView.setTextColor(Color.WHITE);
+
+ }
+
+ baseBasalView.setText(basalText);
+
+ final ExtendedBolus extendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
+ String extendedBolusText = "";
+ if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses()) {
+ extendedBolusText = extendedBolus.toString();
+ }
+ if (extendedBolusView != null) { // must not exists in all layouts
+ if (shorttextmode) {
+ if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses()) {
+ extendedBolusText = DecimalFormatter.to2Decimal(extendedBolus.absoluteRate()) + "U/h";
+ } else {
+ extendedBolusText = "";
+ }
+ extendedBolusView.setText(extendedBolusText);
+ extendedBolusView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.extendedbolus), extendedBolus.toString(), null);
+ }
+ });
+
+ } else {
+ extendedBolusView.setText(extendedBolusText);
+ }
+ }
+
+ activeProfileView.setText(MainApp.getConfigBuilder().getProfileName());
+ activeProfileView.setBackgroundColor(Color.GRAY);
+
+ activeProfileView.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View view) {
+ view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
+ NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
+ final OptionsToShow profileswitch = CareportalFragment.profileswitch;
+ profileswitch.executeProfileSwitch = true;
+ newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
+ newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
+ return true;
+ }
+ });
+ activeProfileView.setLongClickable(true);
+
+
+ tempTargetView.setOnLongClickListener(new View.OnLongClickListener() {
+ @Override
+ public boolean onLongClick(View view) {
+ view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
+ NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog();
+ final OptionsToShow temptarget = CareportalFragment.temptarget;
+ temptarget.executeTempTarget = true;
+ newTTDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
+ newTTDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
+ return true;
+ }
+ });
+ tempTargetView.setLongClickable(true);
+
+ // QuickWizard button
+ QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
+ if (quickWizardEntry != null && lastBG != null && pump.isInitialized() && !pump.isSuspended()) {
+ quickWizardButton.setVisibility(View.VISIBLE);
+ String text = quickWizardEntry.buttonText() + "\n" + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
+ BolusWizard wizard = new BolusWizard();
+ wizard.doCalc(profile, quickWizardEntry.carbs(), 0d, lastBG.valueToUnits(units), 0d, true, true, false, false);
+ text += " " + DecimalFormatter.to2Decimal(wizard.calculatedTotalInsulin) + "U";
+ quickWizardButton.setText(text);
+ if (wizard.calculatedTotalInsulin <= 0)
+ quickWizardButton.setVisibility(View.GONE);
+ } else
+ quickWizardButton.setVisibility(View.GONE);
+
+ // Bolus and calc button
+ if (pump.isInitialized() && !pump.isSuspended()) {
+ wizardButton.setVisibility(View.VISIBLE);
+ treatmentButton.setVisibility(View.VISIBLE);
+ } else {
+ wizardButton.setVisibility(View.GONE);
+ treatmentButton.setVisibility(View.GONE);
+ }
+
+ Double lowLine = SP.getDouble("low_mark", 0d);
+ Double highLine = SP.getDouble("high_mark", 0d);
+ if (lowLine < 1) {
+ lowLine = Profile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units);
+ }
+ if (highLine < 1) {
+ highLine = Profile.fromMgdlToUnits(OverviewPlugin.bgTargetHigh, units);
+ }
+
+ // **** BG value ****
+ if (lastBG != null) {
+ int color = MainApp.sResources.getColor(R.color.inrange);
+ if (lastBG.valueToUnits(units) < lowLine)
+ color = MainApp.sResources.getColor(R.color.low);
+ else if (lastBG.valueToUnits(units) > highLine)
+ color = MainApp.sResources.getColor(R.color.high);
+ bgView.setText(lastBG.valueToUnitsToString(units));
+ arrowView.setText(lastBG.directionToSymbol());
+ bgView.setTextColor(color);
+ arrowView.setTextColor(color);
+ GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
+ if (glucoseStatus != null) {
+ deltaView.setText("Δ " + Profile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units);
+ if (avgdeltaView != null)
+ avgdeltaView.setText("øΔ15m: " + Profile.toUnitsString(glucoseStatus.short_avgdelta, glucoseStatus.short_avgdelta * Constants.MGDL_TO_MMOLL, units) +
+ " øΔ40m: " + Profile.toUnitsString(glucoseStatus.long_avgdelta, glucoseStatus.long_avgdelta * Constants.MGDL_TO_MMOLL, units));
+ } else {
+ deltaView.setText("Δ " + MainApp.sResources.getString(R.string.notavailable));
+ if (avgdeltaView != null)
+ avgdeltaView.setText("");
+ }
+ } else {
+ return;
+ }
+ Integer flag = bgView.getPaintFlags();
+ if (actualBG == null) {
+ flag |= Paint.STRIKE_THRU_TEXT_FLAG;
+ } else
+ flag &= ~Paint.STRIKE_THRU_TEXT_FLAG;
+ bgView.setPaintFlags(flag);
+
+ Long agoMsec = System.currentTimeMillis() - lastBG.date;
+ int agoMin = (int) (agoMsec / 60d / 1000d);
+ timeAgoView.setText(String.format(MainApp.sResources.getString(R.string.minago), agoMin));
+
+ // iob
+ MainApp.getConfigBuilder().updateTotalIOBTreatments();
+ MainApp.getConfigBuilder().updateTotalIOBTempBasals();
+ final IobTotal bolusIob = MainApp.getConfigBuilder().getLastCalculationTreatments().round();
+ final IobTotal basalIob = MainApp.getConfigBuilder().getLastCalculationTempBasals().round();
+
+ if (shorttextmode) {
+ String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U";
+ iobView.setText(iobtext);
+ iobView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U\n"
+ + getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U\n"
+ + getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U\n";
+ OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.iob), iobtext, null);
+ }
+ });
+ } else if (MainApp.sResources.getBoolean(R.bool.isTablet)) {
+ String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
+ + getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
+ + getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)";
+ iobView.setText(iobtext);
+ } else {
+ String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
+ + DecimalFormatter.to2Decimal(bolusIob.iob) + "/"
+ + DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
+ iobView.setText(iobtext);
+ }
+
+ // cob
+ if (cobView != null) { // view must not exists
+ String cobText = "";
+ AutosensData autosensData = IobCobCalculatorPlugin.getAutosensData(System.currentTimeMillis());
+ if (autosensData != null)
+ cobText = (int) autosensData.cob + " g";
+ cobView.setText(cobText);
+ }
+
+ boolean showPrediction = showPredictionView.isChecked() && finalLastRun != null && finalLastRun.constraintsProcessed.getClass().equals(DetermineBasalResultAMA.class);
+ if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class) != null && MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS)) {
+ showPredictionView.setVisibility(View.VISIBLE);
+ getActivity().findViewById(R.id.overview_showprediction_label).setVisibility(View.VISIBLE);
+ } else {
+ showPredictionView.setVisibility(View.GONE);
+ getActivity().findViewById(R.id.overview_showprediction_label).setVisibility(View.GONE);
+ }
+
+ // pump status from ns
+ if (pumpDeviceStatusView != null) {
+ pumpDeviceStatusView.setText(NSDeviceStatus.getInstance().getPumpStatus());
+ pumpDeviceStatusView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.pump), NSDeviceStatus.getInstance().getExtendedPumpStatus(), null);
+ }
+ });
+ }
+
+ // OpenAPS status from ns
+ if (openapsDeviceStatusView != null) {
+ openapsDeviceStatusView.setText(NSDeviceStatus.getInstance().getOpenApsStatus());
+ openapsDeviceStatusView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.openaps), NSDeviceStatus.getInstance().getExtendedOpenApsStatus(), null);
+ }
+ });
+ }
+
+ // Uploader status from ns
+ if (uploaderDeviceStatusView != null) {
+ uploaderDeviceStatusView.setText(NSDeviceStatus.getInstance().getUploaderStatus());
+ uploaderDeviceStatusView.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.uploader), NSDeviceStatus.getInstance().getExtendedUploaderStatus(), null);
+ }
+ });
+ }
+
+ // ****** GRAPH *******
+ //log.debug("updateGUI checkpoint 1");
+
+ // allign to hours
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTimeInMillis(System.currentTimeMillis());
+ calendar.set(Calendar.MILLISECOND, 0);
+ calendar.set(Calendar.SECOND, 0);
+ calendar.set(Calendar.MINUTE, 0);
+ calendar.add(Calendar.HOUR, 1);
+
+ int hoursToFetch;
+ long toTime;
+ long fromTime;
+ long endTime;
+ if (showPrediction) {
+ int predHours = (int) (Math.ceil(((DetermineBasalResultAMA) finalLastRun.constraintsProcessed).getLatestPredictionsTime() - System.currentTimeMillis()) / (60 * 60 * 1000));
+ predHours = Math.min(2, predHours);
+ predHours = Math.max(0, predHours);
+ hoursToFetch = rangeToDisplay - predHours;
+ toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding - Graphview specific
+ fromTime = toTime - hoursToFetch * 60 * 60 * 1000L;
+ endTime = toTime + predHours * 60 * 60 * 1000L;
+ } else {
+ hoursToFetch = rangeToDisplay;
+ toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding - Graphview specific
+ fromTime = toTime - hoursToFetch * 60 * 60 * 1000L;
+ endTime = toTime;
+ }
+
+ LineGraphSeries basalsLineSeries = null;
+ LineGraphSeries absoluteBasalsLineSeries = null;
+ LineGraphSeries baseBasalsSeries = null;
+ LineGraphSeries tempBasalsSeries = null;
+ AreaGraphSeries areaSeries;
+ LineGraphSeries seriesNow, seriesNow2;
+
+ // **** TEMP BASALS graph ****
+ Double maxBasalValueFound = 0d;
+
+ long now = System.currentTimeMillis();
+ if (pump.getPumpDescription().isTempBasalCapable && showBasalsView.isChecked()) {
+ List baseBasalArray = new ArrayList<>();
+ List tempBasalArray = new ArrayList<>();
+ List basalLineArray = new ArrayList<>();
+ List absoluteBasalLineArray = new ArrayList<>();
+ double lastLineBasal = 0;
+ double lastAbsoluteLineBasal = 0;
+ double lastBaseBasal = 0;
+ double lastTempBasal = 0;
+ for (long time = fromTime; time < now; time += 60 * 1000L) {
+ BasalData basalData = IobCobCalculatorPlugin.getBasalData(time);
+ double baseBasalValue = basalData.basal;
+ double absoluteLineValue = baseBasalValue;
+ double tempBasalValue = 0;
+ double basal = 0d;
+ if (basalData.isTempBasalRunning) {
+ absoluteLineValue = tempBasalValue = basalData.tempBasalAbsolute;
+ if (tempBasalValue != lastTempBasal) {
+ tempBasalArray.add(new DataPoint(time, lastTempBasal));
+ tempBasalArray.add(new DataPoint(time, basal = tempBasalValue));
+ }
+ if (lastBaseBasal != 0d) {
+ baseBasalArray.add(new DataPoint(time, lastBaseBasal));
+ baseBasalArray.add(new DataPoint(time, 0d));
+ lastBaseBasal = 0d;
+ }
+ } else {
+ if (baseBasalValue != lastBaseBasal) {
+ baseBasalArray.add(new DataPoint(time, lastBaseBasal));
+ baseBasalArray.add(new DataPoint(time, basal = baseBasalValue));
+ lastBaseBasal = baseBasalValue;
+ }
+ if (lastTempBasal != 0) {
+ tempBasalArray.add(new DataPoint(time, lastTempBasal));
+ tempBasalArray.add(new DataPoint(time, 0d));
+ }
+ }
+
+ if (baseBasalValue != lastLineBasal) {
+ basalLineArray.add(new DataPoint(time, lastLineBasal));
+ basalLineArray.add(new DataPoint(time, baseBasalValue));
+ }
+ if (absoluteLineValue != lastAbsoluteLineBasal) {
+ absoluteBasalLineArray.add(new DataPoint(time, lastAbsoluteLineBasal));
+ absoluteBasalLineArray.add(new DataPoint(time, basal));
+ }
+
+ lastAbsoluteLineBasal = absoluteLineValue;
+ lastLineBasal = baseBasalValue;
+ lastTempBasal = tempBasalValue;
+ maxBasalValueFound = Math.max(maxBasalValueFound, basal);
+ }
+ basalLineArray.add(new DataPoint(now, lastLineBasal));
+ baseBasalArray.add(new DataPoint(now, lastBaseBasal));
+ tempBasalArray.add(new DataPoint(now, lastTempBasal));
+ absoluteBasalLineArray.add(new DataPoint(now, lastAbsoluteLineBasal));
+
+ DataPoint[] baseBasal = new DataPoint[baseBasalArray.size()];
+ baseBasal = baseBasalArray.toArray(baseBasal);
+ baseBasalsSeries = new LineGraphSeries<>(baseBasal);
+ baseBasalsSeries.setDrawBackground(true);
+ baseBasalsSeries.setBackgroundColor(MainApp.sResources.getColor(R.color.basebasal));
+ baseBasalsSeries.setThickness(0);
+
+ DataPoint[] tempBasal = new DataPoint[tempBasalArray.size()];
+ tempBasal = tempBasalArray.toArray(tempBasal);
+ tempBasalsSeries = new LineGraphSeries<>(tempBasal);
+ tempBasalsSeries.setDrawBackground(true);
+ tempBasalsSeries.setBackgroundColor(MainApp.sResources.getColor(R.color.tempbasal));
+ tempBasalsSeries.setThickness(0);
+
+ DataPoint[] basalLine = new DataPoint[basalLineArray.size()];
+ basalLine = basalLineArray.toArray(basalLine);
+ basalsLineSeries = new LineGraphSeries<>(basalLine);
+ Paint paint = new Paint();
+ paint.setStyle(Paint.Style.STROKE);
+ paint.setStrokeWidth(2);
+ paint.setPathEffect(new DashPathEffect(new float[]{2, 4}, 0));
+ paint.setColor(MainApp.sResources.getColor(R.color.basal));
+ basalsLineSeries.setCustomPaint(paint);
+
+ DataPoint[] absoluteBasalLine = new DataPoint[absoluteBasalLineArray.size()];
+ absoluteBasalLine = absoluteBasalLineArray.toArray(absoluteBasalLine);
+ absoluteBasalsLineSeries = new LineGraphSeries<>(absoluteBasalLine);
+ Paint absolutePaint = new Paint();
+ absolutePaint.setStyle(Paint.Style.STROKE);
+ absolutePaint.setStrokeWidth(4);
+ absolutePaint.setColor(MainApp.sResources.getColor(R.color.basal));
+ absoluteBasalsLineSeries.setCustomPaint(absolutePaint);
+ }
+
+ //log.debug("updateGUI checkpoint 2");
+
+ // **** IOB COB DEV graph ****
+ class DeviationDataPoint extends DataPoint {
+ public int color;
+
+ public DeviationDataPoint(double x, double y, int color) {
+ super(x, y);
+ this.color = color;
+ }
+ }
+ FixedLineGraphSeries iobSeries;
+ FixedLineGraphSeries cobSeries;
+ BarGraphSeries devSeries;
+ LineGraphSeries ratioSeries;
+ Double maxIobValueFound = 0d;
+ Double maxCobValueFound = 0d;
+ Double maxDevValueFound = 0d;
+ Double maxRatioValueFound = 0d;
+
+ if (showIobView.isChecked() || showCobView.isChecked() || showDeviationsView.isChecked() || showRatiosView.isChecked()) {
+ //Date start = new Date();
+ List iobArray = new ArrayList<>();
+ List cobArray = new ArrayList<>();
+ List devArray = new ArrayList<>();
+ List ratioArray = new ArrayList<>();
+ double lastIob = 0;
+ int lastCob = 0;
+ for (long time = fromTime; time <= now; time += 5 * 60 * 1000L) {
+ if (showIobView.isChecked()) {
+ double iob = IobCobCalculatorPlugin.calulateFromTreatmentsAndTemps(time).iob;
+ if (Math.abs(lastIob - iob) > 0.02) {
+ if (Math.abs(lastIob - iob) > 0.2)
+ iobArray.add(new DataPoint(time, lastIob));
+ iobArray.add(new DataPoint(time, iob));
+ maxIobValueFound = Math.max(maxIobValueFound, Math.abs(iob));
+ lastIob = iob;
+ }
+ }
+ if (showCobView.isChecked() || showDeviationsView.isChecked() || showRatiosView.isChecked()) {
+ AutosensData autosensData = IobCobCalculatorPlugin.getAutosensData(time);
+ if (autosensData != null && showCobView.isChecked()) {
+ int cob = (int) autosensData.cob;
+ if (cob != lastCob) {
+ if (autosensData.carbsFromBolus > 0)
+ cobArray.add(new DataPoint(time, lastCob));
+ cobArray.add(new DataPoint(time, cob));
+ maxCobValueFound = Math.max(maxCobValueFound, cob);
+ lastCob = cob;
+ }
+ }
+ if (autosensData != null && showDeviationsView.isChecked()) {
+ int color = Color.BLACK; // "="
+ if (autosensData.pastSensitivity.equals("C")) color = Color.GRAY;
+ if (autosensData.pastSensitivity.equals("+")) color = Color.GREEN;
+ if (autosensData.pastSensitivity.equals("-")) color = Color.RED;
+ devArray.add(new DeviationDataPoint(time, autosensData.deviation, color));
+ maxDevValueFound = Math.max(maxDevValueFound, Math.abs(autosensData.deviation));
+ }
+ if (autosensData != null && showRatiosView.isChecked()) {
+ ratioArray.add(new DataPoint(time, autosensData.autosensRatio));
+ maxRatioValueFound = Math.max(maxRatioValueFound, Math.abs(autosensData.autosensRatio));
+ }
+ }
+ }
+ //Profiler.log(log, "IOB processed", start);
+ DataPoint[] iobData = new DataPoint[iobArray.size()];
+ iobData = iobArray.toArray(iobData);
+ iobSeries = new FixedLineGraphSeries<>(iobData);
+ iobSeries.setDrawBackground(true);
+ iobSeries.setBackgroundColor(0x80FFFFFF & MainApp.sResources.getColor(R.color.iob)); //50%
+ iobSeries.setColor(MainApp.sResources.getColor(R.color.iob));
+ iobSeries.setThickness(3);
+
+
+ Double maxByScale = null;
+ int graphsToShow = 0;
+ if (showIobView.isChecked()) {
+ if (maxByScale == null) maxByScale = maxIobValueFound;
+ graphsToShow++;
+ }
+ if (showCobView.isChecked()) {
+ if (maxByScale == null) maxByScale = maxCobValueFound;
+ graphsToShow++;
+ }
+ if (showDeviationsView.isChecked()) {
+ if (maxByScale == null) maxByScale = maxDevValueFound;
+ graphsToShow++;
+ }
+ if (showRatiosView.isChecked()) {
+ if (maxByScale == null) maxByScale = maxRatioValueFound;
+ graphsToShow++;
+ }
+
+ if (graphsToShow > 1) {
+ if (!maxByScale.equals(maxCobValueFound)) {
+ List cobArrayRescaled = new ArrayList<>();
+ for (int ci = 0; ci < cobArray.size(); ci++) {
+ cobArrayRescaled.add(new DataPoint(cobArray.get(ci).getX(), cobArray.get(ci).getY() * maxByScale / maxCobValueFound / 2));
+ }
+ cobArray = cobArrayRescaled;
+ }
+ if (!maxByScale.equals(maxDevValueFound)) {
+ List devArrayRescaled = new ArrayList<>();
+ for (int ci = 0; ci < devArray.size(); ci++) {
+ devArrayRescaled.add(new DeviationDataPoint(devArray.get(ci).getX(), devArray.get(ci).getY() * maxByScale / maxDevValueFound, devArray.get(ci).color));
+ }
+ devArray = devArrayRescaled;
+ }
+ if (!maxByScale.equals(maxRatioValueFound)) {
+ List ratioArrayRescaled = new ArrayList<>();
+ for (int ci = 0; ci < ratioArray.size(); ci++) {
+ ratioArrayRescaled.add(new DataPoint(ratioArray.get(ci).getX(), (ratioArray.get(ci).getY() - 1) * maxByScale / maxRatioValueFound));
+ }
+ ratioArray = ratioArrayRescaled;
+ }
+ }
+
+ // COB
+ DataPoint[] cobData = new DataPoint[cobArray.size()];
+ cobData = cobArray.toArray(cobData);
+ cobSeries = new FixedLineGraphSeries<>(cobData);
+ cobSeries.setDrawBackground(true);
+ cobSeries.setBackgroundColor(0xB0FFFFFF & MainApp.sResources.getColor(R.color.cob)); //50%
+ cobSeries.setColor(MainApp.sResources.getColor(R.color.cob));
+ cobSeries.setThickness(3);
+
+ // DEVIATIONS
+ DeviationDataPoint[] devData = new DeviationDataPoint[devArray.size()];
+ devData = devArray.toArray(devData);
+ devSeries = new BarGraphSeries<>(devData);
+ devSeries.setValueDependentColor(new ValueDependentColor() {
+ @Override
+ public int get(DeviationDataPoint data) {
+ return data.color;
+ }
+ });
+
+ // RATIOS
+ DataPoint[] ratioData = new DataPoint[ratioArray.size()];
+ ratioData = ratioArray.toArray(ratioData);
+ ratioSeries = new LineGraphSeries<>(ratioData);
+ ratioSeries.setColor(MainApp.sResources.getColor(R.color.ratio));
+ ratioSeries.setThickness(3);
+
+ iobGraph.getSeries().clear();
+
+ if (showIobView.isChecked() && iobData.length > 0) {
+ addSeriesWithoutInvalidate(iobSeries, iobGraph);
+ }
+ if (showCobView.isChecked() && cobData.length > 0) {
+ addSeriesWithoutInvalidate(cobSeries, iobGraph);
+ }
+ if (showDeviationsView.isChecked() && devData.length > 0) {
+ addSeriesWithoutInvalidate(devSeries, iobGraph);
+ }
+ if (showRatiosView.isChecked() && ratioData.length > 0) {
+ addSeriesWithoutInvalidate(ratioSeries, iobGraph);
+ }
+ iobGraph.setVisibility(View.VISIBLE);
+ } else {
+ iobGraph.setVisibility(View.GONE);
+ }
+ //log.debug("updateGUI checkpoint 3");
+
+ // remove old data from graph
+ bgGraph.getSecondScale().getSeries().clear();
+ bgGraph.getSeries().clear();
+ //log.debug("updateGUI checkpoint 4");
+
+ // **** Area ****
+ DoubleDataPoint[] areaDataPoints = new DoubleDataPoint[]{
+ new DoubleDataPoint(fromTime, lowLine, highLine),
+ new DoubleDataPoint(endTime, lowLine, highLine)
+ };
+ areaSeries = new AreaGraphSeries<>(areaDataPoints);
+ addSeriesWithoutInvalidate(areaSeries, bgGraph);
+ areaSeries.setColor(0);
+ areaSeries.setDrawBackground(true);
+ areaSeries.setBackgroundColor(MainApp.sResources.getColor(R.color.inrangebackground));
+
+ // set manual x bounds to have nice steps
+ bgGraph.getViewport().setMaxX(endTime);
+ bgGraph.getViewport().setMinX(fromTime);
+ bgGraph.getViewport().setXAxisBoundsManual(true);
+ bgGraph.getGridLabelRenderer().setLabelFormatter(new TimeAsXAxisLabelFormatter(getActivity(), "HH"));
+ bgGraph.getGridLabelRenderer().setNumHorizontalLabels(7); // only 7 because of the space
+ iobGraph.getViewport().setMaxX(endTime);
+ iobGraph.getViewport().setMinX(fromTime);
+ iobGraph.getViewport().setXAxisBoundsManual(true);
+ iobGraph.getGridLabelRenderer().setLabelFormatter(new TimeAsXAxisLabelFormatter(getActivity(), "HH"));
+ iobGraph.getGridLabelRenderer().setNumHorizontalLabels(7); // only 7 because of the space
+
+ //log.debug("updateGUI checkpoint 5");
+ // **** BG graph ****
+ List bgReadingsArray = MainApp.getDbHelper().getBgreadingsDataFromTime(fromTime, true);
+ List bgListArray = new ArrayList<>();
+
+ if (bgReadingsArray.size() == 0) {
+ return;
+ }
+
+ Iterator it = bgReadingsArray.iterator();
+ Double maxBgValue = 0d;
+ while (it.hasNext()) {
+ BgReading bg = it.next();
+ if (bg.value > maxBgValue) maxBgValue = bg.value;
+ bgListArray.add(bg);
+ }
+ if (showPrediction) {
+ DetermineBasalResultAMA amaResult = (DetermineBasalResultAMA) finalLastRun.constraintsProcessed;
+ List predArray = amaResult.getPredictions();
+ bgListArray.addAll(predArray);
+ }
+
+ maxBgValue = Profile.fromMgdlToUnits(maxBgValue, units);
+ maxBgValue = units.equals(Constants.MGDL) ? Round.roundTo(maxBgValue, 40d) + 80 : Round.roundTo(maxBgValue, 2d) + 4;
+ if (highLine > maxBgValue) maxBgValue = highLine;
+ Integer numOfVertLines = units.equals(Constants.MGDL) ? (int) (maxBgValue / 40 + 1) : (int) (maxBgValue / 2 + 1);
+
+ DataPointWithLabelInterface[] bg = new DataPointWithLabelInterface[bgListArray.size()];
+ bg = bgListArray.toArray(bg);
+
+ if (bg.length > 0) {
+ addSeriesWithoutInvalidate(new PointsWithLabelGraphSeries<>(bg), bgGraph);
+ }
+
+ //log.debug("updateGUI checkpoint 6");
+ // Treatments
+ List filteredTreatments = new ArrayList<>();
+
+ List treatments = MainApp.getConfigBuilder().getTreatmentsFromHistory();
+
+ for (int tx = 0; tx < treatments.size(); tx++) {
+ DataPointWithLabelInterface t = treatments.get(tx);
+ if (t.getX() < fromTime || t.getX() > endTime) continue;
+ t.setY(getNearestBg((long) t.getX(), bgReadingsArray));
+ filteredTreatments.add(t);
+ }
+
+ //log.debug("updateGUI checkpoint 7");
+ // ProfileSwitch
+ List profileSwitches = MainApp.getConfigBuilder().getProfileSwitchesFromHistory().getList();
+
+ for (int tx = 0; tx < profileSwitches.size(); tx++) {
+ DataPointWithLabelInterface t = profileSwitches.get(tx);
+ if (t.getX() < fromTime || t.getX() > endTime) continue;
+ filteredTreatments.add(t);
+ }
+
+ //log.debug("updateGUI checkpoint 8");
+ // Extended bolus
+ if (!pump.isFakingTempsByExtendedBoluses()) {
+ List extendedBoluses = MainApp.getConfigBuilder().getExtendedBolusesFromHistory().getList();
+
+ for (int tx = 0; tx < extendedBoluses.size(); tx++) {
+ DataPointWithLabelInterface t = extendedBoluses.get(tx);
+ if (t.getX() + t.getDuration() < fromTime || t.getX() > endTime) continue;
+ if (t.getDuration() == 0) continue;
+ t.setY(getNearestBg((long) t.getX(), bgReadingsArray));
+ filteredTreatments.add(t);
+ }
+ }
+
+ //log.debug("updateGUI checkpoint 9");
+ // Careportal
+ List careportalEvents = MainApp.getDbHelper().getCareportalEventsFromTime(fromTime, true);
+
+ for (int tx = 0; tx < careportalEvents.size(); tx++) {
+ DataPointWithLabelInterface t = careportalEvents.get(tx);
+ if (t.getX() + t.getDuration() < fromTime || t.getX() > endTime) continue;
+ t.setY(getNearestBg((long) t.getX(), bgReadingsArray));
+ filteredTreatments.add(t);
+ }
+
+ DataPointWithLabelInterface[] treatmentsArray = new DataPointWithLabelInterface[filteredTreatments.size()];
+ treatmentsArray = filteredTreatments.toArray(treatmentsArray);
+ if (treatmentsArray.length > 0) {
+ addSeriesWithoutInvalidate(new PointsWithLabelGraphSeries<>(treatmentsArray), bgGraph);
+ }
+ //log.debug("updateGUI checkpoint 10");
+
+ // set manual y bounds to have nice steps
+ bgGraph.getViewport().setMaxY(maxBgValue);
+ bgGraph.getViewport().setMinY(0);
+ bgGraph.getViewport().setYAxisBoundsManual(true);
+ bgGraph.getGridLabelRenderer().setNumVerticalLabels(numOfVertLines);
+
+ // set second scale
+ if (pump.getPumpDescription().isTempBasalCapable && showBasalsView.isChecked()) {
+ bgGraph.getSecondScale().setMinY(0);
+ bgGraph.getSecondScale().setMaxY(maxBgValue / lowLine * maxBasalValueFound * 1.2d);
+ bgGraph.getSecondScale().addSeries(baseBasalsSeries);
+ bgGraph.getSecondScale().addSeries(tempBasalsSeries);
+ bgGraph.getSecondScale().addSeries(basalsLineSeries);
+ bgGraph.getSecondScale().addSeries(absoluteBasalsLineSeries);
+ }
+ bgGraph.getSecondScale().setLabelFormatter(new LabelFormatter() {
+ @Override
+ public String formatLabel(double value, boolean isValueX) {
+ return "";
+ }
+
+ @Override
+ public void setViewport(Viewport viewport) {
+
+ }
+ });
+
+ //log.debug("updateGUI checkpoint 11");
+ // **** NOW line ****
+ DataPoint[] nowPoints = new DataPoint[]{
+ new DataPoint(now, 0),
+ new DataPoint(now, maxBgValue)
+ };
+ addSeriesWithoutInvalidate(seriesNow = new LineGraphSeries<>(nowPoints), bgGraph);
+ seriesNow.setDrawDataPoints(false);
+ DataPoint[] nowPoints2 = new DataPoint[]{
+ new DataPoint(now, 0),
+ new DataPoint(now, maxIobValueFound)
+ };
+ addSeriesWithoutInvalidate(seriesNow2 = new LineGraphSeries<>(nowPoints2), iobGraph);
+ seriesNow2.setDrawDataPoints(false);
+ //seriesNow.setThickness(1);
+ // custom paint to make a dotted line
+ Paint paint = new Paint();
+ paint.setStyle(Paint.Style.STROKE);
+ paint.setStrokeWidth(2);
+ paint.setPathEffect(new DashPathEffect(new float[]{10, 20}, 0));
+ paint.setColor(Color.WHITE);
+ seriesNow.setCustomPaint(paint);
+ seriesNow2.setCustomPaint(paint);
+ bgGraph.onDataChanged(false, false);
+ iobGraph.onDataChanged(false, false);
+
+ Profiler.log(log, from, updateGUIStart);
+ }
+
+ public double getNearestBg(long date, List bgReadingsArray) {
+ double bg = 0;
+ String units = MainApp.getConfigBuilder().getProfileUnits();
+ for (int r = bgReadingsArray.size() - 1; r >= 0; r--) {
+ BgReading reading = bgReadingsArray.get(r);
+ if (reading.date > date) continue;
+ bg = Profile.fromMgdlToUnits(reading.value, units);
+ break;
+ }
+ return bg;
+ }
+
+ void addSeriesWithoutInvalidate(Series s, GraphView graph) {
+ s.onGraphViewAttached(graph);
+ graph.getSeries().add(s);
+ }
+
+
+ //Notifications
+ static class RecyclerViewAdapter extends RecyclerView.Adapter {
+
+ List notificationsList;
+
+ RecyclerViewAdapter(List notificationsList) {
+ this.notificationsList = notificationsList;
+ }
+
+ @Override
+ public NotificationsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
+ View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.overview_notification_item, viewGroup, false);
+ return new NotificationsViewHolder(v);
+ }
+
+ @Override
+ public void onBindViewHolder(NotificationsViewHolder holder, int position) {
+ Notification notification = notificationsList.get(position);
+ holder.dismiss.setTag(notification);
+ holder.text.setText(notification.text);
+ holder.time.setText(DateUtil.timeString(notification.date));
+ if (notification.level == Notification.URGENT)
+ holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationUrgent));
+ else if (notification.level == Notification.NORMAL)
+ holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationNormal));
+ else if (notification.level == Notification.LOW)
+ holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationLow));
+ else if (notification.level == Notification.INFO)
+ holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationInfo));
+ else if (notification.level == Notification.ANNOUNCEMENT)
+ holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationAnnouncement));
+ }
+
+ @Override
+ public int getItemCount() {
+ return notificationsList.size();
+ }
+
+ @Override
+ public void onAttachedToRecyclerView(RecyclerView recyclerView) {
+ super.onAttachedToRecyclerView(recyclerView);
+ }
+
+ static class NotificationsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
+ CardView cv;
+ TextView time;
+ TextView text;
+ Button dismiss;
+
+ NotificationsViewHolder(View itemView) {
+ super(itemView);
+ cv = (CardView) itemView.findViewById(R.id.notification_cardview);
+ time = (TextView) itemView.findViewById(R.id.notification_time);
+ text = (TextView) itemView.findViewById(R.id.notification_text);
+ dismiss = (Button) itemView.findViewById(R.id.notification_dismiss);
+ dismiss.setOnClickListener(this);
+ }
+
+ @Override
+ public void onClick(View v) {
+ Notification notification = (Notification) v.getTag();
+ switch (v.getId()) {
+ case R.id.notification_dismiss:
+ MainApp.bus().post(new EventDismissNotification(notification.id));
+ if (notification.nsAlarm != null) {
+ BroadcastAckAlarm.handleClearAlarm(notification.nsAlarm, MainApp.instance().getApplicationContext(), 60 * 60 * 1000L);
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ void updateNotifications() {
+ Activity activity = getActivity();
+ if (activity != null)
+ activity.runOnUiThread(new Runnable() {
+ @Override
+ public void run() {
+ NotificationStore nstore = getPlugin().notificationStore;
+ nstore.removeExpired();
+ if (nstore.store.size() > 0) {
+ RecyclerViewAdapter adapter = new RecyclerViewAdapter(nstore.store);
+ notificationsView.setAdapter(adapter);
+ notificationsView.setVisibility(View.VISIBLE);
+ } else {
+ notificationsView.setVisibility(View.GONE);
+ }
+ }
+ });
+ }
+
+
+}
From a8b17a1f22f15dd0a85b9642cc8d8958ee0837d0 Mon Sep 17 00:00:00 2001
From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com>
Date: Fri, 4 Aug 2017 14:48:44 +0300
Subject: [PATCH 05/35] adding staleDataThreshold as snooze time
---
.../plugins/Overview/Notification.java | 28 +++++++++++++++----
1 file changed, 22 insertions(+), 6 deletions(-)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java
index 31783523c4..b0d906e7f0 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java
@@ -9,11 +9,16 @@ import info.nightscout.androidaps.plugins.NSClientInternal.data.NSAlarm;
import info.nightscout.androidaps.plugins.NSClientInternal.data.NSSettingsStatus;
import info.nightscout.utils.SP;
+// Added by Rumen for debugging
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Created by mike on 03.12.2016.
*/
public class Notification {
+ private static Logger log = LoggerFactory.getLogger(Notification.class);
+
public static final int URGENT = 0;
public static final int NORMAL = 1;
public static final int LOW = 2;
@@ -55,6 +60,7 @@ public class Notification {
}
public Notification(int id, Date date, String text, int level, Date validTo) {
+ log.debug("Initialized Notification.class 1");
this.id = id;
this.date = date;
this.text = text;
@@ -63,6 +69,7 @@ public class Notification {
}
public Notification(int id, String text, int level, int validMinutes) {
+ log.debug("Initialized Notification.class 2");
this.id = id;
this.date = new Date();
this.text = text;
@@ -71,6 +78,7 @@ public class Notification {
}
public Notification(int id, String text, int level) {
+ log.debug("Initialized Notification.class 3");
this.id = id;
this.date = new Date();
this.text = text;
@@ -93,7 +101,7 @@ public class Notification {
this.id = NSALARM;
this.level = NORMAL;
this.text = nsAlarm.getTile();
- if (isAlarmForLow() && SP.getBoolean(R.string.key_nsalarm_low, false) || isAlarmForHigh() && SP.getBoolean(R.string.key_nsalarm_high, false))
+ if (isAlarmForLow() && SP.getBoolean(R.string.key_nsalarm_low, false) || isAlarmForHigh() && SP.getBoolean(R.string.key_nsalarm_high, false) || isAlarmForStaleData() && SP.getBoolean(R.string.key_nsalarm_staledata,false))
this.soundId = R.raw.alarm;
break;
case 2:
@@ -112,7 +120,9 @@ public class Notification {
if (level == ANNOUNCEMENT)
return true;
if (level == NORMAL && isAlarmForLow() && SP.getBoolean(R.string.key_nsalarm_low, false) || isAlarmForHigh() && SP.getBoolean(R.string.key_nsalarm_high, false) || isAlarmForStaleData() && SP.getBoolean(R.string.key_nsalarm_staledata, false))
+ {
return true;
+ }
if (level == URGENT && isAlarmForLow() && SP.getBoolean(R.string.key_nsalarm_urgent_low, false) || isAlarmForHigh() && SP.getBoolean(R.string.key_nsalarm_urgent_high, false) || isAlarmForStaleData() && SP.getBoolean(R.string.key_nsalarm_urgent_staledata, false))
return true;
return false;
@@ -142,16 +152,22 @@ public class Notification {
return false;
}
- boolean isAlarmForStaleData(){
+ static boolean isAlarmForStaleData(){
+ if(SP.getLong("snoozedTo", 0L) != 0L){
+ if(System.currentTimeMillis() < SP.getLong("snoozedTo", 0L)) {
+ log.debug("Alarm is snoozed for next "+(SP.getLong("snoozedTo", 0L)-System.currentTimeMillis())/1000+" seconds");
+ return false;
+ }
+ }
BgReading bgReading = MainApp.getDbHelper().lastBg();
if (bgReading == null)
return false;
long bgReadingAgo = System.currentTimeMillis() - bgReading.date;
int bgReadingAgoMin = (int) (bgReadingAgo / (1000 * 60));
- //Integer staleDataThreshold = NSSettingsStatus.getInstance().getIntegerOrNull("alarmTimeagoWarnMins");
- //if (staleDataThreshold == null)
- // return false;
- if(bgReadingAgoMin > SP.getInt(R.string.key_nsalarm_staledatavalue,16)){
+ // Added for testing
+ //bgReadingAgoMin = 20;
+ log.debug("bgReadingAgoMin value is:"+bgReadingAgoMin);
+ if(bgReadingAgoMin > SP.getInt(R.string.key_nsalarm_staledatavalue,15) && SP.getBoolean(R.string.key_nsalarm_staledata, false)){
return true;
}
return false;
From 82541a50e4a77b7f3cccfb0369367aff3a2fbc8e Mon Sep 17 00:00:00 2001
From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com>
Date: Fri, 4 Aug 2017 14:49:46 +0300
Subject: [PATCH 06/35] Added functions for snoozing and unsnoozing
---
.../plugins/Overview/NotificationStore.java | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/NotificationStore.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/NotificationStore.java
index 45393f3659..e869d1191b 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/NotificationStore.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/NotificationStore.java
@@ -15,7 +15,8 @@ import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.Services.AlarmSoundService;
import info.nightscout.androidaps.plugins.Wear.WearPlugin;
-
+//Added by Rumen for snooze time
+import info.nightscout.utils.SP;
/**
* Created by mike on 03.12.2016.
@@ -24,7 +25,7 @@ import info.nightscout.androidaps.plugins.Wear.WearPlugin;
public class NotificationStore {
private static Logger log = LoggerFactory.getLogger(NotificationStore.class);
public List store = new ArrayList();
-
+ public long snoozedUntil = 0L;
public NotificationStore() {
}
@@ -86,4 +87,18 @@ public class NotificationStore {
}
}
}
+
+ public void snoozeTo(long timeToSnooze){
+ log.debug("Snoozing alarm until: "+timeToSnooze);
+ SP.putLong("snoozedTo", timeToSnooze);
+ }
+
+ public void unSnooze(){
+ if(Notification.isAlarmForStaleData()){
+ Notification notification = new Notification(Notification.NSALARM, MainApp.sResources.getString(R.string.nsalarm_staledata), Notification.URGENT);
+ SP.putLong("snoozedTo", System.currentTimeMillis());
+ add(notification);
+ log.debug("Snoozed to current time and added back notification!");
+ }
+ }
}
From 837dcdb23bd417fb564d006ca88be206eca6e5b8 Mon Sep 17 00:00:00 2001
From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com>
Date: Fri, 4 Aug 2017 14:51:25 +0300
Subject: [PATCH 07/35] If alarm is staledata dismis snoozes it
---
.../plugins/Overview/OverviewFragment.java | 21 ++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
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 7e33d1ff8c..3a12c54650 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
@@ -126,7 +126,9 @@ import info.nightscout.utils.Profiler;
import info.nightscout.utils.Round;
import info.nightscout.utils.SP;
import info.nightscout.utils.ToastUtils;
-
+//Added By Rumen for staledata alarm
+import info.nightscout.androidaps.plugins.Overview.Notification;
+import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
public class OverviewFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
private static Logger log = LoggerFactory.getLogger(OverviewFragment.class);
@@ -744,6 +746,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
public void run() {
scheduleUpdateGUI("refreshLoop");
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
+ // Added by Rumen for STALE DATA ALARM
+ boolean isThereStaleData = Notification.isAlarmForStaleData();
+ log.debug("isThereIsStaleData: "+isThereStaleData);
+ if(isThereStaleData){
+ Notification notification = new Notification(Notification.NSALARM, getString(R.string.nsalarm_staledata), Notification.URGENT);
+ MainApp.bus().post(new EventNewNotification(notification));
+ }
+ // end of insert
}
};
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
@@ -1802,6 +1812,14 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
if (notification.nsAlarm != null) {
BroadcastAckAlarm.handleClearAlarm(notification.nsAlarm, MainApp.instance().getApplicationContext(), 60 * 60 * 1000L);
}
+ // Adding current time to snooze if we got staleData
+ log.debug("Notification text is: "+notification.text);
+ if(notification.text == MainApp.sResources.getString(R.string.nsalarm_staledata)){
+ NotificationStore nstore = getPlugin().notificationStore;
+ long msToSnooze = SP.getInt("nsalarm_staledatavalue",15)*60*1000L;
+ log.debug("snooze nsalarm_staledatavalue in minutes is "+SP.getInt("nsalarm_staledatavalue",15)+"\n in ms is: "+msToSnooze+" currentTimeMillis is: "+System.currentTimeMillis());
+ nstore.snoozeTo(System.currentTimeMillis()+(SP.getInt("nsalarm_staledatavalue",15)*60*1000L));
+ }
break;
}
}
@@ -1816,6 +1834,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
public void run() {
NotificationStore nstore = getPlugin().notificationStore;
nstore.removeExpired();
+ nstore.unSnooze();
if (nstore.store.size() > 0) {
RecyclerViewAdapter adapter = new RecyclerViewAdapter(nstore.store);
notificationsView.setAdapter(adapter);
From 714a292d78802af8bd8b4447a617ae4ad8e92e4a Mon Sep 17 00:00:00 2001
From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com>
Date: Fri, 4 Aug 2017 15:05:09 +0300
Subject: [PATCH 08/35] fixed wrong pasting
---
app/src/main/res/layout/overview_fragment.xml | 2304 ++++-------------
1 file changed, 462 insertions(+), 1842 deletions(-)
diff --git a/app/src/main/res/layout/overview_fragment.xml b/app/src/main/res/layout/overview_fragment.xml
index 0708ac5005..9468ce5bf2 100644
--- a/app/src/main/res/layout/overview_fragment.xml
+++ b/app/src/main/res/layout/overview_fragment.xml
@@ -1,1842 +1,462 @@
-package info.nightscout.androidaps.plugins.Overview;
-
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.app.NotificationManager;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.graphics.Color;
-import android.graphics.DashPathEffect;
-import android.graphics.Paint;
-import android.os.Bundle;
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.support.v4.app.Fragment;
-import android.support.v4.app.FragmentManager;
-import android.support.v4.content.ContextCompat;
-import android.support.v7.app.AlertDialog;
-import android.support.v7.widget.CardView;
-import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.RecyclerView;
-import android.util.DisplayMetrics;
-import android.util.TypedValue;
-import android.view.ContextMenu;
-import android.view.HapticFeedbackConstants;
-import android.view.LayoutInflater;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.CheckBox;
-import android.widget.CompoundButton;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import com.crashlytics.android.answers.Answers;
-import com.crashlytics.android.answers.CustomEvent;
-import com.jjoe64.graphview.GraphView;
-import com.jjoe64.graphview.LabelFormatter;
-import com.jjoe64.graphview.ValueDependentColor;
-import com.jjoe64.graphview.Viewport;
-import com.jjoe64.graphview.series.BarGraphSeries;
-import com.jjoe64.graphview.series.DataPoint;
-import com.jjoe64.graphview.series.LineGraphSeries;
-import com.jjoe64.graphview.series.Series;
-import com.squareup.otto.Subscribe;
-
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.text.DecimalFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.concurrent.Executors;
-import java.util.concurrent.ScheduledExecutorService;
-import java.util.concurrent.ScheduledFuture;
-import java.util.concurrent.TimeUnit;
-
-import info.nightscout.androidaps.BuildConfig;
-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.DetailedBolusInfo;
-import info.nightscout.androidaps.data.GlucoseStatus;
-import info.nightscout.androidaps.data.IobTotal;
-import info.nightscout.androidaps.data.Profile;
-import info.nightscout.androidaps.data.PumpEnactResult;
-import info.nightscout.androidaps.db.BgReading;
-import info.nightscout.androidaps.db.CareportalEvent;
-import info.nightscout.androidaps.db.DatabaseHelper;
-import info.nightscout.androidaps.db.ExtendedBolus;
-import info.nightscout.androidaps.db.ProfileSwitch;
-import info.nightscout.androidaps.db.Source;
-import info.nightscout.androidaps.db.TempTarget;
-import info.nightscout.androidaps.db.TemporaryBasal;
-import info.nightscout.androidaps.db.Treatment;
-import info.nightscout.androidaps.events.EventCareportalEventChange;
-import info.nightscout.androidaps.events.EventExtendedBolusChange;
-import info.nightscout.androidaps.events.EventInitializationChanged;
-import info.nightscout.androidaps.events.EventPreferenceChange;
-import info.nightscout.androidaps.events.EventPumpStatusChanged;
-import info.nightscout.androidaps.events.EventRefreshOverview;
-import info.nightscout.androidaps.events.EventTempBasalChange;
-import info.nightscout.androidaps.events.EventTempTargetChange;
-import info.nightscout.androidaps.events.EventTreatmentChange;
-import info.nightscout.androidaps.interfaces.PluginBase;
-import info.nightscout.androidaps.interfaces.PumpInterface;
-import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
-import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
-import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
-import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
-import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin;
-import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
-import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
-import info.nightscout.androidaps.plugins.IobCobCalculator.events.BasalData;
-import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
-import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
-import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
-import info.nightscout.androidaps.plugins.NSClientInternal.broadcasts.BroadcastAckAlarm;
-import info.nightscout.androidaps.plugins.NSClientInternal.data.NSDeviceStatus;
-import info.nightscout.androidaps.plugins.OpenAPSAMA.DetermineBasalResultAMA;
-import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
-import info.nightscout.androidaps.plugins.Overview.Dialogs.CalibrationDialog;
-import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTreatmentDialog;
-import info.nightscout.androidaps.plugins.Overview.Dialogs.WizardDialog;
-import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
-import info.nightscout.androidaps.plugins.Overview.events.EventSetWakeLock;
-import info.nightscout.androidaps.plugins.Overview.graphExtensions.AreaGraphSeries;
-import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
-import info.nightscout.androidaps.plugins.Overview.graphExtensions.DoubleDataPoint;
-import info.nightscout.androidaps.plugins.Overview.graphExtensions.FixedLineGraphSeries;
-import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
-import info.nightscout.androidaps.plugins.Overview.graphExtensions.TimeAsXAxisLabelFormatter;
-import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
-import info.nightscout.utils.BolusWizard;
-import info.nightscout.utils.DateUtil;
-import info.nightscout.utils.DecimalFormatter;
-import info.nightscout.utils.NSUpload;
-import info.nightscout.utils.OKDialog;
-import info.nightscout.utils.Profiler;
-import info.nightscout.utils.Round;
-import info.nightscout.utils.SP;
-import info.nightscout.utils.ToastUtils;
-//Added By Rumen for staledata alarm
-import info.nightscout.androidaps.plugins.Overview.Notification;
-import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
-import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
-
-public class OverviewFragment extends Fragment implements View.OnClickListener, CompoundButton.OnCheckedChangeListener {
- private static Logger log = LoggerFactory.getLogger(OverviewFragment.class);
-
- private static OverviewPlugin overviewPlugin = new OverviewPlugin();
-
- public static OverviewPlugin getPlugin() {
- return overviewPlugin;
- }
-
- TextView timeView;
- TextView bgView;
- TextView arrowView;
- TextView timeAgoView;
- TextView deltaView;
- TextView avgdeltaView;
- TextView baseBasalView;
- TextView extendedBolusView;
- TextView activeProfileView;
- TextView iobView;
- TextView cobView;
- TextView apsModeView;
- TextView tempTargetView;
- TextView pumpStatusView;
- TextView pumpDeviceStatusView;
- TextView openapsDeviceStatusView;
- TextView uploaderDeviceStatusView;
- LinearLayout loopStatusLayout;
- LinearLayout pumpStatusLayout;
- GraphView bgGraph;
- GraphView iobGraph;
-
- TextView iage;
- TextView cage;
- TextView sage;
- TextView pbage;
-
- CheckBox showPredictionView;
- CheckBox showBasalsView;
- CheckBox showIobView;
- CheckBox showCobView;
- CheckBox showDeviationsView;
- CheckBox showRatiosView;
-
- RecyclerView notificationsView;
- LinearLayoutManager llm;
-
- LinearLayout acceptTempLayout;
- Button treatmentButton;
- Button wizardButton;
- Button calibrationButton;
- Button acceptTempButton;
- Button quickWizardButton;
-
- CheckBox lockScreen;
-
- boolean smallWidth;
- boolean smallHeight;
-
- public static boolean shorttextmode = false;
-
- private int rangeToDisplay = 6; // for graph
-
- Handler sLoopHandler = new Handler();
- Runnable sRefreshLoop = null;
-
- private static Handler sHandler;
- private static HandlerThread sHandlerThread;
-
- private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
- private static ScheduledFuture> scheduledUpdate = null;
-
- public OverviewFragment() {
- super();
- if (sHandlerThread == null) {
- sHandlerThread = new HandlerThread(OverviewFragment.class.getSimpleName());
- sHandlerThread.start();
- sHandler = new Handler(sHandlerThread.getLooper());
- }
- }
-
- @Override
- public View onCreateView(LayoutInflater inflater, ViewGroup container,
- Bundle savedInstanceState) {
-
- //check screen width
- final DisplayMetrics dm = new DisplayMetrics();
- getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
- int screen_width = dm.widthPixels;
- int screen_height = dm.heightPixels;
- smallWidth = screen_width < Constants.SMALL_WIDTH;
- smallHeight = screen_height < Constants.SMALL_HEIGHT;
- boolean landscape = screen_height < screen_width;
-
- View view;
-
- if (MainApp.sResources.getBoolean(R.bool.isTablet) && BuildConfig.NSCLIENTOLNY) {
- view = inflater.inflate(R.layout.overview_fragment_nsclient_tablet, container, false);
- } else if (BuildConfig.NSCLIENTOLNY) {
- view = inflater.inflate(R.layout.overview_fragment_nsclient, container, false);
- shorttextmode = true;
- } else if (smallHeight || landscape) {
- view = inflater.inflate(R.layout.overview_fragment_smallheight, container, false);
- } else {
- view = inflater.inflate(R.layout.overview_fragment, container, false);
- }
-
- timeView = (TextView) view.findViewById(R.id.overview_time);
- bgView = (TextView) view.findViewById(R.id.overview_bg);
- arrowView = (TextView) view.findViewById(R.id.overview_arrow);
- if (smallWidth) {
- arrowView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 35);
- }
- timeAgoView = (TextView) view.findViewById(R.id.overview_timeago);
- deltaView = (TextView) view.findViewById(R.id.overview_delta);
- avgdeltaView = (TextView) view.findViewById(R.id.overview_avgdelta);
- baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal);
- extendedBolusView = (TextView) view.findViewById(R.id.overview_extendedbolus);
- activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile);
- pumpStatusView = (TextView) view.findViewById(R.id.overview_pumpstatus);
- pumpDeviceStatusView = (TextView) view.findViewById(R.id.overview_pump);
- openapsDeviceStatusView = (TextView) view.findViewById(R.id.overview_openaps);
- uploaderDeviceStatusView = (TextView) view.findViewById(R.id.overview_uploader);
- loopStatusLayout = (LinearLayout) view.findViewById(R.id.overview_looplayout);
- pumpStatusLayout = (LinearLayout) view.findViewById(R.id.overview_pumpstatuslayout);
-
- pumpStatusView.setBackgroundColor(MainApp.sResources.getColor(R.color.colorInitializingBorder));
-
- iobView = (TextView) view.findViewById(R.id.overview_iob);
- cobView = (TextView) view.findViewById(R.id.overview_cob);
- apsModeView = (TextView) view.findViewById(R.id.overview_apsmode);
- tempTargetView = (TextView) view.findViewById(R.id.overview_temptarget);
-
- iage = (TextView) view.findViewById(R.id.careportal_insulinage);
- cage = (TextView) view.findViewById(R.id.careportal_canulaage);
- sage = (TextView) view.findViewById(R.id.careportal_sensorage);
- pbage = (TextView) view.findViewById(R.id.careportal_pbage);
-
- bgGraph = (GraphView) view.findViewById(R.id.overview_bggraph);
- iobGraph = (GraphView) view.findViewById(R.id.overview_iobgraph);
-
- treatmentButton = (Button) view.findViewById(R.id.overview_treatmentbutton);
- treatmentButton.setOnClickListener(this);
- wizardButton = (Button) view.findViewById(R.id.overview_wizardbutton);
- wizardButton.setOnClickListener(this);
- acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton);
- if (acceptTempButton != null)
- acceptTempButton.setOnClickListener(this);
- quickWizardButton = (Button) view.findViewById(R.id.overview_quickwizardbutton);
- quickWizardButton.setOnClickListener(this);
- calibrationButton = (Button) view.findViewById(R.id.overview_calibrationbutton);
- if (calibrationButton != null)
- calibrationButton.setOnClickListener(this);
-
- acceptTempLayout = (LinearLayout) view.findViewById(R.id.overview_accepttemplayout);
-
- showPredictionView = (CheckBox) view.findViewById(R.id.overview_showprediction);
- showBasalsView = (CheckBox) view.findViewById(R.id.overview_showbasals);
- showIobView = (CheckBox) view.findViewById(R.id.overview_showiob);
- showCobView = (CheckBox) view.findViewById(R.id.overview_showcob);
- showDeviationsView = (CheckBox) view.findViewById(R.id.overview_showdeviations);
- showRatiosView = (CheckBox) view.findViewById(R.id.overview_showratios);
- showPredictionView.setChecked(SP.getBoolean("showprediction", false));
- showBasalsView.setChecked(SP.getBoolean("showbasals", true));
- showIobView.setChecked(SP.getBoolean("showiob", false));
- showCobView.setChecked(SP.getBoolean("showcob", false));
- showDeviationsView.setChecked(SP.getBoolean("showdeviations", false));
- showRatiosView.setChecked(SP.getBoolean("showratios", false));
- showPredictionView.setOnCheckedChangeListener(this);
- showBasalsView.setOnCheckedChangeListener(this);
- showIobView.setOnCheckedChangeListener(this);
- showCobView.setOnCheckedChangeListener(this);
- showDeviationsView.setOnCheckedChangeListener(this);
- showRatiosView.setOnCheckedChangeListener(this);
-
- notificationsView = (RecyclerView) view.findViewById(R.id.overview_notifications);
- notificationsView.setHasFixedSize(true);
- llm = new LinearLayoutManager(view.getContext());
- notificationsView.setLayoutManager(llm);
-
- bgGraph.getGridLabelRenderer().setGridColor(MainApp.sResources.getColor(R.color.graphgrid));
- bgGraph.getGridLabelRenderer().reloadStyles();
- iobGraph.getGridLabelRenderer().setGridColor(MainApp.sResources.getColor(R.color.graphgrid));
- iobGraph.getGridLabelRenderer().reloadStyles();
- iobGraph.getGridLabelRenderer().setHorizontalLabelsVisible(false);
- bgGraph.getGridLabelRenderer().setLabelVerticalWidth(50);
- iobGraph.getGridLabelRenderer().setLabelVerticalWidth(50);
- iobGraph.getGridLabelRenderer().setNumVerticalLabels(5);
-
- rangeToDisplay = SP.getInt(R.string.key_rangetodisplay, 6);
-
- bgGraph.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View v) {
- rangeToDisplay += 6;
- rangeToDisplay = rangeToDisplay > 24 ? 6 : rangeToDisplay;
- SP.putInt(R.string.key_rangetodisplay, rangeToDisplay);
- updateGUI("rangeChange");
- return false;
- }
- });
-
- lockScreen = (CheckBox) view.findViewById(R.id.overview_lockscreen);
- if (lockScreen != null) {
- lockScreen.setChecked(SP.getBoolean("lockscreen", false));
- lockScreen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- SP.putBoolean("lockscreen", isChecked);
- MainApp.bus().post(new EventSetWakeLock(isChecked));
- }
- });
- }
-
- return view;
- }
-
-
- @Override
- public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
- super.onCreateContextMenu(menu, v, menuInfo);
- final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
- if (activeloop == null)
- return;
- menu.setHeaderTitle(MainApp.sResources.getString(R.string.loop));
- if (activeloop.isEnabled(PluginBase.LOOP)) {
- menu.add(MainApp.sResources.getString(R.string.disableloop));
- if (!activeloop.isSuspended()) {
- menu.add(MainApp.sResources.getString(R.string.suspendloopfor1h));
- menu.add(MainApp.sResources.getString(R.string.suspendloopfor2h));
- menu.add(MainApp.sResources.getString(R.string.suspendloopfor3h));
- menu.add(MainApp.sResources.getString(R.string.suspendloopfor10h));
- menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor30m));
- menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor1h));
- menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor2h));
- menu.add(MainApp.sResources.getString(R.string.disconnectpumpfor3h));
- } else {
- menu.add(MainApp.sResources.getString(R.string.resume));
- }
- }
- if (!activeloop.isEnabled(PluginBase.LOOP))
- menu.add(MainApp.sResources.getString(R.string.enableloop));
- }
-
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- switch (buttonView.getId()) {
- case R.id.overview_showprediction:
- case R.id.overview_showbasals:
- case R.id.overview_showiob:
- break;
- case R.id.overview_showcob:
- showDeviationsView.setOnCheckedChangeListener(null);
- showDeviationsView.setChecked(false);
- showDeviationsView.setOnCheckedChangeListener(this);
- break;
- case R.id.overview_showdeviations:
- showCobView.setOnCheckedChangeListener(null);
- showCobView.setChecked(false);
- showCobView.setOnCheckedChangeListener(this);
- break;
- case R.id.overview_showratios:
- break;
- }
- SP.putBoolean("showiob", showIobView.isChecked());
- SP.putBoolean("showprediction", showPredictionView.isChecked());
- SP.putBoolean("showbasals", showBasalsView.isChecked());
- SP.putBoolean("showcob", showCobView.isChecked());
- SP.putBoolean("showdeviations", showDeviationsView.isChecked());
- SP.putBoolean("showratios", showRatiosView.isChecked());
- scheduleUpdateGUI("onGraphCheckboxesCheckedChanged");
- }
-
- @Override
- public boolean onContextItemSelected(MenuItem item) {
- final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
- if (item.getTitle().equals(MainApp.sResources.getString(R.string.disableloop))) {
- activeloop.setFragmentEnabled(PluginBase.LOOP, false);
- activeloop.setFragmentVisible(PluginBase.LOOP, false);
- MainApp.getConfigBuilder().storeSettings();
- updateGUI("suspendmenu");
- sHandler.post(new Runnable() {
- @Override
- public void run() {
- PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
- }
- }
- });
- NSUpload.uploadOpenAPSOffline(60); // upload 60 min, we don;t know real duration
- return true;
- } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.enableloop))) {
- activeloop.setFragmentEnabled(PluginBase.LOOP, true);
- activeloop.setFragmentVisible(PluginBase.LOOP, true);
- MainApp.getConfigBuilder().storeSettings();
- updateGUI("suspendmenu");
- NSUpload.uploadOpenAPSOffline(0);
- return true;
- } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.resume))) {
- activeloop.suspendTo(0L);
- updateGUI("suspendmenu");
- sHandler.post(new Runnable() {
- @Override
- public void run() {
- PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
- }
- }
- });
- NSUpload.uploadOpenAPSOffline(0);
- return true;
- } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor1h))) {
- activeloop.suspendTo(System.currentTimeMillis() + 60L * 60 * 1000);
- updateGUI("suspendmenu");
- sHandler.post(new Runnable() {
- @Override
- public void run() {
- PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
- }
- }
- });
- NSUpload.uploadOpenAPSOffline(60);
- return true;
- } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor2h))) {
- activeloop.suspendTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
- updateGUI("suspendmenu");
- sHandler.post(new Runnable() {
- @Override
- public void run() {
- PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
- }
- }
- });
- NSUpload.uploadOpenAPSOffline(120);
- return true;
- } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor3h))) {
- activeloop.suspendTo(System.currentTimeMillis() + 3 * 60L * 60 * 1000);
- updateGUI("suspendmenu");
- sHandler.post(new Runnable() {
- @Override
- public void run() {
- PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
- }
- }
- });
- NSUpload.uploadOpenAPSOffline(180);
- return true;
- } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor10h))) {
- activeloop.suspendTo(System.currentTimeMillis() + 10 * 60L * 60 * 1000);
- updateGUI("suspendmenu");
- sHandler.post(new Runnable() {
- @Override
- public void run() {
- PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
- }
- }
- });
- NSUpload.uploadOpenAPSOffline(600);
- return true;
- } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor30m))) {
- activeloop.suspendTo(System.currentTimeMillis() + 30L * 60 * 1000);
- updateGUI("suspendmenu");
- sHandler.post(new Runnable() {
- @Override
- public void run() {
- MainApp.getConfigBuilder().cancelTempBasal(true);
- PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 30);
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
- }
- }
- });
- NSUpload.uploadOpenAPSOffline(30);
- return true;
- } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor1h))) {
- activeloop.suspendTo(System.currentTimeMillis() + 1 * 60L * 60 * 1000);
- updateGUI("suspendmenu");
- sHandler.post(new Runnable() {
- @Override
- public void run() {
- MainApp.getConfigBuilder().cancelTempBasal(true);
- PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 60);
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
- }
- }
- });
- NSUpload.uploadOpenAPSOffline(60);
- return true;
- } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor2h))) {
- activeloop.suspendTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
- updateGUI("suspendmenu");
- sHandler.post(new Runnable() {
- @Override
- public void run() {
- MainApp.getConfigBuilder().cancelTempBasal(true);
- PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 2 * 60);
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
- }
- }
- });
- NSUpload.uploadOpenAPSOffline(120);
- return true;
- } else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor3h))) {
- activeloop.suspendTo(System.currentTimeMillis() + 3 * 60L * 60 * 1000);
- updateGUI("suspendmenu");
- sHandler.post(new Runnable() {
- @Override
- public void run() {
- MainApp.getConfigBuilder().cancelTempBasal(true);
- PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 3 * 60);
- if (!result.success) {
- ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
- }
- }
- });
- NSUpload.uploadOpenAPSOffline(180);
- return true;
- }
-
- return super.onContextItemSelected(item);
- }
-
- @Override
- public void onClick(View v) {
- FragmentManager manager = getFragmentManager();
- switch (v.getId()) {
- case R.id.overview_accepttempbutton:
- onClickAcceptTemp();
- break;
- case R.id.overview_quickwizardbutton:
- onClickQuickwizard();
- break;
- case R.id.overview_wizardbutton:
- WizardDialog wizardDialog = new WizardDialog();
- wizardDialog.show(manager, "WizardDialog");
- break;
- case R.id.overview_calibrationbutton:
- CalibrationDialog calibrationDialog = new CalibrationDialog();
- calibrationDialog.show(manager, "CalibrationDialog");
- break;
- case R.id.overview_treatmentbutton:
- NewTreatmentDialog treatmentDialogFragment = new NewTreatmentDialog();
- treatmentDialogFragment.show(manager, "TreatmentDialog");
- break;
- case R.id.overview_pumpstatus:
- if (MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().isInitialized())
- sHandler.post(new Runnable() {
- @Override
- public void run() {
- MainApp.getConfigBuilder().refreshDataFromPump("RefreshClicked");
- }
- });
- break;
- }
-
- }
-
- private void onClickAcceptTemp() {
- if (ConfigBuilderPlugin.getActiveLoop() != null) {
- ConfigBuilderPlugin.getActiveLoop().invoke("Accept temp button", false);
- final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
- if (finalLastRun != null && finalLastRun.lastAPSRun != null && finalLastRun.constraintsProcessed.changeRequested) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
- builder.setTitle(getContext().getString(R.string.confirmation));
- builder.setMessage(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
- builder.setPositiveButton(getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- sHandler.post(new Runnable() {
- @Override
- public void run() {
- hideTempRecommendation();
- clearNotification();
- PumpEnactResult applyResult = MainApp.getConfigBuilder().applyAPSRequest(finalLastRun.constraintsProcessed);
- if (applyResult.enacted) {
- finalLastRun.setByPump = applyResult;
- finalLastRun.lastEnact = new Date();
- finalLastRun.lastOpenModeAccept = new Date();
- NSUpload.uploadDeviceStatus();
- ObjectivesPlugin objectivesPlugin = (ObjectivesPlugin) MainApp.getSpecificPlugin(ObjectivesPlugin.class);
- if (objectivesPlugin != null) {
- ObjectivesPlugin.manualEnacts++;
- ObjectivesPlugin.saveProgress();
- }
- }
- scheduleUpdateGUI("onClickAcceptTemp");
- }
- });
- Answers.getInstance().logCustom(new CustomEvent("AcceptTemp"));
- }
- });
- builder.setNegativeButton(getContext().getString(R.string.cancel), null);
- builder.show();
- }
- }
- }
-
- void onClickQuickwizard() {
- final BgReading actualBg = DatabaseHelper.actualBg();
- final Profile profile = MainApp.getConfigBuilder().getProfile();
-
- QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
- if (quickWizardEntry != null && actualBg != null) {
- quickWizardButton.setVisibility(View.VISIBLE);
- BolusWizard wizard = new BolusWizard();
- wizard.doCalc(profile, quickWizardEntry.carbs(), 0d, actualBg.valueToUnits(profile.getUnits()), 0d, true, true, false, false);
-
- final JSONObject boluscalcJSON = new JSONObject();
- try {
- boluscalcJSON.put("eventTime", DateUtil.toISOString(new Date()));
- boluscalcJSON.put("targetBGLow", wizard.targetBGLow);
- boluscalcJSON.put("targetBGHigh", wizard.targetBGHigh);
- boluscalcJSON.put("isf", wizard.sens);
- boluscalcJSON.put("ic", wizard.ic);
- boluscalcJSON.put("iob", -(wizard.insulingFromBolusIOB + wizard.insulingFromBasalsIOB));
- boluscalcJSON.put("bolusiobused", true);
- boluscalcJSON.put("basaliobused", true);
- boluscalcJSON.put("bg", actualBg.valueToUnits(profile.getUnits()));
- boluscalcJSON.put("insulinbg", wizard.insulinFromBG);
- boluscalcJSON.put("insulinbgused", true);
- boluscalcJSON.put("bgdiff", wizard.bgDiff);
- boluscalcJSON.put("insulincarbs", wizard.insulinFromCarbs);
- boluscalcJSON.put("carbs", quickWizardEntry.carbs());
- boluscalcJSON.put("othercorrection", 0d);
- boluscalcJSON.put("insulintrend", wizard.insulinFromTrend);
- boluscalcJSON.put("insulin", wizard.calculatedTotalInsulin);
- } catch (JSONException e) {
- e.printStackTrace();
- }
- if (wizard.calculatedTotalInsulin > 0d && quickWizardEntry.carbs() > 0d) {
- DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
- String confirmMessage = getString(R.string.entertreatmentquestion);
-
- Double insulinAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(wizard.calculatedTotalInsulin);
- Integer carbsAfterConstraints = MainApp.getConfigBuilder().applyCarbsConstraints(quickWizardEntry.carbs());
-
- confirmMessage += "\n" + getString(R.string.bolus) + ": " + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U";
- confirmMessage += "\n" + getString(R.string.carbs) + ": " + carbsAfterConstraints + "g";
-
- if (!insulinAfterConstraints.equals(wizard.calculatedTotalInsulin) || !carbsAfterConstraints.equals(quickWizardEntry.carbs())) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
- builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
- builder.setMessage(getString(R.string.constraints_violation) + "\n" + getString(R.string.changeyourinput));
- builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
- builder.show();
- return;
- }
-
- final Double finalInsulinAfterConstraints = insulinAfterConstraints;
- final Integer finalCarbsAfterConstraints = carbsAfterConstraints;
- final Context context = getContext();
- AlertDialog.Builder builder = new AlertDialog.Builder(context);
- builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
- builder.setMessage(confirmMessage);
- builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int id) {
- if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
- final ConfigBuilderPlugin pump = MainApp.getConfigBuilder();
- sHandler.post(new Runnable() {
- @Override
- public void run() {
- DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
- detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD;
- detailedBolusInfo.insulin = finalInsulinAfterConstraints;
- detailedBolusInfo.carbs = finalCarbsAfterConstraints;
- detailedBolusInfo.context = context;
- detailedBolusInfo.boluscalc = boluscalcJSON;
- detailedBolusInfo.source = Source.USER;
- PumpEnactResult result = pump.deliverTreatment(detailedBolusInfo);
- if (!result.success) {
- AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
- builder.setTitle(MainApp.sResources.getString(R.string.treatmentdeliveryerror));
- builder.setMessage(result.comment);
- builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
- builder.show();
- }
- }
- });
- Answers.getInstance().logCustom(new CustomEvent("QuickWizard"));
- }
- }
- });
- builder.setNegativeButton(getString(R.string.cancel), null);
- builder.show();
- }
- }
-
- }
-
- @Override
- public void onPause() {
- super.onPause();
- MainApp.bus().unregister(this);
- sLoopHandler.removeCallbacksAndMessages(null);
- unregisterForContextMenu(apsModeView);
- }
-
- @Override
- public void onResume() {
- super.onResume();
- MainApp.bus().register(this);
- sRefreshLoop = new Runnable() {
- @Override
- public void run() {
- scheduleUpdateGUI("refreshLoop");
- sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
- // Added by Rumen for STALE DATA ALARM
- boolean isThereStaleData = Notification.isAlarmForStaleData();
- log.debug("isThereIsStaleData: "+isThereStaleData);
- if(isThereStaleData){
- Notification notification = new Notification(Notification.NSALARM, getString(R.string.nsalarm_staledata), Notification.URGENT);
- MainApp.bus().post(new EventNewNotification(notification));
- }
- // end of insert
- }
- };
- sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
- registerForContextMenu(apsModeView);
- updateGUI("onResume");
- }
-
- @Subscribe
- public void onStatusEvent(final EventInitializationChanged ev) {
- scheduleUpdateGUI("EventInitializationChanged");
- }
-
- @Subscribe
- public void onStatusEvent(final EventPreferenceChange ev) {
- scheduleUpdateGUI("EventPreferenceChange");
- }
-
- @Subscribe
- public void onStatusEvent(final EventRefreshOverview ev) {
- scheduleUpdateGUI(ev.from);
- }
-
- @Subscribe
- public void onStatusEvent(final EventAutosensCalculationFinished ev) {
- scheduleUpdateGUI("EventAutosensCalculationFinished");
- }
-
- @Subscribe
- public void onStatusEvent(final EventTreatmentChange ev) {
- scheduleUpdateGUI("EventTreatmentChange");
- }
-
- @Subscribe
- public void onStatusEvent(final EventCareportalEventChange ev) {
- scheduleUpdateGUI("EventCareportalEventChange");
- }
-
- @Subscribe
- public void onStatusEvent(final EventTempBasalChange ev) {
- scheduleUpdateGUI("EventTempBasalChange");
- }
-
- @Subscribe
- public void onStatusEvent(final EventExtendedBolusChange ev) {
- scheduleUpdateGUI("EventExtendedBolusChange");
- }
-
-// Handled by EventAutosensCalculationFinished
-// @Subscribe
-// public void onStatusEvent(final EventNewBG ev) {
-// scheduleUpdateGUI("EventNewBG");
-// }
-
- @Subscribe
- public void onStatusEvent(final EventNewOpenLoopNotification ev) {
- scheduleUpdateGUI("EventNewOpenLoopNotification");
- }
-
-// Handled by EventAutosensCalculationFinished
-// @Subscribe
-// public void onStatusEvent(final EventNewBasalProfile ev) {
-// scheduleUpdateGUI("EventNewBasalProfile");
-// }
-
- @Subscribe
- public void onStatusEvent(final EventTempTargetChange ev) {
- scheduleUpdateGUI("EventTempTargetChange");
- }
-
- @Subscribe
- public void onStatusEvent(final EventPumpStatusChanged s) {
- Activity activity = getActivity();
- if (activity != null)
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- updatePumpStatus(s.textStatus());
- }
- });
- }
-
- private void hideTempRecommendation() {
- Activity activity = getActivity();
- if (activity != null)
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- if (acceptTempLayout != null)
- acceptTempLayout.setVisibility(View.GONE);
- }
- });
- }
-
- private void clearNotification() {
- NotificationManager notificationManager =
- (NotificationManager) MainApp.instance().getSystemService(Context.NOTIFICATION_SERVICE);
- notificationManager.cancel(Constants.notificationID);
- }
-
- private void updatePumpStatus(String status) {
- if (!status.equals("")) {
- pumpStatusView.setText(status);
- pumpStatusLayout.setVisibility(View.VISIBLE);
- loopStatusLayout.setVisibility(View.GONE);
- } else {
- pumpStatusLayout.setVisibility(View.GONE);
- loopStatusLayout.setVisibility(View.VISIBLE);
- }
- }
-
- public void scheduleUpdateGUI(final String from) {
- class UpdateRunnable implements Runnable {
- public void run() {
- Activity activity = getActivity();
- if (activity != null)
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- updateGUI(from);
- scheduledUpdate = null;
- }
- });
- }
- }
- // prepare task for execution in 400 msec
- // cancel waiting task to prevent multiple updates
- if (scheduledUpdate != null)
- scheduledUpdate.cancel(false);
- Runnable task = new UpdateRunnable();
- final int msec = 500;
- scheduledUpdate = worker.schedule(task, msec, TimeUnit.MILLISECONDS);
- }
-
- @SuppressLint("SetTextI18n")
- public void updateGUI(String from) {
- log.debug("updateGUI entered from: " + from);
- Date updateGUIStart = new Date();
-
- if (getActivity() == null)
- return;
-
- if (timeView != null) { //must not exists
- timeView.setText(DateUtil.timeString(new Date()));
- }
- if (MainApp.getConfigBuilder().getProfile() == null) {// app not initialized yet
- pumpStatusView.setText(R.string.noprofileset);
- pumpStatusLayout.setVisibility(View.VISIBLE);
- loopStatusLayout.setVisibility(View.GONE);
- return;
- }
- pumpStatusLayout.setVisibility(View.GONE);
- loopStatusLayout.setVisibility(View.VISIBLE);
-
- updateNotifications();
- CareportalFragment.updateAge(getActivity(), sage, iage, cage, pbage);
- BgReading actualBG = DatabaseHelper.actualBg();
- BgReading lastBG = DatabaseHelper.lastBg();
-
- PumpInterface pump = MainApp.getConfigBuilder();
-
- Profile profile = MainApp.getConfigBuilder().getProfile();
- String units = profile.getUnits();
-
- if (units == null) {
- pumpStatusView.setText(R.string.noprofileset);
- pumpStatusLayout.setVisibility(View.VISIBLE);
- loopStatusLayout.setVisibility(View.GONE);
- return;
- }
-
- // open loop mode
- final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
- if (Config.APS && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable) {
- apsModeView.setVisibility(View.VISIBLE);
- apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.loopenabled));
- apsModeView.setTextColor(Color.BLACK);
- final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
- if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuperBolus()) {
- apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
- apsModeView.setText(String.format(MainApp.sResources.getString(R.string.loopsuperbolusfor), activeloop.minutesToEndOfSuspend()));
- apsModeView.setTextColor(Color.WHITE);
- } else if (activeloop != null && activeloop.isEnabled(activeloop.getType()) && activeloop.isSuspended()) {
- apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
- apsModeView.setText(String.format(MainApp.sResources.getString(R.string.loopsuspendedfor), activeloop.minutesToEndOfSuspend()));
- apsModeView.setTextColor(Color.WHITE);
- } else if (pump.isSuspended()) {
- apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.looppumpsuspended));
- apsModeView.setText(MainApp.sResources.getString(R.string.pumpsuspended));
- apsModeView.setTextColor(Color.WHITE);
- } else if (activeloop != null && activeloop.isEnabled(activeloop.getType())) {
- if (MainApp.getConfigBuilder().isClosedModeEnabled()) {
- apsModeView.setText(MainApp.sResources.getString(R.string.closedloop));
- } else {
- apsModeView.setText(MainApp.sResources.getString(R.string.openloop));
- }
- } else {
- apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.loopdisabled));
- apsModeView.setText(MainApp.sResources.getString(R.string.disabledloop));
- apsModeView.setTextColor(Color.WHITE);
- }
- } else {
- apsModeView.setVisibility(View.GONE);
- }
-
- // temp target
- TempTarget tempTarget = MainApp.getConfigBuilder().getTempTargetFromHistory(System.currentTimeMillis());
- if (tempTarget != null) {
- tempTargetView.setTextColor(Color.BLACK);
- tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetBackground));
- tempTargetView.setVisibility(View.VISIBLE);
- if (tempTarget.low == tempTarget.high)
- tempTargetView.setText(Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, units), units));
- else
- tempTargetView.setText(Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, units), units) + " - " + Profile.toUnitsString(tempTarget.high, Profile.fromMgdlToUnits(tempTarget.high, units), units));
- } else {
- Double maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
- Double minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
- if (!units.equals(Constants.MGDL)) {
- maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
- minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
- }
- tempTargetView.setTextColor(Color.WHITE);
- tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetDisabledBackground));
- double low = SP.getDouble("openapsma_min_bg", minBgDefault);
- double high = SP.getDouble("openapsma_max_bg", maxBgDefault);
- if (low == high)
- tempTargetView.setText("" + low);
- else
- tempTargetView.setText(low + " - " + high);
- tempTargetView.setVisibility(View.VISIBLE);
- }
- if (Config.NSCLIENT && tempTarget == null) {
- tempTargetView.setVisibility(View.GONE);
- }
-
- // **** Temp button ****
- if (acceptTempLayout != null) {
- boolean showAcceptButton = !MainApp.getConfigBuilder().isClosedModeEnabled(); // Open mode needed
- showAcceptButton = showAcceptButton && finalLastRun != null && finalLastRun.lastAPSRun != null; // aps result must exist
- showAcceptButton = showAcceptButton && (finalLastRun.lastOpenModeAccept == null || finalLastRun.lastOpenModeAccept.getTime() < finalLastRun.lastAPSRun.getTime()); // never accepted or before last result
- showAcceptButton = showAcceptButton && finalLastRun.constraintsProcessed.changeRequested; // change is requested
-
- if (showAcceptButton && pump.isInitialized() && !pump.isSuspended() && ConfigBuilderPlugin.getActiveLoop() != null) {
- acceptTempLayout.setVisibility(View.VISIBLE);
- acceptTempButton.setText(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
- } else {
- acceptTempLayout.setVisibility(View.GONE);
- }
- }
-
- // **** Calibration button ****
- if (calibrationButton != null) {
- if (MainApp.getSpecificPlugin(SourceXdripPlugin.class) != null && MainApp.getSpecificPlugin(SourceXdripPlugin.class).isEnabled(PluginBase.BGSOURCE) && profile != null && DatabaseHelper.actualBg() != null) {
- calibrationButton.setVisibility(View.VISIBLE);
- } else {
- calibrationButton.setVisibility(View.GONE);
- }
- }
-
- final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
- String basalText = "";
- if (shorttextmode) {
- if (activeTemp != null) {
- basalText = "T: " + activeTemp.toStringVeryShort();
- } else {
- basalText = DecimalFormatter.to2Decimal(MainApp.getConfigBuilder().getProfile().getBasal()) + "U/h";
- }
- baseBasalView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String fullText = MainApp.sResources.getString(R.string.virtualpump_basebasalrate_label) + ": " + DecimalFormatter.to2Decimal(MainApp.getConfigBuilder().getProfile().getBasal()) + "U/h\n";
- if (activeTemp != null) {
- fullText += MainApp.sResources.getString(R.string.virtualpump_tempbasal_label) + ": " + activeTemp.toStringFull();
- }
- OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.basal), fullText, null);
- }
- });
-
- } else {
- if (activeTemp != null) {
- basalText = activeTemp.toStringFull() + " ";
- }
- if (Config.NSCLIENT)
- basalText += "(" + DecimalFormatter.to2Decimal(MainApp.getConfigBuilder().getProfile().getBasal()) + " U/h)";
- else if (pump.getPumpDescription().isTempBasalCapable) {
- basalText += "(" + DecimalFormatter.to2Decimal(pump.getBaseBasalRate()) + "U/h)";
- }
- }
- if (activeTemp != null) {
- baseBasalView.setTextColor(MainApp.sResources.getColor(R.color.basal));
- } else {
- baseBasalView.setTextColor(Color.WHITE);
-
- }
-
- baseBasalView.setText(basalText);
-
- final ExtendedBolus extendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
- String extendedBolusText = "";
- if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses()) {
- extendedBolusText = extendedBolus.toString();
- }
- if (extendedBolusView != null) { // must not exists in all layouts
- if (shorttextmode) {
- if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses()) {
- extendedBolusText = DecimalFormatter.to2Decimal(extendedBolus.absoluteRate()) + "U/h";
- } else {
- extendedBolusText = "";
- }
- extendedBolusView.setText(extendedBolusText);
- extendedBolusView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.extendedbolus), extendedBolus.toString(), null);
- }
- });
-
- } else {
- extendedBolusView.setText(extendedBolusText);
- }
- }
-
- activeProfileView.setText(MainApp.getConfigBuilder().getProfileName());
- activeProfileView.setBackgroundColor(Color.GRAY);
-
- activeProfileView.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View view) {
- view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
- NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
- final OptionsToShow profileswitch = CareportalFragment.profileswitch;
- profileswitch.executeProfileSwitch = true;
- newDialog.setOptions(profileswitch, R.string.careportal_profileswitch);
- newDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
- return true;
- }
- });
- activeProfileView.setLongClickable(true);
-
-
- tempTargetView.setOnLongClickListener(new View.OnLongClickListener() {
- @Override
- public boolean onLongClick(View view) {
- view.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS);
- NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog();
- final OptionsToShow temptarget = CareportalFragment.temptarget;
- temptarget.executeTempTarget = true;
- newTTDialog.setOptions(temptarget, R.string.careportal_temporarytarget);
- newTTDialog.show(getFragmentManager(), "NewNSTreatmentDialog");
- return true;
- }
- });
- tempTargetView.setLongClickable(true);
-
- // QuickWizard button
- QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
- if (quickWizardEntry != null && lastBG != null && pump.isInitialized() && !pump.isSuspended()) {
- quickWizardButton.setVisibility(View.VISIBLE);
- String text = quickWizardEntry.buttonText() + "\n" + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
- BolusWizard wizard = new BolusWizard();
- wizard.doCalc(profile, quickWizardEntry.carbs(), 0d, lastBG.valueToUnits(units), 0d, true, true, false, false);
- text += " " + DecimalFormatter.to2Decimal(wizard.calculatedTotalInsulin) + "U";
- quickWizardButton.setText(text);
- if (wizard.calculatedTotalInsulin <= 0)
- quickWizardButton.setVisibility(View.GONE);
- } else
- quickWizardButton.setVisibility(View.GONE);
-
- // Bolus and calc button
- if (pump.isInitialized() && !pump.isSuspended()) {
- wizardButton.setVisibility(View.VISIBLE);
- treatmentButton.setVisibility(View.VISIBLE);
- } else {
- wizardButton.setVisibility(View.GONE);
- treatmentButton.setVisibility(View.GONE);
- }
-
- Double lowLine = SP.getDouble("low_mark", 0d);
- Double highLine = SP.getDouble("high_mark", 0d);
- if (lowLine < 1) {
- lowLine = Profile.fromMgdlToUnits(OverviewPlugin.bgTargetLow, units);
- }
- if (highLine < 1) {
- highLine = Profile.fromMgdlToUnits(OverviewPlugin.bgTargetHigh, units);
- }
-
- // **** BG value ****
- if (lastBG != null) {
- int color = MainApp.sResources.getColor(R.color.inrange);
- if (lastBG.valueToUnits(units) < lowLine)
- color = MainApp.sResources.getColor(R.color.low);
- else if (lastBG.valueToUnits(units) > highLine)
- color = MainApp.sResources.getColor(R.color.high);
- bgView.setText(lastBG.valueToUnitsToString(units));
- arrowView.setText(lastBG.directionToSymbol());
- bgView.setTextColor(color);
- arrowView.setTextColor(color);
- GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
- if (glucoseStatus != null) {
- deltaView.setText("Δ " + Profile.toUnitsString(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units) + " " + units);
- if (avgdeltaView != null)
- avgdeltaView.setText("øΔ15m: " + Profile.toUnitsString(glucoseStatus.short_avgdelta, glucoseStatus.short_avgdelta * Constants.MGDL_TO_MMOLL, units) +
- " øΔ40m: " + Profile.toUnitsString(glucoseStatus.long_avgdelta, glucoseStatus.long_avgdelta * Constants.MGDL_TO_MMOLL, units));
- } else {
- deltaView.setText("Δ " + MainApp.sResources.getString(R.string.notavailable));
- if (avgdeltaView != null)
- avgdeltaView.setText("");
- }
- } else {
- return;
- }
- Integer flag = bgView.getPaintFlags();
- if (actualBG == null) {
- flag |= Paint.STRIKE_THRU_TEXT_FLAG;
- } else
- flag &= ~Paint.STRIKE_THRU_TEXT_FLAG;
- bgView.setPaintFlags(flag);
-
- Long agoMsec = System.currentTimeMillis() - lastBG.date;
- int agoMin = (int) (agoMsec / 60d / 1000d);
- timeAgoView.setText(String.format(MainApp.sResources.getString(R.string.minago), agoMin));
-
- // iob
- MainApp.getConfigBuilder().updateTotalIOBTreatments();
- MainApp.getConfigBuilder().updateTotalIOBTempBasals();
- final IobTotal bolusIob = MainApp.getConfigBuilder().getLastCalculationTreatments().round();
- final IobTotal basalIob = MainApp.getConfigBuilder().getLastCalculationTempBasals().round();
-
- if (shorttextmode) {
- String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U";
- iobView.setText(iobtext);
- iobView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U\n"
- + getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U\n"
- + getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U\n";
- OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.iob), iobtext, null);
- }
- });
- } else if (MainApp.sResources.getBoolean(R.bool.isTablet)) {
- String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
- + getString(R.string.bolus) + ": " + DecimalFormatter.to2Decimal(bolusIob.iob) + "U "
- + getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)";
- iobView.setText(iobtext);
- } else {
- String iobtext = DecimalFormatter.to2Decimal(bolusIob.iob + basalIob.basaliob) + "U ("
- + DecimalFormatter.to2Decimal(bolusIob.iob) + "/"
- + DecimalFormatter.to2Decimal(basalIob.basaliob) + ")";
- iobView.setText(iobtext);
- }
-
- // cob
- if (cobView != null) { // view must not exists
- String cobText = "";
- AutosensData autosensData = IobCobCalculatorPlugin.getAutosensData(System.currentTimeMillis());
- if (autosensData != null)
- cobText = (int) autosensData.cob + " g";
- cobView.setText(cobText);
- }
-
- boolean showPrediction = showPredictionView.isChecked() && finalLastRun != null && finalLastRun.constraintsProcessed.getClass().equals(DetermineBasalResultAMA.class);
- if (MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class) != null && MainApp.getSpecificPlugin(OpenAPSAMAPlugin.class).isEnabled(PluginBase.APS)) {
- showPredictionView.setVisibility(View.VISIBLE);
- getActivity().findViewById(R.id.overview_showprediction_label).setVisibility(View.VISIBLE);
- } else {
- showPredictionView.setVisibility(View.GONE);
- getActivity().findViewById(R.id.overview_showprediction_label).setVisibility(View.GONE);
- }
-
- // pump status from ns
- if (pumpDeviceStatusView != null) {
- pumpDeviceStatusView.setText(NSDeviceStatus.getInstance().getPumpStatus());
- pumpDeviceStatusView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.pump), NSDeviceStatus.getInstance().getExtendedPumpStatus(), null);
- }
- });
- }
-
- // OpenAPS status from ns
- if (openapsDeviceStatusView != null) {
- openapsDeviceStatusView.setText(NSDeviceStatus.getInstance().getOpenApsStatus());
- openapsDeviceStatusView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.openaps), NSDeviceStatus.getInstance().getExtendedOpenApsStatus(), null);
- }
- });
- }
-
- // Uploader status from ns
- if (uploaderDeviceStatusView != null) {
- uploaderDeviceStatusView.setText(NSDeviceStatus.getInstance().getUploaderStatus());
- uploaderDeviceStatusView.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- OKDialog.show(getActivity(), MainApp.sResources.getString(R.string.uploader), NSDeviceStatus.getInstance().getExtendedUploaderStatus(), null);
- }
- });
- }
-
- // ****** GRAPH *******
- //log.debug("updateGUI checkpoint 1");
-
- // allign to hours
- Calendar calendar = Calendar.getInstance();
- calendar.setTimeInMillis(System.currentTimeMillis());
- calendar.set(Calendar.MILLISECOND, 0);
- calendar.set(Calendar.SECOND, 0);
- calendar.set(Calendar.MINUTE, 0);
- calendar.add(Calendar.HOUR, 1);
-
- int hoursToFetch;
- long toTime;
- long fromTime;
- long endTime;
- if (showPrediction) {
- int predHours = (int) (Math.ceil(((DetermineBasalResultAMA) finalLastRun.constraintsProcessed).getLatestPredictionsTime() - System.currentTimeMillis()) / (60 * 60 * 1000));
- predHours = Math.min(2, predHours);
- predHours = Math.max(0, predHours);
- hoursToFetch = rangeToDisplay - predHours;
- toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding - Graphview specific
- fromTime = toTime - hoursToFetch * 60 * 60 * 1000L;
- endTime = toTime + predHours * 60 * 60 * 1000L;
- } else {
- hoursToFetch = rangeToDisplay;
- toTime = calendar.getTimeInMillis() + 100000; // little bit more to avoid wrong rounding - Graphview specific
- fromTime = toTime - hoursToFetch * 60 * 60 * 1000L;
- endTime = toTime;
- }
-
- LineGraphSeries basalsLineSeries = null;
- LineGraphSeries absoluteBasalsLineSeries = null;
- LineGraphSeries baseBasalsSeries = null;
- LineGraphSeries tempBasalsSeries = null;
- AreaGraphSeries areaSeries;
- LineGraphSeries seriesNow, seriesNow2;
-
- // **** TEMP BASALS graph ****
- Double maxBasalValueFound = 0d;
-
- long now = System.currentTimeMillis();
- if (pump.getPumpDescription().isTempBasalCapable && showBasalsView.isChecked()) {
- List baseBasalArray = new ArrayList<>();
- List tempBasalArray = new ArrayList<>();
- List basalLineArray = new ArrayList<>();
- List absoluteBasalLineArray = new ArrayList<>();
- double lastLineBasal = 0;
- double lastAbsoluteLineBasal = 0;
- double lastBaseBasal = 0;
- double lastTempBasal = 0;
- for (long time = fromTime; time < now; time += 60 * 1000L) {
- BasalData basalData = IobCobCalculatorPlugin.getBasalData(time);
- double baseBasalValue = basalData.basal;
- double absoluteLineValue = baseBasalValue;
- double tempBasalValue = 0;
- double basal = 0d;
- if (basalData.isTempBasalRunning) {
- absoluteLineValue = tempBasalValue = basalData.tempBasalAbsolute;
- if (tempBasalValue != lastTempBasal) {
- tempBasalArray.add(new DataPoint(time, lastTempBasal));
- tempBasalArray.add(new DataPoint(time, basal = tempBasalValue));
- }
- if (lastBaseBasal != 0d) {
- baseBasalArray.add(new DataPoint(time, lastBaseBasal));
- baseBasalArray.add(new DataPoint(time, 0d));
- lastBaseBasal = 0d;
- }
- } else {
- if (baseBasalValue != lastBaseBasal) {
- baseBasalArray.add(new DataPoint(time, lastBaseBasal));
- baseBasalArray.add(new DataPoint(time, basal = baseBasalValue));
- lastBaseBasal = baseBasalValue;
- }
- if (lastTempBasal != 0) {
- tempBasalArray.add(new DataPoint(time, lastTempBasal));
- tempBasalArray.add(new DataPoint(time, 0d));
- }
- }
-
- if (baseBasalValue != lastLineBasal) {
- basalLineArray.add(new DataPoint(time, lastLineBasal));
- basalLineArray.add(new DataPoint(time, baseBasalValue));
- }
- if (absoluteLineValue != lastAbsoluteLineBasal) {
- absoluteBasalLineArray.add(new DataPoint(time, lastAbsoluteLineBasal));
- absoluteBasalLineArray.add(new DataPoint(time, basal));
- }
-
- lastAbsoluteLineBasal = absoluteLineValue;
- lastLineBasal = baseBasalValue;
- lastTempBasal = tempBasalValue;
- maxBasalValueFound = Math.max(maxBasalValueFound, basal);
- }
- basalLineArray.add(new DataPoint(now, lastLineBasal));
- baseBasalArray.add(new DataPoint(now, lastBaseBasal));
- tempBasalArray.add(new DataPoint(now, lastTempBasal));
- absoluteBasalLineArray.add(new DataPoint(now, lastAbsoluteLineBasal));
-
- DataPoint[] baseBasal = new DataPoint[baseBasalArray.size()];
- baseBasal = baseBasalArray.toArray(baseBasal);
- baseBasalsSeries = new LineGraphSeries<>(baseBasal);
- baseBasalsSeries.setDrawBackground(true);
- baseBasalsSeries.setBackgroundColor(MainApp.sResources.getColor(R.color.basebasal));
- baseBasalsSeries.setThickness(0);
-
- DataPoint[] tempBasal = new DataPoint[tempBasalArray.size()];
- tempBasal = tempBasalArray.toArray(tempBasal);
- tempBasalsSeries = new LineGraphSeries<>(tempBasal);
- tempBasalsSeries.setDrawBackground(true);
- tempBasalsSeries.setBackgroundColor(MainApp.sResources.getColor(R.color.tempbasal));
- tempBasalsSeries.setThickness(0);
-
- DataPoint[] basalLine = new DataPoint[basalLineArray.size()];
- basalLine = basalLineArray.toArray(basalLine);
- basalsLineSeries = new LineGraphSeries<>(basalLine);
- Paint paint = new Paint();
- paint.setStyle(Paint.Style.STROKE);
- paint.setStrokeWidth(2);
- paint.setPathEffect(new DashPathEffect(new float[]{2, 4}, 0));
- paint.setColor(MainApp.sResources.getColor(R.color.basal));
- basalsLineSeries.setCustomPaint(paint);
-
- DataPoint[] absoluteBasalLine = new DataPoint[absoluteBasalLineArray.size()];
- absoluteBasalLine = absoluteBasalLineArray.toArray(absoluteBasalLine);
- absoluteBasalsLineSeries = new LineGraphSeries<>(absoluteBasalLine);
- Paint absolutePaint = new Paint();
- absolutePaint.setStyle(Paint.Style.STROKE);
- absolutePaint.setStrokeWidth(4);
- absolutePaint.setColor(MainApp.sResources.getColor(R.color.basal));
- absoluteBasalsLineSeries.setCustomPaint(absolutePaint);
- }
-
- //log.debug("updateGUI checkpoint 2");
-
- // **** IOB COB DEV graph ****
- class DeviationDataPoint extends DataPoint {
- public int color;
-
- public DeviationDataPoint(double x, double y, int color) {
- super(x, y);
- this.color = color;
- }
- }
- FixedLineGraphSeries iobSeries;
- FixedLineGraphSeries cobSeries;
- BarGraphSeries devSeries;
- LineGraphSeries ratioSeries;
- Double maxIobValueFound = 0d;
- Double maxCobValueFound = 0d;
- Double maxDevValueFound = 0d;
- Double maxRatioValueFound = 0d;
-
- if (showIobView.isChecked() || showCobView.isChecked() || showDeviationsView.isChecked() || showRatiosView.isChecked()) {
- //Date start = new Date();
- List iobArray = new ArrayList<>();
- List cobArray = new ArrayList<>();
- List devArray = new ArrayList<>();
- List ratioArray = new ArrayList<>();
- double lastIob = 0;
- int lastCob = 0;
- for (long time = fromTime; time <= now; time += 5 * 60 * 1000L) {
- if (showIobView.isChecked()) {
- double iob = IobCobCalculatorPlugin.calulateFromTreatmentsAndTemps(time).iob;
- if (Math.abs(lastIob - iob) > 0.02) {
- if (Math.abs(lastIob - iob) > 0.2)
- iobArray.add(new DataPoint(time, lastIob));
- iobArray.add(new DataPoint(time, iob));
- maxIobValueFound = Math.max(maxIobValueFound, Math.abs(iob));
- lastIob = iob;
- }
- }
- if (showCobView.isChecked() || showDeviationsView.isChecked() || showRatiosView.isChecked()) {
- AutosensData autosensData = IobCobCalculatorPlugin.getAutosensData(time);
- if (autosensData != null && showCobView.isChecked()) {
- int cob = (int) autosensData.cob;
- if (cob != lastCob) {
- if (autosensData.carbsFromBolus > 0)
- cobArray.add(new DataPoint(time, lastCob));
- cobArray.add(new DataPoint(time, cob));
- maxCobValueFound = Math.max(maxCobValueFound, cob);
- lastCob = cob;
- }
- }
- if (autosensData != null && showDeviationsView.isChecked()) {
- int color = Color.BLACK; // "="
- if (autosensData.pastSensitivity.equals("C")) color = Color.GRAY;
- if (autosensData.pastSensitivity.equals("+")) color = Color.GREEN;
- if (autosensData.pastSensitivity.equals("-")) color = Color.RED;
- devArray.add(new DeviationDataPoint(time, autosensData.deviation, color));
- maxDevValueFound = Math.max(maxDevValueFound, Math.abs(autosensData.deviation));
- }
- if (autosensData != null && showRatiosView.isChecked()) {
- ratioArray.add(new DataPoint(time, autosensData.autosensRatio));
- maxRatioValueFound = Math.max(maxRatioValueFound, Math.abs(autosensData.autosensRatio));
- }
- }
- }
- //Profiler.log(log, "IOB processed", start);
- DataPoint[] iobData = new DataPoint[iobArray.size()];
- iobData = iobArray.toArray(iobData);
- iobSeries = new FixedLineGraphSeries<>(iobData);
- iobSeries.setDrawBackground(true);
- iobSeries.setBackgroundColor(0x80FFFFFF & MainApp.sResources.getColor(R.color.iob)); //50%
- iobSeries.setColor(MainApp.sResources.getColor(R.color.iob));
- iobSeries.setThickness(3);
-
-
- Double maxByScale = null;
- int graphsToShow = 0;
- if (showIobView.isChecked()) {
- if (maxByScale == null) maxByScale = maxIobValueFound;
- graphsToShow++;
- }
- if (showCobView.isChecked()) {
- if (maxByScale == null) maxByScale = maxCobValueFound;
- graphsToShow++;
- }
- if (showDeviationsView.isChecked()) {
- if (maxByScale == null) maxByScale = maxDevValueFound;
- graphsToShow++;
- }
- if (showRatiosView.isChecked()) {
- if (maxByScale == null) maxByScale = maxRatioValueFound;
- graphsToShow++;
- }
-
- if (graphsToShow > 1) {
- if (!maxByScale.equals(maxCobValueFound)) {
- List cobArrayRescaled = new ArrayList<>();
- for (int ci = 0; ci < cobArray.size(); ci++) {
- cobArrayRescaled.add(new DataPoint(cobArray.get(ci).getX(), cobArray.get(ci).getY() * maxByScale / maxCobValueFound / 2));
- }
- cobArray = cobArrayRescaled;
- }
- if (!maxByScale.equals(maxDevValueFound)) {
- List devArrayRescaled = new ArrayList<>();
- for (int ci = 0; ci < devArray.size(); ci++) {
- devArrayRescaled.add(new DeviationDataPoint(devArray.get(ci).getX(), devArray.get(ci).getY() * maxByScale / maxDevValueFound, devArray.get(ci).color));
- }
- devArray = devArrayRescaled;
- }
- if (!maxByScale.equals(maxRatioValueFound)) {
- List ratioArrayRescaled = new ArrayList<>();
- for (int ci = 0; ci < ratioArray.size(); ci++) {
- ratioArrayRescaled.add(new DataPoint(ratioArray.get(ci).getX(), (ratioArray.get(ci).getY() - 1) * maxByScale / maxRatioValueFound));
- }
- ratioArray = ratioArrayRescaled;
- }
- }
-
- // COB
- DataPoint[] cobData = new DataPoint[cobArray.size()];
- cobData = cobArray.toArray(cobData);
- cobSeries = new FixedLineGraphSeries<>(cobData);
- cobSeries.setDrawBackground(true);
- cobSeries.setBackgroundColor(0xB0FFFFFF & MainApp.sResources.getColor(R.color.cob)); //50%
- cobSeries.setColor(MainApp.sResources.getColor(R.color.cob));
- cobSeries.setThickness(3);
-
- // DEVIATIONS
- DeviationDataPoint[] devData = new DeviationDataPoint[devArray.size()];
- devData = devArray.toArray(devData);
- devSeries = new BarGraphSeries<>(devData);
- devSeries.setValueDependentColor(new ValueDependentColor() {
- @Override
- public int get(DeviationDataPoint data) {
- return data.color;
- }
- });
-
- // RATIOS
- DataPoint[] ratioData = new DataPoint[ratioArray.size()];
- ratioData = ratioArray.toArray(ratioData);
- ratioSeries = new LineGraphSeries<>(ratioData);
- ratioSeries.setColor(MainApp.sResources.getColor(R.color.ratio));
- ratioSeries.setThickness(3);
-
- iobGraph.getSeries().clear();
-
- if (showIobView.isChecked() && iobData.length > 0) {
- addSeriesWithoutInvalidate(iobSeries, iobGraph);
- }
- if (showCobView.isChecked() && cobData.length > 0) {
- addSeriesWithoutInvalidate(cobSeries, iobGraph);
- }
- if (showDeviationsView.isChecked() && devData.length > 0) {
- addSeriesWithoutInvalidate(devSeries, iobGraph);
- }
- if (showRatiosView.isChecked() && ratioData.length > 0) {
- addSeriesWithoutInvalidate(ratioSeries, iobGraph);
- }
- iobGraph.setVisibility(View.VISIBLE);
- } else {
- iobGraph.setVisibility(View.GONE);
- }
- //log.debug("updateGUI checkpoint 3");
-
- // remove old data from graph
- bgGraph.getSecondScale().getSeries().clear();
- bgGraph.getSeries().clear();
- //log.debug("updateGUI checkpoint 4");
-
- // **** Area ****
- DoubleDataPoint[] areaDataPoints = new DoubleDataPoint[]{
- new DoubleDataPoint(fromTime, lowLine, highLine),
- new DoubleDataPoint(endTime, lowLine, highLine)
- };
- areaSeries = new AreaGraphSeries<>(areaDataPoints);
- addSeriesWithoutInvalidate(areaSeries, bgGraph);
- areaSeries.setColor(0);
- areaSeries.setDrawBackground(true);
- areaSeries.setBackgroundColor(MainApp.sResources.getColor(R.color.inrangebackground));
-
- // set manual x bounds to have nice steps
- bgGraph.getViewport().setMaxX(endTime);
- bgGraph.getViewport().setMinX(fromTime);
- bgGraph.getViewport().setXAxisBoundsManual(true);
- bgGraph.getGridLabelRenderer().setLabelFormatter(new TimeAsXAxisLabelFormatter(getActivity(), "HH"));
- bgGraph.getGridLabelRenderer().setNumHorizontalLabels(7); // only 7 because of the space
- iobGraph.getViewport().setMaxX(endTime);
- iobGraph.getViewport().setMinX(fromTime);
- iobGraph.getViewport().setXAxisBoundsManual(true);
- iobGraph.getGridLabelRenderer().setLabelFormatter(new TimeAsXAxisLabelFormatter(getActivity(), "HH"));
- iobGraph.getGridLabelRenderer().setNumHorizontalLabels(7); // only 7 because of the space
-
- //log.debug("updateGUI checkpoint 5");
- // **** BG graph ****
- List bgReadingsArray = MainApp.getDbHelper().getBgreadingsDataFromTime(fromTime, true);
- List bgListArray = new ArrayList<>();
-
- if (bgReadingsArray.size() == 0) {
- return;
- }
-
- Iterator it = bgReadingsArray.iterator();
- Double maxBgValue = 0d;
- while (it.hasNext()) {
- BgReading bg = it.next();
- if (bg.value > maxBgValue) maxBgValue = bg.value;
- bgListArray.add(bg);
- }
- if (showPrediction) {
- DetermineBasalResultAMA amaResult = (DetermineBasalResultAMA) finalLastRun.constraintsProcessed;
- List predArray = amaResult.getPredictions();
- bgListArray.addAll(predArray);
- }
-
- maxBgValue = Profile.fromMgdlToUnits(maxBgValue, units);
- maxBgValue = units.equals(Constants.MGDL) ? Round.roundTo(maxBgValue, 40d) + 80 : Round.roundTo(maxBgValue, 2d) + 4;
- if (highLine > maxBgValue) maxBgValue = highLine;
- Integer numOfVertLines = units.equals(Constants.MGDL) ? (int) (maxBgValue / 40 + 1) : (int) (maxBgValue / 2 + 1);
-
- DataPointWithLabelInterface[] bg = new DataPointWithLabelInterface[bgListArray.size()];
- bg = bgListArray.toArray(bg);
-
- if (bg.length > 0) {
- addSeriesWithoutInvalidate(new PointsWithLabelGraphSeries<>(bg), bgGraph);
- }
-
- //log.debug("updateGUI checkpoint 6");
- // Treatments
- List filteredTreatments = new ArrayList<>();
-
- List treatments = MainApp.getConfigBuilder().getTreatmentsFromHistory();
-
- for (int tx = 0; tx < treatments.size(); tx++) {
- DataPointWithLabelInterface t = treatments.get(tx);
- if (t.getX() < fromTime || t.getX() > endTime) continue;
- t.setY(getNearestBg((long) t.getX(), bgReadingsArray));
- filteredTreatments.add(t);
- }
-
- //log.debug("updateGUI checkpoint 7");
- // ProfileSwitch
- List profileSwitches = MainApp.getConfigBuilder().getProfileSwitchesFromHistory().getList();
-
- for (int tx = 0; tx < profileSwitches.size(); tx++) {
- DataPointWithLabelInterface t = profileSwitches.get(tx);
- if (t.getX() < fromTime || t.getX() > endTime) continue;
- filteredTreatments.add(t);
- }
-
- //log.debug("updateGUI checkpoint 8");
- // Extended bolus
- if (!pump.isFakingTempsByExtendedBoluses()) {
- List extendedBoluses = MainApp.getConfigBuilder().getExtendedBolusesFromHistory().getList();
-
- for (int tx = 0; tx < extendedBoluses.size(); tx++) {
- DataPointWithLabelInterface t = extendedBoluses.get(tx);
- if (t.getX() + t.getDuration() < fromTime || t.getX() > endTime) continue;
- if (t.getDuration() == 0) continue;
- t.setY(getNearestBg((long) t.getX(), bgReadingsArray));
- filteredTreatments.add(t);
- }
- }
-
- //log.debug("updateGUI checkpoint 9");
- // Careportal
- List careportalEvents = MainApp.getDbHelper().getCareportalEventsFromTime(fromTime, true);
-
- for (int tx = 0; tx < careportalEvents.size(); tx++) {
- DataPointWithLabelInterface t = careportalEvents.get(tx);
- if (t.getX() + t.getDuration() < fromTime || t.getX() > endTime) continue;
- t.setY(getNearestBg((long) t.getX(), bgReadingsArray));
- filteredTreatments.add(t);
- }
-
- DataPointWithLabelInterface[] treatmentsArray = new DataPointWithLabelInterface[filteredTreatments.size()];
- treatmentsArray = filteredTreatments.toArray(treatmentsArray);
- if (treatmentsArray.length > 0) {
- addSeriesWithoutInvalidate(new PointsWithLabelGraphSeries<>(treatmentsArray), bgGraph);
- }
- //log.debug("updateGUI checkpoint 10");
-
- // set manual y bounds to have nice steps
- bgGraph.getViewport().setMaxY(maxBgValue);
- bgGraph.getViewport().setMinY(0);
- bgGraph.getViewport().setYAxisBoundsManual(true);
- bgGraph.getGridLabelRenderer().setNumVerticalLabels(numOfVertLines);
-
- // set second scale
- if (pump.getPumpDescription().isTempBasalCapable && showBasalsView.isChecked()) {
- bgGraph.getSecondScale().setMinY(0);
- bgGraph.getSecondScale().setMaxY(maxBgValue / lowLine * maxBasalValueFound * 1.2d);
- bgGraph.getSecondScale().addSeries(baseBasalsSeries);
- bgGraph.getSecondScale().addSeries(tempBasalsSeries);
- bgGraph.getSecondScale().addSeries(basalsLineSeries);
- bgGraph.getSecondScale().addSeries(absoluteBasalsLineSeries);
- }
- bgGraph.getSecondScale().setLabelFormatter(new LabelFormatter() {
- @Override
- public String formatLabel(double value, boolean isValueX) {
- return "";
- }
-
- @Override
- public void setViewport(Viewport viewport) {
-
- }
- });
-
- //log.debug("updateGUI checkpoint 11");
- // **** NOW line ****
- DataPoint[] nowPoints = new DataPoint[]{
- new DataPoint(now, 0),
- new DataPoint(now, maxBgValue)
- };
- addSeriesWithoutInvalidate(seriesNow = new LineGraphSeries<>(nowPoints), bgGraph);
- seriesNow.setDrawDataPoints(false);
- DataPoint[] nowPoints2 = new DataPoint[]{
- new DataPoint(now, 0),
- new DataPoint(now, maxIobValueFound)
- };
- addSeriesWithoutInvalidate(seriesNow2 = new LineGraphSeries<>(nowPoints2), iobGraph);
- seriesNow2.setDrawDataPoints(false);
- //seriesNow.setThickness(1);
- // custom paint to make a dotted line
- Paint paint = new Paint();
- paint.setStyle(Paint.Style.STROKE);
- paint.setStrokeWidth(2);
- paint.setPathEffect(new DashPathEffect(new float[]{10, 20}, 0));
- paint.setColor(Color.WHITE);
- seriesNow.setCustomPaint(paint);
- seriesNow2.setCustomPaint(paint);
- bgGraph.onDataChanged(false, false);
- iobGraph.onDataChanged(false, false);
-
- Profiler.log(log, from, updateGUIStart);
- }
-
- public double getNearestBg(long date, List bgReadingsArray) {
- double bg = 0;
- String units = MainApp.getConfigBuilder().getProfileUnits();
- for (int r = bgReadingsArray.size() - 1; r >= 0; r--) {
- BgReading reading = bgReadingsArray.get(r);
- if (reading.date > date) continue;
- bg = Profile.fromMgdlToUnits(reading.value, units);
- break;
- }
- return bg;
- }
-
- void addSeriesWithoutInvalidate(Series s, GraphView graph) {
- s.onGraphViewAttached(graph);
- graph.getSeries().add(s);
- }
-
-
- //Notifications
- static class RecyclerViewAdapter extends RecyclerView.Adapter {
-
- List notificationsList;
-
- RecyclerViewAdapter(List notificationsList) {
- this.notificationsList = notificationsList;
- }
-
- @Override
- public NotificationsViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
- View v = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.overview_notification_item, viewGroup, false);
- return new NotificationsViewHolder(v);
- }
-
- @Override
- public void onBindViewHolder(NotificationsViewHolder holder, int position) {
- Notification notification = notificationsList.get(position);
- holder.dismiss.setTag(notification);
- holder.text.setText(notification.text);
- holder.time.setText(DateUtil.timeString(notification.date));
- if (notification.level == Notification.URGENT)
- holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationUrgent));
- else if (notification.level == Notification.NORMAL)
- holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationNormal));
- else if (notification.level == Notification.LOW)
- holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationLow));
- else if (notification.level == Notification.INFO)
- holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationInfo));
- else if (notification.level == Notification.ANNOUNCEMENT)
- holder.cv.setBackgroundColor(ContextCompat.getColor(MainApp.instance(), R.color.notificationAnnouncement));
- }
-
- @Override
- public int getItemCount() {
- return notificationsList.size();
- }
-
- @Override
- public void onAttachedToRecyclerView(RecyclerView recyclerView) {
- super.onAttachedToRecyclerView(recyclerView);
- }
-
- static class NotificationsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
- CardView cv;
- TextView time;
- TextView text;
- Button dismiss;
-
- NotificationsViewHolder(View itemView) {
- super(itemView);
- cv = (CardView) itemView.findViewById(R.id.notification_cardview);
- time = (TextView) itemView.findViewById(R.id.notification_time);
- text = (TextView) itemView.findViewById(R.id.notification_text);
- dismiss = (Button) itemView.findViewById(R.id.notification_dismiss);
- dismiss.setOnClickListener(this);
- }
-
- @Override
- public void onClick(View v) {
- Notification notification = (Notification) v.getTag();
- switch (v.getId()) {
- case R.id.notification_dismiss:
- MainApp.bus().post(new EventDismissNotification(notification.id));
- if (notification.nsAlarm != null) {
- BroadcastAckAlarm.handleClearAlarm(notification.nsAlarm, MainApp.instance().getApplicationContext(), 60 * 60 * 1000L);
- }
- break;
- }
- }
- }
- }
-
- void updateNotifications() {
- Activity activity = getActivity();
- if (activity != null)
- activity.runOnUiThread(new Runnable() {
- @Override
- public void run() {
- NotificationStore nstore = getPlugin().notificationStore;
- nstore.removeExpired();
- if (nstore.store.size() > 0) {
- RecyclerViewAdapter adapter = new RecyclerViewAdapter(nstore.store);
- notificationsView.setAdapter(adapter);
- notificationsView.setVisibility(View.VISIBLE);
- } else {
- notificationsView.setVisibility(View.GONE);
- }
- }
- });
- }
-
-
-}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From aff62d86b1b9c84f7b5d54c9e2f8638ad4e65f19 Mon Sep 17 00:00:00 2001
From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com>
Date: Fri, 4 Aug 2017 16:43:46 +0300
Subject: [PATCH 09/35] Changed name of button to snooze if it's staleDataAlarm
---
.../androidaps/plugins/Overview/OverviewFragment.java | 10 ++--------
1 file changed, 2 insertions(+), 8 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 3a12c54650..86664f47b9 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
@@ -746,14 +746,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
public void run() {
scheduleUpdateGUI("refreshLoop");
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
- // Added by Rumen for STALE DATA ALARM
- boolean isThereStaleData = Notification.isAlarmForStaleData();
- log.debug("isThereIsStaleData: "+isThereStaleData);
- if(isThereStaleData){
- Notification notification = new Notification(Notification.NSALARM, getString(R.string.nsalarm_staledata), Notification.URGENT);
- MainApp.bus().post(new EventNewNotification(notification));
- }
- // end of insert
}
};
sLoopHandler.postDelayed(sRefreshLoop, 60 * 1000L);
@@ -1764,6 +1756,8 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
public void onBindViewHolder(NotificationsViewHolder holder, int position) {
Notification notification = notificationsList.get(position);
holder.dismiss.setTag(notification);
+ if(notification.text == MainApp.sResources.getString(R.string.nsalarm_staledata))
+ holder.dismiss.setText("snooze");
holder.text.setText(notification.text);
holder.time.setText(DateUtil.timeString(notification.date));
if (notification.level == Notification.URGENT)
From cdee9bf70353966795b15ea428fc9f504c52536e Mon Sep 17 00:00:00 2001
From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com>
Date: Fri, 4 Aug 2017 17:04:57 +0300
Subject: [PATCH 10/35] Get staleData setting from NS first
---
.../androidaps/plugins/Overview/Notification.java | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java
index b0d906e7f0..f6a524c9d9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java
@@ -60,7 +60,6 @@ public class Notification {
}
public Notification(int id, Date date, String text, int level, Date validTo) {
- log.debug("Initialized Notification.class 1");
this.id = id;
this.date = date;
this.text = text;
@@ -69,7 +68,6 @@ public class Notification {
}
public Notification(int id, String text, int level, int validMinutes) {
- log.debug("Initialized Notification.class 2");
this.id = id;
this.date = new Date();
this.text = text;
@@ -78,7 +76,6 @@ public class Notification {
}
public Notification(int id, String text, int level) {
- log.debug("Initialized Notification.class 3");
this.id = id;
this.date = new Date();
this.text = text;
@@ -155,7 +152,7 @@ public class Notification {
static boolean isAlarmForStaleData(){
if(SP.getLong("snoozedTo", 0L) != 0L){
if(System.currentTimeMillis() < SP.getLong("snoozedTo", 0L)) {
- log.debug("Alarm is snoozed for next "+(SP.getLong("snoozedTo", 0L)-System.currentTimeMillis())/1000+" seconds");
+ //log.debug("Alarm is snoozed for next "+(SP.getLong("snoozedTo", 0L)-System.currentTimeMillis())/1000+" seconds");
return false;
}
}
@@ -165,9 +162,11 @@ public class Notification {
long bgReadingAgo = System.currentTimeMillis() - bgReading.date;
int bgReadingAgoMin = (int) (bgReadingAgo / (1000 * 60));
// Added for testing
- //bgReadingAgoMin = 20;
+ bgReadingAgoMin = 20;
log.debug("bgReadingAgoMin value is:"+bgReadingAgoMin);
- if(bgReadingAgoMin > SP.getInt(R.string.key_nsalarm_staledatavalue,15) && SP.getBoolean(R.string.key_nsalarm_staledata, false)){
+ Double threshold = NSSettingsStatus.getInstance().getThreshold("alarmTimeagoWarnMins");
+ if(threshold == null) threshold = SP.getDouble(R.string.key_nsalarm_staledatavalue,15D);
+ if(bgReadingAgoMin > threshold && SP.getBoolean(R.string.key_nsalarm_staledata, false)){
return true;
}
return false;
From 3d9df4e18ed25eb05c45d54803d9ede2297e1005 Mon Sep 17 00:00:00 2001
From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com>
Date: Sat, 5 Aug 2017 11:20:09 +0300
Subject: [PATCH 11/35] Using equals() instead of == on line 1811
---
.../androidaps/plugins/Overview/OverviewFragment.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
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 86664f47b9..dcd7c356f5 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
@@ -1808,7 +1808,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
}
// Adding current time to snooze if we got staleData
log.debug("Notification text is: "+notification.text);
- if(notification.text == MainApp.sResources.getString(R.string.nsalarm_staledata)){
+ if(notification.text.equals(MainApp.sResources.getString(R.string.nsalarm_staledata))){
NotificationStore nstore = getPlugin().notificationStore;
long msToSnooze = SP.getInt("nsalarm_staledatavalue",15)*60*1000L;
log.debug("snooze nsalarm_staledatavalue in minutes is "+SP.getInt("nsalarm_staledatavalue",15)+"\n in ms is: "+msToSnooze+" currentTimeMillis is: "+System.currentTimeMillis());
From ad122153a93346de15b374b31f110f49e11718d0 Mon Sep 17 00:00:00 2001
From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com>
Date: Sat, 5 Aug 2017 11:26:12 +0300
Subject: [PATCH 12/35] added openAPSEnabledAlerts()
check for OpenAPS alerts enabled
---
.../NSClientInternal/data/NSSettingsStatus.java | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java
index f7a2de3144..bb01050702 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java
@@ -305,6 +305,7 @@ public class NSSettingsStatus {
return 0d;
}
+
@Nullable
public JSONObject extentendedPumpSettings() {
try {
@@ -343,5 +344,16 @@ public class NSSettingsStatus {
return "";
}
+ public boolean openAPSEnabledAlerts() {
+ try {
+ JSONObject pump = extentendedPumpSettings();
+ if (pump != null && pump.has("openaps")) {
+ return pump.getBoolean("enableAlerts");
+ }
+ } catch (JSONException e) {
+ e.printStackTrace();
+ }
+ return false;
+ }
}
From 222c357456074ad050febcf1e9753d1b4c0f16fe Mon Sep 17 00:00:00 2001
From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com>
Date: Sat, 5 Aug 2017 11:58:49 +0300
Subject: [PATCH 13/35] Added check for enabled openAPS stale data alarm in NS
---
.../androidaps/plugins/Overview/Notification.java | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java
index f6a524c9d9..a8bdad32c3 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java
@@ -162,11 +162,16 @@ public class Notification {
long bgReadingAgo = System.currentTimeMillis() - bgReading.date;
int bgReadingAgoMin = (int) (bgReadingAgo / (1000 * 60));
// Added for testing
- bgReadingAgoMin = 20;
+ //bgReadingAgoMin = 20;
log.debug("bgReadingAgoMin value is:"+bgReadingAgoMin);
Double threshold = NSSettingsStatus.getInstance().getThreshold("alarmTimeagoWarnMins");
+ boolean openAPSEnabledAlerts = NSSettingsStatus.getInstance().openAPSEnabledAlerts();
+ log.debug("OpenAPS Alerts enabled: "+openAPSEnabledAlerts);
+ // if no thresshold from Ns get it loccally
if(threshold == null) threshold = SP.getDouble(R.string.key_nsalarm_staledatavalue,15D);
- if(bgReadingAgoMin > threshold && SP.getBoolean(R.string.key_nsalarm_staledata, false)){
+ // No threshold of OpenAPS Alarm so using the one for BG
+ // Added OpenAPSEnabledAlerts to alarm check
+ if((bgReadingAgoMin > threshold && SP.getBoolean(R.string.key_nsalarm_staledata, false))||(bgReadingAgoMin > threshold && openAPSEnabledAlerts)){
return true;
}
return false;
From 9546c6f493a526adac1f33a0a544c3db573dbde8 Mon Sep 17 00:00:00 2001
From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com>
Date: Sat, 5 Aug 2017 12:27:43 +0300
Subject: [PATCH 14/35] Update overview_fragment.xml
From 78236b674c23b16a050002c1d1e2228d881fe47c Mon Sep 17 00:00:00 2001
From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com>
Date: Sat, 5 Aug 2017 12:28:28 +0300
Subject: [PATCH 15/35] Update overview_fragment.xml
From 1dd908692473e5a6164256d2a08ca9535fdbc401 Mon Sep 17 00:00:00 2001
From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com>
Date: Mon, 7 Aug 2017 18:53:56 +0300
Subject: [PATCH 16/35] added snoozing if bgReadingAgo is smaller than
threshold
---
.../nightscout/androidaps/plugins/Overview/Notification.java | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java
index a8bdad32c3..9f35599b36 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Overview/Notification.java
@@ -1,3 +1,4 @@
+
package info.nightscout.androidaps.plugins.Overview;
import java.util.Date;
@@ -174,6 +175,9 @@ public class Notification {
if((bgReadingAgoMin > threshold && SP.getBoolean(R.string.key_nsalarm_staledata, false))||(bgReadingAgoMin > threshold && openAPSEnabledAlerts)){
return true;
}
+ //snoozing for threshold
+ SP.putLong("snoozedTo", (long) (bgReading.date+(threshold*1000*60L)));
+ //log.debug("New bg data is available Alarm is snoozed for next "+threshold*1000*60+" seconds");
return false;
}
}
From 122efb1b8e9399e9a7323f6cd694e7688dcb0004 Mon Sep 17 00:00:00 2001
From: RoumenGeorgiev <30696147+RoumenGeorgiev@users.noreply.github.com>
Date: Mon, 7 Aug 2017 20:06:15 +0300
Subject: [PATCH 17/35] Fix for getting double of alarmTimeagoWarnMins
---
.../plugins/NSClientInternal/data/NSSettingsStatus.java | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java
index bb01050702..189474c9c8 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java
@@ -189,8 +189,7 @@ public class NSSettingsStatus {
}
}
if (settingsO.has("alarmTimeagoWarnMins") && what == "alarmTimeagoWarnMins"){
- JSONObject tObject = settingsO.getJSONObject("alarmTimeagoWarnMins");
- Double result = tObject.getDouble(what);
+ Double result = settingsO.getDouble(what);
return result;
}
}
From 0766ac812ce78add753266351170ad39d43d298f Mon Sep 17 00:00:00 2001
From: ellabellakaramella
Date: Thu, 10 Aug 2017 15:15:40 +0200
Subject: [PATCH 18/35] SV translation
---
app/src/main/res/values-sv/strings.xml | 608 +++++++++++++++++++++++++
1 file changed, 608 insertions(+)
create mode 100644 app/src/main/res/values-sv/strings.xml
diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml
new file mode 100644
index 0000000000..84b2b5477c
--- /dev/null
+++ b/app/src/main/res/values-sv/strings.xml
@@ -0,0 +1,608 @@
+
+
+ Avbryt
+ Glimp
+ MM640g
+ Absolut
+ Åtgärd
+ ACT
+ Aktivitet
+ Vuxen
+ Avancerade inställningar
+ Starta om telefonen eller AndroidAPS from systeminställningar
+ Använd alltid kort medel delta istället för enkel delta
+ Användbart när ofiltrerade källor som xDrip ger brusvärden
+ AndroidAPS startar
+ Temp Basal Slut
+ Basal Temp Start
+ Snart daglig max av insulin
+ APS Mode
+ Medel delta
+ Basal
+ Basal E/tim
+ Basal steg
+ Basal saknas i profil. Använder grundbasal
+ BR
+ Basal understiger min.nivå. Ingen profil satt
+ Basalprofil
+ Pump Batteri Urladdat
+ Bolus
+ Bolus Steg
+ Bolus spärr aktiverad
+ Bolus %.2fU korrekt tillförd
+ Ger %.2fU
+ Kommer att ge %.2fU
+ Knapp 1
+ Knapp 2
+ Knapp 3
+ Kalibrering skickad till xDrip
+ Avbryt Temp Basal
+ Kolhydrater
+ Kohydrat spärr aktiverad
+ Careportal
+ Meddelande
+ BG Kontroll
+ Kanyl ålder
+
+ Kolhydrat korrektion
+ CGM Sensor Insättning
+ CGM Sensor Start
+ Combo Bolus
+ Korrektion Bolus
+ Träning
+ Insulin Ålder
+ Insulin Reservoir Byte
+ Måltids Bolus
+ Absolut
+ Kolhydrater
+ KH tid
+ Duration
+ Infört av
+ Tid för händelse
+ Händelse typ
+ Glukos sort
+ Insulin
+ Mätare
+ min
+ Notering
+ Annat
+ Procent
+ Profil
+ Sensor
+ Delad
+ Notering
+ OpenAPS Offline
+ Pump Batteri Ålder
+ Profil Byte
+ Pump Kanyl Byte
+ Fråga
+ CP
+ Bolus för Mellis
+ Temp Basal Slut
+ Temp Basal Start
+ Temp Mål BG
+ Temp Mål BG Slut
+ Ändra inmatning
+ Barn
+ Cirkadisk Profil Procent
+ CPP
+ Ta bort kö
+ Rensa inmatningar
+ Closed Loop
+ COB
+ Kommentar
+ Konfigurationsverktyg
+ APS
+ BG Källa
+ Begränsningar
+ Generell
+ Insulin
+ Loop
+ Nightscout version:
+ Profil
+ Pump
+ KONF
+ Temp Basaler
+ Åtgärd
+ Bekräftelse
+ Sammankopplad
+ Sammankopplar
+ Sammankoppling till pump förlorad
+ Begränsning aktiverad
+ Begränsning Överträdelse
+ Kopierad till Clipboard
+ Kopiera till Clipboard
+ Korr
+ CZ
+ Alarm
+ basal tim
+ Bluetooth Status
+ DanaR Bluetooth Pump
+ kolhydrat
+ Enheter/Dag
+
+ Avaktivera EasyUI mode in pump
+
+ Aktivera förlängd bolus i pump
+ Fel
+ Glukos
+ Historia
+ Larm
+ Basal Timmar
+ Bolusar
+ Kolhydrater
+ Sammankopplar för %d s
+ Daglig insulinmängd
+ Fel
+ Glukos
+ Påfyllnad
+ Stoppa
+ Ladda om
+ Fel på inlagd data
+ Pump IOB
+ Sista bolus
+
+ Lösenord Pump
+ DanaR pump inställningar
+ Påfyllnad
+
+
+ Kumulativ TDD
+ Datum
+ Exponentiellt viktad TDD
+ Gammal Data Vg tryck \"Ladda om\"
+ Ratio
+
+ Använd förlängd bolus med >200%
+ Värde ej korrekt angivet
+ Se profil
+ Se förlängd bolus som %
+ DanaR Korea
+ DanaR profil inställningar
+ DIA (h)
+ Insulinets verkningstid (DIA)
+ DanaR
+ DANA
+ dagar
+ Deutsch
+ Ge nu
+ Delta
+ DEV
+
+ Vald enhet ej funnen
+ DIA
+ Loop Frånkopplad
+ Frånkoppla pump i 1 h
+ Stäng av loop
+ Frånkopplad
+ Frånkopplar
+ Frånkoppla pump i 10 h
+ Frånkoppla pump i 2 h
+ Frånkoppla pump i 30 min
+ Frånkoppla pump i 3 h
+ AVBÖJ
+ Ignorera profilbyten
+ Alla profilbyten ignoreras och aktiv profil används alltid
+ Visa inte detta igen
+ Duration
+ Äta snart
+ Ändra Base-Basal:
+ Engelska
+ Startad
+ Starta loop
+ Aktivera superbolus i kalkylatorn
+ Aktivera superbolus funktionen i kalkylatorn. Aktivera inte innan du förstått hur den fungerar. DEN KAN ORSAKA ÖVERDOSERING AV INSULIN OM INSIKT SAKNAS OM FUNKTIONEN
+ Aktiverad
+ Licensavtal för Slutanvändare
+ JAG FÖRSTÅR OCH GODKÄNNER
+ Ange ny behandling
+ Denna kolumn får ej vara tom
+ Endast siffror får användas
+ \"Endast siffror är tillåtna inom %1$s - %2$\"
+ Ej giltigt telefonnummer
+ Spanska
+ Utför
+ Exportera inställningar till
+ Inställningar exporterade
+ FörlängdBolus
+ Lyckades ej uppdatera basalprofil
+ Snabbverkande Insulin
+ Novorapid, Novolog, Humalog, Apidra
+
+ Data ej funnen
+ Fyll/Förfyll standard insulin mängd
+ Vg försäkra dig om att mängd motsvarar det som är specificerat för just ditt infusionsset
+ Hämtar pump status
+ Glukos
+ Finger
+ Sensor
+ HÖG markering
+ timmar
+ h sedan
+ Importera inställningar från
+ Startar...
+
+ Ogiltig profil !!!
+ IOB
+ Italienska
+ Koreanska
+ Språk
+ Lokal Profil
+ LP
+
+ Loop
+ APS
+ Efter avklarade begränsningar
+ Inställning i pump
+ LOOP
+ LOOP STOPPAD PGA BEGRÄNSNINGAR
+ Loop meny
+ Superbolus (%d m
+ Loop avstängd
+ LÅG markering
+ Svagt Batteri
+ Manual
+ Avbryt
+ Måltid
+ Fattas
+ Om
+ Backup
+ Exit
+ Exportera inställningar
+ Importera inställningar
+ Inställningar
+ Uppdatera behandlingar från NS
+ Återställ Databaser
+ Visa log
+ Testa alarm
+ Nightscout
+ INGEN APS VALD
+ Ingen Bluetooth adapter funnen
+ Ingen ändring behövs
+ Ingen profil laddad ännu från NS
+ Ingen profil vald
+ INGEN PROFIL VALD
+ misslyckat - vg kontrollera telefonen
+ Ej tillgängligt
+ NSCLIENT har inga skrivrättigheter. Fel API secret?
+ Alarm inställningar
+ Medge lokal sändning till andra appar (ex xDrip)
+ Aktivera lokal Broadcasts
+ Markera app start till NS
+ Ingen uppladdning till NS
+ Ingen data sänds till NS. AAPS kommunicerar med NS men inga ändringar görs i NS
+ Använd alltid absoluta värden i basal
+ Endast uppladdning till NS (avaktiverad sync)
+ Endast uppladdning till NS. Fungerar ej med SGV om inte lokal källa som xDrip används. Inte effektiv med Profiler om NS-Profiler används
+ Hög
+ Låg
+ Gammal data
+ NSClient
+ Ange enhetens namn
+ Enhetens namn
+ Ange NS API sectet (min 12 tecken)
+ NS API secret
+ NSClient är inte installerad. Data förlorad!
+ Nightscout URL
+ Enter Nightscout URL
+ URL:
+ NSClient
+ NSCI
+ NS API secret
+ Aktiv profil
+ Basal
+ DIA
+ IC
+ ISF
+ Målvärde
+ Enheter
+ OAPS
+ Mål/Syfte
+ Kontrollera att BG syns i NS, och att pump insulin data laddas upp
+ Ställa in utseende och övervakning, för att sedan kunna analysera basaler och kvoter
+ Du har nått din tillåtna gräns
+ xds
+ xDrip Status (klocka)
+ xDrip Statusline (klocka)
+ xDrip+ inte installerat
+ xDrip
+ Fel lösenord för pump
+ Fel pump program vald
+ Fel lösenord
+ Visa BGI
+ Visa BGI i statusfält
+ WEAR
+ Wear inställningar
+ Visa detaljerad IOB
+ Visa IOB med bolus och basal på klocka
+ Wear
+ Väntar på resultat
+ Väntar på pump. Klicka för att uppdatera
+ Väntar på pump
+ Virtuell
+ Synlig
+ Ladda upp till NS
+ Temp basal
+ SQL Error
+ VPUMP
+ Virtuell pump inställningar
+ OK
+ Reservoir
+ Sista kontakt
+ Programversion
+ Förlängd bolus
+ Batteri
+ Grund basal hastighet
+ Virtuell Pump
+ Uppladdning
+ Uppdaterar basal hastigheter
+ Upp
+ Version av NS som inte stöds
+ Version av NSClient som inte stöds
+ Lås upp inställningar
+ Enheter:
+ Säkerhet vid behandling
+ Max tillåtna KH (g)
+ Max tillåten
+ E
+ TOTAL
+ Korr
+ COB
+ KH
+ Bolus IOB
+ 15min trend
+ BG
+ Basal IOB
+ TREAT
+ Insulin
+ KH
+ Total IOB:
+ Total aktiv IOB:
+ IOB:
+ Insulin:
+ KH:
+ Aktivitet:
+ Behandlingar
+ Bolus ej tillförd
+
+ TT
+ TempMål
+ TB
+ Dur:
+ Kvot:
+ Ins:
+ Total IOB:
+ IOB:
+ Tempbasal ej tillförd
+ Tempbasal
+ Tonåring
+ Mål saknas i profil. Använder grundinställning
+ Mål gränser:
+ Uppdatera profil till pump
+ Stäng av loop i 3 h
+ Stäng av loop i 2 h
+ Stäng av loop i 1 h
+ Stäng av loop i 10 h
+ Superbolus
+ Lyckad
+ Stoppar temp basal
+ Stoppar förlängd bolus
+ Status:
+ Fel duration:
+ Okänt kommando eller fel svar
+ "Temp basal %.2fU/h for %d min startad "
+ "Fel vid Temp basal start "
+ Gick ej att avbryta temp basal
+ Temp basal avbruten
+ För att avbryta loop i %d minuter svara med kod %s
+ SMS
+ Tillåt fjärrkommandon via SMS
+ Fjärrkommandon tillåts ej
+ Kalibrering från andra källor godkänns ej
+ Fjärrbolus är inte tillåtet
+ Fjärrkommandon för att ändra basaler tillåts ej
+ Ej godkänd för SMS
+ Loop avstängd
+ Loop åter startad
+ Loop är aktiverad
+ Loop är avstängd
+ Loop är aktiverat
+ Loop är avstängd
+ Icke giltigt telefonnummer för SMS
+ Kalibrering skickad. xDrip måste tillåta att ta emot kalibrering i inställningarna
+ För att skicka kalibrering %.2f svar med kod %s
+ xDrip tar inte emot kalibreringar
+ För att ge bolus %.2fU svar med kod %s
+ Bolus ej given
+ Bolus %.2fU tillförd
+ För att stoppa temp basal svara med kod %s
+ För att starta basal %.2fU/h svara med kod %s
+ +XXXXXXXXXX;+YYYYYYYYYY
+ Tillåtna telefonnummer
+ SMS Tjänst
+ Senaste BG:
+ Enkel profil
+ Visa kö
+ Lösenord för inställningar
+ Ställ in förlängd bolus
+ inställningar importerade
+ Ställ in ny förlängd bolus:
+ Acceptera ny temp basal:
+ SKICKA TILL PUMP
+ Skicka kalibrering %.1f till xDrip?
+ SKICKA
+ Spara
+ Säkerhet
+ Återuppta
+ Resultat
+ Gå ur applikationen för att starta inställning
+ Omstart
+ Vill du verkligen återställa databasen?
+ Återsänd all Data
+ Ta bort sparad data:
+ Ladda om profil
+ Uppdatera händelser från NS
+ Orsak
+ RAT
+ Hastighet
+ Kalkylator inställningar
+ Kalkylator
+ Kö:
+ Pump stoppad. Klicka för ladda om status
+ Pump stoppad
+ Pump avstängd
+ Pumpfel
+ Pump upptagen
+ Pump inte igångsatt, ingen profil vald
+ Pump inte startad
+ Pump
+ NSPROFIL
+ NS Profil
+ ProfilByte
+ Basal profil i pump uppdaterad
+ Ny basal profil misslyckades
+ Profil
+ Prime/Fyll
+ Gränsvärden för Visualisering
+ Högt och lågt värde för graf i översikten och i smartwatch
+ Vg ge tillåtelse
+ Procent
+ Procentfaktor med vilken basal profilen kommer att bli multiplicerad
+ Pausad
+ Vg ange personens ålder för inställningar av gränser
+ Personens ålder
+ TempBasal
+ Hemma
+ Ta bort
+ Editera
+ % (100% = current)
+ Basal värde
+ Stoppa Förlängd Bolus
+ Förlängd Bolus
+ Lägg till
+ Giltig:
+ KH:
+ Knapp text:
+ Kalibrering
+ Kalibrering
+ Kalkylator
+ STOPP NEDTRYCKT
+ Stoppad
+ Stopp
+ Kommer tillföra %.2fU
+ Tillförd
+ Bolus
+ Översikt
+ Andra
+ Ny behandlingsrekommendation tillgänglig
+ Open Loop
+ Värde %s är utanför gränserna
+ %.2f begränsad till %.2f
+ Målvärde för kalkylatorn
+ Kör nu
+ Fråga
+ Profil
+ Ingen pump tillgänglig
+ Ingen profil tillänglig
+ Ingen glukos data tillänglig
+ Nedre målvärde
+ Måltids data
+ Maximal basal IOB som OpenAPS kan ge [E]
+ Detta värde kallas Max IOB i OpenAPS. Det är ställt till noll från start. Efter flera dagar till veckor, beroende på hur du känner, kan du välja att justera denna.
+ Max E/h som Temp Basal kan ställas in på
+ Detta värde kallas max basal inom OpenAPS
+ Nedre BG gräns för önskat BG
+ Senaste körning
+ Senast startad
+ IOB data
+ Ange värden
+ Övre BG gräns för önskat BG
+ Status Glukos
+ Plug in är avaktiverad
+ Nuvarande temp
+ Autosens data
+ OpenAPS MA
+ Använd AMA autosens funktioner
+ Inställt värde: 3.0 Detta är grundinställning för KH.absorption per 5 min. 3 mg/dl/5 min. Detta styr hur snabbt COB minskar, dvs hur snabbt programmet kalkylerar att KH tagits upp, och påverkar BG framöver när BG faller mer än väntat, eller inte stiger som väntat\"
+ Inställt värde: 3 Detta är en grundsten i OpenAPS säkerhetsaspekt. Detta begränsar din basal till att vara 3x din största basalhastighet. Du behöver ofta inte ändra detta värde, Läs på och förstå skilnaden på 3x nuvarande och 3x daglig max som säkerhetsinställningar.
+ Viktigt! Normalt behöver du inte ändra dessa värden. Vg KLICKA HÄR och LÄS texten och försäkra dig om att du FÖRSTÅTT innan du ändrar dessa värden.
+ Inställt värde: 4 Detta är andra delen i grunden för säkerhet i OpenAPS, dvs kring 3x och 4 x daglig och nuvarnde basaler. Detta värde innebär att din nuvarande basal, oberoende av din max basalhastighet, kan aldrig bli högre än 4x nuvarande basal. Detta för att undvika att man farliga inställningar. Om man når taket i denna inställning så kanske ändringar i andra inställningar behövs. De flesta behöver inte ändra denna inställning.
+ Inställt värde: 2 Bolus snooze är aktivt efter att du givit en måltidsbolus, detta för att inte loop ska lågtempa när du just ätit. I detta exempel och grundvärde är 2; innebär att DIA på 3 tim kommer bolus snooze kommer att fasas ut under 1,5 tim (3DIA/2).
+ Antal timmar för beräkning av känslighet (KH absorptionstid är exkluderad)
+ Intervall för autosens (h)
+ Inställt värde: 0.7 Detta är den andra delen av autosens säkerhetsaspekt, den sätter en gräns på hur lågt autosens kan justera basaler, och hur högt den kan justera ISF och BG mål
+ Inställt värde: 1.2 Detta är inställt värde för hur mycket autosens kan multiplicera uppåt (snart även autotune) dvs max 20%, med 1.2 kan alltså autosens öka dina basaler med max 20%, denna gräns gäller alltså hur högt autosens kan justera dina basaler men även hur lågt den kan justera ISF och hur lågt den kan sätta BG mål.
+ Inställt värde: sant Detta för att tillåta autosens justera BG målvärden, tillsammans med ISF och basaler
+ OpenAPS AMA
+ OAPS
+ OpenAPS
+ Öppna inställningar på Wear
+ Pågående rapportering
+ GAMMAL DATA
+ OK
+ Ocklusion
+ M/S
+ Pump status tillgänglig i NS
+ Mål/syfte
+ Minimal duration
+ Manuell aktivering
+ Spärr:
+ Godkänn
+ Starta
+ BG är tillängligt i NS
+ Aktiverar extra funktioner som kan användas dagitd, såsom avancerad måltids assist
+ Justerar basaler och ration om det behövs, aktivera sedan auto-sens
+ 1 veckas framgångsrik dagtids looping där alla måltider lagts in
+ Finjustering av closed loop, gradvis ökande IOB och minskande önskat BG målvärde
+ Kör några dagar, och åtminstone en natt utan larm för lågt BG, innan du sänker BG målvärde
+ Börja använda closed loop med aktiverad funktion att stänga av vid lågt BG
+ Aktivera closed loop med max IOB=0 i några dagar till dess systemet inte stänger av pga lågt BG för många gånger
+ Förstå din open loop, och hur den föreslår temp basaler
+ Utifrån vad du nu lärt dig, besluta vilken max basal du vil ha, ställ in det både i inställningar i APS och i den pump.
+ Starta med open loop
+ Starta Open loop och använd det några dagar, försök att ge många föreslagna temp basaler
+ Tid i timmar när alla KH väntas vara absorberade
+ Måltids max absorptions tid (h)
+ Absorptions inställningar
+ AndroidAPS
+ Bulgariska
+ PUMP
+ Batteribyte Pump
+ Sensor ålder
+ SAGE
+
+ Måste vara aktiverad för att kunna skicka värden till pumpen
+ Värden sparas inte
+ Möjligen felvärde om man använder bolus för att priming/fyllning!
+
+ Ändra Base-IC:
+ Ändra Base-ISF:
+ Grekiska
+ MUST NOT BE USED TO MAKE MEDICAL DECISIONS. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM “AS IS” WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+ ISF fattas i profilen. Använder värde från grundinställning.
+ Lås skärm
+ Lås
+ mmol/l
+ %dmin sedan
+ mg/dl
+ OK
+ MDI
+
+ NSClient
+ Autoscroll
+ http://openaps.readthedocs.io/en/latest/docs/walkthrough/phase-3/beyond-low-glucose-suspend.html
+ Basal typ
+ SENS
+ Genom att slå på Autosens funktionen, kom ihåg att skriva in alla KH. Annars kommer programmet göra fel i beräkningar av känslighet (ISF)!!
+ Sensitivity AAPS
+ Sensitivity Oref0
+ Sensitivity WeightedAverage
+ Ställa in temp basal
+ SP
+ BG:
+ Basal:
+ Bolus:
+ Delta:
+ IOB:
+ %dmin sedan
+
\ No newline at end of file
From f703c82ca7469022c824f1f9098a7b0afd891040 Mon Sep 17 00:00:00 2001
From: Milos Kozak
Date: Thu, 10 Aug 2017 17:28:41 +0200
Subject: [PATCH 19/35] microbolus calculation
---
.../info/nightscout/androidaps/data/IobTotal.java | 12 ++++++++++++
.../plugins/Treatments/TreatmentsPlugin.java | 9 +++++++--
2 files changed, 19 insertions(+), 2 deletions(-)
diff --git a/app/src/main/java/info/nightscout/androidaps/data/IobTotal.java b/app/src/main/java/info/nightscout/androidaps/data/IobTotal.java
index cd5df466f0..bd924d35b5 100644
--- a/app/src/main/java/info/nightscout/androidaps/data/IobTotal.java
+++ b/app/src/main/java/info/nightscout/androidaps/data/IobTotal.java
@@ -16,6 +16,10 @@ public class IobTotal {
public double netbasalinsulin;
public double hightempinsulin;
+ // oref1
+ public double microBolusInsulin;
+ public double microBolusIOB;
+
public double netInsulin = 0d; // for calculations from temp basals only
public double netRatio = 0d; // net ratio at start of temp basal
@@ -30,6 +34,8 @@ public class IobTotal {
this.basaliob = 0d;
this.netbasalinsulin = 0d;
this.hightempinsulin = 0d;
+ this.microBolusInsulin = 0d;
+ this.microBolusIOB = 0d;
this.time = time;
}
@@ -42,6 +48,8 @@ public class IobTotal {
hightempinsulin += other.hightempinsulin;
netInsulin += other.netInsulin;
extendedBolusInsulin += other.extendedBolusInsulin;
+ microBolusInsulin += other.microBolusInsulin;
+ microBolusIOB += other.microBolusIOB;
return this;
}
@@ -53,6 +61,8 @@ public class IobTotal {
result.basaliob = basalIob.basaliob;
result.netbasalinsulin = basalIob.netbasalinsulin;
result.hightempinsulin = basalIob.hightempinsulin;
+ result.microBolusInsulin = bolusIOB.microBolusInsulin + basalIob.microBolusInsulin;
+ result.microBolusIOB = bolusIOB.microBolusIOB + basalIob.microBolusIOB;
return result;
}
@@ -63,6 +73,8 @@ public class IobTotal {
this.basaliob = Round.roundTo(this.basaliob, 0.001);
this.netbasalinsulin = Round.roundTo(this.netbasalinsulin, 0.001);
this.hightempinsulin = Round.roundTo(this.hightempinsulin, 0.001);
+ this.microBolusInsulin = Round.roundTo(this.microBolusInsulin, 0.001);
+ this.microBolusIOB = Round.roundTo(this.microBolusIOB, 0.001);
return this;
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java
index 8a999cbcd6..34fca17d27 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Treatments/TreatmentsPlugin.java
@@ -183,8 +183,13 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
Iob tIOB = t.iobCalc(time, dia);
total.iob += tIOB.iobContrib;
total.activity += tIOB.activityContrib;
- Iob bIOB = t.iobCalc(time, dia / SP.getDouble("openapsama_bolussnooze_dia_divisor", 2.0));
- total.bolussnooze += bIOB.iobContrib;
+ if (!t.isSMB) {
+ Iob bIOB = t.iobCalc(time, dia / SP.getDouble("openapsama_bolussnooze_dia_divisor", 2.0));
+ total.bolussnooze += bIOB.iobContrib;
+ } else {
+ total.basaliob += t.insulin;
+ total.microBolusIOB += tIOB.iobContrib;
+ }
}
if (!MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses())
From 33f5e97ac64d96e4816cee47602e6e2b8294eb5a Mon Sep 17 00:00:00 2001
From: diabetesdt1
Date: Thu, 10 Aug 2017 21:12:56 +0200
Subject: [PATCH 20/35] Update strings.xml
add more german translation and typos fixed
---
app/src/main/res/values-de/strings.xml | 173 ++++++++++++++++++++++---
1 file changed, 158 insertions(+), 15 deletions(-)
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index ec8cf8088a..96275dc3d4 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -55,7 +55,7 @@
Temp Basals
Delta
Dauer
- English
+ Englisch
APS
Glukose
Backup
@@ -144,7 +144,7 @@
NO APS SELECTED OR PROVIDED RESULT
Test Alarm
Avg. delta
- Bolus constraint applied
+ Bolus Einschränkung angewendet
Ankündigung
BZ Check
Kohlehydrat Korrektur
@@ -160,7 +160,7 @@
Treatments
Constraint applied!
Constraints violation
- Czech
+ Tschechisch
Gesetzt durch Pumpe
LOOP DISABLED BY CONSTRAINTS
After processed constraints
@@ -172,7 +172,7 @@
Erneure treatments von NS
Exit
Fehlend
- Enabled
+ aktiviert
Eingabe neues treatment
Einstellungen exportieren nach
Datei nicht gefunden
@@ -184,7 +184,7 @@
Deutsch
Max U/hr die man für eine Temp Basal setzen kann
Maximale Menge von nicht bolus IOB die OpenAPs abgeben kann
- Bulgarian
+ Bulgarisch
Nightscout
+XXXXXXXXXX;+YYYYYYYYYY
Absolut
@@ -231,7 +231,7 @@
Kein Bluetoothadapter gefunden
Remote Bolus nicht erlaubt
Um Bolus %.2fU bitte mit %s antworten
- Korean
+ Koreanisch
Limit erreicht
Falsches Pumpen-Passwort!
Warte auf Pumpe. Click to refresh.
@@ -278,7 +278,7 @@
%.2fU werden abgegeben werden
Vorfüllen / Füllen
Hochladen
- Spanish
+ Spanisch
Basalrate:
Basisprofil:
Pumpenbatterie entladen
@@ -307,9 +307,9 @@
"TT"
"TB"
"SMS"
- "SP"
+ SP
"PROF"
- "HOME"
+ HOME
"OBJ"
"OAPS"
"LOOP"
@@ -350,7 +350,7 @@
Zeige detailliertes IOB
Trenne IOB in Bolus- und Basal-IOB auf dem Watchface
Falsches Passwort
- Italian
+ Italienisch
Glimp
MM640g
Zeit in Stunden in der zu erwarten ist, dass alle Kohlenhydrate resorbiert sein werden
@@ -358,7 +358,7 @@
Resorptions-Einstellungen
Aktivität
Erwachsener
- Erweiter
+ Erweiterte Einstelungen
AndroidAPS
BAS
Basal-Schritt
@@ -368,11 +368,11 @@
Bolus-Schritt
Werde %.2fE abgeben
AKTIVITÄT & FEEDBACK
- Katheter-Liegedauer
+ Katheteralter
CAGE
CARBS & BOLUS
CGM & OPENAPS
-
+ Insulinalter
Dauer [min]
pausiert
Patientenalter
@@ -383,7 +383,7 @@
Tempbasal Abgabe-Fehler
TempZiel
Zeit in Stunden um die das profil zylindrisch verschoben wird.
-
+ 15Min Trend
COB
Nicht-unterstütze Nightscout-Version
Uploader
@@ -393,5 +393,148 @@
Virtuelle Pumpe Einstellungen
Status zu NS hochladen
Superbolus
-
+ Pausiere Loop für 10h
+ Anzahl %d Einträge. Aktuelle Einträge:
+ IAGE
+ Batteriealter
+ PUMP
+ Pumpen Batterie Wechsel
+ Sensoralter
+ Insulin
+ Es sind nicht alle Profile geladen!
+ Aktivierung wird benötigt um Werte an die Pumpe zu senden!
+ Werte nicht gespeichert!
+ Aktiviere Extended Bolus in der Pumpe
+ DanaR Stats
+ # Tage
+ Basal
+ Bolus
+ Gewichtung
+ Zeige Extended Bolus als % an
+ DanaR Korean
+ DanaRv2
+ Abgeben
+ DEV
+ Gerät
+ DIA:
+ Deaktiviere Loop
+ Trenne
+ Trenne Pumpe für 10h
+ Trenne Pumpe für 1h
+ Trenne Pumpe für 2h
+ Trenne Pumpe für 30Min
+ Trenne Pumpe für 3h
+ Ignoriere Profilwechsel
+ Alle Profilwechsel werden ignorierd und nur das aktive Profil wird verwendet
+ Nicht erneut anzeigen
+ Bald essen
+ Bearbeite Basis-Basal:
+ Griechisch
+ aktiviere Loop
+ Aktiviere SuperBolus im Wizard
+ Führe aus
+ ExtendedBolus
+ Fast Acting Insulin
+ Novorapid, Novolog, Humalog
+ Fast Acting Insulin Prolonged
+ Hole Pumpenstatus
+ Stunden
+ Initialisierung...
+ Ungültiges oder defektes Profil!!!
+ IOB
+ Lokales Profil
+ Sperrbildschirm
+ Loop Menü
+ Superbolus (%d m)
+ Loop pausiert
+ pausiert (%d m)
+ Abbrechen
+ OK
+ mg/dl
+ mmol/l
+ Über
+ Logs anzeigen
+ nicht erfolgreich - Bitte Telefon prüfen
+ Nicht verfügbar
+ NSCLIENT hat keine Schreibrechte. Falscher API-Key?
+ Alarm Optionen
+ Aktiviere Broadcast für andere Apps (z.B. xDrip).
+ Aktiviere lokalen Broadcast.
+ Logge App-Start in NS
+ Kein Upload zu NS
+ Alle an NS gesendete Daten verworfen. AAPS ist verbunden, aber keine Änderungen in NS
+ Hoch
+ Niedrig
+ Gesetzt zu %f
+ Sehr hoch
+ Sehr niedrig
+ Autoscroll
+ Gerätenamen eingeben
+ Gerätename
+ NS API-Key eingeben (min 12 Zeichen)
+ NS API-Key
+ NS API-Key
+ URL:
+ Nightscout URL eingeben
+ Nightscout URL
+ Verifziere, das der BZ und Pumpen Insulin Daten in Nightscout erfolgreich hoch geladen wurden
+ Konfiguriere Anzeige und das Monitoring und analysiere Basal und die Ratio
+ Lasse den OpenLoop Modus für ein paar Tage laufen und setzte manuell temp Basal-Raten
+ Starte ein OpenLoop
+ ALTE DATEN
+ Laufende Benachrichtigungen
+ Öffne Einstellungen auf der Uhr
+ OpenAPS
+ OAPS
+ OpenAPS AMA
+
+ Skript Debug
+ Wert %s ist ausserhalb des festen Limits.
+ Kalibrierung
+ Kalibrierung
+ Button Text:
+ Extended Bolus abbrechen
+ Basal Wert [U/h]
+
+
+ Profil
+ Setzten vom Basal Profil fehlgeschlagen
+ Basal Profil in der Pumpe erfolgreich aktualisiert
+ Profilwechsel
+ Pumpe
+ Pumpe nicht initialisiert!
+ Pumpe ist nicht initialisiert, Profil nicht gesetzt!
+ Pumpe stoppen
+ Pumpe pausiert
+ Pumpe pausiert. Klicken zum aktualisieren des Status
+ Queue:
+ QuickWizard
+ Aktualisiere Einträge von NS
+ Lösche Eintrag:
+ Alle Daten erneut senden
+ Möchtest du die Datenbank wirklich zurücksetzten?
+ Restart
+ Beende Applikation um neue Einstellungen zu laden.
+ Fortsetzten
+ Russisch
+ Kalibrierung %.1f an xDrip senden?
+ Passwort für die Einstellungen
+ Setzte temp Basal
+ Kurze Tab-Überschriften
+ Zeige Warteschlange
+ BZ
+ Basal:
+ Bolus:
+ Delta:
+ IOB:
+ Letzter BZ:
+ Status:
+ Stoppe Extended Bolus
+ Stoppe temp Basal
+ Pausiere Loop für 1h
+ Pausiere Loop für 2h
+ Pausiere Loop für 3h
+ Schwedisch
+ Aktualisere Basal Raten
+ Übersicht Benachrichtigungen
From 8df0ccdbb192c4d2ff8d15e1bfbbfcf69688b296 Mon Sep 17 00:00:00 2001
From: diabetesdt1
Date: Thu, 10 Aug 2017 21:28:09 +0200
Subject: [PATCH 21/35] Update strings.xml
rollback language-names
---
app/src/main/res/values-de/strings.xml | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 96275dc3d4..76b7cc3811 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -55,7 +55,7 @@
Temp Basals
Delta
Dauer
- Englisch
+ English
APS
Glukose
Backup
@@ -160,7 +160,7 @@
Treatments
Constraint applied!
Constraints violation
- Tschechisch
+ Czech
Gesetzt durch Pumpe
LOOP DISABLED BY CONSTRAINTS
After processed constraints
@@ -181,10 +181,10 @@
Einstellungen importiert
Einstellungen exportieren
Einstellungen importieren
- Deutsch
+ German
Max U/hr die man für eine Temp Basal setzen kann
Maximale Menge von nicht bolus IOB die OpenAPs abgeben kann
- Bulgarisch
+ Bulgarian
Nightscout
+XXXXXXXXXX;+YYYYYYYYYY
Absolut
@@ -231,7 +231,7 @@
Kein Bluetoothadapter gefunden
Remote Bolus nicht erlaubt
Um Bolus %.2fU bitte mit %s antworten
- Koreanisch
+ Korean
Limit erreicht
Falsches Pumpen-Passwort!
Warte auf Pumpe. Click to refresh.
@@ -278,7 +278,7 @@
%.2fU werden abgegeben werden
Vorfüllen / Füllen
Hochladen
- Spanisch
+ Spanish
Basalrate:
Basisprofil:
Pumpenbatterie entladen
@@ -350,7 +350,7 @@
Zeige detailliertes IOB
Trenne IOB in Bolus- und Basal-IOB auf dem Watchface
Falsches Passwort
- Italienisch
+ Italian
Glimp
MM640g
Zeit in Stunden in der zu erwarten ist, dass alle Kohlenhydrate resorbiert sein werden
@@ -394,7 +394,7 @@
Status zu NS hochladen
Superbolus
Pausiere Loop für 10h
- Anzahl %d Einträge. Aktuelle Einträge:
+ Insgesamt %d Einträge. Aktuelle Einträge:
IAGE
Batteriealter
PUMP
@@ -429,7 +429,7 @@
Nicht erneut anzeigen
Bald essen
Bearbeite Basis-Basal:
- Griechisch
+ Greek
aktiviere Loop
Aktiviere SuperBolus im Wizard
Führe aus
@@ -516,7 +516,7 @@
Restart
Beende Applikation um neue Einstellungen zu laden.
Fortsetzten
- Russisch
+ Russian
Kalibrierung %.1f an xDrip senden?
Passwort für die Einstellungen
Setzte temp Basal
@@ -534,7 +534,7 @@
Pausiere Loop für 1h
Pausiere Loop für 2h
Pausiere Loop für 3h
- Schwedisch
+ Schwedish
Aktualisere Basal Raten
Übersicht Benachrichtigungen
From c5b5d65efc707ef61aa4140c306c484f6526ac17 Mon Sep 17 00:00:00 2001
From: diabetesdt1
Date: Thu, 10 Aug 2017 21:29:41 +0200
Subject: [PATCH 22/35] Update strings.xml
---
app/src/main/res/values-de/strings.xml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 76b7cc3811..c34392d598 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -399,7 +399,7 @@
Batteriealter
PUMP
Pumpen Batterie Wechsel
- Sensoralter
+ SAGE
Insulin
Es sind nicht alle Profile geladen!
Aktivierung wird benötigt um Werte an die Pumpe zu senden!
@@ -537,4 +537,5 @@
Schwedish
Aktualisere Basal Raten
Übersicht Benachrichtigungen
+ Sensoralter
From d78928a26441e15379d9b3676a37c9031c7233a8 Mon Sep 17 00:00:00 2001
From: diabetesdt1
Date: Thu, 10 Aug 2017 21:40:03 +0200
Subject: [PATCH 23/35] Update strings.xml
typo fixed and empty strings removed
---
app/src/main/res/values-de/strings.xml | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index c34392d598..20ae86677c 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -477,8 +477,8 @@
URL:
Nightscout URL eingeben
Nightscout URL
- Verifziere, das der BZ und Pumpen Insulin Daten in Nightscout erfolgreich hoch geladen wurden
- Konfiguriere Anzeige und das Monitoring und analysiere Basal und die Ratio
+ Verifziere, dass der BZ und Pumpen Insulin Daten in Nightscout erfolgreich hoch geladen wurden
+ Konfiguriere Anzeige und das Monitoring und analysiere Basal und die Faktoren
Lasse den OpenLoop Modus für ein paar Tage laufen und setzte manuell temp Basal-Raten
Starte ein OpenLoop
ALTE DATEN
@@ -487,16 +487,13 @@
OpenAPS
OAPS
OpenAPS AMA
-
Skript Debug
- Wert %s ist ausserhalb des festen Limits.
+ Wert %s ist außerhalb des festen Limits.
Kalibrierung
Kalibrierung
Button Text:
Extended Bolus abbrechen
Basal Wert [U/h]
-
-
Profil
Setzten vom Basal Profil fehlgeschlagen
Basal Profil in der Pumpe erfolgreich aktualisiert
From 3ca058ce60c609ba2a08304fd986b8b4e4b9205d Mon Sep 17 00:00:00 2001
From: Milos Kozak
Date: Thu, 10 Aug 2017 22:33:38 +0200
Subject: [PATCH 24/35] SV language cleanup
---
app/src/main/res/values-sv/strings.xml | 64 ++++++++------------------
1 file changed, 20 insertions(+), 44 deletions(-)
diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml
index 84b2b5477c..5b00248db8 100644
--- a/app/src/main/res/values-sv/strings.xml
+++ b/app/src/main/res/values-sv/strings.xml
@@ -13,8 +13,6 @@
Använd alltid kort medel delta istället för enkel delta
Användbart när ofiltrerade källor som xDrip ger brusvärden
AndroidAPS startar
- Temp Basal Slut
- Basal Temp Start
Snart daglig max av insulin
APS Mode
Medel delta
@@ -29,9 +27,9 @@
Bolus
Bolus Steg
Bolus spärr aktiverad
- Bolus %.2fU korrekt tillförd
- Ger %.2fU
- Kommer att ge %.2fU
+ Bolus %.2fU korrekt tillförd
+ Ger %.2fU
+ Kommer att ge %.2fU
Knapp 1
Knapp 2
Knapp 3
@@ -43,7 +41,6 @@
Meddelande
BG Kontroll
Kanyl ålder
-
Kolhydrat korrektion
CGM Sensor Insättning
CGM Sensor Start
@@ -63,7 +60,6 @@
Glukos sort
Insulin
Mätare
- min
Notering
Annat
Procent
@@ -120,9 +116,7 @@
DanaR Bluetooth Pump
kolhydrat
Enheter/Dag
-
Avaktivera EasyUI mode in pump
-
Aktivera förlängd bolus i pump
Fel
Glukos
@@ -131,7 +125,7 @@
Basal Timmar
Bolusar
Kolhydrater
- Sammankopplar för %d s
+ Sammankopplar för %d s
Daglig insulinmängd
Fel
Glukos
@@ -141,18 +135,14 @@
Fel på inlagd data
Pump IOB
Sista bolus
-
Lösenord Pump
DanaR pump inställningar
Påfyllnad
-
-
Kumulativ TDD
Datum
Exponentiellt viktad TDD
Gammal Data Vg tryck \"Ladda om\"
Ratio
-
Använd förlängd bolus med >200%
Värde ej korrekt angivet
Se profil
@@ -168,7 +158,6 @@
Ge nu
Delta
DEV
-
Vald enhet ej funnen
DIA
Loop Frånkopplad
@@ -198,7 +187,7 @@
Ange ny behandling
Denna kolumn får ej vara tom
Endast siffror får användas
- \"Endast siffror är tillåtna inom %1$s - %2$\"
+ Endast siffror är tillåtna inom %1$s - %2$s
Ej giltigt telefonnummer
Spanska
Utför
@@ -208,7 +197,6 @@
Lyckades ej uppdatera basalprofil
Snabbverkande Insulin
Novorapid, Novolog, Humalog, Apidra
-
Data ej funnen
Fyll/Förfyll standard insulin mängd
Vg försäkra dig om att mängd motsvarar det som är specificerat för just ditt infusionsset
@@ -221,7 +209,6 @@
h sedan
Importera inställningar från
Startar...
-
Ogiltig profil !!!
IOB
Italienska
@@ -229,7 +216,6 @@
Språk
Lokal Profil
LP
-
Loop
APS
Efter avklarade begränsningar
@@ -237,7 +223,7 @@
LOOP
LOOP STOPPAD PGA BEGRÄNSNINGAR
Loop meny
- Superbolus (%d m
+ Superbolus (%d m
Loop avstängd
LÅG markering
Svagt Batteri
@@ -364,7 +350,6 @@
Aktivitet:
Behandlingar
Bolus ej tillförd
-
TT
TempMål
TB
@@ -390,11 +375,11 @@
Status:
Fel duration:
Okänt kommando eller fel svar
- "Temp basal %.2fU/h for %d min startad "
- "Fel vid Temp basal start "
+ Temp basal %.2fU/h for %d min startad
+ Fel vid Temp basal start
Gick ej att avbryta temp basal
Temp basal avbruten
- För att avbryta loop i %d minuter svara med kod %s
+ För att avbryta loop i %d minuter svara med kod %s
SMS
Tillåt fjärrkommandon via SMS
Fjärrkommandon tillåts ej
@@ -410,13 +395,13 @@
Loop är avstängd
Icke giltigt telefonnummer för SMS
Kalibrering skickad. xDrip måste tillåta att ta emot kalibrering i inställningarna
- För att skicka kalibrering %.2f svar med kod %s
+ För att skicka kalibrering %.2f svar med kod %s
xDrip tar inte emot kalibreringar
- För att ge bolus %.2fU svar med kod %s
+ För att ge bolus %.2fU svar med kod %s
Bolus ej given
- Bolus %.2fU tillförd
+ Bolus %.2fU tillförd
För att stoppa temp basal svara med kod %s
- För att starta basal %.2fU/h svara med kod %s
+ För att starta basal %.2fU/h svara med kod %s
+XXXXXXXXXX;+YYYYYYYYYY
Tillåtna telefonnummer
SMS Tjänst
@@ -429,7 +414,7 @@
Ställ in ny förlängd bolus:
Acceptera ny temp basal:
SKICKA TILL PUMP
- Skicka kalibrering %.1f till xDrip?
+ Skicka kalibrering %.1f till xDrip?
SKICKA
Spara
Säkerhet
@@ -476,7 +461,6 @@
Ta bort
Editera
% (100% = current)
- Basal värde
Stoppa Förlängd Bolus
Förlängd Bolus
Lägg till
@@ -489,41 +473,37 @@
STOPP NEDTRYCKT
Stoppad
Stopp
- Kommer tillföra %.2fU
+ Kommer tillföra %.2fU
Tillförd
Bolus
Översikt
Andra
Ny behandlingsrekommendation tillgänglig
Open Loop
- Värde %s är utanför gränserna
- %.2f begränsad till %.2f
- Målvärde för kalkylatorn
+ Värde %s är utanför gränserna
+ %.2f begränsad till %.2f
Kör nu
Fråga
Profil
Ingen pump tillgänglig
Ingen profil tillänglig
Ingen glukos data tillänglig
- Nedre målvärde
Måltids data
Maximal basal IOB som OpenAPS kan ge [E]
Detta värde kallas Max IOB i OpenAPS. Det är ställt till noll från start. Efter flera dagar till veckor, beroende på hur du känner, kan du välja att justera denna.
Max E/h som Temp Basal kan ställas in på
Detta värde kallas max basal inom OpenAPS
- Nedre BG gräns för önskat BG
Senaste körning
Senast startad
IOB data
Ange värden
- Övre BG gräns för önskat BG
Status Glukos
Plug in är avaktiverad
Nuvarande temp
Autosens data
OpenAPS MA
Använd AMA autosens funktioner
- Inställt värde: 3.0 Detta är grundinställning för KH.absorption per 5 min. 3 mg/dl/5 min. Detta styr hur snabbt COB minskar, dvs hur snabbt programmet kalkylerar att KH tagits upp, och påverkar BG framöver när BG faller mer än väntat, eller inte stiger som väntat\"
+ Inställt värde: 3.0 Detta är grundinställning för KH.absorption per 5 min. 3 mg/dl/5 min. Detta styr hur snabbt COB minskar, dvs hur snabbt programmet kalkylerar att KH tagits upp, och påverkar BG framöver när BG faller mer än väntat, eller inte stiger som väntat"
Inställt värde: 3 Detta är en grundsten i OpenAPS säkerhetsaspekt. Detta begränsar din basal till att vara 3x din största basalhastighet. Du behöver ofta inte ändra detta värde, Läs på och förstå skilnaden på 3x nuvarande och 3x daglig max som säkerhetsinställningar.
Viktigt! Normalt behöver du inte ändra dessa värden. Vg KLICKA HÄR och LÄS texten och försäkra dig om att du FÖRSTÅTT innan du ändrar dessa värden.
Inställt värde: 4 Detta är andra delen i grunden för säkerhet i OpenAPS, dvs kring 3x och 4 x daglig och nuvarnde basaler. Detta värde innebär att din nuvarande basal, oberoende av din max basalhastighet, kan aldrig bli högre än 4x nuvarande basal. Detta för att undvika att man farliga inställningar. Om man når taket i denna inställning så kanske ändringar i andra inställningar behövs. De flesta behöver inte ändra denna inställning.
@@ -564,17 +544,14 @@
Tid i timmar när alla KH väntas vara absorberade
Måltids max absorptions tid (h)
Absorptions inställningar
- AndroidAPS
Bulgariska
PUMP
Batteribyte Pump
Sensor ålder
SAGE
-
Måste vara aktiverad för att kunna skicka värden till pumpen
Värden sparas inte
Möjligen felvärde om man använder bolus för att priming/fyllning!
-
Ändra Base-IC:
Ändra Base-ISF:
Grekiska
@@ -583,11 +560,10 @@
Lås skärm
Lås
mmol/l
- %dmin sedan
+ %dmin sedan
mg/dl
OK
MDI
-
NSClient
Autoscroll
http://openaps.readthedocs.io/en/latest/docs/walkthrough/phase-3/beyond-low-glucose-suspend.html
@@ -604,5 +580,5 @@
Bolus:
Delta:
IOB:
- %dmin sedan
+ %dmin sedan
\ No newline at end of file
From 0b62669079b8046dc09e0125e0ccaae39eac59a7 Mon Sep 17 00:00:00 2001
From: diabetesdt1
Date: Fri, 11 Aug 2017 07:30:53 +0200
Subject: [PATCH 25/35] Update strings.xml
typo fixed
---
app/src/main/res/values-de/strings.xml | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 20ae86677c..994413d12e 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -391,10 +391,10 @@
EXT
Firmware
Virtuelle Pumpe Einstellungen
- Status zu NS hochladen
+ Status zu Nightscout hochladen
Superbolus
Pausiere Loop für 10h
- Insgesamt %d Einträge. Aktuelle Einträge:
+ Insgesamt %d Einträge. Aktueller Wert:
IAGE
Batteriealter
PUMP
@@ -460,9 +460,9 @@
Alarm Optionen
Aktiviere Broadcast für andere Apps (z.B. xDrip).
Aktiviere lokalen Broadcast.
- Logge App-Start in NS
- Kein Upload zu NS
- Alle an NS gesendete Daten verworfen. AAPS ist verbunden, aber keine Änderungen in NS
+ Logge App-Start in Nightscout
+ Kein Upload zu Nightscout
+ Alle an Nightscout gesendete Daten verworfen. AAPS ist verbunden, aber keine Änderungen in NS
Hoch
Niedrig
Gesetzt zu %f
@@ -471,17 +471,17 @@
Autoscroll
Gerätenamen eingeben
Gerätename
- NS API-Key eingeben (min 12 Zeichen)
- NS API-Key
- NS API-Key
+ Nightscout API-Key eingeben (min 12 Zeichen)
+ Nightscout API-Key
+ Nightscout API-Key
URL:
Nightscout URL eingeben
Nightscout URL
- Verifziere, dass der BZ und Pumpen Insulin Daten in Nightscout erfolgreich hoch geladen wurden
+ Verifiziere, dass der BZ und Pumpen Insulin Daten in Nightscout erfolgreich hoch geladen wurden
Konfiguriere Anzeige und das Monitoring und analysiere Basal und die Faktoren
Lasse den OpenLoop Modus für ein paar Tage laufen und setzte manuell temp Basal-Raten
Starte ein OpenLoop
- ALTE DATEN
+ VERALTETE DATEN
Laufende Benachrichtigungen
Öffne Einstellungen auf der Uhr
OpenAPS
@@ -506,7 +506,7 @@
Pumpe pausiert. Klicken zum aktualisieren des Status
Queue:
QuickWizard
- Aktualisiere Einträge von NS
+ Aktualisiere Einträge von Nightscout
Lösche Eintrag:
Alle Daten erneut senden
Möchtest du die Datenbank wirklich zurücksetzten?
@@ -533,6 +533,6 @@
Pausiere Loop für 3h
Schwedish
Aktualisere Basal Raten
- Übersicht Benachrichtigungen
+ PopUp Benachrichtigungen
Sensoralter
From 15fc53530ddf311589358059339264f7f964ab50 Mon Sep 17 00:00:00 2001
From: diabetesdt1
Date: Fri, 11 Aug 2017 12:43:46 +0200
Subject: [PATCH 26/35] Update strings.xml
Changed Nightscout to NS back (but not on the short Text).
Add more Translations.
Overview-Notification used and not "Popup-Notification".
Removed on short Names the ".
I think "treatment" = "Behandlung" sounds wrong :-|
---
app/src/main/res/values-de/strings.xml | 126 ++++++++++++++++++-------
1 file changed, 91 insertions(+), 35 deletions(-)
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 994413d12e..7162964a4b 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -81,7 +81,7 @@
Rate
Grund
Sicherheit:
- SEND
+ SENDE
Aktivität:
Kohlehydrate:
Insulin:
@@ -108,7 +108,7 @@
Korr
Kohlehydrat Menge
Insulin Menge
- Treatments
+ Behandlungen
Max erlaubter Bolus [U]
Max erlaubte Kohlehydrate [g]
Tratments Sicherheit
@@ -124,23 +124,23 @@
Neue Empfehlung verfügbar
Ergebnis
Anfrage
- Run now
+ Ausführen
Keine Pumpe verfügbar
Kein Profil verfügbar
Keine BZ Daten verfügbar
Mahlzeiten Daten
- Last run
- Last enacted
+ Letzte Ausführung
+ Zuletzt abgegeben
Plugin ist deaktiviert
- Current temp
+ Aktuelle temp
Gate:
Objective:
Zielsetzungen
KEIN PROFIL GESETZT
- NSClient nicht installiert. Record lost!
+ NSClient ist nicht installiert. Eintrag verloren!
Verwende absolute statt prozentuelle Basalwerte beim Upload zu NightScout
Bisher noch kein Profil von NS geladen
- No change requested
+ Keine Anpassung benötigt
NO APS SELECTED OR PROVIDED RESULT
Test Alarm
Avg. delta
@@ -169,11 +169,11 @@
Carbs constraint applied
Reset Datenbanken
Minimale Dauer
- Erneure treatments von NS
+ Erneure Behandlungen von NS
Exit
Fehlend
aktiviert
- Eingabe neues treatment
+ Eingabe neuer Behandlung:
Einstellungen exportieren nach
Datei nicht gefunden
Einstellungen exportiert
@@ -182,7 +182,7 @@
Einstellungen exportieren
Einstellungen importieren
German
- Max U/hr die man für eine Temp Basal setzen kann
+ Dieser Wert wird max basal in OpenAPS genannt
Maximale Menge von nicht bolus IOB die OpenAPs abgeben kann
Bulgarian
Nightscout
@@ -229,12 +229,12 @@
Profil zur Pumpe synchronisieren
auf Pumpenergebnis warten
Kein Bluetoothadapter gefunden
- Remote Bolus nicht erlaubt
+ Remote Bolus ist nicht erlaubt
Um Bolus %.2fU bitte mit %s antworten
Korean
Limit erreicht
Falsches Pumpen-Passwort!
- Warte auf Pumpe. Click to refresh.
+ Warte auf Pumpe. Klicke zum aktualisieren.
Korr
Abgabe %.2fU
%.2fU Bolus erfolgreich abgegeben
@@ -253,7 +253,7 @@
Unterbrechungen
Pumpen-Passwort
Essensbolus
- Kein Profil gewählt
+ Kein Profil ausgewählt
Stop
Gestoppt
STOP GEDRÜCKT
@@ -275,7 +275,7 @@
Andere
Verstopfung
Abgegeben
- %.2fU werden abgegeben werden
+ Es werden %.2fU abgegeben
Vorfüllen / Füllen
Hochladen
Spanish
@@ -293,7 +293,7 @@
Einheiten:
Falscher Pumpentreiber ausgewählt
Befüllen
- EasyUI mode in Pumpe deaktivieren
+ EasyUI Modus in der Pumpe deaktivieren
Basal-Stunde
Knopf 1
Knopf 2
@@ -301,20 +301,20 @@
Config Builder
vor %d min
"AKT"
- "WEAR"
+ WEAR
VP
- "TREAT"
- "TT"
- "TB"
- "SMS"
+ TREAT
+ TT
+ TB
+ SMS
SP
- "PROF"
+ PROF
HOME
- "OBJ"
- "OAPS"
- "LOOP"
- "LP"
- "DANA"
+ OBJ
+ OAPS
+ LOOP
+ LP
+ DANA
"CONF"
"CPP"
"CP"
@@ -339,7 +339,7 @@
Kumulative TDD
Datum
Exponentiell Gewichtete TDD
- Veraltete Daten \"Reload\"
+ Veraltete Daten, bitte klicke auf \"Reload\"
xds
xDrip Statuszeile (Uhr)
xDrip Status (Uhr)
@@ -460,9 +460,9 @@
Alarm Optionen
Aktiviere Broadcast für andere Apps (z.B. xDrip).
Aktiviere lokalen Broadcast.
- Logge App-Start in Nightscout
- Kein Upload zu Nightscout
- Alle an Nightscout gesendete Daten verworfen. AAPS ist verbunden, aber keine Änderungen in NS
+ Logge App-Start in NS
+ Kein Upload zu NS
+ Alle an NS gesendete Daten verworfen. AAPS ist verbunden, aber keine Änderungen in NS ist fertig
Hoch
Niedrig
Gesetzt zu %f
@@ -471,9 +471,9 @@
Autoscroll
Gerätenamen eingeben
Gerätename
- Nightscout API-Key eingeben (min 12 Zeichen)
- Nightscout API-Key
- Nightscout API-Key
+ NS API-Key eingeben (min 12 Zeichen)
+ NightScout API-Key
+ NightScout API-Key
URL:
Nightscout URL eingeben
Nightscout URL
@@ -533,6 +533,62 @@
Pausiere Loop für 3h
Schwedish
Aktualisere Basal Raten
- PopUp Benachrichtigungen
+ Übersicht Benachrichtigungen
Sensoralter
+ Wechsle Modus von U/d zu U/h in der Pumpe
+ Insgesamt %d Einträge erfolgreich hochgeladen
+ Dauer der Insulinwirkung
+ Bearbeite Basis-IC:
+ Bearbeite Basis-ISF:
+ IC Angabe fehlt im Profil. Verwende default Wert.
+ INS
+ ISF fehlt im Profil. Verwende default Wert.
+ Sperr
+ %s benötigt Batterie-Optimierungs-Whitelisting um korrekt arbeiten zu können
+ Veraltete Daten
+ Veraltete Daten seit [Min]
+ Es wird verwendet für das enteredBy Feld
+ Autosens Daten
+ Max U/h die an Temp Basal gesetzt werden kann
+ Maximum Basal IOB, was OpenAPS abgeben darf [U]
+ Prozentialer Faktor um den das Basis Profil multipiziert wird.
+ Bitte Rechte gewähren
+ Hoch und niedrig Werte für die Übersicht- und die Smartwatch-Anzeige
+ Zielbereich für die Grafikanzeige
+ Bei aktivierter Autosense-Funktion, bitte stell sicher, das du alle gegessenen Kohlenhydrate eingibts. Ansonsten können die Kohlenhydrate-Abweichung als falsche Resistens/Empfindlichkeit identifziert werden!!!
+ Empfindlichkeit AAPS
+ Empfindlichkeit Oref0
+ Durschnittliche Empfindlichkeitsgewichtung
+ Einstellung Extended Bolus
+ vor %dMin
+ "Um das temp Basal zu stoppen, antworte mit dem Code %s"
+ Bolus %.2fU erfolgreich abgegeben
+ xDrip hat die Kalbrierung nicht erhalten
+ Um die Kalibrierung %.2f zu senden, antworte mit dem Code %s
+ Kalibrierung gesendet. Das empfangen von Kalbrierungen muss in xDrip aktiviert sein.
+ Falsche/Ungültige SMS Telefonnummer
+ Loop wurde deaktiviert
+ Lopp wurde aktiviert
+ Loop ist deaktiviert
+ Loop ist aktiviert
+ Loop wurde fortgesetzt
+ Loop pausiert
+ Es fehlt das SMS-Recht
+ Basal Einstellungen per Remote ist nicht erlaubt
+ Kalibrierung per Remote ist nicht erlaubt
+ Externe Befehle sind nicht erlaubt
+ Erlaube externe Befehle per SMS
+ Um den Loop zu pausieren für %d Minuten, antworte mit dem Code %s
+ Temp Basal abgebrochen
+ Abbrechen des temp Basal ist fehlgeschlagen
+ Temp Basal starten ist fehlgeschlagen
+ Temp Basal %.2fU/h für %d min wurde erfolgreich gestartet
+ Unbekannter Befehl oder falsche Antwort
+ Falsche Dauer
+ Einstellungen freischalten
+ %.2f limitiert auf %.2f
+ S Bolus
+ Model: %02X Protokol: %02X Code: %02X
+ Empfindlichkeitserkennung
+ COB
From a69a94a3844d42d05b84f5df117e3a76bd22082b Mon Sep 17 00:00:00 2001
From: diabetesdt1
Date: Fri, 11 Aug 2017 12:48:15 +0200
Subject: [PATCH 27/35] Update strings.xml
---
app/src/main/res/values-de/strings.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index 7162964a4b..fee7a948b2 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -588,7 +588,7 @@
Einstellungen freischalten
%.2f limitiert auf %.2f
S Bolus
- Model: %02X Protokol: %02X Code: %02X
+ Model: %02X Protokoll: %02X Code: %02X
Empfindlichkeitserkennung
COB
From 8cd24fd919a4a8c32b99ec62a73abffd972a04cd Mon Sep 17 00:00:00 2001
From: diabetesdt1
Date: Fri, 11 Aug 2017 13:28:39 +0200
Subject: [PATCH 28/35] Update strings.xml
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Replaced "Empfindlichkeit" with "Sensitivität"
---
app/src/main/res/values-de/strings.xml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml
index fee7a948b2..99275d8cb8 100644
--- a/app/src/main/res/values-de/strings.xml
+++ b/app/src/main/res/values-de/strings.xml
@@ -556,9 +556,9 @@
Hoch und niedrig Werte für die Übersicht- und die Smartwatch-Anzeige
Zielbereich für die Grafikanzeige
Bei aktivierter Autosense-Funktion, bitte stell sicher, das du alle gegessenen Kohlenhydrate eingibts. Ansonsten können die Kohlenhydrate-Abweichung als falsche Resistens/Empfindlichkeit identifziert werden!!!
- Empfindlichkeit AAPS
- Empfindlichkeit Oref0
- Durschnittliche Empfindlichkeitsgewichtung
+ Sensitivität AAPS
+ Sensitivität Oref0
+ Durschnittliche Sensitivität
Einstellung Extended Bolus
vor %dMin
"Um das temp Basal zu stoppen, antworte mit dem Code %s"
From 7839299530d7a45b3096e0c3b300767ba4fff544 Mon Sep 17 00:00:00 2001
From: Timm Korte
Date: Fri, 11 Aug 2017 22:08:33 +0200
Subject: [PATCH 29/35] add force parameter to setTempBasalAbsolute in order to
force setting of a 0 temp for disconnecting the pump - instead of calling
cancel as introduced in a24cbfda500aaead3a049571b2d55432902336ae
---
.../androidaps/interfaces/PumpInterface.java | 2 +-
.../plugins/Actions/dialogs/NewTempBasalDialog.java | 2 +-
.../plugins/ConfigBuilder/ConfigBuilderPlugin.java | 8 ++++++--
.../plugins/Overview/OverviewFragment.java | 12 ++++--------
.../androidaps/plugins/PumpDanaR/DanaRPlugin.java | 4 ++--
.../plugins/PumpDanaRKorean/DanaRKoreanPlugin.java | 4 ++--
.../plugins/PumpDanaRv2/DanaRv2Plugin.java | 4 ++--
.../androidaps/plugins/PumpMDI/MDIPlugin.java | 2 +-
.../plugins/PumpVirtual/VirtualPumpPlugin.java | 2 +-
.../SmsCommunicator/SmsCommunicatorPlugin.java | 2 +-
10 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java
index bb78ea1d0a..d3e8d0f21e 100644
--- a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java
+++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java
@@ -31,7 +31,7 @@ public interface PumpInterface {
PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo);
void stopBolusDelivering();
- PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes);
+ PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean force);
PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes);
PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes);
//some pumps might set a very short temp close to 100% as canecelling a temp can be noisy
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 0a379a904d..9582dced87 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
@@ -155,7 +155,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
if (setAsPercent) {
result = pump.setTempBasalPercent(finalBasalPercent, finalDurationInMinutes);
} else {
- result = pump.setTempBasalAbsolute(finalBasal, finalDurationInMinutes);
+ result = pump.setTempBasalAbsolute(finalBasal, finalDurationInMinutes, false);
}
if (!result.success) {
if (context instanceof Activity) {
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 e65e5b8445..769ca94d9c 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
@@ -475,14 +475,18 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
* @return
*/
@Override
- public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes) {
+ public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean force) {
Double rateAfterConstraints = applyBasalConstraints(absoluteRate);
- PumpEnactResult result = activePump.setTempBasalAbsolute(rateAfterConstraints, durationInMinutes);
+ PumpEnactResult result = activePump.setTempBasalAbsolute(rateAfterConstraints, durationInMinutes, force);
if (Config.logCongigBuilderActions)
log.debug("setTempBasalAbsolute rate: " + rateAfterConstraints + " durationInMinutes: " + durationInMinutes + " success: " + result.success + " enacted: " + result.enacted);
return result;
}
+ public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes) {
+ return setTempBasalAbsolute(absoluteRate, durationInMinutes, false);
+ }
+
/**
* apply constraints, set temp based on percent and expecting result in percent
*
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 2faee2d293..ff6218786e 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
@@ -504,8 +504,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
sHandler.post(new Runnable() {
@Override
public void run() {
- MainApp.getConfigBuilder().cancelTempBasal(true);
- PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 30);
+ PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 30, true);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
}
@@ -519,8 +518,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
sHandler.post(new Runnable() {
@Override
public void run() {
- MainApp.getConfigBuilder().cancelTempBasal(true);
- PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 60);
+ PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 60, true);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
}
@@ -534,8 +532,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
sHandler.post(new Runnable() {
@Override
public void run() {
- MainApp.getConfigBuilder().cancelTempBasal(true);
- PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 2 * 60);
+ PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 2 * 60, true);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
}
@@ -549,8 +546,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
sHandler.post(new Runnable() {
@Override
public void run() {
- MainApp.getConfigBuilder().cancelTempBasal(true);
- PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 3 * 60);
+ PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 3 * 60, true);
if (!result.success) {
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
}
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
index aaae495c58..1f57fafef9 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
@@ -334,7 +334,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
// This is called from APS
@Override
- public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes) {
+ public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean force) {
// Recheck pump status if older than 30 min
if (pump.lastConnection.getTime() + 30 * 60 * 1000L < System.currentTimeMillis()) {
doConnect("setTempBasalAbsolute old data");
@@ -399,7 +399,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
TemporaryBasal running = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: currently running: " + running.toString());
- if (running.percentRate == percentRate) {
+ if (running.percentRate == percentRate && force == false) {
result.success = true;
result.percent = percentRate;
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
index e3b6bf3598..7a170763b8 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
@@ -338,7 +338,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
// This is called from APS
@Override
- public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes) {
+ public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean force) {
// Recheck pump status if older than 30 min
if (pump.lastConnection.getTime() + 30 * 60 * 1000L < System.currentTimeMillis()) {
doConnect("setTempBasalAbsolute old data");
@@ -397,7 +397,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
// Check if some temp is already in progress
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
// Correct basal already set ?
- if (MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()).percentRate == percentRate) {
+ if (MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()).percentRate == percentRate && force == false) {
result.success = true;
result.percent = percentRate;
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory();
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 8c2b2d327b..895e5919c6 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
@@ -323,7 +323,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
// This is called from APS
@Override
- public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes) {
+ public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean force) {
// Recheck pump status if older than 30 min
if (pump.lastConnection.getTime() + 30 * 60 * 1000L < System.currentTimeMillis()) {
doConnect("setTempBasalAbsolute old data");
@@ -364,7 +364,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
// Check if some temp is already in progress
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
// Correct basal already set ?
- if (MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).percentRate == percentRate) {
+ if (MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).percentRate == percentRate && force == false) {
result.success = true;
result.percent = percentRate;
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java
index ddd05a2e0b..7c0e28ec97 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java
@@ -166,7 +166,7 @@ public class MDIPlugin implements PluginBase, PumpInterface {
}
@Override
- public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes) {
+ public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean force) {
PumpEnactResult result = new PumpEnactResult();
result.success = false;
result.comment = MainApp.instance().getString(R.string.pumperror);
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 7337859c47..5d3899b0af 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
@@ -258,7 +258,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
}
@Override
- public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes) {
+ public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean force) {
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
TemporaryBasal tempBasal = new TemporaryBasal();
tempBasal.date = System.currentTimeMillis();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java
index 8e5e3bde46..1cf17881af 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/SmsCommunicator/SmsCommunicatorPlugin.java
@@ -487,7 +487,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
PumpInterface pumpInterface = MainApp.getConfigBuilder();
if (pumpInterface != null) {
danaRPlugin = (DanaRPlugin) MainApp.getSpecificPlugin(DanaRPlugin.class);
- PumpEnactResult result = pumpInterface.setTempBasalAbsolute(tempBasalWaitingForConfirmation.tempBasal, 30);
+ PumpEnactResult result = pumpInterface.setTempBasalAbsolute(tempBasalWaitingForConfirmation.tempBasal, 30, false);
if (result.success) {
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_tempbasalset), result.absolute, result.duration);
if (danaRPlugin != null)
From 73b6235188f9e22413178c0f0b6982db3e549b38 Mon Sep 17 00:00:00 2001
From: Milos Kozak
Date: Fri, 11 Aug 2017 22:46:08 +0200
Subject: [PATCH 30/35] APSRequest Answers event
---
.../info/nightscout/androidaps/plugins/Loop/LoopPlugin.java | 3 +++
1 file changed, 3 insertions(+)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java
index d3f59de5ad..6e459a03b2 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java
@@ -10,6 +10,8 @@ import android.os.Handler;
import android.os.HandlerThread;
import android.support.v7.app.NotificationCompat;
+import com.crashlytics.android.answers.Answers;
+import com.crashlytics.android.answers.CustomEvent;
import com.squareup.otto.Subscribe;
import org.json.JSONException;
@@ -277,6 +279,7 @@ public class LoopPlugin implements PluginBase {
@Override
public void run() {
final PumpEnactResult applyResult = configBuilder.applyAPSRequest(resultAfterConstraints);
+ Answers.getInstance().logCustom(new CustomEvent("APSRequest"));
if (applyResult.enacted || applyResult.success) {
lastRun.setByPump = applyResult;
lastRun.lastEnact = lastRun.lastAPSRun;
From 8db9cb88875de67579cb6b613807c97efea449ca Mon Sep 17 00:00:00 2001
From: Timm Korte
Date: Fri, 11 Aug 2017 23:06:35 +0200
Subject: [PATCH 31/35] add cancelTempBasal to setTempBasal if forced
---
.../plugins/PumpDanaR/DanaRPlugin.java | 26 ++++++++++-------
.../PumpDanaRKorean/DanaRKoreanPlugin.java | 26 ++++++++++-------
.../plugins/PumpDanaRv2/DanaRv2Plugin.java | 29 +++++++++++--------
3 files changed, 47 insertions(+), 34 deletions(-)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
index 1f57fafef9..b33db24995 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
@@ -399,17 +399,21 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
TemporaryBasal running = MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis());
if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: currently running: " + running.toString());
- if (running.percentRate == percentRate && force == false) {
- result.success = true;
- result.percent = percentRate;
- result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory();
- result.enacted = false;
- result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutesFromHistory()).intValue();
- result.isPercent = true;
- result.isTempCancel = false;
- if (Config.logPumpActions)
- log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)");
- return result;
+ if (running.percentRate == percentRate) {
+ if (force == true) {
+ cancelTempBasal(true);
+ } else {
+ result.success = true;
+ result.percent = percentRate;
+ result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory();
+ result.enacted = false;
+ result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutesFromHistory()).intValue();
+ result.isPercent = true;
+ result.isTempCancel = false;
+ if (Config.logPumpActions)
+ log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)");
+ return result;
+ }
}
}
// Convert duration from minutes to hours
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
index 7a170763b8..6f792f066e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
@@ -397,17 +397,21 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
// Check if some temp is already in progress
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
// Correct basal already set ?
- if (MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()).percentRate == percentRate && force == false) {
- result.success = true;
- result.percent = percentRate;
- result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory();
- result.enacted = false;
- result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutesFromHistory()).intValue();
- result.isPercent = true;
- result.isTempCancel = false;
- if (Config.logPumpActions)
- log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)");
- return result;
+ if (MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()).percentRate == percentRate) {
+ if (force == true) {
+ cancelTempBasal(true);
+ } else {
+ result.success = true;
+ result.percent = percentRate;
+ result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory();
+ result.enacted = false;
+ result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutesFromHistory()).intValue();
+ result.isPercent = true;
+ result.isTempCancel = false;
+ if (Config.logPumpActions)
+ log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)");
+ return result;
+ }
}
}
// Convert duration from minutes to hours
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 895e5919c6..4fa9db6ee0 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
@@ -364,18 +364,23 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
// Check if some temp is already in progress
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
// Correct basal already set ?
- if (MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).percentRate == percentRate && force == false) {
- result.success = true;
- result.percent = percentRate;
- result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory();
- result.enacted = false;
- result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutesFromHistory()).intValue();
- result.isPercent = true;
- result.isTempCancel = false;
- if (Config.logPumpActions)
- log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)");
- return result;
- } }
+ if (MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).percentRate == percentRate) {
+ if (force == true) {
+ cancelTempBasal(true);
+ } else {
+ result.success = true;
+ result.percent = percentRate;
+ result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory();
+ result.enacted = false;
+ result.duration = ((Double) MainApp.getConfigBuilder().getTempBasalRemainingMinutesFromHistory()).intValue();
+ result.isPercent = true;
+ result.isTempCancel = false;
+ if (Config.logPumpActions)
+ log.debug("setTempBasalAbsolute: Correct temp basal already set (doLowTemp || doHighTemp)");
+ return result;
+ }
+ }
+ }
// Convert duration from minutes to hours
if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: Setting temp basal " + percentRate + "% for " + durationInMinutes + " mins (doLowTemp || doHighTemp)");
From f861546e12b50c6de93a88ce5634a472e479912f Mon Sep 17 00:00:00 2001
From: AdrianLxM
Date: Sat, 12 Aug 2017 11:20:56 +0200
Subject: [PATCH 32/35] Quickfix to avoid crashes after staleData merge
---
.../plugins/NSClientInternal/data/NSSettingsStatus.java | 2 ++
1 file changed, 2 insertions(+)
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java
index 189474c9c8..4829af714e 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/NSClientInternal/data/NSSettingsStatus.java
@@ -201,6 +201,7 @@ public class NSSettingsStatus {
private String getStringOrNull(String key) {
String ret = null;
+ if(data == null) return null;
if (data.has(key)) {
try {
ret = data.getString(key);
@@ -309,6 +310,7 @@ public class NSSettingsStatus {
public JSONObject extentendedPumpSettings() {
try {
JSONObject extended = getExtendedSettings();
+ if(extended == null) return null;
if (extended.has("pump")) {
JSONObject pump = extended.getJSONObject("pump");
return pump;
From 6bbb785574548923135f6a71b4e265cd57ec2158 Mon Sep 17 00:00:00 2001
From: Timm Korte
Date: Fri, 11 Aug 2017 23:22:55 +0200
Subject: [PATCH 33/35] rename 'userRequested' to 'force' as parameter to
cancelTempBasal in order to have the same naming as with setTempBasalAbsolute
---
.../nightscout/androidaps/interfaces/PumpInterface.java | 6 +++---
.../plugins/ConfigBuilder/ConfigBuilderPlugin.java | 4 ++--
.../androidaps/plugins/PumpDanaR/DanaRPlugin.java | 4 ++--
.../plugins/PumpDanaRKorean/DanaRKoreanPlugin.java | 4 ++--
.../androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java | 4 ++--
.../nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java | 2 +-
.../androidaps/plugins/PumpVirtual/VirtualPumpPlugin.java | 2 +-
7 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java
index d3e8d0f21e..2db7564de7 100644
--- a/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java
+++ b/app/src/main/java/info/nightscout/androidaps/interfaces/PumpInterface.java
@@ -34,9 +34,9 @@ public interface PumpInterface {
PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean force);
PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes);
PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes);
- //some pumps might set a very short temp close to 100% as canecelling a temp can be noisy
- //when the cancel request is requested by the user, the pump should always do a real cancel
- PumpEnactResult cancelTempBasal(boolean userRequested);
+ //some pumps might set a very short temp close to 100% as cancelling a temp can be noisy
+ //when the cancel request is requested by the user (forced), the pump should always do a real cancel
+ PumpEnactResult cancelTempBasal(boolean force);
PumpEnactResult cancelExtendedBolus();
// Status to be passed to NS
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 769ca94d9c..e4e4aac7cc 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
@@ -513,8 +513,8 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
}
@Override
- public PumpEnactResult cancelTempBasal(boolean userRequested) {
- PumpEnactResult result = activePump.cancelTempBasal(userRequested);
+ public PumpEnactResult cancelTempBasal(boolean force) {
+ PumpEnactResult result = activePump.cancelTempBasal(force);
if (Config.logCongigBuilderActions)
log.debug("cancelTempBasal success: " + result.success + " enacted: " + result.enacted);
return result;
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
index b33db24995..2e01ee662d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaR/DanaRPlugin.java
@@ -400,7 +400,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
if (Config.logPumpActions)
log.debug("setTempBasalAbsolute: currently running: " + running.toString());
if (running.percentRate == percentRate) {
- if (force == true) {
+ if (force) {
cancelTempBasal(true);
} else {
result.success = true;
@@ -576,7 +576,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
}
@Override
- public PumpEnactResult cancelTempBasal(boolean userRequested) {
+ public PumpEnactResult cancelTempBasal(boolean force) {
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress())
return cancelRealTempBasal();
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
index 6f792f066e..84552946ae 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpDanaRKorean/DanaRKoreanPlugin.java
@@ -398,7 +398,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
// Correct basal already set ?
if (MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()).percentRate == percentRate) {
- if (force == true) {
+ if (force) {
cancelTempBasal(true);
} else {
result.success = true;
@@ -574,7 +574,7 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
}
@Override
- public PumpEnactResult cancelTempBasal(boolean userRequested) {
+ public PumpEnactResult cancelTempBasal(boolean force) {
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress())
return cancelRealTempBasal();
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress() && useExtendedBoluses) {
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 4fa9db6ee0..97840ad34b 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
@@ -365,7 +365,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
// Correct basal already set ?
if (MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).percentRate == percentRate) {
- if (force == true) {
+ if (force) {
cancelTempBasal(true);
} else {
result.success = true;
@@ -515,7 +515,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
}
@Override
- public PumpEnactResult cancelTempBasal(boolean userRequested) {
+ public PumpEnactResult cancelTempBasal(boolean force) {
PumpEnactResult result = new PumpEnactResult();
if (pump.isTempBasalInProgress) {
sExecutionService.tempBasalStop();
diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java
index 7c0e28ec97..f9f4b6fa2d 100644
--- a/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java
+++ b/app/src/main/java/info/nightscout/androidaps/plugins/PumpMDI/MDIPlugin.java
@@ -196,7 +196,7 @@ public class MDIPlugin implements PluginBase, PumpInterface {
}
@Override
- public PumpEnactResult cancelTempBasal(boolean userRequested) {
+ public PumpEnactResult cancelTempBasal(boolean force) {
PumpEnactResult result = new PumpEnactResult();
result.success = false;
result.comment = MainApp.instance().getString(R.string.pumperror);
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 5d3899b0af..c04ec9b12f 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
@@ -337,7 +337,7 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
}
@Override
- public PumpEnactResult cancelTempBasal(boolean userRequested) {
+ public PumpEnactResult cancelTempBasal(boolean force) {
TreatmentsInterface treatmentsInterface = MainApp.getConfigBuilder();
PumpEnactResult result = new PumpEnactResult();
result.success = true;
From 8caaeeff2a648234913eb1a51feef57261ab6a61 Mon Sep 17 00:00:00 2001
From: Timm Korte
Date: Sun, 13 Aug 2017 14:32:37 +0200
Subject: [PATCH 34/35] change logfile name pattern to still be rotated once a
day but include the hour-minute-seconds as timestamp in the filename
---
app/src/main/assets/logback.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/src/main/assets/logback.xml b/app/src/main/assets/logback.xml
index 41ed7bdefe..1e18709044 100644
--- a/app/src/main/assets/logback.xml
+++ b/app/src/main/assets/logback.xml
@@ -6,7 +6,7 @@
- ${EXT_FILES_DIR}/AndroidAPS._%d{yyyy-MM-dd}.%i.zip
+ ${EXT_FILES_DIR}/AndroidAPS._%d{yyyy-MM-dd}_%d{HH-mm-ss, aux}_.%i.zip
5MB
From d4642b3958c1b4ce84e9dbc37890c791b2f47f24 Mon Sep 17 00:00:00 2001
From: Milos Kozak
Date: Sun, 13 Aug 2017 20:31:15 +0200
Subject: [PATCH 35/35] do not enforce stop for v2 driver
---
.../androidaps/plugins/PumpDanaRv2/DanaRv2Plugin.java | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
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 97840ad34b..0697a69af7 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
@@ -365,9 +365,7 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
// Correct basal already set ?
if (MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()).percentRate == percentRate) {
- if (force) {
- cancelTempBasal(true);
- } else {
+ if (!force) {
result.success = true;
result.percent = percentRate;
result.absolute = MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory();