Merge branch 'dev' of https://github.com/MilosKozak/AndroidAPS into MilosKozak-dev

This commit is contained in:
AdrianLxM 2017-01-19 20:47:53 +01:00
commit 6c3a07cc62
21 changed files with 178 additions and 87 deletions

View file

@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" /> <ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" /> <ConfirmationsSetting value="0" id="Remove" />
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

View file

@ -44,7 +44,7 @@ android {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 23 targetSdkVersion 23
versionCode 1100 versionCode 1100
versionName "1.1" versionName "1.1c"
buildConfigField "String", "BUILDVERSION", generateGitBuild() buildConfigField "String", "BUILDVERSION", generateGitBuild()
} }
lintOptions { lintOptions {

View file

@ -252,7 +252,7 @@ public class DanaRPlugin implements PluginBase, PumpInterface, ConstraintsInterf
for (int h = 0; h < basalValues; h++) { for (int h = 0; h < basalValues; h++) {
Double pumpValue = pump.pumpProfiles[pump.activeProfile][h]; Double pumpValue = pump.pumpProfiles[pump.activeProfile][h];
Double profileValue = profile.getBasal(h * basalIncrement); Double profileValue = profile.getBasal(h * basalIncrement);
if (!pumpValue.equals(profileValue)) { if (Math.abs(pumpValue - profileValue) > getPumpDescription().basalStep) {
log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue); log.debug("Diff found. Hour: " + h + " Pump: " + pumpValue + " Profile: " + profileValue);
return false; return false;
} }

View file

@ -76,7 +76,7 @@ public class Autosens {
double[] bgis = new double[bucketed_data.size() - 2]; double[] bgis = new double[bucketed_data.size() - 2];
double[] deviations = new double[bucketed_data.size() - 2]; double[] deviations = new double[bucketed_data.size() - 2];
String debugString = ""; String pastSensitivity = "";
for (int i = 0; i < bucketed_data.size() - 3; ++i) { for (int i = 0; i < bucketed_data.size() - 3; ++i) {
long bgTime = bucketed_data.get(i).timeIndex; long bgTime = bucketed_data.get(i).timeIndex;
int secondsFromMidnight = NSProfile.secondsFromMidnight(new Date(bgTime)); int secondsFromMidnight = NSProfile.secondsFromMidnight(new Date(bgTime));
@ -108,20 +108,21 @@ public class Autosens {
// Exclude large positive deviations (carb absorption) from autosens // Exclude large positive deviations (carb absorption) from autosens
if (avgDelta - bgi < 6) { if (avgDelta - bgi < 6) {
if (deviation > 0) { if (deviation > 0) {
debugString += "+"; pastSensitivity += "+";
} else if (deviation == 0) { } else if (deviation == 0) {
debugString += "="; pastSensitivity += "=";
} else { } else {
debugString += "-"; pastSensitivity += "-";
} }
avgDeltas[i] = avgDelta; avgDeltas[i] = avgDelta;
bgis[i] = bgi; bgis[i] = bgi;
deviations[i] = deviation; deviations[i] = deviation;
deviationSum += deviation; deviationSum += deviation;
} else { } else {
debugString += ">"; pastSensitivity += ">";
//console.error(bgTime); //console.error(bgTime);
} }
//log.debug("TIME: " + new Date(bgTime).toString() + " BG: " + bg + " SENS: " + sens + " DELTA: " + delta + " AVGDELTA: " + avgDelta + " IOB: " + iob.iob + " ACTIVITY: " + iob.activity + " BGI: " + bgi + " DEVIATION: " + deviation);
// if bgTime is more recent than mealTime // if bgTime is more recent than mealTime
if (bgTime > mealTime) { if (bgTime > mealTime) {
@ -134,7 +135,7 @@ public class Autosens {
} }
} }
//console.error(""); //console.error("");
log.debug(debugString); log.debug(pastSensitivity);
//console.log(JSON.stringify(avgDeltas)); //console.log(JSON.stringify(avgDeltas));
//console.log(JSON.stringify(bgis)); //console.log(JSON.stringify(bgis));
Arrays.sort(avgDeltas); Arrays.sort(avgDeltas);
@ -157,15 +158,17 @@ public class Autosens {
//console.error("Mean deviation: "+average.toFixed(2)); //console.error("Mean deviation: "+average.toFixed(2));
double basalOff = 0; double basalOff = 0;
String sensResult = "";
if (pSensitive < 0) { // sensitive if (pSensitive < 0) { // sensitive
basalOff = pSensitive * (60 / 5) / NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()), profile.getUnits()); basalOff = pSensitive * (60 / 5) / NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()), profile.getUnits());
log.debug("Excess insulin sensitivity detected: "); sensResult = "Excess insulin sensitivity detected";
} else if (pResistant > 0) { // resistant } else if (pResistant > 0) { // resistant
basalOff = pResistant * (60 / 5) / NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()), profile.getUnits()); basalOff = pResistant * (60 / 5) / NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()), profile.getUnits());
log.debug("Excess insulin resistance detected: "); sensResult = "Excess insulin resistance detected";
} else { } else {
log.debug("Sensitivity normal."); sensResult = "Sensitivity normal";
} }
log.debug(sensResult);
double ratio = 1 + (basalOff / profile.getMaxDailyBasal()); double ratio = 1 + (basalOff / profile.getMaxDailyBasal());
// don't adjust more than 1.5x // don't adjust more than 1.5x
@ -173,8 +176,10 @@ public class Autosens {
ratio = Math.max(ratio, Constants.AUTOSENS_MIN); ratio = Math.max(ratio, Constants.AUTOSENS_MIN);
ratio = Math.min(ratio, Constants.AUTOSENS_MAX); ratio = Math.min(ratio, Constants.AUTOSENS_MAX);
String ratioLimit = "";
if (ratio != rawRatio) { if (ratio != rawRatio) {
log.debug("Ratio limited from " + rawRatio + " to " + ratio); ratioLimit = "Ratio limited from " + rawRatio + " to " + ratio;
log.debug(ratioLimit);
} }
double newisf = Math.round(NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()), profile.getUnits()) / ratio); double newisf = Math.round(NSProfile.toMgdl(profile.getIsf(NSProfile.secondsFromMidnight()), profile.getUnits()) / ratio);
@ -187,6 +192,9 @@ public class Autosens {
AutosensResult output = new AutosensResult(); AutosensResult output = new AutosensResult();
output.ratio = Round.roundTo(ratio, 0.01); output.ratio = Round.roundTo(ratio, 0.01);
output.carbsAbsorbed = Round.roundTo(carbsAbsorbed, 0.01); output.carbsAbsorbed = Round.roundTo(carbsAbsorbed, 0.01);
output.pastSensitivity = pastSensitivity;
output.ratioLimit = ratioLimit;
output.sensResult = sensResult;
return output; return output;
} }

