Merge branch 'dev' of git://github.com/MilosKozak/AndroidAps into dev

This commit is contained in:
osodebailar 2018-04-22 19:11:52 +02:00
commit febaf9fc49
57 changed files with 871 additions and 408 deletions

View file

@ -63,7 +63,7 @@ android {
targetSdkVersion 25 targetSdkVersion 25
multiDexEnabled true multiDexEnabled true
versionCode 1500 versionCode 1500
version "1.60d-dev" version "1.60e-dev"
buildConfigField "String", "VERSION", '"' + version + '"' buildConfigField "String", "VERSION", '"' + version + '"'
buildConfigField "String", "BUILDVERSION", generateGitBuild() buildConfigField "String", "BUILDVERSION", generateGitBuild()
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

Binary file not shown.

View file

@ -15,9 +15,11 @@
<uses-permission android:name="android.permission.SEND_MMS" /> <uses-permission android:name="android.permission.SEND_MMS" />
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" /> <uses-permission android:name="com.google.android.permission.PROVIDE_BACKGROUND" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="sugar.free.sightremote.HISTORY_BROADCASTS" />
<uses-permission-sdk-23 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> <uses-permission-sdk-23 android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
@ -111,6 +113,14 @@
</intent-filter> </intent-filter>
</receiver> </receiver>
<!-- Network change local receiver -->
<receiver android:name=".receivers.NetworkChangeReceiver">
<intent-filter>
<action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
<action android:name="android.net.wifi.WIFI_STATE_CHANGED" />
</intent-filter>
</receiver>
<!-- Service processing incomming data --> <!-- Service processing incomming data -->
<service <service
android:name=".Services.DataService" android:name=".Services.DataService"

View file

@ -23,8 +23,6 @@ public class Config {
public static final boolean SMSCOMMUNICATORENABLED = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER; public static final boolean SMSCOMMUNICATORENABLED = !BuildConfig.NSCLIENTOLNY && !BuildConfig.G5UPLOADER;
public static final boolean displayDeviationSlope = false;
public static final boolean detailedLog = true; public static final boolean detailedLog = true;
public static final boolean logFunctionCalls = true; public static final boolean logFunctionCalls = true;
public static final boolean logIncommingData = true; public static final boolean logIncommingData = true;

View file

@ -59,6 +59,7 @@ public class Constants {
//Autosens //Autosens
public static final double DEVIATION_TO_BE_EQUAL = 2.0; public static final double DEVIATION_TO_BE_EQUAL = 2.0;
public static final double DEFAULT_MAX_ABSORPTION_TIME = 6.0;
// Pump // Pump
public static final int PUMP_MAX_CONNECTION_TIME_IN_SECONDS = 120 - 1; public static final int PUMP_MAX_CONNECTION_TIME_IN_SECONDS = 120 - 1;

View file

@ -46,7 +46,7 @@ public class HistoryBrowseActivity extends AppCompatActivity {
ImageButton chartButton; ImageButton chartButton;
boolean showBasal = true; boolean showBasal = true;
boolean showIob, showCob, showDev, showRat; boolean showIob, showCob, showDev, showRat, showDevslope;
@BindView(R.id.historybrowse_date) @BindView(R.id.historybrowse_date)
@ -267,6 +267,7 @@ public class HistoryBrowseActivity extends AppCompatActivity {
boolean useCobForScale = false; boolean useCobForScale = false;
boolean useDevForScale = false; boolean useDevForScale = false;
boolean useRatioForScale = false; boolean useRatioForScale = false;
boolean useDevSlopeForScale = false;
if (showIob) { if (showIob) {
useIobForScale = true; useIobForScale = true;
@ -276,6 +277,8 @@ public class HistoryBrowseActivity extends AppCompatActivity {
useDevForScale = true; useDevForScale = true;
} else if (showRat) { } else if (showRat) {
useRatioForScale = true; useRatioForScale = true;
} else if (showDevslope) {
useDevSlopeForScale = true;
} }
if (showIob) if (showIob)
@ -286,6 +289,8 @@ public class HistoryBrowseActivity extends AppCompatActivity {
secondGraphData.addDeviations(fromTime, toTime, useDevForScale, 1d); secondGraphData.addDeviations(fromTime, toTime, useDevForScale, 1d);
if (showRat) if (showRat)
secondGraphData.addRatio(fromTime, toTime, useRatioForScale, 1d); secondGraphData.addRatio(fromTime, toTime, useRatioForScale, 1d);
if (showDevslope)
secondGraphData.addDeviationSlope(fromTime, toTime, useDevSlopeForScale, 1d);
// **** NOW line **** // **** NOW line ****
// set manual x bounds to have nice steps // set manual x bounds to have nice steps
@ -293,7 +298,7 @@ public class HistoryBrowseActivity extends AppCompatActivity {
secondGraphData.addNowLine(pointer); secondGraphData.addNowLine(pointer);
// do GUI update // do GUI update
if (showIob || showCob || showDev || showRat) { if (showIob || showCob || showDev || showRat || showDevslope) {
iobGraph.setVisibility(View.VISIBLE); iobGraph.setVisibility(View.VISIBLE);
} else { } else {
iobGraph.setVisibility(View.GONE); iobGraph.setVisibility(View.GONE);
@ -354,23 +359,31 @@ public class HistoryBrowseActivity extends AppCompatActivity {
item.setCheckable(true); item.setCheckable(true);
item.setChecked(showRat); item.setChecked(showRat);
if (MainApp.devBranch) {
item = popup.getMenu().add(Menu.NONE, OverviewFragment.CHARTTYPE.DEVSLOPE.ordinal(), Menu.NONE, "Deviation slope");
title = item.getTitle();
s = new SpannableString(title);
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.devslopepos, null)), 0, s.length(), 0);
item.setTitle(s);
item.setCheckable(true);
item.setChecked(showDevslope);
}
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
if (item.getItemId() == OverviewFragment.CHARTTYPE.BAS.ordinal()) { if (item.getItemId() == OverviewFragment.CHARTTYPE.BAS.ordinal()) {
showBasal = !item.isChecked(); showBasal = !item.isChecked();
} else if (item.getItemId() == OverviewFragment.CHARTTYPE.IOB.ordinal()) { } else if (item.getItemId() == OverviewFragment.CHARTTYPE.IOB.ordinal()) {
showIob = !item.isChecked(); showIob = !item.isChecked();
} else if (item.getItemId() == OverviewFragment.CHARTTYPE.COB.ordinal()) { } else if (item.getItemId() == OverviewFragment.CHARTTYPE.COB.ordinal()) {
showCob = !item.isChecked(); showCob = !item.isChecked();
} else if (item.getItemId() == OverviewFragment.CHARTTYPE.DEV.ordinal()) { } else if (item.getItemId() == OverviewFragment.CHARTTYPE.DEV.ordinal()) {
showDev = !item.isChecked(); showDev = !item.isChecked();
} else if (item.getItemId() == OverviewFragment.CHARTTYPE.SEN.ordinal()) { } else if (item.getItemId() == OverviewFragment.CHARTTYPE.SEN.ordinal()) {
showRat = !item.isChecked(); showRat = !item.isChecked();
} else if (item.getItemId() == OverviewFragment.CHARTTYPE.DEVSLOPE.ordinal()) {
showDevslope = !item.isChecked();
} }
updateGUI("onGraphCheckboxesCheckedChanged"); updateGUI("onGraphCheckboxesCheckedChanged");
return true; return true;

View file

@ -67,7 +67,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
MainApp.bus().post(new EventRefreshGui()); MainApp.bus().post(new EventRefreshGui());
} }
if (key.equals(MainApp.gs(R.string.key_openapsama_useautosens)) && SP.getBoolean(R.string.key_openapsama_useautosens, false)) { if (key.equals(MainApp.gs(R.string.key_openapsama_useautosens)) && SP.getBoolean(R.string.key_openapsama_useautosens, false)) {
OKDialog.show(this, MainApp.sResources.getString(R.string.configbuilder_sensitivity), MainApp.sResources.getString(R.string.sensitivity_warning), null); OKDialog.show(this, MainApp.gs(R.string.configbuilder_sensitivity), MainApp.gs(R.string.sensitivity_warning), null);
} }
updatePrefSummary(myPreferenceFragment.getPreference(key)); updatePrefSummary(myPreferenceFragment.getPreference(key));
} }
@ -81,13 +81,13 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
EditTextPreference editTextPref = (EditTextPreference) pref; EditTextPreference editTextPref = (EditTextPreference) pref;
if (pref.getKey().contains("password") || pref.getKey().contains("secret")) { if (pref.getKey().contains("password") || pref.getKey().contains("secret")) {
pref.setSummary("******"); pref.setSummary("******");
} else if (pref.getKey().equals(MainApp.sResources.getString(R.string.key_danars_name))) { } else if (pref.getKey().equals(MainApp.gs(R.string.key_danars_name))) {
pref.setSummary(SP.getString(R.string.key_danars_name, "")); pref.setSummary(SP.getString(R.string.key_danars_name, ""));
} else if (editTextPref.getText() != null && !editTextPref.getText().equals("")) { } else if (editTextPref.getText() != null && !editTextPref.getText().equals("")) {
((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage()); ((EditTextPreference) pref).setDialogMessage(editTextPref.getDialogMessage());
pref.setSummary(editTextPref.getText()); pref.setSummary(editTextPref.getText());
} else if (pref.getKey().contains("smscommunicator_allowednumbers") && TextUtils.isEmpty(editTextPref.getText().trim())) { } else if (pref.getKey().contains("smscommunicator_allowednumbers") && TextUtils.isEmpty(editTextPref.getText().trim())) {
pref.setSummary(MainApp.sResources.getString(R.string.smscommunicator_allowednumbers_summary)); pref.setSummary(MainApp.gs(R.string.smscommunicator_allowednumbers_summary));
} }
} }
} }
@ -127,9 +127,7 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
if (id != -1) { if (id != -1) {
addPreferencesFromResource(id); addPreferencesFromResource(id);
addPreferencesFromResource(R.xml.pref_advanced);
} else { } else {
addPreferencesFromResource(R.xml.pref_overview);
if (!Config.NSCLIENT && !Config.G5UPLOADER) { if (!Config.NSCLIENT && !Config.G5UPLOADER) {
addPreferencesFromResource(R.xml.pref_password); addPreferencesFromResource(R.xml.pref_password);
@ -137,9 +135,8 @@ public class PreferencesActivity extends PreferenceActivity implements SharedPre
addPreferencesFromResource(R.xml.pref_age); addPreferencesFromResource(R.xml.pref_age);
addPreferencesFromResource(R.xml.pref_language); addPreferencesFromResource(R.xml.pref_language);
if (!Config.NSCLIENT && !Config.G5UPLOADER) { addPreferencesFromResource(R.xml.pref_overview);
addPreferencesFromResource(R.xml.pref_quickwizard);
}
addPreferencesFromResourceIfEnabled(SourceDexcomG5Plugin.getPlugin(), PluginType.BGSOURCE); addPreferencesFromResourceIfEnabled(SourceDexcomG5Plugin.getPlugin(), PluginType.BGSOURCE);
addPreferencesFromResourceIfEnabled(CareportalPlugin.getPlugin(), PluginType.GENERAL); addPreferencesFromResourceIfEnabled(CareportalPlugin.getPlugin(), PluginType.GENERAL);
addPreferencesFromResourceIfEnabled(SafetyPlugin.getPlugin(), PluginType.CONSTRAINTS); addPreferencesFromResourceIfEnabled(SafetyPlugin.getPlugin(), PluginType.CONSTRAINTS);

View file

@ -130,7 +130,7 @@ public class DataService extends IntentService {
handleNewDataFromDexcomG5(intent); handleNewDataFromDexcomG5(intent);
} }
} else if (Intents.ACTION_NEW_SGV.equals(action)) { } else if (Intents.ACTION_NEW_SGV.equals(action)) {
if (nsClientEnabled || SP.getBoolean(R.string.ns_autobackfill, true)) if (nsClientEnabled || SP.getBoolean(R.string.key_ns_autobackfill, true))
handleNewDataFromNSClient(intent); handleNewDataFromNSClient(intent);
// Objectives 0 // Objectives 0
ObjectivesPlugin.bgIsAvailableInNS = true; ObjectivesPlugin.bgIsAvailableInNS = true;

View file

@ -11,4 +11,5 @@ public class MealData {
public double slopeFromMinDeviation = 999; public double slopeFromMinDeviation = 999;
public long lastBolusTime; public long lastBolusTime;
public long lastCarbTime = 0L; public long lastCarbTime = 0L;
public double usedMinCarbsImpact = 0d;
} }

View file

@ -195,8 +195,7 @@ public class BgReading implements DataPointWithLabelInterface {
@Override @Override
public float getSize() { public float getSize() {
boolean isTablet = MainApp.sResources.getBoolean(R.bool.isTablet); return 1;
return isTablet ? 8 : 5;
} }
@Override @Override

View file

@ -0,0 +1,10 @@
package info.nightscout.androidaps.events;
public class EventNetworkChange extends Event {
public boolean mobileConnected = false;
public boolean wifiConnected = false;
public String ssid;
public boolean roaming = false;
}

View file

@ -7,20 +7,25 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.DataPointWithLabelInterface;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.PointsWithLabelGraphSeries;
import info.nightscout.androidaps.plugins.Overview.graphExtensions.Scale;
import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin; import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin; import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
/** /**
* Created by mike on 25.04.2017. * Created by mike on 25.04.2017.
*/ */
public class AutosensData { public class AutosensData implements DataPointWithLabelInterface {
private static Logger log = LoggerFactory.getLogger(AutosensData.class); private static Logger log = LoggerFactory.getLogger(AutosensData.class);
static class CarbsInPast { static class CarbsInPast {
@ -34,14 +39,14 @@ public class AutosensData {
carbs = t.carbs; carbs = t.carbs;
remaining = t.carbs; remaining = t.carbs;
if (SensitivityAAPSPlugin.getPlugin().isEnabled(PluginType.SENSITIVITY) || SensitivityWeightedAveragePlugin.getPlugin().isEnabled(PluginType.SENSITIVITY)) { if (SensitivityAAPSPlugin.getPlugin().isEnabled(PluginType.SENSITIVITY) || SensitivityWeightedAveragePlugin.getPlugin().isEnabled(PluginType.SENSITIVITY)) {
double maxAbsorptionHours = SP.getDouble(R.string.key_absorption_maxtime, 4d); double maxAbsorptionHours = SP.getDouble(R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME);
Profile profile = MainApp.getConfigBuilder().getProfile(t.date); Profile profile = MainApp.getConfigBuilder().getProfile(t.date);
double sens = Profile.toMgdl(profile.getIsf(t.date), profile.getUnits()); double sens = Profile.toMgdl(profile.getIsf(t.date), profile.getUnits());
double ic = profile.getIc(t.date); double ic = profile.getIc(t.date);
min5minCarbImpact = t.carbs / (maxAbsorptionHours * 60 / 5) * sens / ic; min5minCarbImpact = t.carbs / (maxAbsorptionHours * 60 / 5) * sens / ic;
log.debug("Min 5m carbs impact for " + carbs + "g @" + new Date(t.date).toLocaleString() + " for " + maxAbsorptionHours + "h calculated to " + min5minCarbImpact + " ISF: " + sens + " IC: " + ic); log.debug("Min 5m carbs impact for " + carbs + "g @" + new Date(t.date).toLocaleString() + " for " + maxAbsorptionHours + "h calculated to " + min5minCarbImpact + " ISF: " + sens + " IC: " + ic);
} else { } else {
min5minCarbImpact = SP.getDouble("openapsama_min_5m_carbimpact", 3.0); min5minCarbImpact = SP.getDouble(R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact);
} }
} }
} }
@ -63,25 +68,33 @@ public class AutosensData {
public double autosensRatio = 1d; public double autosensRatio = 1d;
public double slopeFromMaxDeviation = 0; public double slopeFromMaxDeviation = 0;
public double slopeFromMinDeviation = 999; public double slopeFromMinDeviation = 999;
public double usedMinCarbsImpact = 0d;
public boolean failoverToMinAbsorbtionRate = false;
@Override @Override
public String toString() { public String toString() {
return "AutosensData: " + new Date(time).toLocaleString() + " " + pastSensitivity + " Delta=" + delta + " avgDelta=" + avgDelta + " Bgi=" + bgi + " Deviation=" + deviation + " avgDeviation=" + avgDeviation + " Absorbed=" + absorbed + " CarbsFromBolus=" + carbsFromBolus + " COB=" + cob + " autosensRatio=" + autosensRatio + " slopeFromMaxDeviation=" + slopeFromMaxDeviation + " slopeFromMinDeviation =" + slopeFromMinDeviation ; return "AutosensData: " + new Date(time).toLocaleString() + " " + pastSensitivity + " Delta=" + delta + " avgDelta=" + avgDelta + " Bgi=" + bgi + " Deviation=" + deviation + " avgDeviation=" + avgDeviation + " Absorbed=" + absorbed + " CarbsFromBolus=" + carbsFromBolus + " COB=" + cob + " autosensRatio=" + autosensRatio + " slopeFromMaxDeviation=" + slopeFromMaxDeviation + " slopeFromMinDeviation =" + slopeFromMinDeviation;
} }
public int minOld() { public int minOld() {
return (int) ((System.currentTimeMillis() - time) / 1000 / 60); return (int) ((System.currentTimeMillis() - time) / 1000 / 60);
} }
// remove carbs older than 4h // remove carbs older than timeframe
public void removeOldCarbs(long toTime) { public void removeOldCarbs(long toTime) {
double maxAbsorptionHours = Constants.DEFAULT_MAX_ABSORPTION_TIME;
if (SensitivityAAPSPlugin.getPlugin().isEnabled(PluginType.SENSITIVITY) || SensitivityWeightedAveragePlugin.getPlugin().isEnabled(PluginType.SENSITIVITY)) {
maxAbsorptionHours = SP.getDouble(R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME);
} else {
maxAbsorptionHours = SP.getDouble(R.string.key_absorption_cutoff, Constants.DEFAULT_MAX_ABSORPTION_TIME);
}
for (int i = 0; i < activeCarbsList.size(); i++) { for (int i = 0; i < activeCarbsList.size(); i++) {
CarbsInPast c = activeCarbsList.get(i); CarbsInPast c = activeCarbsList.get(i);
if (c.time + 4 * 60 * 60 * 1000L < toTime) { if (c.time + maxAbsorptionHours * 60 * 60 * 1000L < toTime) {
activeCarbsList.remove(i--); activeCarbsList.remove(i--);
if (c.remaining > 0) if (c.remaining > 0)
cob -= c.remaining; cob -= c.remaining;
log.debug("Removing carbs at "+ new Date(toTime).toLocaleString() + " + after 4h :" + new Date(c.time).toLocaleString()); log.debug("Removing carbs at " + new Date(toTime).toLocaleString() + " + after " + maxAbsorptionHours + "h :" + new Date(c.time).toLocaleString());
} }
} }
} }
@ -98,4 +111,57 @@ public class AutosensData {
} }
} }
// ------- DataPointWithLabelInterface ------
private Scale scale;
public void setScale(Scale scale) {
this.scale = scale;
}
@Override
public double getX() {
return time;
}
@Override
public double getY() {
return scale.transform(cob);
}
@Override
public void setY(double y) {
}
@Override
public String getLabel() {
return null;
}
@Override
public long getDuration() {
return 0;
}
@Override
public PointsWithLabelGraphSeries.Shape getShape() {
return PointsWithLabelGraphSeries.Shape.COBFAILOVER;
}
@Override
public float getSize() {
return 1f;
}
@Override
public int getColor() {
return MainApp.gc(R.color.cob);
}
@Override
public int getSecondColor() {
return 0;
}
} }

View file

@ -74,7 +74,7 @@ public class IobCobCalculatorPlugin extends PluginBase {
.neverVisible(true) .neverVisible(true)
.alwaysEnabled(true) .alwaysEnabled(true)
); );
} }
@Override @Override
protected void onStart() { protected void onStart() {
@ -548,7 +548,9 @@ public class IobCobCalculatorPlugin extends PluginBase {
} }
if (ev.isChanged(R.string.key_openapsama_autosens_period) || if (ev.isChanged(R.string.key_openapsama_autosens_period) ||
ev.isChanged(R.string.key_age) || ev.isChanged(R.string.key_age) ||
ev.isChanged(R.string.key_absorption_maxtime) ev.isChanged(R.string.key_absorption_maxtime) ||
ev.isChanged(R.string.key_openapsama_min_5m_carbimpact) ||
ev.isChanged(R.string.key_absorption_cutoff)
) { ) {
stopCalculation("onEventPreferenceChange"); stopCalculation("onEventPreferenceChange");
synchronized (dataLock) { synchronized (dataLock) {

View file

@ -17,15 +17,24 @@ import info.nightscout.androidaps.BuildConfig;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.Constants; import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.data.IobTotal; import info.nightscout.androidaps.data.IobTotal;
import info.nightscout.androidaps.data.Profile; import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.db.BgReading; import info.nightscout.androidaps.db.BgReading;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.events.Event; import info.nightscout.androidaps.events.Event;
import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalculationProgress;
import info.nightscout.androidaps.plugins.OpenAPSSMB.SMBDefaults;
import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.SP;
import static info.nightscout.utils.DateUtil.now;
/** /**
* Created by mike on 23.01.2018. * Created by mike on 23.01.2018.
@ -69,28 +78,28 @@ public class IobCobThread extends Thread {
} }
//log.debug("Locking calculateSensitivityData"); //log.debug("Locking calculateSensitivityData");
Object dataLock = iobCobCalculatorPlugin.dataLock;
long oldestTimeWithData = iobCobCalculatorPlugin.oldestDataAvailable(); long oldestTimeWithData = iobCobCalculatorPlugin.oldestDataAvailable();
synchronized (dataLock) { synchronized (iobCobCalculatorPlugin.dataLock) {
if (bgDataReload) { if (bgDataReload) {
iobCobCalculatorPlugin.loadBgData(start); iobCobCalculatorPlugin.loadBgData(start);
iobCobCalculatorPlugin.createBucketedData(); iobCobCalculatorPlugin.createBucketedData();
} }
List<BgReading> bucketed_data = iobCobCalculatorPlugin.getBucketedData(); List<BgReading> bucketed_data = iobCobCalculatorPlugin.getBucketedData();
LongSparseArray<AutosensData> autosensDataTable = iobCobCalculatorPlugin.getAutosensDataTable(); LongSparseArray<AutosensData> autosensDataTable = IobCobCalculatorPlugin.getPlugin().getAutosensDataTable();
if (bucketed_data == null || bucketed_data.size() < 3) { if (bucketed_data == null || bucketed_data.size() < 3) {
log.debug("Aborting calculation thread (No bucketed data available): " + from); log.debug("Aborting calculation thread (No bucketed data available): " + from);
return; return;
} }
long prevDataTime = iobCobCalculatorPlugin.roundUpTime(bucketed_data.get(bucketed_data.size() - 3).date); long prevDataTime = IobCobCalculatorPlugin.roundUpTime(bucketed_data.get(bucketed_data.size() - 3).date);
log.debug("Prev data time: " + new Date(prevDataTime).toLocaleString()); log.debug("Prev data time: " + new Date(prevDataTime).toLocaleString());
AutosensData previous = autosensDataTable.get(prevDataTime); AutosensData previous = autosensDataTable.get(prevDataTime);
// start from oldest to be able sub cob // start from oldest to be able sub cob
for (int i = bucketed_data.size() - 4; i >= 0; i--) { for (int i = bucketed_data.size() - 4; i >= 0; i--) {
MainApp.bus().post(new EventIobCalculationProgress(i + "/" + bucketed_data.size()));
if (iobCobCalculatorPlugin.stopCalculationTrigger) { if (iobCobCalculatorPlugin.stopCalculationTrigger) {
iobCobCalculatorPlugin.stopCalculationTrigger = false; iobCobCalculatorPlugin.stopCalculationTrigger = false;
log.debug("Aborting calculation thread (trigger): " + from); log.debug("Aborting calculation thread (trigger): " + from);
@ -98,10 +107,9 @@ public class IobCobThread extends Thread {
} }
// check if data already exists // check if data already exists
long bgTime = bucketed_data.get(i).date; long bgTime = bucketed_data.get(i).date;
bgTime = iobCobCalculatorPlugin.roundUpTime(bgTime); bgTime = IobCobCalculatorPlugin.roundUpTime(bgTime);
if (bgTime > System.currentTimeMillis()) if (bgTime > IobCobCalculatorPlugin.roundUpTime(now()))
continue; continue;
Profile profile = MainApp.getConfigBuilder().getProfile(bgTime);
AutosensData existing; AutosensData existing;
if ((existing = autosensDataTable.get(bgTime)) != null) { if ((existing = autosensDataTable.get(bgTime)) != null) {
@ -109,6 +117,7 @@ public class IobCobThread extends Thread {
continue; continue;
} }
Profile profile = MainApp.getConfigBuilder().getProfile(bgTime);
if (profile == null) { if (profile == null) {
log.debug("Aborting calculation thread (no profile): " + from); log.debug("Aborting calculation thread (no profile): " + from);
return; // profile not set yet return; // profile not set yet
@ -152,7 +161,7 @@ public class IobCobThread extends Thread {
// https://github.com/openaps/oref0/blob/master/lib/determine-basal/cob-autosens.js#L169 // https://github.com/openaps/oref0/blob/master/lib/determine-basal/cob-autosens.js#L169
if (i < bucketed_data.size() - 16) { // we need 1h of data to calculate minDeviationSlope if (i < bucketed_data.size() - 16) { // we need 1h of data to calculate minDeviationSlope
long hourago = bgTime + 10 * 1000 - 60 * 60 * 1000L; long hourago = bgTime + 10 * 1000 - 60 * 60 * 1000L;
AutosensData hourAgoData = iobCobCalculatorPlugin.getAutosensData(hourago); AutosensData hourAgoData = IobCobCalculatorPlugin.getPlugin().getAutosensData(hourago);
if (hourAgoData != null) { if (hourAgoData != null) {
int initialIndex = autosensDataTable.indexOfKey(hourAgoData.time); int initialIndex = autosensDataTable.indexOfKey(hourAgoData.time);
if (Config.logAutosensData) if (Config.logAutosensData)
@ -199,18 +208,27 @@ public class IobCobThread extends Thread {
if (previous != null && previous.cob > 0) { if (previous != null && previous.cob > 0) {
// calculate sum of min carb impact from all active treatments // calculate sum of min carb impact from all active treatments
double totalMinCarbsImpact = 0d; double totalMinCarbsImpact = 0d;
for (int ii = 0; ii < autosensData.activeCarbsList.size(); ++ii) { if (SensitivityAAPSPlugin.getPlugin().isEnabled(PluginType.SENSITIVITY) || SensitivityWeightedAveragePlugin.getPlugin().isEnabled(PluginType.SENSITIVITY)) {
AutosensData.CarbsInPast c = autosensData.activeCarbsList.get(ii); //when the impact depends on a max time, sum them up as smaller carb sizes make them smaller
totalMinCarbsImpact += c.min5minCarbImpact; for (int ii = 0; ii < autosensData.activeCarbsList.size(); ++ii) {
AutosensData.CarbsInPast c = autosensData.activeCarbsList.get(ii);
totalMinCarbsImpact += c.min5minCarbImpact;
}
} else {
//Oref sensitivity
totalMinCarbsImpact = SP.getDouble(R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact);
} }
// figure out how many carbs that represents // figure out how many carbs that represents
// but always assume at least 3mg/dL/5m (default) absorption per active treatment // but always assume at least 3mg/dL/5m (default) absorption per active treatment
double ci = Math.max(deviation, totalMinCarbsImpact); double ci = Math.max(deviation, totalMinCarbsImpact);
if (ci != deviation)
autosensData.failoverToMinAbsorbtionRate = true;
autosensData.absorbed = ci * profile.getIc(bgTime) / sens; autosensData.absorbed = ci * profile.getIc(bgTime) / sens;
// and add that to the running total carbsAbsorbed // and add that to the running total carbsAbsorbed
autosensData.cob = Math.max(previous.cob - autosensData.absorbed, 0d); autosensData.cob = Math.max(previous.cob - autosensData.absorbed, 0d);
autosensData.substractAbosorbedCarbs(); autosensData.substractAbosorbedCarbs();
autosensData.usedMinCarbsImpact = totalMinCarbsImpact;
} }
autosensData.removeOldCarbs(bgTime); autosensData.removeOldCarbs(bgTime);
autosensData.cob += autosensData.carbsFromBolus; autosensData.cob += autosensData.carbsFromBolus;
@ -254,6 +272,7 @@ public class IobCobThread extends Thread {
log.debug("Finishing calculation thread: " + from); log.debug("Finishing calculation thread: " + from);
} finally { } finally {
mWakeLock.release(); mWakeLock.release();
MainApp.bus().post(new EventIobCalculationProgress(""));
} }
} }

View file

@ -0,0 +1,11 @@
package info.nightscout.androidaps.plugins.IobCobCalculator.events;
import info.nightscout.androidaps.events.Event;
public class EventIobCalculationProgress extends Event {
public String progress;
public EventIobCalculationProgress(String progress) {
this.progress = progress;
}
}

View file

@ -24,6 +24,8 @@ import info.nightscout.androidaps.Constants;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R; import info.nightscout.androidaps.R;
import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.events.EventNetworkChange;
import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PluginBase;
import info.nightscout.androidaps.interfaces.PluginDescription; import info.nightscout.androidaps.interfaces.PluginDescription;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
@ -31,6 +33,7 @@ import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientN
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientStatus;
import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI; import info.nightscout.androidaps.plugins.NSClientInternal.events.EventNSClientUpdateGUI;
import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService; import info.nightscout.androidaps.plugins.NSClientInternal.services.NSClientService;
import info.nightscout.androidaps.receivers.NetworkChangeReceiver;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
import info.nightscout.utils.ToastUtils; import info.nightscout.utils.ToastUtils;
@ -52,13 +55,14 @@ public class NSClientPlugin extends PluginBase {
Spanned textLog = Html.fromHtml(""); Spanned textLog = Html.fromHtml("");
public boolean paused = false; public boolean paused = false;
public boolean allowed = true;
boolean autoscroll = true; boolean autoscroll = true;
public String status = ""; public String status = "";
public NSClientService nsClientService = null; public NSClientService nsClientService = null;
public NSClientPlugin() { private NSClientPlugin() {
super(new PluginDescription() super(new PluginDescription()
.mainType(PluginType.GENERAL) .mainType(PluginType.GENERAL)
.fragmentClass(NSClientFragment.class.getName()) .fragmentClass(NSClientFragment.class.getName())
@ -87,6 +91,10 @@ public class NSClientPlugin extends PluginBase {
Intent intent = new Intent(context, NSClientService.class); Intent intent = new Intent(context, NSClientService.class);
context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE); context.bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
super.onStart(); super.onStart();
EventNetworkChange event = NetworkChangeReceiver.grabNetworkStatus();
if (event != null)
MainApp.bus().post(event);
} }
@Override @Override
@ -111,9 +119,39 @@ public class NSClientPlugin extends PluginBase {
} }
}; };
@SuppressWarnings("UnusedParameters")
@Subscribe @Subscribe
public void onStatusEvent(final EventAppExit e) { public void onStatusEvent(EventPreferenceChange ev) {
if (ev.isChanged(R.string.key_ns_wifionly) ||
ev.isChanged(R.string.key_ns_wifi_ssids) ||
ev.isChanged(R.string.key_ns_allowroaming)
) {
EventNetworkChange event = NetworkChangeReceiver.grabNetworkStatus();
if (event != null)
MainApp.bus().post(event);
}
}
@Subscribe
public void onStatusEvent(final EventNetworkChange ev) {
boolean wifiOnly = SP.getBoolean(R.string.key_ns_wifionly, false);
String allowedSSIDs = SP.getString(R.string.key_ns_wifi_ssids, "");
boolean allowRoaming = SP.getBoolean(R.string.key_ns_allowroaming, true);
boolean newAllowedState = true;
if (!ev.wifiConnected && wifiOnly) newAllowedState = false;
if (ev.wifiConnected && !allowedSSIDs.isEmpty() && !allowedSSIDs.contains(ev.ssid))
newAllowedState = false;
if (!allowRoaming && ev.roaming) newAllowedState = false;
if (newAllowedState != allowed) {
allowed = newAllowedState;
MainApp.bus().post(new EventPreferenceChange(R.string.key_nsclientinternal_paused));
}
}
@Subscribe
public void onStatusEvent(final EventAppExit ignored) {
if (nsClientService != null) if (nsClientService != null)
MainApp.instance().getApplicationContext().unbindService(mConnection); MainApp.instance().getApplicationContext().unbindService(mConnection);
} }

View file

@ -203,7 +203,10 @@ public class NSClientService extends Service {
nsAPIhashCode = Hashing.sha1().hashString(nsAPISecret, Charsets.UTF_8).toString(); nsAPIhashCode = Hashing.sha1().hashString(nsAPISecret, Charsets.UTF_8).toString();
MainApp.bus().post(new EventNSClientStatus("Initializing")); MainApp.bus().post(new EventNSClientStatus("Initializing"));
if (MainApp.getSpecificPlugin(NSClientPlugin.class).paused) { if (!MainApp.getSpecificPlugin(NSClientPlugin.class).allowed) {
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "not allowed"));
MainApp.bus().post(new EventNSClientStatus("Not allowed"));
} else if (MainApp.getSpecificPlugin(NSClientPlugin.class).paused) {
MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "paused")); MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "paused"));
MainApp.bus().post(new EventNSClientStatus("Paused")); MainApp.bus().post(new EventNSClientStatus("Paused"));
} else if (!nsEnabled) { } else if (!nsEnabled) {
@ -652,7 +655,7 @@ public class NSClientService extends Service {
} }
//MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "onDataUpdate end"); //MainApp.bus().post(new EventNSClientNewLog("NSCLIENT", "onDataUpdate end");
} finally { } finally {
if (wakeLock.isHeld()) wakeLock.release(); if (wakeLock.isHeld()) wakeLock.release();
} }
} }

View file

@ -213,8 +213,12 @@ public class DetermineBasalAdapterAMAJS {
mProfile.put("current_basal", basalrate); mProfile.put("current_basal", basalrate);
mProfile.put("temptargetSet", tempTargetSet); mProfile.put("temptargetSet", tempTargetSet);
mProfile.put("autosens_adjust_targets", SP.getBoolean("openapsama_autosens_adjusttargets", true)); mProfile.put("autosens_adjust_targets", SP.getBoolean("openapsama_autosens_adjusttargets", true));
//TODO: align with max-absorption model in AMA sensitivity //align with max-absorption model in AMA sensitivity
mProfile.put("min_5m_carbimpact", SP.getDouble("openapsama_min_5m_carbimpact", SMBDefaults.min_5m_carbimpact)); if(mealData.usedMinCarbsImpact > 0){
mProfile.put("min_5m_carbimpact", mealData.usedMinCarbsImpact);
} else {
mProfile.put("min_5m_carbimpact", SP.getDouble(R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact));
}
if (units.equals(Constants.MMOL)) { if (units.equals(Constants.MMOL)) {
mProfile.put("out_units", "mmol/L"); mProfile.put("out_units", "mmol/L");

View file

@ -243,9 +243,12 @@ public class DetermineBasalAdapterSMBJS {
mProfile.put("half_basal_exercise_target", SMBDefaults.half_basal_exercise_target); mProfile.put("half_basal_exercise_target", SMBDefaults.half_basal_exercise_target);
mProfile.put("maxCOB", SMBDefaults.maxCOB); mProfile.put("maxCOB", SMBDefaults.maxCOB);
mProfile.put("skip_neutral_temps", SMBDefaults.skip_neutral_temps); mProfile.put("skip_neutral_temps", SMBDefaults.skip_neutral_temps);
//TODO: align with max-absorption model in AMA sensitivity //align with max-absorption model in AMA sensitivity
mProfile.put("min_5m_carbimpact", SP.getDouble("openapsama_min_5m_carbimpact", SMBDefaults.min_5m_carbimpact)); if(mealData.usedMinCarbsImpact > 0){
; mProfile.put("min_5m_carbimpact", mealData.usedMinCarbsImpact);
} else {
mProfile.put("min_5m_carbimpact", SP.getDouble(R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact));
}
mProfile.put("remainingCarbsCap", SMBDefaults.remainingCarbsCap); mProfile.put("remainingCarbsCap", SMBDefaults.remainingCarbsCap);
mProfile.put("enableUAM", SP.getBoolean(R.string.key_use_uam, false)); mProfile.put("enableUAM", SP.getBoolean(R.string.key_use_uam, false));
mProfile.put("A52_risk_enable", SMBDefaults.A52_risk_enable); mProfile.put("A52_risk_enable", SMBDefaults.A52_risk_enable);

View file

@ -431,7 +431,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
carbInfo.context = getContext(); carbInfo.context = getContext();
carbInfo.source = Source.USER; carbInfo.source = Source.USER;
carbInfo.notes = notes; carbInfo.notes = notes;
if (ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo) { if (ConfigBuilderPlugin.getActivePump().getPumpDescription().storesCarbInfo && carbInfo.date <= now()) {
ConfigBuilderPlugin.getCommandQueue().bolus(carbInfo, new Callback() { ConfigBuilderPlugin.getCommandQueue().bolus(carbInfo, new Callback() {
@Override @Override
public void run() { public void run() {

View file

@ -35,6 +35,7 @@ import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.androidaps.queue.Callback; import info.nightscout.androidaps.queue.Callback;
import info.nightscout.utils.DecimalFormatter;
import info.nightscout.utils.FabricPrivacy; import info.nightscout.utils.FabricPrivacy;
import info.nightscout.utils.NumberPicker; import info.nightscout.utils.NumberPicker;
import info.nightscout.utils.SafeParse; import info.nightscout.utils.SafeParse;
@ -104,7 +105,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_insulinamount); editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_insulinamount);
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher); editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, new DecimalFormat("0.00"), false, textWatcher); editInsulin.setParams(0d, 0d, maxInsulin, ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, DecimalFormatter.pumpSupportedBolusFormat(), false, textWatcher);
recordOnlyCheckbox = (CheckBox) view.findViewById(R.id.newtreatment_record_only); recordOnlyCheckbox = (CheckBox) view.findViewById(R.id.newtreatment_record_only);

View file

@ -5,7 +5,6 @@ import android.app.Activity;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.content.ActivityNotFoundException; import android.content.ActivityNotFoundException;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.graphics.Color; import android.graphics.Color;
@ -15,10 +14,8 @@ import android.os.Handler;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.res.ResourcesCompat; import android.support.v4.content.res.ResourcesCompat;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.widget.CardView;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.PopupMenu; import android.support.v7.widget.PopupMenu;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
@ -33,7 +30,6 @@ import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CheckBox; import android.widget.CheckBox;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import android.widget.ImageButton; import android.widget.ImageButton;
@ -52,8 +48,6 @@ import org.slf4j.LoggerFactory;
import java.text.DecimalFormat; import java.text.DecimalFormat;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
@ -97,9 +91,9 @@ import info.nightscout.androidaps.plugins.ConstraintsObjectives.ObjectivesPlugin
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData; import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished;
import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventIobCalculationProgress;
import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification; 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.NSClientInternal.data.NSDeviceStatus;
import info.nightscout.androidaps.plugins.Overview.Dialogs.CalibrationDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.CalibrationDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity; import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
@ -108,10 +102,8 @@ import info.nightscout.androidaps.plugins.Overview.Dialogs.NewInsulinDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTreatmentDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.NewTreatmentDialog;
import info.nightscout.androidaps.plugins.Overview.Dialogs.WizardDialog; import info.nightscout.androidaps.plugins.Overview.Dialogs.WizardDialog;
import info.nightscout.androidaps.plugins.Overview.activities.QuickWizardListActivity; import info.nightscout.androidaps.plugins.Overview.activities.QuickWizardListActivity;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.events.EventSetWakeLock; import info.nightscout.androidaps.plugins.Overview.events.EventSetWakeLock;
import info.nightscout.androidaps.plugins.Overview.graphData.GraphData; import info.nightscout.androidaps.plugins.Overview.graphData.GraphData;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.Overview.notifications.NotificationRecyclerViewAdapter; import info.nightscout.androidaps.plugins.Overview.notifications.NotificationRecyclerViewAdapter;
import info.nightscout.androidaps.plugins.Overview.notifications.NotificationStore; import info.nightscout.androidaps.plugins.Overview.notifications.NotificationStore;
import info.nightscout.androidaps.plugins.Source.SourceDexcomG5Plugin; import info.nightscout.androidaps.plugins.Source.SourceDexcomG5Plugin;
@ -150,6 +142,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
TextView pumpDeviceStatusView; TextView pumpDeviceStatusView;
TextView openapsDeviceStatusView; TextView openapsDeviceStatusView;
TextView uploaderDeviceStatusView; TextView uploaderDeviceStatusView;
TextView iobCalculationProgressView;
LinearLayout loopStatusLayout; LinearLayout loopStatusLayout;
LinearLayout pumpStatusLayout; LinearLayout pumpStatusLayout;
GraphView bgGraph; GraphView bgGraph;
@ -191,9 +184,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
final Object updateSync = new Object(); final Object updateSync = new Object();
public enum CHARTTYPE {PRE, BAS, IOB, COB, DEV, SEN} public enum CHARTTYPE {PRE, BAS, IOB, COB, DEV, SEN, DEVSLOPE}
;
private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor(); private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
private static ScheduledFuture<?> scheduledUpdate = null; private static ScheduledFuture<?> scheduledUpdate = null;
@ -245,6 +236,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
pumpDeviceStatusView = (TextView) view.findViewById(R.id.overview_pump); pumpDeviceStatusView = (TextView) view.findViewById(R.id.overview_pump);
openapsDeviceStatusView = (TextView) view.findViewById(R.id.overview_openaps); openapsDeviceStatusView = (TextView) view.findViewById(R.id.overview_openaps);
uploaderDeviceStatusView = (TextView) view.findViewById(R.id.overview_uploader); uploaderDeviceStatusView = (TextView) view.findViewById(R.id.overview_uploader);
iobCalculationProgressView = (TextView) view.findViewById(R.id.overview_iobcalculationprogess);
loopStatusLayout = (LinearLayout) view.findViewById(R.id.overview_looplayout); loopStatusLayout = (LinearLayout) view.findViewById(R.id.overview_looplayout);
pumpStatusLayout = (LinearLayout) view.findViewById(R.id.overview_pumpstatuslayout); pumpStatusLayout = (LinearLayout) view.findViewById(R.id.overview_pumpstatuslayout);
@ -416,26 +408,33 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
item.setCheckable(true); item.setCheckable(true);
item.setChecked(SP.getBoolean("showratios", false)); item.setChecked(SP.getBoolean("showratios", false));
if (MainApp.devBranch) {
item = popup.getMenu().add(Menu.NONE, CHARTTYPE.DEVSLOPE.ordinal(), Menu.NONE, "Deviation slope");
title = item.getTitle();
s = new SpannableString(title);
s.setSpan(new ForegroundColorSpan(ResourcesCompat.getColor(getResources(), R.color.devslopepos, null)), 0, s.length(), 0);
item.setTitle(s);
item.setCheckable(true);
item.setChecked(SP.getBoolean("showdevslope", false));
}
popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem item) { public boolean onMenuItemClick(MenuItem item) {
if (item.getItemId() == CHARTTYPE.PRE.ordinal()) { if (item.getItemId() == CHARTTYPE.PRE.ordinal()) {
SP.putBoolean("showprediction", !item.isChecked()); SP.putBoolean("showprediction", !item.isChecked());
} else if (item.getItemId() == CHARTTYPE.BAS.ordinal()) { } else if (item.getItemId() == CHARTTYPE.BAS.ordinal()) {
SP.putBoolean("showbasals", !item.isChecked()); SP.putBoolean("showbasals", !item.isChecked());
} else if (item.getItemId() == CHARTTYPE.IOB.ordinal()) { } else if (item.getItemId() == CHARTTYPE.IOB.ordinal()) {
SP.putBoolean("showiob", !item.isChecked()); SP.putBoolean("showiob", !item.isChecked());
} else if (item.getItemId() == CHARTTYPE.COB.ordinal()) { } else if (item.getItemId() == CHARTTYPE.COB.ordinal()) {
SP.putBoolean("showcob", !item.isChecked()); SP.putBoolean("showcob", !item.isChecked());
} else if (item.getItemId() == CHARTTYPE.DEV.ordinal()) { } else if (item.getItemId() == CHARTTYPE.DEV.ordinal()) {
SP.putBoolean("showdeviations", !item.isChecked()); SP.putBoolean("showdeviations", !item.isChecked());
} else if (item.getItemId() == CHARTTYPE.SEN.ordinal()) { } else if (item.getItemId() == CHARTTYPE.SEN.ordinal()) {
SP.putBoolean("showratios", !item.isChecked()); SP.putBoolean("showratios", !item.isChecked());
} else if (item.getItemId() == CHARTTYPE.DEVSLOPE.ordinal()) {
SP.putBoolean("showdevslope", !item.isChecked());
} }
scheduleUpdateGUI("onGraphCheckboxesCheckedChanged"); scheduleUpdateGUI("onGraphCheckboxesCheckedChanged");
return true; return true;
@ -911,15 +910,22 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
activity.runOnUiThread(() -> updatePumpStatus(s.textStatus())); activity.runOnUiThread(() -> updatePumpStatus(s.textStatus()));
} }
@Subscribe
public void onStatusEvent(final EventIobCalculationProgress e) {
Activity activity = getActivity();
if (activity != null)
activity.runOnUiThread(() -> {
if (iobCalculationProgressView != null)
iobCalculationProgressView.setText(e.progress);
});
}
private void hideTempRecommendation() { private void hideTempRecommendation() {
Activity activity = getActivity(); Activity activity = getActivity();
if (activity != null) if (activity != null)
activity.runOnUiThread(new Runnable() { activity.runOnUiThread(() -> {
@Override if (acceptTempLayout != null)
public void run() { acceptTempLayout.setVisibility(View.GONE);
if (acceptTempLayout != null)
acceptTempLayout.setVisibility(View.GONE);
}
}); });
} }
@ -1386,7 +1392,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
useDevForScale = true; useDevForScale = true;
} else if (SP.getBoolean("showratios", false)) { } else if (SP.getBoolean("showratios", false)) {
useRatioForScale = true; useRatioForScale = true;
} else if (Config.displayDeviationSlope) { } else if (SP.getBoolean("showdevslope", false)) {
useDSForScale = true; useDSForScale = true;
} }
@ -1398,7 +1404,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
secondGraphData.addDeviations(fromTime, now, useDevForScale, 1d); secondGraphData.addDeviations(fromTime, now, useDevForScale, 1d);
if (SP.getBoolean("showratios", false)) if (SP.getBoolean("showratios", false))
secondGraphData.addRatio(fromTime, now, useRatioForScale, 1d); secondGraphData.addRatio(fromTime, now, useRatioForScale, 1d);
if (Config.displayDeviationSlope) if (SP.getBoolean("showdevslope", false))
secondGraphData.addDeviationSlope(fromTime, now, useDSForScale, 1d); secondGraphData.addDeviationSlope(fromTime, now, useDSForScale, 1d);
// **** NOW line **** // **** NOW line ****
@ -1410,7 +1416,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
FragmentActivity activity = getActivity(); FragmentActivity activity = getActivity();
if (activity != null) { if (activity != null) {
activity.runOnUiThread(() -> { activity.runOnUiThread(() -> {
if (SP.getBoolean("showiob", true) || SP.getBoolean("showcob", true) || SP.getBoolean("showdeviations", false) || SP.getBoolean("showratios", false) || Config.displayDeviationSlope) { if (SP.getBoolean("showiob", true)
|| SP.getBoolean("showcob", true)
|| SP.getBoolean("showdeviations", false)
|| SP.getBoolean("showratios", false)
|| SP.getBoolean("showdevslope", false)) {
iobGraph.setVisibility(View.VISIBLE); iobGraph.setVisibility(View.VISIBLE);
} else { } else {
iobGraph.setVisibility(View.GONE); iobGraph.setVisibility(View.GONE);

View file

@ -108,7 +108,7 @@ public class GraphData {
inRangeAreaSeries = new AreaGraphSeries<>(inRangeAreaDataPoints); inRangeAreaSeries = new AreaGraphSeries<>(inRangeAreaDataPoints);
inRangeAreaSeries.setColor(0); inRangeAreaSeries.setColor(0);
inRangeAreaSeries.setDrawBackground(true); inRangeAreaSeries.setDrawBackground(true);
inRangeAreaSeries.setBackgroundColor(MainApp.sResources.getColor(R.color.inrangebackground)); inRangeAreaSeries.setBackgroundColor(MainApp.gc(R.color.inrangebackground));
addSeries(inRangeAreaSeries); addSeries(inRangeAreaSeries);
} }
@ -184,14 +184,14 @@ public class GraphData {
baseBasal = baseBasalArray.toArray(baseBasal); baseBasal = baseBasalArray.toArray(baseBasal);
baseBasalsSeries = new LineGraphSeries<>(baseBasal); baseBasalsSeries = new LineGraphSeries<>(baseBasal);
baseBasalsSeries.setDrawBackground(true); baseBasalsSeries.setDrawBackground(true);
baseBasalsSeries.setBackgroundColor(MainApp.sResources.getColor(R.color.basebasal)); baseBasalsSeries.setBackgroundColor(MainApp.gc(R.color.basebasal));
baseBasalsSeries.setThickness(0); baseBasalsSeries.setThickness(0);
ScaledDataPoint[] tempBasal = new ScaledDataPoint[tempBasalArray.size()]; ScaledDataPoint[] tempBasal = new ScaledDataPoint[tempBasalArray.size()];
tempBasal = tempBasalArray.toArray(tempBasal); tempBasal = tempBasalArray.toArray(tempBasal);
tempBasalsSeries = new LineGraphSeries<>(tempBasal); tempBasalsSeries = new LineGraphSeries<>(tempBasal);
tempBasalsSeries.setDrawBackground(true); tempBasalsSeries.setDrawBackground(true);
tempBasalsSeries.setBackgroundColor(MainApp.sResources.getColor(R.color.tempbasal)); tempBasalsSeries.setBackgroundColor(MainApp.gc(R.color.tempbasal));
tempBasalsSeries.setThickness(0); tempBasalsSeries.setThickness(0);
ScaledDataPoint[] basalLine = new ScaledDataPoint[basalLineArray.size()]; ScaledDataPoint[] basalLine = new ScaledDataPoint[basalLineArray.size()];
@ -201,7 +201,7 @@ public class GraphData {
paint.setStyle(Paint.Style.STROKE); paint.setStyle(Paint.Style.STROKE);
paint.setStrokeWidth(MainApp.instance().getApplicationContext().getResources().getDisplayMetrics().scaledDensity * 2); paint.setStrokeWidth(MainApp.instance().getApplicationContext().getResources().getDisplayMetrics().scaledDensity * 2);
paint.setPathEffect(new DashPathEffect(new float[]{2, 4}, 0)); paint.setPathEffect(new DashPathEffect(new float[]{2, 4}, 0));
paint.setColor(MainApp.sResources.getColor(R.color.basal)); paint.setColor(MainApp.gc(R.color.basal));
basalsLineSeries.setCustomPaint(paint); basalsLineSeries.setCustomPaint(paint);
ScaledDataPoint[] absoluteBasalLine = new ScaledDataPoint[absoluteBasalLineArray.size()]; ScaledDataPoint[] absoluteBasalLine = new ScaledDataPoint[absoluteBasalLineArray.size()];
@ -210,7 +210,7 @@ public class GraphData {
Paint absolutePaint = new Paint(); Paint absolutePaint = new Paint();
absolutePaint.setStyle(Paint.Style.STROKE); absolutePaint.setStyle(Paint.Style.STROKE);
absolutePaint.setStrokeWidth(MainApp.instance().getApplicationContext().getResources().getDisplayMetrics().scaledDensity * 2); absolutePaint.setStrokeWidth(MainApp.instance().getApplicationContext().getResources().getDisplayMetrics().scaledDensity * 2);
absolutePaint.setColor(MainApp.sResources.getColor(R.color.basal)); absolutePaint.setColor(MainApp.gc(R.color.basal));
absoluteBasalsLineSeries.setCustomPaint(absolutePaint); absoluteBasalsLineSeries.setCustomPaint(absolutePaint);
basalScale.setMultiplier(maxY * scale / maxBasalValueFound); basalScale.setMultiplier(maxY * scale / maxBasalValueFound);
@ -259,7 +259,7 @@ public class GraphData {
targets = targetsSeriesArray.toArray(targets); targets = targetsSeriesArray.toArray(targets);
targetsSeries = new LineGraphSeries<>(targets); targetsSeries = new LineGraphSeries<>(targets);
targetsSeries.setDrawBackground(false); targetsSeries.setDrawBackground(false);
targetsSeries.setColor(MainApp.sResources.getColor(R.color.tempTargetBackground)); targetsSeries.setColor(MainApp.gc(R.color.tempTargetBackground));
targetsSeries.setThickness(2); targetsSeries.setThickness(2);
addSeries(targetsSeries); addSeries(targetsSeries);
@ -351,8 +351,8 @@ public class GraphData {
iobData = iobArray.toArray(iobData); iobData = iobArray.toArray(iobData);
iobSeries = new FixedLineGraphSeries<>(iobData); iobSeries = new FixedLineGraphSeries<>(iobData);
iobSeries.setDrawBackground(true); iobSeries.setDrawBackground(true);
iobSeries.setBackgroundColor(0x80FFFFFF & MainApp.sResources.getColor(R.color.iob)); //50% iobSeries.setBackgroundColor(0x80FFFFFF & MainApp.gc(R.color.iob)); //50%
iobSeries.setColor(MainApp.sResources.getColor(R.color.iob)); iobSeries.setColor(MainApp.gc(R.color.iob));
iobSeries.setThickness(3); iobSeries.setThickness(3);
if (useForScale) if (useForScale)
@ -365,6 +365,7 @@ public class GraphData {
// scale in % of vertical size (like 0.3) // scale in % of vertical size (like 0.3)
public void addCob(long fromTime, long toTime, boolean useForScale, double scale) { public void addCob(long fromTime, long toTime, boolean useForScale, double scale) {
List<DataPointWithLabelInterface> minFailoverActiveList = new ArrayList<>();
FixedLineGraphSeries<ScaledDataPoint> cobSeries; FixedLineGraphSeries<ScaledDataPoint> cobSeries;
List<ScaledDataPoint> cobArray = new ArrayList<>(); List<ScaledDataPoint> cobArray = new ArrayList<>();
Double maxCobValueFound = 0d; Double maxCobValueFound = 0d;
@ -382,6 +383,10 @@ public class GraphData {
maxCobValueFound = Math.max(maxCobValueFound, cob); maxCobValueFound = Math.max(maxCobValueFound, cob);
lastCob = cob; lastCob = cob;
} }
if (autosensData.failoverToMinAbsorbtionRate) {
autosensData.setScale(cobScale);
minFailoverActiveList.add(autosensData);
}
} }
} }
@ -390,8 +395,8 @@ public class GraphData {
cobData = cobArray.toArray(cobData); cobData = cobArray.toArray(cobData);
cobSeries = new FixedLineGraphSeries<>(cobData); cobSeries = new FixedLineGraphSeries<>(cobData);
cobSeries.setDrawBackground(true); cobSeries.setDrawBackground(true);
cobSeries.setBackgroundColor(0xB0FFFFFF & MainApp.sResources.getColor(R.color.cob)); //50% cobSeries.setBackgroundColor(0xB0FFFFFF & MainApp.gc(R.color.cob)); //50%
cobSeries.setColor(MainApp.sResources.getColor(R.color.cob)); cobSeries.setColor(MainApp.gc(R.color.cob));
cobSeries.setThickness(3); cobSeries.setThickness(3);
if (useForScale) if (useForScale)
@ -400,6 +405,10 @@ public class GraphData {
cobScale.setMultiplier(maxY * scale / maxCobValueFound); cobScale.setMultiplier(maxY * scale / maxCobValueFound);
addSeries(cobSeries); addSeries(cobSeries);
DataPointWithLabelInterface[] minFailover = new DataPointWithLabelInterface[minFailoverActiveList.size()];
minFailover = minFailoverActiveList.toArray(minFailover);
addSeries(new PointsWithLabelGraphSeries<>(minFailover));
} }
// scale in % of vertical size (like 0.3) // scale in % of vertical size (like 0.3)
@ -468,7 +477,7 @@ public class GraphData {
ScaledDataPoint[] ratioData = new ScaledDataPoint[ratioArray.size()]; ScaledDataPoint[] ratioData = new ScaledDataPoint[ratioArray.size()];
ratioData = ratioArray.toArray(ratioData); ratioData = ratioArray.toArray(ratioData);
ratioSeries = new LineGraphSeries<>(ratioData); ratioSeries = new LineGraphSeries<>(ratioData);
ratioSeries.setColor(MainApp.sResources.getColor(R.color.ratio)); ratioSeries.setColor(MainApp.gc(R.color.ratio));
ratioSeries.setThickness(3); ratioSeries.setThickness(3);
if (useForScale) if (useForScale)
@ -504,13 +513,13 @@ public class GraphData {
ScaledDataPoint[] ratioMaxData = new ScaledDataPoint[dsMaxArray.size()]; ScaledDataPoint[] ratioMaxData = new ScaledDataPoint[dsMaxArray.size()];
ratioMaxData = dsMaxArray.toArray(ratioMaxData); ratioMaxData = dsMaxArray.toArray(ratioMaxData);
dsMaxSeries = new LineGraphSeries<>(ratioMaxData); dsMaxSeries = new LineGraphSeries<>(ratioMaxData);
dsMaxSeries.setColor(Color.MAGENTA); dsMaxSeries.setColor(MainApp.gc(R.color.devslopepos));
dsMaxSeries.setThickness(3); dsMaxSeries.setThickness(3);
ScaledDataPoint[] ratioMinData = new ScaledDataPoint[dsMinArray.size()]; ScaledDataPoint[] ratioMinData = new ScaledDataPoint[dsMinArray.size()];
ratioMinData = dsMinArray.toArray(ratioMinData); ratioMinData = dsMinArray.toArray(ratioMinData);
dsMinSeries = new LineGraphSeries<>(ratioMinData); dsMinSeries = new LineGraphSeries<>(ratioMinData);
dsMinSeries.setColor(Color.YELLOW); dsMinSeries.setColor(MainApp.gc(R.color.devslopeneg));
dsMinSeries.setThickness(3); dsMinSeries.setThickness(3);
if (useForScale) if (useForScale)

View file

@ -3,42 +3,46 @@ package info.nightscout.androidaps.plugins.Overview.graphExtensions;
/** /**
* GraphView * GraphView
* Copyright (C) 2014 Jonas Gehring * Copyright (C) 2014 Jonas Gehring
* * <p>
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, * the Free Software Foundation; either version 2 of the License,
* with the "Linking Exception", which can be found at the license.txt * with the "Linking Exception", which can be found at the license.txt
* file in this program. * file in this program.
* * <p>
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* * <p>
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* with the "Linking Exception" along with this program; if not, * with the "Linking Exception" along with this program; if not,
* write to the author Jonas Gehring <g.jjoe64@gmail.com>. * write to the author Jonas Gehring <g.jjoe64@gmail.com>.
* <p>
* Added by mike
*/ */
/** /**
* Added by mike * Added by mike
*/ */
import android.content.Context;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.Path; import android.graphics.Path;
import android.graphics.Point; import android.graphics.Point;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.Typeface; import android.graphics.Typeface;
import android.util.TypedValue;
// Added by Rumen for scalable text
import android.content.Context;
import info.nightscout.androidaps.MainApp;
import com.jjoe64.graphview.GraphView; import com.jjoe64.graphview.GraphView;
import com.jjoe64.graphview.series.BaseSeries; import com.jjoe64.graphview.series.BaseSeries;
import java.util.Iterator; import java.util.Iterator;
import info.nightscout.androidaps.MainApp;
// Added by Rumen for scalable text
/** /**
* Series that plots the data as points. * Series that plots the data as points.
* The points can be different shapes or a * The points can be different shapes or a
@ -74,7 +78,8 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
OPENAPSOFFLINE, OPENAPSOFFLINE,
EXERCISE, EXERCISE,
GENERAL, GENERAL,
GENERALWITHDURATION GENERALWITHDURATION,
COBFAILOVER
} }
/** /**
@ -148,7 +153,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
float scaleX = (float) (graphWidth / diffX); float scaleX = (float) (graphWidth / diffX);
int i=0; int i = 0;
while (values.hasNext()) { while (values.hasNext()) {
E value = values.next(); E value = values.next();
@ -182,7 +187,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
} }
/* Fix a bug that continue to show the DOT after Y axis */ /* Fix a bug that continue to show the DOT after Y axis */
if(x < 0) { if (x < 0) {
overdraw = true; overdraw = true;
} }
@ -197,10 +202,10 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
// draw data point // draw data point
if (!overdraw) { if (!overdraw) {
if (value.getShape() == Shape.BG) { if (value.getShape() == Shape.BG || value.getShape() == Shape.COBFAILOVER) {
mPaint.setStyle(Paint.Style.FILL); mPaint.setStyle(Paint.Style.FILL);
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
canvas.drawCircle(endX, endY, scaledPxSize, mPaint); canvas.drawCircle(endX, endY, value.getSize() * scaledPxSize, mPaint);
} else if (value.getShape() == Shape.PREDICTION) { } else if (value.getShape() == Shape.PREDICTION) {
mPaint.setColor(value.getColor()); mPaint.setColor(value.getColor());
mPaint.setStyle(Paint.Style.FILL); mPaint.setStyle(Paint.Style.FILL);
@ -211,20 +216,20 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
canvas.drawCircle(endX, endY, scaledPxSize / 3, mPaint); canvas.drawCircle(endX, endY, scaledPxSize / 3, mPaint);
} else if (value.getShape() == Shape.RECTANGLE) { } else if (value.getShape() == Shape.RECTANGLE) {
canvas.drawRect(endX-scaledPxSize, endY-scaledPxSize, endX+scaledPxSize, endY+scaledPxSize, mPaint); canvas.drawRect(endX - scaledPxSize, endY - scaledPxSize, endX + scaledPxSize, endY + scaledPxSize, mPaint);
} else if (value.getShape() == Shape.TRIANGLE) { } else if (value.getShape() == Shape.TRIANGLE) {
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
Point[] points = new Point[3]; Point[] points = new Point[3];
points[0] = new Point((int)endX, (int)(endY-scaledPxSize)); points[0] = new Point((int) endX, (int) (endY - scaledPxSize));
points[1] = new Point((int)(endX+scaledPxSize), (int)(endY+scaledPxSize*0.67)); points[1] = new Point((int) (endX + scaledPxSize), (int) (endY + scaledPxSize * 0.67));
points[2] = new Point((int)(endX-scaledPxSize), (int)(endY+scaledPxSize*0.67)); points[2] = new Point((int) (endX - scaledPxSize), (int) (endY + scaledPxSize * 0.67));
drawArrows(points, canvas, mPaint); drawArrows(points, canvas, mPaint);
} else if (value.getShape() == Shape.BOLUS) { } else if (value.getShape() == Shape.BOLUS) {
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
Point[] points = new Point[3]; Point[] points = new Point[3];
points[0] = new Point((int)endX, (int)(endY-scaledPxSize)); points[0] = new Point((int) endX, (int) (endY - scaledPxSize));
points[1] = new Point((int)(endX+scaledPxSize), (int)(endY+scaledPxSize*0.67)); points[1] = new Point((int) (endX + scaledPxSize), (int) (endY + scaledPxSize * 0.67));
points[2] = new Point((int)(endX-scaledPxSize), (int)(endY+scaledPxSize*0.67)); points[2] = new Point((int) (endX - scaledPxSize), (int) (endY + scaledPxSize * 0.67));
mPaint.setStyle(Paint.Style.FILL_AND_STROKE); mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
drawArrows(points, canvas, mPaint); drawArrows(points, canvas, mPaint);
if (value.getLabel() != null) { if (value.getLabel() != null) {
@ -234,15 +239,15 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
mPaint.setStrokeWidth(2); mPaint.setStrokeWidth(2);
Point[] points = new Point[3]; Point[] points = new Point[3];
float size = value.getSize() * scaledPxSize; float size = value.getSize() * scaledPxSize;
points[0] = new Point((int)endX, (int)(endY-size)); points[0] = new Point((int) endX, (int) (endY - size));
points[1] = new Point((int)(endX+size), (int)(endY+size*0.67)); points[1] = new Point((int) (endX + size), (int) (endY + size * 0.67));
points[2] = new Point((int)(endX-size), (int)(endY+size*0.67)); points[2] = new Point((int) (endX - size), (int) (endY + size * 0.67));
mPaint.setStyle(Paint.Style.FILL_AND_STROKE); mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
drawArrows(points, canvas, mPaint); drawArrows(points, canvas, mPaint);
} else if (value.getShape() == Shape.EXTENDEDBOLUS) { } else if (value.getShape() == Shape.EXTENDEDBOLUS) {
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
if (value.getLabel() != null) { if (value.getLabel() != null) {
Rect bounds = new Rect((int)endX, (int)endY + 3, (int) (xpluslength), (int) endY + 8); Rect bounds = new Rect((int) endX, (int) endY + 3, (int) (xpluslength), (int) endY + 8);
mPaint.setStyle(Paint.Style.FILL_AND_STROKE); mPaint.setStyle(Paint.Style.FILL_AND_STROKE);
canvas.drawRect(bounds, mPaint); canvas.drawRect(bounds, mPaint);
mPaint.setTextSize((float) (scaledTextSize)); mPaint.setTextSize((float) (scaledTextSize));
@ -254,7 +259,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
mPaint.setStrokeWidth(0); mPaint.setStrokeWidth(0);
if (value.getLabel() != null) { if (value.getLabel() != null) {
//mPaint.setTextSize((int) (scaledPxSize * 3)); //mPaint.setTextSize((int) (scaledPxSize * 3));
mPaint.setTextSize((float) (scaledTextSize*1.2)); mPaint.setTextSize((float) (scaledTextSize * 1.2));
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD)); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.BOLD));
Rect bounds = new Rect(); Rect bounds = new Rect();
mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds); mPaint.getTextBounds(value.getLabel(), 0, value.getLabel().length(), bounds);
@ -355,7 +360,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
* @param paint paint object * @param paint paint object
*/ */
private void drawArrows(Point[] point, Canvas canvas, Paint paint) { private void drawArrows(Point[] point, Canvas canvas, Paint paint) {
float [] points = new float[8]; float[] points = new float[8];
points[0] = point[0].x; points[0] = point[0].x;
points[1] = point[0].y; points[1] = point[0].y;
points[2] = point[1].x; points[2] = point[1].x;
@ -368,10 +373,10 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
canvas.save(); canvas.save();
canvas.drawVertices(Canvas.VertexMode.TRIANGLES, 8, points, 0, null, 0, null, 0, null, 0, 0, paint); canvas.drawVertices(Canvas.VertexMode.TRIANGLES, 8, points, 0, null, 0, null, 0, null, 0, 0, paint);
Path path = new Path(); Path path = new Path();
path.moveTo(point[0].x , point[0].y); path.moveTo(point[0].x, point[0].y);
path.lineTo(point[1].x,point[1].y); path.lineTo(point[1].x, point[1].y);
path.lineTo(point[2].x,point[2].y); path.lineTo(point[2].x, point[2].y);
canvas.drawPath(path,paint); canvas.drawPath(path, paint);
canvas.restore(); canvas.restore();
} }
@ -381,7 +386,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
float py = endY + scaledPxSize; float py = endY + scaledPxSize;
canvas.save(); canvas.save();
canvas.rotate(-45, px, py); canvas.rotate(-45, px, py);
mPaint.setTextSize((float) (scaledTextSize*0.8)); mPaint.setTextSize((float) (scaledTextSize * 0.8));
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL)); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
mPaint.setFakeBoldText(true); mPaint.setFakeBoldText(true);
mPaint.setTextAlign(Paint.Align.RIGHT); mPaint.setTextAlign(Paint.Align.RIGHT);
@ -393,7 +398,7 @@ public class PointsWithLabelGraphSeries<E extends DataPointWithLabelInterface> e
float py = endY - scaledPxSize; float py = endY - scaledPxSize;
canvas.save(); canvas.save();
canvas.rotate(-45, px, py); canvas.rotate(-45, px, py);
mPaint.setTextSize((float) (scaledTextSize*0.8)); mPaint.setTextSize((float) (scaledTextSize * 0.8));
mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL)); mPaint.setTypeface(Typeface.create(Typeface.DEFAULT, Typeface.NORMAL));
mPaint.setFakeBoldText(true); mPaint.setFakeBoldText(true);
canvas.drawText(value.getLabel(), px + scaledPxSize, py, mPaint); canvas.drawText(value.getLabel(), px + scaledPxSize, py, mPaint);

View file

@ -304,7 +304,11 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
@Override @Override
public void getPumpStatus() { public void getPumpStatus() {
if (sExecutionService != null) sExecutionService.getPumpStatus(); if (sExecutionService != null) {
sExecutionService.getPumpStatus();
pumpDescription.basalStep = pump.basalStep;
pumpDescription.bolusStep = pump.bolusStep;
}
} }
@Override @Override

View file

@ -18,6 +18,7 @@ import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStartWithSpeed;
import info.nightscout.androidaps.plugins.Treatments.Treatment; import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventPreferenceChange;
@ -129,7 +130,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
// Plugin base interface // Plugin base interface
@Override @Override
public String getName() { public String getName() {
return MainApp.instance().getString(R.string.danarpump); return MainApp.gs(R.string.danarpump);
} }
@Override @Override
@ -158,10 +159,13 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, detailedBolusInfo.carbTime, t); connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, detailedBolusInfo.carbTime, t);
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
result.success = connectionOK; result.success = connectionOK && detailedBolusInfo.insulin == t.insulin;
result.bolusDelivered = t.insulin; result.bolusDelivered = t.insulin;
result.carbsDelivered = detailedBolusInfo.carbs; result.carbsDelivered = detailedBolusInfo.carbs;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); if (!result.success)
result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, MsgBolusStartWithSpeed.errorCode);
else
result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
detailedBolusInfo.insulin = t.insulin; detailedBolusInfo.insulin = t.insulin;
@ -173,7 +177,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
result.success = false; result.success = false;
result.bolusDelivered = 0d; result.bolusDelivered = 0d;
result.carbsDelivered = 0d; result.carbsDelivered = 0d;
result.comment = MainApp.instance().getString(R.string.danar_invalidinput); result.comment = MainApp.gs(R.string.danar_invalidinput);
log.error("deliverTreatment: Invalid input"); log.error("deliverTreatment: Invalid input");
return result; return result;
} }
@ -342,7 +346,7 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
result.success = true; result.success = true;
result.enacted = false; result.enacted = false;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.isTempCancel = true; result.isTempCancel = true;
return result; return result;
} }
@ -358,13 +362,13 @@ public class DanaRPlugin extends AbstractDanaRPlugin {
if (!pump.isTempBasalInProgress) { if (!pump.isTempBasalInProgress) {
result.success = true; result.success = true;
result.isTempCancel = true; result.isTempCancel = true;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("cancelRealTempBasal: OK"); log.debug("cancelRealTempBasal: OK");
return result; return result;
} else { } else {
result.success = false; result.success = false;
result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly); result.comment = MainApp.gs(R.string.danar_valuenotsetproperly);
result.isTempCancel = true; result.isTempCancel = true;
log.error("cancelRealTempBasal: Failed to cancel temp basal"); log.error("cancelRealTempBasal: Failed to cancel temp basal");
return result; return result;

View file

@ -11,6 +11,8 @@ import info.nightscout.utils.HardLimits;
public class MsgBolusStart extends MessageBase { public class MsgBolusStart extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgBolusStart.class); private static Logger log = LoggerFactory.getLogger(MsgBolusStart.class);
public static int errorCode;
public MsgBolusStart() { public MsgBolusStart() {
SetCommand(0x0102); SetCommand(0x0102);
} }
@ -29,13 +31,13 @@ public class MsgBolusStart extends MessageBase {
@Override @Override
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
int result = intFromBuff(bytes, 0, 1); errorCode = intFromBuff(bytes, 0, 1);
if (result != 2) { if (errorCode != 2) {
failed = true; failed = true;
log.debug("Messsage response: " + result + " FAILED!!"); log.debug("Messsage response: " + errorCode + " FAILED!!");
} else { } else {
if (Config.logDanaMessageDetail) if (Config.logDanaMessageDetail)
log.debug("Messsage response: " + result); log.debug("Messsage response: " + errorCode + " OK");
} }
} }
} }

