Merge branch 'dev' into tidepool
This commit is contained in:
commit
968bccaacc
33 changed files with 635 additions and 675 deletions
|
@ -222,8 +222,8 @@ dependencies {
|
||||||
wearApp project(':wear')
|
wearApp project(':wear')
|
||||||
|
|
||||||
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
implementation fileTree(include: ['*.jar'], dir: 'libs')
|
||||||
implementation 'com.google.android.gms:play-services-wearable:16.0.1'
|
implementation 'com.google.android.gms:play-services-wearable:17.0.0'
|
||||||
implementation 'com.google.firebase:firebase-core:16.0.9'
|
implementation 'com.google.firebase:firebase-core:17.0.1'
|
||||||
implementation("com.crashlytics.sdk.android:crashlytics:2.9.9@aar") {
|
implementation("com.crashlytics.sdk.android:crashlytics:2.9.9@aar") {
|
||||||
transitive = true;
|
transitive = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class QuickWizardEntry {
|
||||||
useTemptarget: 0
|
useTemptarget: 0
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
public QuickWizardEntry() {
|
QuickWizardEntry() {
|
||||||
String emptyData = "{\"buttonText\":\"\",\"carbs\":0,\"validFrom\":0,\"validTo\":86340}";
|
String emptyData = "{\"buttonText\":\"\",\"carbs\":0,\"validFrom\":0,\"validTo\":86340}";
|
||||||
try {
|
try {
|
||||||
storage = new JSONObject(emptyData);
|
storage = new JSONObject(emptyData);
|
||||||
|
@ -60,18 +60,17 @@ public class QuickWizardEntry {
|
||||||
position = -1;
|
position = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QuickWizardEntry(JSONObject entry, int position) {
|
QuickWizardEntry(JSONObject entry, int position) {
|
||||||
storage = entry;
|
storage = entry;
|
||||||
this.position = position;
|
this.position = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isActive() {
|
Boolean isActive() {
|
||||||
return Profile.secondsFromMidnight() >= validFrom() && Profile.secondsFromMidnight() <= validTo();
|
return Profile.secondsFromMidnight() >= validFrom() && Profile.secondsFromMidnight() <= validTo();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BolusWizard doCalc(Profile profile, TempTarget tempTarget, BgReading lastBG, boolean _synchronized) {
|
public BolusWizard doCalc(Profile profile, String profileName, BgReading lastBG, boolean _synchronized) {
|
||||||
BolusWizard wizard = new BolusWizard();
|
final TempTarget tempTarget = TreatmentsPlugin.getPlugin().getTempTargetFromHistory();
|
||||||
|
|
||||||
//BG
|
//BG
|
||||||
double bg = 0;
|
double bg = 0;
|
||||||
if (lastBG != null && useBG() == YES) {
|
if (lastBG != null && useBG() == YES) {
|
||||||
|
@ -86,11 +85,6 @@ public class QuickWizardEntry {
|
||||||
cob = cobInfo.displayCob;
|
cob = cobInfo.displayCob;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temp target
|
|
||||||
if (useTempTarget() == NO) {
|
|
||||||
tempTarget = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bolus IOB
|
// Bolus IOB
|
||||||
boolean bolusIOB = false;
|
boolean bolusIOB = false;
|
||||||
if (useBolusIOB() == YES) {
|
if (useBolusIOB() == YES) {
|
||||||
|
@ -130,8 +124,7 @@ public class QuickWizardEntry {
|
||||||
trend = true;
|
trend = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wizard.doCalc(profile, tempTarget, carbs(), cob, bg, 0d, bolusIOB, basalIOB, superBolus, trend);
|
return new BolusWizard(profile, profileName, tempTarget, carbs(), cob, bg, 0d, 100, true, useCOB() == YES, bolusIOB, basalIOB, superBolus, useTempTarget() == YES, trend, "QuickWizard");
|
||||||
return wizard;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String buttonText() {
|
public String buttonText() {
|
||||||
|
|
|
@ -644,14 +644,27 @@ public class LoopPlugin extends PluginBase {
|
||||||
TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin();
|
TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin();
|
||||||
|
|
||||||
LoopPlugin.getPlugin().disconnectTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000L);
|
LoopPlugin.getPlugin().disconnectTo(System.currentTimeMillis() + durationInMinutes * 60 * 1000L);
|
||||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, durationInMinutes, true, profile, new Callback() {
|
|
||||||
@Override
|
if (pump.getPumpDescription().tempBasalStyle == PumpDescription.ABSOLUTE) {
|
||||||
public void run() {
|
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalAbsolute(0, durationInMinutes, true, profile, new Callback() {
|
||||||
if (!result.success) {
|
@Override
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.tempbasaldeliveryerror));
|
public void run() {
|
||||||
|
if (!result.success) {
|
||||||
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.tempbasaldeliveryerror));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
} else {
|
||||||
|
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, durationInMinutes, true, profile, new Callback() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!result.success) {
|
||||||
|
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.tempbasaldeliveryerror));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (pump.getPumpDescription().isExtendedBolusCapable && activeTreatments.isInHistoryExtendedBoluslInProgress()) {
|
if (pump.getPumpDescription().isExtendedBolusCapable && activeTreatments.isInHistoryExtendedBoluslInProgress()) {
|
||||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelExtended(new Callback() {
|
ConfigBuilderPlugin.getPlugin().getCommandQueue().cancelExtended(new Callback() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -13,10 +13,10 @@ import info.nightscout.androidaps.interfaces.PluginDescription;
|
||||||
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.interfaces.PumpInterface;
|
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSAMA.OpenAPSAMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSMA.OpenAPSMAPlugin;
|
||||||
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin;
|
import info.nightscout.androidaps.plugins.aps.openAPSSMB.OpenAPSSMBPlugin;
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
import info.nightscout.androidaps.plugins.general.overview.events.EventNewNotification;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
import info.nightscout.androidaps.plugins.general.overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
|
import info.nightscout.androidaps.plugins.sensitivity.SensitivityOref1Plugin;
|
||||||
|
@ -196,7 +196,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
|
|
||||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||||
if (pump != null) {
|
if (pump != null) {
|
||||||
double rounded = Round.roundTo(insulin.value(), pump.getPumpDescription().pumpType.determineCorrectBolusSize(insulin.value()));
|
double rounded = pump.getPumpDescription().pumpType.determineCorrectBolusSize(insulin.value());
|
||||||
insulin.setIfDifferent(rounded, MainApp.gs(R.string.pumplimit), this);
|
insulin.setIfDifferent(rounded, MainApp.gs(R.string.pumplimit), this);
|
||||||
}
|
}
|
||||||
return insulin;
|
return insulin;
|
||||||
|
@ -213,7 +213,7 @@ public class SafetyPlugin extends PluginBase implements ConstraintsInterface {
|
||||||
|
|
||||||
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||||
if (pump != null) {
|
if (pump != null) {
|
||||||
double rounded = Round.roundTo(insulin.value(), pump.getPumpDescription().pumpType.determineCorrectExtendedBolusSize(insulin.value()));
|
double rounded = pump.getPumpDescription().pumpType.determineCorrectExtendedBolusSize(insulin.value());
|
||||||
insulin.setIfDifferent(rounded, MainApp.gs(R.string.pumplimit), this);
|
insulin.setIfDifferent(rounded, MainApp.gs(R.string.pumplimit), this);
|
||||||
}
|
}
|
||||||
return insulin;
|
return insulin;
|
||||||
|
|
|
@ -37,12 +37,9 @@ import android.widget.TextView;
|
||||||
import com.jjoe64.graphview.GraphView;
|
import com.jjoe64.graphview.GraphView;
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -55,7 +52,6 @@ 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.R;
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
|
||||||
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.data.QuickWizardEntry;
|
import info.nightscout.androidaps.data.QuickWizardEntry;
|
||||||
|
@ -95,7 +91,6 @@ import info.nightscout.androidaps.plugins.general.nsclient.data.NSDeviceStatus;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus;
|
import info.nightscout.androidaps.plugins.general.nsclient.data.NSSettingsStatus;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity;
|
import info.nightscout.androidaps.plugins.general.overview.activities.QuickWizardListActivity;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.dialogs.CalibrationDialog;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.CalibrationDialog;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.dialogs.ErrorHelperActivity;
|
|
||||||
import info.nightscout.androidaps.plugins.general.overview.dialogs.NewCarbsDialog;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.NewCarbsDialog;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.dialogs.NewInsulinDialog;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.NewInsulinDialog;
|
||||||
import info.nightscout.androidaps.plugins.general.overview.dialogs.NewTreatmentDialog;
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.NewTreatmentDialog;
|
||||||
|
@ -785,122 +780,25 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
void onClickQuickwizard() {
|
void onClickQuickwizard() {
|
||||||
final BgReading actualBg = DatabaseHelper.actualBg();
|
final BgReading actualBg = DatabaseHelper.actualBg();
|
||||||
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||||
final TempTarget tempTarget = TreatmentsPlugin.getPlugin().getTempTargetFromHistory();
|
final String profileName = ProfileFunctions.getInstance().getProfileName();
|
||||||
|
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||||
|
|
||||||
final QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
|
final QuickWizardEntry quickWizardEntry = OverviewPlugin.getPlugin().quickWizard.getActive();
|
||||||
if (quickWizardEntry != null && actualBg != null && profile != null) {
|
if (quickWizardEntry != null && actualBg != null && profile != null && pump != null) {
|
||||||
quickWizardButton.setVisibility(View.VISIBLE);
|
quickWizardButton.setVisibility(View.VISIBLE);
|
||||||
final BolusWizard wizard = quickWizardEntry.doCalc(profile, tempTarget, actualBg, true);
|
final BolusWizard wizard = quickWizardEntry.doCalc(profile, profileName, actualBg, true);
|
||||||
|
|
||||||
final JSONObject boluscalcJSON = new JSONObject();
|
if (wizard.getCalculatedTotalInsulin() > 0d && quickWizardEntry.carbs() > 0d) {
|
||||||
try {
|
|
||||||
boluscalcJSON.put("eventTime", DateUtil.toISOString(new Date()));
|
|
||||||
boluscalcJSON.put("targetBGLow", wizard.targetBGLow);
|
|
||||||
boluscalcJSON.put("targetBGHigh", wizard.targetBGHigh);
|
|
||||||
boluscalcJSON.put("isf", wizard.sens);
|
|
||||||
boluscalcJSON.put("ic", wizard.ic);
|
|
||||||
boluscalcJSON.put("iob", -(wizard.insulingFromBolusIOB + wizard.insulingFromBasalsIOB));
|
|
||||||
boluscalcJSON.put("bolusiobused", true);
|
|
||||||
boluscalcJSON.put("basaliobused", true);
|
|
||||||
boluscalcJSON.put("bg", actualBg.valueToUnits(profile.getUnits()));
|
|
||||||
boluscalcJSON.put("insulinbg", wizard.insulinFromBG);
|
|
||||||
boluscalcJSON.put("insulinbgused", true);
|
|
||||||
boluscalcJSON.put("bgdiff", wizard.bgDiff);
|
|
||||||
boluscalcJSON.put("insulincarbs", wizard.insulinFromCarbs);
|
|
||||||
boluscalcJSON.put("carbs", quickWizardEntry.carbs());
|
|
||||||
boluscalcJSON.put("othercorrection", 0d);
|
|
||||||
boluscalcJSON.put("insulintrend", wizard.insulinFromTrend);
|
|
||||||
boluscalcJSON.put("insulin", wizard.calculatedTotalInsulin);
|
|
||||||
} catch (JSONException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
if (wizard.calculatedTotalInsulin > 0d && quickWizardEntry.carbs() > 0d) {
|
|
||||||
DecimalFormat formatNumber2decimalplaces = new DecimalFormat("0.00");
|
|
||||||
String confirmMessage = MainApp.gs(R.string.entertreatmentquestion);
|
|
||||||
|
|
||||||
Double insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(wizard.calculatedTotalInsulin)).value();
|
|
||||||
Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(quickWizardEntry.carbs())).value();
|
Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(quickWizardEntry.carbs())).value();
|
||||||
|
|
||||||
confirmMessage += "\n" + MainApp.gs(R.string.bolus) + ": " + formatNumber2decimalplaces.format(insulinAfterConstraints) + "U";
|
if (Math.abs(wizard.getInsulinAfterConstraints() - wizard.getCalculatedTotalInsulin()) >= pump.getPumpDescription().pumpType.determineCorrectBolusStepSize(wizard.getInsulinAfterConstraints()) || !carbsAfterConstraints.equals(quickWizardEntry.carbs())) {
|
||||||
confirmMessage += "\n" + MainApp.gs(R.string.carbs) + ": " + carbsAfterConstraints + "g";
|
OKDialog.show(getContext(), MainApp.gs(R.string.treatmentdeliveryerror), MainApp.gs(R.string.constraints_violation) + "\n" + MainApp.gs(R.string.changeyourinput), null);
|
||||||
|
|
||||||
if (Math.abs(insulinAfterConstraints - wizard.calculatedTotalInsulin) >= 0.01 || !carbsAfterConstraints.equals(quickWizardEntry.carbs())) {
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
|
||||||
builder.setTitle(MainApp.gs(R.string.treatmentdeliveryerror));
|
|
||||||
builder.setMessage(MainApp.gs(R.string.constraints_violation) + "\n" + MainApp.gs(R.string.changeyourinput));
|
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), null);
|
|
||||||
builder.show();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Double finalInsulinAfterConstraints = insulinAfterConstraints;
|
wizard.confirmAndExecute(getContext());
|
||||||
final Integer finalCarbsAfterConstraints = carbsAfterConstraints;
|
|
||||||
final Context context = getContext();
|
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
||||||
accepted = false;
|
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
|
||||||
builder.setMessage(confirmMessage);
|
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), (dialog, id) -> {
|
|
||||||
synchronized (builder) {
|
|
||||||
if (accepted) {
|
|
||||||
if (L.isEnabled(L.OVERVIEW))
|
|
||||||
log.debug("guarding: already accepted");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
accepted = true;
|
|
||||||
if (Math.abs(insulinAfterConstraints - wizard.calculatedTotalInsulin) >= 0.01 || finalCarbsAfterConstraints > 0) {
|
|
||||||
if (wizard.superBolus) {
|
|
||||||
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
|
||||||
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
|
||||||
loopPlugin.superBolusTo(System.currentTimeMillis() + T.hours(2).msecs());
|
|
||||||
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
|
|
||||||
}
|
|
||||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, 120, true, profile, new Callback() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (!result.success) {
|
|
||||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
|
||||||
i.putExtra("soundid", R.raw.boluserror);
|
|
||||||
i.putExtra("status", result.comment);
|
|
||||||
i.putExtra("title", MainApp.gs(R.string.tempbasaldeliveryerror));
|
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
MainApp.instance().startActivity(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
|
||||||
detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD;
|
|
||||||
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
|
||||||
detailedBolusInfo.carbs = finalCarbsAfterConstraints;
|
|
||||||
detailedBolusInfo.context = context;
|
|
||||||
detailedBolusInfo.boluscalc = boluscalcJSON;
|
|
||||||
detailedBolusInfo.source = Source.USER;
|
|
||||||
if (finalInsulinAfterConstraints > 0 || ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().storesCarbInfo) {
|
|
||||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (!result.success) {
|
|
||||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
|
||||||
i.putExtra("soundid", R.raw.boluserror);
|
|
||||||
i.putExtra("status", result.comment);
|
|
||||||
i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror));
|
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
MainApp.instance().startActivity(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
|
||||||
builder.show();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1085,6 +983,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||||
|
|
||||||
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||||
|
final String profileName = ProfileFunctions.getInstance().getProfileName();
|
||||||
|
|
||||||
final String units = profile.getUnits();
|
final String units = profile.getUnits();
|
||||||
final double lowLine = OverviewPlugin.getPlugin().determineLowLine(units);
|
final double lowLine = OverviewPlugin.getPlugin().determineLowLine(units);
|
||||||
|
@ -1282,10 +1181,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
if (quickWizardEntry != null && lastBG != null && pump.isInitialized() && !pump.isSuspended()) {
|
if (quickWizardEntry != null && lastBG != null && pump.isInitialized() && !pump.isSuspended()) {
|
||||||
quickWizardButton.setVisibility(View.VISIBLE);
|
quickWizardButton.setVisibility(View.VISIBLE);
|
||||||
String text = quickWizardEntry.buttonText() + "\n" + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
|
String text = quickWizardEntry.buttonText() + "\n" + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
|
||||||
BolusWizard wizard = quickWizardEntry.doCalc(profile, tempTarget, lastBG, false);
|
BolusWizard wizard = quickWizardEntry.doCalc(profile, profileName, lastBG, false);
|
||||||
text += " " + DecimalFormatter.toPumpSupportedBolus(wizard.calculatedTotalInsulin) + "U";
|
text += " " + DecimalFormatter.toPumpSupportedBolus(wizard.getCalculatedTotalInsulin()) + "U";
|
||||||
quickWizardButton.setText(text);
|
quickWizardButton.setText(text);
|
||||||
if (wizard.calculatedTotalInsulin <= 0)
|
if (wizard.getCalculatedTotalInsulin() <= 0)
|
||||||
quickWizardButton.setVisibility(View.GONE);
|
quickWizardButton.setVisibility(View.GONE);
|
||||||
} else
|
} else
|
||||||
quickWizardButton.setVisibility(View.GONE);
|
quickWizardButton.setVisibility(View.GONE);
|
||||||
|
|
|
@ -225,7 +225,7 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Math.abs(insulinAfterConstraints - insulin) > pump.getPumpDescription().pumpType.determineCorrectBolusSize(insulinAfterConstraints))
|
if (Math.abs(insulinAfterConstraints - insulin) > pump.getPumpDescription().pumpType.determineCorrectBolusStepSize(insulinAfterConstraints))
|
||||||
actions.add("<font color='" + MainApp.gc(R.color.warning) + "'>" + MainApp.gs(R.string.bolusconstraintapplied) + "</font>");
|
actions.add("<font color='" + MainApp.gc(R.color.warning) + "'>" + MainApp.gs(R.string.bolusconstraintapplied) + "</font>");
|
||||||
|
|
||||||
int eatingSoonTTDuration = SP.getInt(R.string.key_eatingsoon_duration, Constants.defaultEatingSoonTTDuration);
|
int eatingSoonTTDuration = SP.getInt(R.string.key_eatingsoon_duration, Constants.defaultEatingSoonTTDuration);
|
||||||
|
|
|
@ -141,7 +141,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
|
||||||
if (recordOnlyCheckbox.isChecked()) {
|
if (recordOnlyCheckbox.isChecked()) {
|
||||||
confirmMessage += "<br/><font color='" + MainApp.gc(R.color.warning) + "'>" + MainApp.gs(R.string.bolusrecordedonly) + "</font>";
|
confirmMessage += "<br/><font color='" + MainApp.gc(R.color.warning) + "'>" + MainApp.gs(R.string.bolusrecordedonly) + "</font>";
|
||||||
}
|
}
|
||||||
if (Math.abs(insulinAfterConstraints - insulin) > pump.getPumpDescription().pumpType.determineCorrectBolusSize(insulinAfterConstraints) || !Objects.equals(carbsAfterConstraints, carbs))
|
if (Math.abs(insulinAfterConstraints - insulin) > pump.getPumpDescription().pumpType.determineCorrectBolusStepSize(insulinAfterConstraints) || !Objects.equals(carbsAfterConstraints, carbs))
|
||||||
confirmMessage += "<br/><font color='" + MainApp.gc(R.color.warning) + "'>" + MainApp.gs(R.string.bolusconstraintapplied) + "</font>";
|
confirmMessage += "<br/><font color='" + MainApp.gc(R.color.warning) + "'>" + MainApp.gs(R.string.bolusconstraintapplied) + "</font>";
|
||||||
}
|
}
|
||||||
if (carbsAfterConstraints > 0)
|
if (carbsAfterConstraints > 0)
|
||||||
|
|
|
@ -2,13 +2,10 @@ package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import androidx.fragment.app.DialogFragment;
|
import androidx.fragment.app.DialogFragment;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
import android.text.Html;
|
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -28,46 +25,35 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
|
|
||||||
import org.json.JSONException;
|
|
||||||
import org.json.JSONObject;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
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.R;
|
||||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
|
||||||
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.data.ProfileStore;
|
import info.nightscout.androidaps.data.ProfileStore;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.CareportalEvent;
|
|
||||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||||
import info.nightscout.androidaps.db.Source;
|
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.events.EventFeatureRunning;
|
import info.nightscout.androidaps.events.EventFeatureRunning;
|
||||||
import info.nightscout.androidaps.events.EventRefreshOverview;
|
|
||||||
import info.nightscout.androidaps.interfaces.Constraint;
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.interfaces.PluginType;
|
|
||||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
|
||||||
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.CobInfo;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.CobInfo;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
||||||
import info.nightscout.androidaps.queue.Callback;
|
|
||||||
import info.nightscout.androidaps.utils.BolusWizard;
|
import info.nightscout.androidaps.utils.BolusWizard;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.androidaps.utils.NumberPicker;
|
import info.nightscout.androidaps.utils.NumberPicker;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
import info.nightscout.androidaps.utils.SafeParse;
|
import info.nightscout.androidaps.utils.SafeParse;
|
||||||
|
import info.nightscout.androidaps.utils.StringUtils;
|
||||||
import info.nightscout.androidaps.utils.ToastUtils;
|
import info.nightscout.androidaps.utils.ToastUtils;
|
||||||
|
|
||||||
public class WizardDialog extends DialogFragment implements OnClickListener, CompoundButton.OnCheckedChangeListener, Spinner.OnItemSelectedListener {
|
public class WizardDialog extends DialogFragment implements OnClickListener, CompoundButton.OnCheckedChangeListener, Spinner.OnItemSelectedListener {
|
||||||
|
@ -108,8 +94,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
EditText notesEdit;
|
EditText notesEdit;
|
||||||
|
|
||||||
Integer calculatedCarbs = 0;
|
Integer calculatedCarbs = 0;
|
||||||
Double calculatedTotalInsulin = 0d;
|
BolusWizard wizard;
|
||||||
JSONObject boluscalcJSON;
|
|
||||||
|
|
||||||
Context context;
|
Context context;
|
||||||
|
|
||||||
|
@ -311,99 +296,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
okClicked = true;
|
okClicked = true;
|
||||||
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
wizard.confirmAndExecute(context);
|
||||||
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
dismiss();
|
||||||
|
|
||||||
if (pump != null && profile != null && (calculatedTotalInsulin > 0d || calculatedCarbs > 0d)) {
|
|
||||||
String confirmMessage = MainApp.gs(R.string.entertreatmentquestion);
|
|
||||||
|
|
||||||
Double insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(calculatedTotalInsulin)).value();
|
|
||||||
Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(calculatedCarbs)).value();
|
|
||||||
|
|
||||||
if (insulinAfterConstraints > 0)
|
|
||||||
confirmMessage += "<br/>" + MainApp.gs(R.string.bolus) + ": " + "<font color='" + MainApp.gc(R.color.bolus) + "'>" + DecimalFormatter.toPumpSupportedBolus(insulinAfterConstraints) + "U" + "</font>";
|
|
||||||
if (carbsAfterConstraints > 0)
|
|
||||||
confirmMessage += "<br/>" + MainApp.gs(R.string.carbs) + ": " + "<font color='" + MainApp.gc(R.color.carbs) + "'>" + carbsAfterConstraints + "g" + "</font>";
|
|
||||||
|
|
||||||
if (Math.abs(insulinAfterConstraints - calculatedTotalInsulin) > pump.getPumpDescription().pumpType.determineCorrectBolusSize(insulinAfterConstraints) || !carbsAfterConstraints.equals(calculatedCarbs)) {
|
|
||||||
confirmMessage += "<br/><font color='" + MainApp.gc(R.color.warning) + "'>" + MainApp.gs(R.string.bolusconstraintapplied) + "</font>";
|
|
||||||
}
|
|
||||||
|
|
||||||
final Double finalInsulinAfterConstraints = insulinAfterConstraints;
|
|
||||||
final Integer finalCarbsAfterConstraints = carbsAfterConstraints;
|
|
||||||
final Double bg = SafeParse.stringToDouble(editBg.getText());
|
|
||||||
final int carbTime = SafeParse.stringToInt(editCarbTime.getText());
|
|
||||||
final boolean useSuperBolus = superbolusCheckbox.isChecked();
|
|
||||||
final String finalNotes = notesEdit.getText().toString();
|
|
||||||
|
|
||||||
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
|
||||||
builder.setMessage(Html.fromHtml(confirmMessage));
|
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
|
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
|
||||||
synchronized (builder) {
|
|
||||||
if (accepted) {
|
|
||||||
log.debug("guarding: already accepted");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
accepted = true;
|
|
||||||
if (finalInsulinAfterConstraints > 0 || finalCarbsAfterConstraints > 0) {
|
|
||||||
if (useSuperBolus) {
|
|
||||||
final LoopPlugin loopPlugin = LoopPlugin.getPlugin();
|
|
||||||
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
|
||||||
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
|
|
||||||
MainApp.bus().post(new EventRefreshOverview("WizardDialog"));
|
|
||||||
}
|
|
||||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().tempBasalPercent(0, 120, true, profile, new Callback() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (!result.success) {
|
|
||||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
|
||||||
i.putExtra("soundid", R.raw.boluserror);
|
|
||||||
i.putExtra("status", result.comment);
|
|
||||||
i.putExtra("title", MainApp.gs(R.string.tempbasaldeliveryerror));
|
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
MainApp.instance().startActivity(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
|
||||||
detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD;
|
|
||||||
detailedBolusInfo.insulin = finalInsulinAfterConstraints;
|
|
||||||
detailedBolusInfo.carbs = finalCarbsAfterConstraints;
|
|
||||||
detailedBolusInfo.context = context;
|
|
||||||
detailedBolusInfo.glucose = bg;
|
|
||||||
detailedBolusInfo.glucoseType = "Manual";
|
|
||||||
detailedBolusInfo.carbTime = carbTime;
|
|
||||||
detailedBolusInfo.boluscalc = boluscalcJSON;
|
|
||||||
detailedBolusInfo.source = Source.USER;
|
|
||||||
detailedBolusInfo.notes = finalNotes;
|
|
||||||
if (detailedBolusInfo.insulin > 0 || ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().storesCarbInfo) {
|
|
||||||
ConfigBuilderPlugin.getPlugin().getCommandQueue().bolus(detailedBolusInfo, new Callback() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (!result.success) {
|
|
||||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
|
||||||
i.putExtra("soundid", R.raw.boluserror);
|
|
||||||
i.putExtra("status", result.comment);
|
|
||||||
i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror));
|
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
||||||
MainApp.instance().startActivity(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
builder.setNegativeButton(MainApp.gs(R.string.cancel), null);
|
|
||||||
builder.show();
|
|
||||||
dismiss();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case R.id.cancel:
|
case R.id.cancel:
|
||||||
dismiss();
|
dismiss();
|
||||||
|
@ -450,8 +344,8 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
TreatmentsPlugin.getPlugin().updateTotalIOBTempBasals();
|
TreatmentsPlugin.getPlugin().updateTotalIOBTempBasals();
|
||||||
IobTotal basalIob = TreatmentsPlugin.getPlugin().getLastCalculationTempBasals().round();
|
IobTotal basalIob = TreatmentsPlugin.getPlugin().getLastCalculationTempBasals().round();
|
||||||
|
|
||||||
bolusIobInsulin.setText(DecimalFormatter.to2Decimal(-bolusIob.iob) + "U");
|
bolusIobInsulin.setText(StringUtils.formatInsulin(-bolusIob.iob));
|
||||||
basalIobInsulin.setText(DecimalFormatter.to2Decimal(-basalIob.basaliob) + "U");
|
basalIobInsulin.setText(StringUtils.formatInsulin(-basalIob.basaliob));
|
||||||
|
|
||||||
calculateInsulin();
|
calculateInsulin();
|
||||||
}
|
}
|
||||||
|
@ -460,13 +354,13 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
ProfileStore profileStore = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile();
|
ProfileStore profileStore = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile();
|
||||||
if (profileSpinner == null || profileSpinner.getSelectedItem() == null || profileStore == null)
|
if (profileSpinner == null || profileSpinner.getSelectedItem() == null || profileStore == null)
|
||||||
return; // not initialized yet
|
return; // not initialized yet
|
||||||
String selectedAlternativeProfile = profileSpinner.getSelectedItem().toString();
|
String profileName = profileSpinner.getSelectedItem().toString();
|
||||||
Profile specificProfile;
|
Profile specificProfile;
|
||||||
if (selectedAlternativeProfile.equals(MainApp.gs(R.string.active))) {
|
if (profileName.equals(MainApp.gs(R.string.active))) {
|
||||||
specificProfile = ProfileFunctions.getInstance().getProfile();
|
specificProfile = ProfileFunctions.getInstance().getProfile();
|
||||||
selectedAlternativeProfile = ProfileFunctions.getInstance().getProfileName();
|
profileName = ProfileFunctions.getInstance().getProfileName();
|
||||||
} else
|
} else
|
||||||
specificProfile = profileStore.getSpecificProfile(selectedAlternativeProfile);
|
specificProfile = profileStore.getSpecificProfile(profileName);
|
||||||
|
|
||||||
// Entered values
|
// Entered values
|
||||||
Double c_bg = SafeParse.stringToDouble(editBg.getText());
|
Double c_bg = SafeParse.stringToDouble(editBg.getText());
|
||||||
|
@ -494,104 +388,61 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
||||||
Double c_cob = 0d;
|
Double c_cob = 0d;
|
||||||
if (cobCheckbox.isChecked()) {
|
if (cobCheckbox.isChecked()) {
|
||||||
CobInfo cobInfo = IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "Wizard COB");
|
CobInfo cobInfo = IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "Wizard COB");
|
||||||
if (cobInfo != null && cobInfo.displayCob != null)
|
if (cobInfo.displayCob != null)
|
||||||
c_cob = cobInfo.displayCob;
|
c_cob = cobInfo.displayCob;
|
||||||
}
|
}
|
||||||
|
|
||||||
BolusWizard wizard = new BolusWizard();
|
wizard = new BolusWizard(specificProfile, profileName, tempTarget, carbsAfterConstraint, c_cob, c_bg, corrAfterConstraint, 100d, bgCheckbox.isChecked(), cobCheckbox.isChecked(), bolusIobCheckbox.isChecked(), basalIobCheckbox.isChecked(), superbolusCheckbox.isChecked(), ttCheckbox.isChecked(), bgtrendCheckbox.isChecked(), notesEdit.getText().toString(), SafeParse.stringToInt(editCarbTime.getText()));
|
||||||
wizard.doCalc(specificProfile, tempTarget, carbsAfterConstraint, c_cob, c_bg, corrAfterConstraint, bolusIobCheckbox.isChecked(), basalIobCheckbox.isChecked(), superbolusCheckbox.isChecked(), bgtrendCheckbox.isChecked());
|
|
||||||
|
|
||||||
bg.setText(c_bg + " ISF: " + DecimalFormatter.to1Decimal(wizard.sens));
|
bg.setText(c_bg + " ISF: " + DecimalFormatter.to1Decimal(wizard.getSens()));
|
||||||
bgInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromBG) + "U");
|
bgInsulin.setText(StringUtils.formatInsulin(wizard.getInsulinFromBG()));
|
||||||
|
|
||||||
carbs.setText(DecimalFormatter.to0Decimal(c_carbs) + "g IC: " + DecimalFormatter.to1Decimal(wizard.ic));
|
carbs.setText(DecimalFormatter.to0Decimal(c_carbs) + "g IC: " + DecimalFormatter.to1Decimal(wizard.getIc()));
|
||||||
carbsInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromCarbs) + "U");
|
carbsInsulin.setText(StringUtils.formatInsulin(wizard.getInsulinFromCarbs()));
|
||||||
|
|
||||||
bolusIobInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulingFromBolusIOB) + "U");
|
bolusIobInsulin.setText(StringUtils.formatInsulin(wizard.getInsulinFromBolusIOB()));
|
||||||
basalIobInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulingFromBasalsIOB) + "U");
|
basalIobInsulin.setText(StringUtils.formatInsulin(wizard.getInsulinFromBasalsIOB()));
|
||||||
|
|
||||||
correctionInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromCorrection) + "U");
|
correctionInsulin.setText(StringUtils.formatInsulin(wizard.getInsulinFromCorrection()));
|
||||||
calculatedTotalInsulin = wizard.calculatedTotalInsulin;
|
|
||||||
|
|
||||||
calculatedCarbs = carbsAfterConstraint;
|
calculatedCarbs = carbsAfterConstraint;
|
||||||
|
|
||||||
// Superbolus
|
// Superbolus
|
||||||
if (superbolusCheckbox.isChecked()) {
|
superbolus.setText(superbolusCheckbox.isChecked() ? MainApp.gs(R.string.twohours) : "");
|
||||||
superbolus.setText("2h");
|
superbolusInsulin.setText(StringUtils.formatInsulin(wizard.getInsulinFromSuperBolus()));
|
||||||
} else {
|
|
||||||
superbolus.setText("");
|
|
||||||
}
|
|
||||||
superbolusInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromSuperBolus) + "U");
|
|
||||||
|
|
||||||
// Trend
|
// Trend
|
||||||
if (bgtrendCheckbox.isChecked()) {
|
if (bgtrendCheckbox.isChecked() && wizard.getGlucoseStatus() != null) {
|
||||||
if (wizard.glucoseStatus != null) {
|
bgTrend.setText(
|
||||||
bgTrend.setText((wizard.glucoseStatus.avgdelta > 0 ? "+" : "") + Profile.toUnitsString(wizard.glucoseStatus.avgdelta * 3, wizard.glucoseStatus.avgdelta * 3 / 18, specificProfile.getUnits()) + " " + specificProfile.getUnits());
|
(wizard.getTrend() > 0 ? "+" : "")
|
||||||
} else {
|
+ Profile.toUnitsString(wizard.getTrend() * 3, wizard.getTrend() * 3 / Constants.MMOLL_TO_MGDL, specificProfile.getUnits())
|
||||||
bgTrend.setText("");
|
+ " " + specificProfile.getUnits());
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
bgTrend.setText("");
|
bgTrend.setText("");
|
||||||
}
|
}
|
||||||
bgTrendInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromTrend) + "U");
|
bgTrendInsulin.setText(StringUtils.formatInsulin(wizard.getInsulinFromTrend()));
|
||||||
|
|
||||||
// COB
|
// COB
|
||||||
if (cobCheckbox.isChecked()) {
|
if (cobCheckbox.isChecked()) {
|
||||||
cob.setText(DecimalFormatter.to2Decimal(c_cob) + "g IC: " + DecimalFormatter.to1Decimal(wizard.ic));
|
cob.setText(DecimalFormatter.to2Decimal(c_cob) + "g IC: " + DecimalFormatter.to1Decimal(wizard.getIc()));
|
||||||
cobInsulin.setText(DecimalFormatter.to2Decimal(wizard.insulinFromCOB) + "U");
|
cobInsulin.setText(StringUtils.formatInsulin(wizard.getInsulinFromCOB()));
|
||||||
} else {
|
} else {
|
||||||
cob.setText("");
|
cob.setText("");
|
||||||
cobInsulin.setText("");
|
cobInsulin.setText("");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (calculatedTotalInsulin > 0d || calculatedCarbs > 0d) {
|
if (wizard.getCalculatedTotalInsulin() > 0d || calculatedCarbs > 0d) {
|
||||||
String insulinText = calculatedTotalInsulin > 0d ? (DecimalFormatter.toPumpSupportedBolus(calculatedTotalInsulin) + "U") : "";
|
String insulinText = wizard.getCalculatedTotalInsulin() > 0d ? (DecimalFormatter.toPumpSupportedBolus(wizard.getCalculatedTotalInsulin()) + "U") : "";
|
||||||
String carbsText = calculatedCarbs > 0d ? (DecimalFormatter.to0Decimal(calculatedCarbs) + "g") : "";
|
String carbsText = calculatedCarbs > 0d ? (DecimalFormatter.to0Decimal(calculatedCarbs) + "g") : "";
|
||||||
total.setText(MainApp.gs(R.string.result) + ": " + insulinText + " " + carbsText);
|
total.setText(MainApp.gs(R.string.result) + ": " + insulinText + " " + carbsText);
|
||||||
okButton.setVisibility(View.VISIBLE);
|
okButton.setVisibility(View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
// TODO this should also be run when loading the dialog as the OK button is initially visible
|
// TODO this should also be run when loading the dialog as the OK button is initially visible
|
||||||
// but does nothing if neither carbs nor insulin is > 0
|
// but does nothing if neither carbs nor insulin is > 0
|
||||||
total.setText(MainApp.gs(R.string.missing) + " " + DecimalFormatter.to0Decimal(wizard.carbsEquivalent) + "g");
|
total.setText(MainApp.gs(R.string.missing) + " " + DecimalFormatter.to0Decimal(wizard.getCarbsEquivalent()) + "g");
|
||||||
okButton.setVisibility(View.INVISIBLE);
|
okButton.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
boluscalcJSON = new JSONObject();
|
|
||||||
try {
|
|
||||||
boluscalcJSON.put("profile", selectedAlternativeProfile);
|
|
||||||
boluscalcJSON.put("notes", notesEdit.getText());
|
|
||||||
boluscalcJSON.put("eventTime", DateUtil.toISOString(new Date()));
|
|
||||||
boluscalcJSON.put("targetBGLow", wizard.targetBGLow);
|
|
||||||
boluscalcJSON.put("targetBGHigh", wizard.targetBGHigh);
|
|
||||||
boluscalcJSON.put("isf", wizard.sens);
|
|
||||||
boluscalcJSON.put("ic", wizard.ic);
|
|
||||||
boluscalcJSON.put("iob", -(wizard.insulingFromBolusIOB + wizard.insulingFromBasalsIOB));
|
|
||||||
boluscalcJSON.put("bolusiob", wizard.insulingFromBolusIOB);
|
|
||||||
boluscalcJSON.put("basaliob", wizard.insulingFromBasalsIOB);
|
|
||||||
boluscalcJSON.put("bolusiobused", bolusIobCheckbox.isChecked());
|
|
||||||
boluscalcJSON.put("basaliobused", basalIobCheckbox.isChecked());
|
|
||||||
boluscalcJSON.put("bg", c_bg);
|
|
||||||
boluscalcJSON.put("insulinbg", wizard.insulinFromBG);
|
|
||||||
boluscalcJSON.put("insulinbgused", bgCheckbox.isChecked());
|
|
||||||
boluscalcJSON.put("bgdiff", wizard.bgDiff);
|
|
||||||
boluscalcJSON.put("insulincarbs", wizard.insulinFromCarbs);
|
|
||||||
boluscalcJSON.put("carbs", c_carbs);
|
|
||||||
boluscalcJSON.put("cob", c_cob);
|
|
||||||
boluscalcJSON.put("cobused", cobCheckbox.isChecked());
|
|
||||||
boluscalcJSON.put("insulincob", wizard.insulinFromCOB);
|
|
||||||
boluscalcJSON.put("othercorrection", corrAfterConstraint);
|
|
||||||
boluscalcJSON.put("insulinsuperbolus", wizard.insulinFromSuperBolus);
|
|
||||||
boluscalcJSON.put("insulintrend", wizard.insulinFromTrend);
|
|
||||||
boluscalcJSON.put("insulin", calculatedTotalInsulin);
|
|
||||||
boluscalcJSON.put("superbolusused", superbolusCheckbox.isChecked());
|
|
||||||
boluscalcJSON.put("insulinsuperbolus", wizard.insulinFromSuperBolus);
|
|
||||||
boluscalcJSON.put("trendused", bgtrendCheckbox.isChecked());
|
|
||||||
boluscalcJSON.put("insulintrend", wizard.insulinFromTrend);
|
|
||||||
boluscalcJSON.put("trend", bgTrend.getText());
|
|
||||||
boluscalcJSON.put("ttused", ttCheckbox.isChecked());
|
|
||||||
} catch (JSONException e) {
|
|
||||||
log.error("Unhandled exception", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@ import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
public class PersistentNotificationPlugin extends PluginBase {
|
public class PersistentNotificationPlugin extends PluginBase {
|
||||||
|
|
||||||
private static PersistentNotificationPlugin plugin;
|
private static PersistentNotificationPlugin plugin;
|
||||||
|
private Notification notification;
|
||||||
|
|
||||||
public static PersistentNotificationPlugin getPlugin() {
|
public static PersistentNotificationPlugin getPlugin() {
|
||||||
if (plugin == null) plugin = new PersistentNotificationPlugin(MainApp.instance());
|
if (plugin == null) plugin = new PersistentNotificationPlugin(MainApp.instance());
|
||||||
|
@ -250,6 +251,7 @@ public class PersistentNotificationPlugin extends PluginBase {
|
||||||
|
|
||||||
android.app.Notification notification = builder.build();
|
android.app.Notification notification = builder.build();
|
||||||
mNotificationManager.notify(ONGOING_NOTIFICATION_ID, notification);
|
mNotificationManager.notify(ONGOING_NOTIFICATION_ID, notification);
|
||||||
|
this.notification = notification;
|
||||||
return notification;
|
return notification;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,6 +271,17 @@ public class PersistentNotificationPlugin extends PluginBase {
|
||||||
return deltastring;
|
return deltastring;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* returns the current ongoing notification.
|
||||||
|
*
|
||||||
|
* If it does not exist, return a dummy notification. This should only happen if onStart() wasn't called.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public Notification getLastNotification() {
|
||||||
|
if (notification != null) return notification;
|
||||||
|
else return new Notification();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(final EventPreferenceChange ev) {
|
public void onStatusEvent(final EventPreferenceChange ev) {
|
||||||
|
|
|
@ -207,6 +207,7 @@ public class ActionStringHandler {
|
||||||
int percentage = Integer.parseInt(act[2]);
|
int percentage = Integer.parseInt(act[2]);
|
||||||
|
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||||
|
String profileName = ProfileFunctions.getInstance().getProfileName();
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
sendError("No profile found!");
|
sendError("No profile found!");
|
||||||
return;
|
return;
|
||||||
|
@ -226,45 +227,38 @@ public class ActionStringHandler {
|
||||||
|
|
||||||
DecimalFormat format = new DecimalFormat("0.00");
|
DecimalFormat format = new DecimalFormat("0.00");
|
||||||
DecimalFormat formatInt = new DecimalFormat("0");
|
DecimalFormat formatInt = new DecimalFormat("0");
|
||||||
BolusWizard bolusWizard = new BolusWizard();
|
BolusWizard bolusWizard = new BolusWizard(profile, profileName, TreatmentsPlugin.getPlugin().getTempTargetFromHistory(),
|
||||||
bolusWizard.doCalc(profile, useTT ? TreatmentsPlugin.getPlugin().getTempTargetFromHistory() : null,
|
carbsAfterConstraints, cobInfo.displayCob, bgReading.valueToUnits(profile.getUnits()),
|
||||||
carbsAfterConstraints, useCOB?cobInfo.displayCob:0d, useBG ? bgReading.valueToUnits(profile.getUnits()) : 0d,
|
0d, percentage, useBG, useCOB, useBolusIOB, useBasalIOB, false, useTT, useTrend);
|
||||||
0d, percentage, useBolusIOB, useBasalIOB, false, useTrend);
|
|
||||||
|
|
||||||
Double insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(new Constraint<>(bolusWizard.calculatedTotalInsulin)).value();
|
if (Math.abs(bolusWizard.getInsulinAfterConstraints() - bolusWizard.getCalculatedTotalInsulin()) >= 0.01) {
|
||||||
if (Math.abs(insulinAfterConstraints - bolusWizard.calculatedTotalInsulin) >= 0.01) {
|
|
||||||
sendError("Insulin constraint violation!" +
|
sendError("Insulin constraint violation!" +
|
||||||
"\nCannot deliver " + format.format(bolusWizard.calculatedTotalInsulin) + "!");
|
"\nCannot deliver " + format.format(bolusWizard.getCalculatedTotalInsulin()) + "!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bolusWizard.getCalculatedTotalInsulin() <= 0 && bolusWizard.getCarbs() <= 0) {
|
||||||
if (bolusWizard.calculatedTotalInsulin < 0) {
|
|
||||||
bolusWizard.calculatedTotalInsulin = 0d;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bolusWizard.calculatedTotalInsulin <= 0 && bolusWizard.carbs <= 0) {
|
|
||||||
rAction = "info";
|
rAction = "info";
|
||||||
rTitle = "INFO";
|
rTitle = "INFO";
|
||||||
} else {
|
} else {
|
||||||
rAction = actionstring;
|
rAction = actionstring;
|
||||||
}
|
}
|
||||||
rMessage += "Carbs: " + bolusWizard.carbs + "g";
|
rMessage += "Carbs: " + bolusWizard.getCarbs() + "g";
|
||||||
rMessage += "\nBolus: " + format.format(bolusWizard.calculatedTotalInsulin) + "U";
|
rMessage += "\nBolus: " + format.format(bolusWizard.getCalculatedTotalInsulin()) + "U";
|
||||||
rMessage += "\n_____________";
|
rMessage += "\n_____________";
|
||||||
rMessage += "\nCalc (IC:" + DecimalFormatter.to1Decimal(bolusWizard.ic) + ", " + "ISF:" + DecimalFormatter.to1Decimal(bolusWizard.sens) + "): ";
|
rMessage += "\nCalc (IC:" + DecimalFormatter.to1Decimal(bolusWizard.getIc()) + ", " + "ISF:" + DecimalFormatter.to1Decimal(bolusWizard.getSens()) + "): ";
|
||||||
rMessage += "\nFrom Carbs: " + format.format(bolusWizard.insulinFromCarbs) + "U";
|
rMessage += "\nFrom Carbs: " + format.format(bolusWizard.getInsulinFromCarbs()) + "U";
|
||||||
if (useCOB)
|
if (useCOB)
|
||||||
rMessage += "\nFrom" + formatInt.format(cobInfo.displayCob) + "g COB : " + format.format(bolusWizard.insulinFromCOB) + "U";
|
rMessage += "\nFrom" + formatInt.format(cobInfo.displayCob) + "g COB : " + format.format(bolusWizard.getInsulinFromCOB()) + "U";
|
||||||
if (useBG) rMessage += "\nFrom BG: " + format.format(bolusWizard.insulinFromBG) + "U";
|
if (useBG) rMessage += "\nFrom BG: " + format.format(bolusWizard.getInsulinFromBG()) + "U";
|
||||||
if (useBolusIOB)
|
if (useBolusIOB)
|
||||||
rMessage += "\nBolus IOB: " + format.format(bolusWizard.insulingFromBolusIOB) + "U";
|
rMessage += "\nBolus IOB: " + format.format(bolusWizard.getInsulinFromBolusIOB()) + "U";
|
||||||
if (useBasalIOB)
|
if (useBasalIOB)
|
||||||
rMessage += "\nBasal IOB: " + format.format(bolusWizard.insulingFromBasalsIOB) + "U";
|
rMessage += "\nBasal IOB: " + format.format(bolusWizard.getInsulinFromBasalsIOB()) + "U";
|
||||||
if (useTrend)
|
if (useTrend)
|
||||||
rMessage += "\nFrom 15' trend: " + format.format(bolusWizard.insulinFromTrend) + "U";
|
rMessage += "\nFrom 15' trend: " + format.format(bolusWizard.getInsulinFromTrend()) + "U";
|
||||||
if (percentage != 100) {
|
if (percentage != 100) {
|
||||||
rMessage += "\nPercentage: " + format.format(bolusWizard.totalBeforePercentageAdjustment) + "U * " + percentage + "% -> ~" + format.format(bolusWizard.calculatedTotalInsulin) + "U";
|
rMessage += "\nPercentage: " + format.format(bolusWizard.getTotalBeforePercentageAdjustment()) + "U * " + percentage + "% -> ~" + format.format(bolusWizard.getCalculatedTotalInsulin()) + "U";
|
||||||
}
|
}
|
||||||
|
|
||||||
lastBolusWizard = bolusWizard;
|
lastBolusWizard = bolusWizard;
|
||||||
|
@ -628,7 +622,7 @@ public class ActionStringHandler {
|
||||||
if (lastBolusWizard != null) {
|
if (lastBolusWizard != null) {
|
||||||
//use last calculation as confirmed string matches
|
//use last calculation as confirmed string matches
|
||||||
|
|
||||||
doBolus(lastBolusWizard.calculatedTotalInsulin, lastBolusWizard.carbs);
|
doBolus(lastBolusWizard.getCalculatedTotalInsulin(), lastBolusWizard.getCarbs());
|
||||||
lastBolusWizard = null;
|
lastBolusWizard = null;
|
||||||
}
|
}
|
||||||
} else if ("bolus".equals(act[0])) {
|
} else if ("bolus".equals(act[0])) {
|
||||||
|
|
|
@ -242,6 +242,7 @@ public class RuffyScripter implements RuffyCommands {
|
||||||
Thread cmdThread = null;
|
Thread cmdThread = null;
|
||||||
try {
|
try {
|
||||||
activeCmd = cmd;
|
activeCmd = cmd;
|
||||||
|
unparsableMenuEncountered = false;
|
||||||
long connectStart = System.currentTimeMillis();
|
long connectStart = System.currentTimeMillis();
|
||||||
ensureConnected();
|
ensureConnected();
|
||||||
log.debug("Connection ready to execute cmd " + cmd);
|
log.debug("Connection ready to execute cmd " + cmd);
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.util.Map;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.data.DoseSettings;
|
import info.nightscout.androidaps.plugins.pump.common.data.DoseSettings;
|
||||||
|
import info.nightscout.androidaps.utils.Round;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -19,71 +19,71 @@ import info.nightscout.androidaps.plugins.pump.common.data.DoseSettings;
|
||||||
public enum PumpType {
|
public enum PumpType {
|
||||||
|
|
||||||
GenericAAPS("Generic AAPS", "AndroidAPS", "VirutalPump", 0.1d, null, //
|
GenericAAPS("Generic AAPS", "AndroidAPS", "VirutalPump", 0.1d, null, //
|
||||||
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
||||||
PumpTempBasalType.Percent, //
|
PumpTempBasalType.Percent, //
|
||||||
new DoseSettings(10,30, 24*60, 0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(10, 30, 24 * 60, 0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.01d, 0.01d, null, PumpCapability.VirtualPumpCapabilities), //
|
0.01d, 0.01d, null, PumpCapability.VirtualPumpCapabilities), //
|
||||||
|
|
||||||
// Cellnovo
|
// Cellnovo
|
||||||
|
|
||||||
Cellnovo1("Cellnovo", "Cellnovo", "Cellnovo", 0.05d, null, //
|
Cellnovo1("Cellnovo", "Cellnovo", "Cellnovo", 0.05d, null, //
|
||||||
new DoseSettings(0.05d, 30, 24*60, 1d, null),
|
new DoseSettings(0.05d, 30, 24 * 60, 1d, null),
|
||||||
PumpTempBasalType.Percent,
|
PumpTempBasalType.Percent,
|
||||||
new DoseSettings(5,30, 24*60, 0d, 200d), PumpCapability.BasalRate_Duration30minAllowed, //
|
new DoseSettings(5, 30, 24 * 60, 0d, 200d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||||
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities), //
|
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities), //
|
||||||
|
|
||||||
// Accu-Chek
|
// Accu-Chek
|
||||||
|
|
||||||
AccuChekCombo("Accu-Chek Combo", "Roche", "Combo", 0.1d, null, //
|
AccuChekCombo("Accu-Chek Combo", "Roche", "Combo", 0.1d, null, //
|
||||||
new DoseSettings(0.1d, 15, 12*60, 0.1d), //
|
new DoseSettings(0.1d, 15, 12 * 60, 0.1d), //
|
||||||
PumpTempBasalType.Percent,
|
PumpTempBasalType.Percent,
|
||||||
new DoseSettings(10, 15, 12*60,0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(10, 15, 12 * 60, 0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.01d, 0.01d, DoseStepSize.ComboBasal, PumpCapability.ComboCapabilities), //
|
0.01d, 0.01d, DoseStepSize.ComboBasal, PumpCapability.ComboCapabilities), //
|
||||||
|
|
||||||
AccuChekSpirit("Accu-Chek Spirit", "Roche", "Spirit", 0.1d, null, //
|
AccuChekSpirit("Accu-Chek Spirit", "Roche", "Spirit", 0.1d, null, //
|
||||||
new DoseSettings(0.1d, 15, 12*60, 0.1d), //
|
new DoseSettings(0.1d, 15, 12 * 60, 0.1d), //
|
||||||
PumpTempBasalType.Percent,
|
PumpTempBasalType.Percent,
|
||||||
new DoseSettings(10, 15, 12*60,0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(10, 15, 12 * 60, 0d, 500d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.01d, 0.1d, null, PumpCapability.VirtualPumpCapabilities), //
|
0.01d, 0.1d, null, PumpCapability.VirtualPumpCapabilities), //
|
||||||
|
|
||||||
AccuChekInsight("Accu-Chek Insight", "Roche", "Insight", 0.05d, DoseStepSize.InsightBolus, //
|
AccuChekInsight("Accu-Chek Insight", "Roche", "Insight", 0.05d, DoseStepSize.InsightBolus, //
|
||||||
new DoseSettings(0.05d, 15, 24*60, 0.05d), //
|
new DoseSettings(0.05d, 15, 24 * 60, 0.05d), //
|
||||||
PumpTempBasalType.Percent,
|
PumpTempBasalType.Percent,
|
||||||
new DoseSettings(10, 15, 24*60,0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(10, 15, 24 * 60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.02d, 0.01d, null, PumpCapability.InsightCapabilities), //
|
0.02d, 0.01d, null, PumpCapability.InsightCapabilities), //
|
||||||
|
|
||||||
AccuChekInsightBluetooth("Accu-Chek Insight", "Roche", "Insight", 0.01d, null, //
|
AccuChekInsightBluetooth("Accu-Chek Insight", "Roche", "Insight", 0.01d, null, //
|
||||||
new DoseSettings(0.01d, 15, 24*60, 0.05d), //
|
new DoseSettings(0.01d, 15, 24 * 60, 0.05d), //
|
||||||
PumpTempBasalType.Percent,
|
PumpTempBasalType.Percent,
|
||||||
new DoseSettings(10, 15, 24*60,0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(10, 15, 24 * 60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.02d, 0.01d, DoseStepSize.InsightBolus, PumpCapability.InsightCapabilities), //
|
0.02d, 0.01d, DoseStepSize.InsightBolus, PumpCapability.InsightCapabilities), //
|
||||||
|
|
||||||
// Animas
|
// Animas
|
||||||
AnimasVibe("Animas Vibe","Animas", "Vibe", 0.05d, null, // AnimasBolus?
|
AnimasVibe("Animas Vibe","Animas", "Vibe", 0.05d, null, // AnimasBolus?
|
||||||
new DoseSettings(0.05d, 30, 12*60, 0.05d), //
|
new DoseSettings(0.05d, 30, 12 * 60, 0.05d), //
|
||||||
PumpTempBasalType.Percent, //
|
PumpTempBasalType.Percent, //
|
||||||
new DoseSettings(10, 30, 24*60, 0d, 300d), PumpCapability.BasalRate_Duration30minAllowed, //
|
new DoseSettings(10, 30, 24 * 60, 0d, 300d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||||
0.025d, 5d, 0d, null, PumpCapability.VirtualPumpCapabilities), //
|
0.025d, 5d, 0d, null, PumpCapability.VirtualPumpCapabilities), //
|
||||||
|
|
||||||
AnimasPing("Animas Ping", "Ping", AnimasVibe),
|
AnimasPing("Animas Ping", "Ping", AnimasVibe),
|
||||||
|
|
||||||
// Dana
|
// Dana
|
||||||
DanaR("DanaR", "SOOIL", "DanaR", 0.05d, null, //
|
DanaR("DanaR", "SOOIL", "DanaR", 0.05d, null, //
|
||||||
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
||||||
PumpTempBasalType.Percent, //
|
PumpTempBasalType.Percent, //
|
||||||
new DoseSettings(10d, 60, 24*60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minNotAllowed, //
|
new DoseSettings(10d, 60, 24 * 60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minNotAllowed, //
|
||||||
0.04d, 0.01d, null, PumpCapability.DanaCapabilities),
|
0.04d, 0.01d, null, PumpCapability.DanaCapabilities),
|
||||||
|
|
||||||
DanaRKorean("DanaR Korean", "SOOIL", "DanaRKorean", 0.05d, null, //
|
DanaRKorean("DanaR Korean", "SOOIL", "DanaRKorean", 0.05d, null, //
|
||||||
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
||||||
PumpTempBasalType.Percent, //
|
PumpTempBasalType.Percent, //
|
||||||
new DoseSettings(10d, 60, 24*60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minNotAllowed, //
|
new DoseSettings(10d, 60, 24 * 60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minNotAllowed, //
|
||||||
0.1d, 0.01d, null, PumpCapability.DanaCapabilities),
|
0.1d, 0.01d, null, PumpCapability.DanaCapabilities),
|
||||||
|
|
||||||
DanaRS("DanaRS", "SOOIL", "DanaRS", 0.05d, null, //
|
DanaRS("DanaRS", "SOOIL", "DanaRS", 0.05d, null, //
|
||||||
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
||||||
PumpTempBasalType.Percent, //
|
PumpTempBasalType.Percent, //
|
||||||
new DoseSettings(10d, 60, 24*60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(10d, 60, 24 * 60, 0d, 200d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.04d, 0.01d, null, PumpCapability.DanaWithHistoryCapabilities),
|
0.04d, 0.01d, null, PumpCapability.DanaWithHistoryCapabilities),
|
||||||
|
|
||||||
DanaRv2("DanaRv2", "DanaRv2", DanaRS),
|
DanaRv2("DanaRv2", "DanaRv2", DanaRS),
|
||||||
|
@ -91,40 +91,40 @@ public enum PumpType {
|
||||||
|
|
||||||
// Insulet
|
// Insulet
|
||||||
Insulet_Omnipod("Insulet Omnipod", "Insulet", "Omnipod", 0.05d, null, //
|
Insulet_Omnipod("Insulet Omnipod", "Insulet", "Omnipod", 0.05d, null, //
|
||||||
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
||||||
PumpTempBasalType.Absolute, //
|
PumpTempBasalType.Absolute, //
|
||||||
new DoseSettings(0.05d, 30, 12*60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, // cannot exceed max basal rate 30u/hr
|
new DoseSettings(0.05d, 30, 12 * 60, 0d, 30.0d), PumpCapability.BasalRate_Duration30minAllowed, // cannot exceed max basal rate 30u/hr
|
||||||
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities),
|
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities),
|
||||||
|
|
||||||
// Medtronic
|
// Medtronic
|
||||||
Medtronic_512_712("Medtronic 512/712", "Medtronic", "512/712", 0.05d, null, //
|
Medtronic_512_712("Medtronic 512/712", "Medtronic", "512/712", 0.05d, null, //
|
||||||
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
||||||
PumpTempBasalType.Absolute, //
|
PumpTempBasalType.Absolute, //
|
||||||
new DoseSettings(0.05d, 30, 24*60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
|
new DoseSettings(0.05d, 30, 24 * 60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||||
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities), // TODO
|
0.05d, 0.05d, null, PumpCapability.VirtualPumpCapabilities), // TODO
|
||||||
|
|
||||||
Medtronic_515_715("Medtronic 515/715", "515/715", Medtronic_512_712),
|
Medtronic_515_715("Medtronic 515/715", "515/715", Medtronic_512_712),
|
||||||
Medtronic_522_722("Medtronic 522/722", "522/722", Medtronic_512_712),
|
Medtronic_522_722("Medtronic 522/722", "522/722", Medtronic_512_712),
|
||||||
|
|
||||||
Medtronic_523_723_Revel("Medtronic 523/723 (Revel)", "Medtronic", "523/723 (Revel)", 0.05d, null, //
|
Medtronic_523_723_Revel("Medtronic 523/723 (Revel)", "Medtronic", "523/723 (Revel)", 0.05d, null, //
|
||||||
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
||||||
PumpTempBasalType.Absolute, //
|
PumpTempBasalType.Absolute, //
|
||||||
new DoseSettings(0.05d, 30, 24*60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
|
new DoseSettings(0.05d, 30, 24 * 60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||||
0.025d, 0.025d, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPumpCapabilities), //
|
0.025d, 0.025d, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPumpCapabilities), //
|
||||||
|
|
||||||
Medtronic_554_754_Veo("Medtronic 554/754 (Veo)", "554/754 (Veo)", Medtronic_523_723_Revel), // TODO
|
Medtronic_554_754_Veo("Medtronic 554/754 (Veo)", "554/754 (Veo)", Medtronic_523_723_Revel), // TODO
|
||||||
|
|
||||||
Medtronic_640G("Medtronic 640G", "Medtronic", "640G", 0.025d, null, //
|
Medtronic_640G("Medtronic 640G", "Medtronic", "640G", 0.025d, null, //
|
||||||
new DoseSettings(0.05d, 30, 8*60, 0.05d), //
|
new DoseSettings(0.05d, 30, 8 * 60, 0.05d), //
|
||||||
PumpTempBasalType.Absolute, //
|
PumpTempBasalType.Absolute, //
|
||||||
new DoseSettings(0.05d, 30, 24*60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
|
new DoseSettings(0.05d, 30, 24 * 60, 0d, 35d), PumpCapability.BasalRate_Duration30minAllowed, //
|
||||||
0.025d, 0.025d, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPumpCapabilities), //
|
0.025d, 0.025d, DoseStepSize.MedtronicVeoBasal, PumpCapability.VirtualPumpCapabilities), //
|
||||||
|
|
||||||
// Tandem
|
// Tandem
|
||||||
TandemTSlim("Tandem t:slim", "Tandem", "t:slim", 0.01d, null, //
|
TandemTSlim("Tandem t:slim", "Tandem", "t:slim", 0.01d, null, //
|
||||||
new DoseSettings(0.01d,15, 8*60, 0.4d),
|
new DoseSettings(0.01d, 15, 8 * 60, 0.4d),
|
||||||
PumpTempBasalType.Percent,
|
PumpTempBasalType.Percent,
|
||||||
new DoseSettings(1,15, 8*60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
new DoseSettings(1, 15, 8 * 60, 0d, 250d), PumpCapability.BasalRate_Duration15and30minAllowed, //
|
||||||
0.1d, 0.001d, null, PumpCapability.VirtualPumpCapabilities),
|
0.1d, 0.001d, null, PumpCapability.VirtualPumpCapabilities),
|
||||||
|
|
||||||
TandemTFlex("Tandem t:flex", "t:flex", TandemTSlim), //
|
TandemTFlex("Tandem t:flex", "t:flex", TandemTSlim), //
|
||||||
|
@ -148,10 +148,9 @@ public enum PumpType {
|
||||||
private PumpCapability pumpCapability;
|
private PumpCapability pumpCapability;
|
||||||
|
|
||||||
private PumpType parent;
|
private PumpType parent;
|
||||||
private static Map<String,PumpType> mapByDescription;
|
private static Map<String, PumpType> mapByDescription;
|
||||||
|
|
||||||
static
|
static {
|
||||||
{
|
|
||||||
mapByDescription = new HashMap<>();
|
mapByDescription = new HashMap<>();
|
||||||
|
|
||||||
for (PumpType pumpType : values()) {
|
for (PumpType pumpType : values()) {
|
||||||
|
@ -186,8 +185,7 @@ public enum PumpType {
|
||||||
PumpType(String description, String manufacter, String model, double bolusSize, DoseStepSize specialBolusSize, //
|
PumpType(String description, String manufacter, String model, double bolusSize, DoseStepSize specialBolusSize, //
|
||||||
DoseSettings extendedBolusSettings, //
|
DoseSettings extendedBolusSettings, //
|
||||||
PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, PumpCapability specialBasalDurations, //
|
PumpTempBasalType pumpTempBasalType, DoseSettings tbrSettings, PumpCapability specialBasalDurations, //
|
||||||
double baseBasalMinValue, Double baseBasalMaxValue, double baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability)
|
double baseBasalMinValue, Double baseBasalMaxValue, double baseBasalStep, DoseStepSize baseBasalSpecialSteps, PumpCapability pumpCapability) {
|
||||||
{
|
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.manufacter = manufacter;
|
this.manufacter = manufacter;
|
||||||
this.model = model;
|
this.model = model;
|
||||||
|
@ -275,20 +273,15 @@ public enum PumpType {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private boolean isParentSet()
|
private boolean isParentSet() {
|
||||||
{
|
return this.parent != null;
|
||||||
return this.parent!=null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static PumpType getByDescription(String desc)
|
public static PumpType getByDescription(String desc) {
|
||||||
{
|
if (mapByDescription.containsKey(desc)) {
|
||||||
if (mapByDescription.containsKey(desc))
|
|
||||||
{
|
|
||||||
return mapByDescription.get(desc);
|
return mapByDescription.get(desc);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return PumpType.GenericAAPS;
|
return PumpType.GenericAAPS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -296,7 +289,7 @@ public enum PumpType {
|
||||||
|
|
||||||
public String getFullDescription(String i18nTemplate, boolean hasExtendedBasals) {
|
public String getFullDescription(String i18nTemplate, boolean hasExtendedBasals) {
|
||||||
|
|
||||||
String unit = getPumpTempBasalType()==PumpTempBasalType.Percent ? "%" : "";
|
String unit = getPumpTempBasalType() == PumpTempBasalType.Percent ? "%" : "";
|
||||||
|
|
||||||
DoseSettings eb = getExtendedBolusSettings();
|
DoseSettings eb = getExtendedBolusSettings();
|
||||||
DoseSettings tbr = getTbrSettings();
|
DoseSettings tbr = getTbrSettings();
|
||||||
|
@ -305,24 +298,22 @@ public enum PumpType {
|
||||||
|
|
||||||
return String.format(i18nTemplate, //
|
return String.format(i18nTemplate, //
|
||||||
getStep("" + getBolusSize(), getSpecialBolusSize()), //
|
getStep("" + getBolusSize(), getSpecialBolusSize()), //
|
||||||
eb.getStep(), eb.getDurationStep(), eb.getMaxDuration()/60, //
|
eb.getStep(), eb.getDurationStep(), eb.getMaxDuration() / 60, //
|
||||||
getStep(getBaseBasalRange(), getBaseBasalSpecialSteps()), //
|
getStep(getBaseBasalRange(), getBaseBasalSpecialSteps()), //
|
||||||
tbr.getMinDose() + unit + "-" + tbr.getMaxDose() + unit, tbr.getStep() + unit,
|
tbr.getMinDose() + unit + "-" + tbr.getMaxDose() + unit, tbr.getStep() + unit,
|
||||||
tbr.getDurationStep(), tbr.getMaxDuration()/60, extendedNote);
|
tbr.getDurationStep(), tbr.getMaxDuration() / 60, extendedNote);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getBaseBasalRange()
|
private String getBaseBasalRange() {
|
||||||
{
|
|
||||||
Double maxValue = getBaseBasalMaxValue();
|
Double maxValue = getBaseBasalMaxValue();
|
||||||
|
|
||||||
return maxValue==null ? "" + getBaseBasalMinValue() : getBaseBasalMinValue() + "-" + maxValue;
|
return maxValue == null ? "" + getBaseBasalMinValue() : getBaseBasalMinValue() + "-" + maxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private String getStep(String step, DoseStepSize stepSize)
|
private String getStep(String step, DoseStepSize stepSize) {
|
||||||
{
|
if (stepSize != null)
|
||||||
if (stepSize!=null)
|
|
||||||
return step + " [" + stepSize.getDescription() + "] *";
|
return step + " [" + stepSize.getDescription() + "] *";
|
||||||
else
|
else
|
||||||
return "" + step;
|
return "" + step;
|
||||||
|
@ -330,18 +321,15 @@ public enum PumpType {
|
||||||
|
|
||||||
|
|
||||||
public boolean hasExtendedBasals() {
|
public boolean hasExtendedBasals() {
|
||||||
return ((getBaseBasalSpecialSteps() !=null) || (getSpecialBolusSize() != null));
|
return ((getBaseBasalSpecialSteps() != null) || (getSpecialBolusSize() != null));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public PumpCapability getSpecialBasalDurations() {
|
public PumpCapability getSpecialBasalDurations() {
|
||||||
|
|
||||||
if (isParentSet())
|
if (isParentSet()) {
|
||||||
{
|
|
||||||
return parent.getSpecialBasalDurations();
|
return parent.getSpecialBasalDurations();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
return specialBasalDurations == null ? //
|
return specialBasalDurations == null ? //
|
||||||
PumpCapability.BasalRate_Duration15and30minNotAllowed : specialBasalDurations;
|
PumpCapability.BasalRate_Duration15and30minNotAllowed : specialBasalDurations;
|
||||||
}
|
}
|
||||||
|
@ -352,20 +340,24 @@ public enum PumpType {
|
||||||
return bolusAmount;
|
return bolusAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
double bolusStepSize;
|
double bolusStepSize = getBolusSize();
|
||||||
|
|
||||||
if (getSpecialBolusSize() == null) {
|
if (getSpecialBolusSize() != null) {
|
||||||
bolusStepSize = getBolusSize();
|
|
||||||
} else {
|
|
||||||
DoseStepSize specialBolusSize = getSpecialBolusSize();
|
DoseStepSize specialBolusSize = getSpecialBolusSize();
|
||||||
|
bolusStepSize = specialBolusSize.getStepSizeForAmount(bolusAmount);
|
||||||
bolusStepSize = specialBolusSize.getStepSizeForAmount((double)bolusAmount);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Math.round(bolusAmount / bolusStepSize) * bolusStepSize;
|
return Round.roundTo(bolusAmount, bolusStepSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public double determineCorrectBolusStepSize(double bolusAmount) {
|
||||||
|
DoseStepSize specialBolusSize = getSpecialBolusSize();
|
||||||
|
if (specialBolusSize != null)
|
||||||
|
return specialBolusSize.getStepSizeForAmount(bolusAmount);
|
||||||
|
return getBolusSize();
|
||||||
|
}
|
||||||
|
|
||||||
public double determineCorrectExtendedBolusSize(double bolusAmount) {
|
public double determineCorrectExtendedBolusSize(double bolusAmount) {
|
||||||
if (bolusAmount == 0.0d) {
|
if (bolusAmount == 0.0d) {
|
||||||
return bolusAmount;
|
return bolusAmount;
|
||||||
|
@ -385,7 +377,7 @@ public enum PumpType {
|
||||||
bolusAmount = extendedBolusSettings.getMaxDose();
|
bolusAmount = extendedBolusSettings.getMaxDose();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Math.round(bolusAmount / bolusStepSize) * bolusStepSize;
|
return Round.roundTo(bolusAmount, bolusStepSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -407,7 +399,7 @@ public enum PumpType {
|
||||||
if (basalAmount > getTbrSettings().getMaxDose())
|
if (basalAmount > getTbrSettings().getMaxDose())
|
||||||
basalAmount = getTbrSettings().getMaxDose().doubleValue();
|
basalAmount = getTbrSettings().getMaxDose().doubleValue();
|
||||||
|
|
||||||
return Math.round(basalAmount / basalStepSize) * basalStepSize;
|
return Round.roundTo(basalAmount, basalStepSize);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class InsightAlertActivity extends AppCompatActivity {
|
||||||
alertService.setAlertActivity(InsightAlertActivity.this);
|
alertService.setAlertActivity(InsightAlertActivity.this);
|
||||||
alert = alertService.getAlert();
|
alert = alertService.getAlert();
|
||||||
if (alert == null) finish();
|
if (alert == null) finish();
|
||||||
update(alert);
|
else update(alert);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package info.nightscout.androidaps.plugins.source
|
package info.nightscout.androidaps.plugins.source
|
||||||
|
|
||||||
import android.Manifest
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.content.pm.PackageManager
|
import android.content.pm.PackageManager
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
|
@ -33,9 +32,9 @@ object SourceDexcomPlugin : PluginBase(PluginDescription()
|
||||||
private val log = LoggerFactory.getLogger(L.BGSOURCE)
|
private val log = LoggerFactory.getLogger(L.BGSOURCE)
|
||||||
|
|
||||||
private val PACKAGE_NAMES = arrayOf("com.dexcom.cgm.region1.mgdl", "com.dexcom.cgm.region1.mmol",
|
private val PACKAGE_NAMES = arrayOf("com.dexcom.cgm.region1.mgdl", "com.dexcom.cgm.region1.mmol",
|
||||||
"com.dexcom.cgm.region2.mgdl", "com.dexcom.cgm.region2.mmol",
|
"com.dexcom.cgm.region2.mgdl", "com.dexcom.cgm.region2.mmol",
|
||||||
"com.dexcom.g6.region1.mmol", "com.dexcom.g6.region2.mgdl",
|
"com.dexcom.g6.region1.mmol", "com.dexcom.g6.region2.mgdl",
|
||||||
"com.dexcom.g6.region3.mgdl", "com.dexcom.g6.region3.mmol")
|
"com.dexcom.g6.region3.mgdl", "com.dexcom.g6.region3.mmol")
|
||||||
|
|
||||||
const val PERMISSION = "com.dexcom.cgm.EXTERNAL_PERMISSION"
|
const val PERMISSION = "com.dexcom.cgm.EXTERNAL_PERMISSION"
|
||||||
|
|
||||||
|
@ -83,7 +82,7 @@ object SourceDexcomPlugin : PluginBase(PluginDescription()
|
||||||
val meters = intent.getBundleExtra("meters")
|
val meters = intent.getBundleExtra("meters")
|
||||||
for (i in 0 until meters.size()) {
|
for (i in 0 until meters.size()) {
|
||||||
val meter = meters.getBundle(i.toString())
|
val meter = meters.getBundle(i.toString())
|
||||||
val timestamp = meter.getLong("timestamp") * 1000
|
val timestamp = meter!!.getLong("timestamp") * 1000
|
||||||
if (MainApp.getDbHelper().getCareportalEventFromTimestamp(timestamp) != null) continue
|
if (MainApp.getDbHelper().getCareportalEventFromTimestamp(timestamp) != null) continue
|
||||||
val jsonObject = JSONObject()
|
val jsonObject = JSONObject()
|
||||||
jsonObject.put("enteredBy", "AndroidAPS-Dexcom")
|
jsonObject.put("enteredBy", "AndroidAPS-Dexcom")
|
||||||
|
@ -95,7 +94,7 @@ object SourceDexcomPlugin : PluginBase(PluginDescription()
|
||||||
NSUpload.uploadCareportalEntryToNS(jsonObject)
|
NSUpload.uploadCareportalEntryToNS(jsonObject)
|
||||||
}
|
}
|
||||||
if (SP.getBoolean(R.string.key_dexcom_lognssensorchange, false) && intent.hasExtra("sensorInsertionTime")) {
|
if (SP.getBoolean(R.string.key_dexcom_lognssensorchange, false) && intent.hasExtra("sensorInsertionTime")) {
|
||||||
val sensorInsertionTime = intent.extras.getLong("sensorInsertionTime") * 1000
|
val sensorInsertionTime = intent.extras!!.getLong("sensorInsertionTime") * 1000
|
||||||
if (MainApp.getDbHelper().getCareportalEventFromTimestamp(sensorInsertionTime) == null) {
|
if (MainApp.getDbHelper().getCareportalEventFromTimestamp(sensorInsertionTime) == null) {
|
||||||
val jsonObject = JSONObject()
|
val jsonObject = JSONObject()
|
||||||
jsonObject.put("enteredBy", "AndroidAPS-Dexcom")
|
jsonObject.put("enteredBy", "AndroidAPS-Dexcom")
|
||||||
|
@ -104,7 +103,7 @@ object SourceDexcomPlugin : PluginBase(PluginDescription()
|
||||||
NSUpload.uploadCareportalEntryToNS(jsonObject)
|
NSUpload.uploadCareportalEntryToNS(jsonObject)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e : Exception) {
|
} catch (e: Exception) {
|
||||||
log.error("Error while processing intent from Dexcom App", e)
|
log.error("Error while processing intent from Dexcom App", e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package info.nightscout.androidaps.services;
|
package info.nightscout.androidaps.services;
|
||||||
|
|
||||||
|
import android.app.Notification;
|
||||||
import android.app.Service;
|
import android.app.Service;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
@ -16,6 +17,7 @@ import java.io.IOException;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.logging.L;
|
import info.nightscout.androidaps.logging.L;
|
||||||
|
import info.nightscout.androidaps.plugins.general.persistentNotification.PersistentNotificationPlugin;
|
||||||
|
|
||||||
public class AlarmSoundService extends Service {
|
public class AlarmSoundService extends Service {
|
||||||
private static Logger log = LoggerFactory.getLogger(L.CORE);
|
private static Logger log = LoggerFactory.getLogger(L.CORE);
|
||||||
|
@ -28,8 +30,7 @@ public class AlarmSoundService extends Service {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IBinder onBind(Intent intent) {
|
public IBinder onBind(Intent intent) {
|
||||||
// TODO: Return the communication channel to the service.
|
return null;
|
||||||
throw new UnsupportedOperationException("Not yet implemented");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -40,6 +41,8 @@ public class AlarmSoundService extends Service {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
|
Notification notification = PersistentNotificationPlugin.getPlugin().getLastNotification();
|
||||||
|
startForeground(PersistentNotificationPlugin.ONGOING_NOTIFICATION_ID, notification);
|
||||||
if (player != null && player.isPlaying())
|
if (player != null && player.isPlaying())
|
||||||
player.stop();
|
player.stop();
|
||||||
if (L.isEnabled(L.CORE))
|
if (L.isEnabled(L.CORE))
|
||||||
|
|
|
@ -1,183 +0,0 @@
|
||||||
package info.nightscout.androidaps.utils;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
|
||||||
import info.nightscout.androidaps.data.Profile;
|
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
|
||||||
import info.nightscout.androidaps.logging.L;
|
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by mike on 11.10.2016.
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class BolusWizard {
|
|
||||||
private Logger log = LoggerFactory.getLogger(L.CORE);
|
|
||||||
// Inputs
|
|
||||||
private Profile specificProfile = null;
|
|
||||||
private TempTarget tempTarget;
|
|
||||||
public Integer carbs = 0;
|
|
||||||
private Double bg = 0d;
|
|
||||||
private Double cob = 0d;
|
|
||||||
private Double correction;
|
|
||||||
private Double percentageCorrection;
|
|
||||||
private Boolean includeBolusIOB = true;
|
|
||||||
private Boolean includeBasalIOB = true;
|
|
||||||
public Boolean superBolus = false;
|
|
||||||
private Boolean trend = false;
|
|
||||||
|
|
||||||
// Intermediate
|
|
||||||
public double sens = 0d;
|
|
||||||
public double ic = 0d;
|
|
||||||
|
|
||||||
public GlucoseStatus glucoseStatus;
|
|
||||||
|
|
||||||
public double targetBGLow = 0d;
|
|
||||||
public double targetBGHigh = 0d;
|
|
||||||
public double bgDiff = 0d;
|
|
||||||
|
|
||||||
public double insulinFromBG = 0d;
|
|
||||||
public double insulinFromCarbs = 0d;
|
|
||||||
public double insulingFromBolusIOB = 0d;
|
|
||||||
public double insulingFromBasalsIOB = 0d;
|
|
||||||
public double insulinFromCorrection = 0d;
|
|
||||||
public double insulinFromSuperBolus = 0d;
|
|
||||||
public double insulinFromCOB = 0d;
|
|
||||||
public double insulinFromTrend = 0d;
|
|
||||||
|
|
||||||
// Result
|
|
||||||
public Double calculatedTotalInsulin = 0d;
|
|
||||||
public Double totalBeforePercentageAdjustment = 0d;
|
|
||||||
public Double carbsEquivalent = 0d;
|
|
||||||
|
|
||||||
public Double doCalc(Profile specificProfile, TempTarget tempTarget, Integer carbs, Double cob, Double bg, Double correction, Boolean includeBolusIOB, Boolean includeBasalIOB, Boolean superBolus, Boolean trend) {
|
|
||||||
return doCalc(specificProfile, tempTarget, carbs, cob, bg, correction, 100d, includeBolusIOB, includeBasalIOB, superBolus, trend);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Double doCalc(Profile specificProfile, TempTarget tempTarget, Integer carbs, Double cob, Double bg, Double correction, double percentageCorrection, Boolean includeBolusIOB, Boolean includeBasalIOB, Boolean superBolus, Boolean trend) {
|
|
||||||
this.specificProfile = specificProfile;
|
|
||||||
this.tempTarget = tempTarget;
|
|
||||||
this.carbs = carbs;
|
|
||||||
this.bg = bg;
|
|
||||||
this.cob = cob;
|
|
||||||
this.correction = correction;
|
|
||||||
this.percentageCorrection = percentageCorrection;
|
|
||||||
this.includeBolusIOB = includeBolusIOB;
|
|
||||||
this.includeBasalIOB = includeBasalIOB;
|
|
||||||
this.superBolus = superBolus;
|
|
||||||
this.trend = trend;
|
|
||||||
|
|
||||||
// Insulin from BG
|
|
||||||
sens = specificProfile.getIsf();
|
|
||||||
targetBGLow = specificProfile.getTargetLow();
|
|
||||||
targetBGHigh = specificProfile.getTargetHigh();
|
|
||||||
if (tempTarget != null) {
|
|
||||||
targetBGLow = Profile.fromMgdlToUnits(tempTarget.low, specificProfile.getUnits());
|
|
||||||
targetBGHigh = Profile.fromMgdlToUnits(tempTarget.high, specificProfile.getUnits());
|
|
||||||
}
|
|
||||||
if (bg >= targetBGLow && bg <= targetBGHigh) {
|
|
||||||
bgDiff = 0d;
|
|
||||||
} else if (bg <= targetBGLow) {
|
|
||||||
bgDiff = bg - targetBGLow;
|
|
||||||
} else {
|
|
||||||
bgDiff = bg - targetBGHigh;
|
|
||||||
}
|
|
||||||
insulinFromBG = bg != 0d ? bgDiff / sens : 0d;
|
|
||||||
|
|
||||||
// Insulin from 15 min trend
|
|
||||||
glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
|
||||||
if (glucoseStatus != null && trend) {
|
|
||||||
insulinFromTrend = (Profile.fromMgdlToUnits(glucoseStatus.short_avgdelta, specificProfile.getUnits()) * 3) / sens;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insuling from carbs
|
|
||||||
ic = specificProfile.getIc();
|
|
||||||
insulinFromCarbs = carbs / ic;
|
|
||||||
insulinFromCOB = cob / ic;
|
|
||||||
|
|
||||||
// Insulin from IOB
|
|
||||||
// IOB calculation
|
|
||||||
TreatmentsInterface treatments = TreatmentsPlugin.getPlugin();
|
|
||||||
treatments.updateTotalIOBTreatments();
|
|
||||||
IobTotal bolusIob = treatments.getLastCalculationTreatments().round();
|
|
||||||
treatments.updateTotalIOBTempBasals();
|
|
||||||
IobTotal basalIob = treatments.getLastCalculationTempBasals().round();
|
|
||||||
|
|
||||||
insulingFromBolusIOB = includeBolusIOB ? -bolusIob.iob : 0d;
|
|
||||||
insulingFromBasalsIOB = includeBasalIOB ? -basalIob.basaliob : 0d;
|
|
||||||
|
|
||||||
// Insulin from correction
|
|
||||||
insulinFromCorrection = correction;
|
|
||||||
|
|
||||||
// Insulin from superbolus for 2h. Get basal rate now and after 1h
|
|
||||||
if (superBolus) {
|
|
||||||
insulinFromSuperBolus = specificProfile.getBasal();
|
|
||||||
long timeAfter1h = System.currentTimeMillis();
|
|
||||||
timeAfter1h += T.hours(1).msecs();
|
|
||||||
insulinFromSuperBolus += specificProfile.getBasal(timeAfter1h);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Total
|
|
||||||
calculatedTotalInsulin = insulinFromBG + insulinFromTrend + insulinFromCarbs + insulingFromBolusIOB + insulingFromBasalsIOB + insulinFromCorrection + insulinFromSuperBolus + insulinFromCOB;
|
|
||||||
|
|
||||||
// Percentage adjustment
|
|
||||||
totalBeforePercentageAdjustment = calculatedTotalInsulin;
|
|
||||||
if (calculatedTotalInsulin > 0) {
|
|
||||||
calculatedTotalInsulin = calculatedTotalInsulin * percentageCorrection / 100d;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (calculatedTotalInsulin < 0) {
|
|
||||||
carbsEquivalent = -calculatedTotalInsulin * ic;
|
|
||||||
calculatedTotalInsulin = 0d;
|
|
||||||
}
|
|
||||||
|
|
||||||
double bolusStep = ConfigBuilderPlugin.getPlugin().getActivePump().getPumpDescription().bolusStep;
|
|
||||||
calculatedTotalInsulin = Round.roundTo(calculatedTotalInsulin, bolusStep);
|
|
||||||
|
|
||||||
log.debug(log());
|
|
||||||
|
|
||||||
return calculatedTotalInsulin;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String log() {
|
|
||||||
StringBuilder sb = new StringBuilder();
|
|
||||||
|
|
||||||
sb.append("TempTarget=").append(tempTarget != null ? tempTarget.toString() : "null").append("; ");
|
|
||||||
sb.append("Carbs=").append(carbs != null ? carbs : null).append("; ");
|
|
||||||
sb.append("Bg=").append(bg).append("; ");
|
|
||||||
sb.append("Cob=").append(cob).append("; ");
|
|
||||||
sb.append("Correction=").append(correction).append("; ");
|
|
||||||
sb.append("PercentageCorrection=").append(percentageCorrection).append("; ");
|
|
||||||
sb.append("IncludeBolusIOB=").append(includeBolusIOB).append("; ");
|
|
||||||
sb.append("IncludeBasalIOB=").append(includeBasalIOB).append("; ");
|
|
||||||
sb.append("Superbolus=").append(superBolus).append("; ");
|
|
||||||
sb.append("Trend=").append(trend).append("; ");
|
|
||||||
sb.append("Profile=").append(specificProfile != null && specificProfile.getData() != null ? specificProfile.getData().toString() : "null").append("; ");
|
|
||||||
sb.append("\n");
|
|
||||||
|
|
||||||
sb.append("targetBGLow=").append(targetBGLow).append("; ");
|
|
||||||
sb.append("targetBGHigh=").append(targetBGHigh).append("; ");
|
|
||||||
sb.append("bgDiff=").append(bgDiff).append("; ");
|
|
||||||
sb.append("insulinFromBG=").append(insulinFromBG).append("; ");
|
|
||||||
sb.append("insulinFromCarbs=").append(insulinFromCarbs).append("; ");
|
|
||||||
sb.append("insulingFromBolusIOB=").append(insulingFromBolusIOB).append("; ");
|
|
||||||
sb.append("insulingFromBasalsIOB=").append(insulingFromBasalsIOB).append("; ");
|
|
||||||
sb.append("insulinFromCorrection=").append(insulinFromCorrection).append("; ");
|
|
||||||
sb.append("insulinFromSuperBolus=").append(insulinFromSuperBolus).append("; ");
|
|
||||||
sb.append("insulinFromCOB=").append(insulinFromCOB).append("; ");
|
|
||||||
sb.append("insulinFromTrend=").append(insulinFromTrend).append("; ");
|
|
||||||
sb.append("\n");
|
|
||||||
|
|
||||||
|
|
||||||
sb.append("calculatedTotalInsulin=").append(calculatedTotalInsulin).append("; ");
|
|
||||||
sb.append("totalBeforePercentageAdjustment=").append(totalBeforePercentageAdjustment).append("; ");
|
|
||||||
sb.append("carbsEquivalent=").append(carbsEquivalent).append("; ");
|
|
||||||
|
|
||||||
return sb.toString();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,344 @@
|
||||||
|
package info.nightscout.androidaps.utils
|
||||||
|
|
||||||
|
import android.content.Context
|
||||||
|
import android.content.Intent
|
||||||
|
import android.text.Html
|
||||||
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import info.nightscout.androidaps.MainApp
|
||||||
|
import info.nightscout.androidaps.R
|
||||||
|
import info.nightscout.androidaps.data.DetailedBolusInfo
|
||||||
|
import info.nightscout.androidaps.data.Profile
|
||||||
|
import info.nightscout.androidaps.db.CareportalEvent
|
||||||
|
import info.nightscout.androidaps.db.Source
|
||||||
|
import info.nightscout.androidaps.db.TempTarget
|
||||||
|
import info.nightscout.androidaps.events.EventRefreshOverview
|
||||||
|
import info.nightscout.androidaps.interfaces.Constraint
|
||||||
|
import info.nightscout.androidaps.interfaces.PluginType
|
||||||
|
import info.nightscout.androidaps.interfaces.PumpDescription
|
||||||
|
import info.nightscout.androidaps.interfaces.PumpInterface
|
||||||
|
import info.nightscout.androidaps.logging.L
|
||||||
|
import info.nightscout.androidaps.plugins.aps.loop.LoopPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
||||||
|
import info.nightscout.androidaps.plugins.general.overview.dialogs.ErrorHelperActivity
|
||||||
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus
|
||||||
|
import info.nightscout.androidaps.plugins.treatments.TreatmentsPlugin
|
||||||
|
import info.nightscout.androidaps.queue.Callback
|
||||||
|
import org.json.JSONException
|
||||||
|
import org.json.JSONObject
|
||||||
|
import org.slf4j.LoggerFactory
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
class BolusWizard @JvmOverloads constructor(val profile: Profile,
|
||||||
|
val profileName: String,
|
||||||
|
val tempTarget: TempTarget?,
|
||||||
|
val carbs: Int,
|
||||||
|
val cob: Double,
|
||||||
|
val bg: Double,
|
||||||
|
val correction: Double,
|
||||||
|
private val percentageCorrection: Double = 100.0,
|
||||||
|
private val useBg: Boolean,
|
||||||
|
private val useCob: Boolean,
|
||||||
|
private val includeBolusIOB: Boolean,
|
||||||
|
private val includeBasalIOB: Boolean,
|
||||||
|
private val useSuperBolus: Boolean,
|
||||||
|
private val useTT: Boolean,
|
||||||
|
private val useTrend: Boolean,
|
||||||
|
val notes: String = "",
|
||||||
|
private val carbTime: Int = 0
|
||||||
|
) {
|
||||||
|
|
||||||
|
private val log = LoggerFactory.getLogger(L.CORE)
|
||||||
|
|
||||||
|
// Intermediate
|
||||||
|
var sens = 0.0
|
||||||
|
private set
|
||||||
|
|
||||||
|
var ic = 0.0
|
||||||
|
private set
|
||||||
|
|
||||||
|
var glucoseStatus: GlucoseStatus? = null
|
||||||
|
private set
|
||||||
|
|
||||||
|
var targetBGLow = 0.0
|
||||||
|
private set
|
||||||
|
|
||||||
|
var targetBGHigh = 0.0
|
||||||
|
private set
|
||||||
|
|
||||||
|
var bgDiff = 0.0
|
||||||
|
private set
|
||||||
|
|
||||||
|
var insulinFromBG = 0.0
|
||||||
|
private set
|
||||||
|
|
||||||
|
var insulinFromCarbs = 0.0
|
||||||
|
private set
|
||||||
|
|
||||||
|
var insulinFromBolusIOB = 0.0
|
||||||
|
private set
|
||||||
|
|
||||||
|
var insulinFromBasalsIOB = 0.0
|
||||||
|
private set
|
||||||
|
|
||||||
|
var insulinFromCorrection = 0.0
|
||||||
|
private set
|
||||||
|
|
||||||
|
var insulinFromSuperBolus = 0.0
|
||||||
|
private set
|
||||||
|
|
||||||
|
var insulinFromCOB = 0.0
|
||||||
|
private set
|
||||||
|
|
||||||
|
var insulinFromTrend = 0.0
|
||||||
|
private set
|
||||||
|
|
||||||
|
var trend = 0.0
|
||||||
|
private set
|
||||||
|
|
||||||
|
var accepted = false
|
||||||
|
private set
|
||||||
|
|
||||||
|
// Result
|
||||||
|
var calculatedTotalInsulin: Double = 0.0
|
||||||
|
private set
|
||||||
|
|
||||||
|
var totalBeforePercentageAdjustment: Double = 0.0
|
||||||
|
private set
|
||||||
|
|
||||||
|
var carbsEquivalent: Double = 0.0
|
||||||
|
private set
|
||||||
|
|
||||||
|
var insulinAfterConstraints: Double = 0.0
|
||||||
|
private set
|
||||||
|
|
||||||
|
init {
|
||||||
|
doCalc()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun doCalc() {
|
||||||
|
|
||||||
|
// Insulin from BG
|
||||||
|
sens = profile.isf
|
||||||
|
targetBGLow = profile.targetLow
|
||||||
|
targetBGHigh = profile.targetHigh
|
||||||
|
if (useTT && tempTarget != null) {
|
||||||
|
targetBGLow = Profile.fromMgdlToUnits(tempTarget.low, profile.units)
|
||||||
|
targetBGHigh = Profile.fromMgdlToUnits(tempTarget.high, profile.units)
|
||||||
|
}
|
||||||
|
if (useBg && bg > 0) {
|
||||||
|
if (bg >= targetBGLow && bg <= targetBGHigh) {
|
||||||
|
bgDiff = 0.0
|
||||||
|
} else if (bg <= targetBGLow) {
|
||||||
|
bgDiff = bg - targetBGLow
|
||||||
|
} else {
|
||||||
|
bgDiff = bg - targetBGHigh
|
||||||
|
}
|
||||||
|
insulinFromBG = bgDiff / sens
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insulin from 15 min trend
|
||||||
|
glucoseStatus = GlucoseStatus.getGlucoseStatusData()
|
||||||
|
glucoseStatus?.let {
|
||||||
|
if (useTrend) {
|
||||||
|
trend = it.short_avgdelta
|
||||||
|
insulinFromTrend = Profile.fromMgdlToUnits(trend, profile.units) * 3 / sens
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Insuling from carbs
|
||||||
|
ic = profile.ic
|
||||||
|
insulinFromCarbs = carbs / ic
|
||||||
|
insulinFromCOB = if (useCob) (cob / ic) else 0.0
|
||||||
|
|
||||||
|
// Insulin from IOB
|
||||||
|
// IOB calculation
|
||||||
|
val treatments = TreatmentsPlugin.getPlugin()
|
||||||
|
treatments.updateTotalIOBTreatments()
|
||||||
|
val bolusIob = treatments.lastCalculationTreatments.round()
|
||||||
|
treatments.updateTotalIOBTempBasals()
|
||||||
|
val basalIob = treatments.lastCalculationTempBasals.round()
|
||||||
|
|
||||||
|
insulinFromBolusIOB = if (includeBolusIOB) -bolusIob.iob else 0.0
|
||||||
|
insulinFromBasalsIOB = if (includeBasalIOB) -basalIob.basaliob else 0.0
|
||||||
|
|
||||||
|
// Insulin from correction
|
||||||
|
insulinFromCorrection = correction
|
||||||
|
|
||||||
|
// Insulin from superbolus for 2h. Get basal rate now and after 1h
|
||||||
|
if (useSuperBolus) {
|
||||||
|
insulinFromSuperBolus = profile.basal
|
||||||
|
var timeAfter1h = System.currentTimeMillis()
|
||||||
|
timeAfter1h += T.hours(1).msecs()
|
||||||
|
insulinFromSuperBolus += profile.getBasal(timeAfter1h)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Total
|
||||||
|
calculatedTotalInsulin = insulinFromBG + insulinFromTrend + insulinFromCarbs + insulinFromBolusIOB + insulinFromBasalsIOB + insulinFromCorrection + insulinFromSuperBolus + insulinFromCOB
|
||||||
|
|
||||||
|
// Percentage adjustment
|
||||||
|
totalBeforePercentageAdjustment = calculatedTotalInsulin
|
||||||
|
if (calculatedTotalInsulin > 0) {
|
||||||
|
calculatedTotalInsulin = calculatedTotalInsulin * percentageCorrection / 100.0
|
||||||
|
}
|
||||||
|
|
||||||
|
if (calculatedTotalInsulin < 0) {
|
||||||
|
carbsEquivalent = (-calculatedTotalInsulin) * ic
|
||||||
|
calculatedTotalInsulin = 0.0
|
||||||
|
}
|
||||||
|
|
||||||
|
val bolusStep = ConfigBuilderPlugin.getPlugin().activePump?.pumpDescription!!.bolusStep
|
||||||
|
calculatedTotalInsulin = Round.roundTo(calculatedTotalInsulin, bolusStep)
|
||||||
|
|
||||||
|
insulinAfterConstraints = MainApp.getConstraintChecker().applyBolusConstraints(Constraint(calculatedTotalInsulin)).value()
|
||||||
|
|
||||||
|
log.debug(this.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
fun nsJSON(): JSONObject {
|
||||||
|
val boluscalcJSON = JSONObject()
|
||||||
|
try {
|
||||||
|
boluscalcJSON.put("profile", profileName)
|
||||||
|
boluscalcJSON.put("notes", notes)
|
||||||
|
boluscalcJSON.put("eventTime", DateUtil.toISOString(Date()))
|
||||||
|
boluscalcJSON.put("targetBGLow", targetBGLow)
|
||||||
|
boluscalcJSON.put("targetBGHigh", targetBGHigh)
|
||||||
|
boluscalcJSON.put("isf", sens)
|
||||||
|
boluscalcJSON.put("ic", ic)
|
||||||
|
boluscalcJSON.put("iob", -(insulinFromBolusIOB + insulinFromBasalsIOB))
|
||||||
|
boluscalcJSON.put("bolusiob", insulinFromBolusIOB)
|
||||||
|
boluscalcJSON.put("basaliob", insulinFromBasalsIOB)
|
||||||
|
boluscalcJSON.put("bolusiobused", includeBolusIOB)
|
||||||
|
boluscalcJSON.put("basaliobused", includeBasalIOB)
|
||||||
|
boluscalcJSON.put("bg", bg)
|
||||||
|
boluscalcJSON.put("insulinbg", insulinFromBG)
|
||||||
|
boluscalcJSON.put("insulinbgused", useBg)
|
||||||
|
boluscalcJSON.put("bgdiff", bgDiff)
|
||||||
|
boluscalcJSON.put("insulincarbs", insulinFromCarbs)
|
||||||
|
boluscalcJSON.put("carbs", carbs)
|
||||||
|
boluscalcJSON.put("cob", cob)
|
||||||
|
boluscalcJSON.put("cobused", useCob)
|
||||||
|
boluscalcJSON.put("insulincob", insulinFromCOB)
|
||||||
|
boluscalcJSON.put("othercorrection", correction)
|
||||||
|
boluscalcJSON.put("insulinsuperbolus", insulinFromSuperBolus)
|
||||||
|
boluscalcJSON.put("insulintrend", insulinFromTrend)
|
||||||
|
boluscalcJSON.put("insulin", calculatedTotalInsulin)
|
||||||
|
boluscalcJSON.put("superbolusused", useSuperBolus)
|
||||||
|
boluscalcJSON.put("insulinsuperbolus", insulinFromSuperBolus)
|
||||||
|
boluscalcJSON.put("trendused", useTrend)
|
||||||
|
boluscalcJSON.put("insulintrend", insulinFromTrend)
|
||||||
|
boluscalcJSON.put("trend", trend)
|
||||||
|
boluscalcJSON.put("ttused", useTT)
|
||||||
|
} catch (e: JSONException) {
|
||||||
|
log.error("Unhandled exception", e)
|
||||||
|
}
|
||||||
|
return boluscalcJSON
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun confirmMessageAfterConstraints(pump: PumpInterface): String {
|
||||||
|
|
||||||
|
var confirmMessage = MainApp.gs(R.string.entertreatmentquestion)
|
||||||
|
if (insulinAfterConstraints > 0)
|
||||||
|
confirmMessage += "<br/>" + MainApp.gs(R.string.bolus) + ": " + "<font color='" + MainApp.gc(R.color.bolus) + "'>" + DecimalFormatter.toPumpSupportedBolus(insulinAfterConstraints) + "U" + "</font>"
|
||||||
|
if (carbs > 0)
|
||||||
|
confirmMessage += "<br/>" + MainApp.gs(R.string.carbs) + ": " + "<font color='" + MainApp.gc(R.color.carbs) + "'>" + carbs + "g" + "</font>"
|
||||||
|
|
||||||
|
if (Math.abs(insulinAfterConstraints - calculatedTotalInsulin) > pump.getPumpDescription().pumpType.determineCorrectBolusStepSize(insulinAfterConstraints)) {
|
||||||
|
confirmMessage += "<br/><font color='" + MainApp.gc(R.color.warning) + "'>" + MainApp.gs(R.string.bolusconstraintapplied) + "</font>"
|
||||||
|
}
|
||||||
|
|
||||||
|
return confirmMessage
|
||||||
|
}
|
||||||
|
|
||||||
|
fun confirmAndExecute(context: Context) {
|
||||||
|
val profile = ProfileFunctions.getInstance().profile
|
||||||
|
val pump = ConfigBuilderPlugin.getPlugin().activePump
|
||||||
|
|
||||||
|
if (pump != null && profile != null && (calculatedTotalInsulin > 0.0 || carbs > 0.0)) {
|
||||||
|
val confirmMessage = confirmMessageAfterConstraints(pump)
|
||||||
|
|
||||||
|
val builder = AlertDialog.Builder(context)
|
||||||
|
builder.setTitle(MainApp.gs(R.string.confirmation))
|
||||||
|
builder.setMessage(Html.fromHtml(confirmMessage))
|
||||||
|
builder.setPositiveButton(MainApp.gs(R.string.ok)) { _, _ ->
|
||||||
|
synchronized(builder) {
|
||||||
|
if (accepted) {
|
||||||
|
log.debug("guarding: already accepted")
|
||||||
|
return@setPositiveButton
|
||||||
|
}
|
||||||
|
accepted = true
|
||||||
|
if (insulinAfterConstraints > 0 || carbs > 0) {
|
||||||
|
if (useSuperBolus) {
|
||||||
|
val loopPlugin = LoopPlugin.getPlugin()
|
||||||
|
if (loopPlugin.isEnabled(PluginType.LOOP)) {
|
||||||
|
loopPlugin.superBolusTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000)
|
||||||
|
MainApp.bus().post(EventRefreshOverview("WizardDialog"))
|
||||||
|
}
|
||||||
|
|
||||||
|
val pump1 = ConfigBuilderPlugin.getPlugin().activePump
|
||||||
|
|
||||||
|
if (pump1?.pumpDescription?.tempBasalStyle == PumpDescription.ABSOLUTE) {
|
||||||
|
ConfigBuilderPlugin.getPlugin().commandQueue.tempBasalAbsolute(0.0, 120, true, profile, object : Callback() {
|
||||||
|
override fun run() {
|
||||||
|
if (!result.success) {
|
||||||
|
val i = Intent(MainApp.instance(), ErrorHelperActivity::class.java)
|
||||||
|
i.putExtra("soundid", R.raw.boluserror)
|
||||||
|
i.putExtra("status", result.comment)
|
||||||
|
i.putExtra("title", MainApp.gs(R.string.tempbasaldeliveryerror))
|
||||||
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
MainApp.instance().startActivity(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
|
||||||
|
ConfigBuilderPlugin.getPlugin().commandQueue.tempBasalPercent(0, 120, true, profile, object : Callback() {
|
||||||
|
override fun run() {
|
||||||
|
if (!result.success) {
|
||||||
|
val i = Intent(MainApp.instance(), ErrorHelperActivity::class.java)
|
||||||
|
i.putExtra("soundid", R.raw.boluserror)
|
||||||
|
i.putExtra("status", result.comment)
|
||||||
|
i.putExtra("title", MainApp.gs(R.string.tempbasaldeliveryerror))
|
||||||
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
MainApp.instance().startActivity(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
val detailedBolusInfo = DetailedBolusInfo()
|
||||||
|
detailedBolusInfo.eventType = CareportalEvent.BOLUSWIZARD
|
||||||
|
detailedBolusInfo.insulin = insulinAfterConstraints
|
||||||
|
detailedBolusInfo.carbs = carbs.toDouble()
|
||||||
|
detailedBolusInfo.context = context
|
||||||
|
detailedBolusInfo.glucose = bg
|
||||||
|
detailedBolusInfo.glucoseType = "Manual"
|
||||||
|
detailedBolusInfo.carbTime = carbTime
|
||||||
|
detailedBolusInfo.boluscalc = nsJSON()
|
||||||
|
detailedBolusInfo.source = Source.USER
|
||||||
|
detailedBolusInfo.notes = notes
|
||||||
|
if (detailedBolusInfo.insulin > 0 || ConfigBuilderPlugin.getPlugin().activePump?.pumpDescription!!.storesCarbInfo) {
|
||||||
|
ConfigBuilderPlugin.getPlugin().commandQueue.bolus(detailedBolusInfo, object : Callback() {
|
||||||
|
override fun run() {
|
||||||
|
if (!result.success) {
|
||||||
|
val i = Intent(MainApp.instance(), ErrorHelperActivity::class.java)
|
||||||
|
i.putExtra("soundid", R.raw.boluserror)
|
||||||
|
i.putExtra("status", result.comment)
|
||||||
|
i.putExtra("title", MainApp.gs(R.string.treatmentdeliveryerror))
|
||||||
|
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||||
|
MainApp.instance().startActivity(i)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
TreatmentsPlugin.getPlugin().addToHistoryTreatment(detailedBolusInfo, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
builder.setNegativeButton(MainApp.gs(R.string.cancel), null)
|
||||||
|
builder.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,8 @@
|
||||||
package info.nightscout.androidaps.utils;
|
package info.nightscout.androidaps.utils;
|
||||||
|
|
||||||
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.R;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* class contains useful String functions
|
* class contains useful String functions
|
||||||
*/
|
*/
|
||||||
|
@ -22,4 +25,7 @@ public class StringUtils {
|
||||||
return str == null || str.length() == 0;
|
return str == null || str.length() == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String formatInsulin(double insulin) {
|
||||||
|
return String.format(MainApp.gs(R.string.formatinsulinunits), insulin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,6 +147,8 @@
|
||||||
<string name="constraints_violation">Beperkings skending</string>
|
<string name="constraints_violation">Beperkings skending</string>
|
||||||
<string name="treatmentdeliveryerror">Bolus aflewering fout</string>
|
<string name="treatmentdeliveryerror">Bolus aflewering fout</string>
|
||||||
<string name="tempbasaldeliveryerror">Tempbasal aflewering fout</string>
|
<string name="tempbasaldeliveryerror">Tempbasal aflewering fout</string>
|
||||||
|
<string name="overview_newtempbasal_basalpercent">Basale waarde [%%]</string>
|
||||||
|
<string name="overview_newtempbasal_percent_label">%% (100%% = huidig)</string>
|
||||||
<string name="setbasalquestion">Aanvaar nuwe tydelike basale:</string>
|
<string name="setbasalquestion">Aanvaar nuwe tydelike basale:</string>
|
||||||
<string name="overview_treatment_label">Behandeling</string>
|
<string name="overview_treatment_label">Behandeling</string>
|
||||||
<string name="overview_calculator_label">Rekenaar</string>
|
<string name="overview_calculator_label">Rekenaar</string>
|
||||||
|
@ -246,6 +248,7 @@
|
||||||
<string name="danar_iob_label">Pomp IAB</string>
|
<string name="danar_iob_label">Pomp IAB</string>
|
||||||
<string name="danar_dailyunits">Daaglikse eenhede</string>
|
<string name="danar_dailyunits">Daaglikse eenhede</string>
|
||||||
<string name="pump_lastbolus_label">Laaste bolus</string>
|
<string name="pump_lastbolus_label">Laaste bolus</string>
|
||||||
|
<string name="hoursago">%1$.1fh terug</string>
|
||||||
<string name="danar_invalidinput">Ongeldige invoer</string>
|
<string name="danar_invalidinput">Ongeldige invoer</string>
|
||||||
<string name="danar_valuenotsetproperly">Waarde nie behoorlik gestel</string>
|
<string name="danar_valuenotsetproperly">Waarde nie behoorlik gestel</string>
|
||||||
<string name="reloadprofile">Herlaai profiel</string>
|
<string name="reloadprofile">Herlaai profiel</string>
|
||||||
|
@ -525,6 +528,7 @@
|
||||||
<string name="resistantadult">Insulien weerstandige volwasse</string>
|
<string name="resistantadult">Insulien weerstandige volwasse</string>
|
||||||
<string name="patientage_summary">Kies asseblief pasiënt ouderdom om veiligheids limiete te stel</string>
|
<string name="patientage_summary">Kies asseblief pasiënt ouderdom om veiligheids limiete te stel</string>
|
||||||
<string name="Glimp">Glimp</string>
|
<string name="Glimp">Glimp</string>
|
||||||
|
<string name="needwhitelisting">%1$s benodig battery optimisering bemagtiging vir beter werksverrigting</string>
|
||||||
<string name="loopsuspended">Lus opgeskort</string>
|
<string name="loopsuspended">Lus opgeskort</string>
|
||||||
<string name="loopsuspendedfor">Opgeskort (%1$d m)</string>
|
<string name="loopsuspendedfor">Opgeskort (%1$d m)</string>
|
||||||
<string name="loopsuperbolusfor">Superbolus (%1$d m)</string>
|
<string name="loopsuperbolusfor">Superbolus (%1$d m)</string>
|
||||||
|
@ -560,6 +564,8 @@
|
||||||
<string name="show_statuslights_summary">Wys status vlae vir cage, iage, sage, stoor en battery vlak op tuisskerm.</string>
|
<string name="show_statuslights_summary">Wys status vlae vir cage, iage, sage, stoor en battery vlak op tuisskerm.</string>
|
||||||
<string name="statuslights_res_warning">Drempel waarskuwings stoor vlak [U]</string>
|
<string name="statuslights_res_warning">Drempel waarskuwings stoor vlak [U]</string>
|
||||||
<string name="statuslights_res_critical">Drempel kritieke stoor vlak [U]</string>
|
<string name="statuslights_res_critical">Drempel kritieke stoor vlak [U]</string>
|
||||||
|
<string name="statuslights_bat_warning">Drempel waarskuwing battery vlak [%%]</string>
|
||||||
|
<string name="statuslights_bat_critical">Drempel kritieke battery vlak [%%]</string>
|
||||||
<string name="iob">IAB</string>
|
<string name="iob">IAB</string>
|
||||||
<string name="cob">KOB</string>
|
<string name="cob">KOB</string>
|
||||||
<string name="virtualpump_firmware_label">Firmware</string>
|
<string name="virtualpump_firmware_label">Firmware</string>
|
||||||
|
@ -758,6 +764,7 @@
|
||||||
<string name="combo_pump_state_running">Loop tans</string>
|
<string name="combo_pump_state_running">Loop tans</string>
|
||||||
<string name="combo_pump_action_cancelling_tbr">Kanselleer TBR</string>
|
<string name="combo_pump_action_cancelling_tbr">Kanselleer TBR</string>
|
||||||
<string name="combo_pump_action_setting_tbr">Stel TBR (%1$d%% / %2$d min)</string>
|
<string name="combo_pump_action_setting_tbr">Stel TBR (%1$d%% / %2$d min)</string>
|
||||||
|
<string name="combo_pump_action_bolusing">Bolusing (%1$.1f U)</string>
|
||||||
<string name="combo_pump_action_refreshing">Verfris</string>
|
<string name="combo_pump_action_refreshing">Verfris</string>
|
||||||
<string name="combo_pump_unsupported_operation">Versoekte bewerking nie ondersteun deur pomp</string>
|
<string name="combo_pump_unsupported_operation">Versoekte bewerking nie ondersteun deur pomp</string>
|
||||||
<string name="combo_low_suspend_forced_notification">Onveilige gebruik: uitgebreide of multigolf boluses is aktief. Lus modus is gestel om laag te opskort net 6 ure. Net gewone boluses is ondersteun in lus modus</string>
|
<string name="combo_low_suspend_forced_notification">Onveilige gebruik: uitgebreide of multigolf boluses is aktief. Lus modus is gestel om laag te opskort net 6 ure. Net gewone boluses is ondersteun in lus modus</string>
|
||||||
|
@ -1149,6 +1156,12 @@
|
||||||
<string name="sms_wrongcode">Verkeerde kode. Opdrag gekanselleer.</string>
|
<string name="sms_wrongcode">Verkeerde kode. Opdrag gekanselleer.</string>
|
||||||
<string name="notconfigured">Nie gekonfigureer nie</string>
|
<string name="notconfigured">Nie gekonfigureer nie</string>
|
||||||
<string name="profileswitchcreated">Profiel skakelaar geskep</string>
|
<string name="profileswitchcreated">Profiel skakelaar geskep</string>
|
||||||
|
<string name="versionChecker">Weergawe Navolger</string>
|
||||||
|
<string name="old_version">ou weergawe</string>
|
||||||
|
<string name="very_old_version">baie ou weergawe</string>
|
||||||
|
<string name="new_version_warning">Nuwe weergawe reeds beskikbaar vir %1$d! Sal na 60 dae terugval na LGS, lus sal ongeldig gemaak word na 90 dae</string>
|
||||||
|
<string name="twohours">2h</string>
|
||||||
|
<string name="formatinsulinunits">%1$.2fU</string>
|
||||||
<plurals name="objective_days">
|
<plurals name="objective_days">
|
||||||
<item quantity="one">%1$d dae</item>
|
<item quantity="one">%1$d dae</item>
|
||||||
<item quantity="other">%1$d dae</item>
|
<item quantity="other">%1$d dae</item>
|
||||||
|
|
|
@ -1160,6 +1160,8 @@
|
||||||
<string name="old_version">стара версия</string>
|
<string name="old_version">стара версия</string>
|
||||||
<string name="very_old_version">много стара версия</string>
|
<string name="very_old_version">много стара версия</string>
|
||||||
<string name="new_version_warning">Има нова версия от най-малко %1$d дни! Връщане към LGS след 60 дни, цикълът ще бъде изключен след 90 дни</string>
|
<string name="new_version_warning">Има нова версия от най-малко %1$d дни! Връщане към LGS след 60 дни, цикълът ще бъде изключен след 90 дни</string>
|
||||||
|
<string name="twohours">2ч</string>
|
||||||
|
<string name="formatinsulinunits">%1$.2fЕ</string>
|
||||||
<plurals name="objective_days">
|
<plurals name="objective_days">
|
||||||
<item quantity="one">%1$d дeн</item>
|
<item quantity="one">%1$d дeн</item>
|
||||||
<item quantity="other">%1$d дни</item>
|
<item quantity="other">%1$d дни</item>
|
||||||
|
|
|
@ -329,8 +329,8 @@
|
||||||
<string name="objectives_5_gate">Loope eine Woche erfolgreich am Tag mit regelmäßiger Kohlenhydrat-Eingabe.</string>
|
<string name="objectives_5_gate">Loope eine Woche erfolgreich am Tag mit regelmäßiger Kohlenhydrat-Eingabe.</string>
|
||||||
<string name="objectives_6_objective">Aktiviere zusätzliche Funktionen wie z. B. den Mahlzeitenassistenten</string>
|
<string name="objectives_6_objective">Aktiviere zusätzliche Funktionen wie z. B. den Mahlzeitenassistenten</string>
|
||||||
<string name="objectives_7_objective">Aktiviere zusätzliche Funktionen wie z. B. SMB</string>
|
<string name="objectives_7_objective">Aktiviere zusätzliche Funktionen wie z. B. SMB</string>
|
||||||
<string name="objectives_7_gate">"Lies das Wiki und hebe maxIOB an, damit SMB funktioniert. Ein guter Startwert ist
|
<string name="objectives_7_gate">Lies das Wiki und hebe maxIOB an, damit SMB funktioniert. Ein guter Startwert ist
|
||||||
maxIOB = durchschnittlicher Essensbolus + 3 x maximale Basalrate"</string>
|
maxIOB = durchschnittlicher Essensbolus + 3 x maximale Basalrate</string>
|
||||||
<string name="youareonallowedlimit">Limit erreicht</string>
|
<string name="youareonallowedlimit">Limit erreicht</string>
|
||||||
<string name="noprofileselected">Kein Profil ausgewählt</string>
|
<string name="noprofileselected">Kein Profil ausgewählt</string>
|
||||||
<string name="smscommunicator_loophasbeendisabled">Loop wurde deaktiviert.</string>
|
<string name="smscommunicator_loophasbeendisabled">Loop wurde deaktiviert.</string>
|
||||||
|
@ -1066,8 +1066,8 @@ maxIOB = durchschnittlicher Essensbolus + 3 x maximale Basalrate"</string>
|
||||||
<string name="treatments_wizard_total_label">Gesamt</string>
|
<string name="treatments_wizard_total_label">Gesamt</string>
|
||||||
<string name="calculation_short">Berech.</string>
|
<string name="calculation_short">Berech.</string>
|
||||||
<string name="handshaking">Handshaking</string>
|
<string name="handshaking">Handshaking</string>
|
||||||
<string name="sendlogfiles">"Sende die heutigen Logdateien unter Angabe dieser Uhrzeit an die Entwickler.
|
<string name="sendlogfiles">Sende die heutigen Logdateien unter Angabe dieser Uhrzeit an die Entwickler.
|
||||||
Unerwartetes Verhalten."</string>
|
Unerwartetes Verhalten.</string>
|
||||||
<string name="maxbolusviolation">Max. Bolus überschritten</string>
|
<string name="maxbolusviolation">Max. Bolus überschritten</string>
|
||||||
<string name="commanderror">Fehler bei Befehl</string>
|
<string name="commanderror">Fehler bei Befehl</string>
|
||||||
<string name="speederror">Geschwindigkeits-Fehler</string>
|
<string name="speederror">Geschwindigkeits-Fehler</string>
|
||||||
|
@ -1162,6 +1162,8 @@ Unerwartetes Verhalten."</string>
|
||||||
<string name="old_version">Vorherige Version</string>
|
<string name="old_version">Vorherige Version</string>
|
||||||
<string name="very_old_version">sehr alte Version</string>
|
<string name="very_old_version">sehr alte Version</string>
|
||||||
<string name="new_version_warning">Neue Version für mindestens %1$d Tage verfügbar! Rückfall zur sensorunterstützten Pumpentherapie nach 60 Tagen, Loop wird nach 90 Tagen deaktiviert</string>
|
<string name="new_version_warning">Neue Version für mindestens %1$d Tage verfügbar! Rückfall zur sensorunterstützten Pumpentherapie nach 60 Tagen, Loop wird nach 90 Tagen deaktiviert</string>
|
||||||
|
<string name="twohours">2h</string>
|
||||||
|
<string name="formatinsulinunits">%1$.2f IE</string>
|
||||||
<plurals name="objective_days">
|
<plurals name="objective_days">
|
||||||
<item quantity="one">%1$d Tag</item>
|
<item quantity="one">%1$d Tag</item>
|
||||||
<item quantity="other">%1$d Tage</item>
|
<item quantity="other">%1$d Tage</item>
|
||||||
|
|
|
@ -239,8 +239,8 @@
|
||||||
<string name="disconnected">Déconnectée</string>
|
<string name="disconnected">Déconnectée</string>
|
||||||
<string name="danar_pump_settings">Paramètres pompe DanaR</string>
|
<string name="danar_pump_settings">Paramètres pompe DanaR</string>
|
||||||
<string name="end_user_license_agreement">Contrat de Licence pour Utilisateur Final</string>
|
<string name="end_user_license_agreement">Contrat de Licence pour Utilisateur Final</string>
|
||||||
<string name="end_user_license_agreement_text">"NE DOIT PAS ÊTRE UTILISÉ POUR PRENDRE DES DÉCISIONS MÉDICALES. IL N'Y A AUCUNE GARANTIE POUR LE PROGRAMME, DANS LA LIMITE PERMISE PAR LA LOI APPLICABLE. SAUF S'IL EST INDIQUÉ LE CONTRAIRE PAR ÉCRIT. LES TITULAIRES DU DROIT D'AUTEUR ET / OU D'AUTRES PARTIES FOURNISSENT LE PROGRAMME «EN L'ÉTAT» SANS GARANTIE D'AUCUNE SORTE, EXPLICITE OU IMPLICITE, Y COMPRIS MAIS NON SEULEMENT AUX GARANTIES IMPLICITES DE QUALITÉ MARCHANDE ET D'ADÉQUATION À UN USAGE PARTICULIER
|
<string name="end_user_license_agreement_text">NE DOIT PAS ÊTRE UTILISÉ POUR PRENDRE DES DÉCISIONS MÉDICALES. IL N\'Y A AUCUNE GARANTIE POUR LE PROGRAMME, DANS LA LIMITE PERMISE PAR LA LOI APPLICABLE. SAUF S\'IL EST INDIQUÉ LE CONTRAIRE PAR ÉCRIT. LES TITULAIRES DU DROIT D\'AUTEUR ET / OU D\'AUTRES PARTIES FOURNISSENT LE PROGRAMME «EN L\'ÉTAT» SANS GARANTIE D\'AUCUNE SORTE, EXPLICITE OU IMPLICITE, Y COMPRIS MAIS NON SEULEMENT AUX GARANTIES IMPLICITES DE QUALITÉ MARCHANDE ET D\'ADÉQUATION À UN USAGE PARTICULIER
|
||||||
L'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME SONT DE VOTRE RESPONSABILITÉ. SI LE PROGRAMME EST DÉFECTUEUX, VOUS ASSUMEZ LE COÛT DE TOUS LES SERVICES, RÉPARATIONS OU CORRECTIONS NÉCESSAIRES."</string>
|
L\'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME SONT DE VOTRE RESPONSABILITÉ. SI LE PROGRAMME EST DÉFECTUEUX, VOUS ASSUMEZ LE COÛT DE TOUS LES SERVICES, RÉPARATIONS OU CORRECTIONS NÉCESSAIRES.</string>
|
||||||
<string name="end_user_license_agreement_i_understand">JE COMPRENDS ET J\'ACCEPTE LES CONDITIONS DU CONTRAT</string>
|
<string name="end_user_license_agreement_i_understand">JE COMPRENDS ET J\'ACCEPTE LES CONDITIONS DU CONTRAT</string>
|
||||||
<string name="save">Sauvegarder</string>
|
<string name="save">Sauvegarder</string>
|
||||||
<string name="nobtadapter">L\'adaptateur bluetooth est introuvable</string>
|
<string name="nobtadapter">L\'adaptateur bluetooth est introuvable</string>
|
||||||
|
@ -1161,6 +1161,8 @@ L'ENSEMBLE DES RISQUES LIÉS À LA QUALITÉ ET À LA PERFORMANCE DU PROGRAMME SO
|
||||||
<string name="old_version">ancienne version</string>
|
<string name="old_version">ancienne version</string>
|
||||||
<string name="very_old_version">très ancienne version</string>
|
<string name="very_old_version">très ancienne version</string>
|
||||||
<string name="new_version_warning">Une nouvelle version est disponible depuis au moins %1$d jours ! Retour au traitement par pompe assistée par capteur (Arrêt par Glycémie Basse (AGB), Low Glucose Suspend (LGS) ) après 60 jours et la Boucle sera désactivée après 90 jours</string>
|
<string name="new_version_warning">Une nouvelle version est disponible depuis au moins %1$d jours ! Retour au traitement par pompe assistée par capteur (Arrêt par Glycémie Basse (AGB), Low Glucose Suspend (LGS) ) après 60 jours et la Boucle sera désactivée après 90 jours</string>
|
||||||
|
<string name="twohours">2 h</string>
|
||||||
|
<string name="formatinsulinunits">%1$.2fU</string>
|
||||||
<plurals name="objective_days">
|
<plurals name="objective_days">
|
||||||
<item quantity="one">%1$d jour</item>
|
<item quantity="one">%1$d jour</item>
|
||||||
<item quantity="other">%1$d jours</item>
|
<item quantity="other">%1$d jours</item>
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
<!--Generated by crowdin.com-->
|
<!--Generated by crowdin.com-->
|
||||||
<resources>
|
<resources>
|
||||||
<string name="nav_refreshtreatments">רענן טיפול מ-Nightscout</string>
|
<string name="nav_refreshtreatments">רענן טיפול מ-Nightscout</string>
|
||||||
<string name="alert_dialog_storage_permission_text">"בבקשה אתחל את הסמרטפון שלך או תרענן את אפלקצית AndroidAPS בהגדרות המערכת
|
<string name="alert_dialog_storage_permission_text">בבקשה אתחל את הסמרטפון שלך או תרענן את אפלקצית AndroidAPS בהגדרות המערכת
|
||||||
אחרת AndroidAPS לא יוכל לבצע רישום (חשוב לעקוב אחר ולוודא כי האלגוריתמים פועלים כראוי)!"</string>
|
אחרת AndroidAPS לא יוכל לבצע רישום (חשוב לעקוב אחר ולוודא כי האלגוריתמים פועלים כראוי)!</string>
|
||||||
<string name="description_food">מציג את ההגדרות הקבועות מראש עבור מזון המוגדר ב-Nightscout</string>
|
<string name="description_food">מציג את ההגדרות הקבועות מראש עבור מזון המוגדר ב-Nightscout</string>
|
||||||
<string name="description_loop">להפעיל או לכבות את הלולאה.</string>
|
<string name="description_loop">להפעיל או לכבות את הלולאה.</string>
|
||||||
<string name="description_ns_client">מסנכרן את הנתונים שלך עם Nightscout</string>
|
<string name="description_ns_client">מסנכרן את הנתונים שלך עם Nightscout</string>
|
||||||
|
|
|
@ -318,8 +318,8 @@
|
||||||
<string name="objectives_0_objective">Opzetten van visualisatie en monitoring en analyzeren van basaal en ratio\'s</string>
|
<string name="objectives_0_objective">Opzetten van visualisatie en monitoring en analyzeren van basaal en ratio\'s</string>
|
||||||
<string name="objectives_0_gate">Controleren van beschikbaarheid BG en insuline pomp data op Nightscout</string>
|
<string name="objectives_0_gate">Controleren van beschikbaarheid BG en insuline pomp data op Nightscout</string>
|
||||||
<string name="objectives_1_objective">Starten met de Open Loop modus</string>
|
<string name="objectives_1_objective">Starten met de Open Loop modus</string>
|
||||||
<string name="objectives_1_gate">"In Open Loop modus werken voor enkele dagen en handmatig meermaals tijdelijke basaal instellen.
|
<string name="objectives_1_gate">In Open Loop modus werken voor enkele dagen en handmatig meermaals tijdelijke basaal instellen.
|
||||||
Stel in en gebruik tijdelijk en standaard tijdelijke streefdoelen (bv. bij sporten of koolhydraten inname bij hypo)"</string>
|
Stel in en gebruik tijdelijk en standaard tijdelijke streefdoelen (bv. bij sporten of koolhydraten inname bij hypo)</string>
|
||||||
<string name="objectives_2_objective">De Open Loop begrijpen, inclusief de voorgestelde tijdelijke basaalstanden</string>
|
<string name="objectives_2_objective">De Open Loop begrijpen, inclusief de voorgestelde tijdelijke basaalstanden</string>
|
||||||
<string name="objectives_2_gate">Gebaseerd op deze ervaringen beslissen wat het maximale basaal mag zijn en dit in de pomp instellen</string>
|
<string name="objectives_2_gate">Gebaseerd op deze ervaringen beslissen wat het maximale basaal mag zijn en dit in de pomp instellen</string>
|
||||||
<string name="objectives_3_objective">Starten met closed Loop met bescherming tegen lage BG</string>
|
<string name="objectives_3_objective">Starten met closed Loop met bescherming tegen lage BG</string>
|
||||||
|
@ -1161,6 +1161,7 @@ Stel in en gebruik tijdelijk en standaard tijdelijke streefdoelen (bv. bij sport
|
||||||
<string name="old_version">oude versie</string>
|
<string name="old_version">oude versie</string>
|
||||||
<string name="very_old_version">zeer oude versie</string>
|
<string name="very_old_version">zeer oude versie</string>
|
||||||
<string name="new_version_warning">Er is als sinds ten minste %1$d dagen een nieuwe versie beschikbaar! Na 60 dagen wordt de loop beperkt tot LGS, na 90 dagen zal de loop worden uitgeschakeld</string>
|
<string name="new_version_warning">Er is als sinds ten minste %1$d dagen een nieuwe versie beschikbaar! Na 60 dagen wordt de loop beperkt tot LGS, na 90 dagen zal de loop worden uitgeschakeld</string>
|
||||||
|
<string name="twohours">2u</string>
|
||||||
<plurals name="objective_days">
|
<plurals name="objective_days">
|
||||||
<item quantity="one">%1$d dag</item>
|
<item quantity="one">%1$d dag</item>
|
||||||
<item quantity="other">%1$d dag</item>
|
<item quantity="other">%1$d dag</item>
|
||||||
|
|
|
@ -580,8 +580,8 @@
|
||||||
<string name="wear_showbgi_title">Pokaż BGI</string>
|
<string name="wear_showbgi_title">Pokaż BGI</string>
|
||||||
<string name="wear_showbgi_summary">Dodaj BGI do Linii Statusu</string>
|
<string name="wear_showbgi_summary">Dodaj BGI do Linii Statusu</string>
|
||||||
<string name="ns_noupload">Brak przesyłania do NS</string>
|
<string name="ns_noupload">Brak przesyłania do NS</string>
|
||||||
<string name="ns_noupload_summary">"Wszystkie dane wysyłane do NS są odrzucane. AAPS jest podłączony do NS, ale nie dokonuje
|
<string name="ns_noupload_summary">Wszystkie dane wysyłane do NS są odrzucane. AAPS jest podłączony do NS, ale nie dokonuje
|
||||||
żadnych zmian w NS"</string>
|
żadnych zmian w NS</string>
|
||||||
<string name="basal_step">Krok bazy</string>
|
<string name="basal_step">Krok bazy</string>
|
||||||
<string name="bolus_step">Krok bolusa</string>
|
<string name="bolus_step">Krok bolusa</string>
|
||||||
<string name="extendedbolus">BolusPrzedłużony</string>
|
<string name="extendedbolus">BolusPrzedłużony</string>
|
||||||
|
|
|
@ -1,28 +1,28 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!--Generated by crowdin.com-->
|
<!--Generated by crowdin.com-->
|
||||||
<resources>
|
<resources>
|
||||||
<string name="treatmentssafety_title">Segurança do Tratamento</string>
|
<string name="treatmentssafety_title">Segurança de tratamentos</string>
|
||||||
<string name="treatmentssafety_maxbolus_title">Máximo bolus permitido [U]</string>
|
<string name="treatmentssafety_maxbolus_title">Max bolus permitido [U]</string>
|
||||||
<string name="treatmentssafety_maxcarbs_title">Máximo de carbs permitidos [g]</string>
|
<string name="treatmentssafety_maxcarbs_title">Max hidratos permitidos [g]</string>
|
||||||
<string name="nav_preferences">Preferências</string>
|
<string name="nav_preferences">Preferências</string>
|
||||||
<string name="nav_refreshtreatments">Atualizar tratamentos de NS</string>
|
<string name="nav_refreshtreatments">Atualizar tratamentos do NS</string>
|
||||||
<string name="nav_resetdb">Redefinir banco de dados</string>
|
<string name="nav_resetdb">Reinicializar base de dados</string>
|
||||||
<string name="reset_db_confirm">Você realmente quer redefinir os bancos de dados?</string>
|
<string name="reset_db_confirm">Quer realmente reiniciar a base de dados?</string>
|
||||||
<string name="nav_exit">Sair</string>
|
<string name="nav_exit">Sair</string>
|
||||||
<string name="danar_useextended_title">Usar bólus prolongado de >200%%</string>
|
<string name="danar_useextended_title">Usar bólus prolongado de >200%%</string>
|
||||||
<string name="danar_bt_name_title">Dispositivo Bluetooth DanaR</string>
|
<string name="danar_bt_name_title">Dispositivo Bluetooth DanaR</string>
|
||||||
<string name="ns_sync_use_absolute_title">Sempre usar valores absolutos basais</string>
|
<string name="ns_sync_use_absolute_title">Usar sempre valores absolutos de basal</string>
|
||||||
<string name="alert_dialog_storage_permission_text">Por favor, reinicie seu telefone ou reinicie o AndroidAPS nas Configurações do Sistema \nCaso contrário o Android APS não terá registro (importante para rastrear e verificar que os algoritmos estão funcionando corretamente)!</string>
|
<string name="alert_dialog_storage_permission_text">Por favor, reinicie o seu telefone ou reinicie o AndroidAPS a partir das Configurações do Sistema \ncaso contrário, o AndroidAPS não terá registro (importante para controlar e verificar se os algoritmos estão a funcionar corretamente)!</string>
|
||||||
<string name="description_actions">Alguns botões para acessar rapidamente a funções comuns</string>
|
<string name="description_actions">Alguns botões para aceder rapidamente a funções comuns</string>
|
||||||
<string name="description_careportal">Digite as entradas avançadas do livro de log.</string>
|
<string name="description_careportal">Inserir as entradas avançadas do livro de registo.</string>
|
||||||
<string name="description_config_builder">Usado para configurar os plugins ativos</string>
|
<string name="description_config_builder">Usado para configurar os plugins ativos</string>
|
||||||
<string name="description_objectives">Programa de aprendizagem</string>
|
<string name="description_objectives">Programa de aprendizagem</string>
|
||||||
<string name="description_food">Exibe as predefinições de comida definidas no Nightscout</string>
|
<string name="description_food">Exibe as predefinições de comida definidas no Nightscout</string>
|
||||||
<string name="description_insulin_rapid">Predefinição de Insulina para Humalog e NovoRapid / NovoLog</string>
|
<string name="description_insulin_rapid">Predefinição de Insulina Humalog e NovoRapid / NovoLog</string>
|
||||||
<string name="description_insulin_ultra_rapid">Pré-ajuste de Insulina para Fiasp</string>
|
<string name="description_insulin_ultra_rapid">Predefinição de Insulina Fiasp</string>
|
||||||
<string name="description_insulin_free_peak">Permite que você defina o pico da atividade de insulina, deve ser usado apenas por usuários avançados</string>
|
<string name="description_insulin_free_peak">Permite definir o pico de atividade da insulina e deve ser usado somente por usuários avançados</string>
|
||||||
<string name="description_loop">Ativar ou desativar a aplicação que desencadeia o loop.</string>
|
<string name="description_loop">Ativar ou desativar a aplicação que desencadeia o loop.</string>
|
||||||
<string name="description_ns_client">Sincroniza seus dados com o Nightscout</string>
|
<string name="description_ns_client">Sincroniza os seus dados com o Nightscout</string>
|
||||||
<string name="description_ma">Estado do algoritmo em 2016</string>
|
<string name="description_ma">Estado do algoritmo em 2016</string>
|
||||||
<string name="description_ama">Estado do algoritmo em 2017</string>
|
<string name="description_ama">Estado do algoritmo em 2017</string>
|
||||||
<string name="description_smb">Algoritmo mais recente para usuários avançados</string>
|
<string name="description_smb">Algoritmo mais recente para usuários avançados</string>
|
||||||
|
@ -1160,6 +1160,8 @@
|
||||||
<string name="old_version">versão antiga</string>
|
<string name="old_version">versão antiga</string>
|
||||||
<string name="very_old_version">versão muito antiga</string>
|
<string name="very_old_version">versão muito antiga</string>
|
||||||
<string name="new_version_warning">Nova versão para pelo menos %1$d dias disponíveis! Voltar para o LGS após 60 dias, o loop será desativado após 90 dias</string>
|
<string name="new_version_warning">Nova versão para pelo menos %1$d dias disponíveis! Voltar para o LGS após 60 dias, o loop será desativado após 90 dias</string>
|
||||||
|
<string name="twohours">2h</string>
|
||||||
|
<string name="formatinsulinunits">%1$.2fU</string>
|
||||||
<plurals name="objective_days">
|
<plurals name="objective_days">
|
||||||
<item quantity="one">%1$d dia</item>
|
<item quantity="one">%1$d dia</item>
|
||||||
<item quantity="other">%1$d dias</item>
|
<item quantity="other">%1$d dias</item>
|
||||||
|
|
|
@ -991,9 +991,9 @@
|
||||||
<string name="apssetup">Настроить плагин APS</string>
|
<string name="apssetup">Настроить плагин APS</string>
|
||||||
<string name="sensitivitysetup">Настроить плагин чувствительности Sensitivity</string>
|
<string name="sensitivitysetup">Настроить плагин чувствительности Sensitivity</string>
|
||||||
<string name="setupwizard_sensitivity_description">Плагин чувствительности Sensitivity применяется для определения чувствительности к инсулину и вычисления активных углеводов COB. Дополнительная информация:</string>
|
<string name="setupwizard_sensitivity_description">Плагин чувствительности Sensitivity применяется для определения чувствительности к инсулину и вычисления активных углеводов COB. Дополнительная информация:</string>
|
||||||
<string name="setupwizard_sensitivity_url">"https://github.com/MilosKozak/AndroidAPS/wiki/Sensitivity-detection-and-COB
|
<string name="setupwizard_sensitivity_url">https://github.com/MilosKozak/AndroidAPS/wiki/Sensitivity-detection-and-COB
|
||||||
|
|
||||||
Context | Edit Context"</string>
|
Context | Edit Context</string>
|
||||||
<string name="nsclientinfotext">NSClient обрабатывает подключения к Nightscout. Вы можете пропустить этот этап сейчас, но вы не преодолеете все Цели пока не настроите его.</string>
|
<string name="nsclientinfotext">NSClient обрабатывает подключения к Nightscout. Вы можете пропустить этот этап сейчас, но вы не преодолеете все Цели пока не настроите его.</string>
|
||||||
<string name="diawarning">Напоминание: новые профили инсулина требуют как минимум 5 часов длительности действия DIA. 5-6 часовая DIA эквивалентна трехчасовой на старых профилях.</string>
|
<string name="diawarning">Напоминание: новые профили инсулина требуют как минимум 5 часов длительности действия DIA. 5-6 часовая DIA эквивалентна трехчасовой на старых профилях.</string>
|
||||||
<string name="bgsourcesetup">Настройте источник СК</string>
|
<string name="bgsourcesetup">Настройте источник СК</string>
|
||||||
|
@ -1162,4 +1162,6 @@ Context | Edit Context"</string>
|
||||||
<string name="old_version">старая версия</string>
|
<string name="old_version">старая версия</string>
|
||||||
<string name="very_old_version">очень старая версия</string>
|
<string name="very_old_version">очень старая версия</string>
|
||||||
<string name="new_version_warning">Новая версия доступна не менее %1$d дней! После 60 дней переход на остановку при низкой гликемии LGS, замкнутый цикл будет отключен через 90 дней</string>
|
<string name="new_version_warning">Новая версия доступна не менее %1$d дней! После 60 дней переход на остановку при низкой гликемии LGS, замкнутый цикл будет отключен через 90 дней</string>
|
||||||
|
<string name="twohours">2ч</string>
|
||||||
|
<string name="formatinsulinunits">%1$.2f ед</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -45,8 +45,8 @@
|
||||||
<string name="description_sensitivity_weighted_average">Känsligheten beräknas som ett viktat medelvärde av avvikelserna. Senare avvikelser får en högre vikt. Minimal upptagning av kolhydrater beräknas utifrån maximal upptagstid för kolhydrater som angetts i inställningarna. Den här algoritmen är den snabbaste att justera förändringar i känsligheten.</string>
|
<string name="description_sensitivity_weighted_average">Känsligheten beräknas som ett viktat medelvärde av avvikelserna. Senare avvikelser får en högre vikt. Minimal upptagning av kolhydrater beräknas utifrån maximal upptagstid för kolhydrater som angetts i inställningarna. Den här algoritmen är den snabbaste att justera förändringar i känsligheten.</string>
|
||||||
<string name="description_source_dexcom_g5">Ta emot BG-data från den modifierade Dexcom G5-appen</string>
|
<string name="description_source_dexcom_g5">Ta emot BG-data från den modifierade Dexcom G5-appen</string>
|
||||||
<string name="description_source_dexcom_g6">Ta emot BG-data från den modifierade Dexcom G6-appen.</string>
|
<string name="description_source_dexcom_g6">Ta emot BG-data från den modifierade Dexcom G6-appen.</string>
|
||||||
<string name="description_source_eversense">"Ta emot BG-data från den modifierade
|
<string name="description_source_eversense">Ta emot BG-data från den modifierade
|
||||||
Eversense-appen."</string>
|
Eversense-appen.</string>
|
||||||
<string name="description_source_glimp">Ta emot BG-data från Glimp</string>
|
<string name="description_source_glimp">Ta emot BG-data från Glimp</string>
|
||||||
<string name="description_source_mm640g">Ta emot BG-data från 600SeriesAndroidUploader</string>
|
<string name="description_source_mm640g">Ta emot BG-data från 600SeriesAndroidUploader</string>
|
||||||
<string name="description_source_ns_client">Ladda ner BG-data från Nightscout</string>
|
<string name="description_source_ns_client">Ladda ner BG-data från Nightscout</string>
|
||||||
|
|
|
@ -441,8 +441,8 @@
|
||||||
<string name="openapsama_autosens_adjusttargets">Autosens hedefleri de ayarlar</string>
|
<string name="openapsama_autosens_adjusttargets">Autosens hedefleri de ayarlar</string>
|
||||||
<string name="openapsama_autosens_adjusttargets_summary">Varsayılan değer: true\nBu autosens in İnsülin Duyarlılık Faktörü ve bazallara ek olarak KŞ hedeflerinin ayarlanmasında kullanılır.</string>
|
<string name="openapsama_autosens_adjusttargets_summary">Varsayılan değer: true\nBu autosens in İnsülin Duyarlılık Faktörü ve bazallara ek olarak KŞ hedeflerinin ayarlanmasında kullanılır.</string>
|
||||||
<string name="openapsama_bolussnooze_dia_divisor_summary">Varsayılan değer: 2\nEğer sadece öğününüzü yerseniz, öğün bolusu alındıktan sonra bolus ertelemesi devreye girer, bu şekilde Döngü karşı bir tetbir olarak geçici bazal oranını azaltmasın diye. Buaradaki örnekte olduğu gibi varsayılan 2; 3 saat DIA olacak şekilde bolus ertelemesi kademeli olarak 1,5 saat üzeri (3DIA/2=1,5).</string>
|
<string name="openapsama_bolussnooze_dia_divisor_summary">Varsayılan değer: 2\nEğer sadece öğününüzü yerseniz, öğün bolusu alındıktan sonra bolus ertelemesi devreye girer, bu şekilde Döngü karşı bir tetbir olarak geçici bazal oranını azaltmasın diye. Buaradaki örnekte olduğu gibi varsayılan 2; 3 saat DIA olacak şekilde bolus ertelemesi kademeli olarak 1,5 saat üzeri (3DIA/2=1,5).</string>
|
||||||
<string name="openapsama_min_5m_carbimpact_summary">"Varsayılan değer: 3.0 (AMA) Gelişmiş Yemek Asistanı veya 8.0 (SMB) Super Micro Bolus. Bu 5 dakika başına varsayılan karbonhidrat emilimi için bir ayardır. Standart değer AMA için 3mg/dl/5dk aynı şekilde SMB 8mg/dl/5dk dir.
|
<string name="openapsama_min_5m_carbimpact_summary">Varsayılan değer: 3.0 (AMA) Gelişmiş Yemek Asistanı veya 8.0 (SMB) Super Micro Bolus. Bu 5 dakika başına varsayılan karbonhidrat emilimi için bir ayardır. Standart değer AMA için 3mg/dl/5dk aynı şekilde SMB 8mg/dl/5dk dir.
|
||||||
Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ'nin beklenenden daha fazla düştüğü veya beklenildiği kadar yükselmediği zamanlarda gelecekte yapılacak tahminlerde KŞ'nin hesaplanmasında ne kadar karbonhidrat emilimi gerçekleşeceğini öngörür."</string>
|
Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ\'nin beklenenden daha fazla düştüğü veya beklenildiği kadar yükselmediği zamanlarda gelecekte yapılacak tahminlerde KŞ\'nin hesaplanmasında ne kadar karbonhidrat emilimi gerçekleşeceğini öngörür.</string>
|
||||||
<string name="openapsama_link_to_preferncejson_doc_txt">Dikkat!\nNormalde aşağıdaki bu değerleri değiştirmek zorunda değilsiniz. Lütfen burayı TIKLAYIN ve metni OKUYUN ve bu değerlerden herhangi birini değiştirmeden önce ANLADIĞINIZDAN emin olun.</string>
|
<string name="openapsama_link_to_preferncejson_doc_txt">Dikkat!\nNormalde aşağıdaki bu değerleri değiştirmek zorunda değilsiniz. Lütfen burayı TIKLAYIN ve metni OKUYUN ve bu değerlerden herhangi birini değiştirmeden önce ANLADIĞINIZDAN emin olun.</string>
|
||||||
<string name="error_only_numeric_digits_allowed">Yalnızca sayısal rakam girebilirsiniz.</string>
|
<string name="error_only_numeric_digits_allowed">Yalnızca sayısal rakam girebilirsiniz.</string>
|
||||||
<string name="error_only_numeric_digits_range_allowed">%1$s - %2$s aralığında yalnızca sayısal rakamlar kullanılabilir.</string>
|
<string name="error_only_numeric_digits_range_allowed">%1$s - %2$s aralığında yalnızca sayısal rakamlar kullanılabilir.</string>
|
||||||
|
@ -701,8 +701,7 @@ Aktif Karbonhidratın ne kadar hızlı sindirildiğine ve KŞ'nin beklenenden da
|
||||||
<string name="no">Hayır</string>
|
<string name="no">Hayır</string>
|
||||||
<string name="positiveonly">Sadece pozitif</string>
|
<string name="positiveonly">Sadece pozitif</string>
|
||||||
<string name="negativeonly">Sadece negatif</string>
|
<string name="negativeonly">Sadece negatif</string>
|
||||||
<string name="overview_editquickwizard_usecob">"COB (Aktif Karbonhidrat) hesaplaması
|
<string name="overview_editquickwizard_usecob">COB (Aktif Karbonhidrat) hesaplaması</string>
|
||||||
"</string>
|
|
||||||
<string name="overview_editquickwizard_usetemptarget">Geçici hedef hesaplaması</string>
|
<string name="overview_editquickwizard_usetemptarget">Geçici hedef hesaplaması</string>
|
||||||
<string name="loopenabled">Döngü etkin</string>
|
<string name="loopenabled">Döngü etkin</string>
|
||||||
<string name="apsselected">Seçili APS</string>
|
<string name="apsselected">Seçili APS</string>
|
||||||
|
|
|
@ -1345,6 +1345,17 @@
|
||||||
<string name="tidepool_shortname">TDP</string>
|
<string name="tidepool_shortname">TDP</string>
|
||||||
<string name="description_tidepool">Uploads data to Tidepool</string>
|
<string name="description_tidepool">Uploads data to Tidepool</string>
|
||||||
<string name="key_tidepool_last_end" translatable="false">tidepool_last_end</string>
|
<string name="key_tidepool_last_end" translatable="false">tidepool_last_end</string>
|
||||||
|
<string name="tidepool_upload_cgm">Upload CGM data</string>
|
||||||
|
<string name="key_tidepool_upload_cgm" translatable="false">tidepool_upload_cgm</string>
|
||||||
|
<string name="key_tidepool_upload_bolus" translatable="false">tidepool_upload_bolus</string>
|
||||||
|
<string name="tidepool_upload_bolus">Upload treatments (insulin, carbs)</string>
|
||||||
|
<string name="key_tidepool_upload_tbr" translatable="false">tidepool_upload_tbr</string>
|
||||||
|
<string name="tidepool_upload_tbr">Upload temporary basals</string>
|
||||||
|
<string name="key_tidepool_upload_profile" translatable="false">tidepool_upload_profile</string>
|
||||||
|
<string name="tidepool_upload_profile">Upload profile switches, temp targets</string>
|
||||||
|
<string name="key_tidepool_upload_bg" translatable="false">tidepool_upload_bg</string>
|
||||||
|
<string name="tidepool_upload_bg">Upload BG tests</string>
|
||||||
|
<string name="key_instanceid" translatable="false">instanceid</string>
|
||||||
|
|
||||||
<string name="key_smbmaxminutes" translatable="false">smbmaxminutes</string>
|
<string name="key_smbmaxminutes" translatable="false">smbmaxminutes</string>
|
||||||
<string name="dst_plugin_name" translatable="false">Dayligh Saving time</string>
|
<string name="dst_plugin_name" translatable="false">Dayligh Saving time</string>
|
||||||
|
@ -1364,17 +1375,8 @@
|
||||||
<string name="old_version">old version</string>
|
<string name="old_version">old version</string>
|
||||||
<string name="very_old_version">very old version</string>
|
<string name="very_old_version">very old version</string>
|
||||||
<string name="new_version_warning">New version for at least %1$d days available! Fallback to LGS after 60 days, loop will be disabled after 90 days</string>
|
<string name="new_version_warning">New version for at least %1$d days available! Fallback to LGS after 60 days, loop will be disabled after 90 days</string>
|
||||||
<string name="tidepool_upload_cgm">Upload CGM data</string>
|
<string name="twohours">2h</string>
|
||||||
<string name="key_tidepool_upload_cgm" translatable="false">tidepool_upload_cgm</string>
|
<string name="formatinsulinunits">%1$.2fU</string>
|
||||||
<string name="key_tidepool_upload_bolus" translatable="false">tidepool_upload_bolus</string>
|
|
||||||
<string name="tidepool_upload_bolus">Upload treatments (insulin, carbs)</string>
|
|
||||||
<string name="key_tidepool_upload_tbr" translatable="false">tidepool_upload_tbr</string>
|
|
||||||
<string name="tidepool_upload_tbr">Upload temporary basals</string>
|
|
||||||
<string name="key_tidepool_upload_profile" translatable="false">tidepool_upload_profile</string>
|
|
||||||
<string name="tidepool_upload_profile">Upload profile switches, temp targets</string>
|
|
||||||
<string name="key_tidepool_upload_bg" translatable="false">tidepool_upload_bg</string>
|
|
||||||
<string name="tidepool_upload_bg">Upload BG tests</string>
|
|
||||||
<string name="key_instanceid" translatable="false">instanceid</string>
|
|
||||||
|
|
||||||
<string name="dexcom_app_patched">Dexcom App (patched)</string>
|
<string name="dexcom_app_patched">Dexcom App (patched)</string>
|
||||||
<string name="dexcom_short">DXCM</string>
|
<string name="dexcom_short">DXCM</string>
|
||||||
|
|
|
@ -10,7 +10,6 @@ import com.squareup.otto.Bus;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.mockito.stubbing.Answer;
|
|
||||||
import org.powermock.api.mockito.PowerMockito;
|
import org.powermock.api.mockito.PowerMockito;
|
||||||
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -27,14 +26,12 @@ import info.nightscout.androidaps.logging.L;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.CobInfo;
|
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
|
import info.nightscout.androidaps.plugins.pump.danaR.DanaRPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin;
|
import info.nightscout.androidaps.plugins.pump.danaRKorean.DanaRKoreanPlugin;
|
||||||
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin;
|
import info.nightscout.androidaps.plugins.pump.danaRv2.DanaRv2Plugin;
|
||||||
import info.nightscout.androidaps.plugins.treatments.TreatmentService;
|
import info.nightscout.androidaps.plugins.treatments.TreatmentService;
|
||||||
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.CommandQueue;
|
import info.nightscout.androidaps.queue.CommandQueue;
|
||||||
import info.nightscout.androidaps.utils.SP;
|
import info.nightscout.androidaps.utils.SP;
|
||||||
|
|
||||||
|
@ -42,7 +39,6 @@ import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
import static org.mockito.ArgumentMatchers.anyInt;
|
import static org.mockito.ArgumentMatchers.anyInt;
|
||||||
import static org.mockito.ArgumentMatchers.anyLong;
|
import static org.mockito.ArgumentMatchers.anyLong;
|
||||||
import static org.mockito.Mockito.doAnswer;
|
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ -59,6 +55,7 @@ public class AAPSMocker {
|
||||||
public static Intent intentSent = null;
|
public static Intent intentSent = null;
|
||||||
|
|
||||||
public static CommandQueue queue;
|
public static CommandQueue queue;
|
||||||
|
public static ConstraintChecker constraintChecker;
|
||||||
|
|
||||||
public static void mockStrings() {
|
public static void mockStrings() {
|
||||||
Locale.setDefault(new Locale("en", "US"));
|
Locale.setDefault(new Locale("en", "US"));
|
||||||
|
@ -168,7 +165,7 @@ public class AAPSMocker {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ConstraintChecker mockConstraintsChecker() {
|
public static ConstraintChecker mockConstraintsChecker() {
|
||||||
ConstraintChecker constraintChecker = mock(ConstraintChecker.class);
|
constraintChecker = mock(ConstraintChecker.class);
|
||||||
when(MainApp.getConstraintChecker()).thenReturn(constraintChecker);
|
when(MainApp.getConstraintChecker()).thenReturn(constraintChecker);
|
||||||
return constraintChecker;
|
return constraintChecker;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,15 @@ package info.nightscout.androidaps.utils;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
import org.mockito.Mockito;
|
||||||
import org.powermock.api.mockito.PowerMockito;
|
import org.powermock.api.mockito.PowerMockito;
|
||||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||||
import org.powermock.modules.junit4.PowerMockRunner;
|
import org.powermock.modules.junit4.PowerMockRunner;
|
||||||
|
|
||||||
import info.AAPSMocker;
|
import info.AAPSMocker;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
|
import info.nightscout.androidaps.data.ConstraintChecker;
|
||||||
|
import info.nightscout.androidaps.interfaces.Constraint;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.Profile;
|
import info.nightscout.androidaps.data.Profile;
|
||||||
|
@ -17,6 +20,7 @@ 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.plugins.pump.mdi.MDIPlugin;
|
import info.nightscout.androidaps.plugins.pump.mdi.MDIPlugin;
|
||||||
|
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ -24,38 +28,41 @@ import static org.mockito.Mockito.when;
|
||||||
* Created by kuchjir on 12/12/2017.
|
* Created by kuchjir on 12/12/2017.
|
||||||
*/
|
*/
|
||||||
@RunWith(PowerMockRunner.class)
|
@RunWith(PowerMockRunner.class)
|
||||||
@PrepareForTest({MainApp.class, GlucoseStatus.class, ConfigBuilderPlugin.class, TreatmentsPlugin.class})
|
@PrepareForTest({MainApp.class, GlucoseStatus.class, ConfigBuilderPlugin.class, TreatmentsPlugin.class, ConstraintChecker.class})
|
||||||
public class BolusWizardTest {
|
public class BolusWizardTest {
|
||||||
private static final double PUMP_BOLUS_STEP = 0.1;
|
private static final double PUMP_BOLUS_STEP = 0.1;
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
/** Should calculate the same bolus when different blood glucose but both in target range */
|
/** Should calculate the same bolus when different blood glucose but both in target range */
|
||||||
public void shuldCalculateTheSameBolusWhenBGsInRange() throws Exception {
|
public void shouldCalculateTheSameBolusWhenBGsInRange() throws Exception {
|
||||||
BolusWizard bw = new BolusWizard();
|
|
||||||
Profile profile = setupProfile(4d, 8d, 20d, 12d);
|
Profile profile = setupProfile(4d, 8d, 20d, 12d);
|
||||||
|
|
||||||
Double bolusForBg42 = bw.doCalc(profile, null, 20, 0.0, 4.2, 0d, 100d, true, true, false, false);
|
BolusWizard bw = new BolusWizard(profile, "", null, 20, 0.0, 4.2, 0d, 100d, true, true, true, true, false, false, false);
|
||||||
Double bolusForBg54 = bw.doCalc(profile, null, 20, 0.0, 5.4, 0d, 100d, true, true, false, false);
|
Double bolusForBg42 = bw.getCalculatedTotalInsulin();
|
||||||
|
bw = new BolusWizard(profile, "", null, 20, 0.0, 5.4, 0d, 100d, true, true, true, true, false, false, false);
|
||||||
|
Double bolusForBg54 = bw.getCalculatedTotalInsulin();
|
||||||
Assert.assertEquals(bolusForBg42, bolusForBg54);
|
Assert.assertEquals(bolusForBg42, bolusForBg54);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shuldCalculateHigherBolusWhenHighBG() throws Exception {
|
public void shouldCalculateHigherBolusWhenHighBG() throws Exception {
|
||||||
BolusWizard bw = new BolusWizard();
|
|
||||||
Profile profile = setupProfile(4d, 8d, 20d, 12d);
|
Profile profile = setupProfile(4d, 8d, 20d, 12d);
|
||||||
|
|
||||||
Double bolusForHighBg = bw.doCalc(profile, null, 20, 0d, 9.8, 0d, 100d, true, true, false, false);
|
BolusWizard bw = new BolusWizard(profile, "", null, 20, 0.0, 9.8, 0d, 100d, true, true, true, true, false, false, false);
|
||||||
Double bolusForBgInRange = bw.doCalc(profile, null, 20, 0.0, 5.4, 0d, 100d, true, true, false, false);
|
Double bolusForHighBg = bw.getCalculatedTotalInsulin();
|
||||||
|
bw = new BolusWizard(profile, "", null, 20, 0.0, 5.4, 0d, 100d, true, true, true, true, false, false, false);
|
||||||
|
Double bolusForBgInRange = bw.getCalculatedTotalInsulin();
|
||||||
Assert.assertTrue(bolusForHighBg > bolusForBgInRange);
|
Assert.assertTrue(bolusForHighBg > bolusForBgInRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void shuldCalculateLowerBolusWhenLowBG() throws Exception {
|
public void shouldCalculateLowerBolusWhenLowBG() throws Exception {
|
||||||
BolusWizard bw = new BolusWizard();
|
|
||||||
Profile profile = setupProfile(4d, 8d, 20d, 12d);
|
Profile profile = setupProfile(4d, 8d, 20d, 12d);
|
||||||
|
|
||||||
Double bolusForLowBg = bw.doCalc(profile, null, 20, 0d, 3.6, 0d, 100d, true, true, false, false);
|
BolusWizard bw = new BolusWizard(profile, "", null, 20, 0.0, 3.6, 0d, 100d, true, true, true, true, false, false, false);
|
||||||
Double bolusForBgInRange = bw.doCalc(profile, null, 20, 0.0, 5.4, 0d, 100d, true, true, false, false);
|
Double bolusForLowBg = bw.getCalculatedTotalInsulin();
|
||||||
|
bw = new BolusWizard(profile, "", null, 20, 0.0, 5.4, 0d, 100d, true, true, true, true, false, false, false);
|
||||||
|
Double bolusForBgInRange = bw.getCalculatedTotalInsulin();
|
||||||
Assert.assertTrue(bolusForLowBg < bolusForBgInRange);
|
Assert.assertTrue(bolusForLowBg < bolusForBgInRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,6 +89,12 @@ public class BolusWizardTest {
|
||||||
pump.getPumpDescription().bolusStep = PUMP_BOLUS_STEP;
|
pump.getPumpDescription().bolusStep = PUMP_BOLUS_STEP;
|
||||||
when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(pump);
|
when(ConfigBuilderPlugin.getPlugin().getActivePump()).thenReturn(pump);
|
||||||
|
|
||||||
|
AAPSMocker.mockConstraintsChecker();
|
||||||
|
Mockito.doAnswer(invocation -> {
|
||||||
|
Constraint<Double> constraint = invocation.getArgument(0);
|
||||||
|
return constraint;
|
||||||
|
}).when(AAPSMocker.constraintChecker).applyBolusConstraints(any(Constraint.class));
|
||||||
|
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.3.31'
|
ext.kotlin_version = '1.3.41'
|
||||||
ext.butterknifeVersion = '10.1.0'
|
ext.butterknifeVersion = '10.1.0'
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
|
@ -10,9 +10,9 @@ buildscript {
|
||||||
maven { url 'https://maven.fabric.io/public' }
|
maven { url 'https://maven.fabric.io/public' }
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.4.1'
|
classpath 'com.android.tools.build:gradle:3.4.2'
|
||||||
classpath 'com.google.gms:google-services:4.2.0'
|
classpath 'com.google.gms:google-services:4.3.0'
|
||||||
classpath 'io.fabric.tools:gradle:1.29.0'
|
classpath 'io.fabric.tools:gradle:1.30.0'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
|
Loading…
Reference in a new issue