refactor pump interface out of ConfigBuilder, remove handlers
This commit is contained in:
parent
21ae42d37b
commit
3ab235f829
|
@ -89,6 +89,31 @@ public class PumpEnactResult extends Object {
|
|||
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() {
|
||||
JSONObject result = new JSONObject();
|
||||
try {
|
||||
|
|
|
@ -3,8 +3,6 @@ package info.nightscout.androidaps.plugins.Actions;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -34,6 +32,7 @@ import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
|||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||
import info.nightscout.androidaps.plugins.Common.SubscriberFragment;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
|
||||
/**
|
||||
* A simple {@link Fragment} subclass.
|
||||
|
@ -54,16 +53,8 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
|||
Button tempBasalCancel;
|
||||
Button fill;
|
||||
|
||||
private static Handler sHandler;
|
||||
private static HandlerThread sHandlerThread;
|
||||
|
||||
public ActionsFragment() {
|
||||
super();
|
||||
if (sHandlerThread == null) {
|
||||
sHandlerThread = new HandlerThread(ActionsFragment.class.getSimpleName());
|
||||
sHandlerThread.start();
|
||||
sHandler = new Handler(sHandlerThread.getLooper());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -135,14 +126,15 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
|||
fill.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
boolean allowProfileSwitch = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile().getProfileList().size() > 1;
|
||||
if (!MainApp.getConfigBuilder().getPumpDescription().isSetBasalProfileCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || !allowProfileSwitch)
|
||||
if (!pump.getPumpDescription().isSetBasalProfileCapable || !pump.isInitialized() || pump.isSuspended() || !allowProfileSwitch)
|
||||
profileSwitch.setVisibility(View.GONE);
|
||||
else
|
||||
profileSwitch.setVisibility(View.VISIBLE);
|
||||
|
||||
|
||||
if (!MainApp.getConfigBuilder().getPumpDescription().isExtendedBolusCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended() || MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses()) {
|
||||
if (!pump.getPumpDescription().isExtendedBolusCapable || !pump.isInitialized() || pump.isSuspended() || pump.isFakingTempsByExtendedBoluses()) {
|
||||
extendedBolus.setVisibility(View.GONE);
|
||||
extendedBolusCancel.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
@ -158,7 +150,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
|||
}
|
||||
|
||||
|
||||
if (!MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended()) {
|
||||
if (!pump.getPumpDescription().isTempBasalCapable || !pump.isInitialized() || pump.isSuspended()) {
|
||||
tempBasal.setVisibility(View.GONE);
|
||||
tempBasalCancel.setVisibility(View.GONE);
|
||||
} else {
|
||||
|
@ -173,7 +165,7 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
|||
}
|
||||
}
|
||||
|
||||
if (!MainApp.getConfigBuilder().getPumpDescription().isRefillingCapable || !MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended())
|
||||
if (!pump.getPumpDescription().isRefillingCapable || !pump.isInitialized() || pump.isSuspended())
|
||||
fill.setVisibility(View.GONE);
|
||||
else
|
||||
fill.setVisibility(View.VISIBLE);
|
||||
|
@ -190,7 +182,6 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
|||
@Override
|
||||
public void onClick(View view) {
|
||||
FragmentManager manager = getFragmentManager();
|
||||
final PumpInterface pump = MainApp.getConfigBuilder();
|
||||
switch (view.getId()) {
|
||||
case R.id.actions_profileswitch:
|
||||
NewNSTreatmentDialog newDialog = new NewNSTreatmentDialog();
|
||||
|
@ -212,24 +203,14 @@ public class ActionsFragment extends SubscriberFragment implements View.OnClickL
|
|||
break;
|
||||
case R.id.actions_extendedbolus_cancel:
|
||||
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pump.cancelExtendedBolus();
|
||||
Answers.getInstance().logCustom(new CustomEvent("CancelExtended"));
|
||||
}
|
||||
});
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelExtended(null);
|
||||
Answers.getInstance().logCustom(new CustomEvent("CancelExtended"));
|
||||
}
|
||||
break;
|
||||
case R.id.actions_canceltempbasal:
|
||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
pump.cancelTempBasal(true);
|
||||
Answers.getInstance().logCustom(new CustomEvent("CancelTemp"));
|
||||
}
|
||||
});
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, null);
|
||||
Answers.getInstance().logCustom(new CustomEvent("CancelTemp"));
|
||||
}
|
||||
break;
|
||||
case R.id.actions_settempbasal:
|
||||
|
|
|
@ -61,7 +61,7 @@ public class FillDialog extends DialogFragment implements OnClickListener {
|
|||
getDialog().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
|
||||
|
||||
Double maxInsulin = MainApp.getConfigBuilder().applyBolusConstraints(Constants.bolusOnlyForCheckLimit);
|
||||
double bolusstep = MainApp.getConfigBuilder().getPumpDescription().bolusStep;
|
||||
double bolusstep = ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep;
|
||||
editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_insulinamount);
|
||||
editInsulin.setParams(0d, 0d, maxInsulin, bolusstep, new DecimalFormat("0.00"), false);
|
||||
|
||||
|
|
|
@ -2,15 +2,13 @@ package info.nightscout.androidaps.plugins.Actions.dialogs;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
|
||||
import com.crashlytics.android.answers.Answers;
|
||||
import com.crashlytics.android.answers.CustomEvent;
|
||||
|
@ -23,10 +21,9 @@ import java.text.DecimalFormat;
|
|||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.utils.NumberPicker;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
||||
|
@ -36,13 +33,7 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
|
|||
NumberPicker editInsulin;
|
||||
NumberPicker editDuration;
|
||||
|
||||
Handler mHandler;
|
||||
public static HandlerThread mHandlerThread;
|
||||
|
||||
public NewExtendedBolusDialog() {
|
||||
mHandlerThread = new HandlerThread(NewExtendedBolusDialog.class.getSimpleName());
|
||||
mHandlerThread.start();
|
||||
this.mHandler = new Handler(mHandlerThread.getLooper());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -56,8 +47,8 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
|
|||
editInsulin = (NumberPicker) view.findViewById(R.id.overview_newextendedbolus_insulin);
|
||||
editInsulin.setParams(0d, 0d, maxInsulin, 0.1d, new DecimalFormat("0.00"), false);
|
||||
|
||||
double extendedDurationStep = MainApp.getConfigBuilder().getPumpDescription().extendedBolusDurationStep;
|
||||
double extendedMaxDuration = MainApp.getConfigBuilder().getPumpDescription().extendedBolusMaxDuration;
|
||||
double extendedDurationStep = ConfigBuilderPlugin.getActivePump().getPumpDescription().extendedBolusDurationStep;
|
||||
double extendedMaxDuration = ConfigBuilderPlugin.getActivePump().getPumpDescription().extendedBolusMaxDuration;
|
||||
editDuration = (NumberPicker) view.findViewById(R.id.overview_newextendedbolus_duration);
|
||||
editDuration.setParams(extendedDurationStep, extendedDurationStep, extendedMaxDuration, extendedDurationStep, new DecimalFormat("0"), false);
|
||||
|
||||
|
@ -99,24 +90,15 @@ public class NewExtendedBolusDialog extends DialogFragment implements View.OnCli
|
|||
builder.setMessage(confirmMessage);
|
||||
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
final PumpInterface pump = MainApp.getConfigBuilder();
|
||||
mHandler.post(new Runnable() {
|
||||
ConfigBuilderPlugin.getCommandQueue().extendedBolus(finalInsulin, finalDurationInMinutes, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
PumpEnactResult result = pump.setExtendedBolus(finalInsulin, finalDurationInMinutes);
|
||||
if (!result.success) {
|
||||
try {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(context.getString(R.string.treatmentdeliveryerror));
|
||||
builder.setMessage(result.comment);
|
||||
builder.setPositiveButton(context.getString(R.string.ok), null);
|
||||
builder.show();
|
||||
} catch (WindowManager.BadTokenException | NullPointerException e) {
|
||||
// window has been destroyed
|
||||
Notification notification = new Notification(Notification.BOLUS_DELIVERY_ERROR, MainApp.sResources.getString(R.string.treatmentdeliveryerror), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
}
|
||||
}
|
||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||
i.putExtra("soundid", R.raw.boluserror);
|
||||
i.putExtra("status", result.comment);
|
||||
i.putExtra("title", MainApp.sResources.getString(R.string.treatmentdeliveryerror));
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
MainApp.instance().startActivity(i);
|
||||
}
|
||||
});
|
||||
Answers.getInstance().logCustom(new CustomEvent("ExtendedBolus"));
|
||||
|
|
|
@ -1,11 +1,9 @@
|
|||
package info.nightscout.androidaps.plugins.Actions.dialogs;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -26,9 +24,10 @@ import java.text.DecimalFormat;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.utils.NumberPicker;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
||||
|
@ -47,13 +46,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
|
|||
NumberPicker basalAbsolute;
|
||||
NumberPicker duration;
|
||||
|
||||
Handler mHandler;
|
||||
public static HandlerThread mHandlerThread;
|
||||
|
||||
public NewTempBasalDialog() {
|
||||
mHandlerThread = new HandlerThread(NewTempBasalDialog.class.getSimpleName());
|
||||
mHandlerThread.start();
|
||||
this.mHandler = new Handler(mHandlerThread.getLooper());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -70,7 +63,7 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
|
|||
absoluteRadio = (RadioButton) view.findViewById(R.id.overview_newtempbasal_absolute_radio);
|
||||
typeSelectorLayout = (LinearLayout) view.findViewById(R.id.overview_newtempbasal_typeselector_layout);
|
||||
|
||||
PumpDescription pumpDescription = MainApp.getConfigBuilder().getPumpDescription();
|
||||
PumpDescription pumpDescription = ConfigBuilderPlugin.getActivePump().getPumpDescription();
|
||||
|
||||
basalPercent = (NumberPicker) view.findViewById(R.id.overview_newtempbasal_basalpercentinput);
|
||||
double maxTempPercent = pumpDescription.maxTempPercent;
|
||||
|
@ -143,37 +136,29 @@ public class NewTempBasalDialog extends DialogFragment implements View.OnClickLi
|
|||
final Double finalBasal = absolute;
|
||||
final int finalDurationInMinutes = durationInMinutes;
|
||||
|
||||
final Context context = getContext();
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||
builder.setTitle(this.getContext().getString(R.string.confirmation));
|
||||
builder.setMessage(confirmMessage);
|
||||
builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
final PumpInterface pump = MainApp.getConfigBuilder();
|
||||
mHandler.post(new Runnable() {
|
||||
Callback callback = new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
PumpEnactResult result;
|
||||
if (setAsPercent) {
|
||||
result = pump.setTempBasalPercent(finalBasalPercent, finalDurationInMinutes);
|
||||
} else {
|
||||
result = pump.setTempBasalAbsolute(finalBasal, finalDurationInMinutes, true);
|
||||
}
|
||||
if (!result.success) {
|
||||
if (context instanceof Activity) {
|
||||
Activity activity = (Activity) context;
|
||||
if (activity.isFinishing()) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
builder.setTitle(MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
builder.setMessage(result.comment);
|
||||
builder.setPositiveButton(MainApp.sResources.getString(R.string.ok), null);
|
||||
builder.show();
|
||||
Intent i = new Intent(MainApp.instance(), ErrorHelperActivity.class);
|
||||
i.putExtra("soundid", R.raw.boluserror);
|
||||
i.putExtra("status", result.comment);
|
||||
i.putExtra("title", MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
MainApp.instance().startActivity(i);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
if (setAsPercent) {
|
||||
ConfigBuilderPlugin.getCommandQueue().tempBasalPercent(finalBasalPercent, finalDurationInMinutes, callback);
|
||||
} else {
|
||||
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(finalBasal, finalDurationInMinutes, true, callback);
|
||||
}
|
||||
Answers.getInstance().logCustom(new CustomEvent("TempBasal"));
|
||||
}
|
||||
});
|
||||
|
|
|
@ -3,9 +3,8 @@ package info.nightscout.androidaps.plugins.Careportal.Dialogs;
|
|||
|
||||
import android.app.Activity;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.Editable;
|
||||
|
@ -51,9 +50,10 @@ import info.nightscout.androidaps.db.ProfileSwitch;
|
|||
import info.nightscout.androidaps.db.Source;
|
||||
import info.nightscout.androidaps.db.TempTarget;
|
||||
import info.nightscout.androidaps.events.EventNewBasalProfile;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.Careportal.OptionsToShow;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
import info.nightscout.utils.NSUpload;
|
||||
import info.nightscout.utils.NumberPicker;
|
||||
|
@ -105,10 +105,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
|
||||
Date eventTime;
|
||||
|
||||
private static Handler sHandler;
|
||||
private static HandlerThread sHandlerThread;
|
||||
|
||||
|
||||
public void setOptions(OptionsToShow options, int event) {
|
||||
this.options = options;
|
||||
this.event = MainApp.sResources.getString(event);
|
||||
|
@ -116,11 +112,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
|
||||
public NewNSTreatmentDialog() {
|
||||
super();
|
||||
if (sHandlerThread == null) {
|
||||
sHandlerThread = new HandlerThread(NewNSTreatmentDialog.class.getSimpleName());
|
||||
sHandlerThread.start();
|
||||
sHandler = new Handler(sHandlerThread.getLooper());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -138,7 +129,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
if (options==null) return null;
|
||||
if (options == null) return null;
|
||||
getDialog().setTitle(getString(options.eventName));
|
||||
setStyle(DialogFragment.STYLE_NORMAL, getTheme());
|
||||
View view = inflater.inflate(R.layout.careportal_newnstreatment_dialog, container, false);
|
||||
|
@ -203,27 +194,30 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||
double defaultDuration = 0;
|
||||
double defaultTarget = 0;
|
||||
if(profile!=null){
|
||||
if (profile != null) {
|
||||
defaultTarget = bg.doubleValue();
|
||||
}
|
||||
boolean erase = false;
|
||||
|
||||
if(MainApp.sResources.getString(R.string.eatingsoon).equals(reasonList.get(position))){
|
||||
if (MainApp.sResources.getString(R.string.eatingsoon).equals(reasonList.get(position))) {
|
||||
defaultDuration = SP.getDouble(R.string.key_eatingsoon_duration, 0d);
|
||||
defaultTarget = SP.getDouble(R.string.key_eatingsoon_target, 0d);;
|
||||
} else if (MainApp.sResources.getString(R.string.activity).equals(reasonList.get(position))){
|
||||
defaultDuration = SP.getDouble(R.string.key_activity_duration, 0d);;
|
||||
defaultTarget = SP.getDouble(R.string.key_activity_target, 0d);;
|
||||
defaultTarget = SP.getDouble(R.string.key_eatingsoon_target, 0d);
|
||||
;
|
||||
} else if (MainApp.sResources.getString(R.string.activity).equals(reasonList.get(position))) {
|
||||
defaultDuration = SP.getDouble(R.string.key_activity_duration, 0d);
|
||||
;
|
||||
defaultTarget = SP.getDouble(R.string.key_activity_target, 0d);
|
||||
;
|
||||
} else {
|
||||
defaultDuration = 0;
|
||||
erase = true;
|
||||
}
|
||||
if(defaultTarget != 0 || erase){
|
||||
if (defaultTarget != 0 || erase) {
|
||||
editTemptarget.setValue(defaultTarget);
|
||||
}
|
||||
if(defaultDuration != 0){
|
||||
if (defaultDuration != 0) {
|
||||
editDuration.setValue(defaultDuration);
|
||||
} else if (erase){
|
||||
} else if (erase) {
|
||||
editDuration.setValue(0d);
|
||||
}
|
||||
}
|
||||
|
@ -237,7 +231,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
// bg
|
||||
bgUnitsView.setText(units);
|
||||
|
||||
TextWatcher bgTextWatcher = new TextWatcher() {
|
||||
TextWatcher bgTextWatcher = new TextWatcher() {
|
||||
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
|
@ -337,15 +331,15 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
editTimeshift.setParams(0d, (double) Constants.CPP_MIN_TIMESHIFT, (double) Constants.CPP_MAX_TIMESHIFT, 1d, new DecimalFormat("0"), false);
|
||||
|
||||
ProfileSwitch ps = MainApp.getConfigBuilder().getProfileSwitchFromHistory(System.currentTimeMillis());
|
||||
if(ps!=null && ps.isCPP){
|
||||
if (ps != null && ps.isCPP) {
|
||||
final int percentage = ps.percentage;
|
||||
final int timeshift = ps.timeshift;
|
||||
reuseButton.setText(reuseButton.getText() + " " + percentage + "% " + timeshift +"h");
|
||||
reuseButton.setText(reuseButton.getText() + " " + percentage + "% " + timeshift + "h");
|
||||
reuseButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
editPercentage.setValue((double)percentage);
|
||||
editTimeshift.setValue((double)timeshift);
|
||||
editPercentage.setValue((double) percentage);
|
||||
editTimeshift.setValue((double) timeshift);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -363,7 +357,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_profile_layout), options.profile);
|
||||
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_percentage_layout), options.profile);
|
||||
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_timeshift_layout), options.profile);
|
||||
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_reuse_layout), options.profile && ps!=null && ps.isCPP);
|
||||
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_reuse_layout), options.profile && ps != null && ps.isCPP);
|
||||
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_temptarget_layout), options.tempTarget);
|
||||
|
||||
return view;
|
||||
|
@ -674,31 +668,22 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
} else if (options.executeTempTarget) {
|
||||
try {
|
||||
if ((data.has("targetBottom") && data.has("targetTop")) || (data.has("duration") && data.getInt("duration") == 0)) {
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
TempTarget tempTarget = new TempTarget();
|
||||
tempTarget.date = eventTime.getTime();
|
||||
tempTarget.durationInMinutes = data.getInt("duration");
|
||||
tempTarget.reason = data.getString("reason");
|
||||
tempTarget.source = Source.USER;
|
||||
if (tempTarget.durationInMinutes != 0) {
|
||||
tempTarget.low = Profile.toMgdl(data.getDouble("targetBottom"), profile.getUnits());
|
||||
tempTarget.high = Profile.toMgdl(data.getDouble("targetTop"), profile.getUnits());
|
||||
} else {
|
||||
tempTarget.low = 0;
|
||||
tempTarget.high = 0;
|
||||
}
|
||||
log.debug("Creating new TempTarget db record: " + tempTarget.toString());
|
||||
MainApp.getDbHelper().createOrUpdate(tempTarget);
|
||||
NSUpload.uploadCareportalEntryToNS(data);
|
||||
Answers.getInstance().logCustom(new CustomEvent("TempTarget"));
|
||||
} catch (JSONException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
TempTarget tempTarget = new TempTarget();
|
||||
tempTarget.date = eventTime.getTime();
|
||||
tempTarget.durationInMinutes = data.getInt("duration");
|
||||
tempTarget.reason = data.getString("reason");
|
||||
tempTarget.source = Source.USER;
|
||||
if (tempTarget.durationInMinutes != 0) {
|
||||
tempTarget.low = Profile.toMgdl(data.getDouble("targetBottom"), profile.getUnits());
|
||||
tempTarget.high = Profile.toMgdl(data.getDouble("targetTop"), profile.getUnits());
|
||||
} else {
|
||||
tempTarget.low = 0;
|
||||
tempTarget.high = 0;
|
||||
}
|
||||
log.debug("Creating new TempTarget db record: " + tempTarget.toString());
|
||||
MainApp.getDbHelper().createOrUpdate(tempTarget);
|
||||
NSUpload.uploadCareportalEntryToNS(data);
|
||||
Answers.getInstance().logCustom(new CustomEvent("TempTarget"));
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
|
@ -714,64 +699,68 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
|||
}
|
||||
|
||||
public static void doProfileSwitch(final ProfileStore profileStore, final String profileName, final int duration, final int percentage, final int timeshift) {
|
||||
sHandler.post(new Runnable() {
|
||||
ProfileSwitch profileSwitch = new ProfileSwitch();
|
||||
profileSwitch.date = System.currentTimeMillis();
|
||||
profileSwitch.source = Source.USER;
|
||||
profileSwitch.profileName = profileName;
|
||||
profileSwitch.profileJson = profileStore.getSpecificProfile(profileName).getData().toString();
|
||||
profileSwitch.profilePlugin = ConfigBuilderPlugin.getActiveProfileInterface().getClass().getName();
|
||||
profileSwitch.durationInMinutes = duration;
|
||||
profileSwitch.isCPP = percentage != 100 || timeshift != 0;
|
||||
profileSwitch.timeshift = timeshift;
|
||||
profileSwitch.percentage = percentage;
|
||||
MainApp.getConfigBuilder().addToHistoryProfileSwitch(profileSwitch);
|
||||
|
||||
ConfigBuilderPlugin.getCommandQueue().setProfile(profileSwitch.getProfileObject(), new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
ProfileSwitch profileSwitch = new ProfileSwitch();
|
||||
profileSwitch.date = System.currentTimeMillis();
|
||||
profileSwitch.source = Source.USER;
|
||||
profileSwitch.profileName = profileName;
|
||||
profileSwitch.profileJson = profileStore.getSpecificProfile(profileName).getData().toString();
|
||||
profileSwitch.profilePlugin = ConfigBuilderPlugin.getActiveProfileInterface().getClass().getName();
|
||||
profileSwitch.durationInMinutes = duration;
|
||||
profileSwitch.isCPP = percentage != 100 || timeshift != 0;
|
||||
profileSwitch.timeshift = timeshift;
|
||||
profileSwitch.percentage = percentage;
|
||||
MainApp.getConfigBuilder().addToHistoryProfileSwitch(profileSwitch);
|
||||
|
||||
PumpInterface pump = MainApp.getConfigBuilder();
|
||||
if (pump != null) {
|
||||
pump.setNewBasalProfile(profileSwitch.getProfileObject());
|
||||
MainApp.bus().post(new EventNewBasalProfile());
|
||||
} else {
|
||||
log.error("No active pump selected");
|
||||
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.sResources.getString(R.string.failedupdatebasalprofile));
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
MainApp.instance().startActivity(i);
|
||||
}
|
||||
Answers.getInstance().logCustom(new CustomEvent("ProfileSwitch"));
|
||||
MainApp.bus().post(new EventNewBasalProfile());
|
||||
}
|
||||
});
|
||||
Answers.getInstance().logCustom(new CustomEvent("ProfileSwitch"));
|
||||
}
|
||||
|
||||
public static void doProfileSwitch(final int duration, final int percentage, final int timeshift) {
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ProfileSwitch profileSwitch = MainApp.getConfigBuilder().getProfileSwitchFromHistory(System.currentTimeMillis());
|
||||
if (profileSwitch != null) {
|
||||
profileSwitch = new ProfileSwitch();
|
||||
profileSwitch.date = System.currentTimeMillis();
|
||||
profileSwitch.source = Source.USER;
|
||||
profileSwitch.profileName = MainApp.getConfigBuilder().getProfileName(System.currentTimeMillis(), false);
|
||||
profileSwitch.profileJson = MainApp.getConfigBuilder().getProfile().getData().toString();
|
||||
profileSwitch.profilePlugin = ConfigBuilderPlugin.getActiveProfileInterface().getClass().getName();
|
||||
profileSwitch.durationInMinutes = duration;
|
||||
profileSwitch.isCPP = percentage != 100 || timeshift != 0;
|
||||
profileSwitch.timeshift = timeshift;
|
||||
profileSwitch.percentage = percentage;
|
||||
MainApp.getConfigBuilder().addToHistoryProfileSwitch(profileSwitch);
|
||||
ProfileSwitch profileSwitch = MainApp.getConfigBuilder().getProfileSwitchFromHistory(System.currentTimeMillis());
|
||||
if (profileSwitch != null) {
|
||||
profileSwitch = new ProfileSwitch();
|
||||
profileSwitch.date = System.currentTimeMillis();
|
||||
profileSwitch.source = Source.USER;
|
||||
profileSwitch.profileName = MainApp.getConfigBuilder().getProfileName(System.currentTimeMillis(), false);
|
||||
profileSwitch.profileJson = MainApp.getConfigBuilder().getProfile().getData().toString();
|
||||
profileSwitch.profilePlugin = ConfigBuilderPlugin.getActiveProfileInterface().getClass().getName();
|
||||
profileSwitch.durationInMinutes = duration;
|
||||
profileSwitch.isCPP = percentage != 100 || timeshift != 0;
|
||||
profileSwitch.timeshift = timeshift;
|
||||
profileSwitch.percentage = percentage;
|
||||
MainApp.getConfigBuilder().addToHistoryProfileSwitch(profileSwitch);
|
||||
|
||||
PumpInterface pump = MainApp.getConfigBuilder();
|
||||
if (pump != null) {
|
||||
pump.setNewBasalProfile(profileSwitch.getProfileObject());
|
||||
MainApp.bus().post(new EventNewBasalProfile());
|
||||
} else {
|
||||
log.error("No active pump selected");
|
||||
ConfigBuilderPlugin.getCommandQueue().setProfile(profileSwitch.getProfileObject(), 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.sResources.getString(R.string.failedupdatebasalprofile));
|
||||
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
MainApp.instance().startActivity(i);
|
||||
}
|
||||
Answers.getInstance().logCustom(new CustomEvent("ProfileSwitch"));
|
||||
} else {
|
||||
log.error("No profile switch existing");
|
||||
MainApp.bus().post(new EventNewBasalProfile());
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
Answers.getInstance().logCustom(new CustomEvent("ProfileSwitch"));
|
||||
} else {
|
||||
log.error("No profile switch existing");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogr
|
|||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.plugins.PumpVirtual.VirtualPumpPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.androidaps.queue.CommandQueue;
|
||||
import info.nightscout.utils.NSUpload;
|
||||
import info.nightscout.utils.SP;
|
||||
|
@ -59,7 +60,7 @@ import info.nightscout.utils.SP;
|
|||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
*/
|
||||
public class ConfigBuilderPlugin implements PluginBase, PumpInterface, ConstraintsInterface, TreatmentsInterface {
|
||||
public class ConfigBuilderPlugin implements PluginBase, ConstraintsInterface, TreatmentsInterface {
|
||||
private static Logger log = LoggerFactory.getLogger(ConfigBuilderPlugin.class);
|
||||
|
||||
private static BgSourceInterface activeBgSource;
|
||||
|
@ -361,279 +362,75 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
}
|
||||
|
||||
/*
|
||||
* Pump interface
|
||||
* Ex Pump interface
|
||||
*
|
||||
* Config builder return itself as a pump and check constraints before it passes command to pump driver
|
||||
*/
|
||||
@Override
|
||||
public boolean isInitialized() {
|
||||
if (activePump != null)
|
||||
return activePump.isInitialized();
|
||||
else return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSuspended() {
|
||||
if (activePump != null)
|
||||
return activePump.isSuspended();
|
||||
else return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBusy() {
|
||||
if (activePump != null)
|
||||
return activePump.isBusy();
|
||||
else return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnected() {
|
||||
if (activePump != null)
|
||||
return activePump.isConnected();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isConnecting() {
|
||||
if (activePump != null)
|
||||
return activePump.isConnecting();
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect(String reason) {
|
||||
if (activePump != null)
|
||||
activePump.connect(reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disconnect(String reason) {
|
||||
if (activePump != null)
|
||||
activePump.disconnect(reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopConnecting() {
|
||||
if (activePump != null)
|
||||
activePump.stopConnecting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getPumpStatus() {
|
||||
if (activePump != null)
|
||||
activePump.getPumpStatus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult setNewBasalProfile(Profile profile) {
|
||||
PumpEnactResult result = new PumpEnactResult();
|
||||
// Compare with pump limits
|
||||
Profile.BasalValue[] basalValues = profile.getBasalValues();
|
||||
|
||||
for (int index = 0; index < basalValues.length; index++) {
|
||||
if (basalValues[index].value < getPumpDescription().basalMinimumRate) {
|
||||
Notification notification = new Notification(Notification.BASAL_VALUE_BELOW_MINIMUM, MainApp.sResources.getString(R.string.basalvaluebelowminimum), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
result.success = false;
|
||||
result.comment = MainApp.sResources.getString(R.string.basalvaluebelowminimum);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
MainApp.bus().post(new EventDismissNotification(Notification.BASAL_VALUE_BELOW_MINIMUM));
|
||||
|
||||
if (isThisProfileSet(profile)) {
|
||||
log.debug("Correct profile already set");
|
||||
result.success = true;
|
||||
result.enacted = false;
|
||||
return result;
|
||||
} else
|
||||
return activePump.setNewBasalProfile(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isThisProfileSet(Profile profile) {
|
||||
if (activePump != null) {
|
||||
boolean result = activePump.isThisProfileSet(profile);
|
||||
if (result == false) {
|
||||
log.debug("Current profile: " + getProfile().getData().toString());
|
||||
log.debug("New profile: " + profile.getData().toString());
|
||||
}
|
||||
return result;
|
||||
} else return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date lastDataTime() {
|
||||
if (activePump != null)
|
||||
return activePump.lastDataTime();
|
||||
else return new Date();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getBaseBasalRate() {
|
||||
if (activePump != null)
|
||||
return activePump.getBaseBasalRate();
|
||||
else
|
||||
return 0d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||
MainApp.bus().post(new EventBolusRequested(detailedBolusInfo.insulin));
|
||||
|
||||
PumpEnactResult result = activePump.deliverTreatment(detailedBolusInfo);
|
||||
|
||||
BolusProgressDialog.bolusEnded = true;
|
||||
MainApp.bus().post(new EventDismissBolusprogressIfRunning(result));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopBolusDelivering() {
|
||||
activePump.stopBolusDelivering();
|
||||
}
|
||||
|
||||
/**
|
||||
* apply constraints, set temp based on absolute valus and expecting absolute result
|
||||
*
|
||||
* @param absoluteRate
|
||||
* @param durationInMinutes
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes, boolean force) {
|
||||
Double rateAfterConstraints = applyBasalConstraints(absoluteRate);
|
||||
PumpEnactResult result = activePump.setTempBasalAbsolute(rateAfterConstraints, durationInMinutes, force);
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("setTempBasalAbsolute rate: " + rateAfterConstraints + " durationInMinutes: " + durationInMinutes + " success: " + result.success + " enacted: " + result.enacted);
|
||||
return result;
|
||||
}
|
||||
|
||||
public PumpEnactResult setTempBasalAbsolute(Double absoluteRate, Integer durationInMinutes) {
|
||||
return setTempBasalAbsolute(absoluteRate, durationInMinutes, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* apply constraints, set temp based on percent and expecting result in percent
|
||||
*
|
||||
* @param percent 0 ... 100 ...
|
||||
* @param durationInMinutes
|
||||
* @return result
|
||||
*/
|
||||
@Override
|
||||
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
|
||||
Integer percentAfterConstraints = applyBasalConstraints(percent);
|
||||
PumpEnactResult result = activePump.setTempBasalPercent(percentAfterConstraints, durationInMinutes);
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("setTempBasalPercent percent: " + percentAfterConstraints + " durationInMinutes: " + durationInMinutes + " success: " + result.success + " enacted: " + result.enacted);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult setExtendedBolus(Double insulin, Integer durationInMinutes) {
|
||||
Double rateAfterConstraints = applyBolusConstraints(insulin);
|
||||
PumpEnactResult result = activePump.setExtendedBolus(rateAfterConstraints, durationInMinutes);
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("setExtendedBolus rate: " + rateAfterConstraints + " durationInMinutes: " + durationInMinutes + " success: " + result.success + " enacted: " + result.enacted);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult cancelTempBasal(boolean force) {
|
||||
PumpEnactResult result = activePump.cancelTempBasal(force);
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("cancelTempBasal success: " + result.success + " enacted: " + result.enacted);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PumpEnactResult cancelExtendedBolus() {
|
||||
PumpEnactResult result = activePump.cancelExtendedBolus();
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("cancelExtendedBolus success: " + result.success + " enacted: " + result.enacted);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* expect absolute request and allow both absolute and percent response based on pump capabilities
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
* true if command is going to be executed
|
||||
* false if error
|
||||
*/
|
||||
|
||||
public PumpEnactResult applyAPSRequest(APSResult request) {
|
||||
public boolean applyAPSRequest(APSResult request, Callback callback) {
|
||||
PumpInterface pump = getActivePump();
|
||||
request.rate = applyBasalConstraints(request.rate);
|
||||
PumpEnactResult result;
|
||||
|
||||
if (!isInitialized()) {
|
||||
result = new PumpEnactResult();
|
||||
result.comment = MainApp.sResources.getString(R.string.pumpNotInitialized);
|
||||
result.enacted = false;
|
||||
result.success = false;
|
||||
if (!pump.isInitialized()) {
|
||||
log.debug("applyAPSRequest: " + MainApp.sResources.getString(R.string.pumpNotInitialized));
|
||||
return result;
|
||||
if (callback != null) {
|
||||
callback.result(new PumpEnactResult().comment(MainApp.sResources.getString(R.string.pumpNotInitialized)).enacted(false).success(false)).run();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isSuspended()) {
|
||||
result = new PumpEnactResult();
|
||||
result.comment = MainApp.sResources.getString(R.string.pumpsuspended);
|
||||
result.enacted = false;
|
||||
result.success = false;
|
||||
if (pump.isSuspended()) {
|
||||
log.debug("applyAPSRequest: " + MainApp.sResources.getString(R.string.pumpsuspended));
|
||||
return result;
|
||||
if (callback != null) {
|
||||
callback.result(new PumpEnactResult().comment(MainApp.sResources.getString(R.string.pumpsuspended)).enacted(false).success(false)).run();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("applyAPSRequest: " + request.toString());
|
||||
if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - getBaseBasalRate()) < getPumpDescription().basalStep) {
|
||||
if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - pump.getBaseBasalRate()) < pump.getPumpDescription().basalStep) {
|
||||
if (isTempBasalInProgress()) {
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("applyAPSRequest: cancelTempBasal()");
|
||||
result = cancelTempBasal(false);
|
||||
getCommandQueue().cancelTempBasal(false, callback);
|
||||
return true;
|
||||
} else {
|
||||
result = new PumpEnactResult();
|
||||
result.absolute = request.rate;
|
||||
result.duration = 0;
|
||||
result.enacted = false;
|
||||
result.comment = "Basal set correctly";
|
||||
result.success = true;
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("applyAPSRequest: Basal set correctly");
|
||||
if (callback != null) {
|
||||
callback.result(new PumpEnactResult().absolute(request.rate).duration(0).enacted(false).success(true).comment("Basal set correctly")).run();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} else if (isTempBasalInProgress() && Math.abs(request.rate - getTempBasalAbsoluteRateHistory()) < getPumpDescription().basalStep) {
|
||||
result = new PumpEnactResult();
|
||||
result.absolute = getTempBasalAbsoluteRateHistory();
|
||||
result.duration = getTempBasalFromHistory(System.currentTimeMillis()).getPlannedRemainingMinutes();
|
||||
result.enacted = false;
|
||||
result.comment = "Temp basal set correctly";
|
||||
result.success = true;
|
||||
} else if (isTempBasalInProgress() && Math.abs(request.rate - getTempBasalAbsoluteRateHistory()) < pump.getPumpDescription().basalStep) {
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("applyAPSRequest: Temp basal set correctly");
|
||||
if (callback != null) {
|
||||
callback.result(new PumpEnactResult().absolute(getTempBasalAbsoluteRateHistory()).duration(getTempBasalFromHistory(System.currentTimeMillis()).getPlannedRemainingMinutes()).enacted(false).success(true).comment("Temp basal set correctly")).run();
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("applyAPSRequest: setTempBasalAbsolute()");
|
||||
result = setTempBasalAbsolute(request.rate, request.duration);
|
||||
getCommandQueue().tempBasalAbsolute(request.rate, request.duration, false, callback);
|
||||
return true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public JSONObject getJSONStatus() {
|
||||
if (activePump != null)
|
||||
return activePump.getJSONStatus();
|
||||
else return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String deviceID() {
|
||||
if (activePump != null)
|
||||
return activePump.deviceID();
|
||||
else return "No Pump active!";
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public PumpDescription getPumpDescription() {
|
||||
if (activePump != null)
|
||||
|
@ -648,20 +445,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
|||
return emptyDescription;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String shortStatus(boolean veryShort) {
|
||||
if (activePump != null) {
|
||||
return activePump.shortStatus(veryShort);
|
||||
} else {
|
||||
return "No Pump active!";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFakingTempsByExtendedBoluses() {
|
||||
return activePump.isFakingTempsByExtendedBoluses();
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* Constraints interface
|
||||
|
|
|
@ -16,7 +16,7 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
|
@ -62,7 +62,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
|||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.objectives_shortname);
|
||||
if (!name.trim().isEmpty()){
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class ObjectivesPlugin implements PluginBase, ConstraintsInterface {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == CONSTRAINTS && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable;
|
||||
return type == CONSTRAINTS && ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -10,9 +10,10 @@ import info.nightscout.androidaps.Config;
|
|||
import info.nightscout.androidaps.Constants;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.utils.HardLimits;
|
||||
import info.nightscout.utils.Round;
|
||||
import info.nightscout.utils.SP;
|
||||
|
@ -93,7 +94,7 @@ public class SafetyPlugin implements PluginBase, ConstraintsInterface {
|
|||
|
||||
@Override
|
||||
public boolean isLoopEnabled() {
|
||||
return MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable;
|
||||
return ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,6 +12,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
|
||||
|
@ -25,15 +26,16 @@ public class APSResult {
|
|||
public double rate;
|
||||
public int duration;
|
||||
public boolean changeRequested = false;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final ConfigBuilderPlugin configBuilder = MainApp.getConfigBuilder();
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
if (changeRequested) {
|
||||
if (rate == 0 && duration == 0)
|
||||
return MainApp.sResources.getString(R.string.canceltemp);
|
||||
else
|
||||
return MainApp.sResources.getString(R.string.rate) + ": " + DecimalFormatter.to2Decimal(rate) + " U/h " +
|
||||
"(" + DecimalFormatter.to2Decimal(rate/configBuilder.getBaseBasalRate() *100) + "%)\n" +
|
||||
"(" + DecimalFormatter.to2Decimal(rate / pump.getBaseBasalRate() * 100) + "%)\n" +
|
||||
MainApp.sResources.getString(R.string.duration) + ": " + DecimalFormatter.to0Decimal(duration) + " min\n" +
|
||||
MainApp.sResources.getString(R.string.reason) + ": " + reason;
|
||||
} else
|
||||
|
@ -41,13 +43,13 @@ public class APSResult {
|
|||
}
|
||||
|
||||
public Spanned toSpanned() {
|
||||
final ConfigBuilderPlugin configBuilder = MainApp.getConfigBuilder();
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
if (changeRequested) {
|
||||
String ret = "";
|
||||
if (rate == 0 && duration == 0) ret = MainApp.sResources.getString(R.string.canceltemp);
|
||||
else
|
||||
ret = "<b>" + MainApp.sResources.getString(R.string.rate) + "</b>: " + DecimalFormatter.to2Decimal(rate) + " U/h " +
|
||||
"(" + DecimalFormatter.to2Decimal(rate/configBuilder.getBaseBasalRate() *100) + "%) <br>" +
|
||||
"(" + DecimalFormatter.to2Decimal(rate / pump.getBaseBasalRate() * 100) + "%) <br>" +
|
||||
"<b>" + MainApp.sResources.getString(R.string.duration) + "</b>: " + DecimalFormatter.to2Decimal(duration) + " min<br>" +
|
||||
"<b>" + MainApp.sResources.getString(R.string.reason) + "</b>: " + reason.replace("<", "<").replace(">", ">");
|
||||
return Html.fromHtml(ret);
|
||||
|
|
|
@ -6,15 +6,12 @@ import android.app.PendingIntent;
|
|||
import android.app.TaskStackBuilder;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.support.v7.app.NotificationCompat;
|
||||
|
||||
import com.crashlytics.android.answers.Answers;
|
||||
import com.crashlytics.android.answers.CustomEvent;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -31,14 +28,14 @@ import info.nightscout.androidaps.events.EventTreatmentChange;
|
|||
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||
import info.nightscout.androidaps.interfaces.ConstraintsInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.events.EventLoopSetLastRunGui;
|
||||
import info.nightscout.androidaps.plugins.Loop.events.EventLoopUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.Loop.events.EventNewOpenLoopNotification;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSAMA.OpenAPSAMAPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.utils.NSUpload;
|
||||
import info.nightscout.utils.SP;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
||||
/**
|
||||
* Created by mike on 05.08.2016.
|
||||
|
@ -55,9 +52,6 @@ public class LoopPlugin implements PluginBase {
|
|||
return loopPlugin;
|
||||
}
|
||||
|
||||
private static Handler sHandler;
|
||||
private static HandlerThread sHandlerThread;
|
||||
|
||||
private boolean fragmentEnabled = false;
|
||||
private boolean fragmentVisible = false;
|
||||
|
||||
|
@ -77,11 +71,6 @@ public class LoopPlugin implements PluginBase {
|
|||
static public LastRun lastRun = null;
|
||||
|
||||
public LoopPlugin() {
|
||||
if (sHandlerThread == null) {
|
||||
sHandlerThread = new HandlerThread(LoopPlugin.class.getSimpleName());
|
||||
sHandlerThread.start();
|
||||
sHandler = new Handler(sHandlerThread.getLooper());
|
||||
}
|
||||
MainApp.bus().register(this);
|
||||
loopSuspendedTill = SP.getLong("loopSuspendedTill", 0L);
|
||||
isSuperBolus = SP.getBoolean("isSuperBolus", false);
|
||||
|
@ -105,7 +94,7 @@ public class LoopPlugin implements PluginBase {
|
|||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.loop_shortname);
|
||||
if (!name.trim().isEmpty()){
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
|
@ -115,12 +104,14 @@ public class LoopPlugin implements PluginBase {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == LOOP && fragmentEnabled && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable;
|
||||
boolean pumpCapable = ConfigBuilderPlugin.getActivePump() == null || ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable;
|
||||
return type == LOOP && fragmentEnabled && pumpCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == LOOP && fragmentVisible && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable;
|
||||
boolean pumpCapable = ConfigBuilderPlugin.getActivePump() == null || ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable;
|
||||
return type == LOOP && fragmentVisible && pumpCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -208,7 +199,7 @@ public class LoopPlugin implements PluginBase {
|
|||
return true;
|
||||
}
|
||||
|
||||
public boolean isSuperBolus() {
|
||||
public boolean isSuperBolus() {
|
||||
if (loopSuspendedTill == 0)
|
||||
return false;
|
||||
|
||||
|
@ -232,10 +223,10 @@ public class LoopPlugin implements PluginBase {
|
|||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.loopdisabled)));
|
||||
return;
|
||||
}
|
||||
final ConfigBuilderPlugin configBuilder = MainApp.getConfigBuilder();
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
APSResult result = null;
|
||||
|
||||
if (configBuilder == null || !isEnabled(PluginBase.LOOP))
|
||||
if (!isEnabled(PluginBase.LOOP))
|
||||
return;
|
||||
|
||||
if (isSuspended()) {
|
||||
|
@ -244,22 +235,22 @@ public class LoopPlugin implements PluginBase {
|
|||
return;
|
||||
}
|
||||
|
||||
if (configBuilder.isSuspended()) {
|
||||
if (pump.isSuspended()) {
|
||||
log.debug(MainApp.sResources.getString(R.string.pumpsuspended));
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.pumpsuspended)));
|
||||
return;
|
||||
}
|
||||
|
||||
if (configBuilder.getProfile() == null) {
|
||||
if (MainApp.getConfigBuilder().getProfile() == null) {
|
||||
log.debug(MainApp.sResources.getString(R.string.noprofileselected));
|
||||
MainApp.bus().post(new EventLoopSetLastRunGui(MainApp.sResources.getString(R.string.noprofileselected)));
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if pump info is loaded
|
||||
if (configBuilder.getBaseBasalRate() < 0.01d) return;
|
||||
if (pump.getBaseBasalRate() < 0.01d) return;
|
||||
|
||||
APSInterface usedAPS = configBuilder.getActiveAPS();
|
||||
APSInterface usedAPS = MainApp.getConfigBuilder().getActiveAPS();
|
||||
if (usedAPS != null && ((PluginBase) usedAPS).isEnabled(PluginBase.APS)) {
|
||||
usedAPS.invoke(initiator);
|
||||
result = usedAPS.getLastAPSResult();
|
||||
|
@ -282,20 +273,19 @@ public class LoopPlugin implements PluginBase {
|
|||
lastRun.source = ((PluginBase) usedAPS).getName();
|
||||
lastRun.setByPump = null;
|
||||
|
||||
if (constraintsInterface.isClosedModeEnabled()) {
|
||||
if (constraintsInterface.isClosedModeEnabled()) {
|
||||
if (result.changeRequested) {
|
||||
final PumpEnactResult waiting = new PumpEnactResult();
|
||||
final PumpEnactResult previousResult = lastRun.setByPump;
|
||||
waiting.queued = true;
|
||||
lastRun.setByPump = waiting;
|
||||
MainApp.bus().post(new EventLoopUpdateGui());
|
||||
sHandler.post(new Runnable() {
|
||||
MainApp.getConfigBuilder().applyAPSRequest(resultAfterConstraints, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
final PumpEnactResult applyResult = configBuilder.applyAPSRequest(resultAfterConstraints);
|
||||
Answers.getInstance().logCustom(new CustomEvent("APSRequest"));
|
||||
if (applyResult.enacted || applyResult.success) {
|
||||
lastRun.setByPump = applyResult;
|
||||
if (result.enacted || result.success) {
|
||||
lastRun.setByPump = result;
|
||||
lastRun.lastEnact = lastRun.lastAPSRun;
|
||||
} else {
|
||||
lastRun.setByPump = previousResult;
|
||||
|
|
|
@ -75,12 +75,14 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == APS && fragmentEnabled && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable;
|
||||
boolean pumpCapable = ConfigBuilderPlugin.getActivePump() == null || ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable;
|
||||
return type == APS && fragmentEnabled && pumpCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == APS && fragmentVisible && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable;
|
||||
boolean pumpCapable = ConfigBuilderPlugin.getActivePump() == null || ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable;
|
||||
return type == APS && fragmentVisible && pumpCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -137,7 +139,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
|||
public void invoke(String initiator) {
|
||||
log.debug("invoke from " + initiator);
|
||||
lastAPSResult = null;
|
||||
DetermineBasalAdapterAMAJS determineBasalAdapterAMAJS = null;
|
||||
DetermineBasalAdapterAMAJS determineBasalAdapterAMAJS;
|
||||
try {
|
||||
determineBasalAdapterAMAJS = new DetermineBasalAdapterAMAJS(new ScriptReader(MainApp.instance().getBaseContext()));
|
||||
} catch (IOException e) {
|
||||
|
@ -214,7 +216,8 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
|||
if (!checkOnlyHardLimits(Profile.toMgdl(profile.getIsf(), units), "sens", 2, 900))
|
||||
return;
|
||||
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.1, 10)) return;
|
||||
if (!checkOnlyHardLimits(ConfigBuilderPlugin.getActivePump().getBaseBasalRate(), "current_basal", 0.01, 5)) return;
|
||||
if (!checkOnlyHardLimits(ConfigBuilderPlugin.getActivePump().getBaseBasalRate(), "current_basal", 0.01, 5))
|
||||
return;
|
||||
|
||||
startPart = new Date();
|
||||
if (MainApp.getConfigBuilder().isAMAModeEnabled()) {
|
||||
|
@ -247,7 +250,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
|||
if (!MainApp.getConfigBuilder().isClosedModeEnabled()) {
|
||||
if (MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultAMA.rate - MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory()) < 0.1)
|
||||
determineBasalResultAMA.changeRequested = false;
|
||||
if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultAMA.rate - MainApp.getConfigBuilder().getBaseBasalRate()) < 0.1)
|
||||
if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultAMA.rate - ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) < 0.1)
|
||||
determineBasalResultAMA.changeRequested = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
|||
@Override
|
||||
public String getNameShort() {
|
||||
String name = MainApp.sResources.getString(R.string.oaps_shortname);
|
||||
if (!name.trim().isEmpty()){
|
||||
if (!name.trim().isEmpty()) {
|
||||
//only if translation exists
|
||||
return name;
|
||||
}
|
||||
|
@ -73,12 +73,14 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
|||
|
||||
@Override
|
||||
public boolean isEnabled(int type) {
|
||||
return type == APS && fragmentEnabled && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable;
|
||||
boolean pumpCapable = ConfigBuilderPlugin.getActivePump() == null || ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable;
|
||||
return type == APS && fragmentEnabled && pumpCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == APS && fragmentVisible && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable;
|
||||
boolean pumpCapable = ConfigBuilderPlugin.getActivePump() == null || ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable;
|
||||
return type == APS && fragmentVisible && pumpCapable;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -212,7 +214,8 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
|||
if (!checkOnlyHardLimits(Profile.toMgdl(profile.getIsf(), units), "sens", 2, 900))
|
||||
return;
|
||||
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.1, 10)) return;
|
||||
if (!checkOnlyHardLimits(ConfigBuilderPlugin.getActivePump().getBaseBasalRate(), "current_basal", 0.01, 5)) return;
|
||||
if (!checkOnlyHardLimits(ConfigBuilderPlugin.getActivePump().getBaseBasalRate(), "current_basal", 0.01, 5))
|
||||
return;
|
||||
|
||||
start = new Date();
|
||||
try {
|
||||
|
@ -231,7 +234,7 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
|||
if (!MainApp.getConfigBuilder().isClosedModeEnabled()) {
|
||||
if (MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultMA.rate - MainApp.getConfigBuilder().getTempBasalAbsoluteRateHistory()) < 0.1)
|
||||
determineBasalResultMA.changeRequested = false;
|
||||
if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultMA.rate - MainApp.getConfigBuilder().getBaseBasalRate()) < 0.1)
|
||||
if (!MainApp.getConfigBuilder().isTempBasalInProgress() && Math.abs(determineBasalResultMA.rate - ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) < 0.1)
|
||||
determineBasalResultMA.changeRequested = false;
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.slf4j.LoggerFactory;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventPumpStatusChanged;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProgress;
|
||||
|
||||
|
@ -96,8 +96,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
|||
case R.id.overview_bolusprogress_stop:
|
||||
log.debug("Stop bolus delivery button pressed");
|
||||
stopPressedView.setVisibility(View.VISIBLE);
|
||||
PumpInterface pump = MainApp.getConfigBuilder();
|
||||
pump.stopBolusDelivering();
|
||||
ConfigBuilderPlugin.getActivePump().stopBolusDelivering();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -123,7 +122,7 @@ public class BolusProgressDialog extends DialogFragment implements View.OnClickL
|
|||
|
||||
@Subscribe
|
||||
public void onStatusEvent(final EventDismissBolusprogressIfRunning ev) {
|
||||
if(BolusProgressDialog.running){
|
||||
if (BolusProgressDialog.running) {
|
||||
dismiss();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,7 @@ public class NewTreatmentDialog extends DialogFragment implements OnClickListene
|
|||
editInsulin = (NumberPicker) view.findViewById(R.id.treatments_newtreatment_insulinamount);
|
||||
|
||||
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
|
||||
editInsulin.setParams(0d, 0d, maxInsulin, MainApp.getConfigBuilder().getPumpDescription().bolusStep, new DecimalFormat("0.00"), false, textWatcher);
|
||||
editInsulin.setParams(0d, 0d, maxInsulin,ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep, new DecimalFormat("0.00"), false, textWatcher);
|
||||
|
||||
return view;
|
||||
}
|
||||
|
|
|
@ -5,8 +5,6 @@ import android.content.Context;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.text.Editable;
|
||||
|
@ -106,16 +104,10 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
JSONObject boluscalcJSON;
|
||||
boolean cobAvailable = false;
|
||||
|
||||
Handler mHandler;
|
||||
public static HandlerThread mHandlerThread;
|
||||
|
||||
Context context;
|
||||
|
||||
public WizardDialog() {
|
||||
super();
|
||||
mHandlerThread = new HandlerThread(WizardDialog.class.getSimpleName());
|
||||
mHandlerThread.start();
|
||||
mHandler = new Handler(mHandlerThread.getLooper());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -250,7 +242,7 @@ public class WizardDialog extends DialogFragment implements OnClickListener, Com
|
|||
|
||||
editBg.setParams(0d, 0d, 500d, 0.1d, new DecimalFormat("0.0"), false, textWatcher);
|
||||
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, textWatcher);
|
||||
double bolusstep = MainApp.getConfigBuilder().getPumpDescription().bolusStep;
|
||||
double bolusstep = ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep;
|
||||
editCorr.setParams(0d, -maxCorrection, maxCorrection, bolusstep, new DecimalFormat("0.00"), false, textWatcher);
|
||||
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false);
|
||||
initDialog();
|
||||
|
|
|
@ -7,11 +7,9 @@ import android.content.Context;
|
|||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.DashPathEffect;
|
||||
import android.graphics.Paint;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
|
@ -37,11 +35,6 @@ import com.crashlytics.android.Crashlytics;
|
|||
import com.crashlytics.android.answers.Answers;
|
||||
import com.crashlytics.android.answers.CustomEvent;
|
||||
import com.jjoe64.graphview.GraphView;
|
||||
import com.jjoe64.graphview.ValueDependentColor;
|
||||
import com.jjoe64.graphview.series.BarGraphSeries;
|
||||
import com.jjoe64.graphview.series.DataPoint;
|
||||
import com.jjoe64.graphview.series.LineGraphSeries;
|
||||
import com.jjoe64.graphview.series.Series;
|
||||
import com.squareup.otto.Subscribe;
|
||||
|
||||
import org.json.JSONException;
|
||||
|
@ -50,7 +43,6 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
@ -69,7 +61,6 @@ import info.nightscout.androidaps.data.DetailedBolusInfo;
|
|||
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.db.CareportalEvent;
|
||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||
|
@ -109,8 +100,6 @@ import info.nightscout.androidaps.plugins.Overview.Dialogs.WizardDialog;
|
|||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventSetWakeLock;
|
||||
import info.nightscout.androidaps.plugins.Overview.graphData.GraphData;
|
||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.FixedLineGraphSeries;
|
||||
import info.nightscout.androidaps.plugins.Overview.graphExtensions.TimeAsXAxisLabelFormatter;
|
||||
import info.nightscout.androidaps.plugins.SourceXdrip.SourceXdripPlugin;
|
||||
import info.nightscout.androidaps.plugins.Treatments.fragments.ProfileViewerDialog;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
|
@ -182,19 +171,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
Handler sLoopHandler = new Handler();
|
||||
Runnable sRefreshLoop = null;
|
||||
|
||||
private static Handler sHandler;
|
||||
private static HandlerThread sHandlerThread;
|
||||
|
||||
private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
|
||||
private static ScheduledFuture<?> scheduledUpdate = null;
|
||||
|
||||
public OverviewFragment() {
|
||||
super();
|
||||
if (sHandlerThread == null) {
|
||||
sHandlerThread = new HandlerThread(OverviewFragment.class.getSimpleName());
|
||||
sHandlerThread.start();
|
||||
sHandler = new Handler(sHandlerThread.getLooper());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -409,10 +390,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
activeloop.setFragmentVisible(PluginBase.LOOP, false);
|
||||
MainApp.getConfigBuilder().storeSettings();
|
||||
updateGUI("suspendmenu");
|
||||
sHandler.post(new Runnable() {
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
}
|
||||
|
@ -430,10 +410,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.resume))) {
|
||||
activeloop.suspendTo(0L);
|
||||
updateGUI("suspendmenu");
|
||||
sHandler.post(new Runnable() {
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
}
|
||||
|
@ -444,10 +423,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor1h))) {
|
||||
activeloop.suspendTo(System.currentTimeMillis() + 60L * 60 * 1000);
|
||||
updateGUI("suspendmenu");
|
||||
sHandler.post(new Runnable() {
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
}
|
||||
|
@ -458,10 +436,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor2h))) {
|
||||
activeloop.suspendTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
|
||||
updateGUI("suspendmenu");
|
||||
sHandler.post(new Runnable() {
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
}
|
||||
|
@ -472,10 +449,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor3h))) {
|
||||
activeloop.suspendTo(System.currentTimeMillis() + 3 * 60L * 60 * 1000);
|
||||
updateGUI("suspendmenu");
|
||||
sHandler.post(new Runnable() {
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
}
|
||||
|
@ -486,10 +462,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.suspendloopfor10h))) {
|
||||
activeloop.suspendTo(System.currentTimeMillis() + 10 * 60L * 60 * 1000);
|
||||
updateGUI("suspendmenu");
|
||||
sHandler.post(new Runnable() {
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
}
|
||||
|
@ -500,10 +475,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor30m))) {
|
||||
activeloop.suspendTo(System.currentTimeMillis() + 30L * 60 * 1000);
|
||||
updateGUI("suspendmenu");
|
||||
sHandler.post(new Runnable() {
|
||||
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(0d, 30, true, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 30, true);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
}
|
||||
|
@ -514,10 +488,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor1h))) {
|
||||
activeloop.suspendTo(System.currentTimeMillis() + 1 * 60L * 60 * 1000);
|
||||
updateGUI("suspendmenu");
|
||||
sHandler.post(new Runnable() {
|
||||
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(0d, 60, true, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 60, true);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
}
|
||||
|
@ -528,10 +501,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor2h))) {
|
||||
activeloop.suspendTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
|
||||
updateGUI("suspendmenu");
|
||||
sHandler.post(new Runnable() {
|
||||
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(0d, 2 * 60, true, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 2 * 60, true);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
}
|
||||
|
@ -542,10 +514,9 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor3h))) {
|
||||
activeloop.suspendTo(System.currentTimeMillis() + 3 * 60L * 60 * 1000);
|
||||
updateGUI("suspendmenu");
|
||||
sHandler.post(new Runnable() {
|
||||
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(0d, 3 * 60, true, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().setTempBasalAbsolute(0d, 3 * 60, true);
|
||||
if (!result.success) {
|
||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.tempbasaldeliveryerror));
|
||||
}
|
||||
|
@ -591,7 +562,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
treatmentDialogFragment.show(manager, "TreatmentDialog");
|
||||
break;
|
||||
case R.id.overview_pumpstatus:
|
||||
if (MainApp.getConfigBuilder().isSuspended() || !MainApp.getConfigBuilder().isInitialized())
|
||||
if (ConfigBuilderPlugin.getActivePump().isSuspended() || !ConfigBuilderPlugin.getActivePump().isInitialized())
|
||||
ConfigBuilderPlugin.getCommandQueue().readStatus("RefreshClicked", null);
|
||||
break;
|
||||
}
|
||||
|
@ -608,14 +579,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
builder.setMessage(getContext().getString(R.string.setbasalquestion) + "\n" + finalLastRun.constraintsProcessed);
|
||||
builder.setPositiveButton(getContext().getString(R.string.ok), new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int id) {
|
||||
sHandler.post(new Runnable() {
|
||||
hideTempRecommendation();
|
||||
clearNotification();
|
||||
MainApp.getConfigBuilder().applyAPSRequest(finalLastRun.constraintsProcessed, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
hideTempRecommendation();
|
||||
clearNotification();
|
||||
PumpEnactResult applyResult = MainApp.getConfigBuilder().applyAPSRequest(finalLastRun.constraintsProcessed);
|
||||
if (applyResult.enacted) {
|
||||
finalLastRun.setByPump = applyResult;
|
||||
if (result.enacted) {
|
||||
finalLastRun.setByPump = result;
|
||||
finalLastRun.lastEnact = new Date();
|
||||
finalLastRun.lastOpenModeAccept = new Date();
|
||||
NSUpload.uploadDeviceStatus();
|
||||
|
@ -906,7 +876,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
BgReading actualBG = DatabaseHelper.actualBg();
|
||||
BgReading lastBG = DatabaseHelper.lastBg();
|
||||
|
||||
PumpInterface pump = MainApp.getConfigBuilder();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
String units = profile.getUnits();
|
||||
|
@ -948,7 +918,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
|
||||
// open loop mode
|
||||
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
|
||||
if (Config.APS && MainApp.getConfigBuilder().getPumpDescription().isTempBasalCapable) {
|
||||
if (Config.APS && pump.getPumpDescription().isTempBasalCapable) {
|
||||
apsModeView.setVisibility(View.VISIBLE);
|
||||
apsModeView.setBackgroundColor(MainApp.sResources.getColor(R.color.loopenabled));
|
||||
apsModeView.setTextColor(Color.BLACK);
|
||||
|
@ -1061,15 +1031,10 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
|
||||
final ExtendedBolus extendedBolus = MainApp.getConfigBuilder().getExtendedBolusFromHistory(System.currentTimeMillis());
|
||||
String extendedBolusText = "";
|
||||
if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses()) {
|
||||
extendedBolusText = extendedBolus.toString();
|
||||
}
|
||||
if (extendedBolusView != null) { // must not exists in all layouts
|
||||
if (shorttextmode) {
|
||||
if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses()) {
|
||||
extendedBolusText = DecimalFormatter.to2Decimal(extendedBolus.absoluteRate()) + "U/h";
|
||||
} else {
|
||||
extendedBolusText = "";
|
||||
}
|
||||
extendedBolusView.setText(extendedBolusText);
|
||||
extendedBolusView.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -1080,8 +1045,15 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
});
|
||||
|
||||
} else {
|
||||
if (extendedBolus != null && !pump.isFakingTempsByExtendedBoluses()) {
|
||||
extendedBolusText = extendedBolus.toString();
|
||||
}
|
||||
extendedBolusView.setText(extendedBolusText);
|
||||
}
|
||||
if (extendedBolusText.equals(""))
|
||||
extendedBolusView.setVisibility(View.GONE);
|
||||
else
|
||||
extendedBolusView.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
activeProfileView.setText(MainApp.getConfigBuilder().getProfileName());
|
||||
|
|
|
@ -24,6 +24,7 @@ import info.nightscout.androidaps.db.CareportalEvent;
|
|||
import info.nightscout.androidaps.db.ExtendedBolus;
|
||||
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.events.BasalData;
|
||||
|
@ -237,7 +238,7 @@ public class GraphData {
|
|||
}
|
||||
|
||||
// Extended bolus
|
||||
if (!MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses()) {
|
||||
if (!ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) {
|
||||
List<ExtendedBolus> extendedBoluses = MainApp.getConfigBuilder().getExtendedBolusesFromHistory().getList();
|
||||
|
||||
for (int tx = 0; tx < extendedBoluses.size(); tx++) {
|
||||
|
|
|
@ -522,7 +522,7 @@ public class CircadianPercentageProfileFragment extends SubscriberFragment {
|
|||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended()) {
|
||||
if (!ConfigBuilderPlugin.getActivePump().isInitialized() || ConfigBuilderPlugin.getActivePump().isSuspended()) {
|
||||
profileswitchButton.setVisibility(View.GONE);
|
||||
} else {
|
||||
profileswitchButton.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -162,7 +162,7 @@ public class LocalProfileFragment extends SubscriberFragment {
|
|||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended()) {
|
||||
if (!ConfigBuilderPlugin.getActivePump().isInitialized() || ConfigBuilderPlugin.getActivePump().isSuspended()) {
|
||||
profileswitchButton.setVisibility(View.GONE);
|
||||
} else {
|
||||
profileswitchButton.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -18,10 +18,10 @@ import info.nightscout.androidaps.Services.Intents;
|
|||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ProfileNS.events.EventNSProfileUpdateGUI;
|
||||
import info.nightscout.androidaps.plugins.SmsCommunicator.SmsCommunicatorPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
/**
|
||||
|
@ -77,7 +77,7 @@ public class NSProfilePlugin implements PluginBase, ProfileInterface {
|
|||
|
||||
@Override
|
||||
public boolean isVisibleInTabs(int type) {
|
||||
return type == PROFILE && (Config.NSCLIENT ||fragmentVisible);
|
||||
return type == PROFILE && (Config.NSCLIENT || fragmentVisible);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -121,12 +121,17 @@ public class NSProfilePlugin implements PluginBase, ProfileInterface {
|
|||
storeNSProfile();
|
||||
MainApp.bus().post(new EventNSProfileUpdateGUI());
|
||||
if (SP.getBoolean("syncprofiletopump", false)) {
|
||||
if (ConfigBuilderPlugin.getActivePump().setNewBasalProfile(MainApp.getConfigBuilder().getProfile()).enacted == true) {
|
||||
SmsCommunicatorPlugin smsCommunicatorPlugin = MainApp.getSpecificPlugin(SmsCommunicatorPlugin.class);
|
||||
if (smsCommunicatorPlugin != null && smsCommunicatorPlugin.isEnabled(PluginBase.GENERAL)) {
|
||||
smsCommunicatorPlugin.sendNotificationToAllNumbers(MainApp.sResources.getString(R.string.profile_set_ok));
|
||||
ConfigBuilderPlugin.getCommandQueue().setProfile(MainApp.getConfigBuilder().getProfile(), new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (result.enacted) {
|
||||
SmsCommunicatorPlugin smsCommunicatorPlugin = MainApp.getSpecificPlugin(SmsCommunicatorPlugin.class);
|
||||
if (smsCommunicatorPlugin != null && smsCommunicatorPlugin.isEnabled(PluginBase.GENERAL)) {
|
||||
smsCommunicatorPlugin.sendNotificationToAllNumbers(MainApp.sResources.getString(R.string.profile_set_ok));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import com.squareup.otto.Subscribe;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||
import info.nightscout.androidaps.plugins.Careportal.CareportalFragment;
|
||||
|
@ -155,7 +154,7 @@ public class SimpleProfileFragment extends SubscriberFragment {
|
|||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!MainApp.getConfigBuilder().isInitialized() || MainApp.getConfigBuilder().isSuspended()) {
|
||||
if (!ConfigBuilderPlugin.getActivePump().isInitialized() || ConfigBuilderPlugin.getActivePump().isSuspended()) {
|
||||
profileswitchButton.setVisibility(View.GONE);
|
||||
} else {
|
||||
profileswitchButton.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.app.Activity;
|
|||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.text.Spanned;
|
||||
import android.view.LayoutInflater;
|
||||
|
@ -223,15 +222,15 @@ public class DanaRFragment extends SubscriberFragment {
|
|||
Long agoMsec = System.currentTimeMillis() - pump.lastBolusTime.getTime();
|
||||
double agoHours = agoMsec / 60d / 60d / 1000d;
|
||||
if (agoHours < 6) // max 6h back
|
||||
lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " " + DateUtil.sinceString(pump.lastBolusTime.getTime()) + " " + DecimalFormatter.to2Decimal(DanaRPump.getInstance().lastBolusAmount) + " U");
|
||||
lastBolusView.setText(DateUtil.timeString(pump.lastBolusTime) + " " + DateUtil.sinceString(pump.lastBolusTime.getTime()) + " " + DecimalFormatter.to2Decimal(DanaRPump.getInstance().lastBolusAmount) + " U");
|
||||
else lastBolusView.setText("");
|
||||
}
|
||||
|
||||
dailyUnitsView.setText(DecimalFormatter.to0Decimal(pump.dailyTotalUnits) + " / " + pump.maxDailyTotalUnits + " U");
|
||||
SetWarnColor.setColor(dailyUnitsView, pump.dailyTotalUnits, pump.maxDailyTotalUnits * 0.75d, pump.maxDailyTotalUnits * 0.9d);
|
||||
basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(MainApp.getConfigBuilder().getBaseBasalRate()) + " U/h");
|
||||
basaBasalRateView.setText("( " + (pump.activeProfile + 1) + " ) " + DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) + " U/h");
|
||||
// DanaRPlugin, DanaRKoreanPlugin
|
||||
if (MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses()) {
|
||||
if (ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) {
|
||||
if (MainApp.getConfigBuilder().isInHistoryRealTempBasalInProgress()) {
|
||||
tempBasalView.setText(MainApp.getConfigBuilder().getRealTempBasalFromHistory(System.currentTimeMillis()).toStringFull());
|
||||
} else {
|
||||
|
|
|
@ -42,7 +42,7 @@ public class DanaRS_Packet_Bolus_Set_Extended_Bolus extends DanaRS_Packet {
|
|||
public void handleMessage(byte[] data) {
|
||||
int result = intFromBuff(data, 0, 1);
|
||||
if (Config.logDanaMessageDetail) {
|
||||
if (result != 0)
|
||||
if (result == 0)
|
||||
log.debug("Result OK");
|
||||
else
|
||||
log.error("Result Error: " + result);
|
||||
|
|
|
@ -289,11 +289,15 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
LoopPlugin loopPlugin = MainApp.getSpecificPlugin(LoopPlugin.class);
|
||||
if (loopPlugin != null && loopPlugin.isEnabled(PluginBase.LOOP)) {
|
||||
loopPlugin.setFragmentEnabled(PluginBase.LOOP, false);
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_STOP"));
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeendisabled) + " " +
|
||||
MainApp.sResources.getString(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_STOP"));
|
||||
String reply = MainApp.sResources.getString(R.string.smscommunicator_loophasbeendisabled) + " " +
|
||||
MainApp.sResources.getString(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
});
|
||||
}
|
||||
receivedSms.processed = true;
|
||||
Answers.getInstance().logCustom(new CustomEvent("SMS_Loop_Stop"));
|
||||
|
@ -437,7 +441,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
if (System.currentTimeMillis() - lastRemoteBolusTime.getTime() < Constants.remoteBolusMinDistance) {
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_remotebolusnotallowed);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
} else if (MainApp.getConfigBuilder().isSuspended()) {
|
||||
} else if (ConfigBuilderPlugin.getActivePump().isSuspended()) {
|
||||
reply = MainApp.sResources.getString(R.string.pumpsuspended);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
} else if (splited.length > 1) {
|
||||
|
@ -478,7 +482,6 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
if (bolusWaitingForConfirmation != null && !bolusWaitingForConfirmation.processed &&
|
||||
bolusWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - bolusWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
|
||||
bolusWaitingForConfirmation.processed = true;
|
||||
PumpInterface pumpInterface = MainApp.getConfigBuilder();
|
||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||
detailedBolusInfo.insulin = bolusWaitingForConfirmation.bolusRequested;
|
||||
detailedBolusInfo.source = Source.USER;
|
||||
|
@ -503,41 +506,37 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
} else if (tempBasalWaitingForConfirmation != null && !tempBasalWaitingForConfirmation.processed &&
|
||||
tempBasalWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - tempBasalWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
|
||||
tempBasalWaitingForConfirmation.processed = true;
|
||||
PumpInterface pumpInterface = MainApp.getConfigBuilder();
|
||||
if (pumpInterface != null) {
|
||||
danaRPlugin = MainApp.getSpecificPlugin(DanaRPlugin.class);
|
||||
PumpEnactResult result = pumpInterface.setTempBasalAbsolute(tempBasalWaitingForConfirmation.tempBasal, 30, true);
|
||||
if (result.success) {
|
||||
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_tempbasalset), result.absolute, result.duration);
|
||||
if (danaRPlugin != null)
|
||||
reply += "\n" + danaRPlugin.shortStatus(true);
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
} else {
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalfailed);
|
||||
if (danaRPlugin != null)
|
||||
reply += "\n" + danaRPlugin.shortStatus(true);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
ConfigBuilderPlugin.getCommandQueue().tempBasalAbsolute(tempBasalWaitingForConfirmation.tempBasal, 30, true, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (result.success) {
|
||||
String reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_tempbasalset), result.absolute, result.duration);
|
||||
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
} else {
|
||||
String reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalfailed);
|
||||
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (cancelTempBasalWaitingForConfirmation != null && !cancelTempBasalWaitingForConfirmation.processed &&
|
||||
cancelTempBasalWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - cancelTempBasalWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
|
||||
cancelTempBasalWaitingForConfirmation.processed = true;
|
||||
PumpInterface pumpInterface = MainApp.getConfigBuilder();
|
||||
if (pumpInterface != null) {
|
||||
danaRPlugin = MainApp.getSpecificPlugin(DanaRPlugin.class);
|
||||
PumpEnactResult result = pumpInterface.cancelTempBasal(true);
|
||||
if (result.success) {
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalcanceled);
|
||||
if (danaRPlugin != null)
|
||||
reply += "\n" + danaRPlugin.shortStatus(true);
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
} else {
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalcancelfailed);
|
||||
if (danaRPlugin != null)
|
||||
reply += "\n" + danaRPlugin.shortStatus(true);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (result.success) {
|
||||
String reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalcanceled);
|
||||
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
} else {
|
||||
String reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalcancelfailed);
|
||||
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} else if (calibrationWaitingForConfirmation != null && !calibrationWaitingForConfirmation.processed &&
|
||||
calibrationWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - calibrationWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
|
||||
calibrationWaitingForConfirmation.processed = true;
|
||||
|
@ -552,14 +551,24 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
} else if (suspendWaitingForConfirmation != null && !suspendWaitingForConfirmation.processed &&
|
||||
suspendWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - suspendWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
|
||||
suspendWaitingForConfirmation.processed = true;
|
||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
||||
activeloop.suspendTo(System.currentTimeMillis() + suspendWaitingForConfirmation.duration * 60L * 1000);
|
||||
PumpEnactResult result = MainApp.getConfigBuilder().cancelTempBasal(true);
|
||||
NSUpload.uploadOpenAPSOffline(suspendWaitingForConfirmation.duration * 60);
|
||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_SUSPENDED"));
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_loopsuspended) + " " +
|
||||
MainApp.sResources.getString(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
ConfigBuilderPlugin.getCommandQueue().cancelTempBasal(true, new Callback() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (result.success) {
|
||||
final LoopPlugin activeloop = ConfigBuilderPlugin.getActiveLoop();
|
||||
activeloop.suspendTo(System.currentTimeMillis() + suspendWaitingForConfirmation.duration * 60L * 1000);
|
||||
NSUpload.uploadOpenAPSOffline(suspendWaitingForConfirmation.duration * 60);
|
||||
MainApp.bus().post(new EventRefreshOverview("SMS_LOOP_SUSPENDED"));
|
||||
String reply = MainApp.sResources.getString(R.string.smscommunicator_loopsuspended) + " " +
|
||||
MainApp.sResources.getString(result.success ? R.string.smscommunicator_tempbasalcanceled : R.string.smscommunicator_tempbasalcancelfailed);
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
} else {
|
||||
String reply = MainApp.sResources.getString(R.string.smscommunicator_tempbasalcancelfailed);
|
||||
reply += "\n" + ConfigBuilderPlugin.getActivePump().shortStatus(true);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, MainApp.sResources.getString(R.string.smscommunicator_unknowncommand), new Date()));
|
||||
}
|
||||
|
|
|
@ -210,7 +210,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
}
|
||||
}
|
||||
|
||||
if (!MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses())
|
||||
if (!ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses())
|
||||
synchronized (extendedBoluses) {
|
||||
for (Integer pos = 0; pos < extendedBoluses.size(); pos++) {
|
||||
ExtendedBolus e = extendedBoluses.get(pos);
|
||||
|
@ -329,7 +329,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
total.plus(calc);
|
||||
}
|
||||
}
|
||||
if (MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses()) {
|
||||
if (ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses()) {
|
||||
IobTotal totalExt = new IobTotal(time);
|
||||
synchronized (extendedBoluses) {
|
||||
for (Integer pos = 0; pos < extendedBoluses.size(); pos++) {
|
||||
|
@ -361,7 +361,7 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
if (tb != null)
|
||||
return tb;
|
||||
ExtendedBolus eb = getExtendedBolusFromHistory(time);
|
||||
if (eb != null && MainApp.getConfigBuilder().isFakingTempsByExtendedBoluses())
|
||||
if (eb != null && ConfigBuilderPlugin.getActivePump().isFakingTempsByExtendedBoluses())
|
||||
return new TemporaryBasal(eb);
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package info.nightscout.androidaps.plugins.Wear;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
import android.support.annotation.NonNull;
|
||||
|
@ -20,7 +19,6 @@ 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.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.db.BgReading;
|
||||
import info.nightscout.androidaps.db.DanaRHistoryRecord;
|
||||
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||
|
@ -37,7 +35,6 @@ import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialo
|
|||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.ErrorHelperActivity;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
|
@ -176,8 +173,8 @@ public class ActionStringHandler {
|
|||
} else if ("loop".equals(act[1])) {
|
||||
rTitle += " LOOP";
|
||||
rMessage = "TARGETS:\n" + getTargetsStatus();
|
||||
rMessage += "\n\n" + getLoopStatus();
|
||||
rMessage += "\n\nOAPS RESULT:\n" + getOAPSResultStatus();
|
||||
rMessage += "\n\n" + getLoopStatus();
|
||||
rMessage += "\n\nOAPS RESULT:\n" + getOAPSResultStatus();
|
||||
}
|
||||
|
||||
} else if ("wizard".equals(act[0])) {
|
||||
|
@ -239,15 +236,15 @@ public class ActionStringHandler {
|
|||
rMessage += "\nBolus IOB: " + format.format(bolusWizard.insulingFromBolusIOB) + "U";
|
||||
if (useBasalIOB)
|
||||
rMessage += "\nBasal IOB: " + format.format(bolusWizard.insulingFromBasalsIOB) + "U";
|
||||
if(percentage != 100){
|
||||
rMessage += "\nPercentage: " +format.format(bolusWizard.totalBeforePercentageAdjustment) + "U * " + percentage + "% -> ~" + format.format(bolusWizard.calculatedTotalInsulin) + "U";
|
||||
if (percentage != 100) {
|
||||
rMessage += "\nPercentage: " + format.format(bolusWizard.totalBeforePercentageAdjustment) + "U * " + percentage + "% -> ~" + format.format(bolusWizard.calculatedTotalInsulin) + "U";
|
||||
}
|
||||
|
||||
lastBolusWizard = bolusWizard;
|
||||
|
||||
} else if("opencpp".equals(act[0])){
|
||||
} else if ("opencpp".equals(act[0])) {
|
||||
ProfileSwitch activeProfileSwitch = MainApp.getConfigBuilder().getProfileSwitchFromHistory(System.currentTimeMillis());
|
||||
if(activeProfileSwitch==null){
|
||||
if (activeProfileSwitch == null) {
|
||||
sendError("No active profile switch!");
|
||||
return;
|
||||
} else {
|
||||
|
@ -257,30 +254,30 @@ public class ActionStringHandler {
|
|||
rAction = "opencpp" + " " + activeProfileSwitch.percentage + " " + activeProfileSwitch.timeshift;
|
||||
}
|
||||
|
||||
} else if("cppset".equals(act[0])){
|
||||
} else if ("cppset".equals(act[0])) {
|
||||
ProfileSwitch activeProfileSwitch = MainApp.getConfigBuilder().getProfileSwitchFromHistory(System.currentTimeMillis());
|
||||
if(activeProfileSwitch==null){
|
||||
if (activeProfileSwitch == null) {
|
||||
sendError("No active profile switch!");
|
||||
return;
|
||||
} else {
|
||||
// read CPP values
|
||||
rMessage = "CPP:" + "\n\n"+
|
||||
"Timeshift: " + act[1] + "\n" +
|
||||
"Percentage: " + act[2] + "%";
|
||||
rMessage = "CPP:" + "\n\n" +
|
||||
"Timeshift: " + act[1] + "\n" +
|
||||
"Percentage: " + act[2] + "%";
|
||||
rAction = actionstring;
|
||||
}
|
||||
|
||||
} else if("tddstats".equals(act[0])){
|
||||
} else if ("tddstats".equals(act[0])) {
|
||||
Object activePump = MainApp.getConfigBuilder().getActivePump();
|
||||
PumpInterface dana = MainApp.getSpecificPlugin(DanaRPlugin.class);
|
||||
PumpInterface danaV2 = MainApp.getSpecificPlugin(DanaRv2Plugin.class);
|
||||
PumpInterface danaKorean = MainApp.getSpecificPlugin(DanaRKoreanPlugin.class);
|
||||
|
||||
|
||||
if((dana == null || dana != activePump) &&
|
||||
if ((dana == null || dana != activePump) &&
|
||||
(danaV2 == null || danaV2 != activePump) &&
|
||||
(danaKorean == null || danaKorean != activePump)
|
||||
){
|
||||
) {
|
||||
sendError("Pump does not support TDDs!");
|
||||
return;
|
||||
} else {
|
||||
|
@ -288,7 +285,7 @@ public class ActionStringHandler {
|
|||
List<DanaRHistoryRecord> dummies = new LinkedList<DanaRHistoryRecord>();
|
||||
List<DanaRHistoryRecord> historyList = getTDDList(dummies);
|
||||
|
||||
if(isOldData(historyList)){
|
||||
if (isOldData(historyList)) {
|
||||
rTitle = "TDD";
|
||||
rAction = "statusmessage";
|
||||
rMessage = "OLD DATA - ";
|
||||
|
@ -303,10 +300,10 @@ public class ActionStringHandler {
|
|||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
((DanaRInterface)pump).loadHistory(RecordTypes.RECORD_TYPE_DAILY);
|
||||
((DanaRInterface) pump).loadHistory(RecordTypes.RECORD_TYPE_DAILY);
|
||||
List<DanaRHistoryRecord> dummies = new LinkedList<DanaRHistoryRecord>();
|
||||
List<DanaRHistoryRecord> historyList = getTDDList(dummies);
|
||||
if(isOldData(historyList)){
|
||||
if (isOldData(historyList)) {
|
||||
sendStatusmessage("TDD", "TDD: Still old data! Cannot load from pump.");
|
||||
} else {
|
||||
sendStatusmessage("TDD", generateTDDMessage(historyList, dummies));
|
||||
|
@ -322,8 +319,7 @@ public class ActionStringHandler {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
else return;
|
||||
} else return;
|
||||
|
||||
|
||||
// send result
|
||||
|
@ -336,14 +332,14 @@ public class ActionStringHandler {
|
|||
|
||||
ProfileInterface activeProfile = MainApp.getConfigBuilder().getActiveProfileInterface();
|
||||
|
||||
if(activeProfile == null){
|
||||
if (activeProfile == null) {
|
||||
return "No profile loaded :(";
|
||||
}
|
||||
|
||||
DateFormat df = new SimpleDateFormat("dd.MM.");
|
||||
String message = "";
|
||||
|
||||
double refTDD = activeProfile.getProfile().getDefaultProfile().baseBasalSum()*2;
|
||||
double refTDD = activeProfile.getProfile().getDefaultProfile().baseBasalSum() * 2;
|
||||
|
||||
int i = 0;
|
||||
double sum = 0d;
|
||||
|
@ -367,15 +363,15 @@ public class ActionStringHandler {
|
|||
i++;
|
||||
}
|
||||
message += "weighted:\n";
|
||||
message += "0.3: " + DecimalFormatter.to2Decimal(weighted03) + "U " + (DecimalFormatter.to0Decimal(100*weighted03/refTDD) + "%") + "\n";
|
||||
message += "0.5: " + DecimalFormatter.to2Decimal(weighted05) + "U " + (DecimalFormatter.to0Decimal(100*weighted05/refTDD) + "%") + "\n";
|
||||
message += "0.7: " + DecimalFormatter.to2Decimal(weighted07) + "U " + (DecimalFormatter.to0Decimal(100*weighted07/refTDD) + "%") + "\n";
|
||||
message += "0.3: " + DecimalFormatter.to2Decimal(weighted03) + "U " + (DecimalFormatter.to0Decimal(100 * weighted03 / refTDD) + "%") + "\n";
|
||||
message += "0.5: " + DecimalFormatter.to2Decimal(weighted05) + "U " + (DecimalFormatter.to0Decimal(100 * weighted05 / refTDD) + "%") + "\n";
|
||||
message += "0.7: " + DecimalFormatter.to2Decimal(weighted07) + "U " + (DecimalFormatter.to0Decimal(100 * weighted07 / refTDD) + "%") + "\n";
|
||||
message += "\n";
|
||||
|
||||
PumpInterface pump = MainApp.getConfigBuilder().getActivePump();
|
||||
if (pump != null && pump instanceof DanaRPlugin) {
|
||||
double tdd = DanaRPump.getInstance().dailyTotalUnits;
|
||||
message += "Today: " + DecimalFormatter.to2Decimal(tdd) + "U " + (DecimalFormatter.to0Decimal(100*tdd/refTDD) + "%") + "\n";
|
||||
message += "Today: " + DecimalFormatter.to2Decimal(tdd) + "U " + (DecimalFormatter.to0Decimal(100 * tdd / refTDD) + "%") + "\n";
|
||||
message += "\n";
|
||||
}
|
||||
|
||||
|
@ -383,7 +379,7 @@ public class ActionStringHandler {
|
|||
Collections.reverse(historyList);
|
||||
for (DanaRHistoryRecord record : historyList) {
|
||||
double tdd = record.recordDailyBolus + record.recordDailyBasal;
|
||||
message += df.format(new Date(record.recordDate)) + " " + DecimalFormatter.to2Decimal(tdd) +"U " + (DecimalFormatter.to0Decimal(100*tdd/refTDD) + "%") + (dummies.contains(record)?"x":"") +"\n";
|
||||
message += df.format(new Date(record.recordDate)) + " " + DecimalFormatter.to2Decimal(tdd) + "U " + (DecimalFormatter.to0Decimal(100 * tdd / refTDD) + "%") + (dummies.contains(record) ? "x" : "") + "\n";
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
@ -401,17 +397,17 @@ public class ActionStringHandler {
|
|||
historyList = historyList.subList(0, Math.min(10, historyList.size()));
|
||||
|
||||
//fill single gaps
|
||||
List<DanaRHistoryRecord> dummies = (returnDummies!=null)?returnDummies:(new LinkedList());
|
||||
List<DanaRHistoryRecord> dummies = (returnDummies != null) ? returnDummies : (new LinkedList());
|
||||
DateFormat df = new SimpleDateFormat("dd.MM.");
|
||||
for(int i = 0; i < historyList.size()-1; i++){
|
||||
for (int i = 0; i < historyList.size() - 1; i++) {
|
||||
DanaRHistoryRecord elem1 = historyList.get(i);
|
||||
DanaRHistoryRecord elem2 = historyList.get(i+1);
|
||||
DanaRHistoryRecord elem2 = historyList.get(i + 1);
|
||||
|
||||
if (!df.format(new Date(elem1.recordDate)).equals(df.format(new Date(elem2.recordDate + 25*60*60*1000)))){
|
||||
if (!df.format(new Date(elem1.recordDate)).equals(df.format(new Date(elem2.recordDate + 25 * 60 * 60 * 1000)))) {
|
||||
DanaRHistoryRecord dummy = new DanaRHistoryRecord();
|
||||
dummy.recordDate = elem1.recordDate - 24*60*60*1000;
|
||||
dummy.recordDailyBasal = elem1.recordDailyBasal/2;
|
||||
dummy.recordDailyBolus = elem1.recordDailyBolus/2;
|
||||
dummy.recordDate = elem1.recordDate - 24 * 60 * 60 * 1000;
|
||||
dummy.recordDailyBasal = elem1.recordDailyBasal / 2;
|
||||
dummy.recordDailyBolus = elem1.recordDailyBolus / 2;
|
||||
dummies.add(dummy);
|
||||
elem1.recordDailyBasal /= 2;
|
||||
elem1.recordDailyBolus /= 2;
|
||||
|
@ -421,7 +417,7 @@ public class ActionStringHandler {
|
|||
Collections.sort(historyList, new Comparator<DanaRHistoryRecord>() {
|
||||
@Override
|
||||
public int compare(DanaRHistoryRecord lhs, DanaRHistoryRecord rhs) {
|
||||
return (int) (rhs.recordDate-lhs.recordDate);
|
||||
return (int) (rhs.recordDate - lhs.recordDate);
|
||||
}
|
||||
});
|
||||
return historyList;
|
||||
|
@ -429,7 +425,7 @@ public class ActionStringHandler {
|
|||
|
||||
@NonNull
|
||||
private static String getPumpStatus() {
|
||||
return MainApp.getConfigBuilder().shortStatus(false);
|
||||
return ConfigBuilderPlugin.getActivePump().shortStatus(false);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
@ -508,12 +504,12 @@ public class ActionStringHandler {
|
|||
}
|
||||
|
||||
if (!result.changeRequested) {
|
||||
ret += MainApp.sResources.getString(R.string.nochangerequested) + "\n";
|
||||
ret += MainApp.sResources.getString(R.string.nochangerequested) + "\n";
|
||||
} else if (result.rate == 0 && result.duration == 0) {
|
||||
ret += MainApp.sResources.getString(R.string.canceltemp)+ "\n";
|
||||
ret += MainApp.sResources.getString(R.string.canceltemp) + "\n";
|
||||
} else {
|
||||
ret += MainApp.sResources.getString(R.string.rate) + ": " + DecimalFormatter.to2Decimal(result.rate) + " U/h " +
|
||||
"(" + DecimalFormatter.to2Decimal(result.rate / MainApp.getConfigBuilder().getBaseBasalRate() * 100) + "%)\n" +
|
||||
"(" + DecimalFormatter.to2Decimal(result.rate / ConfigBuilderPlugin.getActivePump().getBaseBasalRate() * 100) + "%)\n" +
|
||||
MainApp.sResources.getString(R.string.duration) + ": " + DecimalFormatter.to0Decimal(result.duration) + " min\n";
|
||||
}
|
||||
ret += "\n" + MainApp.sResources.getString(R.string.reason) + ": " + result.reason;
|
||||
|
@ -568,7 +564,7 @@ public class ActionStringHandler {
|
|||
int timeshift = SafeParse.stringToInt(act[1]);
|
||||
int percentage = SafeParse.stringToInt(act[2]);
|
||||
setCPP(timeshift, percentage);
|
||||
} else if ("dismissoverviewnotification".equals(act[0])){
|
||||
} else if ("dismissoverviewnotification".equals(act[0])) {
|
||||
MainApp.bus().post(new EventDismissNotification(SafeParse.stringToInt(act[1])));
|
||||
}
|
||||
lastBolusWizard = null;
|
||||
|
@ -581,20 +577,20 @@ public class ActionStringHandler {
|
|||
|
||||
//check for validity
|
||||
if (percentage < Constants.CPP_MIN_PERCENTAGE || percentage > Constants.CPP_MAX_PERCENTAGE) {
|
||||
msg+= String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Percentage") + "\n";
|
||||
msg += String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Percentage") + "\n";
|
||||
}
|
||||
if (timeshift < 0 || timeshift > 23) {
|
||||
msg+= String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Timeshift") + "\n";
|
||||
msg += String.format(MainApp.sResources.getString(R.string.openapsma_valueoutofrange), "Profile-Timeshift") + "\n";
|
||||
}
|
||||
if(!SP.getBoolean("syncprofiletopump", false)){
|
||||
msg+= MainApp.sResources.getString(R.string.syncprofiletopump_title) + " " + MainApp.sResources.getString(R.string.cpp_sync_setting_missing) + "\n";
|
||||
if (!SP.getBoolean("syncprofiletopump", false)) {
|
||||
msg += MainApp.sResources.getString(R.string.syncprofiletopump_title) + " " + MainApp.sResources.getString(R.string.cpp_sync_setting_missing) + "\n";
|
||||
}
|
||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
|
||||
if (profile == null || profile.getBasal() == null){
|
||||
msg+= MainApp.sResources.getString(R.string.cpp_notloadedplugins) + "\n";
|
||||
if (profile == null || profile.getBasal() == null) {
|
||||
msg += MainApp.sResources.getString(R.string.cpp_notloadedplugins) + "\n";
|
||||
}
|
||||
if(!"".equals(msg)) {
|
||||
if (!"".equals(msg)) {
|
||||
msg += MainApp.sResources.getString(R.string.cpp_valuesnotstored);
|
||||
String rTitle = "STATUS";
|
||||
String rAction = "statusmessage";
|
||||
|
|
|
@ -35,8 +35,8 @@ import info.nightscout.androidaps.db.BgReading;
|
|||
import info.nightscout.androidaps.db.DatabaseHelper;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.OverviewPlugin;
|
||||
import info.nightscout.androidaps.plugins.Wear.ActionStringHandler;
|
||||
|
@ -189,8 +189,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
}
|
||||
|
||||
private void cancelBolus() {
|
||||
PumpInterface pump = MainApp.getConfigBuilder();
|
||||
pump.stopBolusDelivering();
|
||||
ConfigBuilderPlugin.getActivePump().stopBolusDelivering();
|
||||
}
|
||||
|
||||
private void sendData() {
|
||||
|
@ -533,7 +532,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
|||
private void sendPreferences() {
|
||||
if (googleApiClient.isConnected()) {
|
||||
|
||||
boolean wearcontrol = SP.getBoolean("wearcontrol",false);
|
||||
boolean wearcontrol = SP.getBoolean("wearcontrol", false);
|
||||
|
||||
PutDataMapRequest dataMapRequest = PutDataMapRequest.create(NEW_PREFERENCES_PATH);
|
||||
//unique content
|
||||
|
|
|
@ -15,8 +15,14 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.events.EventBolusRequested;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressHelperActivity;
|
||||
import info.nightscout.androidaps.plugins.Overview.Notification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventNewNotification;
|
||||
import info.nightscout.androidaps.queue.commands.Command;
|
||||
import info.nightscout.androidaps.queue.commands.CommandBolus;
|
||||
import info.nightscout.androidaps.queue.commands.CommandCancelExtendedBolus;
|
||||
|
@ -148,6 +154,9 @@ public class CommandQueue {
|
|||
|
||||
notifyAboutNewCommand();
|
||||
|
||||
// Notify Wear about upcoming bolus
|
||||
MainApp.bus().post(new EventBolusRequested(detailedBolusInfo.insulin));
|
||||
|
||||
// Bring up bolus progress dialog
|
||||
detailedBolusInfo.insulin = MainApp.getConfigBuilder().applyBolusConstraints(detailedBolusInfo.insulin);
|
||||
detailedBolusInfo.carbs = MainApp.getConfigBuilder().applyCarbsConstraints((int) detailedBolusInfo.carbs);
|
||||
|
@ -179,8 +188,10 @@ public class CommandQueue {
|
|||
// remove all unfinished
|
||||
removeAll(Command.CommandType.TEMPBASAL);
|
||||
|
||||
Double rateAfterConstraints = MainApp.getConfigBuilder().applyBasalConstraints(absoluteRate);
|
||||
|
||||
// add new command to queue
|
||||
add(new CommandTempBasalAbsolute(absoluteRate, durationInMinutes, enforceNew, callback));
|
||||
add(new CommandTempBasalAbsolute(rateAfterConstraints, durationInMinutes, enforceNew, callback));
|
||||
|
||||
notifyAboutNewCommand();
|
||||
|
||||
|
@ -198,8 +209,10 @@ public class CommandQueue {
|
|||
// remove all unfinished
|
||||
removeAll(Command.CommandType.TEMPBASAL);
|
||||
|
||||
Integer percentAfterConstraints = MainApp.getConfigBuilder().applyBasalConstraints(percent);
|
||||
|
||||
// add new command to queue
|
||||
add(new CommandTempBasalPercent(percent, durationInMinutes, callback));
|
||||
add(new CommandTempBasalPercent(percentAfterConstraints, durationInMinutes, callback));
|
||||
|
||||
notifyAboutNewCommand();
|
||||
|
||||
|
@ -214,11 +227,13 @@ public class CommandQueue {
|
|||
return false;
|
||||
}
|
||||
|
||||
Double rateAfterConstraints = MainApp.getConfigBuilder().applyBolusConstraints(insulin);
|
||||
|
||||
// remove all unfinished
|
||||
removeAll(Command.CommandType.EXTENDEDBOLUS);
|
||||
|
||||
// add new command to queue
|
||||
add(new CommandExtendedBolus(insulin, durationInMinutes, callback));
|
||||
add(new CommandExtendedBolus(rateAfterConstraints, durationInMinutes, callback));
|
||||
|
||||
notifyAboutNewCommand();
|
||||
|
||||
|
@ -271,6 +286,29 @@ public class CommandQueue {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Compare with pump limits
|
||||
Profile.BasalValue[] basalValues = profile.getBasalValues();
|
||||
PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
|
||||
for (int index = 0; index < basalValues.length; index++) {
|
||||
if (basalValues[index].value < pump.getPumpDescription().basalMinimumRate) {
|
||||
Notification notification = new Notification(Notification.BASAL_VALUE_BELOW_MINIMUM, MainApp.sResources.getString(R.string.basalvaluebelowminimum), Notification.URGENT);
|
||||
MainApp.bus().post(new EventNewNotification(notification));
|
||||
if (callback != null)
|
||||
callback.result(new PumpEnactResult().success(false).comment(MainApp.sResources.getString(R.string.basalvaluebelowminimum))).run();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
MainApp.bus().post(new EventDismissNotification(Notification.BASAL_VALUE_BELOW_MINIMUM));
|
||||
|
||||
if (isThisProfileSet(profile)) {
|
||||
log.debug("Correct profile already set");
|
||||
if (callback != null)
|
||||
callback.result(new PumpEnactResult().success(true).enacted(false)).run();
|
||||
return false;
|
||||
}
|
||||
|
||||
// remove all unfinished
|
||||
removeAll(Command.CommandType.BASALPROFILE);
|
||||
|
||||
|
@ -333,4 +371,16 @@ public class CommandQueue {
|
|||
return Html.fromHtml(s);
|
||||
}
|
||||
|
||||
public boolean isThisProfileSet(Profile profile) {
|
||||
PumpInterface activePump = ConfigBuilderPlugin.getActivePump();
|
||||
if (activePump != null) {
|
||||
boolean result = activePump.isThisProfileSet(profile);
|
||||
if (!result) {
|
||||
log.debug("Current profile: " + MainApp.getConfigBuilder().getProfile().getData().toString());
|
||||
log.debug("New profile: " + profile.getData().toString());
|
||||
}
|
||||
return result;
|
||||
} else return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,6 +3,9 @@ package info.nightscout.androidaps.queue.commands;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Overview.Dialogs.BolusProgressDialog;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissBolusprogressIfRunning;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
|
||||
|
@ -21,7 +24,11 @@ public class CommandBolus extends Command {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
PumpEnactResult r = MainApp.getConfigBuilder().deliverTreatment(detailedBolusInfo);
|
||||
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().deliverTreatment(detailedBolusInfo);
|
||||
|
||||
BolusProgressDialog.bolusEnded = true;
|
||||
MainApp.bus().post(new EventDismissBolusprogressIfRunning(r));
|
||||
|
||||
if (callback != null)
|
||||
callback.result(r).run();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
package info.nightscout.androidaps.queue.commands;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
|
||||
/**
|
||||
|
@ -9,6 +14,7 @@ import info.nightscout.androidaps.queue.Callback;
|
|||
*/
|
||||
|
||||
public class CommandCancelExtendedBolus extends Command {
|
||||
private static Logger log = LoggerFactory.getLogger(CommandCancelExtendedBolus.class);
|
||||
|
||||
public CommandCancelExtendedBolus(Callback callback) {
|
||||
commandType = CommandType.EXTENDEDBOLUS;
|
||||
|
@ -17,7 +23,9 @@ public class CommandCancelExtendedBolus extends Command {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
PumpEnactResult r = MainApp.getConfigBuilder().cancelExtendedBolus();
|
||||
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().cancelExtendedBolus();
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("cancelExtendedBolus success: " + r.success + " enacted: " + r.enacted);
|
||||
if (callback != null)
|
||||
callback.result(r).run();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package info.nightscout.androidaps.queue.commands;
|
|||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
|
||||
/**
|
||||
|
@ -19,7 +20,7 @@ public class CommandCancelTempBasal extends Command {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
PumpEnactResult r = MainApp.getConfigBuilder().cancelTempBasal(enforceNew);
|
||||
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().cancelTempBasal(enforceNew);
|
||||
if (callback != null)
|
||||
callback.result(r).run();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
package info.nightscout.androidaps.queue.commands;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
|
||||
/**
|
||||
|
@ -9,6 +14,8 @@ import info.nightscout.androidaps.queue.Callback;
|
|||
*/
|
||||
|
||||
public class CommandExtendedBolus extends Command {
|
||||
private static Logger log = LoggerFactory.getLogger(CommandExtendedBolus.class);
|
||||
|
||||
private double insulin;
|
||||
private int durationInMinutes;
|
||||
|
||||
|
@ -21,7 +28,9 @@ public class CommandExtendedBolus extends Command {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
PumpEnactResult r = MainApp.getConfigBuilder().setExtendedBolus(insulin, durationInMinutes);
|
||||
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setExtendedBolus(insulin, durationInMinutes);
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("setExtendedBolus rate: " + insulin + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted);
|
||||
if (callback != null)
|
||||
callback.result(r).run();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package info.nightscout.androidaps.queue.commands;
|
||||
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
|
||||
/**
|
||||
|
@ -18,7 +19,7 @@ public class CommandReadStatus extends Command {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
MainApp.getConfigBuilder().getPumpStatus();
|
||||
ConfigBuilderPlugin.getActivePump().getPumpStatus();
|
||||
if (callback != null)
|
||||
callback.result(null).run();
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package info.nightscout.androidaps.queue.commands;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
|
||||
/**
|
||||
|
@ -20,7 +21,7 @@ public class CommandSetProfile extends Command {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
PumpEnactResult r = MainApp.getConfigBuilder().setNewBasalProfile(profile);
|
||||
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setNewBasalProfile(profile);
|
||||
if (callback != null)
|
||||
callback.result(r).run();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
package info.nightscout.androidaps.queue.commands;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
|
||||
/**
|
||||
|
@ -9,6 +14,8 @@ import info.nightscout.androidaps.queue.Callback;
|
|||
*/
|
||||
|
||||
public class CommandTempBasalAbsolute extends Command {
|
||||
private static Logger log = LoggerFactory.getLogger(CommandTempBasalAbsolute.class);
|
||||
|
||||
int durationInMinutes;
|
||||
double absoluteRate;
|
||||
boolean enforceNew;
|
||||
|
@ -23,7 +30,9 @@ public class CommandTempBasalAbsolute extends Command {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
PumpEnactResult r = MainApp.getConfigBuilder().setTempBasalAbsolute(absoluteRate, durationInMinutes, enforceNew);
|
||||
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setTempBasalAbsolute(absoluteRate, durationInMinutes, enforceNew);
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("setTempBasalAbsolute rate: " + absoluteRate + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted);
|
||||
if (callback != null)
|
||||
callback.result(r).run();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,12 @@
|
|||
package info.nightscout.androidaps.queue.commands;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.data.PumpEnactResult;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.queue.Callback;
|
||||
|
||||
/**
|
||||
|
@ -9,6 +14,8 @@ import info.nightscout.androidaps.queue.Callback;
|
|||
*/
|
||||
|
||||
public class CommandTempBasalPercent extends Command {
|
||||
private static Logger log = LoggerFactory.getLogger(CommandTempBasalPercent.class);
|
||||
|
||||
int durationInMinutes;
|
||||
int percent;
|
||||
|
||||
|
@ -21,7 +28,9 @@ public class CommandTempBasalPercent extends Command {
|
|||
|
||||
@Override
|
||||
public void execute() {
|
||||
PumpEnactResult r = MainApp.getConfigBuilder().setTempBasalPercent(percent, durationInMinutes);
|
||||
PumpEnactResult r = ConfigBuilderPlugin.getActivePump().setTempBasalPercent(percent, durationInMinutes);
|
||||
if (Config.logCongigBuilderActions)
|
||||
log.debug("setTempBasalPercent percent: " + percent + " durationInMinutes: " + durationInMinutes + " success: " + r.success + " enacted: " + r.enacted);
|
||||
if (callback != null)
|
||||
callback.result(r).run();
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import info.nightscout.androidaps.Constants;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
|
||||
public class KeepAliveReceiver extends BroadcastReceiver {
|
||||
private static Logger log = LoggerFactory.getLogger(KeepAliveReceiver.class);
|
||||
|
@ -33,7 +34,7 @@ public class KeepAliveReceiver extends BroadcastReceiver {
|
|||
wl.acquire();
|
||||
|
||||
|
||||
final PumpInterface pump = MainApp.getConfigBuilder();
|
||||
final PumpInterface pump = ConfigBuilderPlugin.getActivePump();
|
||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
if (pump != null && profile != null && profile.getBasal() != null) {
|
||||
boolean isBasalOutdated = false;
|
||||
|
|
|
@ -6,6 +6,7 @@ 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.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
|
||||
/**
|
||||
* Created by mike on 11.10.2016.
|
||||
|
@ -124,7 +125,7 @@ public class BolusWizard {
|
|||
calculatedTotalInsulin = 0d;
|
||||
}
|
||||
|
||||
double bolusStep = MainApp.getConfigBuilder().getPumpDescription().bolusStep;
|
||||
double bolusStep = ConfigBuilderPlugin.getActivePump().getPumpDescription().bolusStep;
|
||||
calculatedTotalInsulin = Round.roundTo(calculatedTotalInsulin, bolusStep);
|
||||
|
||||
return calculatedTotalInsulin;
|
||||
|
|
|
@ -23,6 +23,7 @@ import info.nightscout.androidaps.db.ExtendedBolus;
|
|||
import info.nightscout.androidaps.db.ProfileSwitch;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.db.Treatment;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
||||
import info.nightscout.androidaps.plugins.Loop.DeviceStatus;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
|
@ -220,7 +221,7 @@ public class NSUpload {
|
|||
log.debug("OpenAPS data too old to upload");
|
||||
}
|
||||
deviceStatus.device = "openaps://" + Build.MANUFACTURER + " " + Build.MODEL;
|
||||
JSONObject pumpstatus = MainApp.getConfigBuilder().getJSONStatus();
|
||||
JSONObject pumpstatus = ConfigBuilderPlugin.getActivePump().getJSONStatus();
|
||||
if (pumpstatus != null) {
|
||||
deviceStatus.pump = pumpstatus;
|
||||
}
|
||||
|
|
|
@ -180,6 +180,15 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/overview_extendedbolus"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="@color/mdtp_white" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -175,6 +175,15 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/overview_extendedbolus"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center_horizontal"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall"
|
||||
android:textColor="@color/mdtp_white" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -475,7 +475,7 @@
|
|||
<string name="tempbasals_realduration_label_string">DUR:</string>
|
||||
<string name="tempbasaldeliveryerror">Errore di somministrazione basale temporale</string>
|
||||
<string name="smscommunicator_tempbasalset" formatted="false">Basale temporanea %.2fU/h for %d min avviata con successo</string>
|
||||
<string name="smscommunicator_suspendreplywithcode" formatted="false">Sospendi il loop per %d minuti riprendi</string>
|
||||
<string name="smscommunicator_suspendreplywithcode" formatted="false">Sospendi il loop per %d minuti riprendi %s</string>
|
||||
<string name="smscommunicator_calibrationsent">La calibrazione è stata inviata. La ricezione deve essere abilitata in xDrip.</string>
|
||||
<string name="smscommunicator_basalstopreplywithcode" formatted="false">Per interrompere la risposta basale della temperatura con il codice %s</string>
|
||||
<string name="smscommunicator_allowednumbers_summary">+XXXXXXXXXX;+YYYYYYYYYY</string>
|
||||
|
|
Loading…
Reference in a new issue