View file

@ -11,6 +11,8 @@ import info.nightscout.utils.HardLimits;
public class MsgBolusStartWithSpeed extends MessageBase { public class MsgBolusStartWithSpeed extends MessageBase {
private static Logger log = LoggerFactory.getLogger(MsgBolusStartWithSpeed.class); private static Logger log = LoggerFactory.getLogger(MsgBolusStartWithSpeed.class);
public static int errorCode;
public MsgBolusStartWithSpeed() { public MsgBolusStartWithSpeed() {
SetCommand(0x0104); SetCommand(0x0104);
} }
@ -30,13 +32,13 @@ public class MsgBolusStartWithSpeed extends MessageBase {
@Override @Override
public void handleMessage(byte[] bytes) { public void handleMessage(byte[] bytes) {
int result = intFromBuff(bytes, 0, 1); errorCode = intFromBuff(bytes, 0, 1);
if (result != 2) { if (errorCode != 2) {
failed = true; failed = true;
log.debug("Messsage response: " + result + " FAILED!!"); log.debug("Messsage response: " + errorCode + " FAILED!!");
} else { } else {
if (Config.logDanaMessageDetail) if (Config.logDanaMessageDetail)
log.debug("Messsage response: " + result); log.debug("Messsage response: " + errorCode + " OK");
} }
} }
} }

View file

@ -339,7 +339,7 @@ public class DanaRExecutionService extends AbstractDanaRExecutionService{
} else { } else {
ConfigBuilderPlugin.getCommandQueue().readStatus("bolusOK", null); ConfigBuilderPlugin.getCommandQueue().readStatus("bolusOK", null);
} }
return true; return !start.failed;
} }
public boolean carbsEntry(int amount) { public boolean carbsEntry(int amount) {

View file

@ -18,14 +18,15 @@ import info.nightscout.androidaps.data.Profile;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.events.EventPreferenceChange; import info.nightscout.androidaps.events.EventPreferenceChange;
import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.PluginType; import info.nightscout.androidaps.interfaces.PluginType;
import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStart;
import info.nightscout.androidaps.plugins.PumpDanaRKorean.services.DanaRKoreanExecutionService; import info.nightscout.androidaps.plugins.PumpDanaRKorean.services.DanaRKoreanExecutionService;
import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
import info.nightscout.utils.Round; import info.nightscout.utils.Round;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -130,7 +131,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
// Plugin base interface // Plugin base interface
@Override @Override
public String getName() { public String getName() {
return MainApp.instance().getString(R.string.danarkoreanpump); return MainApp.gs(R.string.danarkoreanpump);
} }
@Override @Override
@ -159,10 +160,13 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0) if (detailedBolusInfo.insulin > 0 || detailedBolusInfo.carbs > 0)
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, detailedBolusInfo.carbTime, t); connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) detailedBolusInfo.carbs, detailedBolusInfo.carbTime, t);
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
result.success = connectionOK; result.success = connectionOK && detailedBolusInfo.insulin == t.insulin;
result.bolusDelivered = t.insulin; result.bolusDelivered = t.insulin;
result.carbsDelivered = detailedBolusInfo.carbs; result.carbsDelivered = detailedBolusInfo.carbs;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); if (!result.success)
result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, MsgBolusStart.errorCode);
else
result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
detailedBolusInfo.insulin = t.insulin; detailedBolusInfo.insulin = t.insulin;
@ -174,7 +178,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
result.success = false; result.success = false;
result.bolusDelivered = 0d; result.bolusDelivered = 0d;
result.carbsDelivered = 0d; result.carbsDelivered = 0d;
result.comment = MainApp.instance().getString(R.string.danar_invalidinput); result.comment = MainApp.gs(R.string.danar_invalidinput);
log.error("deliverTreatment: Invalid input"); log.error("deliverTreatment: Invalid input");
return result; return result;
} }
@ -343,7 +347,7 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
result.success = true; result.success = true;
result.enacted = false; result.enacted = false;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.isTempCancel = true; result.isTempCancel = true;
return result; return result;
} }
@ -359,13 +363,13 @@ public class DanaRKoreanPlugin extends AbstractDanaRPlugin {
if (!pump.isTempBasalInProgress) { if (!pump.isTempBasalInProgress) {
result.success = true; result.success = true;
result.isTempCancel = true; result.isTempCancel = true;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("cancelRealTempBasal: OK"); log.debug("cancelRealTempBasal: OK");
return result; return result;
} else { } else {
result.success = false; result.success = false;
result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly); result.comment = MainApp.gs(R.string.danar_valuenotsetproperly);
result.isTempCancel = true; result.isTempCancel = true;
log.error("cancelRealTempBasal: Failed to cancel temp basal"); log.error("cancelRealTempBasal: Failed to cancel temp basal");
return result; return result;

View file

@ -286,7 +286,7 @@ public class DanaRKoreanExecutionService extends AbstractDanaRExecutionService {
mBolusingTreatment = null; mBolusingTreatment = null;
ConfigBuilderPlugin.getCommandQueue().readStatus("bolusOK", null); ConfigBuilderPlugin.getCommandQueue().readStatus("bolusOK", null);
return true; return !start.failed;
} }
public boolean carbsEntry(int amount) { public boolean carbsEntry(int amount) {

View file

@ -26,6 +26,7 @@ import info.nightscout.androidaps.data.ProfileStore;
import info.nightscout.androidaps.data.PumpEnactResult; import info.nightscout.androidaps.data.PumpEnactResult;
import info.nightscout.androidaps.db.ExtendedBolus; import info.nightscout.androidaps.db.ExtendedBolus;
import info.nightscout.androidaps.db.TemporaryBasal; import info.nightscout.androidaps.db.TemporaryBasal;
import info.nightscout.androidaps.plugins.PumpDanaRS.comm.DanaRS_Packet_Bolus_Set_Step_Bolus_Start;
import info.nightscout.androidaps.plugins.Treatments.Treatment; import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.events.EventAppExit; import info.nightscout.androidaps.events.EventAppExit;
import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.Constraint;
@ -178,8 +179,6 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
final Object o = new Object(); final Object o = new Object();
danaRSService.connect(from, mDeviceAddress, o); danaRSService.connect(from, mDeviceAddress, o);
pumpDescription.basalStep = pump.basalStep;
pumpDescription.bolusStep = pump.bolusStep;
} }
} }
@ -205,8 +204,11 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
@Override @Override
public void getPumpStatus() { public void getPumpStatus() {
if (danaRSService != null) if (danaRSService != null) {
danaRSService.getPumpStatus(); danaRSService.getPumpStatus();
pumpDescription.basalStep = pump.basalStep;
pumpDescription.bolusStep = pump.bolusStep;
}
} }
// DanaR interface // DanaR interface
@ -368,7 +370,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
} }
// RS stores end time for bolus, we need to adjust time // RS stores end time for bolus, we need to adjust time
// default delivery speed is 12 sec/U // default delivery speed is 12 sec/U
detailedBolusInfo.date = DateUtil.now() + (long)(speed * detailedBolusInfo.insulin * 1000); detailedBolusInfo.date = DateUtil.now() + (long) (speed * detailedBolusInfo.insulin * 1000);
// clean carbs to prevent counting them as twice because they will picked up as another record // clean carbs to prevent counting them as twice because they will picked up as another record
// I don't think it's necessary to copy DetailedBolusInfo right now for carbs records // I don't think it's necessary to copy DetailedBolusInfo right now for carbs records
double carbs = detailedBolusInfo.carbs; double carbs = detailedBolusInfo.carbs;
@ -384,10 +386,13 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
if (detailedBolusInfo.insulin > 0 || carbs > 0) if (detailedBolusInfo.insulin > 0 || carbs > 0)
connectionOK = danaRSService.bolus(detailedBolusInfo.insulin, (int) carbs, DateUtil.now() + carbTime * 60 * 1000, t); connectionOK = danaRSService.bolus(detailedBolusInfo.insulin, (int) carbs, DateUtil.now() + carbTime * 60 * 1000, t);
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
result.success = connectionOK; result.success = connectionOK && detailedBolusInfo.insulin == t.insulin;
result.bolusDelivered = t.insulin; result.bolusDelivered = t.insulin;
result.carbsDelivered = detailedBolusInfo.carbs; result.carbsDelivered = detailedBolusInfo.carbs;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); if (!result.success)
result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, DanaRS_Packet_Bolus_Set_Step_Bolus_Start.errorCode);
else
result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
return result; return result;
@ -396,7 +401,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.success = false; result.success = false;
result.bolusDelivered = 0d; result.bolusDelivered = 0d;
result.carbsDelivered = 0d; result.carbsDelivered = 0d;
result.comment = MainApp.instance().getString(R.string.danar_invalidinput); result.comment = MainApp.gs(R.string.danar_invalidinput);
log.error("deliverTreatment: Invalid input"); log.error("deliverTreatment: Invalid input");
return result; return result;
} }
@ -500,7 +505,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.isTempCancel = false; result.isTempCancel = false;
result.enacted = false; result.enacted = false;
result.success = false; result.success = false;
result.comment = MainApp.instance().getString(R.string.danar_invalidinput); result.comment = MainApp.gs(R.string.danar_invalidinput);
log.error("setTempBasalPercent: Invalid input"); log.error("setTempBasalPercent: Invalid input");
return result; return result;
} }
@ -512,7 +517,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
result.enacted = false; result.enacted = false;
result.success = true; result.success = true;
result.isTempCancel = false; result.isTempCancel = false;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.duration = pump.tempBasalRemainingMin; result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent; result.percent = pump.tempBasalPercent;
result.isPercent = true; result.isPercent = true;
@ -530,7 +535,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percent) { if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percent) {
result.enacted = true; result.enacted = true;
result.success = true; result.success = true;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.isTempCancel = false; result.isTempCancel = false;
result.duration = pump.tempBasalRemainingMin; result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent; result.percent = pump.tempBasalPercent;
@ -541,7 +546,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
} }
result.enacted = false; result.enacted = false;
result.success = false; result.success = false;
result.comment = MainApp.instance().getString(R.string.tempbasaldeliveryerror); result.comment = MainApp.gs(R.string.tempbasaldeliveryerror);
log.error("setTempBasalPercent: Failed to set temp basal"); log.error("setTempBasalPercent: Failed to set temp basal");
return result; return result;
} }
@ -552,7 +557,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percent) { if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percent) {
result.enacted = true; result.enacted = true;
result.success = true; result.success = true;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.isTempCancel = false; result.isTempCancel = false;
result.duration = pump.tempBasalRemainingMin; result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent; result.percent = pump.tempBasalPercent;
@ -563,7 +568,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
} }
result.enacted = false; result.enacted = false;
result.success = false; result.success = false;
result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly); result.comment = MainApp.gs(R.string.danar_valuenotsetproperly);
log.error("setHighTempBasalPercent: Failed to set temp basal"); log.error("setHighTempBasalPercent: Failed to set temp basal");
return result; return result;
} }
@ -579,7 +584,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
if (runningEB != null && Math.abs(runningEB.insulin - insulin) < getPumpDescription().extendedBolusStep) { if (runningEB != null && Math.abs(runningEB.insulin - insulin) < getPumpDescription().extendedBolusStep) {
result.enacted = false; result.enacted = false;
result.success = true; result.success = true;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.duration = pump.extendedBolusRemainingMinutes; result.duration = pump.extendedBolusRemainingMinutes;
result.absolute = pump.extendedBolusAbsoluteRate; result.absolute = pump.extendedBolusAbsoluteRate;
result.isPercent = false; result.isPercent = false;
@ -592,7 +597,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
if (connectionOK && pump.isExtendedInProgress && Math.abs(pump.extendedBolusAbsoluteRate - insulin) < getPumpDescription().extendedBolusStep) { if (connectionOK && pump.isExtendedInProgress && Math.abs(pump.extendedBolusAbsoluteRate - insulin) < getPumpDescription().extendedBolusStep) {
result.enacted = true; result.enacted = true;
result.success = true; result.success = true;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.isTempCancel = false; result.isTempCancel = false;
result.duration = pump.extendedBolusRemainingMinutes; result.duration = pump.extendedBolusRemainingMinutes;
result.absolute = pump.extendedBolusAbsoluteRate; result.absolute = pump.extendedBolusAbsoluteRate;
@ -604,7 +609,7 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
} }
result.enacted = false; result.enacted = false;
result.success = false; result.success = false;
result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly); result.comment = MainApp.gs(R.string.danar_valuenotsetproperly);
log.error("setExtendedBolus: Failed to extended bolus"); log.error("setExtendedBolus: Failed to extended bolus");
return result; return result;
} }
@ -621,13 +626,13 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
if (!pump.isTempBasalInProgress) { if (!pump.isTempBasalInProgress) {
result.success = true; result.success = true;
result.isTempCancel = true; result.isTempCancel = true;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("cancelRealTempBasal: OK"); log.debug("cancelRealTempBasal: OK");
return result; return result;
} else { } else {
result.success = false; result.success = false;
result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly); result.comment = MainApp.gs(R.string.danar_valuenotsetproperly);
result.isTempCancel = true; result.isTempCancel = true;
log.error("cancelRealTempBasal: Failed to cancel temp basal"); log.error("cancelRealTempBasal: Failed to cancel temp basal");
return result; return result;
@ -645,13 +650,13 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
} }
if (!pump.isExtendedInProgress) { if (!pump.isExtendedInProgress) {
result.success = true; result.success = true;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("cancelExtendedBolus: OK"); log.debug("cancelExtendedBolus: OK");
return result; return result;
} else { } else {
result.success = false; result.success = false;
result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly); result.comment = MainApp.gs(R.string.danar_valuenotsetproperly);
log.error("cancelExtendedBolus: Failed to cancel extended bolus"); log.error("cancelExtendedBolus: Failed to cancel extended bolus");
return result; return result;
} }

