split enacting TRB and SMB
This commit is contained in:
parent
390e5d6d11
commit
db7671cd23
21 changed files with 188 additions and 123 deletions
|
@ -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 += "<br><b>" + MainApp.sResources.getString(R.string.enacted) + "</b>: " + enacted;
|
||||
ret += "<br><b>" + MainApp.sResources.getString(R.string.comment) + "</b>: " + comment;
|
||||
ret += "<br><b>" + MainApp.sResources.getString(R.string.smb_shortname) + "</b>: " + bolusDelivered + "U";
|
||||
} else if (isTempCancel) {
|
||||
ret += "<br><b>" + MainApp.sResources.getString(R.string.enacted) + "</b>: " + enacted;
|
||||
ret += "<br><b>" + MainApp.sResources.getString(R.string.comment) + "</b>: " + comment +
|
||||
"<br>" + 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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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:
|
||||
@OnClick(R.id.loop_run)
|
||||
void onRunClick() {
|
||||
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();
|
||||
new Thread(() -> LoopPlugin.getPlugin().invoke("Loop button", true)).start();
|
||||
FabricPrivacy.getInstance().logCustom(new CustomEvent("Loop_Run"));
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@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() {
|
||||
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() : "");
|
||||
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() : "");
|
||||
}
|
||||
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() {
|
||||
activity.runOnUiThread(() -> {
|
||||
requestView.setText("");
|
||||
constraintsProcessedView.setText("");
|
||||
setByPumpView.setText("");
|
||||
sourceView.setText("");
|
||||
lastRunView.setText("");
|
||||
lastEnactView.setText("");
|
||||
}
|
||||
tbrSetByPumpView.setText("");
|
||||
smbSetByPumpView.setText("");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
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("recieved", true);
|
||||
JSONObject requested = new JSONObject();
|
||||
|
||||
if (lastRun.tbrSetByPump != null && lastRun.tbrSetByPump.enacted) { // enacted
|
||||
deviceStatus.enacted = lastRun.request.json();
|
||||
deviceStatus.enacted.put("rate", lastRun.tbrSetByPump.json().get("rate"));
|
||||
deviceStatus.enacted.put("duration", lastRun.tbrSetByPump.json().get("duration"));
|
||||
deviceStatus.enacted.put("recieved", true);
|
||||
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");
|
||||
}
|
||||
|
|
|
@ -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" />
|
||||
|
||||
<TextView
|
||||
|
@ -270,7 +270,52 @@
|
|||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loop_setbypump"
|
||||
android:id="@+id/loop_tbrsetbypump"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:gravity="start"
|
||||
android:paddingLeft="5dp"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="14sp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="2dip"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:layout_marginLeft="20dp"
|
||||
android:layout_marginRight="20dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:background="@color/listdelimiter" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="2"
|
||||
android:gravity="end"
|
||||
android:paddingRight="5dp"
|
||||
android:text="@string/loop_smbsetbypump_label"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="5dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="0"
|
||||
android:gravity="center_horizontal"
|
||||
android:paddingEnd="2dp"
|
||||
android:paddingStart="2dp"
|
||||
android:text=":"
|
||||
android:textSize="14sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/loop_smbsetbypump"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
|
|
|
@ -98,7 +98,6 @@
|
|||
<string name="configbuilder_loop">Loop</string>
|
||||
<string name="loop_aps_label">APS</string>
|
||||
<string name="loop_constraintsprocessed_label">След ограничения</string>
|
||||
<string name="loop_setbypump_label">Зададено на помпата</string>
|
||||
<string name="openapsma_lastenact_label">Последно зададено</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">Откажи</string>
|
||||
|
|
|
@ -68,7 +68,8 @@
|
|||
<string name="loop">Smyčka</string>
|
||||
<string name="loop_aps_label">APS</string>
|
||||
<string name="loop_constraintsprocessed_label">Po zpracování omezení</string>
|
||||
<string name="loop_setbypump_label">Nastaveno pumpou</string>
|
||||
<string name="loop_tbrsetbypump_label">Bazál nastavený pumpou</string>
|
||||
<string name="loop_smbsetbypump_label">SMB provedené pumpou</string>
|
||||
<string name="loopdisabled">SMYČKA ZAKÁZÁNA OMEZENÍM</string>
|
||||
<string name="objectives_manualenacts">Ručně spuštěno</string>
|
||||
<string name="objectives_minimalduration">Minimální trvání</string>
|
||||
|
|
|
@ -160,7 +160,6 @@
|
|||
<string name="constraintapllied">Beschränkungen angewendet!</string>
|
||||
<string name="constraints_violation">Beschränkungen wurden verletzt oder Limit erreicht</string>
|
||||
<string name="cs_lang">Czech</string>
|
||||
<string name="loop_setbypump_label">Gesetzt durch Pumpe</string>
|
||||
<string name="loopdisabled">LOOP DEAKTIVIERT DURCH BESCHRÄNKUNGEN</string>
|
||||
<string name="loop_constraintsprocessed_label">Beschränkungen angewendet</string>
|
||||
<string name="loop">Loop</string>
|
||||
|
|
|
@ -100,7 +100,6 @@
|
|||
<string name="configbuilder_loop">Κύκλωμα</string>
|
||||
<string name="loop_aps_label">APS</string>
|
||||
<string name="loop_constraintsprocessed_label">Μετά από επεξεργασία περιορισμών</string>
|
||||
<string name="loop_setbypump_label">Ρυθμίστε με αντλία</string>
|
||||
<string name="openapsma_lastenact_label">Τελευταία Εφαρμογή</string>
|
||||
<string name="ok">ΟΚ</string>
|
||||
<string name="cancel">Ακύρωση</string>
|
||||
|
|
|
@ -92,7 +92,6 @@
|
|||
<string name="configbuilder_loop">Lazo</string>
|
||||
<string name="loop_aps_label">APS</string>
|
||||
<string name="loop_constraintsprocessed_label">Tras procesar limitaciones</string>
|
||||
<string name="loop_setbypump_label">Definido por la bomba</string>
|
||||
<string name="openapsma_lastenact_label">Última aceptada</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">Cancelar</string>
|
||||
|
|
|
@ -95,7 +95,6 @@
|
|||
<string name="configbuilder_loop">Loop</string>
|
||||
<string name="loop_aps_label">APS</string>
|
||||
<string name="loop_constraintsprocessed_label">Après traitement des restrictions</string>
|
||||
<string name="loop_setbypump_label">"Défini par pompe "</string>
|
||||
<string name="openapsma_lastenact_label">Dérnière mise en marche</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">Annuler</string>
|
||||
|
|
|
@ -189,7 +189,6 @@
|
|||
<string name="long_avgdelta">Delta acg. esteso</string>
|
||||
<string name="loop">Loop</string>
|
||||
<string name="loop_aps_label">APS</string>
|
||||
<string name="loop_setbypump_label">Set Micro</string>
|
||||
<string name="loop_shortname">Loop</string>
|
||||
<string name="loopdisabled">Loop disabilitato da vincolo</string>
|
||||
<string name="loopmenu">Loop menu</string>
|
||||
|
|
|
@ -98,7 +98,6 @@
|
|||
<string name="configbuilder_loop">Loop</string>
|
||||
<string name="loop_aps_label">APS</string>
|
||||
<string name="loop_constraintsprocessed_label">제약 적용 후</string>
|
||||
<string name="loop_setbypump_label">펌프 설정</string>
|
||||
<string name="openapsma_lastenact_label">최근 주입</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">취소</string>
|
||||
|
|
|
@ -218,7 +218,6 @@
|
|||
<string name="loop">Loop</string>
|
||||
<string name="loop_aps_label">APS</string>
|
||||
<string name="loop_constraintsprocessed_label">Berekening met toepassing van limieten</string>
|
||||
<string name="loop_setbypump_label">Gedefinieerd door de pomp</string>
|
||||
<string name="loop_shortname">LOOP</string>
|
||||
<string name="it_lang">Italiano</string>
|
||||
<string name="nl_lang">Nederlands</string>
|
||||
|
|
|
@ -98,7 +98,6 @@
|
|||
<string name="configbuilder_loop">Loop</string>
|
||||
<string name="loop_aps_label">APS</string>
|
||||
<string name="loop_constraintsprocessed_label">Constrângeri după procesare<string>
|
||||
<string name="loop_setbypump_label">Setat de pompă</string>
|
||||
<string name="openapsma_lastenact_label">Ultima acțiune</string>
|
||||
<string name="refreshtreatmentsfromnightscout">Doriți reîncărcarea tratamentelor din Nightscout</string>
|
||||
<string name="refreshtemptargetsfromnightscout">Doriți reîncărcarea țintelor temporare din Nightscout</string>
|
||||
|
|
|
@ -234,7 +234,6 @@
|
|||
<string name="loop">замкнутый цикл</string>
|
||||
<string name="loop_aps_label">APS</string>
|
||||
<string name="loop_constraintsprocessed_label">после наложенных ограничений</string>
|
||||
<string name="loop_setbypump_label">задано помпой</string>
|
||||
<string name="loop_shortname">ЗЦ</string>
|
||||
<string name="loopdisabled">ЗЦ ОТМЕНЕН ОГРАНИЧЕНИЯМИ</string>
|
||||
<string name="loopmenu">меню ЗЦ</string>
|
||||
|
|
|
@ -218,7 +218,6 @@
|
|||
<string name="loop">Loop</string>
|
||||
<string name="loop_aps_label">APS</string>
|
||||
<string name="loop_constraintsprocessed_label">Efter avklarade begränsningar</string>
|
||||
<string name="loop_setbypump_label">Inställning i pump</string>
|
||||
<string name="loop_shortname">LOOP</string>
|
||||
<string name="loopdisabled">LOOP STOPPAD PGA BEGRÄNSNINGAR</string>
|
||||
<string name="loopmenu">Loop meny</string>
|
||||
|
|
|
@ -104,7 +104,7 @@
|
|||
<string name="configbuilder_loop">Loop</string>
|
||||
<string name="loop_aps_label">APS</string>
|
||||
<string name="loop_constraintsprocessed_label">After processed constraints</string>
|
||||
<string name="loop_setbypump_label">Set by pump</string>
|
||||
<string name="loop_tbrsetbypump_label">Temp basal set by pump</string>
|
||||
<string name="openapsma_lastenact_label">Last enacted</string>
|
||||
<string name="ok">OK</string>
|
||||
<string name="cancel">Cancel</string>
|
||||
|
@ -981,5 +981,6 @@
|
|||
<string name="bolusrecordedonly">Bolus will be recorded only</string>
|
||||
<string name="ns_autobackfill">Autobackfill missig BGs from NS</string>
|
||||
<string name="key_ns_autobackfill" translatable="false">ns_autobackfill</string>
|
||||
<string name="loop_smbsetbypump_label">SMB set by pump</string>
|
||||
</resources>
|
||||
|
||||
|
|
Loading…
Reference in a new issue