use global units setting
This commit is contained in:
parent
5cc19d2b87
commit
02891a14fc
54 changed files with 222 additions and 303 deletions
|
@ -249,8 +249,6 @@ public class MainActivity extends NoSplashAppCompatActivity {
|
||||||
|
|
||||||
private void doMigrations() {
|
private void doMigrations() {
|
||||||
|
|
||||||
checkUpgradeToProfileTarget();
|
|
||||||
|
|
||||||
// guarantee that the unreachable threshold is at least 30 and of type String
|
// guarantee that the unreachable threshold is at least 30 and of type String
|
||||||
// Added in 1.57 at 21.01.2018
|
// Added in 1.57 at 21.01.2018
|
||||||
int unreachable_threshold = SP.getInt(R.string.key_pump_unreachable_threshold, 30);
|
int unreachable_threshold = SP.getInt(R.string.key_pump_unreachable_threshold, 30);
|
||||||
|
@ -260,26 +258,6 @@ public class MainActivity extends NoSplashAppCompatActivity {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void checkUpgradeToProfileTarget() { // TODO: can be removed in the future
|
|
||||||
boolean oldKeyExists = SP.contains("openapsma_min_bg");
|
|
||||||
if (oldKeyExists) {
|
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
|
||||||
String oldRange = SP.getDouble("openapsma_min_bg", 0d) + " - " + SP.getDouble("openapsma_max_bg", 0d);
|
|
||||||
String newRange = "";
|
|
||||||
if (profile != null) {
|
|
||||||
newRange = profile.getTargetLow() + " - " + profile.getTargetHigh();
|
|
||||||
}
|
|
||||||
String message = "Target range is changed in current version.\n\nIt's not taken from preferences but from profile.\n\n!!! REVIEW YOUR SETTINGS !!!";
|
|
||||||
message += "\n\nOld settings: " + oldRange;
|
|
||||||
message += "\nProfile settings: " + newRange;
|
|
||||||
OKDialog.show(this, "Target range change", message, () -> {
|
|
||||||
SP.remove("openapsma_min_bg");
|
|
||||||
SP.remove("openapsma_max_bg");
|
|
||||||
SP.remove("openapsma_target_bg");
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
|
|
@ -231,9 +231,8 @@ public class HistoryBrowseActivity extends NoSplashActivity {
|
||||||
noProfile.setVisibility(View.GONE);
|
noProfile.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String units = profile.getUnits();
|
final double lowLine = OverviewPlugin.INSTANCE.determineLowLine();
|
||||||
final double lowLine = OverviewPlugin.INSTANCE.determineLowLine(units);
|
final double highLine = OverviewPlugin.INSTANCE.determineHighLine();
|
||||||
final double highLine = OverviewPlugin.INSTANCE.determineHighLine(units);
|
|
||||||
|
|
||||||
buttonDate.setText(DateUtil.dateAndTimeString(start));
|
buttonDate.setText(DateUtil.dateAndTimeString(start));
|
||||||
buttonZoom.setText(String.valueOf(rangeToDisplay));
|
buttonZoom.setText(String.valueOf(rangeToDisplay));
|
||||||
|
|
|
@ -149,7 +149,7 @@ public class Profile {
|
||||||
return units;
|
return units;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TimeZone getTimeZone() {
|
TimeZone getTimeZone() {
|
||||||
return timeZone;
|
return timeZone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ public class Profile {
|
||||||
double multiplier = getMultiplier(array);
|
double multiplier = getMultiplier(array);
|
||||||
|
|
||||||
LongSparseArray<Double> sparse = new LongSparseArray<>();
|
LongSparseArray<Double> sparse = new LongSparseArray<>();
|
||||||
for (Integer index = 0; index < array.length(); index++) {
|
for (int index = 0; index < array.length(); index++) {
|
||||||
try {
|
try {
|
||||||
final JSONObject o = array.getJSONObject(index);
|
final JSONObject o = array.getJSONObject(index);
|
||||||
long tas = 0;
|
long tas = 0;
|
||||||
|
@ -385,12 +385,12 @@ public class Profile {
|
||||||
return retValue;
|
return retValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getIsf() {
|
public double getIsfMgdl() {
|
||||||
return getIsfTimeFromMidnight(secondsFromMidnight());
|
return toMgdl(getIsfTimeFromMidnight(secondsFromMidnight()), units);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getIsf(long time) {
|
public double getIsfMgdl(long time) {
|
||||||
return getIsfTimeFromMidnight(secondsFromMidnight(time));
|
return toMgdl(getIsfTimeFromMidnight(secondsFromMidnight(time)), units);
|
||||||
}
|
}
|
||||||
|
|
||||||
double getIsfTimeFromMidnight(int timeAsSeconds) {
|
double getIsfTimeFromMidnight(int timeAsSeconds) {
|
||||||
|
@ -405,15 +405,15 @@ public class Profile {
|
||||||
return getValuesList(isf_v, null, new DecimalFormat("0.0"), getUnits() + MainApp.gs(R.string.profile_per_unit));
|
return getValuesList(isf_v, null, new DecimalFormat("0.0"), getUnits() + MainApp.gs(R.string.profile_per_unit));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProfileValue[] getIsfs() {
|
public ProfileValue[] getIsfsMgdl() {
|
||||||
if (isf_v == null)
|
if (isf_v == null)
|
||||||
isf_v = convertToSparseArray(ic);
|
isf_v = convertToSparseArray(ic);
|
||||||
ProfileValue[] ret = new ProfileValue[isf_v.size()];
|
ProfileValue[] ret = new ProfileValue[isf_v.size()];
|
||||||
|
|
||||||
for (Integer index = 0; index < isf_v.size(); index++) {
|
for (int index = 0; index < isf_v.size(); index++) {
|
||||||
Integer tas = (int) isf_v.keyAt(index);
|
int tas = (int) isf_v.keyAt(index);
|
||||||
double value = isf_v.valueAt(index);
|
double value = isf_v.valueAt(index);
|
||||||
ret[index] = new ProfileValue(tas, value);
|
ret[index] = new ProfileValue(tas, toMgdl(value, units));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -495,44 +495,44 @@ public class Profile {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTarget() {
|
public double getTargetMgdl() {
|
||||||
return getTarget(secondsFromMidnight());
|
return getTargetMgdl(secondsFromMidnight());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected double getTarget(int timeAsSeconds) {
|
public double getTargetMgdl(int timeAsSeconds) {
|
||||||
return (getTargetLowTimeFromMidnight(timeAsSeconds) + getTargetHighTimeFromMidnight(timeAsSeconds)) / 2;
|
return toMgdl((getTargetLowTimeFromMidnight(timeAsSeconds) + getTargetHighTimeFromMidnight(timeAsSeconds)) / 2, units);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTargetLow() {
|
public double getTargetLowMgdl() {
|
||||||
return getTargetLowTimeFromMidnight(secondsFromMidnight());
|
return toMgdl(getTargetLowTimeFromMidnight(secondsFromMidnight()), units);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTargetLow(long time) {
|
public double getTargetLowMgdl(long time) {
|
||||||
return getTargetLowTimeFromMidnight(secondsFromMidnight(time));
|
return toMgdl(getTargetLowTimeFromMidnight(secondsFromMidnight(time)), units);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTargetLowTimeFromMidnight(int timeAsSeconds) {
|
double getTargetLowTimeFromMidnight(int timeAsSeconds) {
|
||||||
if (targetLow_v == null)
|
if (targetLow_v == null)
|
||||||
targetLow_v = convertToSparseArray(targetLow);
|
targetLow_v = convertToSparseArray(targetLow);
|
||||||
return getValueToTime(targetLow_v, timeAsSeconds);
|
return getValueToTime(targetLow_v, timeAsSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTargetHigh() {
|
public double getTargetHighMgdl() {
|
||||||
return getTargetHighTimeFromMidnight(secondsFromMidnight());
|
return toMgdl(getTargetHighTimeFromMidnight(secondsFromMidnight()), units);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTargetHigh(long time) {
|
public double getTargetHighMgdl(long time) {
|
||||||
return getTargetHighTimeFromMidnight(secondsFromMidnight(time));
|
return toMgdl(getTargetHighTimeFromMidnight(secondsFromMidnight(time)), units);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTargetHighTimeFromMidnight(int timeAsSeconds) {
|
double getTargetHighTimeFromMidnight(int timeAsSeconds) {
|
||||||
if (targetHigh_v == null)
|
if (targetHigh_v == null)
|
||||||
targetHigh_v = convertToSparseArray(targetHigh);
|
targetHigh_v = convertToSparseArray(targetHigh);
|
||||||
return getValueToTime(targetHigh_v, timeAsSeconds);
|
return getValueToTime(targetHigh_v, timeAsSeconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class TargetValue {
|
public class TargetValue {
|
||||||
public TargetValue(int timeAsSeconds, double low, double high) {
|
TargetValue(int timeAsSeconds, double low, double high) {
|
||||||
this.timeAsSeconds = timeAsSeconds;
|
this.timeAsSeconds = timeAsSeconds;
|
||||||
this.low = low;
|
this.low = low;
|
||||||
this.high = high;
|
this.high = high;
|
||||||
|
@ -559,17 +559,17 @@ public class Profile {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ProfileValue[] getSingleTargets() {
|
public ProfileValue[] getSingleTargetsMgdl() {
|
||||||
if (targetLow_v == null)
|
if (targetLow_v == null)
|
||||||
targetLow_v = convertToSparseArray(targetLow);
|
targetLow_v = convertToSparseArray(targetLow);
|
||||||
if (targetHigh_v == null)
|
if (targetHigh_v == null)
|
||||||
targetHigh_v = convertToSparseArray(targetHigh);
|
targetHigh_v = convertToSparseArray(targetHigh);
|
||||||
ProfileValue[] ret = new ProfileValue[targetLow_v.size()];
|
ProfileValue[] ret = new ProfileValue[targetLow_v.size()];
|
||||||
|
|
||||||
for (Integer index = 0; index < targetLow_v.size(); index++) {
|
for (int index = 0; index < targetLow_v.size(); index++) {
|
||||||
Integer tas = (int) targetLow_v.keyAt(index);
|
int tas = (int) targetLow_v.keyAt(index);
|
||||||
double target = (targetLow_v.valueAt(index) + targetHigh_v.valueAt(index)) / 2;
|
double target = (targetLow_v.valueAt(index) + targetHigh_v.valueAt(index)) / 2;
|
||||||
ret[index] = new ProfileValue(tas, target);
|
ret[index] = new ProfileValue(tas, toMgdl(target, units));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,22 +11,19 @@ import org.slf4j.LoggerFactory;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 01.06.2017.
|
* Created by mike on 01.06.2017.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ProfileStore {
|
public class ProfileStore {
|
||||||
private static Logger log = LoggerFactory.getLogger(ProfileStore.class);
|
private static Logger log = LoggerFactory.getLogger(ProfileStore.class);
|
||||||
private JSONObject json = null;
|
private JSONObject json;
|
||||||
private String units = Constants.MGDL;
|
|
||||||
|
|
||||||
ArrayMap<String, Profile> cachedObjects = new ArrayMap<>();
|
private ArrayMap<String, Profile> cachedObjects = new ArrayMap<>();
|
||||||
|
|
||||||
public ProfileStore(JSONObject json) {
|
public ProfileStore(JSONObject json) {
|
||||||
this.json = json;
|
this.json = json;
|
||||||
getDefaultProfile(); // initialize units
|
getDefaultProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject getData() {
|
public JSONObject getData() {
|
||||||
|
@ -42,13 +39,13 @@ public class ProfileStore {
|
||||||
if (store.has(defaultProfileName)) {
|
if (store.has(defaultProfileName)) {
|
||||||
profile = cachedObjects.get(defaultProfileName);
|
profile = cachedObjects.get(defaultProfileName);
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
if (store.has("units"))
|
if (store.has("units")) {
|
||||||
units = store.getString("units");
|
String units = store.getString("units");
|
||||||
profile = new Profile(store.getJSONObject(defaultProfileName), units);
|
profile = new Profile(store.getJSONObject(defaultProfileName), units);
|
||||||
units = profile.getUnits();
|
|
||||||
cachedObjects.put(defaultProfileName, profile);
|
cachedObjects.put(defaultProfileName, profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
@ -70,10 +67,6 @@ public class ProfileStore {
|
||||||
return defaultProfileName;
|
return defaultProfileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUnits() {
|
|
||||||
return units;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Profile getSpecificProfile(String profileName) {
|
public Profile getSpecificProfile(String profileName) {
|
||||||
Profile profile = null;
|
Profile profile = null;
|
||||||
|
@ -82,13 +75,13 @@ public class ProfileStore {
|
||||||
if (store.has(profileName)) {
|
if (store.has(profileName)) {
|
||||||
profile = cachedObjects.get(profileName);
|
profile = cachedObjects.get(profileName);
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
if (store.has("units"))
|
if (store.has("units")) {
|
||||||
units = store.getString("units");
|
String units = store.getString("units");
|
||||||
profile = new Profile(store.getJSONObject(profileName), units);
|
profile = new Profile(store.getJSONObject(profileName), units);
|
||||||
units = profile.getUnits();
|
|
||||||
cachedObjects.put(profileName, profile);
|
cachedObjects.put(profileName, profile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +89,7 @@ public class ProfileStore {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<CharSequence> getProfileList() {
|
public ArrayList<CharSequence> getProfileList() {
|
||||||
ArrayList<CharSequence> ret = new ArrayList<CharSequence>();
|
ArrayList<CharSequence> ret = new ArrayList<>();
|
||||||
|
|
||||||
JSONObject store;
|
JSONObject store;
|
||||||
try {
|
try {
|
||||||
|
@ -110,9 +103,6 @@ public class ProfileStore {
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
log.error("Unhandled exception", e);
|
log.error("Unhandled exception", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.db.TempTarget;
|
import info.nightscout.androidaps.db.TempTarget;
|
||||||
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
import info.nightscout.androidaps.interfaces.TreatmentsInterface;
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.CobInfo;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.CobInfo;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.IobCobCalculatorPlugin;
|
||||||
|
@ -74,7 +75,7 @@ public class QuickWizardEntry {
|
||||||
//BG
|
//BG
|
||||||
double bg = 0;
|
double bg = 0;
|
||||||
if (lastBG != null && useBG() == YES) {
|
if (lastBG != null && useBG() == YES) {
|
||||||
bg = lastBG.valueToUnits(profile.getUnits());
|
bg = lastBG.valueToUnits(ProfileFunctions.getSystemUnits());
|
||||||
}
|
}
|
||||||
|
|
||||||
// COB
|
// COB
|
||||||
|
|
|
@ -181,8 +181,7 @@ public class BgReading implements DataPointWithLabelInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getY() {
|
public double getY() {
|
||||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
return valueToUnits(ProfileFunctions.getSystemUnits());
|
||||||
return valueToUnits(units);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -215,9 +214,9 @@ public class BgReading implements DataPointWithLabelInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColor() {
|
public int getColor() {
|
||||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
String units = ProfileFunctions.getSystemUnits();
|
||||||
Double lowLine = OverviewPlugin.INSTANCE.determineLowLine(units);
|
Double lowLine = OverviewPlugin.INSTANCE.determineLowLine();
|
||||||
Double highLine = OverviewPlugin.INSTANCE.determineHighLine(units);
|
Double highLine = OverviewPlugin.INSTANCE.determineHighLine();
|
||||||
int color = MainApp.gc(R.color.inrange);
|
int color = MainApp.gc(R.color.inrange);
|
||||||
if (isPrediction())
|
if (isPrediction())
|
||||||
return getPredectionColor();
|
return getPredectionColor();
|
||||||
|
|
|
@ -167,7 +167,7 @@ public class CareportalEvent implements DataPointWithLabelInterface, Interval {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getY() {
|
public double getY() {
|
||||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
String units = ProfileFunctions.getSystemUnits();
|
||||||
if (eventType.equals(MBG)) {
|
if (eventType.equals(MBG)) {
|
||||||
double mbg = 0d;
|
double mbg = 0d;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -259,11 +259,11 @@ public class ExtendedBolus implements Interval, DataPointWithLabelInterface {
|
||||||
double sensitivityRatio = lastAutosensResult.ratio;
|
double sensitivityRatio = lastAutosensResult.ratio;
|
||||||
double normalTarget = 100;
|
double normalTarget = 100;
|
||||||
|
|
||||||
if (exercise_mode && isTempTarget && profile.getTarget() >= normalTarget + 5) {
|
if (exercise_mode && isTempTarget && profile.getTargetMgdl() >= normalTarget + 5) {
|
||||||
// w/ target 100, temp target 110 = .89, 120 = 0.8, 140 = 0.67, 160 = .57, and 200 = .44
|
// w/ target 100, temp target 110 = .89, 120 = 0.8, 140 = 0.67, 160 = .57, and 200 = .44
|
||||||
// e.g.: Sensitivity ratio set to 0.8 based on temp target of 120; Adjusting basal from 1.65 to 1.35; ISF from 58.9 to 73.6
|
// e.g.: Sensitivity ratio set to 0.8 based on temp target of 120; Adjusting basal from 1.65 to 1.35; ISF from 58.9 to 73.6
|
||||||
double c = half_basal_exercise_target - normalTarget;
|
double c = half_basal_exercise_target - normalTarget;
|
||||||
sensitivityRatio = c / (c + profile.getTarget() - normalTarget);
|
sensitivityRatio = c / (c + profile.getTargetMgdl() - normalTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (realDuration > 0) {
|
if (realDuration > 0) {
|
||||||
|
|
|
@ -299,11 +299,11 @@ public class TemporaryBasal implements Interval, DbObjectBase {
|
||||||
double sensitivityRatio = lastAutosensResult.ratio;
|
double sensitivityRatio = lastAutosensResult.ratio;
|
||||||
double normalTarget = 100;
|
double normalTarget = 100;
|
||||||
|
|
||||||
if (exercise_mode && isTempTarget && profile.getTarget() >= normalTarget + 5) {
|
if (exercise_mode && isTempTarget && profile.getTargetMgdl() >= normalTarget + 5) {
|
||||||
// w/ target 100, temp target 110 = .89, 120 = 0.8, 140 = 0.67, 160 = .57, and 200 = .44
|
// w/ target 100, temp target 110 = .89, 120 = 0.8, 140 = 0.67, 160 = .57, and 200 = .44
|
||||||
// e.g.: Sensitivity ratio set to 0.8 based on temp target of 120; Adjusting basal from 1.65 to 1.35; ISF from 58.9 to 73.6
|
// e.g.: Sensitivity ratio set to 0.8 based on temp target of 120; Adjusting basal from 1.65 to 1.35; ISF from 58.9 to 73.6
|
||||||
double c = half_basal_exercise_target - normalTarget;
|
double c = half_basal_exercise_target - normalTarget;
|
||||||
sensitivityRatio = c / (c + profile.getTarget() - normalTarget);
|
sensitivityRatio = c / (c + profile.getTargetMgdl() - normalTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (realDuration > 0) {
|
if (realDuration > 0) {
|
||||||
|
|
|
@ -10,6 +10,5 @@ import info.nightscout.androidaps.data.ProfileStore;
|
||||||
public interface ProfileInterface {
|
public interface ProfileInterface {
|
||||||
@Nullable
|
@Nullable
|
||||||
ProfileStore getProfile();
|
ProfileStore getProfile();
|
||||||
String getUnits();
|
|
||||||
String getProfileName();
|
String getProfileName();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import javax.annotation.Nullable;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.MealData;
|
import info.nightscout.androidaps.data.MealData;
|
||||||
|
@ -194,8 +195,6 @@ public class DetermineBasalAdapterAMAJS {
|
||||||
double autosensDataRatio,
|
double autosensDataRatio,
|
||||||
boolean tempTargetSet) throws JSONException {
|
boolean tempTargetSet) throws JSONException {
|
||||||
|
|
||||||
String units = profile.getUnits();
|
|
||||||
|
|
||||||
mProfile = new JSONObject();
|
mProfile = new JSONObject();
|
||||||
mProfile.put("max_iob", maxIob);
|
mProfile.put("max_iob", maxIob);
|
||||||
mProfile.put("dia", Math.min(profile.getDia(), 3d));
|
mProfile.put("dia", Math.min(profile.getDia(), 3d));
|
||||||
|
@ -206,7 +205,7 @@ public class DetermineBasalAdapterAMAJS {
|
||||||
mProfile.put("max_bg", maxBg);
|
mProfile.put("max_bg", maxBg);
|
||||||
mProfile.put("target_bg", targetBg);
|
mProfile.put("target_bg", targetBg);
|
||||||
mProfile.put("carb_ratio", profile.getIc());
|
mProfile.put("carb_ratio", profile.getIc());
|
||||||
mProfile.put("sens", Profile.toMgdl(profile.getIsf(), units));
|
mProfile.put("sens", profile.getIsfMgdl());
|
||||||
mProfile.put("max_daily_safety_multiplier", SP.getInt(R.string.key_openapsama_max_daily_safety_multiplier, 3));
|
mProfile.put("max_daily_safety_multiplier", SP.getInt(R.string.key_openapsama_max_daily_safety_multiplier, 3));
|
||||||
mProfile.put("current_basal_safety_multiplier", SP.getDouble(R.string.key_openapsama_current_basal_safety_multiplier, 4d));
|
mProfile.put("current_basal_safety_multiplier", SP.getDouble(R.string.key_openapsama_current_basal_safety_multiplier, 4d));
|
||||||
mProfile.put("skip_neutral_temps", true);
|
mProfile.put("skip_neutral_temps", true);
|
||||||
|
@ -220,7 +219,7 @@ public class DetermineBasalAdapterAMAJS {
|
||||||
mProfile.put("min_5m_carbimpact", SP.getDouble(R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact));
|
mProfile.put("min_5m_carbimpact", SP.getDouble(R.string.key_openapsama_min_5m_carbimpact, SMBDefaults.min_5m_carbimpact));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (units.equals(Constants.MMOL)) {
|
if (ProfileFunctions.getSystemUnits().equals(Constants.MMOL)) {
|
||||||
mProfile.put("out_units", "mmol/L");
|
mProfile.put("out_units", "mmol/L");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -107,6 +107,13 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pump == null) {
|
||||||
|
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.nopumpselected)));
|
||||||
|
if (L.isEnabled(L.APS))
|
||||||
|
log.debug(MainApp.gs(R.string.nopumpselected));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isEnabled(PluginType.APS)) {
|
if (!isEnabled(PluginType.APS)) {
|
||||||
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
|
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
|
||||||
if (L.isEnabled(L.APS))
|
if (L.isEnabled(L.APS))
|
||||||
|
@ -121,12 +128,10 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String units = profile.getUnits();
|
|
||||||
|
|
||||||
double maxBasal = MainApp.getConstraintChecker().getMaxBasalAllowed(profile).value();
|
double maxBasal = MainApp.getConstraintChecker().getMaxBasalAllowed(profile).value();
|
||||||
double minBg = Profile.toMgdl(profile.getTargetLow(), units);
|
double minBg = profile.getTargetLowMgdl();
|
||||||
double maxBg = Profile.toMgdl(profile.getTargetHigh(), units);
|
double maxBg = profile.getTargetHighMgdl();
|
||||||
double targetBg = Profile.toMgdl(profile.getTarget(), units);
|
double targetBg = profile.getTargetMgdl();
|
||||||
|
|
||||||
minBg = Round.roundTo(minBg, 0.1d);
|
minBg = Round.roundTo(minBg, 0.1d);
|
||||||
maxBg = Round.roundTo(maxBg, 0.1d);
|
maxBg = Round.roundTo(maxBg, 0.1d);
|
||||||
|
@ -162,7 +167,7 @@ public class OpenAPSAMAPlugin extends PluginBase implements APSInterface {
|
||||||
return;
|
return;
|
||||||
if (!HardLimits.checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", HardLimits.MINIC, HardLimits.MAXIC))
|
if (!HardLimits.checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", HardLimits.MINIC, HardLimits.MAXIC))
|
||||||
return;
|
return;
|
||||||
if (!HardLimits.checkOnlyHardLimits(Profile.toMgdl(profile.getIsf(), units), "sens", HardLimits.MINISF, HardLimits.MAXISF))
|
if (!HardLimits.checkOnlyHardLimits(profile.getIsfMgdl(), "sens", HardLimits.MINISF, HardLimits.MAXISF))
|
||||||
return;
|
return;
|
||||||
if (!HardLimits.checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.02, HardLimits.maxBasal()))
|
if (!HardLimits.checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.02, HardLimits.maxBasal()))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -20,6 +20,7 @@ import javax.annotation.Nullable;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.MealData;
|
import info.nightscout.androidaps.data.MealData;
|
||||||
|
@ -160,8 +161,6 @@ public class DetermineBasalAdapterMAJS {
|
||||||
GlucoseStatus glucoseStatus,
|
GlucoseStatus glucoseStatus,
|
||||||
MealData mealData) throws JSONException {
|
MealData mealData) throws JSONException {
|
||||||
|
|
||||||
String units = profile.getUnits();
|
|
||||||
|
|
||||||
mProfile = new JSONObject();
|
mProfile = new JSONObject();
|
||||||
mProfile.put("max_iob", maxIob);
|
mProfile.put("max_iob", maxIob);
|
||||||
mProfile.put("dia", Math.min(profile.getDia(), 3d));
|
mProfile.put("dia", Math.min(profile.getDia(), 3d));
|
||||||
|
@ -172,11 +171,11 @@ public class DetermineBasalAdapterMAJS {
|
||||||
mProfile.put("max_bg", maxBg);
|
mProfile.put("max_bg", maxBg);
|
||||||
mProfile.put("target_bg", targetBg);
|
mProfile.put("target_bg", targetBg);
|
||||||
mProfile.put("carb_ratio", profile.getIc());
|
mProfile.put("carb_ratio", profile.getIc());
|
||||||
mProfile.put("sens", Profile.toMgdl(profile.getIsf(), units));
|
mProfile.put("sens", profile.getIsfMgdl());
|
||||||
|
|
||||||
mProfile.put("current_basal", basalRate);
|
mProfile.put("current_basal", basalRate);
|
||||||
|
|
||||||
if (units.equals(Constants.MMOL)) {
|
if (ProfileFunctions.getSystemUnits().equals(Constants.MMOL)) {
|
||||||
mProfile.put("out_units", "mmol/L");
|
mProfile.put("out_units", "mmol/L");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,13 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pump == null) {
|
||||||
|
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.nopumpselected)));
|
||||||
|
if (L.isEnabled(L.APS))
|
||||||
|
log.debug(MainApp.gs(R.string.nopumpselected));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isEnabled(PluginType.APS)) {
|
if (!isEnabled(PluginType.APS)) {
|
||||||
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
|
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
|
||||||
if (L.isEnabled(L.APS))
|
if (L.isEnabled(L.APS))
|
||||||
|
@ -120,13 +127,11 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String units = profile.getUnits();
|
|
||||||
|
|
||||||
double maxBasal = MainApp.getConstraintChecker().getMaxBasalAllowed(profile).value();
|
double maxBasal = MainApp.getConstraintChecker().getMaxBasalAllowed(profile).value();
|
||||||
|
|
||||||
double minBg = Profile.toMgdl(profile.getTargetLow(), units);
|
double minBg = profile.getTargetLowMgdl();
|
||||||
double maxBg = Profile.toMgdl(profile.getTargetHigh(), units);
|
double maxBg = profile.getTargetHighMgdl();
|
||||||
double targetBg = Profile.toMgdl(profile.getTarget(), units);
|
double targetBg = profile.getTargetMgdl();
|
||||||
|
|
||||||
minBg = Round.roundTo(minBg, 0.1d);
|
minBg = Round.roundTo(minBg, 0.1d);
|
||||||
maxBg = Round.roundTo(maxBg, 0.1d);
|
maxBg = Round.roundTo(maxBg, 0.1d);
|
||||||
|
@ -160,7 +165,7 @@ public class OpenAPSMAPlugin extends PluginBase implements APSInterface {
|
||||||
return;
|
return;
|
||||||
if (!checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", HardLimits.MINIC, HardLimits.MAXIC))
|
if (!checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", HardLimits.MINIC, HardLimits.MAXIC))
|
||||||
return;
|
return;
|
||||||
if (!checkOnlyHardLimits(Profile.toMgdl(profile.getIsf(), units), "sens", HardLimits.MINISF, HardLimits.MAXISF))
|
if (!checkOnlyHardLimits(profile.getIsfMgdl(), "sens", HardLimits.MINISF, HardLimits.MAXISF))
|
||||||
return;
|
return;
|
||||||
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.02, HardLimits.maxBasal()))
|
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.02, HardLimits.maxBasal()))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -23,6 +23,7 @@ import javax.annotation.Nullable;
|
||||||
import info.nightscout.androidaps.Constants;
|
import info.nightscout.androidaps.Constants;
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.GlucoseStatus;
|
||||||
import info.nightscout.androidaps.data.IobTotal;
|
import info.nightscout.androidaps.data.IobTotal;
|
||||||
import info.nightscout.androidaps.data.MealData;
|
import info.nightscout.androidaps.data.MealData;
|
||||||
|
@ -219,8 +220,6 @@ public class DetermineBasalAdapterSMBJS {
|
||||||
boolean advancedFiltering
|
boolean advancedFiltering
|
||||||
) throws JSONException {
|
) throws JSONException {
|
||||||
|
|
||||||
String units = profile.getUnits();
|
|
||||||
|
|
||||||
mProfile = new JSONObject();
|
mProfile = new JSONObject();
|
||||||
|
|
||||||
mProfile.put("max_iob", maxIob);
|
mProfile.put("max_iob", maxIob);
|
||||||
|
@ -232,7 +231,7 @@ public class DetermineBasalAdapterSMBJS {
|
||||||
mProfile.put("max_bg", maxBg);
|
mProfile.put("max_bg", maxBg);
|
||||||
mProfile.put("target_bg", targetBg);
|
mProfile.put("target_bg", targetBg);
|
||||||
mProfile.put("carb_ratio", profile.getIc());
|
mProfile.put("carb_ratio", profile.getIc());
|
||||||
mProfile.put("sens", Profile.toMgdl(profile.getIsf(), units));
|
mProfile.put("sens", profile.getIsfMgdl());
|
||||||
mProfile.put("max_daily_safety_multiplier", SP.getInt(R.string.key_openapsama_max_daily_safety_multiplier, 3));
|
mProfile.put("max_daily_safety_multiplier", SP.getInt(R.string.key_openapsama_max_daily_safety_multiplier, 3));
|
||||||
mProfile.put("current_basal_safety_multiplier", SP.getDouble(R.string.key_openapsama_current_basal_safety_multiplier, 4d));
|
mProfile.put("current_basal_safety_multiplier", SP.getDouble(R.string.key_openapsama_current_basal_safety_multiplier, 4d));
|
||||||
|
|
||||||
|
@ -273,7 +272,7 @@ public class DetermineBasalAdapterSMBJS {
|
||||||
mProfile.put("temptargetSet", tempTargetSet);
|
mProfile.put("temptargetSet", tempTargetSet);
|
||||||
mProfile.put("autosens_max", SafeParse.stringToDouble(SP.getString(R.string.key_openapsama_autosens_max, "1.2")));
|
mProfile.put("autosens_max", SafeParse.stringToDouble(SP.getString(R.string.key_openapsama_autosens_max, "1.2")));
|
||||||
|
|
||||||
if (units.equals(Constants.MMOL)) {
|
if (ProfileFunctions.getSystemUnits().equals(Constants.MMOL)) {
|
||||||
mProfile.put("out_units", "mmol/L");
|
mProfile.put("out_units", "mmol/L");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -111,6 +111,13 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pump == null) {
|
||||||
|
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.nopumpselected)));
|
||||||
|
if (L.isEnabled(L.APS))
|
||||||
|
log.debug(MainApp.gs(R.string.nopumpselected));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!isEnabled(PluginType.APS)) {
|
if (!isEnabled(PluginType.APS)) {
|
||||||
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
|
RxBus.INSTANCE.send(new EventOpenAPSUpdateResultGui(MainApp.gs(R.string.openapsma_disabled)));
|
||||||
if (L.isEnabled(L.APS))
|
if (L.isEnabled(L.APS))
|
||||||
|
@ -125,16 +132,14 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String units = profile.getUnits();
|
|
||||||
|
|
||||||
Constraint<Double> inputConstraints = new Constraint<>(0d); // fake. only for collecting all results
|
Constraint<Double> inputConstraints = new Constraint<>(0d); // fake. only for collecting all results
|
||||||
|
|
||||||
Constraint<Double> maxBasalConstraint = MainApp.getConstraintChecker().getMaxBasalAllowed(profile);
|
Constraint<Double> maxBasalConstraint = MainApp.getConstraintChecker().getMaxBasalAllowed(profile);
|
||||||
inputConstraints.copyReasons(maxBasalConstraint);
|
inputConstraints.copyReasons(maxBasalConstraint);
|
||||||
double maxBasal = maxBasalConstraint.value();
|
double maxBasal = maxBasalConstraint.value();
|
||||||
double minBg = Profile.toMgdl(profile.getTargetLow(), units);
|
double minBg = profile.getTargetLowMgdl();
|
||||||
double maxBg = Profile.toMgdl(profile.getTargetHigh(), units);
|
double maxBg = profile.getTargetHighMgdl();
|
||||||
double targetBg = Profile.toMgdl(profile.getTarget(), units);
|
double targetBg = profile.getTargetMgdl();
|
||||||
|
|
||||||
minBg = Round.roundTo(minBg, 0.1d);
|
minBg = Round.roundTo(minBg, 0.1d);
|
||||||
maxBg = Round.roundTo(maxBg, 0.1d);
|
maxBg = Round.roundTo(maxBg, 0.1d);
|
||||||
|
@ -168,7 +173,7 @@ public class OpenAPSSMBPlugin extends PluginBase implements APSInterface, Constr
|
||||||
return;
|
return;
|
||||||
if (!checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", HardLimits.MINIC, HardLimits.MAXIC))
|
if (!checkOnlyHardLimits(profile.getIcTimeFromMidnight(Profile.secondsFromMidnight()), "carbratio", HardLimits.MINIC, HardLimits.MAXIC))
|
||||||
return;
|
return;
|
||||||
if (!checkOnlyHardLimits(Profile.toMgdl(profile.getIsf(), units), "sens", HardLimits.MINISF, HardLimits.MAXISF))
|
if (!checkOnlyHardLimits(profile.getIsfMgdl(), "sens", HardLimits.MINISF, HardLimits.MAXISF))
|
||||||
return;
|
return;
|
||||||
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.02, HardLimits.maxBasal()))
|
if (!checkOnlyHardLimits(profile.getMaxDailyBasal(), "max_daily_basal", 0.02, HardLimits.maxBasal()))
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -120,11 +120,6 @@ public class ProfileFunctions {
|
||||||
return SP.getString(R.string.key_units, Constants.MGDL);
|
return SP.getString(R.string.key_units, Constants.MGDL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getProfileUnits() {
|
|
||||||
Profile profile = getProfile();
|
|
||||||
return profile != null ? profile.getUnits() : Constants.MGDL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public Profile getProfile(long time) {
|
public Profile getProfile(long time) {
|
||||||
TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin();
|
TreatmentsInterface activeTreatments = TreatmentsPlugin.getPlugin();
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class InputBg extends Element {
|
||||||
|
|
||||||
public InputBg() {
|
public InputBg() {
|
||||||
super();
|
super();
|
||||||
setUnits(ProfileFunctions.getInstance().getProfileUnits());
|
setUnits(ProfileFunctions.getSystemUnits());
|
||||||
if (getUnits().equals(Constants.MMOL))
|
if (getUnits().equals(Constants.MMOL))
|
||||||
value = MMOL_MIN;
|
value = MMOL_MIN;
|
||||||
else
|
else
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class InputTempTarget extends Element {
|
||||||
|
|
||||||
public InputTempTarget() {
|
public InputTempTarget() {
|
||||||
super();
|
super();
|
||||||
setUnits(ProfileFunctions.getInstance().getProfileUnits());
|
setUnits(ProfileFunctions.getSystemUnits());
|
||||||
if (getUnits().equals(Constants.MMOL))
|
if (getUnits().equals(Constants.MMOL))
|
||||||
value = 6;
|
value = 6;
|
||||||
else
|
else
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class TriggerDelta extends Trigger {
|
||||||
|
|
||||||
public TriggerDelta() {
|
public TriggerDelta() {
|
||||||
super();
|
super();
|
||||||
this.units = ProfileFunctions.getInstance().getProfileUnits();
|
this.units = ProfileFunctions.getSystemUnits();
|
||||||
initializer();
|
initializer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
|
|
||||||
Profile profile;
|
Profile profile;
|
||||||
public ProfileStore profileStore;
|
public ProfileStore profileStore;
|
||||||
String units = Constants.MGDL;
|
|
||||||
|
|
||||||
TextView eventTypeText;
|
TextView eventTypeText;
|
||||||
LinearLayout layoutPercent;
|
LinearLayout layoutPercent;
|
||||||
|
@ -179,7 +178,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ArrayList<CharSequence> profileList;
|
ArrayList<CharSequence> profileList;
|
||||||
units = profile != null ? profile.getUnits() : Constants.MGDL;
|
|
||||||
profileList = profileStore.getProfileList();
|
profileList = profileStore.getProfileList();
|
||||||
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(getContext(),
|
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<>(getContext(),
|
||||||
R.layout.spinner_centered, profileList);
|
R.layout.spinner_centered, profileList);
|
||||||
|
@ -190,7 +188,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
profileSpinner.setSelection(p);
|
profileSpinner.setSelection(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
final Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, units);
|
final Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, ProfileFunctions.getSystemUnits());
|
||||||
|
|
||||||
// temp target
|
// temp target
|
||||||
final List<String> reasonList = Lists.newArrayList(
|
final List<String> reasonList = Lists.newArrayList(
|
||||||
|
@ -205,8 +203,8 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
@Override
|
@Override
|
||||||
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
|
||||||
double defaultDuration;
|
double defaultDuration;
|
||||||
double defaultTarget = 0;
|
double defaultTarget;
|
||||||
if (profile != null && editTemptarget.getValue() == bg) {
|
if (profile != null && editTemptarget.getValue().equals(bg)) {
|
||||||
defaultTarget = bg;
|
defaultTarget = bg;
|
||||||
} else {
|
} else {
|
||||||
//prevent changes on screen rotate
|
//prevent changes on screen rotate
|
||||||
|
@ -214,7 +212,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
}
|
}
|
||||||
boolean erase = false;
|
boolean erase = false;
|
||||||
|
|
||||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
String units = ProfileFunctions.getSystemUnits();
|
||||||
DefaultValueHelper helper = new DefaultValueHelper();
|
DefaultValueHelper helper = new DefaultValueHelper();
|
||||||
if (MainApp.gs(R.string.eatingsoon).equals(reasonList.get(position))) {
|
if (MainApp.gs(R.string.eatingsoon).equals(reasonList.get(position))) {
|
||||||
defaultDuration = helper.determineEatingSoonTTDuration();
|
defaultDuration = helper.determineEatingSoonTTDuration();
|
||||||
|
@ -249,7 +247,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
});
|
});
|
||||||
|
|
||||||
// bg
|
// bg
|
||||||
bgUnitsView.setText(units);
|
bgUnitsView.setText(ProfileFunctions.getSystemUnits());
|
||||||
|
|
||||||
TextWatcher bgTextWatcher = new TextWatcher() {
|
TextWatcher bgTextWatcher = new TextWatcher() {
|
||||||
|
|
||||||
|
@ -268,7 +266,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
if (profile == null) {
|
if (profile == null) {
|
||||||
editBg.setParams(bg, 0d, 500d, 0.1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok), bgTextWatcher);
|
editBg.setParams(bg, 0d, 500d, 0.1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok), bgTextWatcher);
|
||||||
editTemptarget.setParams(Constants.MIN_TT_MGDL, Constants.MIN_TT_MGDL, Constants.MAX_TT_MGDL, 0.1d, new DecimalFormat("0.0"), false, view.findViewById(R.id.ok));
|
editTemptarget.setParams(Constants.MIN_TT_MGDL, Constants.MIN_TT_MGDL, Constants.MAX_TT_MGDL, 0.1d, new DecimalFormat("0.0"), false, view.findViewById(R.id.ok));
|
||||||
} else if (units.equals(Constants.MMOL)) {
|
} else if (ProfileFunctions.getSystemUnits().equals(Constants.MMOL)) {
|
||||||
editBg.setParams(bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false, view.findViewById(R.id.ok), bgTextWatcher);
|
editBg.setParams(bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false, view.findViewById(R.id.ok), bgTextWatcher);
|
||||||
editTemptarget.setParams(Constants.MIN_TT_MMOL, Constants.MIN_TT_MMOL, Constants.MAX_TT_MMOL, 0.1d, new DecimalFormat("0.0"), false, view.findViewById(R.id.ok));
|
editTemptarget.setParams(Constants.MIN_TT_MMOL, Constants.MIN_TT_MMOL, Constants.MAX_TT_MMOL, 0.1d, new DecimalFormat("0.0"), false, view.findViewById(R.id.ok));
|
||||||
} else {
|
} else {
|
||||||
|
@ -277,7 +275,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
}
|
}
|
||||||
|
|
||||||
sensorRadioButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
sensorRadioButton.setOnCheckedChangeListener((buttonView, isChecked) -> {
|
||||||
Double bg1 = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, units);
|
Double bg1 = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, ProfileFunctions.getSystemUnits());
|
||||||
if (savedInstanceState != null && savedInstanceState.getDouble("editBg") != bg1) {
|
if (savedInstanceState != null && savedInstanceState.getDouble("editBg") != bg1) {
|
||||||
editBg.setValue(savedInstanceState.getDouble("editBg"));
|
editBg.setValue(savedInstanceState.getDouble("editBg"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -286,16 +284,16 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
});
|
});
|
||||||
|
|
||||||
Integer maxCarbs = MainApp.getConstraintChecker().getMaxCarbsAllowed().value();
|
Integer maxCarbs = MainApp.getConstraintChecker().getMaxCarbsAllowed().value();
|
||||||
editCarbs = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_carbsinput);
|
editCarbs = view.findViewById(R.id.careportal_newnstreatment_carbsinput);
|
||||||
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
editCarbs.setParams(0d, 0d, (double) maxCarbs, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
||||||
|
|
||||||
Double maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
Double maxInsulin = MainApp.getConstraintChecker().getMaxBolusAllowed().value();
|
||||||
editInsulin = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_insulininput);
|
editInsulin = view.findViewById(R.id.careportal_newnstreatment_insulininput);
|
||||||
editInsulin.setParams(0d, 0d, maxInsulin, 0.05d, new DecimalFormat("0.00"), false, view.findViewById(R.id.ok));
|
editInsulin.setParams(0d, 0d, maxInsulin, 0.05d, new DecimalFormat("0.00"), false, view.findViewById(R.id.ok));
|
||||||
|
|
||||||
editSplit = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_splitinput);
|
editSplit = view.findViewById(R.id.careportal_newnstreatment_splitinput);
|
||||||
editSplit.setParams(100d, 0d, 100d, 5d, new DecimalFormat("0"), true, view.findViewById(R.id.ok));
|
editSplit.setParams(100d, 0d, 100d, 5d, new DecimalFormat("0"), true, view.findViewById(R.id.ok));
|
||||||
editDuration = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_durationinput);
|
editDuration = view.findViewById(R.id.careportal_newnstreatment_durationinput);
|
||||||
editDuration.setParams(0d, 0d, Constants.MAX_PROFILE_SWITCH_DURATION, 10d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
editDuration.setParams(0d, 0d, Constants.MAX_PROFILE_SWITCH_DURATION, 10d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
||||||
|
|
||||||
TextWatcher percentTextWatcher = new TextWatcher() {
|
TextWatcher percentTextWatcher = new TextWatcher() {
|
||||||
|
@ -319,7 +317,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
Integer maxPercent = 200;
|
Integer maxPercent = 200;
|
||||||
if (profile != null)
|
if (profile != null)
|
||||||
maxPercent = MainApp.getConstraintChecker().getMaxBasalPercentAllowed(profile).value();
|
maxPercent = MainApp.getConstraintChecker().getMaxBasalPercentAllowed(profile).value();
|
||||||
editPercent = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_percentinput);
|
editPercent = view.findViewById(R.id.careportal_newnstreatment_percentinput);
|
||||||
editPercent.setParams(0d, -100d, (double) maxPercent, 5d, new DecimalFormat("0"), true, view.findViewById(R.id.ok), percentTextWatcher);
|
editPercent.setParams(0d, -100d, (double) maxPercent, 5d, new DecimalFormat("0"), true, view.findViewById(R.id.ok), percentTextWatcher);
|
||||||
|
|
||||||
TextWatcher absoluteTextWatcher = new TextWatcher() {
|
TextWatcher absoluteTextWatcher = new TextWatcher() {
|
||||||
|
@ -343,16 +341,16 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
Double maxAbsolute = HardLimits.maxBasal();
|
Double maxAbsolute = HardLimits.maxBasal();
|
||||||
if (profile != null)
|
if (profile != null)
|
||||||
maxAbsolute = MainApp.getConstraintChecker().getMaxBasalAllowed(profile).value();
|
maxAbsolute = MainApp.getConstraintChecker().getMaxBasalAllowed(profile).value();
|
||||||
editAbsolute = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_absoluteinput);
|
editAbsolute = view.findViewById(R.id.careportal_newnstreatment_absoluteinput);
|
||||||
editAbsolute.setParams(0d, 0d, maxAbsolute, 0.05d, new DecimalFormat("0.00"), true, view.findViewById(R.id.ok), absoluteTextWatcher);
|
editAbsolute.setParams(0d, 0d, maxAbsolute, 0.05d, new DecimalFormat("0.00"), true, view.findViewById(R.id.ok), absoluteTextWatcher);
|
||||||
|
|
||||||
editCarbTime = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_carbtimeinput);
|
editCarbTime = view.findViewById(R.id.careportal_newnstreatment_carbtimeinput);
|
||||||
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
editCarbTime.setParams(0d, -60d, 60d, 5d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
||||||
|
|
||||||
editPercentage = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_percentage);
|
editPercentage = view.findViewById(R.id.careportal_newnstreatment_percentage);
|
||||||
editPercentage.setParams(100d, (double) Constants.CPP_MIN_PERCENTAGE, (double) Constants.CPP_MAX_PERCENTAGE, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
editPercentage.setParams(100d, (double) Constants.CPP_MIN_PERCENTAGE, (double) Constants.CPP_MAX_PERCENTAGE, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
||||||
|
|
||||||
editTimeshift = (NumberPicker) view.findViewById(R.id.careportal_newnstreatment_timeshift);
|
editTimeshift = view.findViewById(R.id.careportal_newnstreatment_timeshift);
|
||||||
editTimeshift.setParams(0d, (double) Constants.CPP_MIN_TIMESHIFT, (double) Constants.CPP_MAX_TIMESHIFT, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
editTimeshift.setParams(0d, (double) Constants.CPP_MIN_TIMESHIFT, (double) Constants.CPP_MAX_TIMESHIFT, 1d, new DecimalFormat("0"), false, view.findViewById(R.id.ok));
|
||||||
|
|
||||||
ProfileSwitch ps = TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(DateUtil.now());
|
ProfileSwitch ps = TreatmentsPlugin.getPlugin().getProfileSwitchFromHistory(DateUtil.now());
|
||||||
|
@ -369,21 +367,21 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
options.duration = false;
|
options.duration = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_eventtime_layout), options.date);
|
showOrHide(view.findViewById(R.id.careportal_newnstreatment_eventtime_layout), options.date);
|
||||||
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_bg_layout), options.bg);
|
showOrHide(view.findViewById(R.id.careportal_newnstreatment_bg_layout), options.bg);
|
||||||
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_bgsource_layout), options.bg);
|
showOrHide(view.findViewById(R.id.careportal_newnstreatment_bgsource_layout), options.bg);
|
||||||
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_insulin_layout), options.insulin);
|
showOrHide(view.findViewById(R.id.careportal_newnstreatment_insulin_layout), options.insulin);
|
||||||
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_carbs_layout), options.carbs);
|
showOrHide(view.findViewById(R.id.careportal_newnstreatment_carbs_layout), options.carbs);
|
||||||
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_split_layout), options.split);
|
showOrHide(view.findViewById(R.id.careportal_newnstreatment_split_layout), options.split);
|
||||||
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_duration_layout), options.duration);
|
showOrHide(view.findViewById(R.id.careportal_newnstreatment_duration_layout), options.duration);
|
||||||
showOrHide(layoutPercent, options.percent);
|
showOrHide(layoutPercent, options.percent);
|
||||||
showOrHide(layoutAbsolute, options.absolute);
|
showOrHide(layoutAbsolute, options.absolute);
|
||||||
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_carbtime_layout), options.prebolus);
|
showOrHide(view.findViewById(R.id.careportal_newnstreatment_carbtime_layout), options.prebolus);
|
||||||
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_profile_layout), options.profile);
|
showOrHide(view.findViewById(R.id.careportal_newnstreatment_profile_layout), options.profile);
|
||||||
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_percentage_layout), options.profile);
|
showOrHide(view.findViewById(R.id.careportal_newnstreatment_percentage_layout), options.profile);
|
||||||
showOrHide((ViewGroup) view.findViewById(R.id.careportal_newnstreatment_timeshift_layout), options.profile);
|
showOrHide(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(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);
|
showOrHide(view.findViewById(R.id.careportal_newnstreatment_temptarget_layout), options.tempTarget);
|
||||||
|
|
||||||
setCancelable(true);
|
setCancelable(true);
|
||||||
getDialog().setCanceledOnTouchOutside(false);
|
getDialog().setCanceledOnTouchOutside(false);
|
||||||
|
@ -457,7 +455,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
if ((data.size() > 0) &&
|
if ((data.size() > 0) &&
|
||||||
(data.get(0).date > millis - 7 * 60 * 1000L) &&
|
(data.get(0).date > millis - 7 * 60 * 1000L) &&
|
||||||
(data.get(0).date < millis + 7 * 60 * 1000L)) {
|
(data.get(0).date < millis + 7 * 60 * 1000L)) {
|
||||||
editBg.setValue(Profile.fromMgdlToUnits(data.get(0).value, units));
|
editBg.setValue(Profile.fromMgdlToUnits(data.get(0).value, ProfileFunctions.getSystemUnits()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -585,7 +583,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
data.put("preBolus", SafeParse.stringToDouble(editCarbTime.getText()));
|
data.put("preBolus", SafeParse.stringToDouble(editCarbTime.getText()));
|
||||||
if (!notesEdit.getText().toString().equals(""))
|
if (!notesEdit.getText().toString().equals(""))
|
||||||
data.put("notes", notesEdit.getText().toString());
|
data.put("notes", notesEdit.getText().toString());
|
||||||
data.put("units", units);
|
data.put("units", ProfileFunctions.getSystemUnits());
|
||||||
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
|
if (!enteredBy.equals("")) data.put("enteredBy", enteredBy);
|
||||||
if (options.eventType == R.id.careportal_combobolus) {
|
if (options.eventType == R.id.careportal_combobolus) {
|
||||||
Double enteredInsulin = SafeParse.stringToDouble(editInsulin.getText());
|
Double enteredInsulin = SafeParse.stringToDouble(editInsulin.getText());
|
||||||
|
@ -611,7 +609,7 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
ret += MainApp.gs(R.string.treatments_wizard_bg_label);
|
ret += MainApp.gs(R.string.treatments_wizard_bg_label);
|
||||||
ret += ": ";
|
ret += ": ";
|
||||||
ret += JsonHelper.safeGetObject(data, "glucose", "");
|
ret += JsonHelper.safeGetObject(data, "glucose", "");
|
||||||
ret += " " + units + "\n";
|
ret += " " + ProfileFunctions.getSystemUnits() + "\n";
|
||||||
}
|
}
|
||||||
if (data.has("glucoseType")) {
|
if (data.has("glucoseType")) {
|
||||||
ret += MainApp.gs(R.string.careportal_newnstreatment_glucosetype);
|
ret += MainApp.gs(R.string.careportal_newnstreatment_glucosetype);
|
||||||
|
@ -734,8 +732,8 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
.reason(reason)
|
.reason(reason)
|
||||||
.source(Source.USER);
|
.source(Source.USER);
|
||||||
if (tempTarget.durationInMinutes != 0) {
|
if (tempTarget.durationInMinutes != 0) {
|
||||||
tempTarget.low(Profile.toMgdl(targetBottom, units))
|
tempTarget.low(Profile.toMgdl(targetBottom, ProfileFunctions.getSystemUnits()))
|
||||||
.high(Profile.toMgdl(targetTop, units));
|
.high(Profile.toMgdl(targetTop, ProfileFunctions.getSystemUnits()));
|
||||||
} else {
|
} else {
|
||||||
tempTarget.low(0).high(0);
|
tempTarget.low(0).high(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -312,21 +312,14 @@ public class NSUpload {
|
||||||
|
|
||||||
public static void uploadTempTarget(TempTarget tempTarget) {
|
public static void uploadTempTarget(TempTarget tempTarget) {
|
||||||
try {
|
try {
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
|
||||||
|
|
||||||
if (profile == null) {
|
|
||||||
log.error("Profile is null. Skipping upload");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
JSONObject data = new JSONObject();
|
JSONObject data = new JSONObject();
|
||||||
data.put("eventType", CareportalEvent.TEMPORARYTARGET);
|
data.put("eventType", CareportalEvent.TEMPORARYTARGET);
|
||||||
data.put("duration", tempTarget.durationInMinutes);
|
data.put("duration", tempTarget.durationInMinutes);
|
||||||
data.put("reason", tempTarget.reason);
|
data.put("reason", tempTarget.reason);
|
||||||
data.put("targetBottom", Profile.fromMgdlToUnits(tempTarget.low, profile.getUnits()));
|
data.put("targetBottom", Profile.fromMgdlToUnits(tempTarget.low, ProfileFunctions.getSystemUnits()));
|
||||||
data.put("targetTop", Profile.fromMgdlToUnits(tempTarget.high, profile.getUnits()));
|
data.put("targetTop", Profile.fromMgdlToUnits(tempTarget.high, ProfileFunctions.getSystemUnits()));
|
||||||
data.put("created_at", DateUtil.toISOString(tempTarget.date));
|
data.put("created_at", DateUtil.toISOString(tempTarget.date));
|
||||||
data.put("units", profile.getUnits());
|
data.put("units", ProfileFunctions.getSystemUnits());
|
||||||
data.put("enteredBy", MainApp.gs(R.string.app_name));
|
data.put("enteredBy", MainApp.gs(R.string.app_name));
|
||||||
uploadCareportalEntryToNS(data);
|
uploadCareportalEntryToNS(data);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
|
|
|
@ -760,36 +760,36 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
pvd.show(manager, "ProfileViewDialog");
|
pvd.show(manager, "ProfileViewDialog");
|
||||||
} else if (item.getTitle().equals(MainApp.gs(R.string.eatingsoon))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.eatingsoon))) {
|
||||||
DefaultValueHelper defHelper = new DefaultValueHelper();
|
DefaultValueHelper defHelper = new DefaultValueHelper();
|
||||||
double target = defHelper.determineEatingSoonTT(profile.getUnits());
|
double target = defHelper.determineEatingSoonTT(Constants.MGDL);
|
||||||
TempTarget tempTarget = new TempTarget()
|
TempTarget tempTarget = new TempTarget()
|
||||||
.date(System.currentTimeMillis())
|
.date(System.currentTimeMillis())
|
||||||
.duration(defHelper.determineEatingSoonTTDuration())
|
.duration(defHelper.determineEatingSoonTTDuration())
|
||||||
.reason(MainApp.gs(R.string.eatingsoon))
|
.reason(MainApp.gs(R.string.eatingsoon))
|
||||||
.source(Source.USER)
|
.source(Source.USER)
|
||||||
.low(Profile.toMgdl(target, profile.getUnits()))
|
.low(target)
|
||||||
.high(Profile.toMgdl(target, profile.getUnits()));
|
.high(target);
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
||||||
} else if (item.getTitle().equals(MainApp.gs(R.string.activity))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.activity))) {
|
||||||
DefaultValueHelper defHelper = new DefaultValueHelper();
|
DefaultValueHelper defHelper = new DefaultValueHelper();
|
||||||
double target = defHelper.determineActivityTT(profile.getUnits());
|
double target = defHelper.determineActivityTT(Constants.MGDL);
|
||||||
TempTarget tempTarget = new TempTarget()
|
TempTarget tempTarget = new TempTarget()
|
||||||
.date(now())
|
.date(now())
|
||||||
.duration(defHelper.determineActivityTTDuration())
|
.duration(defHelper.determineActivityTTDuration())
|
||||||
.reason(MainApp.gs(R.string.activity))
|
.reason(MainApp.gs(R.string.activity))
|
||||||
.source(Source.USER)
|
.source(Source.USER)
|
||||||
.low(Profile.toMgdl(target, profile.getUnits()))
|
.low(target)
|
||||||
.high(Profile.toMgdl(target, profile.getUnits()));
|
.high(target);
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
||||||
} else if (item.getTitle().equals(MainApp.gs(R.string.hypo))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.hypo))) {
|
||||||
DefaultValueHelper defHelper = new DefaultValueHelper();
|
DefaultValueHelper defHelper = new DefaultValueHelper();
|
||||||
double target = defHelper.determineHypoTT(profile.getUnits());
|
double target = defHelper.determineHypoTT(Constants.MGDL);
|
||||||
TempTarget tempTarget = new TempTarget()
|
TempTarget tempTarget = new TempTarget()
|
||||||
.date(now())
|
.date(now())
|
||||||
.duration(defHelper.determineHypoTTDuration())
|
.duration(defHelper.determineHypoTTDuration())
|
||||||
.reason(MainApp.gs(R.string.hypo))
|
.reason(MainApp.gs(R.string.hypo))
|
||||||
.source(Source.USER)
|
.source(Source.USER)
|
||||||
.low(Profile.toMgdl(target, profile.getUnits()))
|
.low(target)
|
||||||
.high(Profile.toMgdl(target, profile.getUnits()));
|
.high(target);
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
||||||
} else if (item.getTitle().equals(MainApp.gs(R.string.custom))) {
|
} else if (item.getTitle().equals(MainApp.gs(R.string.custom))) {
|
||||||
NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog();
|
NewNSTreatmentDialog newTTDialog = new NewNSTreatmentDialog();
|
||||||
|
@ -814,7 +814,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
boolean xdrip = SourceXdripPlugin.getPlugin().isEnabled(PluginType.BGSOURCE);
|
boolean xdrip = SourceXdripPlugin.getPlugin().isEnabled(PluginType.BGSOURCE);
|
||||||
boolean dexcom = SourceDexcomPlugin.INSTANCE.isEnabled(PluginType.BGSOURCE);
|
boolean dexcom = SourceDexcomPlugin.INSTANCE.isEnabled(PluginType.BGSOURCE);
|
||||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
|
||||||
|
|
||||||
FragmentManager manager = getFragmentManager();
|
FragmentManager manager = getFragmentManager();
|
||||||
// try to fix https://fabric.io/nightscout3/android/apps/info.nightscout.androidaps/issues/5aca7a1536c7b23527eb4be7?time=last-seven-days
|
// try to fix https://fabric.io/nightscout3/android/apps/info.nightscout.androidaps/issues/5aca7a1536c7b23527eb4be7?time=last-seven-days
|
||||||
|
@ -1041,7 +1040,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
final Profile profile = ProfileFunctions.getInstance().getProfile();
|
||||||
final String profileName = ProfileFunctions.getInstance().getProfileName();
|
final String profileName = ProfileFunctions.getInstance().getProfileName();
|
||||||
|
|
||||||
final String units = profile.getUnits();
|
final String units = ProfileFunctions.getSystemUnits();
|
||||||
final double lowLine = OverviewPlugin.INSTANCE.determineLowLine(units);
|
final double lowLine = OverviewPlugin.INSTANCE.determineLowLine(units);
|
||||||
final double highLine = OverviewPlugin.INSTANCE.determineHighLine(units);
|
final double highLine = OverviewPlugin.INSTANCE.determineHighLine(units);
|
||||||
|
|
||||||
|
@ -1126,7 +1125,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
} else {
|
} else {
|
||||||
tempTargetView.setTextColor(MainApp.gc(R.color.ribbonTextDefault));
|
tempTargetView.setTextColor(MainApp.gc(R.color.ribbonTextDefault));
|
||||||
tempTargetView.setBackgroundColor(MainApp.gc(R.color.ribbonDefault));
|
tempTargetView.setBackgroundColor(MainApp.gc(R.color.ribbonDefault));
|
||||||
tempTargetView.setText(Profile.toTargetRangeString(profile.getTargetLow(), profile.getTargetHigh(), units, units));
|
tempTargetView.setText(Profile.toTargetRangeString(profile.getTargetLowMgdl(), profile.getTargetHighMgdl(), Constants.MGDL, units));
|
||||||
tempTargetView.setVisibility(View.VISIBLE);
|
tempTargetView.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,19 +65,16 @@ object OverviewPlugin : PluginBase(PluginDescription()
|
||||||
super.onStop()
|
super.onStop()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun determineHighLine(units: String): Double {
|
@JvmOverloads
|
||||||
|
fun determineHighLine(units: String = ProfileFunctions.getSystemUnits()): Double {
|
||||||
var highLineSetting = SP.getDouble("high_mark", Profile.fromMgdlToUnits(bgTargetHigh, units))!!
|
var highLineSetting = SP.getDouble("high_mark", Profile.fromMgdlToUnits(bgTargetHigh, units))!!
|
||||||
if (highLineSetting < 1)
|
if (highLineSetting < 1)
|
||||||
highLineSetting = Profile.fromMgdlToUnits(180.0, units)
|
highLineSetting = Profile.fromMgdlToUnits(180.0, units)
|
||||||
return highLineSetting
|
return highLineSetting
|
||||||
}
|
}
|
||||||
|
|
||||||
fun determineLowLine(): Double {
|
@JvmOverloads
|
||||||
val profile = ProfileFunctions.getInstance().profile ?: return bgTargetLow
|
fun determineLowLine(units: String = ProfileFunctions.getSystemUnits()): Double {
|
||||||
return determineLowLine(profile.units)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun determineLowLine(units: String): Double {
|
|
||||||
var lowLineSetting = SP.getDouble("low_mark", Profile.fromMgdlToUnits(bgTargetLow, units))!!
|
var lowLineSetting = SP.getDouble("low_mark", Profile.fromMgdlToUnits(bgTargetLow, units))!!
|
||||||
if (lowLineSetting < 1)
|
if (lowLineSetting < 1)
|
||||||
lowLineSetting = Profile.fromMgdlToUnits(76.0, units)
|
lowLineSetting = Profile.fromMgdlToUnits(76.0, units)
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis
|
||||||
view.findViewById(R.id.ok).setOnClickListener(this);
|
view.findViewById(R.id.ok).setOnClickListener(this);
|
||||||
view.findViewById(R.id.cancel).setOnClickListener(this);
|
view.findViewById(R.id.cancel).setOnClickListener(this);
|
||||||
|
|
||||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
String units = ProfileFunctions.getSystemUnits();
|
||||||
Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, units);
|
Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, units);
|
||||||
|
|
||||||
bgNumber = (NumberPicker) view.findViewById(R.id.overview_calibration_bg);
|
bgNumber = (NumberPicker) view.findViewById(R.id.overview_calibration_bg);
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.HandlerThread;
|
|
||||||
import androidx.fragment.app.DialogFragment;
|
import androidx.fragment.app.DialogFragment;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
@ -316,7 +315,7 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
|
||||||
int carbs = editCarbs.getValue().intValue();
|
int carbs = editCarbs.getValue().intValue();
|
||||||
Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(carbs)).value();
|
Integer carbsAfterConstraints = MainApp.getConstraintChecker().applyCarbsConstraints(new Constraint<>(carbs)).value();
|
||||||
|
|
||||||
final String units = currentProfile.getUnits();
|
final String units = ProfileFunctions.getSystemUnits();
|
||||||
DefaultValueHelper helper = new DefaultValueHelper();
|
DefaultValueHelper helper = new DefaultValueHelper();
|
||||||
|
|
||||||
int activityTTDuration = helper.determineActivityTTDuration();
|
int activityTTDuration = helper.determineActivityTTDuration();
|
||||||
|
@ -332,20 +331,20 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
|
||||||
|
|
||||||
if (startActivityTTCheckbox.isChecked()) {
|
if (startActivityTTCheckbox.isChecked()) {
|
||||||
String unitLabel = "mg/dl";
|
String unitLabel = "mg/dl";
|
||||||
if (currentProfile.getUnits().equals(Constants.MMOL)) {
|
if (units.equals(Constants.MMOL)) {
|
||||||
unitLabel = "mmol/l";
|
unitLabel = "mmol/l";
|
||||||
}
|
}
|
||||||
actions.add(MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.tempTargetConfirmation) + "'>" + DecimalFormatter.to1Decimal(activityTT) + " " + unitLabel + " (" + activityTTDuration + " min)</font>");
|
actions.add(MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.tempTargetConfirmation) + "'>" + DecimalFormatter.to1Decimal(activityTT) + " " + unitLabel + " (" + activityTTDuration + " min)</font>");
|
||||||
}
|
}
|
||||||
if (startEatingSoonTTCheckbox.isChecked()) {
|
if (startEatingSoonTTCheckbox.isChecked()) {
|
||||||
if (currentProfile.getUnits().equals(Constants.MMOL)) {
|
if (units.equals(Constants.MMOL)) {
|
||||||
actions.add(MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.tempTargetConfirmation) + "'>" + DecimalFormatter.to1Decimal(eatingSoonTT) + " mmol/l (" + eatingSoonTTDuration + " min)</font>");
|
actions.add(MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.tempTargetConfirmation) + "'>" + DecimalFormatter.to1Decimal(eatingSoonTT) + " mmol/l (" + eatingSoonTTDuration + " min)</font>");
|
||||||
} else {
|
} else {
|
||||||
actions.add(MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.tempTargetConfirmation) + "'>" + DecimalFormatter.to0Decimal(eatingSoonTT) + " mg/dl (" + eatingSoonTTDuration + " min)</font>");
|
actions.add(MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.tempTargetConfirmation) + "'>" + DecimalFormatter.to0Decimal(eatingSoonTT) + " mg/dl (" + eatingSoonTTDuration + " min)</font>");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (startHypoTTCheckbox.isChecked()) {
|
if (startHypoTTCheckbox.isChecked()) {
|
||||||
if (currentProfile.getUnits().equals(Constants.MMOL)) {
|
if (units.equals(Constants.MMOL)) {
|
||||||
actions.add(MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.tempTargetConfirmation) + "'>" + DecimalFormatter.to1Decimal(hypoTT) + " mmol/l (" + hypoTTDuration + " min)</font>");
|
actions.add(MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.tempTargetConfirmation) + "'>" + DecimalFormatter.to1Decimal(hypoTT) + " mmol/l (" + hypoTTDuration + " min)</font>");
|
||||||
} else {
|
} else {
|
||||||
actions.add(MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.tempTargetConfirmation) + "'>" + DecimalFormatter.to0Decimal(hypoTT) + " mg/dl (" + hypoTTDuration + " min)</font>");
|
actions.add(MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.tempTargetConfirmation) + "'>" + DecimalFormatter.to0Decimal(hypoTT) + " mg/dl (" + hypoTTDuration + " min)</font>");
|
||||||
|
@ -398,8 +397,8 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
|
||||||
.duration(finalActivityTTDuration)
|
.duration(finalActivityTTDuration)
|
||||||
.reason(MainApp.gs(R.string.activity))
|
.reason(MainApp.gs(R.string.activity))
|
||||||
.source(Source.USER)
|
.source(Source.USER)
|
||||||
.low(Profile.toMgdl(finalActivityTT, currentProfile.getUnits()))
|
.low(Profile.toMgdl(finalActivityTT, ProfileFunctions.getSystemUnits()))
|
||||||
.high(Profile.toMgdl(finalActivityTT, currentProfile.getUnits()));
|
.high(Profile.toMgdl(finalActivityTT, ProfileFunctions.getSystemUnits()));
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
||||||
} else if (startEatingSoonTTCheckbox.isChecked()) {
|
} else if (startEatingSoonTTCheckbox.isChecked()) {
|
||||||
TempTarget tempTarget = new TempTarget()
|
TempTarget tempTarget = new TempTarget()
|
||||||
|
@ -407,8 +406,8 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
|
||||||
.duration(finalEatingSoonTTDuration)
|
.duration(finalEatingSoonTTDuration)
|
||||||
.reason(MainApp.gs(R.string.eatingsoon))
|
.reason(MainApp.gs(R.string.eatingsoon))
|
||||||
.source(Source.USER)
|
.source(Source.USER)
|
||||||
.low(Profile.toMgdl(finalEatigSoonTT, currentProfile.getUnits()))
|
.low(Profile.toMgdl(finalEatigSoonTT, ProfileFunctions.getSystemUnits()))
|
||||||
.high(Profile.toMgdl(finalEatigSoonTT, currentProfile.getUnits()));
|
.high(Profile.toMgdl(finalEatigSoonTT, ProfileFunctions.getSystemUnits()));
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
||||||
} else if (startHypoTTCheckbox.isChecked()) {
|
} else if (startHypoTTCheckbox.isChecked()) {
|
||||||
TempTarget tempTarget = new TempTarget()
|
TempTarget tempTarget = new TempTarget()
|
||||||
|
@ -416,8 +415,8 @@ public class NewCarbsDialog extends DialogFragment implements OnClickListener, C
|
||||||
.duration(finalHypoTTDuration)
|
.duration(finalHypoTTDuration)
|
||||||
.reason(MainApp.gs(R.string.hypo))
|
.reason(MainApp.gs(R.string.hypo))
|
||||||
.source(Source.USER)
|
.source(Source.USER)
|
||||||
.low(Profile.toMgdl(finalHypoTT, currentProfile.getUnits()))
|
.low(Profile.toMgdl(finalHypoTT, ProfileFunctions.getSystemUnits()))
|
||||||
.high(Profile.toMgdl(finalHypoTT, currentProfile.getUnits()));
|
.high(Profile.toMgdl(finalHypoTT, ProfileFunctions.getSystemUnits()));
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,6 @@ package info.nightscout.androidaps.plugins.general.overview.dialogs;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.HandlerThread;
|
|
||||||
import androidx.fragment.app.DialogFragment;
|
import androidx.fragment.app.DialogFragment;
|
||||||
import androidx.appcompat.app.AlertDialog;
|
import androidx.appcompat.app.AlertDialog;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
@ -56,9 +55,9 @@ import static info.nightscout.androidaps.utils.DateUtil.now;
|
||||||
public class NewInsulinDialog extends DialogFragment implements OnClickListener {
|
public class NewInsulinDialog extends DialogFragment implements OnClickListener {
|
||||||
private static Logger log = LoggerFactory.getLogger(NewInsulinDialog.class);
|
private static Logger log = LoggerFactory.getLogger(NewInsulinDialog.class);
|
||||||
|
|
||||||
public static final double PLUS1_DEFAULT = 0.5d;
|
private static final double PLUS1_DEFAULT = 0.5d;
|
||||||
public static final double PLUS2_DEFAULT = 1d;
|
private static final double PLUS2_DEFAULT = 1d;
|
||||||
public static final double PLUS3_DEFAULT = 2d;
|
private static final double PLUS3_DEFAULT = 2d;
|
||||||
|
|
||||||
private CheckBox startEatingSoonTTCheckbox;
|
private CheckBox startEatingSoonTTCheckbox;
|
||||||
private CheckBox recordOnlyCheckbox;
|
private CheckBox recordOnlyCheckbox;
|
||||||
|
@ -207,9 +206,8 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener
|
||||||
okClicked = true;
|
okClicked = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Profile currentProfile = ProfileFunctions.getInstance().getProfile();
|
|
||||||
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
final PumpInterface pump = ConfigBuilderPlugin.getPlugin().getActivePump();
|
||||||
if (currentProfile == null || pump == null)
|
if (pump == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Double insulin = SafeParse.stringToDouble(editInsulin.getText());
|
Double insulin = SafeParse.stringToDouble(editInsulin.getText());
|
||||||
|
@ -228,11 +226,11 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener
|
||||||
|
|
||||||
int eatingSoonTTDuration = SP.getInt(R.string.key_eatingsoon_duration, Constants.defaultEatingSoonTTDuration);
|
int eatingSoonTTDuration = SP.getInt(R.string.key_eatingsoon_duration, Constants.defaultEatingSoonTTDuration);
|
||||||
eatingSoonTTDuration = eatingSoonTTDuration > 0 ? eatingSoonTTDuration : Constants.defaultEatingSoonTTDuration;
|
eatingSoonTTDuration = eatingSoonTTDuration > 0 ? eatingSoonTTDuration : Constants.defaultEatingSoonTTDuration;
|
||||||
double eatingSoonTT = SP.getDouble(R.string.key_eatingsoon_target, currentProfile.getUnits().equals(Constants.MMOL) ? Constants.defaultEatingSoonTTmmol : Constants.defaultEatingSoonTTmgdl);
|
double eatingSoonTT = SP.getDouble(R.string.key_eatingsoon_target, ProfileFunctions.getSystemUnits().equals(Constants.MMOL) ? Constants.defaultEatingSoonTTmmol : Constants.defaultEatingSoonTTmgdl);
|
||||||
eatingSoonTT = eatingSoonTT > 0 ? eatingSoonTT : currentProfile.getUnits().equals(Constants.MMOL) ? Constants.defaultEatingSoonTTmmol : Constants.defaultEatingSoonTTmgdl;
|
eatingSoonTT = eatingSoonTT > 0 ? eatingSoonTT : ProfileFunctions.getSystemUnits().equals(Constants.MMOL) ? Constants.defaultEatingSoonTTmmol : Constants.defaultEatingSoonTTmgdl;
|
||||||
|
|
||||||
if (startEatingSoonTTCheckbox.isChecked()) {
|
if (startEatingSoonTTCheckbox.isChecked()) {
|
||||||
if (currentProfile.getUnits().equals(Constants.MMOL)) {
|
if (ProfileFunctions.getSystemUnits().equals(Constants.MMOL)) {
|
||||||
actions.add(MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.tempTargetConfirmation) + "'>" + DecimalFormatter.to1Decimal(eatingSoonTT) + " mmol/l (" + eatingSoonTTDuration + " min)</font>");
|
actions.add(MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.tempTargetConfirmation) + "'>" + DecimalFormatter.to1Decimal(eatingSoonTT) + " mmol/l (" + eatingSoonTTDuration + " min)</font>");
|
||||||
} else
|
} else
|
||||||
actions.add(MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.tempTargetConfirmation) + "'>" + DecimalFormatter.to0Decimal(eatingSoonTT) + " mg/dl (" + eatingSoonTTDuration + " min)</font>");
|
actions.add(MainApp.gs(R.string.temptargetshort) + ": " + "<font color='" + MainApp.gc(R.color.tempTargetConfirmation) + "'>" + DecimalFormatter.to0Decimal(eatingSoonTT) + " mg/dl (" + eatingSoonTTDuration + " min)</font>");
|
||||||
|
@ -272,8 +270,8 @@ public class NewInsulinDialog extends DialogFragment implements OnClickListener
|
||||||
.duration(finalEatingSoonTTDuration)
|
.duration(finalEatingSoonTTDuration)
|
||||||
.reason(MainApp.gs(R.string.eatingsoon))
|
.reason(MainApp.gs(R.string.eatingsoon))
|
||||||
.source(Source.USER)
|
.source(Source.USER)
|
||||||
.low(Profile.toMgdl(finalEatigSoonTT, currentProfile.getUnits()))
|
.low(Profile.toMgdl(finalEatigSoonTT, ProfileFunctions.getSystemUnits()))
|
||||||
.high(Profile.toMgdl(finalEatigSoonTT, currentProfile.getUnits()));
|
.high(Profile.toMgdl(finalEatigSoonTT, ProfileFunctions.getSystemUnits()));
|
||||||
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
TreatmentsPlugin.getPlugin().addToHistoryTempTarget(tempTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -222,7 +222,7 @@ class WizardDialog : DialogFragment() {
|
||||||
} ?: return
|
} ?: return
|
||||||
|
|
||||||
|
|
||||||
val units = profile.units
|
val units = ProfileFunctions.getSystemUnits()
|
||||||
treatments_wizard_bgunits.text = units
|
treatments_wizard_bgunits.text = units
|
||||||
if (units == Constants.MGDL)
|
if (units == Constants.MGDL)
|
||||||
treatments_wizard_bg_input.setStep(1.0)
|
treatments_wizard_bg_input.setStep(1.0)
|
||||||
|
@ -302,7 +302,7 @@ class WizardDialog : DialogFragment() {
|
||||||
treatment_wizard_notes.text.toString(), carbTime)
|
treatment_wizard_notes.text.toString(), carbTime)
|
||||||
|
|
||||||
wizard?.let { wizard ->
|
wizard?.let { wizard ->
|
||||||
treatments_wizard_bg.text = String.format(MainApp.gs(R.string.format_bg_isf), BgReading().value(Profile.toMgdl(bg, specificProfile.units)).valueToUnitsToString(specificProfile.units), wizard.sens)
|
treatments_wizard_bg.text = String.format(MainApp.gs(R.string.format_bg_isf), BgReading().value(Profile.toMgdl(bg, ProfileFunctions.getSystemUnits())).valueToUnitsToString(ProfileFunctions.getSystemUnits()), wizard.sens)
|
||||||
treatments_wizard_bginsulin.text = StringUtils.formatInsulin(wizard.insulinFromBG)
|
treatments_wizard_bginsulin.text = StringUtils.formatInsulin(wizard.insulinFromBG)
|
||||||
|
|
||||||
treatments_wizard_carbs.text = String.format(MainApp.gs(R.string.format_carbs_ic), carbs.toDouble(), wizard.ic)
|
treatments_wizard_carbs.text = String.format(MainApp.gs(R.string.format_carbs_ic), carbs.toDouble(), wizard.ic)
|
||||||
|
@ -320,8 +320,8 @@ class WizardDialog : DialogFragment() {
|
||||||
// Trend
|
// Trend
|
||||||
if (treatments_wizard_bgtrendcheckbox.isChecked && wizard.glucoseStatus != null) {
|
if (treatments_wizard_bgtrendcheckbox.isChecked && wizard.glucoseStatus != null) {
|
||||||
treatments_wizard_bgtrend.text = ((if (wizard.trend > 0) "+" else "")
|
treatments_wizard_bgtrend.text = ((if (wizard.trend > 0) "+" else "")
|
||||||
+ Profile.toUnitsString(wizard.trend * 3, wizard.trend * 3 / Constants.MMOLL_TO_MGDL, specificProfile.units)
|
+ Profile.toUnitsString(wizard.trend * 3, wizard.trend * 3 / Constants.MMOLL_TO_MGDL, ProfileFunctions.getSystemUnits())
|
||||||
+ " " + specificProfile.units)
|
+ " " + ProfileFunctions.getSystemUnits())
|
||||||
} else {
|
} else {
|
||||||
treatments_wizard_bgtrend.text = ""
|
treatments_wizard_bgtrend.text = ""
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class GraphData {
|
||||||
private IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
private IobCobCalculatorPlugin iobCobCalculatorPlugin;
|
||||||
|
|
||||||
public GraphData(GraphView graph, IobCobCalculatorPlugin iobCobCalculatorPlugin) {
|
public GraphData(GraphView graph, IobCobCalculatorPlugin iobCobCalculatorPlugin) {
|
||||||
units = ProfileFunctions.getInstance().getProfileUnits();
|
units = ProfileFunctions.getSystemUnits();
|
||||||
this.graph = graph;
|
this.graph = graph;
|
||||||
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
|
this.iobCobCalculatorPlugin = iobCobCalculatorPlugin;
|
||||||
}
|
}
|
||||||
|
@ -264,9 +264,9 @@ public class GraphData {
|
||||||
TempTarget tt = TreatmentsPlugin.getPlugin().getTempTargetFromHistory(time);
|
TempTarget tt = TreatmentsPlugin.getPlugin().getTempTargetFromHistory(time);
|
||||||
double value;
|
double value;
|
||||||
if (tt == null) {
|
if (tt == null) {
|
||||||
value = (profile.getTargetLow(time) + profile.getTargetHigh(time)) / 2;
|
value = Profile.fromMgdlToUnits((profile.getTargetLowMgdl(time) + profile.getTargetHighMgdl(time)) / 2, ProfileFunctions.getSystemUnits());
|
||||||
} else {
|
} else {
|
||||||
value = Profile.fromMgdlToUnits(tt.target(), profile.getUnits());
|
value = Profile.fromMgdlToUnits(tt.target(), ProfileFunctions.getSystemUnits());
|
||||||
}
|
}
|
||||||
if (lastTarget != value) {
|
if (lastTarget != value) {
|
||||||
if (lastTarget != -1)
|
if (lastTarget != -1)
|
||||||
|
|
|
@ -181,7 +181,7 @@ public class PersistentNotificationPlugin extends PluginBase {
|
||||||
line1 = MainApp.gs(R.string.loading);
|
line1 = MainApp.gs(R.string.loading);
|
||||||
} else if (ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() != null && ProfileFunctions.getInstance().isProfileValid("Notification")) {
|
} else if (ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() != null && ProfileFunctions.getInstance().isProfileValid("Notification")) {
|
||||||
String line1_aa;
|
String line1_aa;
|
||||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
String units = ProfileFunctions.getSystemUnits();
|
||||||
|
|
||||||
|
|
||||||
BgReading lastBG = DatabaseHelper.lastBg();
|
BgReading lastBG = DatabaseHelper.lastBg();
|
||||||
|
|
|
@ -275,7 +275,7 @@ public class SmsCommunicatorPlugin extends PluginBase {
|
||||||
|
|
||||||
String reply = "";
|
String reply = "";
|
||||||
|
|
||||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
String units = ProfileFunctions.getSystemUnits();
|
||||||
|
|
||||||
if (actualBG != null) {
|
if (actualBG != null) {
|
||||||
reply = MainApp.gs(R.string.sms_actualbg) + " " + actualBG.valueToUnitsToString(units) + ", ";
|
reply = MainApp.gs(R.string.sms_actualbg) + " " + actualBG.valueToUnitsToString(units) + ", ";
|
||||||
|
|
|
@ -41,12 +41,12 @@ class ProfileElement private constructor(ps: ProfileSwitch)
|
||||||
checkNotNull(profile)
|
checkNotNull(profile)
|
||||||
for (br in profile.basalValues)
|
for (br in profile.basalValues)
|
||||||
basalSchedules.Normal.add(BasalRate(br.timeAsSeconds * 1000, br.value))
|
basalSchedules.Normal.add(BasalRate(br.timeAsSeconds * 1000, br.value))
|
||||||
for (target in profile.singleTargets)
|
for (target in profile.singleTargetsMgdl)
|
||||||
bgTargets.Normal.add(Target(target.timeAsSeconds * 1000, Profile.toMgdl(target.value, profile.units)))
|
bgTargets.Normal.add(Target(target.timeAsSeconds * 1000, target.value))
|
||||||
for (ic in profile.ics)
|
for (ic in profile.ics)
|
||||||
carbRatios.Normal.add(Ratio(ic.timeAsSeconds * 1000, ic.value))
|
carbRatios.Normal.add(Ratio(ic.timeAsSeconds * 1000, ic.value))
|
||||||
for (isf in profile.isfs)
|
for (isf in profile.isfsMgdl)
|
||||||
insulinSensitivities.Normal.add(Ratio(isf.timeAsSeconds * 1000, Profile.toMgdl(isf.value, profile.units)))
|
insulinSensitivities.Normal.add(Ratio(isf.timeAsSeconds * 1000, isf.value))
|
||||||
}
|
}
|
||||||
|
|
||||||
inner class BasalProfile internal constructor(
|
inner class BasalProfile internal constructor(
|
||||||
|
|
|
@ -131,12 +131,7 @@ public class ActionStringHandler {
|
||||||
///////////////////////////////////////////////////////// TEMPTARGET
|
///////////////////////////////////////////////////////// TEMPTARGET
|
||||||
boolean isMGDL = Boolean.parseBoolean(act[1]);
|
boolean isMGDL = Boolean.parseBoolean(act[1]);
|
||||||
|
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile();
|
if (ProfileFunctions.getSystemUnits().equals(Constants.MGDL) != isMGDL) {
|
||||||
if (profile == null) {
|
|
||||||
sendError("No profile found!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (profile.getUnits().equals(Constants.MGDL) != isMGDL) {
|
|
||||||
sendError("Different units used on watch and phone!");
|
sendError("Different units used on watch and phone!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -222,7 +217,7 @@ public class ActionStringHandler {
|
||||||
DecimalFormat format = new DecimalFormat("0.00");
|
DecimalFormat format = new DecimalFormat("0.00");
|
||||||
DecimalFormat formatInt = new DecimalFormat("0");
|
DecimalFormat formatInt = new DecimalFormat("0");
|
||||||
BolusWizard bolusWizard = new BolusWizard(profile, profileName, TreatmentsPlugin.getPlugin().getTempTargetFromHistory(),
|
BolusWizard bolusWizard = new BolusWizard(profile, profileName, TreatmentsPlugin.getPlugin().getTempTargetFromHistory(),
|
||||||
carbsAfterConstraints, cobInfo.displayCob, bgReading.valueToUnits(profile.getUnits()),
|
carbsAfterConstraints, cobInfo.displayCob, bgReading.valueToUnits(ProfileFunctions.getSystemUnits()),
|
||||||
0d, percentage, useBG, useCOB, useBolusIOB, useBasalIOB, false, useTT, useTrend);
|
0d, percentage, useBG, useCOB, useBolusIOB, useBasalIOB, false, useTT, useTrend);
|
||||||
|
|
||||||
if (Math.abs(bolusWizard.getInsulinAfterConstraints() - bolusWizard.getCalculatedTotalInsulin()) >= 0.01) {
|
if (Math.abs(bolusWizard.getInsulinAfterConstraints() - bolusWizard.getCalculatedTotalInsulin()) >= 0.01) {
|
||||||
|
@ -534,14 +529,14 @@ public class ActionStringHandler {
|
||||||
//Check for Temp-Target:
|
//Check for Temp-Target:
|
||||||
TempTarget tempTarget = TreatmentsPlugin.getPlugin().getTempTargetFromHistory();
|
TempTarget tempTarget = TreatmentsPlugin.getPlugin().getTempTargetFromHistory();
|
||||||
if (tempTarget != null) {
|
if (tempTarget != null) {
|
||||||
ret += "Temp Target: " + Profile.toTargetRangeString(tempTarget.low, tempTarget.low, Constants.MGDL, profile.getUnits());
|
ret += "Temp Target: " + Profile.toTargetRangeString(tempTarget.low, tempTarget.low, Constants.MGDL, ProfileFunctions.getSystemUnits());
|
||||||
ret += "\nuntil: " + DateUtil.timeString(tempTarget.originalEnd());
|
ret += "\nuntil: " + DateUtil.timeString(tempTarget.originalEnd());
|
||||||
ret += "\n\n";
|
ret += "\n\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
ret += "DEFAULT RANGE: ";
|
ret += "DEFAULT RANGE: ";
|
||||||
ret += profile.getTargetLow() + " - " + profile.getTargetHigh();
|
ret += Profile.fromMgdlToUnits(profile.getTargetLowMgdl(), ProfileFunctions.getSystemUnits()) + " - " + Profile.fromMgdlToUnits(profile.getTargetHighMgdl(), ProfileFunctions.getSystemUnits());
|
||||||
ret += " target: " + profile.getTarget();
|
ret += " target: " + Profile.fromMgdlToUnits(profile.getTargetMgdl(), ProfileFunctions.getSystemUnits());
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -303,7 +303,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
|
|
||||||
|
|
||||||
private DataMap dataMapSingleBG(BgReading lastBG, GlucoseStatus glucoseStatus) {
|
private DataMap dataMapSingleBG(BgReading lastBG, GlucoseStatus glucoseStatus) {
|
||||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
String units = ProfileFunctions.getSystemUnits();
|
||||||
|
|
||||||
Double lowLine = SafeParse.stringToDouble(mPrefs.getString("low_mark", "0"));
|
Double lowLine = SafeParse.stringToDouble(mPrefs.getString("low_mark", "0"));
|
||||||
Double highLine = SafeParse.stringToDouble(mPrefs.getString("high_mark", "0"));
|
Double highLine = SafeParse.stringToDouble(mPrefs.getString("high_mark", "0"));
|
||||||
|
@ -323,7 +323,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
highLine = OverviewPlugin.INSTANCE.getBgTargetHigh();
|
highLine = OverviewPlugin.INSTANCE.getBgTargetHigh();
|
||||||
}
|
}
|
||||||
|
|
||||||
long sgvLevel = 0l;
|
long sgvLevel = 0L;
|
||||||
if (lastBG.value > highLine) {
|
if (lastBG.value > highLine) {
|
||||||
sgvLevel = 1;
|
sgvLevel = 1;
|
||||||
} else if (lastBG.value < lowLine) {
|
} else if (lastBG.value < lowLine) {
|
||||||
|
@ -721,7 +721,7 @@ public class WatchUpdaterService extends WearableListenerService implements Goog
|
||||||
//bgi
|
//bgi
|
||||||
|
|
||||||
|
|
||||||
double bgi = -(bolusIob.activity + basalIob.activity) * 5 * profile.getIsf();
|
double bgi = -(bolusIob.activity + basalIob.activity) * 5 * Profile.fromMgdlToUnits(profile.getIsfMgdl(), ProfileFunctions.getSystemUnits());
|
||||||
bgiString = "" + ((bgi >= 0) ? "+" : "") + DecimalFormatter.to1Decimal(bgi);
|
bgiString = "" + ((bgi >= 0) ? "+" : "") + DecimalFormatter.to1Decimal(bgi);
|
||||||
|
|
||||||
status = generateStatusString(profile, currentBasal, iobSum, iobDetail, bgiString);
|
status = generateStatusString(profile, currentBasal, iobSum, iobDetail, bgiString);
|
||||||
|
|
|
@ -206,7 +206,7 @@ public class StatuslinePlugin extends PluginBase {
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
double bgi = -(bolusIob.activity + basalIob.activity) * 5 * profile.getIsf();
|
double bgi = -(bolusIob.activity + basalIob.activity) * 5 * Profile.fromMgdlToUnits(profile.getIsfMgdl(), ProfileFunctions.getSystemUnits());
|
||||||
|
|
||||||
status += " " + ((bgi >= 0) ? "+" : "") + DecimalFormatter.to2Decimal(bgi);
|
status += " " + ((bgi >= 0) ? "+" : "") + DecimalFormatter.to2Decimal(bgi);
|
||||||
status += " " + IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "StatuslinePlugin").generateCOBString();
|
status += " " + IobCobCalculatorPlugin.getPlugin().getCobInfo(false, "StatuslinePlugin").generateCOBString();
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class AutosensData implements DataPointWithLabelInterface {
|
||||||
if (SensitivityAAPSPlugin.getPlugin().isEnabled(PluginType.SENSITIVITY) || SensitivityWeightedAveragePlugin.getPlugin().isEnabled(PluginType.SENSITIVITY)) {
|
if (SensitivityAAPSPlugin.getPlugin().isEnabled(PluginType.SENSITIVITY) || SensitivityWeightedAveragePlugin.getPlugin().isEnabled(PluginType.SENSITIVITY)) {
|
||||||
double maxAbsorptionHours = SP.getDouble(R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME);
|
double maxAbsorptionHours = SP.getDouble(R.string.key_absorption_maxtime, Constants.DEFAULT_MAX_ABSORPTION_TIME);
|
||||||
Profile profile = ProfileFunctions.getInstance().getProfile(t.date);
|
Profile profile = ProfileFunctions.getInstance().getProfile(t.date);
|
||||||
double sens = Profile.toMgdl(profile.getIsf(t.date), profile.getUnits());
|
double sens = profile.getIsfMgdl(t.date);
|
||||||
double ic = profile.getIc(t.date);
|
double ic = profile.getIc(t.date);
|
||||||
min5minCarbImpact = t.carbs / (maxAbsorptionHours * 60 / 5) * sens / ic;
|
min5minCarbImpact = t.carbs / (maxAbsorptionHours * 60 / 5) * sens / ic;
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
|
|
|
@ -149,7 +149,7 @@ public class IobCobOref1Thread extends Thread {
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
log.debug("Processing calculation thread: " + from + " (" + i + "/" + bucketed_data.size() + ")");
|
log.debug("Processing calculation thread: " + from + " (" + i + "/" + bucketed_data.size() + ")");
|
||||||
|
|
||||||
double sens = Profile.toMgdl(profile.getIsf(bgTime), profile.getUnits());
|
double sens = profile.getIsfMgdl(bgTime);
|
||||||
|
|
||||||
AutosensData autosensData = new AutosensData();
|
AutosensData autosensData = new AutosensData();
|
||||||
autosensData.time = bgTime;
|
autosensData.time = bgTime;
|
||||||
|
|
|
@ -148,7 +148,7 @@ public class IobCobThread extends Thread {
|
||||||
if (L.isEnabled(L.AUTOSENS))
|
if (L.isEnabled(L.AUTOSENS))
|
||||||
log.debug("Processing calculation thread: " + from + " (" + i + "/" + bucketed_data.size() + ")");
|
log.debug("Processing calculation thread: " + from + " (" + i + "/" + bucketed_data.size() + ")");
|
||||||
|
|
||||||
double sens = Profile.toMgdl(profile.getIsf(bgTime), profile.getUnits());
|
double sens = profile.getIsfMgdl(bgTime);
|
||||||
|
|
||||||
AutosensData autosensData = new AutosensData();
|
AutosensData autosensData = new AutosensData();
|
||||||
autosensData.time = bgTime;
|
autosensData.time = bgTime;
|
||||||
|
|
|
@ -17,7 +17,6 @@ import info.nightscout.androidaps.data.Profile
|
||||||
import info.nightscout.androidaps.events.EventInitializationChanged
|
import info.nightscout.androidaps.events.EventInitializationChanged
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus
|
import info.nightscout.androidaps.plugins.bus.RxBus
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions
|
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.CareportalFragment
|
import info.nightscout.androidaps.plugins.general.careportal.CareportalFragment
|
||||||
import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatmentDialog
|
import info.nightscout.androidaps.plugins.general.careportal.Dialogs.NewNSTreatmentDialog
|
||||||
import info.nightscout.androidaps.plugins.insulin.InsulinOrefBasePlugin.MIN_DIA
|
import info.nightscout.androidaps.plugins.insulin.InsulinOrefBasePlugin.MIN_DIA
|
||||||
|
|
|
@ -345,10 +345,6 @@ object LocalProfilePlugin : PluginBase(PluginDescription()
|
||||||
return rawProfile
|
return rawProfile
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getUnits(): String {
|
|
||||||
return if (currentProfile().mgdl) Constants.MGDL else Constants.MMOL
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun getProfileName(): String {
|
override fun getProfileName(): String {
|
||||||
return DecimalFormatter.to2Decimal(rawProfile?.defaultProfile?.percentageBasalSum()
|
return DecimalFormatter.to2Decimal(rawProfile?.defaultProfile?.percentageBasalSum()
|
||||||
?: 0.0) + "U "
|
?: 0.0) + "U "
|
||||||
|
|
|
@ -118,11 +118,6 @@ public class NSProfilePlugin extends PluginBase implements ProfileInterface {
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUnits() {
|
|
||||||
return profile != null ? profile.getUnits() : Constants.MGDL;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getProfileName() {
|
public String getProfileName() {
|
||||||
return profile.getDefaultProfileName();
|
return profile.getDefaultProfileName();
|
||||||
|
|
|
@ -444,11 +444,6 @@ public abstract class AbstractDanaRPlugin extends PluginBase implements PumpInte
|
||||||
return DanaRPump.getInstance().createConvertedProfile();
|
return DanaRPump.getInstance().createConvertedProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUnits() {
|
|
||||||
return DanaRPump.getInstance().getUnits();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getProfileName() {
|
public String getProfileName() {
|
||||||
return DanaRPump.getInstance().createConvertedProfileName();
|
return DanaRPump.getInstance().createConvertedProfileName();
|
||||||
|
|
|
@ -41,7 +41,6 @@ import info.nightscout.androidaps.queue.Callback;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
import info.nightscout.androidaps.utils.DecimalFormatter;
|
import info.nightscout.androidaps.utils.DecimalFormatter;
|
||||||
import info.nightscout.androidaps.utils.FabricPrivacy;
|
import info.nightscout.androidaps.utils.FabricPrivacy;
|
||||||
import info.nightscout.androidaps.utils.ToastUtils;
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||||
import io.reactivex.disposables.CompositeDisposable;
|
import io.reactivex.disposables.CompositeDisposable;
|
||||||
|
|
||||||
|
@ -49,8 +48,6 @@ public class DanaRHistoryActivity extends NoSplashActivity {
|
||||||
private static Logger log = LoggerFactory.getLogger(L.PUMP);
|
private static Logger log = LoggerFactory.getLogger(L.PUMP);
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
|
|
||||||
static Profile profile = null;
|
|
||||||
|
|
||||||
Spinner historyTypeSpinner;
|
Spinner historyTypeSpinner;
|
||||||
TextView statusView;
|
TextView statusView;
|
||||||
Button reloadButton;
|
Button reloadButton;
|
||||||
|
@ -182,11 +179,6 @@ public class DanaRHistoryActivity extends NoSplashActivity {
|
||||||
clearCardView();
|
clearCardView();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
profile = ProfileFunctions.getInstance().getProfile();
|
|
||||||
if (profile == null) {
|
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.gs(R.string.noprofile));
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.HistoryViewHolder> {
|
public static class RecyclerViewAdapter extends RecyclerView.Adapter<RecyclerViewAdapter.HistoryViewHolder> {
|
||||||
|
@ -252,7 +244,7 @@ public class DanaRHistoryActivity extends NoSplashActivity {
|
||||||
holder.alarm.setVisibility(View.GONE);
|
holder.alarm.setVisibility(View.GONE);
|
||||||
break;
|
break;
|
||||||
case RecordTypes.RECORD_TYPE_GLUCOSE:
|
case RecordTypes.RECORD_TYPE_GLUCOSE:
|
||||||
holder.value.setText(Profile.toUnitsString(record.recordValue, record.recordValue * Constants.MGDL_TO_MMOLL, profile.getUnits()));
|
holder.value.setText(Profile.toUnitsString(record.recordValue, record.recordValue * Constants.MGDL_TO_MMOLL, ProfileFunctions.getSystemUnits()));
|
||||||
// rest is the same
|
// rest is the same
|
||||||
case RecordTypes.RECORD_TYPE_CARBO:
|
case RecordTypes.RECORD_TYPE_CARBO:
|
||||||
case RecordTypes.RECORD_TYPE_BASALHOUR:
|
case RecordTypes.RECORD_TYPE_BASALHOUR:
|
||||||
|
|
|
@ -184,7 +184,7 @@ public class DanaRNSHistorySync {
|
||||||
log.debug("Syncing glucose record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate));
|
log.debug("Syncing glucose record " + record.recordValue + " " + DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put(DANARSIGNATURE, record.bytes);
|
nsrec.put(DANARSIGNATURE, record.bytes);
|
||||||
nsrec.put("eventType", "BG Check");
|
nsrec.put("eventType", "BG Check");
|
||||||
nsrec.put("glucose", Profile.fromMgdlToUnits(record.recordValue, ProfileFunctions.getInstance().getProfileUnits()));
|
nsrec.put("glucose", Profile.fromMgdlToUnits(record.recordValue, ProfileFunctions.getSystemUnits()));
|
||||||
nsrec.put("glucoseType", "Finger");
|
nsrec.put("glucoseType", "Finger");
|
||||||
nsrec.put("created_at", DateUtil.toISOString(record.recordDate));
|
nsrec.put("created_at", DateUtil.toISOString(record.recordDate));
|
||||||
nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name));
|
nsrec.put("enteredBy", "openaps://" + MainApp.gs(R.string.app_name));
|
||||||
|
|
|
@ -275,11 +275,6 @@ public class DanaRSPlugin extends PluginBase implements PumpInterface, DanaRInte
|
||||||
return DanaRPump.getInstance().createConvertedProfile();
|
return DanaRPump.getInstance().createConvertedProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUnits() {
|
|
||||||
return DanaRPump.getInstance().getUnits();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getProfileName() {
|
public String getProfileName() {
|
||||||
return DanaRPump.getInstance().createConvertedProfileName();
|
return DanaRPump.getInstance().createConvertedProfileName();
|
||||||
|
|
|
@ -137,7 +137,7 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
|
||||||
Double[] deviations = new Double[deviationsArray.size()];
|
Double[] deviations = new Double[deviationsArray.size()];
|
||||||
deviations = deviationsArray.toArray(deviations);
|
deviations = deviationsArray.toArray(deviations);
|
||||||
|
|
||||||
double sens = profile.getIsf();
|
double sens = profile.getIsfMgdl();
|
||||||
|
|
||||||
String ratioLimit = "";
|
String ratioLimit = "";
|
||||||
String sensResult = "";
|
String sensResult = "";
|
||||||
|
@ -148,7 +148,7 @@ public class SensitivityAAPSPlugin extends AbstractSensitivityPlugin {
|
||||||
Arrays.sort(deviations);
|
Arrays.sort(deviations);
|
||||||
|
|
||||||
double percentile = IobCobCalculatorPlugin.percentile(deviations, 0.50);
|
double percentile = IobCobCalculatorPlugin.percentile(deviations, 0.50);
|
||||||
double basalOff = percentile * (60 / 5) / Profile.toMgdl(sens, profile.getUnits());
|
double basalOff = percentile * (60 / 5) / sens;
|
||||||
double ratio = 1 + (basalOff / profile.getMaxDailyBasal());
|
double ratio = 1 + (basalOff / profile.getMaxDailyBasal());
|
||||||
|
|
||||||
if (percentile < 0) { // sensitive
|
if (percentile < 0) { // sensitive
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class SensitivityOref0Plugin extends AbstractSensitivityPlugin {
|
||||||
Double[] deviations = new Double[deviationsArray.size()];
|
Double[] deviations = new Double[deviationsArray.size()];
|
||||||
deviations = deviationsArray.toArray(deviations);
|
deviations = deviationsArray.toArray(deviations);
|
||||||
|
|
||||||
double sens = profile.getIsf();
|
double sens = profile.getIsfMgdl();
|
||||||
|
|
||||||
double ratio = 1;
|
double ratio = 1;
|
||||||
String ratioLimit = "";
|
String ratioLimit = "";
|
||||||
|
@ -154,10 +154,10 @@ public class SensitivityOref0Plugin extends AbstractSensitivityPlugin {
|
||||||
double basalOff = 0;
|
double basalOff = 0;
|
||||||
|
|
||||||
if (pSensitive < 0) { // sensitive
|
if (pSensitive < 0) { // sensitive
|
||||||
basalOff = pSensitive * (60 / 5) / Profile.toMgdl(sens, profile.getUnits());
|
basalOff = pSensitive * (60 / 5.0) / sens;
|
||||||
sensResult = "Excess insulin sensitivity detected";
|
sensResult = "Excess insulin sensitivity detected";
|
||||||
} else if (pResistant > 0) { // resistant
|
} else if (pResistant > 0) { // resistant
|
||||||
basalOff = pResistant * (60 / 5) / Profile.toMgdl(sens, profile.getUnits());
|
basalOff = pResistant * (60 / 5.0) / sens;
|
||||||
sensResult = "Excess insulin resistance detected";
|
sensResult = "Excess insulin resistance detected";
|
||||||
} else {
|
} else {
|
||||||
sensResult = "Sensitivity normal";
|
sensResult = "Sensitivity normal";
|
||||||
|
|
|
@ -146,7 +146,7 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
|
||||||
Double[] deviations = new Double[deviationsArray.size()];
|
Double[] deviations = new Double[deviationsArray.size()];
|
||||||
deviations = deviationsArray.toArray(deviations);
|
deviations = deviationsArray.toArray(deviations);
|
||||||
|
|
||||||
double sens = profile.getIsf();
|
double sens = profile.getIsfMgdl();
|
||||||
|
|
||||||
double ratio = 1;
|
double ratio = 1;
|
||||||
String ratioLimit = "";
|
String ratioLimit = "";
|
||||||
|
@ -174,10 +174,10 @@ public class SensitivityOref1Plugin extends AbstractSensitivityPlugin {
|
||||||
double basalOff = 0;
|
double basalOff = 0;
|
||||||
|
|
||||||
if (pSensitive < 0) { // sensitive
|
if (pSensitive < 0) { // sensitive
|
||||||
basalOff = pSensitive * (60 / 5) / Profile.toMgdl(sens, profile.getUnits());
|
basalOff = pSensitive * (60 / 5.0) / sens;
|
||||||
sensResult = "Excess insulin sensitivity detected";
|
sensResult = "Excess insulin sensitivity detected";
|
||||||
} else if (pResistant > 0) { // resistant
|
} else if (pResistant > 0) { // resistant
|
||||||
basalOff = pResistant * (60 / 5) / Profile.toMgdl(sens, profile.getUnits());
|
basalOff = pResistant * (60 / 5.0) / sens;
|
||||||
sensResult = "Excess insulin resistance detected";
|
sensResult = "Excess insulin resistance detected";
|
||||||
} else {
|
} else {
|
||||||
sensResult = "Sensitivity normal";
|
sensResult = "Sensitivity normal";
|
||||||
|
|
|
@ -164,7 +164,7 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
|
||||||
return new AutosensResult();
|
return new AutosensResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
double sens = profile.getIsf();
|
double sens = profile.getIsfMgdl();
|
||||||
|
|
||||||
String ratioLimit = "";
|
String ratioLimit = "";
|
||||||
String sensResult;
|
String sensResult;
|
||||||
|
@ -173,7 +173,7 @@ public class SensitivityWeightedAveragePlugin extends AbstractSensitivityPlugin
|
||||||
log.debug("Records: " + index + " " + pastSensitivity);
|
log.debug("Records: " + index + " " + pastSensitivity);
|
||||||
|
|
||||||
double average = weightedsum / weights;
|
double average = weightedsum / weights;
|
||||||
double basalOff = average * (60 / 5) / Profile.toMgdl(sens, profile.getUnits());
|
double basalOff = average * (60 / 5.0) / sens;
|
||||||
double ratio = 1 + (basalOff / profile.getMaxDailyBasal());
|
double ratio = 1 + (basalOff / profile.getMaxDailyBasal());
|
||||||
|
|
||||||
if (average < 0) { // sensitive
|
if (average < 0) { // sensitive
|
||||||
|
|
|
@ -16,12 +16,11 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import info.nightscout.androidaps.Constants;
|
|
||||||
import info.nightscout.androidaps.MainApp;
|
import info.nightscout.androidaps.MainApp;
|
||||||
import info.nightscout.androidaps.R;
|
import info.nightscout.androidaps.R;
|
||||||
import info.nightscout.androidaps.db.BgReading;
|
import info.nightscout.androidaps.db.BgReading;
|
||||||
import info.nightscout.androidaps.plugins.bus.RxBus;
|
import info.nightscout.androidaps.plugins.bus.RxBus;
|
||||||
import info.nightscout.androidaps.plugins.configBuilder.ConfigBuilderPlugin;
|
import info.nightscout.androidaps.plugins.configBuilder.ProfileFunctions;
|
||||||
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
import info.nightscout.androidaps.plugins.general.nsclient.NSUpload;
|
||||||
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
import info.nightscout.androidaps.plugins.iob.iobCobCalculator.events.EventAutosensCalculationFinished;
|
||||||
import info.nightscout.androidaps.utils.DateUtil;
|
import info.nightscout.androidaps.utils.DateUtil;
|
||||||
|
@ -38,8 +37,6 @@ public class BGSourceFragment extends Fragment {
|
||||||
private CompositeDisposable disposable = new CompositeDisposable();
|
private CompositeDisposable disposable = new CompositeDisposable();
|
||||||
RecyclerView recyclerView;
|
RecyclerView recyclerView;
|
||||||
|
|
||||||
String units = Constants.MGDL;
|
|
||||||
|
|
||||||
final long MILLS_TO_THE_PAST = T.hours(12).msecs();
|
final long MILLS_TO_THE_PAST = T.hours(12).msecs();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -57,9 +54,6 @@ public class BGSourceFragment extends Fragment {
|
||||||
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getDbHelper().getAllBgreadingsDataFromTime(now - MILLS_TO_THE_PAST, false));
|
RecyclerViewAdapter adapter = new RecyclerViewAdapter(MainApp.getDbHelper().getAllBgreadingsDataFromTime(now - MILLS_TO_THE_PAST, false));
|
||||||
recyclerView.setAdapter(adapter);
|
recyclerView.setAdapter(adapter);
|
||||||
|
|
||||||
if (ConfigBuilderPlugin.getPlugin().getActiveProfileInterface() != null && ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile() != null && ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile().getDefaultProfile() != null)
|
|
||||||
units = ConfigBuilderPlugin.getPlugin().getActiveProfileInterface().getProfile().getDefaultProfile().getUnits();
|
|
||||||
|
|
||||||
return view;
|
return view;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
FabricPrivacy.logException(e);
|
FabricPrivacy.logException(e);
|
||||||
|
@ -109,7 +103,7 @@ public class BGSourceFragment extends Fragment {
|
||||||
holder.ns.setVisibility(NSUpload.isIdValid(bgReading._id) ? View.VISIBLE : View.GONE);
|
holder.ns.setVisibility(NSUpload.isIdValid(bgReading._id) ? View.VISIBLE : View.GONE);
|
||||||
holder.invalid.setVisibility(!bgReading.isValid ? View.VISIBLE : View.GONE);
|
holder.invalid.setVisibility(!bgReading.isValid ? View.VISIBLE : View.GONE);
|
||||||
holder.date.setText(DateUtil.dateAndTimeString(bgReading.date));
|
holder.date.setText(DateUtil.dateAndTimeString(bgReading.date));
|
||||||
holder.value.setText(bgReading.valueToUnitsToString(units));
|
holder.value.setText(bgReading.valueToUnitsToString(ProfileFunctions.getSystemUnits()));
|
||||||
holder.direction.setText(bgReading.directionToSymbol());
|
holder.direction.setText(bgReading.directionToSymbol());
|
||||||
holder.remove.setTag(bgReading);
|
holder.remove.setTag(bgReading);
|
||||||
}
|
}
|
||||||
|
@ -147,7 +141,7 @@ public class BGSourceFragment extends Fragment {
|
||||||
case R.id.bgsource_remove:
|
case R.id.bgsource_remove:
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
|
||||||
builder.setTitle(MainApp.gs(R.string.confirmation));
|
builder.setTitle(MainApp.gs(R.string.confirmation));
|
||||||
builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(bgReading.date) + "\n" + bgReading.valueToUnitsToString(units));
|
builder.setMessage(MainApp.gs(R.string.removerecord) + "\n" + DateUtil.dateAndTimeString(bgReading.date) + "\n" + bgReading.valueToUnitsToString(ProfileFunctions.getSystemUnits()));
|
||||||
builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
|
builder.setPositiveButton(MainApp.gs(R.string.ok), new DialogInterface.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int id) {
|
public void onClick(DialogInterface dialog, int id) {
|
||||||
/* final String _id = bgReading._id;
|
/* final String _id = bgReading._id;
|
||||||
|
|
|
@ -69,7 +69,7 @@ public class TreatmentsTempTargetFragment extends Fragment implements View.OnCli
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(TempTargetsViewHolder holder, int position) {
|
public void onBindViewHolder(TempTargetsViewHolder holder, int position) {
|
||||||
String units = ProfileFunctions.getInstance().getProfileUnits();
|
String units = ProfileFunctions.getSystemUnits();
|
||||||
TempTarget tempTarget = tempTargetList.getReversed(position);
|
TempTarget tempTarget = tempTargetList.getReversed(position);
|
||||||
holder.ph.setVisibility(tempTarget.source == Source.PUMP ? View.VISIBLE : View.GONE);
|
holder.ph.setVisibility(tempTarget.source == Source.PUMP ? View.VISIBLE : View.GONE);
|
||||||
holder.ns.setVisibility(NSUpload.isIdValid(tempTarget._id) ? View.VISIBLE : View.GONE);
|
holder.ns.setVisibility(NSUpload.isIdValid(tempTarget._id) ? View.VISIBLE : View.GONE);
|
||||||
|
|
|
@ -117,12 +117,12 @@ class BolusWizard @JvmOverloads constructor(val profile: Profile,
|
||||||
private fun doCalc() {
|
private fun doCalc() {
|
||||||
|
|
||||||
// Insulin from BG
|
// Insulin from BG
|
||||||
sens = profile.isf
|
sens = Profile.fromMgdlToUnits(profile.isfMgdl, ProfileFunctions.getSystemUnits())
|
||||||
targetBGLow = profile.targetLow
|
targetBGLow = Profile.fromMgdlToUnits(profile.targetLowMgdl, ProfileFunctions.getSystemUnits())
|
||||||
targetBGHigh = profile.targetHigh
|
targetBGHigh = Profile.fromMgdlToUnits(profile.targetHighMgdl, ProfileFunctions.getSystemUnits())
|
||||||
if (useTT && tempTarget != null) {
|
if (useTT && tempTarget != null) {
|
||||||
targetBGLow = Profile.fromMgdlToUnits(tempTarget.low, profile.units)
|
targetBGLow = Profile.fromMgdlToUnits(tempTarget.low, ProfileFunctions.getSystemUnits())
|
||||||
targetBGHigh = Profile.fromMgdlToUnits(tempTarget.high, profile.units)
|
targetBGHigh = Profile.fromMgdlToUnits(tempTarget.high, ProfileFunctions.getSystemUnits())
|
||||||
}
|
}
|
||||||
if (useBg && bg > 0) {
|
if (useBg && bg > 0) {
|
||||||
bgDiff = when {
|
bgDiff = when {
|
||||||
|
@ -138,7 +138,7 @@ class BolusWizard @JvmOverloads constructor(val profile: Profile,
|
||||||
glucoseStatus?.let {
|
glucoseStatus?.let {
|
||||||
if (useTrend) {
|
if (useTrend) {
|
||||||
trend = it.short_avgdelta
|
trend = it.short_avgdelta
|
||||||
insulinFromTrend = Profile.fromMgdlToUnits(trend, profile.units) * 3 / sens
|
insulinFromTrend = Profile.fromMgdlToUnits(trend, ProfileFunctions.getSystemUnits()) * 3 / sens
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class XdripCalibrations {
|
||||||
Context context = MainApp.instance().getApplicationContext();
|
Context context = MainApp.instance().getApplicationContext();
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putDouble("glucose_number", bg);
|
bundle.putDouble("glucose_number", bg);
|
||||||
bundle.putString("units", ProfileFunctions.getInstance().getProfileUnits().equals(Constants.MGDL) ? "mgdl" : "mmol");
|
bundle.putString("units", ProfileFunctions.getSystemUnits().equals(Constants.MGDL) ? "mgdl" : "mmol");
|
||||||
bundle.putLong("timestamp", System.currentTimeMillis());
|
bundle.putLong("timestamp", System.currentTimeMillis());
|
||||||
Intent intent = new Intent(Intents.ACTION_REMOTE_CALIBRATION);
|
Intent intent = new Intent(Intents.ACTION_REMOTE_CALIBRATION);
|
||||||
intent.putExtras(bundle);
|
intent.putExtras(bundle);
|
||||||
|
|
|
@ -1619,5 +1619,6 @@
|
||||||
<string name="format_carbs">%1$dg</string>
|
<string name="format_carbs">%1$dg</string>
|
||||||
<string name="common_on">On</string>
|
<string name="common_on">On</string>
|
||||||
<string name="common_off">Off</string>
|
<string name="common_off">Off</string>
|
||||||
|
<string name="nopumpselected">No pump selected</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|
Loading…
Reference in a new issue