View file

@ -7,58 +7,63 @@ import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.Config; import info.nightscout.androidaps.Config;
import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.R;
import info.nightscout.androidaps.interfaces.Constraint; import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.utils.HardLimits; import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
public class DanaRS_Packet_Bolus_Set_Step_Bolus_Start extends DanaRS_Packet { public class DanaRS_Packet_Bolus_Set_Step_Bolus_Start extends DanaRS_Packet {
private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Step_Bolus_Start.class); private static Logger log = LoggerFactory.getLogger(DanaRS_Packet_Bolus_Set_Step_Bolus_Start.class);
private double amount; private double amount;
private int speed; private int speed;
public boolean failed; public boolean failed;
public static int errorCode;
public DanaRS_Packet_Bolus_Set_Step_Bolus_Start() { public DanaRS_Packet_Bolus_Set_Step_Bolus_Start() {
super(); super();
opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_STEP_BOLUS_START; opCode = BleCommandUtil.DANAR_PACKET__OPCODE_BOLUS__SET_STEP_BOLUS_START;
} }
// Speed 0 => 12 sec/U, 1 => 30 sec/U, 2 => 60 sec/U // Speed 0 => 12 sec/U, 1 => 30 sec/U, 2 => 60 sec/U
public DanaRS_Packet_Bolus_Set_Step_Bolus_Start(double amount, int speed) { public DanaRS_Packet_Bolus_Set_Step_Bolus_Start(double amount, int speed) {
this(); this();
// HARDCODED LIMIT // HARDCODED LIMIT
amount = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(amount)).value(); amount = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(amount)).value();
this.amount = amount; this.amount = amount;
this.speed = speed; this.speed = speed;
if (Config.logDanaMessageDetail) if (Config.logDanaMessageDetail)
log.debug("Bolus start : " + amount + " speed: " + speed); log.debug("Bolus start : " + amount + " speed: " + speed);
} }
@Override @Override
public byte[] getRequestParams() { public byte[] getRequestParams() {
int stepBolusRate = (int) (amount * 100); int stepBolusRate = (int) (amount * 100);
byte[] request = new byte[3]; byte[] request = new byte[3];
request[0] = (byte) (stepBolusRate & 0xff); request[0] = (byte) (stepBolusRate & 0xff);
request[1] = (byte) ((stepBolusRate >>> 8) & 0xff); request[1] = (byte) ((stepBolusRate >>> 8) & 0xff);
request[2] = (byte) (speed & 0xff); request[2] = (byte) (speed & 0xff);
return request; return request;
} }
@Override
public void handleMessage(byte[] data) {
int result = intFromBuff(data, 0, 1);
if (Config.logDanaMessageDetail) {
if (result == 0)
log.debug("Result OK");
else
log.error("Result Error: " + result);
}
}
@Override @Override
public String getFriendlyName() { public void handleMessage(byte[] data) {
return "BOLUS__SET_STEP_BOLUS_START"; errorCode = intFromBuff(data, 0, 1);
} if (Config.logDanaMessageDetail) {
if (errorCode == 0)
log.debug("Result OK");
else {
failed = true;
log.error("Result Error: " + errorCode);
}
}
}
@Override
public String getFriendlyName() {
return "BOLUS__SET_STEP_BOLUS_START";
}
} }