View file

@ -1,9 +1,30 @@
package info.nightscout.androidaps.plugins.OpenAPSAMA; package info.nightscout.androidaps.plugins.OpenAPSAMA;
import org.json.JSONException;
import org.json.JSONObject;
/** /**
* Created by mike on 06.01.2017. * Created by mike on 06.01.2017.
*/ */
public class AutosensResult { public class AutosensResult {
public double ratio; public double ratio;
public double carbsAbsorbed; public double carbsAbsorbed;
public String sensResult;
public String pastSensitivity;
public String ratioLimit;
public JSONObject json() {
JSONObject ret = new JSONObject();
try {
ret.put("ratio", ratio);
ret.put("ratioLimit", ratioLimit);
ret.put("pastSensitivity", pastSensitivity);
ret.put("sensResult", sensResult);
ret.put("ratio", ratio);
} catch (JSONException e) {
e.printStackTrace();
}
return ret;
}
} }

View file

@ -125,12 +125,14 @@ public class OpenAPSAMAFragment extends Fragment implements View.OnClickListener
} }
profileView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getProfileParam())); profileView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getProfileParam()));
mealDataView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getMealDataParam())); mealDataView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getMealDataParam()));
autosensDataView.setText(JSONFormatter.format(determineBasalAdapterAMAJS.getAutosensDataParam()));
scriptdebugView.setText(determineBasalAdapterAMAJS.getScriptDebug()); scriptdebugView.setText(determineBasalAdapterAMAJS.getScriptDebug());
} }
if (getPlugin().lastAPSRun != null) { if (getPlugin().lastAPSRun != null) {
lastRunView.setText(getPlugin().lastAPSRun.toLocaleString()); lastRunView.setText(getPlugin().lastAPSRun.toLocaleString());
} }
if (getPlugin().lastAutosensResult != null) {
autosensDataView.setText(JSONFormatter.format(getPlugin().lastAutosensResult.json()));
}
} }
}); });
} }

View file

