From db7671cd23cace36e21155d9cb8f482444fdbfe6 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Thu, 15 Mar 2018 18:30:18 +0100 Subject: [PATCH] split enacting TRB and SMB --- .../androidaps/data/PumpEnactResult.java | 30 ++++-- .../ConfigBuilder/ConfigBuilderPlugin.java | 42 +++++++- .../androidaps/plugins/Loop/LoopFragment.java | 95 ++++++++----------- .../androidaps/plugins/Loop/LoopPlugin.java | 36 ++++--- .../plugins/Loop/events/EventLoopResult.java | 12 --- .../DetermineBasalAdapterSMBJS.java | 11 ++- .../java/info/nightscout/utils/NSUpload.java | 19 ++-- app/src/main/res/layout/loop_fragment.xml | 49 +++++++++- app/src/main/res/values-bg/strings.xml | 1 - app/src/main/res/values-cs/strings.xml | 3 +- app/src/main/res/values-de/strings.xml | 1 - app/src/main/res/values-el/strings.xml | 1 - app/src/main/res/values-es/strings.xml | 1 - app/src/main/res/values-fr/strings.xml | 1 - app/src/main/res/values-it/strings.xml | 1 - app/src/main/res/values-ko/strings.xml | 1 - app/src/main/res/values-nl/strings.xml | 1 - app/src/main/res/values-ro/strings.xml | 1 - app/src/main/res/values-ru/strings.xml | 1 - app/src/main/res/values-sv/strings.xml | 1 - app/src/main/res/values/strings.xml | 3 +- 21 files changed, 188 insertions(+), 123 deletions(-) delete mode 100644 app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopResult.java diff --git a/app/src/main/java/info/nightscout/androidaps/data/PumpEnactResult.java b/app/src/main/java/info/nightscout/androidaps/data/PumpEnactResult.java index d19b3316ac..2af503c13f 100644 --- a/app/src/main/java/info/nightscout/androidaps/data/PumpEnactResult.java +++ b/app/src/main/java/info/nightscout/androidaps/data/PumpEnactResult.java @@ -22,8 +22,8 @@ public class PumpEnactResult extends Object { // Result of basal change public Integer duration = -1; // duration set [minutes] - public Double absolute = -1d; // absolute rate [U/h] , isPercent = false - public Integer percent = -1; // percent of current basal [%] (100% = current basal), isPercent = true + public double absolute = -1d; // absolute rate [U/h] , isPercent = false + public int percent = -1; // percent of current basal [%] (100% = current basal), isPercent = true public boolean isPercent = false; // if true percent is used, otherwise absolute public boolean isTempCancel = false; // if true we are caceling temp basal // Result of treatment delivery @@ -47,17 +47,17 @@ public class PumpEnactResult extends Object { return this; } - public PumpEnactResult duration(Integer duration) { + public PumpEnactResult duration(int duration) { this.duration = duration; return this; } - public PumpEnactResult absolute(Double absolute) { + public PumpEnactResult absolute(double absolute) { this.absolute = absolute; return this; } - public PumpEnactResult percent(Integer percent) { + public PumpEnactResult percent(int percent) { this.percent = percent; return this; } @@ -71,12 +71,12 @@ public class PumpEnactResult extends Object { return this; } - public PumpEnactResult bolusDelivered(Double bolusDelivered) { + public PumpEnactResult bolusDelivered(double bolusDelivered) { this.bolusDelivered = bolusDelivered; return this; } - public PumpEnactResult carbsDelivered(Double carbsDelivered) { + public PumpEnactResult carbsDelivered(double carbsDelivered) { this.carbsDelivered = carbsDelivered; return this; } @@ -93,7 +93,11 @@ public class PumpEnactResult extends Object { public String toString() { String ret = MainApp.sResources.getString(R.string.success) + ": " + success; if (enacted) { - if (isTempCancel) { + if (bolusDelivered > 0) { + ret += "\n" + MainApp.sResources.getString(R.string.enacted) + ": " + enacted; + ret += "\n" + MainApp.sResources.getString(R.string.comment) + ": " + comment; + ret += "\n" + MainApp.sResources.getString(R.string.smb_shortname) + ": " + bolusDelivered + "U"; + } else if (isTempCancel) { ret += "\n" + MainApp.sResources.getString(R.string.enacted) + ": " + enacted; ret += "\n" + MainApp.sResources.getString(R.string.comment) + ": " + comment + "\n" + MainApp.sResources.getString(R.string.canceltemp); @@ -119,7 +123,11 @@ public class PumpEnactResult extends Object { if (queued) { ret = MainApp.sResources.getString(R.string.waitingforpumpresult); } else if (enacted) { - if (isTempCancel) { + if (bolusDelivered > 0) { + ret += "
" + MainApp.sResources.getString(R.string.enacted) + ": " + enacted; + ret += "
" + MainApp.sResources.getString(R.string.comment) + ": " + comment; + ret += "
" + MainApp.sResources.getString(R.string.smb_shortname) + ": " + bolusDelivered + "U"; + } else if (isTempCancel) { ret += "
" + MainApp.sResources.getString(R.string.enacted) + ": " + enacted; ret += "
" + MainApp.sResources.getString(R.string.comment) + ": " + comment + "
" + MainApp.sResources.getString(R.string.canceltemp); @@ -149,7 +157,9 @@ public class PumpEnactResult extends Object { public JSONObject json() { JSONObject result = new JSONObject(); try { - if (isTempCancel) { + if (bolusDelivered > 0) { + result.put("smb", bolusDelivered); + } else if (isTempCancel) { result.put("rate", 0); result.put("duration", 0); } else if (isPercent) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java index b1456c97b8..be9b467778 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/ConfigBuilder/ConfigBuilderPlugin.java @@ -353,7 +353,7 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr /** * expect absolute request and allow both absolute and percent response based on pump capabilities */ - public void applyAPSRequest(APSResult request, Callback callback) { + public void applyTBRRequest(APSResult request, Callback callback) { PumpInterface pump = getActivePump(); request.rate = applyBasalConstraints(request.rate); @@ -403,6 +403,29 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr getCommandQueue().tempBasalAbsolute(request.rate, request.duration, false, callback); } } + } + + public void applySMBRequest(APSResult request, Callback callback) { + PumpInterface pump = getActivePump(); + + if (!pump.isInitialized()) { + log.debug("applySMBRequest: " + MainApp.sResources.getString(R.string.pumpNotInitialized)); + if (callback != null) { + callback.result(new PumpEnactResult().comment(MainApp.sResources.getString(R.string.pumpNotInitialized)).enacted(false).success(false)).run(); + } + return; + } + + if (pump.isSuspended()) { + log.debug("applySMBRequest: " + MainApp.sResources.getString(R.string.pumpsuspended)); + if (callback != null) { + callback.result(new PumpEnactResult().comment(MainApp.sResources.getString(R.string.pumpsuspended)).enacted(false).success(false)).run(); + } + return; + } + + if (Config.logCongigBuilderActions) + log.debug("applySMBRequest: " + request.toString()); if (request.bolusRequested) { long lastBolusTime = getLastBolusTime(); @@ -765,6 +788,14 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr return "Default"; } + public boolean isProfileValid(String from) { + return getProfile() != null && getProfile().isValid(from) && + activeProfile != null && + activeProfile.getProfile() != null && + activeProfile.getProfile().getDefaultProfile() != null && + activeProfile.getProfile().getDefaultProfile().isValid(from); + } + @Nullable public Profile getProfile() { return getProfile(System.currentTimeMillis()); @@ -777,8 +808,10 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr @Nullable public Profile getProfile(long time) { - if (activeTreatments == null) + if (activeTreatments == null) { + log.debug("getProfile activeTreatments == null: returning null"); return null; //app not initialized + } //log.debug("Profile for: " + new Date(time).toLocaleString() + " : " + getProfileName(time)); boolean ignoreProfileSwitchEvents = SP.getBoolean(R.string.key_do_not_track_profile_switch, false); if (!ignoreProfileSwitchEvents) { @@ -794,8 +827,10 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr } } // Unable to determine profile, failover to default - if (activeProfile.getProfile() == null) + if (activeProfile.getProfile() == null) { + log.debug("getProfile activeProfile.getProfile() == null: returning null (activeProfile=" + activeProfile.getClass().getSimpleName() + ")"); return null; //app not initialized + } Profile defaultProfile = activeProfile.getProfile().getDefaultProfile(); if (defaultProfile != null) return defaultProfile; @@ -813,6 +848,7 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr } catch (JSONException e) { log.error("Unhandled exception", e); } + log.debug("getProfile at the end: returning null"); return null; } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java index 55038520a4..c9b60ab3d6 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopFragment.java @@ -15,6 +15,9 @@ import com.squareup.otto.Subscribe; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import butterknife.BindView; +import butterknife.ButterKnife; +import butterknife.OnClick; import info.nightscout.androidaps.MainApp; import info.nightscout.androidaps.R; import info.nightscout.androidaps.plugins.Common.SubscriberFragment; @@ -22,16 +25,25 @@ import info.nightscout.androidaps.plugins.Loop.events.EventLoopSetLastRunGui; import info.nightscout.androidaps.plugins.Loop.events.EventLoopUpdateGui; import info.nightscout.utils.FabricPrivacy; -public class LoopFragment extends SubscriberFragment implements View.OnClickListener { +public class LoopFragment extends SubscriberFragment { private static Logger log = LoggerFactory.getLogger(LoopFragment.class); + @BindView(R.id.loop_run) Button runNowButton; + @BindView(R.id.loop_lastrun) TextView lastRunView; + @BindView(R.id.loop_lastenact) TextView lastEnactView; + @BindView(R.id.loop_source) TextView sourceView; + @BindView(R.id.loop_request) TextView requestView; + @BindView(R.id.loop_constraintsprocessed) TextView constraintsProcessedView; - TextView setByPumpView; + @BindView(R.id.loop_tbrsetbypump) + TextView tbrSetByPumpView; + @BindView(R.id.loop_smbsetbypump) + TextView smbSetByPumpView; @Override @@ -39,41 +51,19 @@ public class LoopFragment extends SubscriberFragment implements View.OnClickList Bundle savedInstanceState) { try { View view = inflater.inflate(R.layout.loop_fragment, container, false); - - lastRunView = (TextView) view.findViewById(R.id.loop_lastrun); - lastEnactView = (TextView) view.findViewById(R.id.loop_lastenact); - sourceView = (TextView) view.findViewById(R.id.loop_source); - requestView = (TextView) view.findViewById(R.id.loop_request); - constraintsProcessedView = (TextView) view.findViewById(R.id.loop_constraintsprocessed); - setByPumpView = (TextView) view.findViewById(R.id.loop_setbypump); - runNowButton = (Button) view.findViewById(R.id.loop_run); - runNowButton.setOnClickListener(this); - - updateGUI(); + unbinder = ButterKnife.bind(this, view); return view; } catch (Exception e) { FabricPrivacy.logException(e); } - return null; } - @Override - public void onClick(View view) { - switch (view.getId()) { - case R.id.loop_run: - lastRunView.setText(MainApp.sResources.getString(R.string.executing)); - Thread thread = new Thread(new Runnable() { - @Override - public void run() { - LoopPlugin.getPlugin().invoke("Loop button", true); - } - }); - thread.start(); - FabricPrivacy.getInstance().logCustom(new CustomEvent("Loop_Run")); - break; - } - + @OnClick(R.id.loop_run) + void onRunClick() { + lastRunView.setText(MainApp.sResources.getString(R.string.executing)); + new Thread(() -> LoopPlugin.getPlugin().invoke("Loop button", true)).start(); + FabricPrivacy.getInstance().logCustom(new CustomEvent("Loop_Run")); } @Subscribe @@ -86,12 +76,7 @@ public class LoopFragment extends SubscriberFragment implements View.OnClickList clearGUI(); final Activity activity = getActivity(); if (activity != null) - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - lastRunView.setText(ev.text); - } - }); + activity.runOnUiThread(() -> lastRunView.setText(ev.text)); } @@ -99,17 +84,15 @@ public class LoopFragment extends SubscriberFragment implements View.OnClickList protected void updateGUI() { Activity activity = getActivity(); if (activity != null) - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - if (LoopPlugin.lastRun != null) { - requestView.setText(LoopPlugin.lastRun.request != null ? LoopPlugin.lastRun.request.toSpanned() : ""); - constraintsProcessedView.setText(LoopPlugin.lastRun.constraintsProcessed != null ? LoopPlugin.lastRun.constraintsProcessed.toSpanned() : ""); - setByPumpView.setText(LoopPlugin.lastRun.setByPump != null ? LoopPlugin.lastRun.setByPump.toSpanned() : ""); - sourceView.setText(LoopPlugin.lastRun.source != null ? LoopPlugin.lastRun.source : ""); - lastRunView.setText(LoopPlugin.lastRun.lastAPSRun != null && LoopPlugin.lastRun.lastAPSRun.getTime() != 0 ? LoopPlugin.lastRun.lastAPSRun.toLocaleString() : ""); - lastEnactView.setText(LoopPlugin.lastRun.lastEnact != null && LoopPlugin.lastRun.lastEnact.getTime() != 0 ? LoopPlugin.lastRun.lastEnact.toLocaleString() : ""); - } + activity.runOnUiThread(() -> { + if (LoopPlugin.lastRun != null) { + requestView.setText(LoopPlugin.lastRun.request != null ? LoopPlugin.lastRun.request.toSpanned() : ""); + constraintsProcessedView.setText(LoopPlugin.lastRun.constraintsProcessed != null ? LoopPlugin.lastRun.constraintsProcessed.toSpanned() : ""); + sourceView.setText(LoopPlugin.lastRun.source != null ? LoopPlugin.lastRun.source : ""); + lastRunView.setText(LoopPlugin.lastRun.lastAPSRun != null && LoopPlugin.lastRun.lastAPSRun.getTime() != 0 ? LoopPlugin.lastRun.lastAPSRun.toLocaleString() : ""); + lastEnactView.setText(LoopPlugin.lastRun.lastEnact != null && LoopPlugin.lastRun.lastEnact.getTime() != 0 ? LoopPlugin.lastRun.lastEnact.toLocaleString() : ""); + tbrSetByPumpView.setText(LoopPlugin.lastRun.tbrSetByPump != null ? LoopPlugin.lastRun.tbrSetByPump.toSpanned() : ""); + smbSetByPumpView.setText(LoopPlugin.lastRun.smbSetByPump != null ? LoopPlugin.lastRun.smbSetByPump.toSpanned() : ""); } }); } @@ -117,16 +100,14 @@ public class LoopFragment extends SubscriberFragment implements View.OnClickList void clearGUI() { Activity activity = getActivity(); if (activity != null) - activity.runOnUiThread(new Runnable() { - @Override - public void run() { - requestView.setText(""); - constraintsProcessedView.setText(""); - setByPumpView.setText(""); - sourceView.setText(""); - lastRunView.setText(""); - lastEnactView.setText(""); - } + activity.runOnUiThread(() -> { + requestView.setText(""); + constraintsProcessedView.setText(""); + sourceView.setText(""); + lastRunView.setText(""); + lastEnactView.setText(""); + tbrSetByPumpView.setText(""); + smbSetByPumpView.setText(""); }); } } diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java index 2fff17a9e7..b108f0d233 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/LoopPlugin.java @@ -30,7 +30,6 @@ import info.nightscout.androidaps.interfaces.PluginBase; import info.nightscout.androidaps.interfaces.PumpInterface; import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin; import info.nightscout.androidaps.plugins.IobCobCalculator.events.EventAutosensCalculationFinished; -import info.nightscout.androidaps.plugins.Loop.events.EventLoopResult; import info.nightscout.androidaps.plugins.Loop.events.EventLoopSetLastRunGui; import info.nightscout.androidaps.plugins.Loop.events.EventLoopUpdateGui; import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification; @@ -65,7 +64,8 @@ public class LoopPlugin implements PluginBase { public class LastRun { public APSResult request = null; public APSResult constraintsProcessed = null; - public PumpEnactResult setByPump = null; + public PumpEnactResult tbrSetByPump = null; + public PumpEnactResult smbSetByPump = null; public String source = null; public Date lastAPSRun = null; public Date lastEnact = null; @@ -266,7 +266,7 @@ public class LoopPlugin implements PluginBase { if (!isEnabled(PluginBase.LOOP)) return; - if (MainApp.getConfigBuilder().getProfile() == null) { + if (!MainApp.getConfigBuilder().isProfileValid("Loop")) { log.debug(MainApp.sResources.getString(R.string.noprofileselected)); MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.noprofileselected))); return; @@ -304,7 +304,8 @@ public class LoopPlugin implements PluginBase { lastRun.constraintsProcessed = resultAfterConstraints; lastRun.lastAPSRun = new Date(); lastRun.source = ((PluginBase) usedAPS).getName(); - lastRun.setByPump = null; + lastRun.tbrSetByPump = null; + lastRun.smbSetByPump = null; NSUpload.uploadDeviceStatus(); @@ -320,31 +321,36 @@ public class LoopPlugin implements PluginBase { return; } - MainApp.bus().post(new EventLoopResult(resultAfterConstraints)); - if (constraintsInterface.isClosedModeEnabled()) { if (result.isChangeRequested()) { final PumpEnactResult waiting = new PumpEnactResult(); - final PumpEnactResult previousResult = lastRun.setByPump; waiting.queued = true; - lastRun.setByPump = waiting; + lastRun.tbrSetByPump = waiting; MainApp.bus().post(new EventLoopUpdateGui()); - MainApp.getConfigBuilder().applyAPSRequest(resultAfterConstraints, new Callback() { + FabricPrivacy.getInstance().logCustom(new CustomEvent("APSRequest")); + MainApp.getConfigBuilder().applyTBRRequest(resultAfterConstraints, new Callback() { @Override public void run() { - FabricPrivacy.getInstance().logCustom(new CustomEvent("APSRequest")); if (result.enacted || result.success) { - lastRun.setByPump = result; + lastRun.tbrSetByPump = result; + lastRun.lastEnact = lastRun.lastAPSRun; + } + MainApp.bus().post(new EventLoopUpdateGui()); + } + }); + MainApp.getConfigBuilder().applySMBRequest(resultAfterConstraints, new Callback() { + @Override + public void run() { + if (result.enacted || result.success) { + lastRun.smbSetByPump = result; lastRun.lastEnact = lastRun.lastAPSRun; - } else { - lastRun.setByPump = previousResult; } MainApp.bus().post(new EventLoopUpdateGui()); } }); } else { - lastRun.setByPump = null; - lastRun.source = null; + lastRun.tbrSetByPump = null; + lastRun.smbSetByPump = null; } } else { if (result.isChangeRequested() && allowNotification) { diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopResult.java b/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopResult.java deleted file mode 100644 index 5cbb24ea22..0000000000 --- a/app/src/main/java/info/nightscout/androidaps/plugins/Loop/events/EventLoopResult.java +++ /dev/null @@ -1,12 +0,0 @@ -package info.nightscout.androidaps.plugins.Loop.events; - -import info.nightscout.androidaps.plugins.Loop.APSResult; - -public class EventLoopResult { - public final APSResult apsResult; - - public EventLoopResult(APSResult apsResult) { - this.apsResult = apsResult; - } -} - diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java index 41fea12940..eedf9b8053 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java +++ b/app/src/main/java/info/nightscout/androidaps/plugins/OpenAPSSMB/DetermineBasalAdapterSMBJS.java @@ -246,11 +246,12 @@ public class DetermineBasalAdapterSMBJS { mProfile.put("remainingCarbsCap", SMBDefaults.remainingCarbsCap); mProfile.put("enableUAM", SP.getBoolean(R.string.key_use_uam, false)); mProfile.put("A52_risk_enable", SMBDefaults.A52_risk_enable); - mProfile.put("enableSMB_with_COB", SP.getBoolean(R.string.key_use_smb, false) && SP.getBoolean(R.string.key_enableSMB_with_COB, false)); - mProfile.put("enableSMB_with_temptarget", SP.getBoolean(R.string.key_use_smb, false) && SP.getBoolean(R.string.key_enableSMB_with_temptarget, false)); - mProfile.put("allowSMB_with_high_temptarget", SP.getBoolean(R.string.key_use_smb, false) && SP.getBoolean(R.string.key_allowSMB_with_high_temptarget, false)); - mProfile.put("enableSMB_always", SP.getBoolean(R.string.key_use_smb, false) && SP.getBoolean(R.string.key_enableSMB_always, false) && ConfigBuilderPlugin.getActiveBgSource().advancedFilteringSupported()); - mProfile.put("enableSMB_after_carbs", SP.getBoolean(R.string.key_use_smb, false) && SP.getBoolean(R.string.key_enableSMB_after_carbs, false) && ConfigBuilderPlugin.getActiveBgSource().advancedFilteringSupported()); + boolean SMBEnabled = SP.getBoolean(R.string.key_use_smb, false) && MainApp.getConfigBuilder().isClosedModeEnabled(); + mProfile.put("enableSMB_with_COB", SMBEnabled && SP.getBoolean(R.string.key_enableSMB_with_COB, false)); + mProfile.put("enableSMB_with_temptarget", SMBEnabled && SP.getBoolean(R.string.key_enableSMB_with_temptarget, false)); + mProfile.put("allowSMB_with_high_temptarget", SMBEnabled && SP.getBoolean(R.string.key_allowSMB_with_high_temptarget, false)); + mProfile.put("enableSMB_always", SMBEnabled && SP.getBoolean(R.string.key_enableSMB_always, false) && ConfigBuilderPlugin.getActiveBgSource().advancedFilteringSupported()); + mProfile.put("enableSMB_after_carbs", SMBEnabled && SP.getBoolean(R.string.key_enableSMB_after_carbs, false) && ConfigBuilderPlugin.getActiveBgSource().advancedFilteringSupported()); mProfile.put("maxSMBBasalMinutes", SP.getInt("key_smbmaxminutes", SMBDefaults.maxSMBBasalMinutes)); mProfile.put("carbsReqThreshold", SMBDefaults.carbsReqThreshold); diff --git a/app/src/main/java/info/nightscout/utils/NSUpload.java b/app/src/main/java/info/nightscout/utils/NSUpload.java index 690b239128..a6ba790ad3 100644 --- a/app/src/main/java/info/nightscout/utils/NSUpload.java +++ b/app/src/main/java/info/nightscout/utils/NSUpload.java @@ -34,8 +34,6 @@ import info.nightscout.androidaps.plugins.Loop.APSResult; import info.nightscout.androidaps.plugins.Loop.DeviceStatus; import info.nightscout.androidaps.plugins.Loop.LoopPlugin; import info.nightscout.androidaps.plugins.NSClientInternal.data.DbLogger; -import info.nightscout.androidaps.plugins.OpenAPSAMA.DetermineBasalResultAMA; -import info.nightscout.androidaps.plugins.OpenAPSMA.DetermineBasalResultMA; /** * Created by mike on 26.05.2017. @@ -202,17 +200,26 @@ public class NSUpload { deviceStatus.iob = lastRun.request.iob.json(); deviceStatus.iob.put("time", DateUtil.toISOString(lastRun.lastAPSRun)); - if (lastRun.setByPump != null && lastRun.setByPump.enacted) { // enacted + JSONObject requested = new JSONObject(); + + if (lastRun.tbrSetByPump != null && lastRun.tbrSetByPump.enacted) { // enacted deviceStatus.enacted = lastRun.request.json(); - deviceStatus.enacted.put("rate", lastRun.setByPump.json().get("rate")); - deviceStatus.enacted.put("duration", lastRun.setByPump.json().get("duration")); + deviceStatus.enacted.put("rate", lastRun.tbrSetByPump.json().get("rate")); + deviceStatus.enacted.put("duration", lastRun.tbrSetByPump.json().get("duration")); deviceStatus.enacted.put("recieved", true); - JSONObject requested = new JSONObject(); requested.put("duration", lastRun.request.duration); requested.put("rate", lastRun.request.rate); requested.put("temp", "absolute"); deviceStatus.enacted.put("requested", requested); } + if (lastRun.smbSetByPump != null && lastRun.smbSetByPump.enacted) { // enacted + if (deviceStatus.enacted == null) { + deviceStatus.enacted = lastRun.request.json(); + } + deviceStatus.enacted.put("smb", lastRun.smbSetByPump.bolusDelivered); + requested.put("smb", lastRun.request.smb); + deviceStatus.enacted.put("requested", requested); + } } else { log.debug("OpenAPS data too old to upload"); } diff --git a/app/src/main/res/layout/loop_fragment.xml b/app/src/main/res/layout/loop_fragment.xml index fb6038dcb3..36f310cc81 100644 --- a/app/src/main/res/layout/loop_fragment.xml +++ b/app/src/main/res/layout/loop_fragment.xml @@ -256,7 +256,7 @@ android:layout_weight="2" android:gravity="end" android:paddingRight="5dp" - android:text="@string/loop_setbypump_label" + android:text="@string/loop_tbrsetbypump_label" android:textSize="14sp" /> + + + + + + + + + + + + Loop APS След ограничения - Зададено на помпата Последно зададено OK Откажи diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index e396a0230e..b15e1954cc 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -68,7 +68,8 @@ Smyčka APS Po zpracování omezení - Nastaveno pumpou + Bazál nastavený pumpou + SMB provedené pumpou SMYČKA ZAKÁZÁNA OMEZENÍM Ručně spuštěno Minimální trvání diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 667ad8e961..9646510510 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -160,7 +160,6 @@ Beschränkungen angewendet! Beschränkungen wurden verletzt oder Limit erreicht Czech - Gesetzt durch Pumpe LOOP DEAKTIVIERT DURCH BESCHRÄNKUNGEN Beschränkungen angewendet Loop diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index fd685edbea..9b17d973ea 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -100,7 +100,6 @@ Κύκλωμα APS Μετά από επεξεργασία περιορισμών - Ρυθμίστε με αντλία Τελευταία Εφαρμογή ΟΚ Ακύρωση diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index e12a889785..90270b0a97 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -92,7 +92,6 @@ Lazo APS Tras procesar limitaciones - Definido por la bomba Última aceptada OK Cancelar diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index b83c59b50d..5d4b74043b 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -95,7 +95,6 @@ Loop APS Après traitement des restrictions - "Défini par pompe " Dérnière mise en marche OK Annuler diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 5f4d22246b..566119256b 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -189,7 +189,6 @@ Delta acg. esteso Loop APS - Set Micro Loop Loop disabilitato da vincolo Loop menu diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 714dafaa92..d476543129 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -98,7 +98,6 @@ Loop APS 제약 적용 후 - 펌프 설정 최근 주입 OK 취소 diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index d625f6e204..f9c5e0799c 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -218,7 +218,6 @@ Loop APS Berekening met toepassing van limieten - Gedefinieerd door de pomp LOOP Italiano Nederlands diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index 588fc2ceb5..645c71bcc6 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -98,7 +98,6 @@ Loop APS Constrângeri după procesare - Setat de pompă Ultima acțiune Doriți reîncărcarea tratamentelor din Nightscout Doriți reîncărcarea țintelor temporare din Nightscout diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index bb77a9f2be..81b7017305 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -234,7 +234,6 @@ замкнутый цикл APS после наложенных ограничений - задано помпой ЗЦ ЗЦ ОТМЕНЕН ОГРАНИЧЕНИЯМИ меню ЗЦ diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 5e83108bb3..b8ecdfb8a3 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -218,7 +218,6 @@ Loop APS Efter avklarade begränsningar - Inställning i pump LOOP LOOP STOPPAD PGA BEGRÄNSNINGAR Loop meny diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7cd12ea540..51a0e1538f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -104,7 +104,7 @@ Loop APS After processed constraints - Set by pump + Temp basal set by pump Last enacted OK Cancel @@ -981,5 +981,6 @@ Bolus will be recorded only Autobackfill missig BGs from NS ns_autobackfill + SMB set by pump