View file

@ -273,7 +273,7 @@ public class DanaRSService extends Service {
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.disconnecting))); MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.disconnecting)));
} }
}); });
return true; return !start.failed;
} }
public void bolusStop() { public void bolusStop() {

View file

@ -22,6 +22,7 @@ import info.nightscout.androidaps.interfaces.Constraint;
import info.nightscout.androidaps.interfaces.PumpDescription; import info.nightscout.androidaps.interfaces.PumpDescription;
import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage; import info.nightscout.androidaps.plugins.ConfigBuilder.DetailedBolusInfoStorage;
import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin; import info.nightscout.androidaps.plugins.PumpDanaR.AbstractDanaRPlugin;
import info.nightscout.androidaps.plugins.PumpDanaR.comm.MsgBolusStartWithSpeed;
import info.nightscout.androidaps.plugins.PumpDanaRv2.services.DanaRv2ExecutionService; import info.nightscout.androidaps.plugins.PumpDanaRv2.services.DanaRv2ExecutionService;
import info.nightscout.androidaps.plugins.Treatments.Treatment; import info.nightscout.androidaps.plugins.Treatments.Treatment;
import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin; import info.nightscout.androidaps.plugins.Treatments.TreatmentsPlugin;
@ -119,7 +120,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
// Plugin base interface // Plugin base interface
@Override @Override
public String getName() { public String getName() {
return MainApp.instance().getString(R.string.danarv2pump); return MainApp.gs(R.string.danarv2pump);
} }
@Override @Override
@ -173,10 +174,13 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
if (detailedBolusInfo.insulin > 0 || carbs > 0) if (detailedBolusInfo.insulin > 0 || carbs > 0)
connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) carbs, DateUtil.now() + carbTime * 60 * 1000, t); connectionOK = sExecutionService.bolus(detailedBolusInfo.insulin, (int) carbs, DateUtil.now() + carbTime * 60 * 1000, t);
PumpEnactResult result = new PumpEnactResult(); PumpEnactResult result = new PumpEnactResult();
result.success = connectionOK; result.success = connectionOK && detailedBolusInfo.insulin == t.insulin;
result.bolusDelivered = t.insulin; result.bolusDelivered = t.insulin;
result.carbsDelivered = detailedBolusInfo.carbs; result.carbsDelivered = detailedBolusInfo.carbs;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); if (!result.success)
result.comment = String.format(MainApp.gs(R.string.boluserrorcode), detailedBolusInfo.insulin, t.insulin, MsgBolusStartWithSpeed.errorCode);
else
result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered); log.debug("deliverTreatment: OK. Asked: " + detailedBolusInfo.insulin + " Delivered: " + result.bolusDelivered);
// remove carbs because it's get from history seprately // remove carbs because it's get from history seprately
@ -186,7 +190,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
result.success = false; result.success = false;
result.bolusDelivered = 0d; result.bolusDelivered = 0d;
result.carbsDelivered = 0d; result.carbsDelivered = 0d;
result.comment = MainApp.instance().getString(R.string.danar_invalidinput); result.comment = MainApp.gs(R.string.danar_invalidinput);
log.error("deliverTreatment: Invalid input"); log.error("deliverTreatment: Invalid input");
return result; return result;
} }
@ -287,7 +291,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
result.isTempCancel = false; result.isTempCancel = false;
result.enacted = false; result.enacted = false;
result.success = false; result.success = false;
result.comment = MainApp.instance().getString(R.string.danar_invalidinput); result.comment = MainApp.gs(R.string.danar_invalidinput);
log.error("setTempBasalPercent: Invalid input"); log.error("setTempBasalPercent: Invalid input");
return result; return result;
} }
@ -299,7 +303,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
result.enacted = false; result.enacted = false;
result.success = true; result.success = true;
result.isTempCancel = false; result.isTempCancel = false;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.duration = pump.tempBasalRemainingMin; result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent; result.percent = pump.tempBasalPercent;
result.isPercent = true; result.isPercent = true;
@ -317,7 +321,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percent) { if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percent) {
result.enacted = true; result.enacted = true;
result.success = true; result.success = true;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.isTempCancel = false; result.isTempCancel = false;
result.duration = pump.tempBasalRemainingMin; result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent; result.percent = pump.tempBasalPercent;
@ -328,7 +332,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
} }
result.enacted = false; result.enacted = false;
result.success = false; result.success = false;
result.comment = MainApp.instance().getString(R.string.tempbasaldeliveryerror); result.comment = MainApp.gs(R.string.tempbasaldeliveryerror);
log.error("setTempBasalPercent: Failed to set temp basal"); log.error("setTempBasalPercent: Failed to set temp basal");
return result; return result;
} }
@ -339,7 +343,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percent) { if (connectionOK && pump.isTempBasalInProgress && pump.tempBasalPercent == percent) {
result.enacted = true; result.enacted = true;
result.success = true; result.success = true;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
result.isTempCancel = false; result.isTempCancel = false;
result.duration = pump.tempBasalRemainingMin; result.duration = pump.tempBasalRemainingMin;
result.percent = pump.tempBasalPercent; result.percent = pump.tempBasalPercent;
@ -350,7 +354,7 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
} }
result.enacted = false; result.enacted = false;
result.success = false; result.success = false;
result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly); result.comment = MainApp.gs(R.string.danar_valuenotsetproperly);
log.error("setHighTempBasalPercent: Failed to set temp basal"); log.error("setHighTempBasalPercent: Failed to set temp basal");
return result; return result;
} }
@ -367,13 +371,13 @@ public class DanaRv2Plugin extends AbstractDanaRPlugin {
if (!pump.isTempBasalInProgress) { if (!pump.isTempBasalInProgress) {
result.success = true; result.success = true;
result.isTempCancel = true; result.isTempCancel = true;
result.comment = MainApp.instance().getString(R.string.virtualpump_resultok); result.comment = MainApp.gs(R.string.virtualpump_resultok);
if (Config.logPumpActions) if (Config.logPumpActions)
log.debug("cancelRealTempBasal: OK"); log.debug("cancelRealTempBasal: OK");
return result; return result;
} else { } else {
result.success = false; result.success = false;
result.comment = MainApp.instance().getString(R.string.danar_valuenotsetproperly); result.comment = MainApp.gs(R.string.danar_valuenotsetproperly);
result.isTempCancel = true; result.isTempCancel = true;
log.error("cancelRealTempBasal: Failed to cancel temp basal"); log.error("cancelRealTempBasal: Failed to cancel temp basal");
return result; return result;

View file

@ -386,7 +386,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.disconnecting))); MainApp.bus().post(new EventPumpStatusChanged(MainApp.sResources.getString(R.string.disconnecting)));
} }
}); });
return true; return !start.failed;
} }
public void bolusStop() { public void bolusStop() {

View file

@ -161,18 +161,54 @@ class HistoryIntentAdapter {
Date date = getDateExtra(intent, HistoryBroadcast.EXTRA_EVENT_TIME); Date date = getDateExtra(intent, HistoryBroadcast.EXTRA_EVENT_TIME);
String alertType = intent.getStringExtra(HistoryBroadcast.EXTRA_ALERT_TYPE); String alertType = intent.getStringExtra(HistoryBroadcast.EXTRA_ALERT_TYPE);
if (MainApp.getDbHelper().getCareportalEventFromTimestamp(date.getTime()) != null) return; if (MainApp.getDbHelper().getCareportalEventFromTimestamp(date.getTime()) != null) return;
try { logNote(date, MainApp.instance().getString(getAlertText(alertType)));
JSONObject data = new JSONObject(); }
String enteredBy = SP.getString("careportal_enteredby", ""); }
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
data.put("created_at", DateUtil.toISOString(date)); void processPumpStatusChangedIntent(Intent intent) {
data.put("eventType", CareportalEvent.NOTE); Date newStatusTime = getDateExtra(intent, HistoryBroadcast.EXTRA_EVENT_TIME);
data.put("notes", MainApp.instance().getString(getAlertText(alertType))); if (SP.getBoolean("insight_automatic_careportal_events", false)) {
NSUpload.uploadCareportalEntryToNS(data); String newStatus = intent.getStringExtra(HistoryBroadcast.EXTRA_NEW_STATUS);
} catch (JSONException e) { switch (newStatus) {
e.printStackTrace(); case "STARTED":
logNote(newStatusTime, MainApp.instance().getString(R.string.pump_started));
break;
case "STOPPED":
logNote(newStatusTime, MainApp.instance().getString(R.string.pump_stopped));
break;
case "PAUSED":
logNote(newStatusTime, MainApp.instance().getString(R.string.pump_paused));
break;
} }
} }
if (intent.hasExtra(HistoryBroadcast.EXTRA_OLD_STATUS_TIME)) {
String oldStatus = intent.getStringExtra(HistoryBroadcast.EXTRA_OLD_STATUS);
if (oldStatus.equals("STOPPED")) {
Date oldStatusTime = getDateExtra(intent, HistoryBroadcast.EXTRA_OLD_STATUS_TIME);
int duration = (int) ((newStatusTime.getTime() - oldStatusTime.getTime()) / 60000);
long serialNumber = Long.parseLong(intent.getStringExtra(HistoryBroadcast.EXTRA_PUMP_SERIAL_NUMBER));
long recordId = intent.getLongExtra(HistoryBroadcast.EXTRA_EVENT_NUMBER, -1);
long uniqueRecordId = getRecordUniqueID(serialNumber, recordId);
logAdapter.createTBRrecord(oldStatusTime, 0, duration, uniqueRecordId);
}
}
}
private void logNote(Date date, String note) {
try {
if (MainApp.getDbHelper().getCareportalEventFromTimestamp(date.getTime()) != null) return;
JSONObject data = new JSONObject();
String enteredBy = SP.getString("careportal_enteredby", "");
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
data.put("created_at", DateUtil.toISOString(date));
data.put("eventType", CareportalEvent.NOTE);
data.put("notes", note);
NSUpload.uploadCareportalEntryToNS(data);
} catch (JSONException e) {
e.printStackTrace();
}
} }
private int getAlertText(String type) { private int getAlertText(String type) {

View file

@ -47,6 +47,7 @@ public class HistoryReceiver {
filter.addAction(ACTION_CARTRIDGE_INSERTED); filter.addAction(ACTION_CARTRIDGE_INSERTED);
filter.addAction(ACTION_BATTERY_INSERTED); filter.addAction(ACTION_BATTERY_INSERTED);
filter.addAction(ACTION_OCCURENCE_OF_ALERT); filter.addAction(ACTION_OCCURENCE_OF_ALERT);
filter.addAction(ACTION_PUMP_STATUS_CHANGED);
MainApp.instance().registerReceiver(historyReceiver, filter); MainApp.instance().registerReceiver(historyReceiver, filter);
} }
@ -108,6 +109,9 @@ public class HistoryReceiver {
case ACTION_OCCURENCE_OF_ALERT: case ACTION_OCCURENCE_OF_ALERT:
intentAdapter.processOccurenceOfAlertIntent(intent); intentAdapter.processOccurenceOfAlertIntent(intent);
break; break;
case ACTION_PUMP_STATUS_CHANGED:
intentAdapter.processPumpStatusChangedIntent(intent);
break;
} }
} }
}; };