@ -45,6 +45,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
DetermineBasalAdapterAMAJS lastDetermineBasalAdapterAMAJS = null; DetermineBasalAdapterAMAJS lastDetermineBasalAdapterAMAJS = null;
Date lastAPSRun = null; Date lastAPSRun = null;
DetermineBasalResultAMA lastAPSResult = null; DetermineBasalResultAMA lastAPSResult = null;
AutosensResult lastAutosensResult = null;
boolean fragmentEnabled = false; boolean fragmentEnabled = false;
boolean fragmentVisible = true; boolean fragmentVisible = true;
@ -173,7 +174,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
maxIob = MainApp.getConfigBuilder().applyMaxIOBConstraints(maxIob); maxIob = MainApp.getConfigBuilder().applyMaxIOBConstraints(maxIob);
minBg = verifyHardLimits(minBg, "minBg", 72, 180); minBg = verifyHardLimits(minBg, "minBg", 72, 180);
maxBg = verifyHardLimits(maxBg, "maxBg", 100, 270); maxBg = verifyHardLimits(maxBg, "maxBg", 99, 270);
targetBg = verifyHardLimits(targetBg, "targetBg", 80, 200); targetBg = verifyHardLimits(targetBg, "targetBg", 80, 200);
boolean isTempTarget = false; boolean isTempTarget = false;
@ -202,10 +203,10 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
long oldestDataAvailable = MainApp.getConfigBuilder().getActiveTempBasals().oldestDataAvaialable(); long oldestDataAvailable = MainApp.getConfigBuilder().getActiveTempBasals().oldestDataAvaialable();
List<BgReading> bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(Math.max(oldestDataAvailable, (long) (new Date().getTime() - 60 * 60 * 1000L * (24 + profile.getDia()))), false); List<BgReading> bgReadings = MainApp.getDbHelper().getBgreadingsDataFromTime(Math.max(oldestDataAvailable, (long) (new Date().getTime() - 60 * 60 * 1000L * (24 + profile.getDia()))), false);
log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString() + " (" + bgReadings.size() + " records)"); log.debug("Limiting data to oldest available temps: " + new Date(oldestDataAvailable).toString() + " (" + bgReadings.size() + " records)");
AutosensResult autosensResult = Autosens.detectSensitivityandCarbAbsorption(bgReadings, new Date().getTime()); lastAutosensResult = Autosens.detectSensitivityandCarbAbsorption(bgReadings, new Date().getTime());
determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, pump, iobArray, glucoseStatus, mealData, determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, pump, iobArray, glucoseStatus, mealData,
autosensResult.ratio, //autosensDataRatio lastAutosensResult.ratio, //autosensDataRatio
isTempTarget, isTempTarget,
Constants.MIN_5M_CARBIMPACT //min_5m_carbimpact Constants.MIN_5M_CARBIMPACT //min_5m_carbimpact
); );
@ -247,15 +248,18 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
} }
public static Double verifyHardLimits(Double value, String valueName, double lowLimit, double highLimit) { public static Double verifyHardLimits(Double value, String valueName, double lowLimit, double highLimit) {
if (value < lowLimit || value > highLimit) { Double newvalue = value;
if (newvalue < lowLimit || newvalue > highLimit) {
newvalue = Math.max(newvalue, lowLimit);
newvalue = Math.min(newvalue, highLimit);
String msg = String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), valueName); String msg = String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), valueName);
msg += ".\n";
msg += String.format(MainApp.sResources.getString(R.string.openapsma_valuelimitedto), value, newvalue);
log.error(msg); log.error(msg);
MainApp.getConfigBuilder().uploadError(msg); MainApp.getConfigBuilder().uploadError(msg);
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), msg, R.raw.error); ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), msg, R.raw.error);
value = Math.max(value, lowLimit);
value = Math.min(value, highLimit);
} }
return value; return newvalue;
} }
} }

View file

@ -34,6 +34,9 @@ import info.nightscout.utils.Round;
import info.nightscout.utils.SafeParse; import info.nightscout.utils.SafeParse;
import info.nightscout.utils.ToastUtils; import info.nightscout.utils.ToastUtils;
import static info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin.checkOnlyHardLimits;
import static info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin.verifyHardLimits;
/** /**
* Created by mike on 05.08.2016. * Created by mike on 05.08.2016.
*/ */
@ -179,7 +182,7 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
maxIob = MainApp.getConfigBuilder().applyMaxIOBConstraints(maxIob); maxIob = MainApp.getConfigBuilder().applyMaxIOBConstraints(maxIob);
minBg = verifyHardLimits(minBg, "minBg", 72, 180); minBg = verifyHardLimits(minBg, "minBg", 72, 180);
maxBg = verifyHardLimits(maxBg, "maxBg", 100, 270); maxBg = verifyHardLimits(maxBg, "maxBg", 99, 270);
targetBg = verifyHardLimits(targetBg, "targetBg", 80, 200); targetBg = verifyHardLimits(targetBg, "targetBg", 80, 200);
TempTargetRangePlugin tempTargetRangePlugin = (TempTargetRangePlugin) MainApp.getSpecificPlugin(TempTargetRangePlugin.class); TempTargetRangePlugin tempTargetRangePlugin = (TempTargetRangePlugin) MainApp.getSpecificPlugin(TempTargetRangePlugin.class);
@ -235,21 +238,5 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
//deviceStatus.suggested = determineBasalResultMA.json; //deviceStatus.suggested = determineBasalResultMA.json;
} }
// safety checks
public static boolean checkOnlyHardLimits(Double value, String valueName, double lowLimit, double highLimit) {
return value.equals(verifyHardLimits(value, valueName, lowLimit, highLimit));
}
public static Double verifyHardLimits(Double value, String valueName, double lowLimit, double highLimit) {
if (value < lowLimit || value > highLimit) {
String msg = String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), valueName);
log.error(msg);
MainApp.getConfigBuilder().uploadError(msg);
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), msg, R.raw.error);
value = Math.max(value, lowLimit);
value = Math.min(value, highLimit);
}
return value;
}
} }

View file

