simplify active pump access where possible
This commit is contained in:
parent
8bae1a18e4
commit
d40e0c97c4
13 changed files with 77 additions and 95 deletions
|
@ -17,7 +17,6 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.Config;
|
||||
import info.nightscout.androidaps.Constants;
|
||||
|
@ -25,11 +24,10 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.data.MealData;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.db.TemporaryBasal;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.LoggerCallback;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
|
@ -186,7 +184,7 @@ public class DetermineBasalAdapterAMAJS {
|
|||
double minBg,
|
||||
double maxBg,
|
||||
double targetBg,
|
||||
PumpInterface pump,
|
||||
double basalrate,
|
||||
IobTotal[] iobArray,
|
||||
GlucoseStatus glucoseStatus,
|
||||
MealData mealData,
|
||||
|
@ -210,7 +208,7 @@ public class DetermineBasalAdapterAMAJS {
|
|||
mProfile.put("max_daily_safety_multiplier", SP.getInt("openapsama_max_daily_safety_multiplier", 3));
|
||||
mProfile.put("current_basal_safety_multiplier", SP.getInt("openapsama_current_basal_safety_multiplier", 4));
|
||||
mProfile.put("skip_neutral_temps", true);
|
||||
mProfile.put("current_basal", pump.getBaseBasalRate());
|
||||
mProfile.put("current_basal", basalrate);
|
||||
mProfile.put("temptargetSet", tempTargetSet);
|
||||
mProfile.put("autosens_adjust_targets", SP.getBoolean("openapsama_autosens_adjusttargets", true));
|
||||
mProfile.put("min_5m_carbimpact", SP.getDouble("openapsama_min_5m_carbimpact", 3d));
|
||||
|
|
|
@ -14,15 +14,15 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.data.MealData;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.db.TempTarget;
|
||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.AutosensResult;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
||||
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
@ -147,7 +147,6 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
|||
|
||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
PumpInterface pump = MainApp.getConfigBuilder();
|
||||
|
||||
if (profile == null) {
|
||||
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.noprofileselected)));
|
||||
|
@ -215,7 +214,7 @@ 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(pump.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()) {
|
||||
|
@ -229,7 +228,7 @@ public class OpenAPSAMAPlugin implements PluginBase, APSInterface {
|
|||
start = new Date();
|
||||
|
||||
try {
|
||||
determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, pump, iobArray, glucoseStatus, mealData,
|
||||
determineBasalAdapterAMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, ConfigBuilderPlugin.getActivePump().getBaseBasalRate(), iobArray, glucoseStatus, mealData,
|
||||
lastAutosensResult.ratio, //autosensDataRatio
|
||||
isTempTarget,
|
||||
SafeParse.stringToDouble(SP.getString("openapsama_min_5m_carbimpact", "3.0"))//min_5m_carbimpact
|
||||
|
|
|
@ -22,9 +22,8 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.data.MealData;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
||||
import info.nightscout.utils.SP;
|
||||
|
||||
public class DetermineBasalAdapterMAJS {
|
||||
|
@ -155,7 +154,7 @@ public class DetermineBasalAdapterMAJS {
|
|||
double minBg,
|
||||
double maxBg,
|
||||
double targetBg,
|
||||
PumpInterface pump,
|
||||
double basalRate,
|
||||
IobTotal iobData,
|
||||
GlucoseStatus glucoseStatus,
|
||||
MealData mealData) throws JSONException {
|
||||
|
@ -174,7 +173,7 @@ public class DetermineBasalAdapterMAJS {
|
|||
mProfile.put("carb_ratio", profile.getIc());
|
||||
mProfile.put("sens", Profile.toMgdl(profile.getIsf().doubleValue(), units));
|
||||
|
||||
mProfile.put("current_basal", pump.getBaseBasalRate());
|
||||
mProfile.put("current_basal", basalRate);
|
||||
|
||||
if (units.equals(Constants.MMOL)) {
|
||||
mProfile.put("out_units", "mmol/L");
|
||||
|
|
|
@ -14,13 +14,13 @@ import info.nightscout.androidaps.R;
|
|||
import info.nightscout.androidaps.data.GlucoseStatus;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.data.MealData;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.db.TempTarget;
|
||||
import info.nightscout.androidaps.interfaces.APSInterface;
|
||||
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.APSResult;
|
||||
import info.nightscout.androidaps.plugins.Loop.ScriptReader;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateGui;
|
||||
import info.nightscout.androidaps.plugins.OpenAPSMA.events.EventOpenAPSUpdateResultGui;
|
||||
import info.nightscout.utils.DateUtil;
|
||||
|
@ -145,7 +145,6 @@ public class OpenAPSMAPlugin implements PluginBase, APSInterface {
|
|||
|
||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
PumpInterface pump = MainApp.getConfigBuilder();
|
||||
|
||||
if (profile == null) {
|
||||
MainApp.bus().post(new EventOpenAPSUpdateResultGui(MainApp.instance().getString(R.string.noprofileselected)));
|
||||
|
@ -213,11 +212,11 @@ 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(pump.getBaseBasalRate(), "current_basal", 0.01, 5)) return;
|
||||
if (!checkOnlyHardLimits(ConfigBuilderPlugin.getActivePump().getBaseBasalRate(), "current_basal", 0.01, 5)) return;
|
||||
|
||||
start = new Date();
|
||||
try {
|
||||
determineBasalAdapterMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, pump, iobTotal, glucoseStatus, mealData);
|
||||
determineBasalAdapterMAJS.setData(profile, maxIob, maxBasal, minBg, maxBg, targetBg, ConfigBuilderPlugin.getActivePump().getBaseBasalRate(), iobTotal, glucoseStatus, mealData);
|
||||
} catch (JSONException e) {
|
||||
log.error("Unhandled exception", e);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ import info.nightscout.androidaps.events.EventRefreshOverview;
|
|||
import info.nightscout.androidaps.events.EventTempBasalChange;
|
||||
import info.nightscout.androidaps.events.EventTreatmentChange;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
|
||||
/**
|
||||
|
@ -136,8 +136,6 @@ public class PersistentNotificationPlugin implements PluginBase {
|
|||
}
|
||||
}
|
||||
|
||||
PumpInterface pump = MainApp.getConfigBuilder();
|
||||
|
||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||
TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
||||
line1 += " " + activeTemp.toStringShort();
|
||||
|
@ -154,7 +152,7 @@ public class PersistentNotificationPlugin implements PluginBase {
|
|||
+ ctx.getString(R.string.basal) + ": " + DecimalFormatter.to2Decimal(basalIob.basaliob) + "U)";
|
||||
|
||||
|
||||
String line3 = DecimalFormatter.to2Decimal(pump.getBaseBasalRate()) + " U/h";
|
||||
String line3 = DecimalFormatter.to2Decimal(ConfigBuilderPlugin.getActivePump().getBaseBasalRate()) + " U/h";
|
||||
|
||||
|
||||
line3 += " - " + MainApp.getConfigBuilder().getProfileName();
|
||||
|
|
|
@ -35,11 +35,11 @@ import info.nightscout.androidaps.MainApp;
|
|||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||
import info.nightscout.androidaps.events.EventProfileSwitchChange;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
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;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
||||
|
@ -151,8 +151,7 @@ public class CircadianPercentageProfileFragment extends SubscriberFragment {
|
|||
iceditIcon = (ImageView) layout.findViewById(R.id.circadianpercentageprofile_icedit);
|
||||
isfeditIcon = (ImageView) layout.findViewById(R.id.circadianpercentageprofile_isfedit);
|
||||
|
||||
PumpInterface pump = MainApp.getConfigBuilder();
|
||||
if (!pump.getPumpDescription().isTempBasalCapable) {
|
||||
if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) {
|
||||
layout.findViewById(R.id.circadianpercentageprofile_baseprofilebasal_layout).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
@ -334,7 +333,8 @@ public class CircadianPercentageProfileFragment extends SubscriberFragment {
|
|||
adb.setPositiveButton("MIGRATE", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
CircadianPercentageProfilePlugin.migrateToLP();
|
||||
} });
|
||||
}
|
||||
});
|
||||
adb.setNegativeButton("Cancel", null);
|
||||
adb.show();
|
||||
}
|
||||
|
@ -366,7 +366,7 @@ public class CircadianPercentageProfileFragment extends SubscriberFragment {
|
|||
}
|
||||
|
||||
private void customSnackbar(View view, final String Msg, Object snackbarCaller) {
|
||||
if(mSnackBar!= null) mSnackBar.dismiss();
|
||||
if (mSnackBar != null) mSnackBar.dismiss();
|
||||
|
||||
this.snackbarCaller = snackbarCaller;
|
||||
if (timeshiftViewHint || percentageViewHint) {
|
||||
|
|
|
@ -16,12 +16,10 @@ 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.data.ProfileStore;
|
||||
import info.nightscout.androidaps.interfaces.PluginBase;
|
||||
import info.nightscout.androidaps.interfaces.ProfileInterface;
|
||||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||
import info.nightscout.androidaps.plugins.ConfigBuilder.ConfigBuilderPlugin;
|
||||
import info.nightscout.androidaps.plugins.ProfileLocal.LocalProfilePlugin;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.NSUpload;
|
||||
|
@ -173,34 +171,33 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
|||
|
||||
String msg = "";
|
||||
|
||||
if (!fragmentEnabled){
|
||||
msg+= "NO CPP!" + "\n";
|
||||
if (!fragmentEnabled) {
|
||||
msg += "NO CPP!" + "\n";
|
||||
}
|
||||
|
||||
//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 PumpInterface pump = MainApp.getConfigBuilder();
|
||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
|
||||
if (pump == null || 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);
|
||||
return msg;
|
||||
}
|
||||
|
||||
//store profile
|
||||
this.timeshift= timeshift;
|
||||
this.percentage = percentage;
|
||||
this.timeshift = timeshift;
|
||||
this.percentage = percentage;
|
||||
storeSettings();
|
||||
|
||||
|
||||
|
@ -218,7 +215,7 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
|||
return msg;
|
||||
}
|
||||
|
||||
public static void migrateToLP(){
|
||||
public static void migrateToLP() {
|
||||
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
|
||||
SharedPreferences.Editor editor = settings.edit();
|
||||
editor.putBoolean("LocalProfile" + "mmol", SP.getBoolean(SETTINGS_PREFIX + "mmol", false));
|
||||
|
@ -232,7 +229,7 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
|||
JSONArray targetHigh = new JSONArray().put(new JSONObject().put("time", "00:00").put("timeAsSeconds", 0).put("value", SP.getDouble(SETTINGS_PREFIX + "targethigh", 120d)));
|
||||
editor.putString("LocalProfile" + "targetlow", targetLow.toString());
|
||||
editor.putString("LocalProfile" + "targethigh", targetHigh.toString());
|
||||
} catch (JSONException e) {
|
||||
} catch (JSONException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
editor.commit();
|
||||
|
@ -247,19 +244,19 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
|||
|
||||
}
|
||||
|
||||
public static String getLPisf(){
|
||||
public static String getLPisf() {
|
||||
return getLPConversion("baseisf", 35d);
|
||||
}
|
||||
|
||||
public static String getLPic(){
|
||||
public static String getLPic() {
|
||||
return getLPConversion("baseic", 4);
|
||||
}
|
||||
|
||||
public static String getLPbasal(){
|
||||
public static String getLPbasal() {
|
||||
return getLPConversion("basebasal", 1);
|
||||
}
|
||||
|
||||
public static String getLPConversion(String type, double defaultValue){
|
||||
public static String getLPConversion(String type, double defaultValue) {
|
||||
try {
|
||||
JSONArray jsonArray = new JSONArray();
|
||||
double last = -1d;
|
||||
|
@ -269,10 +266,10 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
|||
String time;
|
||||
DecimalFormat df = new DecimalFormat("00");
|
||||
time = df.format(i) + ":00";
|
||||
if(last != value) {
|
||||
if (last != value) {
|
||||
jsonArray.put(new JSONObject().put("time", time).put("timeAsSeconds", i * 60 * 60).put("value", value));
|
||||
}
|
||||
last = value;
|
||||
last = value;
|
||||
}
|
||||
return jsonArray.toString();
|
||||
} catch (JSONException e) {
|
||||
|
|
|
@ -23,11 +23,11 @@ import java.text.DecimalFormat;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
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;
|
||||
import info.nightscout.utils.DecimalFormatter;
|
||||
import info.nightscout.utils.NumberPicker;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
@ -59,8 +59,8 @@ public class LocalProfileFragment extends SubscriberFragment {
|
|||
@Override
|
||||
public void run() {
|
||||
localProfilePlugin.storeSettings();
|
||||
if(basalView!=null){
|
||||
basalView.updateLabel(MainApp.sResources.getString(R.string.nsprofileview_basal_label)+ ": "+ getSumLabel());
|
||||
if (basalView != null) {
|
||||
basalView.updateLabel(MainApp.sResources.getString(R.string.nsprofileview_basal_label) + ": " + getSumLabel());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -91,12 +91,11 @@ public class LocalProfileFragment extends SubscriberFragment {
|
|||
mmolView = (RadioButton) layout.findViewById(R.id.localprofile_mmol);
|
||||
icView = new TimeListEdit(getContext(), layout, R.id.localprofile_ic, MainApp.sResources.getString(R.string.nsprofileview_ic_label) + ":", getPlugin().ic, null, 0.1d, new DecimalFormat("0.0"), save);
|
||||
isfView = new TimeListEdit(getContext(), layout, R.id.localprofile_isf, MainApp.sResources.getString(R.string.nsprofileview_isf_label) + ":", getPlugin().isf, null, 0.1d, new DecimalFormat("0.0"), save);
|
||||
basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.sResources.getString(R.string.nsprofileview_basal_label)+ ": " + getSumLabel(), getPlugin().basal, null, 0.01d, new DecimalFormat("0.00"), save);
|
||||
targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.sResources.getString(R.string.nsprofileview_target_label)+ ":", getPlugin().targetLow, getPlugin().targetHigh, 0.1d, new DecimalFormat("0.0"), save);
|
||||
basalView = new TimeListEdit(getContext(), layout, R.id.localprofile_basal, MainApp.sResources.getString(R.string.nsprofileview_basal_label) + ": " + getSumLabel(), getPlugin().basal, null, 0.01d, new DecimalFormat("0.00"), save);
|
||||
targetView = new TimeListEdit(getContext(), layout, R.id.localprofile_target, MainApp.sResources.getString(R.string.nsprofileview_target_label) + ":", getPlugin().targetLow, getPlugin().targetHigh, 0.1d, new DecimalFormat("0.0"), save);
|
||||
profileswitchButton = (Button) layout.findViewById(R.id.localprofile_profileswitch);
|
||||
|
||||
PumpInterface pump = MainApp.getConfigBuilder();
|
||||
if (!pump.getPumpDescription().isTempBasalCapable) {
|
||||
if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) {
|
||||
layout.findViewById(R.id.localprofile_basal).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
@ -148,7 +147,7 @@ public class LocalProfileFragment extends SubscriberFragment {
|
|||
|
||||
@NonNull
|
||||
public String getSumLabel() {
|
||||
return " ∑" + DecimalFormatter.to2Decimal(localProfilePlugin.getProfile().getDefaultProfile().baseBasalSum()) +"U";
|
||||
return " ∑" + DecimalFormatter.to2Decimal(localProfilePlugin.getProfile().getDefaultProfile().baseBasalSum()) + "U";
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
|
|
@ -19,6 +19,7 @@ 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.utils.SP;
|
||||
|
@ -119,9 +120,8 @@ public class NSProfilePlugin implements PluginBase, ProfileInterface {
|
|||
profile = new ProfileStore(newProfile.getData());
|
||||
storeNSProfile();
|
||||
MainApp.bus().post(new EventNSProfileUpdateGUI());
|
||||
PumpInterface pump = MainApp.getConfigBuilder();
|
||||
if (SP.getBoolean("syncprofiletopump", false)) {
|
||||
if (pump.setNewBasalProfile(MainApp.getConfigBuilder().getProfile()) == PumpInterface.SUCCESS) {
|
||||
if (ConfigBuilderPlugin.getActivePump().setNewBasalProfile(MainApp.getConfigBuilder().getProfile()) == PumpInterface.SUCCESS) {
|
||||
SmsCommunicatorPlugin smsCommunicatorPlugin = MainApp.getSpecificPlugin(SmsCommunicatorPlugin.class);
|
||||
if (smsCommunicatorPlugin != null && smsCommunicatorPlugin.isEnabled(PluginBase.GENERAL)) {
|
||||
smsCommunicatorPlugin.sendNotificationToAllNumbers(MainApp.sResources.getString(R.string.profile_set_ok));
|
||||
|
|
|
@ -21,11 +21,11 @@ import org.slf4j.LoggerFactory;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.events.EventInitializationChanged;
|
||||
import info.nightscout.androidaps.interfaces.PumpInterface;
|
||||
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;
|
||||
import info.nightscout.utils.SafeParse;
|
||||
|
||||
public class SimpleProfileFragment extends SubscriberFragment {
|
||||
|
@ -56,8 +56,7 @@ public class SimpleProfileFragment extends SubscriberFragment {
|
|||
targethighView = (EditText) layout.findViewById(R.id.simpleprofile_targethigh);
|
||||
profileswitchButton = (Button) layout.findViewById(R.id.simpleprofile_profileswitch);
|
||||
|
||||
PumpInterface pump = MainApp.getConfigBuilder();
|
||||
if (!pump.getPumpDescription().isTempBasalCapable) {
|
||||
if (!ConfigBuilderPlugin.getActivePump().getPumpDescription().isTempBasalCapable) {
|
||||
layout.findViewById(R.id.simpleprofile_basalrate).setVisibility(View.GONE);
|
||||
layout.findViewById(R.id.simpleprofile_basalrate_label).setVisibility(View.GONE);
|
||||
}
|
||||
|
|
|
@ -477,24 +477,22 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
|||
bolusWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - bolusWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
|
||||
bolusWaitingForConfirmation.processed = true;
|
||||
PumpInterface pumpInterface = MainApp.getConfigBuilder();
|
||||
if (pumpInterface != null) {
|
||||
danaRPlugin = MainApp.getSpecificPlugin(DanaRPlugin.class);
|
||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||
detailedBolusInfo.insulin = bolusWaitingForConfirmation.bolusRequested;
|
||||
detailedBolusInfo.source = Source.USER;
|
||||
PumpEnactResult result = pumpInterface.deliverTreatment(detailedBolusInfo);
|
||||
if (result.success) {
|
||||
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_bolusdelivered), result.bolusDelivered);
|
||||
if (danaRPlugin != null)
|
||||
reply += "\n" + danaRPlugin.shortStatus(true);
|
||||
lastRemoteBolusTime = new Date();
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
} else {
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_bolusfailed);
|
||||
if (danaRPlugin != null)
|
||||
reply += "\n" + danaRPlugin.shortStatus(true);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
danaRPlugin = MainApp.getSpecificPlugin(DanaRPlugin.class);
|
||||
DetailedBolusInfo detailedBolusInfo = new DetailedBolusInfo();
|
||||
detailedBolusInfo.insulin = bolusWaitingForConfirmation.bolusRequested;
|
||||
detailedBolusInfo.source = Source.USER;
|
||||
PumpEnactResult result = pumpInterface.deliverTreatment(detailedBolusInfo);
|
||||
if (result.success) {
|
||||
reply = String.format(MainApp.sResources.getString(R.string.smscommunicator_bolusdelivered), result.bolusDelivered);
|
||||
if (danaRPlugin != null)
|
||||
reply += "\n" + danaRPlugin.shortStatus(true);
|
||||
lastRemoteBolusTime = new Date();
|
||||
sendSMSToAllNumbers(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
} else {
|
||||
reply = MainApp.sResources.getString(R.string.smscommunicator_bolusfailed);
|
||||
if (danaRPlugin != null)
|
||||
reply += "\n" + danaRPlugin.shortStatus(true);
|
||||
sendSMS(new Sms(receivedSms.phoneNumber, reply, new Date()));
|
||||
}
|
||||
} else if (tempBasalWaitingForConfirmation != null && !tempBasalWaitingForConfirmation.processed &&
|
||||
tempBasalWaitingForConfirmation.confirmCode.equals(splited[0]) && System.currentTimeMillis() - tempBasalWaitingForConfirmation.date.getTime() < CONFIRM_TIMEOUT) {
|
||||
|
|
|
@ -15,10 +15,10 @@ import info.nightscout.androidaps.Constants;
|
|||
import info.nightscout.androidaps.MainApp;
|
||||
import info.nightscout.androidaps.R;
|
||||
import info.nightscout.androidaps.data.DetailedBolusInfo;
|
||||
import info.nightscout.androidaps.data.Intervals;
|
||||
import info.nightscout.androidaps.data.Iob;
|
||||
import info.nightscout.androidaps.data.IobTotal;
|
||||
import info.nightscout.androidaps.data.MealData;
|
||||
import info.nightscout.androidaps.data.Intervals;
|
||||
import info.nightscout.androidaps.data.NonOverlappingIntervals;
|
||||
import info.nightscout.androidaps.data.OverlappingIntervals;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
|
@ -33,8 +33,8 @@ import info.nightscout.androidaps.events.EventReloadTempBasalData;
|
|||
import info.nightscout.androidaps.events.EventReloadTreatmentData;
|
||||
import info.nightscout.androidaps.events.EventTempTargetChange;
|
||||
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.IobCobCalculator.AutosensData;
|
||||
import info.nightscout.androidaps.plugins.IobCobCalculator.IobCobCalculatorPlugin;
|
||||
import info.nightscout.utils.SP;
|
||||
|
@ -200,8 +200,8 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
if (!t.isSMB) {
|
||||
// instead of dividing the DIA that only worked on the bilinear curves,
|
||||
// multiply the time the treatment is seen active.
|
||||
long timeSinceTreatment = time - t.date;
|
||||
long snoozeTime = t.date + (long)(timeSinceTreatment * SP.getDouble("openapsama_bolussnooze_dia_divisor", 2.0));
|
||||
long timeSinceTreatment = time - t.date;
|
||||
long snoozeTime = t.date + (long) (timeSinceTreatment * SP.getDouble("openapsama_bolussnooze_dia_divisor", 2.0));
|
||||
Iob bIOB = t.iobCalc(snoozeTime, dia);
|
||||
total.bolussnooze += bIOB.iobContrib;
|
||||
} else {
|
||||
|
@ -384,18 +384,16 @@ public class TreatmentsPlugin implements PluginBase, TreatmentsInterface {
|
|||
|
||||
@Override
|
||||
public double getTempBasalAbsoluteRateHistory() {
|
||||
PumpInterface pump = MainApp.getConfigBuilder();
|
||||
|
||||
TemporaryBasal tb = getTempBasalFromHistory(System.currentTimeMillis());
|
||||
if (tb != null) {
|
||||
if (tb.isFakeExtended){
|
||||
double baseRate = pump.getBaseBasalRate();
|
||||
if (tb.isFakeExtended) {
|
||||
double baseRate = ConfigBuilderPlugin.getActivePump().getBaseBasalRate();
|
||||
double tempRate = baseRate + tb.netExtendedRate;
|
||||
return tempRate;
|
||||
} else if (tb.isAbsolute) {
|
||||
return tb.absoluteRate;
|
||||
} else {
|
||||
double baseRate = pump.getBaseBasalRate();
|
||||
double baseRate = ConfigBuilderPlugin.getActivePump().getBaseBasalRate();
|
||||
double tempRate = baseRate * (tb.percentRate / 100d);
|
||||
return tempRate;
|
||||
}
|
||||
|
|
|
@ -13,12 +13,12 @@ import java.util.Date;
|
|||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import info.nightscout.androidaps.BuildConfig;
|
||||
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.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;
|
||||
|
@ -35,7 +35,6 @@ import info.nightscout.androidaps.plugins.Actions.dialogs.FillDialog;
|
|||
import info.nightscout.androidaps.plugins.Careportal.Dialogs.NewNSTreatmentDialog;
|
||||
import info.nightscout.androidaps.plugins.Loop.APSResult;
|
||||
import info.nightscout.androidaps.plugins.Loop.LoopPlugin;
|
||||
import info.nightscout.androidaps.data.Profile;
|
||||
import info.nightscout.androidaps.plugins.Overview.events.EventDismissNotification;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPlugin;
|
||||
import info.nightscout.androidaps.plugins.PumpDanaR.DanaRPump;
|
||||
|
@ -586,10 +585,9 @@ public class ActionStringHandler {
|
|||
if(!SP.getBoolean("syncprofiletopump", false)){
|
||||
msg+= MainApp.sResources.getString(R.string.syncprofiletopump_title) + " " + MainApp.sResources.getString(R.string.cpp_sync_setting_missing) + "\n";
|
||||
}
|
||||
final PumpInterface pump = MainApp.getConfigBuilder();
|
||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||
|
||||
if (pump == null || profile == null || profile.getBasal() == null){
|
||||
if (profile == null || profile.getBasal() == null){
|
||||
msg+= MainApp.sResources.getString(R.string.cpp_notloadedplugins) + "\n";
|
||||
}
|
||||
if(!"".equals(msg)) {
|
||||
|
|
Loading…
Reference in a new issue