View file

@ -35,6 +35,6 @@ public class SourceXdripPlugin extends PluginBase implements BgSourceInterface {
} }
public void setSource(String source) { public void setSource(String source) {
this.advancedFiltering = "G5 Native".equals(source); this.advancedFiltering = source.contains("G5 Native");
} }
} }

View file

@ -40,6 +40,8 @@ import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification; import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
import info.nightscout.androidaps.plugins.Overview.notifications.Notification; import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
import info.nightscout.androidaps.plugins.SensitivityAAPS.SensitivityAAPSPlugin;
import info.nightscout.androidaps.plugins.SensitivityWeightedAverage.SensitivityWeightedAveragePlugin;
import info.nightscout.utils.DateUtil; import info.nightscout.utils.DateUtil;
import info.nightscout.utils.NSUpload; import info.nightscout.utils.NSUpload;
import info.nightscout.utils.SP; import info.nightscout.utils.SP;
@ -211,22 +213,35 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
if (profile == null) return result; if (profile == null) return result;
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
long dia_ago = now - (Double.valueOf(1.5d * profile.getDia() * T.hours(1).msecs())).longValue(); long dia_ago = now - (Double.valueOf(profile.getDia() * T.hours(1).msecs())).longValue();
double maxAbsorptionHours = Constants.DEFAULT_MAX_ABSORPTION_TIME;
if (SensitivityAAPSPlugin.getPlugin().isEnabled(PluginType.SENSITIVITY) || SensitivityWeightedAveragePlugin.getPlugin().isEnabled(PluginType.SENSITIVITY)) {
maxAbsorptionHours = SP.getDouble(R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME);
} else {
maxAbsorptionHours = SP.getDouble(R.string.key_absorption_cutoff, Constants.DEFAULT_MAX_ABSORPTION_TIME);
}
long absorptionTime_ago = now - (Double.valueOf(maxAbsorptionHours * T.hours(1).msecs())).longValue();
synchronized (treatments) { synchronized (treatments) {
for (Treatment treatment : treatments) { for (Treatment treatment : treatments) {
if (!treatment.isValid) if (!treatment.isValid)
continue; continue;
long t = treatment.date; long t = treatment.date;
if (t > dia_ago && t <= now) { if (t > dia_ago && t <= now) {
if (treatment.carbs >= 1) {
result.carbs += treatment.carbs;
result.lastCarbTime = t;
}
if (treatment.insulin > 0 && treatment.mealBolus) { if (treatment.insulin > 0 && treatment.mealBolus) {
result.boluses += treatment.insulin; result.boluses += treatment.insulin;
} }
} }
if (t > absorptionTime_ago && t <= now) {
if (treatment.carbs >= 1) {
result.carbs += treatment.carbs;
if(t > result.lastCarbTime)
result.lastCarbTime = t;
}
}
} }
} }
@ -235,6 +250,7 @@ public class TreatmentsPlugin extends PluginBase implements TreatmentsInterface
result.mealCOB = autosensData.cob; result.mealCOB = autosensData.cob;
result.slopeFromMinDeviation = autosensData.slopeFromMinDeviation; result.slopeFromMinDeviation = autosensData.slopeFromMinDeviation;
result.slopeFromMaxDeviation = autosensData.slopeFromMaxDeviation; result.slopeFromMaxDeviation = autosensData.slopeFromMaxDeviation;
result.usedMinCarbsImpact = autosensData.usedMinCarbsImpact;
} }
result.lastBolusTime = getLastBolusTime(); result.lastBolusTime = getLastBolusTime();
return result; return result;