@ -114,6 +114,7 @@ public class OverviewFragment extends Fragment {
TextView iobView; TextView iobView;
TextView apsModeView; TextView apsModeView;
TextView tempTargetView; TextView tempTargetView;
TextView initializingView;
GraphView bgGraph; GraphView bgGraph;
CheckBox showPredictionView; CheckBox showPredictionView;
@ -122,7 +123,6 @@ public class OverviewFragment extends Fragment {
LinearLayout cancelTempLayout; LinearLayout cancelTempLayout;
LinearLayout acceptTempLayout; LinearLayout acceptTempLayout;
LinearLayout quickWizardLayout;
Button cancelTempButton; Button cancelTempButton;
Button treatmentButton; Button treatmentButton;
Button wizardButton; Button wizardButton;
@ -159,6 +159,7 @@ public class OverviewFragment extends Fragment {
baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal); baseBasalView = (TextView) view.findViewById(R.id.overview_basebasal);
basalLayout = (LinearLayout) view.findViewById(R.id.overview_basallayout); basalLayout = (LinearLayout) view.findViewById(R.id.overview_basallayout);
activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile); activeProfileView = (TextView) view.findViewById(R.id.overview_activeprofile);
initializingView = (TextView) view.findViewById(R.id.overview_initializing);
iobView = (TextView) view.findViewById(R.id.overview_iob); iobView = (TextView) view.findViewById(R.id.overview_iob);
apsModeView = (TextView) view.findViewById(R.id.overview_apsmode); apsModeView = (TextView) view.findViewById(R.id.overview_apsmode);
@ -172,7 +173,6 @@ public class OverviewFragment extends Fragment {
acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton); acceptTempButton = (Button) view.findViewById(R.id.overview_accepttempbutton);
acceptTempLayout = (LinearLayout) view.findViewById(R.id.overview_accepttemplayout); acceptTempLayout = (LinearLayout) view.findViewById(R.id.overview_accepttemplayout);
quickWizardButton = (Button) view.findViewById(R.id.overview_quickwizard); quickWizardButton = (Button) view.findViewById(R.id.overview_quickwizard);
quickWizardLayout = (LinearLayout) view.findViewById(R.id.overview_quickwizardlayout);
showPredictionView = (CheckBox) view.findViewById(R.id.overview_showprediction); showPredictionView = (CheckBox) view.findViewById(R.id.overview_showprediction);
notificationsView = (RecyclerView) view.findViewById(R.id.overview_notifications); notificationsView = (RecyclerView) view.findViewById(R.id.overview_notifications);
@ -286,7 +286,7 @@ public class OverviewFragment extends Fragment {
QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive(); QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
if (quickWizardEntry != null && lastBG != null) { if (quickWizardEntry != null && lastBG != null) {
quickWizardLayout.setVisibility(View.VISIBLE); quickWizardButton.setVisibility(View.VISIBLE);
String text = MainApp.sResources.getString(R.string.bolus) + ": " + quickWizardEntry.buttonText(); String text = MainApp.sResources.getString(R.string.bolus) + ": " + quickWizardEntry.buttonText();
BolusWizard wizard = new BolusWizard(); BolusWizard wizard = new BolusWizard();
wizard.doCalc(profile.getDefaultProfile(), quickWizardEntry.carbs(), lastBG.valueToUnits(profile.getUnits()), 0d, true, true); wizard.doCalc(profile.getDefaultProfile(), quickWizardEntry.carbs(), lastBG.valueToUnits(profile.getUnits()), 0d, true, true);
@ -468,8 +468,14 @@ public class OverviewFragment extends Fragment {
updateNotifications(); updateNotifications();
BgReading actualBG = MainApp.getDbHelper().actualBg(); BgReading actualBG = MainApp.getDbHelper().actualBg();
BgReading lastBG = MainApp.getDbHelper().lastBg(); BgReading lastBG = MainApp.getDbHelper().lastBg();
if (MainApp.getConfigBuilder() == null || MainApp.getConfigBuilder().getActiveProfile() == null || MainApp.getConfigBuilder().getActiveProfile().getProfile() == null) // app not initialized yet
if (MainApp.getConfigBuilder() == null || MainApp.getConfigBuilder().getActiveProfile() == null || MainApp.getConfigBuilder().getActiveProfile().getProfile() == null) {// app not initialized yet
initializingView.setText(R.string.noprofileset);
initializingView.setVisibility(View.VISIBLE);
return; return;
} else {
initializingView.setVisibility(View.GONE);
}
// Skip if not initialized yet // Skip if not initialized yet
if (bgGraph == null) if (bgGraph == null)
@ -635,19 +641,21 @@ public class OverviewFragment extends Fragment {
// QuickWizard button // QuickWizard button
QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive(); QuickWizard.QuickWizardEntry quickWizardEntry = getPlugin().quickWizard.getActive();
if (quickWizardEntry != null && lastBG != null && pump.isInitialized()) { if (quickWizardEntry != null && lastBG != null && pump.isInitialized()) {
quickWizardLayout.setVisibility(View.VISIBLE); quickWizardButton.setVisibility(View.VISIBLE);
String text = MainApp.sResources.getString(R.string.bolus) + ": " + quickWizardEntry.buttonText() + " " + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g"; String text = MainApp.sResources.getString(R.string.bolus) + ": " + quickWizardEntry.buttonText() + " " + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
BolusWizard wizard = new BolusWizard(); BolusWizard wizard = new BolusWizard();
wizard.doCalc(profile.getDefaultProfile(), quickWizardEntry.carbs(), lastBG.valueToUnits(profile.getUnits()), 0d, true, true); wizard.doCalc(profile.getDefaultProfile(), quickWizardEntry.carbs(), lastBG.valueToUnits(profile.getUnits()), 0d, true, true);
text += " " + DecimalFormatter.to2Decimal(wizard.calculatedTotalInsulin) + "U"; text += " " + DecimalFormatter.to2Decimal(wizard.calculatedTotalInsulin) + "U";
quickWizardButton.setText(text); quickWizardButton.setText(text);
if (wizard.calculatedTotalInsulin <= 0) if (wizard.calculatedTotalInsulin <= 0)
quickWizardLayout.setVisibility(View.GONE); quickWizardButton.setVisibility(View.GONE);
} else } else
quickWizardLayout.setVisibility(View.GONE); quickWizardButton.setVisibility(View.GONE);
String units = profile.getUnits();
// **** BG value **** // **** BG value ****
if (lastBG != null && bgView != null) { if (lastBG != null) {
bgView.setText(lastBG.valueToUnitsToString(profile.getUnits())); bgView.setText(lastBG.valueToUnitsToString(profile.getUnits()));
arrowView.setText(lastBG.directionToSymbol()); arrowView.setText(lastBG.directionToSymbol());
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData(); GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
@ -922,6 +930,21 @@ public class OverviewFragment extends Fragment {
bgGraph.getSecondScale().setMaxY(maxBgValue / lowLine * maxBasalValueFound * 1.2d); bgGraph.getSecondScale().setMaxY(maxBgValue / lowLine * maxBasalValueFound * 1.2d);
bgGraph.getGridLabelRenderer().setVerticalLabelsSecondScaleColor(MainApp.instance().getResources().getColor(R.color.background_material_dark)); // same color as backround = hide bgGraph.getGridLabelRenderer().setVerticalLabelsSecondScaleColor(MainApp.instance().getResources().getColor(R.color.background_material_dark)); // same color as backround = hide
} }
// Pump not initialized message
if (!pump.isInitialized()) {
// disable all treatment buttons because we are not able to check constraints without profile
wizardButton.setVisibility(View.INVISIBLE);
treatmentButton.setVisibility(View.INVISIBLE);
quickWizardButton.setVisibility(View.INVISIBLE);
initializingView.setText(R.string.waitingforpump);
initializingView.setVisibility(View.VISIBLE);
} else {
wizardButton.setVisibility(View.VISIBLE);
treatmentButton.setVisibility(View.VISIBLE);
initializingView.setVisibility(View.GONE);
}
} }
//Notifications //Notifications

View file

@ -180,6 +180,7 @@ public class TempBasalsPlugin implements PluginBase, TempBasalsInterface {
if (useExtendedBoluses) { if (useExtendedBoluses) {
for (Integer pos = 0; pos < extendedBoluses.size(); pos++) { for (Integer pos = 0; pos < extendedBoluses.size(); pos++) {
TempBasal t = extendedBoluses.get(pos); TempBasal t = extendedBoluses.get(pos);
if (t.timeStart.getTime() > time) continue;
IobTotal calc = t.iobCalc(now); IobTotal calc = t.iobCalc(now);
total.plus(calc); total.plus(calc);
} }

View file

@ -92,7 +92,7 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
else else
holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.cardColorBackground)); holder.dateLinearLayout.setBackgroundColor(MainApp.instance().getResources().getColor(R.color.cardColorBackground));
holder.remove.setTag(tempTarget); holder.remove.setTag(tempTarget);
} }
@Override @Override
public int getItemCount() { public int getItemCount() {
@ -104,7 +104,7 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
super.onAttachedToRecyclerView(recyclerView); super.onAttachedToRecyclerView(recyclerView);
} }
public class TempTargetsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener { public class TempTargetsViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
CardView cv; CardView cv;
TextView date; TextView date;
TextView duration; TextView duration;
@ -134,26 +134,26 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
final Context finalContext = context; final Context finalContext = context;
switch (v.getId()) { switch (v.getId()) {
case R.id.temptargetrange_remove: case R.id.temptargetrange_remove:
final String _id = tempTarget._id; AlertDialog.Builder builder = new AlertDialog.Builder(context);
if (_id != null && !_id.equals("")) { builder.setTitle(MainApp.sResources.getString(R.string.confirmation));
AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(tempTarget.timeStart));
builder.setTitle(MainApp.sResources.getString(R.string.confirmation)); builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() {
builder.setMessage(MainApp.sResources.getString(R.string.removerecord) + "\n" + _id); public void onClick(DialogInterface dialog, int id) {
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), new DialogInterface.OnClickListener() { final String _id = tempTarget._id;
public void onClick(DialogInterface dialog, int id) { if (_id != null && !_id.equals("")) {
MainApp.getConfigBuilder().removeCareportalEntryFromNS(_id); MainApp.getConfigBuilder().removeCareportalEntryFromNS(_id);
try {
Dao<TempTarget, Long> daoTempTargets = MainApp.getDbHelper().getDaoTempTargets();
daoTempTargets.delete(tempTarget);
MainApp.bus().post(new EventTempTargetRangeChange());
} catch (SQLException e) {
e.printStackTrace();
}
} }
}); try {
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null); Dao<TempTarget, Long> daoTempTargets = MainApp.getDbHelper().getDaoTempTargets();
builder.show(); daoTempTargets.delete(tempTarget);
} MainApp.bus().post(new EventTempTargetRangeChange());
} catch (SQLException e) {
e.printStackTrace();
}
}
});
builder.setNegativeButton(MainApp.sResources.getString(R.string.cancel), null);
builder.show();
break; break;
} }
} }
@ -188,8 +188,8 @@ public class TempTargetRangeFragment extends Fragment implements View.OnClickLis
case R.id.temptargetrange_refreshfromnightscout: case R.id.temptargetrange_refreshfromnightscout:
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean nsUploadOnly = SP.getBoolean("ns_upload_only", false); boolean nsUploadOnly = SP.getBoolean("ns_upload_only", false);
if(nsUploadOnly){ if (nsUploadOnly) {
ToastUtils.showToastInUiThread(getContext(),this.getContext().getString(R.string.ns_upload_only_enabled)); ToastUtils.showToastInUiThread(getContext(), this.getContext().getString(R.string.ns_upload_only_enabled));
} else { } else {
AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext()); AlertDialog.Builder builder = new AlertDialog.Builder(this.getContext());
builder.setTitle(this.getContext().getString(R.string.confirmation)); builder.setTitle(this.getContext().getString(R.string.confirmation));

View file

@ -0,0 +1,7 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle" >
<solid android:color="@color/colorInitializingBorder" />
<stroke android:width="1dip" android:color="@android:color/white"/>
<corners
android:radius="2dp" >
</corners>
</shape>

View file

@ -17,7 +17,7 @@
android:id="@+id/profileview_noprofile" android:id="@+id/profileview_noprofile"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/nsprofileview_noprofile_text" android:text="@string/noprofileset"
android:textAppearance="?android:attr/textAppearanceLarge" android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="@android:color/holo_red_light" android:textColor="@android:color/holo_red_light"
android:textStyle="bold" android:textStyle="bold"

View file

@ -21,9 +21,9 @@
</android.support.v7.widget.RecyclerView> </android.support.v7.widget.RecyclerView>
<LinearLayout <LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingTop="2dp"> android:paddingTop="2dp">
<TextView <TextView
@ -32,6 +32,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:layout_marginRight="10dp" android:layout_marginRight="10dp"
android:layout_weight="0.2"
android:background="@drawable/loopmodeborder" android:background="@drawable/loopmodeborder"
android:gravity="center_vertical|center_horizontal" android:gravity="center_vertical|center_horizontal"
android:paddingLeft="10dp" android:paddingLeft="10dp"
@ -40,20 +41,21 @@
android:textAppearance="?android:attr/textAppearanceSmall" android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_weight="0.1" /> android:layout_weight="0.1" />
<TextView <TextView
android:id="@+id/overview_activeprofile" android:id="@+id/overview_activeprofile"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="right" android:layout_gravity="right"
android:layout_marginRight="10dp" android:layout_marginRight="10dp"
android:layout_weight="0.5"
android:background="@drawable/pillborder" android:background="@drawable/pillborder"
android:gravity="center_vertical|center_horizontal" android:gravity="center_vertical|center_horizontal"
android:text="Profile"
android:paddingLeft="10dp" android:paddingLeft="10dp"
android:paddingRight="10dp" android:paddingRight="10dp"
android:text="Profile"
android:textAppearance="?android:attr/textAppearanceMedium" android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="@color/colorProfileSwitchButton" android:textColor="@color/colorProfileSwitchButton" />
android:layout_weight="0.5" />
<TextView <TextView
android:id="@+id/overview_temptarget" android:id="@+id/overview_temptarget"
@ -71,6 +73,23 @@
android:layout_weight="0.2" /> android:layout_weight="0.2" />
</LinearLayout> </LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:paddingTop="2dp">
<TextView
android:id="@+id/overview_initializing"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/initializingborder"
android:gravity="center_vertical|center_horizontal"
android:text="@string/initializing"
android:textAppearance="?android:attr/textAppearanceMedium"
android:layout_marginTop="10dp" />
</LinearLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
@ -92,13 +111,13 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="top|left" android:layout_gravity="top|left"
android:layout_marginTop="-15dp"
android:gravity="center_vertical" android:gravity="center_vertical"
android:paddingLeft="-5dp" android:paddingLeft="-5dp"
android:paddingRight="-10dp" android:paddingRight="-10dp"
android:text="→" android:text="→"
android:textSize="70dp" android:textSize="70dp"
android:textStyle="bold" android:textStyle="bold" />
android:layout_marginTop="-15dp" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
@ -136,9 +155,9 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/overview_basallayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:id="@+id/overview_basallayout"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="horizontal"> android:orientation="horizontal">
@ -180,11 +199,11 @@
android:layout_height="160dip" /> android:layout_height="160dip" />
<CheckBox <CheckBox
android:id="@+id/overview_showprediction"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:id="@+id/overview_showprediction" android:layout_alignParentEnd="true"
android:layout_alignParentTop="true" android:layout_alignParentTop="true" />
android:layout_alignParentEnd="true" />
</RelativeLayout> </RelativeLayout>
<LinearLayout <LinearLayout
@ -261,7 +280,6 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/overview_quickwizardlayout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal"> android:orientation="horizontal">

View file

@ -89,7 +89,7 @@
<string name="nsprofileview_basal_label">Базални стойности:</string> <string name="nsprofileview_basal_label">Базални стойности:</string>
<string name="nsprofileview_dia_label">DIA (Време на действие на инсулина):</string> <string name="nsprofileview_dia_label">DIA (Време на действие на инсулина):</string>
<string name="nsprofileview_ic_label">IC (Инсулин/въглехидр.):</string> <string name="nsprofileview_ic_label">IC (Инсулин/въглехидр.):</string>
<string name="nsprofileview_noprofile_text">НЕ Е ЗАДАДЕН ПРОФИЛ</string> <string name="noprofileset">НЕ Е ЗАДАДЕН ПРОФИЛ</string>
<string name="nsprofileview_target_label">Целeва КЗ:</string> <string name="nsprofileview_target_label">Целeва КЗ:</string>
<string name="nsprofileview_units_label">Единици:</string> <string name="nsprofileview_units_label">Единици:</string>
<string name="objectives">Цели</string> <string name="objectives">Цели</string>

View file

@ -89,7 +89,7 @@
<string name="nsprofileview_basal_label">Bazál:</string> <string name="nsprofileview_basal_label">Bazál:</string>
<string name="nsprofileview_dia_label">Trvání inzulínu:</string> <string name="nsprofileview_dia_label">Trvání inzulínu:</string>
<string name="nsprofileview_ic_label">Inzulínosacharidový poměr:</string> <string name="nsprofileview_ic_label">Inzulínosacharidový poměr:</string>
<string name="nsprofileview_noprofile_text">ŽÁDNÝ PROFIL NENASTAVEN</string> <string name="noprofileset">ŽÁDNÝ PROFIL NENASTAVEN</string>
<string name="nsprofileview_target_label">Cíl:</string> <string name="nsprofileview_target_label">Cíl:</string>
<string name="nsprofileview_units_label">Jednotky:</string> <string name="nsprofileview_units_label">Jednotky:</string>
<string name="objectives">Cíle</string> <string name="objectives">Cíle</string>
@ -385,4 +385,21 @@
<string name="ongoingnotificaction">Průběžné oznámení</string> <string name="ongoingnotificaction">Průběžné oznámení</string>
<string name="old_data">ZASTARALÉ</string> <string name="old_data">ZASTARALÉ</string>
<string name="localprofile">Místní profil</string> <string name="localprofile">Místní profil</string>
<string name="activity">Aktivita</string>
<string name="array_of_elements">Pole %d prvků. Aktuální hodnota:</string>
<string name="careportal_temptarget"></string>
<string name="eatingsoon">Před jídlem</string>
<string name="el_lang">Řečtina</string>
<string name="initializing">Inicializuji ...</string>
<string name="long_avgdelta">Dlouhodobý průměr</string>
<string name="openapsama">OpenAPS AMA</string>
<string name="openapsama_useautosens">Používat autodetekci senzitivity</string>
<string name="openapsma_autosensdata_label">Data detekce senzitivity</string>
<string name="openapsma_scriptdebugdata_label">Ladící informace</string>
<string name="openapsma_valuelimitedto" formatted="false">%.2f omezeno na %.2f</string>
<string name="refreshtemptargetsfromnightscout">Opravdu aktualizovat dočasné cíle z NS</string>
<string name="removerecord">Odstranit záznam:</string>
<string name="short_avgdelta">Krátkodobý průměr</string>
<string name="temptargetrange">Dočasný cíl</string>
<string name="temptargetrange_refreshfromnightscout">Obnovit dočasné cíle z NS</string>
</resources> </resources>

View file

@ -142,7 +142,7 @@
<string name="objectives_gate_label_string">Gate:</string> <string name="objectives_gate_label_string">Gate:</string>
<string name="objectives_objective_label_string">Objective:</string> <string name="objectives_objective_label_string">Objective:</string>
<string name="objectives">Zielsetzungen</string> <string name="objectives">Zielsetzungen</string>
<string name="nsprofileview_noprofile_text">KEIN PROFIL GESETZT</string> <string name="noprofileset">KEIN PROFIL GESETZT</string>
<string name="nsclientnotinstalled">NSClient nicht installiert. Record lost!</string> <string name="nsclientnotinstalled">NSClient nicht installiert. Record lost!</string>
<string name="ns_sync_use_absolute_title">Verwende absolute statt prozentuelle Basalwerte beim Upload zu NightScout</string> <string name="ns_sync_use_absolute_title">Verwende absolute statt prozentuelle Basalwerte beim Upload zu NightScout</string>
<string name="noprofile">Bisher noch kein Profil von NS geladen</string> <string name="noprofile">Bisher noch kein Profil von NS geladen</string>
@ -312,4 +312,5 @@
<string name="absorption_rate">Absorptionsrate:</string> <string name="absorption_rate">Absorptionsrate:</string>
<string name="configbuilder">Config Builder</string> <string name="configbuilder">Config Builder</string>
<string name="minago">vor %d min</string> <string name="minago">vor %d min</string>
<string name="el_lang"></string>
</resources> </resources>

View file

@ -25,7 +25,7 @@
<string name="nsprofileview_isf_label">ISF (Factor Sensibilidad Insulina):</string> <string name="nsprofileview_isf_label">ISF (Factor Sensibilidad Insulina):</string>
<string name="nsprofileview_basal_label">Dosis Basal:</string> <string name="nsprofileview_basal_label">Dosis Basal:</string>
<string name="nsprofileview_target_label">Objetivo:</string> <string name="nsprofileview_target_label">Objetivo:</string>
<string name="nsprofileview_noprofile_text">PERFIL NO ACTIVO</string> <string name="noprofileset">PERFIL NO ACTIVO</string>
<string name="treatments_insulin_label_string">Insulina:</string> <string name="treatments_insulin_label_string">Insulina:</string>
<string name="treatments_carbs_label_string">Carbohidratos:</string> <string name="treatments_carbs_label_string">Carbohidratos:</string>
<string name="treatments_iob_label_string">IOB:</string> <string name="treatments_iob_label_string">IOB:</string>

View file

@ -26,7 +26,7 @@
<string name="nsprofileview_isf_label">인슐린 민감도(ISF):</string> <string name="nsprofileview_isf_label">인슐린 민감도(ISF):</string>
<string name="nsprofileview_basal_label">기초주입:</string> <string name="nsprofileview_basal_label">기초주입:</string>
<string name="nsprofileview_target_label">목표:</string> <string name="nsprofileview_target_label">목표:</string>
<string name="nsprofileview_noprofile_text">NO PROFILE SET</string> <string name="noprofileset">NO PROFILE SET</string>
<string name="treatments_insulin_label_string">인슐린:</string> <string name="treatments_insulin_label_string">인슐린:</string>
<string name="treatments_carbs_label_string">탄수화물:</string> <string name="treatments_carbs_label_string">탄수화물:</string>
<string name="treatments_iob_label_string">IOB:</string> <string name="treatments_iob_label_string">IOB:</string>

View file

@ -3,6 +3,7 @@
<color name="colorPrimary">#3F51B5</color> <color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color> <color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color> <color name="colorAccent">#FF4081</color>
<color name="colorInitializingBorder">#ff2630</color>
<color name="cardColorBackground">#121212</color> <color name="cardColorBackground">#121212</color>
<color name="cardObjectiveText">#779ECB</color> <color name="cardObjectiveText">#779ECB</color>

View file

@ -27,7 +27,7 @@
<string name="nsprofileview_isf_label">ISF:</string> <string name="nsprofileview_isf_label">ISF:</string>
<string name="nsprofileview_basal_label">Basal:</string> <string name="nsprofileview_basal_label">Basal:</string>
<string name="nsprofileview_target_label">Target:</string> <string name="nsprofileview_target_label">Target:</string>
<string name="nsprofileview_noprofile_text">NO PROFILE SET</string> <string name="noprofileset">NO PROFILE SET</string>
<string name="treatments_insulin_label_string">Insulin:</string> <string name="treatments_insulin_label_string">Insulin:</string>
<string name="treatments_carbs_label_string">Carbs:</string> <string name="treatments_carbs_label_string">Carbs:</string>
<string name="treatments_iob_label_string">IOB:</string> <string name="treatments_iob_label_string">IOB:</string>
@ -319,6 +319,7 @@
<string name="smscommunicator_loophasbeenenabled">Loop has been enabled</string> <string name="smscommunicator_loophasbeenenabled">Loop has been enabled</string>
<string name="smscommunicator_loopisdisabled">Loop is disabled</string> <string name="smscommunicator_loopisdisabled">Loop is disabled</string>
<string name="smscommunicator_loopisenabled">Loop is enabled</string> <string name="smscommunicator_loopisenabled">Loop is enabled</string>
<string name="openapsma_valuelimitedto" formatted="false">%.2f limited to %.2f</string>
<string name="openapsma_valueoutofrange" formatted="false">Value %s is out of hard limits</string> <string name="openapsma_valueoutofrange" formatted="false">Value %s is out of hard limits</string>
<string name="smscommunicator_remotebasalnotallowed">Remote basal setting is not allowed</string> <string name="smscommunicator_remotebasalnotallowed">Remote basal setting is not allowed</string>
<string name="smscommunicator_basalreplywithcode" formatted="false">To start basal %.2fU/h reply with code %s</string> <string name="smscommunicator_basalreplywithcode" formatted="false">To start basal %.2fU/h reply with code %s</string>
@ -408,8 +409,8 @@
<string name="openapsama_useautosens">Use AMA autosens feature</string> <string name="openapsama_useautosens">Use AMA autosens feature</string>
<string name="temptargetrange">Temp Target</string> <string name="temptargetrange">Temp Target</string>
<string name="temptargetrange_refreshfromnightscout">Refresh temp targets from NS</string> <string name="temptargetrange_refreshfromnightscout">Refresh temp targets from NS</string>
<string name="careportal_temptarget">Temporary Target</string>
<string name="eatingsoon">Eating Soon</string> <string name="eatingsoon">Eating Soon</string>
<string name="activity">Activity</string> <string name="activity">Activity</string>
<string name="removerecord">Remove record:</string> <string name="removerecord">Remove record:</string>
<string name="initializing">Initializing ...</string>
</resources> </resources>