Merge branch 'dev' into queue

This commit is contained in:
Milos Kozak 2017-11-22 19:44:16 +01:00
commit dfd0218a6a
8 changed files with 83 additions and 47 deletions

View file

@ -30,21 +30,21 @@ public class Profile {
private JSONObject json; private JSONObject json;
private String units = null; private String units = null;
double dia = Constants.defaultDIA; private double dia = Constants.defaultDIA;
TimeZone timeZone = TimeZone.getDefault(); private TimeZone timeZone = TimeZone.getDefault();
JSONArray isf; private JSONArray isf;
private LongSparseArray<Double> isf_v = null; // oldest at index 0 private LongSparseArray<Double> isf_v = null; // oldest at index 0
JSONArray ic; private JSONArray ic;
private LongSparseArray<Double> ic_v = null; // oldest at index 0 private LongSparseArray<Double> ic_v = null; // oldest at index 0
JSONArray basal; private JSONArray basal;
private LongSparseArray<Double> basal_v = null; // oldest at index 0 private LongSparseArray<Double> basal_v = null; // oldest at index 0
JSONArray targetLow; private JSONArray targetLow;
private LongSparseArray<Double> targetLow_v = null; // oldest at index 0 private LongSparseArray<Double> targetLow_v = null; // oldest at index 0
JSONArray targetHigh; private JSONArray targetHigh;
private LongSparseArray<Double> targetHigh_v = null; // oldest at index 0 private LongSparseArray<Double> targetHigh_v = null; // oldest at index 0
int percentage = 100; private int percentage = 100;
int timeshift = 0; private int timeshift = 0;
public Profile(JSONObject json, String units) { public Profile(JSONObject json, String units) {
this(json, 100, 0); this(json, 100, 0);
@ -206,7 +206,7 @@ public class Profile {
return shiftedTime; return shiftedTime;
} }
double getMultiplier(LongSparseArray<Double> array) { private double getMultiplier(LongSparseArray<Double> array) {
double multiplier = 1d; double multiplier = 1d;
if (array == isf_v) if (array == isf_v)
@ -220,7 +220,7 @@ public class Profile {
return multiplier; return multiplier;
} }
double getMultiplier(JSONArray array) { private double getMultiplier(JSONArray array) {
double multiplier = 1d; double multiplier = 1d;
if (array == isf) if (array == isf)

View file

@ -32,6 +32,56 @@ public class PumpEnactResult extends Object {
public boolean queued = false; public boolean queued = false;
public PumpEnactResult success(boolean success) {
this.success = success;
return this;
}
public PumpEnactResult enacted(boolean enacted) {
this.enacted = enacted;
return this;
}
public PumpEnactResult comment(String comment) {
this.comment = comment;
return this;
}
public PumpEnactResult duration(Integer duration) {
this.duration = duration;
return this;
}
public PumpEnactResult absolute(Double absolute) {
this.absolute = absolute;
return this;
}
public PumpEnactResult isPercent(boolean isPercent) {
this.isPercent = isPercent;
return this;
}
public PumpEnactResult isTempCancel(boolean isTempCancel) {
this.isTempCancel = isTempCancel;
return this;
}
public PumpEnactResult bolusDelivered(Double bolusDelivered) {
this.bolusDelivered = bolusDelivered;
return this;
}
public PumpEnactResult carbsDelivered(Double carbsDelivered) {
this.carbsDelivered = carbsDelivered;
return this;
}
public PumpEnactResult queued(boolean queued) {
this.queued = queued;
return this;
}
public String log() { public String log() {
return "Success: " + success + " Enacted: " + enacted + " Comment: " + comment + " Duration: " + duration + " Absolute: " + absolute + " Percent: " + percent + " IsPercent: " + isPercent + " Queued: " + queued; return "Success: " + success + " Enacted: " + enacted + " Comment: " + comment + " Duration: " + duration + " Absolute: " + absolute + " Percent: " + percent + " IsPercent: " + isPercent + " Queued: " + queued;
} }
@ -89,31 +139,6 @@ public class PumpEnactResult extends Object {
public PumpEnactResult() { public PumpEnactResult() {
} }
public PumpEnactResult success(boolean success) {
this.success = success;
return this;
}
public PumpEnactResult enacted(boolean enacted) {
this.enacted = enacted;
return this;
}
public PumpEnactResult comment(String comment) {
this.comment = comment;
return this;
}
public PumpEnactResult absolute(double absolute) {
this.absolute = absolute;
return this;
}
public PumpEnactResult duration(int duration) {
this.duration = duration;
return this;
}
public JSONObject json() { public JSONObject json() {
JSONObject result = new JSONObject(); JSONObject result = new JSONObject();
try { try {

View file

@ -158,7 +158,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
tempBasal.setVisibility(View.GONE); tempBasal.setVisibility(View.GONE);
tempBasalCancel.setVisibility(View.VISIBLE); tempBasalCancel.setVisibility(View.VISIBLE);
final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis()); final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
tempBasalCancel.setText(MainApp.instance().getString(R.string.cancel) + "\n" + activeTemp.toStringShort()); tempBasalCancel.setText(MainApp.instance().getString(R.string.cancel) + " " + activeTemp.toStringShort());
} else { } else {
tempBasal.setVisibility(View.VISIBLE); tempBasal.setVisibility(View.VISIBLE);
tempBasalCancel.setVisibility(View.GONE); tempBasalCancel.setVisibility(View.GONE);

View file

@ -414,7 +414,9 @@ public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, Tr
} }
return false; return false;
} }
} else if (isTempBasalInProgress() && Math.abs(request.rate - getTempBasalAbsoluteRateHistory()) < pump.getPumpDescription().basalStep) { } else if (isTempBasalInProgress()
&& getTempBasalRemainingMinutesFromHistory() > 5
&& Math.abs(request.rate - getTempBasalAbsoluteRateHistory()) < pump.getPumpDescription().basalStep) {
if (Config.logCongigBuilderActions) if (Config.logCongigBuilderActions)
log.debug("applyAPSRequest: Temp basal set correctly"); log.debug("applyAPSRequest: Temp basal set correctly");
if (callback != null) { if (callback != null) {

View file

@ -96,6 +96,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
case R.id.overview_bolusprogress_stop: case R.id.overview_bolusprogress_stop:
log.debug("Stop bolus delivery button pressed"); log.debug("Stop bolus delivery button pressed");
stopPressedView.setVisibility(View.VISIBLE); stopPressedView.setVisibility(View.VISIBLE);
stopButton.setVisibility(View.INVISIBLE);
ConfigBuilderPlugin.getActivePump().stopBolusDelivering(); ConfigBuilderPlugin.getActivePump().stopBolusDelivering();
break; break;
} }

View file

@ -95,25 +95,28 @@ public class PersistentNotificationPlugin implements PluginBase {
@Override @Override
public void setFragmentEnabled(int type, boolean fragmentEnabled) { public void setFragmentEnabled(int type, boolean fragmentEnabled) {
if (getType() == type) { if (getType() == type) {
this.fragmentEnabled = fragmentEnabled; this.fragmentEnabled = fragmentEnabled;
enableDisableNotification(fragmentEnabled);
checkBusRegistration(); checkBusRegistration();
//updateNotification();
} }
} }
private void updateNotification() { private void enableDisableNotification(boolean fragmentEnabled) {
if (!fragmentEnabled) { if (!fragmentEnabled) {
NotificationManager mNotificationManager = NotificationManager mNotificationManager =
(NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.cancel(ONGOING_NOTIFICATION_ID); mNotificationManager.cancel(ONGOING_NOTIFICATION_ID);
} else {
updateNotification();
}
}
private void updateNotification() {
if (!fragmentEnabled) {
return; return;
} }
String line1 = ctx.getString(R.string.noprofile); String line1 = ctx.getString(R.string.noprofile);
if (MainApp.getConfigBuilder().getActiveProfileInterface() == null || MainApp.getConfigBuilder().getProfile() == null) if (MainApp.getConfigBuilder().getActiveProfileInterface() == null || MainApp.getConfigBuilder().getProfile() == null)
@ -189,11 +192,16 @@ public class PersistentNotificationPlugin implements PluginBase {
private void checkBusRegistration() { private void checkBusRegistration() {
if (fragmentEnabled) { if (fragmentEnabled) {
MainApp.bus().register(this); try {
MainApp.bus().register(this);
} catch (IllegalArgumentException e) {
// already registered
}
} else { } else {
try { try {
MainApp.bus().unregister(this); MainApp.bus().unregister(this);
} catch (Exception e) { } catch (IllegalArgumentException e) {
// already unregistered
} }
} }
} }

View file

@ -52,7 +52,7 @@ public class VirtualPumpFragment extends SubscriberFragment {
public View onCreateView(LayoutInflater inflater, ViewGroup container, public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) { Bundle savedInstanceState) {
try { try {
View view = inflater.inflate(R.layout.vitualpump_fragment, container, false); View view = inflater.inflate(R.layout.virtualpump_fragment, container, false);
basaBasalRateView = (TextView) view.findViewById(R.id.virtualpump_basabasalrate); basaBasalRateView = (TextView) view.findViewById(R.id.virtualpump_basabasalrate);
tempBasalView = (TextView) view.findViewById(R.id.virtualpump_tempbasal); tempBasalView = (TextView) view.findViewById(R.id.virtualpump_tempbasal);
extendedBolusView = (TextView) view.findViewById(R.id.virtualpump_extendedbolus); extendedBolusView = (TextView) view.findViewById(R.id.virtualpump_extendedbolus);