View file

@ -205,7 +205,7 @@ public class CommandQueue {
// returns true if command is queued // returns true if command is queued
public boolean tempBasalAbsolute(double absoluteRate, int durationInMinutes, boolean enforceNew, Profile profile, Callback callback) { public boolean tempBasalAbsolute(double absoluteRate, int durationInMinutes, boolean enforceNew, Profile profile, Callback callback) {
if (isRunning(Command.CommandType.TEMPBASAL)) { if (!enforceNew && isRunning(Command.CommandType.TEMPBASAL)) {
if (callback != null) if (callback != null)
callback.result(executingNowError()).run(); callback.result(executingNowError()).run();
return false; return false;
@ -226,7 +226,7 @@ public class CommandQueue {
// returns true if command is queued // returns true if command is queued
public boolean tempBasalPercent(Integer percent, int durationInMinutes, boolean enforceNew, Profile profile, Callback callback) { public boolean tempBasalPercent(Integer percent, int durationInMinutes, boolean enforceNew, Profile profile, Callback callback) {
if (isRunning(Command.CommandType.TEMPBASAL)) { if (!enforceNew && isRunning(Command.CommandType.TEMPBASAL)) {
if (callback != null) if (callback != null)
callback.result(executingNowError()).run(); callback.result(executingNowError()).run();
return false; return false;
@ -268,7 +268,7 @@ public class CommandQueue {
// returns true if command is queued // returns true if command is queued
public boolean cancelTempBasal(boolean enforceNew, Callback callback) { public boolean cancelTempBasal(boolean enforceNew, Callback callback) {
if (isRunning(Command.CommandType.TEMPBASAL)) { if (!enforceNew && isRunning(Command.CommandType.TEMPBASAL)) {
if (callback != null) if (callback != null)
callback.result(executingNowError()).run(); callback.result(executingNowError()).run();
return false; return false;

View file

@ -0,0 +1,67 @@
package info.nightscout.androidaps.receivers;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.wifi.SupplicantState;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.PowerManager;
import android.support.annotation.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import info.nightscout.androidaps.MainApp;
import info.nightscout.androidaps.events.EventNetworkChange;
public class NetworkChangeReceiver extends BroadcastReceiver {
private static Logger log = LoggerFactory.getLogger(NetworkChangeReceiver.class);
@Override
public void onReceive(final Context context, final Intent intent) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
if (pm == null) return;
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "NetworkChangeReceiver");
wl.acquire(10000);
EventNetworkChange event = grabNetworkStatus();
if (event != null)
MainApp.bus().post(event);
wl.release();
}
@Nullable
public static EventNetworkChange grabNetworkStatus() {
EventNetworkChange event = new EventNetworkChange();
ConnectivityManager cm = (ConnectivityManager) MainApp.instance().getApplicationContext().getSystemService(Context.CONNECTIVITY_SERVICE);
if (cm == null) return null;
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
if (activeNetwork != null) {
if (activeNetwork.getType() == ConnectivityManager.TYPE_WIFI) {
event.wifiConnected = true;
WifiManager wifiManager = (WifiManager) MainApp.instance().getApplicationContext().getSystemService(Context.WIFI_SERVICE);
if (wifiManager != null) {
WifiInfo wifiInfo = wifiManager.getConnectionInfo();
if (wifiInfo.getSupplicantState() == SupplicantState.COMPLETED) {
event.ssid = wifiInfo.getSSID();
}
log.debug("NETCHANGE: Wifi connected. SSID: " + event.ssid);
}
}
if (activeNetwork.getType() == ConnectivityManager.TYPE_MOBILE) {
event.mobileConnected = true;
event.roaming = activeNetwork.isRoaming();
log.debug("NETCHANGE: Mobile connected. Roaming: " + event.roaming);
}
} else {
log.debug("NETCHANGE: Disconnected.");
}
return event;
}
}

View file

@ -46,13 +46,13 @@ public class DecimalFormatter {
} }
public static String toPumpSupportedBolus(double value) { public static String toPumpSupportedBolus(double value) {
return ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep <= 0.01 return ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep <= 0.05
? to2Decimal(value) ? to2Decimal(value)
: to1Decimal(value); : to1Decimal(value);
} }
public static DecimalFormat pumpSupportedBolusFormat() { public static DecimalFormat pumpSupportedBolusFormat() {
return ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep <= 0.01 return ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep <= 0.05
? new DecimalFormat("0.00") ? new DecimalFormat("0.00")
: new DecimalFormat("0.0"); : new DecimalFormat("0.0");
} }

View file

@ -96,6 +96,13 @@
android:paddingTop="5dp" android:paddingTop="5dp"
app:srcCompat="@drawable/ic_arrow_drop_down_white_24dp" /> app:srcCompat="@drawable/ic_arrow_drop_down_white_24dp" />
<TextView
android:id="@+id/overview_iobcalculationprogess"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textSize="15sp" />
</RelativeLayout> </RelativeLayout>
<com.jjoe64.graphview.GraphView <com.jjoe64.graphview.GraphView

View file

@ -239,23 +239,30 @@
</LinearLayout> </LinearLayout>
<RelativeLayout <RelativeLayout
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="0dp" android:layout_height="0dp"
android:layout_weight="1"> android:layout_weight="1">
<com.jjoe64.graphview.GraphView <com.jjoe64.graphview.GraphView
android:id="@+id/overview_bggraph" android:id="@+id/overview_bggraph"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="match_parent" /> android:layout_height="match_parent" />
<ImageButton <ImageButton
android:id="@+id/overview_chartMenuButton" android:id="@+id/overview_chartMenuButton"
android:layout_width="30dp" android:layout_width="30dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:paddingTop="5dp" android:paddingTop="5dp"
app:srcCompat="@drawable/ic_arrow_drop_down_white_24dp" /> app:srcCompat="@drawable/ic_arrow_drop_down_white_24dp" />
<TextView
android:id="@+id/overview_iobcalculationprogess"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textSize="15sp" />
</RelativeLayout> </RelativeLayout>
@ -299,8 +306,8 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:paddingRight="5dp" android:orientation="horizontal"
android:orientation="horizontal"> android:paddingRight="5dp">
<info.nightscout.utils.SingleClickButton <info.nightscout.utils.SingleClickButton
android:id="@+id/overview_treatmentbutton" android:id="@+id/overview_treatmentbutton"

View file

@ -491,6 +491,13 @@
android:paddingTop="5dp" android:paddingTop="5dp"
app:srcCompat="@drawable/ic_arrow_drop_down_white_24dp" /> app:srcCompat="@drawable/ic_arrow_drop_down_white_24dp" />
<TextView
android:id="@+id/overview_iobcalculationprogess"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textSize="15sp" />
</RelativeLayout> </RelativeLayout>
<com.jjoe64.graphview.GraphView <com.jjoe64.graphview.GraphView

View file

@ -577,6 +577,13 @@
android:paddingTop="5dp" android:paddingTop="5dp"
app:srcCompat="@drawable/ic_arrow_drop_down_white_24dp" /> app:srcCompat="@drawable/ic_arrow_drop_down_white_24dp" />
<TextView
android:id="@+id/overview_iobcalculationprogess"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textSize="15sp" />
</RelativeLayout> </RelativeLayout>
<com.jjoe64.graphview.GraphView <com.jjoe64.graphview.GraphView

View file

@ -255,6 +255,13 @@
android:paddingTop="5dp" android:paddingTop="5dp"
app:srcCompat="@drawable/ic_arrow_drop_down_white_24dp" /> app:srcCompat="@drawable/ic_arrow_drop_down_white_24dp" />
<TextView
android:id="@+id/overview_iobcalculationprogess"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textSize="15sp" />
</RelativeLayout> </RelativeLayout>
<com.jjoe64.graphview.GraphView <com.jjoe64.graphview.GraphView

View file

@ -735,4 +735,7 @@
<string name="combo_suspious_bolus_time">Zeit/Datum des abgegebenen Boluses auf der Pumpe erscheint falsch, IOB ist wahrscheinlich nicht korrekt. Bitte prüfe Zeit/Datum der Pumpe.</string> <string name="combo_suspious_bolus_time">Zeit/Datum des abgegebenen Boluses auf der Pumpe erscheint falsch, IOB ist wahrscheinlich nicht korrekt. Bitte prüfe Zeit/Datum der Pumpe.</string>
<string name="combo_tbr_count">Anzahl TBRs</string> <string name="combo_tbr_count">Anzahl TBRs</string>
<string name="combo_bolus_count">Anzahl Boluse</string> <string name="combo_bolus_count">Anzahl Boluse</string>
<string name="pump_stopped">Pumpe gestoppt</string>
<string name="pump_started">Pumpe gestartet</string>
<string name="pump_paused">Pumpe pausiert</string>
</resources> </resources>

View file

@ -8,6 +8,8 @@
<color name="uam">#ffea00</color> <color name="uam">#ffea00</color>
<color name="zt">#ff9500</color> <color name="zt">#ff9500</color>
<color name="ratio">#FFFFFF</color> <color name="ratio">#FFFFFF</color>
<color name="devslopepos">#FFFFFF00</color>
<color name="devslopeneg">#FFFF00FF</color>
<color name="inrange">#00FF00</color> <color name="inrange">#00FF00</color>
<color name="low">#FF0000</color> <color name="low">#FF0000</color>
<color name="high">#FFFF00</color> <color name="high">#FFFF00</color>

View file

@ -619,6 +619,8 @@
<string name="sensitivityaaps">Sensitivity AAPS</string> <string name="sensitivityaaps">Sensitivity AAPS</string>
<string name="absorptionsettings_title">Absorption settings</string> <string name="absorptionsettings_title">Absorption settings</string>
<string name="key_absorption_maxtime" translatable="false">absorption_maxtime</string> <string name="key_absorption_maxtime" translatable="false">absorption_maxtime</string>
<string name="key_absorption_cutoff" translatable="false">absorption_cutoff</string>
<string name="absorption_maxtime_title">Meal max absorption time [h]</string> <string name="absorption_maxtime_title">Meal max absorption time [h]</string>
<string name="absorption_maxtime_summary">Time in hours where is expected all carbs from meal will be absorbed</string> <string name="absorption_maxtime_summary">Time in hours where is expected all carbs from meal will be absorbed</string>
<string name="key_rangetodisplay" translatable="false">rangetodisplay</string> <string name="key_rangetodisplay" translatable="false">rangetodisplay</string>
@ -997,7 +999,29 @@
<string name="key_openapssmb_max_iob" translatable="false">openapsmb_max_iob</string> <string name="key_openapssmb_max_iob" translatable="false">openapsmb_max_iob</string>
<string name="openapssmb_maxiob_title">Maximum total IOB OpenAPS can\'t go over [U]</string> <string name="openapssmb_maxiob_title">Maximum total IOB OpenAPS can\'t go over [U]</string>
<string name="openapssmb_maxiob_summary">This value is called Max IOB in OpenAPS context\nOpenAPS will not add more insulin if current IOB is greater than this value</string> <string name="openapssmb_maxiob_summary">This value is called Max IOB in OpenAPS context\nOpenAPS will not add more insulin if current IOB is greater than this value</string>
<string name="pump_stopped">Pump stopped</string>
<string name="pump_started">Pump started</string>
<string name="pump_paused">Pump paused</string>
<string name="absorption_cutoff_title">Meal max absorption time [h]</string>
<string name="absorption_cutoff_summary">Time at which any meal is considered absorbed. Remaining carbs will be cut off.</string>
<string name="time">Time</string> <string name="time">Time</string>
<string name="key_show_notes_entry_dialogs">show_notes_entry_dialogs</string> <string name="key_show_notes_entry_dialogs">show_notes_entry_dialogs</string>
<string name="overview_show_notes_field_in_dialogs_title">Show notes field in treatment dialogs</string> <string name="overview_show_notes_field_in_dialogs_title">Show notes field in treatment dialogs</string>
<string name="key_openapsama_min_5m_carbimpact" translatable="false">openapsama_min_5m_carbimpact</string>
<string name="boluserrorcode">Asked: %.2fU Delivered: %.2fU Error code: %d</string>
<string name="firstinsulinincrement">First insulin increment</string>
<string name="secondinsulinincrement">Second insulin increment</string>
<string name="thirdinsulinincrement">Third insulin increment</string>
<string name="firstcarbsincrement">First carbs increment</string>
<string name="secondcarbsincrement">Second carbs increment</string>
<string name="thirdcarbsincrement">Third carbs increment</string>
<string name="cgm">CGM</string>
<string name="key_ns_wifionly" translatable="false">ns_wifionly</string>
<string name="key_ns_wifi_ssids" translatable="false">ns_wifi_ssids</string>
<string name="key_ns_allowroaming" translatable="false">ns_allowroaming</string>
<string name="ns_wifionly">Use WiFi connection only</string>
<string name="ns_wifi_ssids">WiFi SSID</string>
<string name="connectionsettings_title">Connection settings</string>
<string name="ns_wifi_allowedssids">Allowed SSIDs (semicolon separated)</string>
<string name="ns_allowroaming">Allow connection in roaming</string>
</resources> </resources>

View file

@ -6,10 +6,10 @@
android:title="@string/absorptionsettings_title"> android:title="@string/absorptionsettings_title">
<com.andreabaccega.widget.ValidatingEditTextPreference <com.andreabaccega.widget.ValidatingEditTextPreference
validate:testType="numericRange" validate:testType="numericRange"
validate:minNumber="1" validate:minNumber="4"
validate:maxNumber="10" validate:maxNumber="10"
android:digits="0123456789.," android:digits="0123456789.,"
android:defaultValue="3" android:defaultValue="6"
android:selectAllOnFocus="true" android:selectAllOnFocus="true"
android:inputType="number" android:inputType="number"
android:maxLines="20" android:maxLines="20"

View file

@ -8,14 +8,27 @@
validate:testType="floatNumericRange" validate:testType="floatNumericRange"
validate:floatminNumber="0.1" validate:floatminNumber="0.1"
validate:floatmaxNumber="12.0" validate:floatmaxNumber="12.0"
android:defaultValue="3.0" android:defaultValue="8.0"
android:selectAllOnFocus="true" android:selectAllOnFocus="true"
android:singleLine="true" android:singleLine="true"
android:inputType="numberDecimal" android:inputType="numberDecimal"
android:maxLines="20" android:maxLines="20"
android:title="@string/openapsama_min_5m_carbimpact" android:title="@string/openapsama_min_5m_carbimpact"
android:dialogMessage="@string/openapsama_min_5m_carbimpact_summary" android:dialogMessage="@string/openapsama_min_5m_carbimpact_summary"
android:key="openapsama_min_5m_carbimpact" /> android:key="@string/key_openapsama_min_5m_carbimpact" />
<com.andreabaccega.widget.ValidatingEditTextPreference
validate:testType="numericRange"
validate:minNumber="4"
validate:maxNumber="10"
android:digits="0123456789.,"
android:defaultValue="6"
android:selectAllOnFocus="true"
android:inputType="number"
android:maxLines="20"
android:title="@string/absorption_cutoff_title"
android:dialogMessage="@string/absorption_cutoff_summary"
android:key="@string/key_absorption_cutoff" />
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View file

@ -5,29 +5,6 @@
android:key="advanced" android:key="advanced"
android:title="@string/advancedsettings_title"> android:title="@string/advancedsettings_title">
<PreferenceScreen android:title="@string/advancedsettings_title"> <PreferenceScreen android:title="@string/advancedsettings_title">
<PreferenceCategory android:title="@string/nightscout">
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_ns_upload_only"
android:summary="@string/ns_upload_only_summary"
android:title="@string/ns_upload_only" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_ns_noupload"
android:summary="@string/ns_noupload_summary"
android:title="@string/ns_noupload" />
<SwitchPreference
android:defaultValue="false"
android:key="ns_sync_use_absolute"
android:title="@string/ns_sync_use_absolute_title" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/superbolus">
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_usesuperbolus"
android:summary="@string/enablesuperbolus_summary"
android:title="@string/enablesuperbolus" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/openapsma"> <PreferenceCategory android:title="@string/openapsma">
<SwitchPreference <SwitchPreference
android:defaultValue="false" android:defaultValue="false"

View file

@ -1,9 +1,8 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:validate="http://schemas.android.com/apk/res-auto"> xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory
android:key="ns_api" <PreferenceCategory android:title="@string/nsclientinternal_title">
android:title="@string/nsclientinternal_title">
<com.andreabaccega.widget.ValidatingEditTextPreference <com.andreabaccega.widget.ValidatingEditTextPreference
android:defaultValue="https://{YOUR-SITE}.azurewebsites.net/" android:defaultValue="https://{YOUR-SITE}.azurewebsites.net/"
@ -15,93 +14,132 @@
validate:testType="webUrl" /> validate:testType="webUrl" />
<EditTextPreference <EditTextPreference
android:defaultValue=""
android:dialogMessage="@string/nsclientinternal_secret_dialogmessage" android:dialogMessage="@string/nsclientinternal_secret_dialogmessage"
android:dialogTitle="@string/nsclientinternal_secret_dialogtitle" android:dialogTitle="@string/nsclientinternal_secret_dialogtitle"
android:inputType="textPassword" android:inputType="textPassword"
android:key="@string/key_nsclientinternal_api_secret" android:key="@string/key_nsclientinternal_api_secret"
android:title="@string/nsclientinternal_secret_title" /> android:title="@string/nsclientinternal_secret_title" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_autobackfill"
android:title="@string/ns_autobackfill" />
<SwitchPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="@string/key_ns_logappstartedevent" android:key="@string/key_ns_logappstartedevent"
android:title="@string/ns_logappstartedevent" /> android:title="@string/ns_logappstartedevent" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_create_announcements_from_errors"
android:title="@string/ns_create_announcements_from_errors_title"
android:summary="@string/ns_create_announcements_from_errors_summary"/>
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_localbroadcasts"
android:title="@string/ns_localbroadcasts_title"
android:summary="@string/ns_localbroadcasts"/>
<PreferenceScreen android:title="@string/ns_alarmoptions"> <PreferenceScreen android:title="@string/ns_alarmoptions">
<SwitchPreference <SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:key="@string/key_nsalarm_urgent_high" android:key="@string/key_nsalarm_urgent_high"
android:title="@string/nsalarm_urgenthigh"/> android:title="@string/nsalarm_urgenthigh" />
<SwitchPreference <SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:key="@string/key_nsalarm_high" android:key="@string/key_nsalarm_high"
android:title="@string/nsalarm_high"/> android:title="@string/nsalarm_high" />
<SwitchPreference <SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:key="@string/key_nsalarm_low" android:key="@string/key_nsalarm_low"
android:title="@string/nsalarm_low"/> android:title="@string/nsalarm_low" />
<SwitchPreference <SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:key="@string/key_nsalarm_urgent_low" android:key="@string/key_nsalarm_urgent_low"
android:title="@string/nsalarm_urgentlow"/> android:title="@string/nsalarm_urgentlow" />
<SwitchPreference <SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:key="@string/key_nsalarm_staledata" android:key="@string/key_nsalarm_staledata"
android:title="@string/nsalarm_staledata"/> android:title="@string/nsalarm_staledata" />
<com.andreabaccega.widget.ValidatingEditTextPreference <com.andreabaccega.widget.ValidatingEditTextPreference
validate:testType="numericRange"
validate:minNumber="15"
validate:maxNumber="120"
android:digits="0123456789"
android:defaultValue="16" android:defaultValue="16"
android:digits="0123456789"
android:inputType="number"
android:key="@string/key_nsalarm_staledatavalue"
android:maxLines="20"
android:selectAllOnFocus="true" android:selectAllOnFocus="true"
android:singleLine="true" android:singleLine="true"
android:inputType="number"
android:maxLines="20"
android:title="@string/nsalarm_staledatavalue_label" android:title="@string/nsalarm_staledatavalue_label"
android:key="@string/key_nsalarm_staledatavalue" /> validate:maxNumber="120"
validate:minNumber="15"
validate:testType="numericRange" />
<SwitchPreference <SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:key="@string/key_nsalarm_urgent_staledata" android:key="@string/key_nsalarm_urgent_staledata"
android:title="@string/nsalarm_urgentstaledata"/> android:title="@string/nsalarm_urgentstaledata" />
<com.andreabaccega.widget.ValidatingEditTextPreference <com.andreabaccega.widget.ValidatingEditTextPreference
validate:testType="numericRange"
validate:minNumber="30"
validate:maxNumber="180"
android:digits="0123456789"
android:defaultValue="31" android:defaultValue="31"
android:digits="0123456789"
android:inputType="number"
android:key="@string/key_nsalarm_urgent_staledatavalue"
android:maxLines="20"
android:selectAllOnFocus="true" android:selectAllOnFocus="true"
android:singleLine="true" android:singleLine="true"
android:inputType="number"
android:maxLines="20"
android:title="@string/nsalarm_urgent_staledatavalue_label" android:title="@string/nsalarm_urgent_staledatavalue_label"
android:key="@string/key_nsalarm_urgent_staledatavalue" /> validate:maxNumber="180"
validate:minNumber="30"
validate:testType="numericRange" />
</PreferenceScreen>
<PreferenceScreen android:title="@string/connectionsettings_title">
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_ns_wifionly"
android:title="@string/ns_wifionly" />
<EditTextPreference
android:dialogMessage="@string/ns_wifi_allowedssids"
android:inputType="text"
android:key="@string/key_ns_wifi_ssids"
android:title="@string/ns_wifi_ssids" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_allowroaming"
android:title="@string/ns_allowroaming" />
</PreferenceScreen>
<PreferenceScreen android:title="@string/advancedsettings_title">
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_autobackfill"
android:title="@string/ns_autobackfill" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_create_announcements_from_errors"
android:summary="@string/ns_create_announcements_from_errors_summary"
android:title="@string/ns_create_announcements_from_errors_title" />
<SwitchPreference
android:defaultValue="true"
android:key="@string/key_ns_localbroadcasts"
android:summary="@string/ns_localbroadcasts"
android:title="@string/ns_localbroadcasts_title" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_ns_upload_only"
android:summary="@string/ns_upload_only_summary"
android:title="@string/ns_upload_only" />
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_ns_noupload"
android:summary="@string/ns_noupload_summary"
android:title="@string/ns_noupload" />
<SwitchPreference
android:defaultValue="false"
android:key="ns_sync_use_absolute"
android:title="@string/ns_sync_use_absolute_title" />
</PreferenceScreen> </PreferenceScreen>

View file

@ -1,120 +1,150 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:validate="http://schemas.android.com/apk/res-auto"> xmlns:validate="http://schemas.android.com/apk/res-auto">
<PreferenceCategory android:title="@string/overview"> <PreferenceCategory android:title="@string/overview">
<PreferenceScreen android:title="@string/overview_buttons_selection"> <PreferenceScreen android:title="@string/overview_buttons_selection">
<SwitchPreference <SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:key="@string/key_show_treatment_button" android:key="@string/key_show_treatment_button"
android:title="Treatments" /> android:title="@string/treatments" />
<SwitchPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="@string/key_show_wizard_button" android:key="@string/key_show_wizard_button"
android:title="@string/overview_calculator_label"/> android:title="@string/overview_calculator_label" />
<SwitchPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="@string/key_show_insulin_button" android:key="@string/key_show_insulin_button"
android:title="Insulin" /> android:title="@string/configbuilder_insulin" />
<com.andreabaccega.widget.ValidatingEditTextPreference <com.andreabaccega.widget.ValidatingEditTextPreference
android:dependency="@string/key_show_insulin_button"
validate:testType="floatNumericRange"
validate:floatminNumber="-5.0"
validate:floatmaxNumber="5.0"
android:defaultValue="0.5" android:defaultValue="0.5"
android:selectAllOnFocus="true" android:dependency="@string/key_show_insulin_button"
android:singleLine="true" android:dialogMessage="@string/insulin_increment_button_message"
android:inputType="numberDecimal|numberDecimal|numberSigned" android:inputType="numberDecimal|numberDecimal|numberSigned"
android:key="@string/key_insulin_button_increment_1"
android:maxLines="20" android:maxLines="20"
android:title="First insulin increment" android:selectAllOnFocus="true"
android:dialogMessage="@string/insulin_increment_button_message" android:singleLine="true"
android:key="@string/key_insulin_button_increment_1" /> android:title="@string/firstinsulinincrement"
<com.andreabaccega.widget.ValidatingEditTextPreference
android:dependency="@string/key_show_insulin_button"
validate:testType="floatNumericRange"
validate:floatminNumber="-5.0"
validate:floatmaxNumber="5.0" validate:floatmaxNumber="5.0"
validate:floatminNumber="-5.0"
validate:testType="floatNumericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
android:defaultValue="1.0" android:defaultValue="1.0"
android:selectAllOnFocus="true"
android:singleLine="true"
android:inputType="numberDecimal|numberSigned"
android:maxLines="20"
android:title="Second insulin increment"
android:dialogMessage="@string/insulin_increment_button_message"
android:key="@string/key_insulin_button_increment_2" />
<com.andreabaccega.widget.ValidatingEditTextPreference
android:dependency="@string/key_show_insulin_button" android:dependency="@string/key_show_insulin_button"
validate:testType="floatNumericRange" android:dialogMessage="@string/insulin_increment_button_message"
validate:floatminNumber="-5.0" android:inputType="numberDecimal|numberSigned"
validate:floatmaxNumber="5.0" android:key="@string/key_insulin_button_increment_2"
android:defaultValue="2.0" android:maxLines="20"
android:selectAllOnFocus="true" android:selectAllOnFocus="true"
android:singleLine="true" android:singleLine="true"
android:inputType="numberDecimal|numberSigned" android:title="@string/secondinsulinincrement"
android:maxLines="20" validate:floatmaxNumber="5.0"
android:title="Third insulin increment" validate:floatminNumber="-5.0"
validate:testType="floatNumericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
android:defaultValue="2.0"
android:dependency="@string/key_show_insulin_button"
android:dialogMessage="@string/insulin_increment_button_message" android:dialogMessage="@string/insulin_increment_button_message"
android:key="@string/key_insulin_button_increment_3"/> android:inputType="numberDecimal|numberSigned"
android:key="@string/key_insulin_button_increment_3"
android:maxLines="20"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/thirdinsulinincrement"
validate:floatmaxNumber="5.0"
validate:floatminNumber="-5.0"
validate:testType="floatNumericRange" />
<SwitchPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="@string/key_show_carbs_button" android:key="@string/key_show_carbs_button"
android:title="Carbs" /> android:title="@string/carbs" />
<com.andreabaccega.widget.ValidatingEditTextPreference <com.andreabaccega.widget.ValidatingEditTextPreference
android:dependency="@string/key_show_carbs_button"
validate:testType="numericRange"
validate:minNumber="-50"
validate:maxNumber="50"
android:defaultValue="5" android:defaultValue="5"
android:dependency="@string/key_show_carbs_button"
android:dialogMessage="@string/carb_increment_button_message"
android:inputType="numberSigned"
android:key="@string/key_carbs_button_increment_1"
android:maxLines="20"
android:selectAllOnFocus="true" android:selectAllOnFocus="true"
android:singleLine="true" android:singleLine="true"
android:inputType="numberSigned" android:title="@string/firstcarbsincrement"
android:maxLines="20"
android:title="First carbs increment"
android:dialogMessage="@string/carb_increment_button_message"
android:key="@string/key_carbs_button_increment_1" />
<com.andreabaccega.widget.ValidatingEditTextPreference
android:dependency="@string/key_show_carbs_button"
validate:testType="numericRange"
validate:minNumber="-50"
validate:maxNumber="50" validate:maxNumber="50"
validate:minNumber="-50"
validate:testType="numericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
android:defaultValue="10" android:defaultValue="10"
android:selectAllOnFocus="true"
android:singleLine="true"
android:inputType="numberSigned"
android:maxLines="20"
android:title="Second carbs increment"
android:dialogMessage="@string/carb_increment_button_message"
android:key="@string/key_carbs_button_increment_2" />
<com.andreabaccega.widget.ValidatingEditTextPreference
android:dependency="@string/key_show_carbs_button" android:dependency="@string/key_show_carbs_button"
validate:testType="numericRange" android:dialogMessage="@string/carb_increment_button_message"
validate:minNumber="-50" android:inputType="numberSigned"
validate:maxNumber="50" android:key="@string/key_carbs_button_increment_2"
android:defaultValue="20" android:maxLines="20"
android:selectAllOnFocus="true" android:selectAllOnFocus="true"
android:singleLine="true" android:singleLine="true"
android:inputType="numberSigned" android:title="@string/secondcarbsincrement"
android:maxLines="20" validate:maxNumber="50"
android:title="Third carbs increment" validate:minNumber="-50"
validate:testType="numericRange" />
<com.andreabaccega.widget.ValidatingEditTextPreference
android:defaultValue="20"
android:dependency="@string/key_show_carbs_button"
android:dialogMessage="@string/carb_increment_button_message" android:dialogMessage="@string/carb_increment_button_message"
android:key="@string/key_carbs_button_increment_3" /> android:inputType="numberSigned"
android:key="@string/key_carbs_button_increment_3"
android:maxLines="20"
android:selectAllOnFocus="true"
android:singleLine="true"
android:title="@string/thirdcarbsincrement"
validate:maxNumber="50"
validate:minNumber="-50"
validate:testType="numericRange" />
<SwitchPreference <SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:key="@string/key_show_cgm_button" android:key="@string/key_show_cgm_button"
android:title="CGM" android:summary="@string/show_cgm_button_summary"
android:summary="@string/show_cgm_button_summary"/> android:title="@string/cgm" />
<SwitchPreference <SwitchPreference
android:defaultValue="true" android:defaultValue="true"
android:key="@string/key_show_calibration_button" android:key="@string/key_show_calibration_button"
android:title="@string/overview_calibration" android:summary="@string/show_calibration_button_summary"
android:summary="@string/show_calibration_button_summary"/> android:title="@string/overview_calibration" />
<SwitchPreference <SwitchPreference
android:defaultValue="false" android:defaultValue="false"
android:key="@string/key_show_notes_entry_dialogs" android:key="@string/key_show_notes_entry_dialogs"
android:title="@string/overview_show_notes_field_in_dialogs_title" /> android:title="@string/overview_show_notes_field_in_dialogs_title" />
</PreferenceScreen> </PreferenceScreen>
<Preference
android:key="quickwizard"
android:title="@string/quickwizardsettings">
<intent android:action="info.nightscout.androidaps.plugins.Overview.activities.QuickWizardListActivity" />
</Preference>
<PreferenceScreen android:title="@string/advancedsettings_title">
<SwitchPreference
android:defaultValue="false"
android:key="@string/key_usesuperbolus"
android:summary="@string/enablesuperbolus_summary"
android:title="@string/enablesuperbolus" />
</PreferenceScreen>
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View file

@ -1,12 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory
android:title="@string/quickwizard">
<Preference
android:key="quickwizard"
android:title="@string/quickwizardsettings">
<intent android:action="info.nightscout.androidaps.plugins.Overview.activities.QuickWizardListActivity"/>
</Preference>
</PreferenceCategory>
</PreferenceScreen>