optimize getUnits() & detecting faked extended
This commit is contained in:
parent
1de64f06c2
commit
afca896f23
26 changed files with 129 additions and 69 deletions
|
@ -10,6 +10,8 @@ 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.
|
||||||
*/
|
*/
|
||||||
|
@ -17,9 +19,11 @@ import java.util.Iterator;
|
||||||
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 = null;
|
||||||
|
private String units = Constants.MGDL;
|
||||||
|
|
||||||
public ProfileStore(JSONObject json) {
|
public ProfileStore(JSONObject json) {
|
||||||
this.json = json;
|
this.json = json;
|
||||||
|
getDefaultProfile(); // initialize units
|
||||||
}
|
}
|
||||||
|
|
||||||
public JSONObject getData() {
|
public JSONObject getData() {
|
||||||
|
@ -33,10 +37,10 @@ public class ProfileStore {
|
||||||
String defaultProfileName = json.getString("defaultProfile");
|
String defaultProfileName = json.getString("defaultProfile");
|
||||||
JSONObject store = json.getJSONObject("store");
|
JSONObject store = json.getJSONObject("store");
|
||||||
if (store.has(defaultProfileName)) {
|
if (store.has(defaultProfileName)) {
|
||||||
String units = null;
|
|
||||||
if (store.has("units"))
|
if (store.has("units"))
|
||||||
units = store.getString("units");
|
units = store.getString("units");
|
||||||
profile = new Profile(store.getJSONObject(defaultProfileName), units);
|
profile = new Profile(store.getJSONObject(defaultProfileName), units);
|
||||||
|
units = profile.getUnits();
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -59,6 +63,10 @@ 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;
|
||||||
|
|
|
@ -158,7 +158,7 @@ public class BgReading implements DataPointWithLabelInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getY() {
|
public double getY() {
|
||||||
String units = MainApp.getConfigBuilder().getProfile().getUnits();
|
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||||
return valueToUnits(units);
|
return valueToUnits(units);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ public class BgReading implements DataPointWithLabelInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getColor() {
|
public int getColor() {
|
||||||
String units = MainApp.getConfigBuilder().getProfile().getUnits();
|
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||||
Double lowLine = SP.getDouble("low_mark", 0d);
|
Double lowLine = SP.getDouble("low_mark", 0d);
|
||||||
Double highLine = SP.getDouble("high_mark", 0d);
|
Double highLine = SP.getDouble("high_mark", 0d);
|
||||||
if (lowLine < 1) {
|
if (lowLine < 1) {
|
||||||
|
|
|
@ -89,7 +89,7 @@ public class CareportalEvent implements DataPointWithLabelInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String age() {
|
public String age() {
|
||||||
Map<TimeUnit,Long> diff = computeDiff(date, new Date().getTime());
|
Map<TimeUnit, Long> diff = computeDiff(date, new Date().getTime());
|
||||||
return diff.get(TimeUnit.DAYS) + " " + MainApp.sResources.getString(R.string.days) + " " + diff.get(TimeUnit.HOURS) + " " + MainApp.sResources.getString(R.string.hours);
|
return diff.get(TimeUnit.DAYS) + " " + MainApp.sResources.getString(R.string.days) + " " + diff.get(TimeUnit.HOURS) + " " + MainApp.sResources.getString(R.string.hours);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,17 +105,17 @@ public class CareportalEvent implements DataPointWithLabelInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
//Map:{DAYS=1, HOURS=3, MINUTES=46, SECONDS=40, MILLISECONDS=0, MICROSECONDS=0, NANOSECONDS=0}
|
//Map:{DAYS=1, HOURS=3, MINUTES=46, SECONDS=40, MILLISECONDS=0, MICROSECONDS=0, NANOSECONDS=0}
|
||||||
public static Map<TimeUnit,Long> computeDiff(long date1, long date2) {
|
public static Map<TimeUnit, Long> computeDiff(long date1, long date2) {
|
||||||
long diffInMillies = date2 - date1;
|
long diffInMillies = date2 - date1;
|
||||||
List<TimeUnit> units = new ArrayList<TimeUnit>(EnumSet.allOf(TimeUnit.class));
|
List<TimeUnit> units = new ArrayList<TimeUnit>(EnumSet.allOf(TimeUnit.class));
|
||||||
Collections.reverse(units);
|
Collections.reverse(units);
|
||||||
Map<TimeUnit,Long> result = new LinkedHashMap<TimeUnit,Long>();
|
Map<TimeUnit, Long> result = new LinkedHashMap<TimeUnit, Long>();
|
||||||
long milliesRest = diffInMillies;
|
long milliesRest = diffInMillies;
|
||||||
for ( TimeUnit unit : units ) {
|
for (TimeUnit unit : units) {
|
||||||
long diff = unit.convert(milliesRest,TimeUnit.MILLISECONDS);
|
long diff = unit.convert(milliesRest, TimeUnit.MILLISECONDS);
|
||||||
long diffInMilliesForUnit = unit.toMillis(diff);
|
long diffInMilliesForUnit = unit.toMillis(diff);
|
||||||
milliesRest = milliesRest - diffInMilliesForUnit;
|
milliesRest = milliesRest - diffInMilliesForUnit;
|
||||||
result.put(unit,diff);
|
result.put(unit, diff);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -131,7 +131,7 @@ public class CareportalEvent implements DataPointWithLabelInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getY() {
|
public double getY() {
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||||
if (eventType.equals(MBG)) {
|
if (eventType.equals(MBG)) {
|
||||||
double mbg = 0d;
|
double mbg = 0d;
|
||||||
try {
|
try {
|
||||||
|
@ -140,13 +140,10 @@ public class CareportalEvent implements DataPointWithLabelInterface {
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (profile != null)
|
return Profile.fromMgdlToUnits(mbg, units);
|
||||||
return profile.fromMgdlToUnits(mbg, profile.getUnits());
|
|
||||||
return 0d;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double glucose = 0d;
|
double glucose = 0d;
|
||||||
String units = Constants.MGDL;
|
|
||||||
try {
|
try {
|
||||||
JSONObject object = new JSONObject(json);
|
JSONObject object = new JSONObject(json);
|
||||||
if (object.has("glucose")) {
|
if (object.has("glucose")) {
|
||||||
|
@ -156,7 +153,7 @@ public class CareportalEvent implements DataPointWithLabelInterface {
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (profile != null && glucose != 0d) {
|
if (glucose != 0d) {
|
||||||
double mmol = 0d;
|
double mmol = 0d;
|
||||||
double mgdl = 0;
|
double mgdl = 0;
|
||||||
if (units.equals(Constants.MGDL)) {
|
if (units.equals(Constants.MGDL)) {
|
||||||
|
@ -167,7 +164,7 @@ public class CareportalEvent implements DataPointWithLabelInterface {
|
||||||
mmol = glucose;
|
mmol = glucose;
|
||||||
mgdl = glucose * Constants.MMOLL_TO_MGDL;
|
mgdl = glucose * Constants.MMOLL_TO_MGDL;
|
||||||
}
|
}
|
||||||
return profile.toUnits(mgdl, mmol, profile.getUnits());
|
return Profile.toUnits(mgdl, mmol, units);
|
||||||
}
|
}
|
||||||
|
|
||||||
return yValue;
|
return yValue;
|
||||||
|
|
|
@ -204,6 +204,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
VirtualPumpPlugin.setFakingStatus(true);
|
||||||
scheduleBgChange(); // trigger refresh
|
scheduleBgChange(); // trigger refresh
|
||||||
scheduleTemporaryBasalChange();
|
scheduleTemporaryBasalChange();
|
||||||
scheduleTreatmentChange();
|
scheduleTreatmentChange();
|
||||||
|
@ -251,6 +252,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
VirtualPumpPlugin.setFakingStatus(false);
|
||||||
scheduleTemporaryBasalChange();
|
scheduleTemporaryBasalChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -817,8 +819,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
|
|
||||||
public void createTemptargetFromJsonIfNotExists(JSONObject trJson) {
|
public void createTemptargetFromJsonIfNotExists(JSONObject trJson) {
|
||||||
try {
|
try {
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||||
String units = profile.getUnits();
|
|
||||||
TempTarget tempTarget = new TempTarget();
|
TempTarget tempTarget = new TempTarget();
|
||||||
tempTarget.date = trJson.getLong("mills");
|
tempTarget.date = trJson.getLong("mills");
|
||||||
tempTarget.durationInMinutes = trJson.getInt("duration");
|
tempTarget.durationInMinutes = trJson.getInt("duration");
|
||||||
|
@ -1070,7 +1071,11 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
extendedBolus.durationInMinutes = trJson.getInt("duration");
|
extendedBolus.durationInMinutes = trJson.getInt("duration");
|
||||||
extendedBolus.insulin = trJson.getDouble("originalExtendedAmount");
|
extendedBolus.insulin = trJson.getDouble("originalExtendedAmount");
|
||||||
extendedBolus._id = trJson.getString("_id");
|
extendedBolus._id = trJson.getString("_id");
|
||||||
VirtualPumpPlugin.fromNSAreCommingFakedExtendedBoluses = true;
|
if (!VirtualPumpPlugin.getFakingStatus()) {
|
||||||
|
VirtualPumpPlugin.setFakingStatus(true);
|
||||||
|
updateEarliestDataChange(0);
|
||||||
|
scheduleTemporaryBasalChange();
|
||||||
|
}
|
||||||
createOrUpdate(extendedBolus);
|
createOrUpdate(extendedBolus);
|
||||||
} else if (trJson.has("isFakedTempBasal")) { // extended bolus end uploaded as temp basal end
|
} else if (trJson.has("isFakedTempBasal")) { // extended bolus end uploaded as temp basal end
|
||||||
ExtendedBolus extendedBolus = new ExtendedBolus();
|
ExtendedBolus extendedBolus = new ExtendedBolus();
|
||||||
|
@ -1080,7 +1085,11 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
|
||||||
extendedBolus.durationInMinutes = 0;
|
extendedBolus.durationInMinutes = 0;
|
||||||
extendedBolus.insulin = 0;
|
extendedBolus.insulin = 0;
|
||||||
extendedBolus._id = trJson.getString("_id");
|
extendedBolus._id = trJson.getString("_id");
|
||||||
VirtualPumpPlugin.fromNSAreCommingFakedExtendedBoluses = true;
|
if (!VirtualPumpPlugin.getFakingStatus()) {
|
||||||
|
VirtualPumpPlugin.setFakingStatus(true);
|
||||||
|
updateEarliestDataChange(0);
|
||||||
|
scheduleTemporaryBasalChange();
|
||||||
|
}
|
||||||
createOrUpdate(extendedBolus);
|
createOrUpdate(extendedBolus);
|
||||||
} else {
|
} else {
|
||||||
TemporaryBasal tempBasal = new TemporaryBasal();
|
TemporaryBasal tempBasal = new TemporaryBasal();
|
||||||
|
|
|
@ -10,5 +10,6 @@ import info.nightscout.androidaps.data.ProfileStore;
|
||||||
public interface ProfileInterface {
|
public interface ProfileInterface {
|
||||||
@Nullable
|
@Nullable
|
||||||
ProfileStore getProfile();
|
ProfileStore getProfile();
|
||||||
|
String getUnits();
|
||||||
String getProfileName();
|
String getProfileName();
|
||||||
}
|
}
|
||||||
|
|
|
@ -231,7 +231,6 @@ public class NewNSTreatmentDialog extends DialogFragment implements View.OnClick
|
||||||
profile = MainApp.getConfigBuilder().getProfile();
|
profile = MainApp.getConfigBuilder().getProfile();
|
||||||
profileStore = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile();
|
profileStore = MainApp.getConfigBuilder().getActiveProfileInterface().getProfile();
|
||||||
ArrayList<CharSequence> profileList;
|
ArrayList<CharSequence> profileList;
|
||||||
units = Constants.MGDL;
|
|
||||||
units = profile.getUnits();
|
units = profile.getUnits();
|
||||||
profileList = profileStore.getProfileList();
|
profileList = profileStore.getProfileList();
|
||||||
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getContext(),
|
ArrayAdapter<CharSequence> adapter = new ArrayAdapter<CharSequence>(getContext(),
|
||||||
|
|
|
@ -1008,6 +1008,10 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
|
||||||
return getProfile(new Date().getTime());
|
return getProfile(new Date().getTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getProfileUnits() {
|
||||||
|
return activeProfile.getUnits();
|
||||||
|
}
|
||||||
|
|
||||||
public Profile getProfile(long time) {
|
public Profile getProfile(long time) {
|
||||||
//log.debug("Profile for: " + new Date(time).toLocaleString() + " : " + getProfileName(time));
|
//log.debug("Profile for: " + new Date(time).toLocaleString() + " : " + getProfileName(time));
|
||||||
ProfileSwitch profileSwitch = getProfileSwitchFromHistory(time);
|
ProfileSwitch profileSwitch = getProfileSwitchFromHistory(time);
|
||||||
|
|
|
@ -345,6 +345,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
||||||
return iobTotal;
|
return iobTotal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
private static Long findPreviousTimeFromBucketedData(long time) {
|
private static Long findPreviousTimeFromBucketedData(long time) {
|
||||||
if (bucketed_data == null)
|
if (bucketed_data == null)
|
||||||
return null;
|
return null;
|
||||||
|
@ -413,6 +414,7 @@ public class IobCobCalculatorPlugin implements PluginBase {
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
// predict IOB out to DIA plus 30m
|
// predict IOB out to DIA plus 30m
|
||||||
long time = new Date().getTime();
|
long time = new Date().getTime();
|
||||||
|
time = roundUpTime(time);
|
||||||
int len = (int) ((profile.getDia() * 60 + 30) / 5);
|
int len = (int) ((profile.getDia() * 60 + 30) / 5);
|
||||||
IobTotal[] array = new IobTotal[len];
|
IobTotal[] array = new IobTotal[len];
|
||||||
int pos = 0;
|
int pos = 0;
|
||||||
|
|
|
@ -156,6 +156,7 @@ public class NSClientService extends Service {
|
||||||
ev.isChanged(R.string.key_nsclientinternal_api_secret) ||
|
ev.isChanged(R.string.key_nsclientinternal_api_secret) ||
|
||||||
ev.isChanged(R.string.key_nsclientinternal_paused)
|
ev.isChanged(R.string.key_nsclientinternal_paused)
|
||||||
) {
|
) {
|
||||||
|
latestDateInReceivedData = 0;
|
||||||
destroy();
|
destroy();
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
@ -164,6 +165,7 @@ public class NSClientService extends Service {
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onStatusEvent(EventConfigBuilderChange ev) {
|
public void onStatusEvent(EventConfigBuilderChange ev) {
|
||||||
if (nsEnabled != MainApp.getSpecificPlugin(NSClientInternalPlugin.class).isEnabled(PluginBase.GENERAL)) {
|
if (nsEnabled != MainApp.getSpecificPlugin(NSClientInternalPlugin.class).isEnabled(PluginBase.GENERAL)) {
|
||||||
|
latestDateInReceivedData = 0;
|
||||||
destroy();
|
destroy();
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,14 +60,10 @@ public class CalibrationDialog extends DialogFragment implements View.OnClickLis
|
||||||
okButton = (Button) view.findViewById(R.id.overview_calibration_okbutton);
|
okButton = (Button) view.findViewById(R.id.overview_calibration_okbutton);
|
||||||
okButton.setOnClickListener(this);
|
okButton.setOnClickListener(this);
|
||||||
|
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||||
Double bg = profile != null ? Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, profile.getUnits()) : 0d;
|
Double bg = Profile.fromMgdlToUnits(GlucoseStatus.getGlucoseStatusData() != null ? GlucoseStatus.getGlucoseStatusData().glucose : 0d, units);
|
||||||
|
|
||||||
String units = Constants.MGDL;
|
if (units.equals(Constants.MMOL))
|
||||||
if (profile != null)
|
|
||||||
units = profile.getUnits();
|
|
||||||
|
|
||||||
if (units.equals(Constants.MMOL))
|
|
||||||
bgText = new PlusMinusEditText(view, R.id.overview_calibration_bg, R.id.overview_calibration_bg_plus, R.id.overview_calibration_bg_minus, bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false);
|
bgText = new PlusMinusEditText(view, R.id.overview_calibration_bg, R.id.overview_calibration_bg_plus, R.id.overview_calibration_bg_minus, bg, 0d, 30d, 0.1d, new DecimalFormat("0.0"), false);
|
||||||
else
|
else
|
||||||
bgText = new PlusMinusEditText(view, R.id.overview_calibration_bg, R.id.overview_calibration_bg_plus, R.id.overview_calibration_bg_minus, bg, 0d, 500d, 1d, new DecimalFormat("0"), false);
|
bgText = new PlusMinusEditText(view, R.id.overview_calibration_bg, R.id.overview_calibration_bg_plus, R.id.overview_calibration_bg_minus, bg, 0d, 500d, 1d, new DecimalFormat("0"), false);
|
||||||
|
|
|
@ -916,6 +916,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
PumpInterface pump = MainApp.getConfigBuilder();
|
PumpInterface pump = MainApp.getConfigBuilder();
|
||||||
|
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
Profile profile = MainApp.getConfigBuilder().getProfile();
|
||||||
|
String units = profile.getUnits();
|
||||||
|
|
||||||
// open loop mode
|
// open loop mode
|
||||||
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
|
final LoopPlugin.LastRun finalLastRun = LoopPlugin.lastRun;
|
||||||
|
@ -958,13 +959,13 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetBackground));
|
tempTargetView.setBackgroundColor(MainApp.sResources.getColor(R.color.tempTargetBackground));
|
||||||
tempTargetView.setVisibility(View.VISIBLE);
|
tempTargetView.setVisibility(View.VISIBLE);
|
||||||
if (tempTarget.low == tempTarget.high)
|
if (tempTarget.low == tempTarget.high)
|
||||||
tempTargetView.setText(Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, profile.getUnits()), profile.getUnits()));
|
tempTargetView.setText(Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, units), units));
|
||||||
else
|
else
|
||||||
tempTargetView.setText(Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, profile.getUnits()), profile.getUnits()) + " - " + Profile.toUnitsString(tempTarget.high, Profile.fromMgdlToUnits(tempTarget.high, profile.getUnits()), profile.getUnits()));
|
tempTargetView.setText(Profile.toUnitsString(tempTarget.low, Profile.fromMgdlToUnits(tempTarget.low, units), units) + " - " + Profile.toUnitsString(tempTarget.high, Profile.fromMgdlToUnits(tempTarget.high, units), units));
|
||||||
} else {
|
} else {
|
||||||
Double maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
|
Double maxBgDefault = Constants.MAX_BG_DEFAULT_MGDL;
|
||||||
Double minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
|
Double minBgDefault = Constants.MIN_BG_DEFAULT_MGDL;
|
||||||
if (!profile.getUnits().equals(Constants.MGDL)) {
|
if (!units.equals(Constants.MGDL)) {
|
||||||
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
|
maxBgDefault = Constants.MAX_BG_DEFAULT_MMOL;
|
||||||
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
|
minBgDefault = Constants.MIN_BG_DEFAULT_MMOL;
|
||||||
}
|
}
|
||||||
|
@ -1062,7 +1063,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
quickWizardButton.setVisibility(View.VISIBLE);
|
quickWizardButton.setVisibility(View.VISIBLE);
|
||||||
String text = quickWizardEntry.buttonText() + "\n" + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
|
String text = quickWizardEntry.buttonText() + "\n" + DecimalFormatter.to0Decimal(quickWizardEntry.carbs()) + "g";
|
||||||
BolusWizard wizard = new BolusWizard();
|
BolusWizard wizard = new BolusWizard();
|
||||||
wizard.doCalc(profile, quickWizardEntry.carbs(), 0d, lastBG.valueToUnits(profile.getUnits()), 0d, true, true, false, false);
|
wizard.doCalc(profile, quickWizardEntry.carbs(), 0d, lastBG.valueToUnits(units), 0d, true, true, false, false);
|
||||||
text += " " + DecimalFormatter.to2Decimal(wizard.calculatedTotalInsulin) + "U";
|
text += " " + DecimalFormatter.to2Decimal(wizard.calculatedTotalInsulin) + "U";
|
||||||
quickWizardButton.setText(text);
|
quickWizardButton.setText(text);
|
||||||
if (wizard.calculatedTotalInsulin <= 0)
|
if (wizard.calculatedTotalInsulin <= 0)
|
||||||
|
@ -1079,8 +1080,6 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
treatmentButton.setVisibility(View.GONE);
|
treatmentButton.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
String units = profile.getUnits();
|
|
||||||
|
|
||||||
Double lowLine = SP.getDouble("low_mark", 0d);
|
Double lowLine = SP.getDouble("low_mark", 0d);
|
||||||
Double highLine = SP.getDouble("high_mark", 0d);
|
Double highLine = SP.getDouble("high_mark", 0d);
|
||||||
if (lowLine < 1) {
|
if (lowLine < 1) {
|
||||||
|
@ -1097,7 +1096,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
color = MainApp.sResources.getColor(R.color.low);
|
color = MainApp.sResources.getColor(R.color.low);
|
||||||
else if (lastBG.valueToUnits(units) > highLine)
|
else if (lastBG.valueToUnits(units) > highLine)
|
||||||
color = MainApp.sResources.getColor(R.color.high);
|
color = MainApp.sResources.getColor(R.color.high);
|
||||||
bgView.setText(lastBG.valueToUnitsToString(profile.getUnits()));
|
bgView.setText(lastBG.valueToUnitsToString(units));
|
||||||
arrowView.setText(lastBG.directionToSymbol());
|
arrowView.setText(lastBG.directionToSymbol());
|
||||||
bgView.setTextColor(color);
|
bgView.setTextColor(color);
|
||||||
arrowView.setTextColor(color);
|
arrowView.setTextColor(color);
|
||||||
|
@ -1156,7 +1155,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
}
|
}
|
||||||
|
|
||||||
// ****** GRAPH *******
|
// ****** GRAPH *******
|
||||||
//log.debug("updateGUI checkpoint 1");
|
log.debug("updateGUI checkpoint 1");
|
||||||
|
|
||||||
// allign to hours
|
// allign to hours
|
||||||
Calendar calendar = Calendar.getInstance();
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
@ -1287,7 +1286,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
absoluteBasalsLineSeries.setCustomPaint(absolutePaint);
|
absoluteBasalsLineSeries.setCustomPaint(absolutePaint);
|
||||||
}
|
}
|
||||||
|
|
||||||
//log.debug("updateGUI checkpoint 2");
|
log.debug("updateGUI checkpoint 2");
|
||||||
|
|
||||||
// **** IOB COB DEV graph ****
|
// **** IOB COB DEV graph ****
|
||||||
class DeviationDataPoint extends DataPoint {
|
class DeviationDataPoint extends DataPoint {
|
||||||
|
@ -1405,12 +1404,12 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
} else {
|
} else {
|
||||||
iobGraph.setVisibility(View.GONE);
|
iobGraph.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
//log.debug("updateGUI checkpoint 3");
|
log.debug("updateGUI checkpoint 3");
|
||||||
|
|
||||||
// remove old data from graph
|
// remove old data from graph
|
||||||
bgGraph.getSecondScale().getSeries().clear();
|
bgGraph.getSecondScale().getSeries().clear();
|
||||||
bgGraph.getSeries().clear();
|
bgGraph.getSeries().clear();
|
||||||
//log.debug("updateGUI checkpoint 4");
|
log.debug("updateGUI checkpoint 4");
|
||||||
|
|
||||||
// **** Area ****
|
// **** Area ****
|
||||||
DoubleDataPoint[] areaDataPoints = new DoubleDataPoint[]{
|
DoubleDataPoint[] areaDataPoints = new DoubleDataPoint[]{
|
||||||
|
@ -1586,11 +1585,11 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
||||||
|
|
||||||
public double getNearestBg(long date, List<BgReading> bgReadingsArray) {
|
public double getNearestBg(long date, List<BgReading> bgReadingsArray) {
|
||||||
double bg = 0;
|
double bg = 0;
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||||
for (int r = bgReadingsArray.size() - 1; r >= 0; r--) {
|
for (int r = bgReadingsArray.size() - 1; r >= 0; r--) {
|
||||||
BgReading reading = bgReadingsArray.get(r);
|
BgReading reading = bgReadingsArray.get(r);
|
||||||
if (reading.date > date) continue;
|
if (reading.date > date) continue;
|
||||||
bg = Profile.fromMgdlToUnits(reading.value, profile.getUnits());
|
bg = Profile.fromMgdlToUnits(reading.value, units);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return bg;
|
return bg;
|
||||||
|
|
|
@ -118,17 +118,17 @@ public class PersistentNotificationPlugin implements PluginBase {
|
||||||
|
|
||||||
|
|
||||||
String line1 = ctx.getString(R.string.noprofile);
|
String line1 = ctx.getString(R.string.noprofile);
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||||
|
|
||||||
|
|
||||||
BgReading lastBG = DatabaseHelper.lastBg();
|
BgReading lastBG = DatabaseHelper.lastBg();
|
||||||
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
GlucoseStatus glucoseStatus = GlucoseStatus.getGlucoseStatusData();
|
||||||
|
|
||||||
if (profile != null && lastBG != null) {
|
if (lastBG != null) {
|
||||||
line1 = lastBG.valueToUnitsToString(profile.getUnits());
|
line1 = lastBG.valueToUnitsToString(units);
|
||||||
if (glucoseStatus != null) {
|
if (glucoseStatus != null) {
|
||||||
line1 += " Δ" + deltastring(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, profile.getUnits())
|
line1 += " Δ" + deltastring(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units)
|
||||||
+ " avgΔ" + deltastring(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, profile.getUnits());
|
+ " avgΔ" + deltastring(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, units);
|
||||||
} else {
|
} else {
|
||||||
line1 += " " +
|
line1 += " " +
|
||||||
ctx.getString(R.string.old_data) +
|
ctx.getString(R.string.old_data) +
|
||||||
|
|
|
@ -213,6 +213,11 @@ public class CircadianPercentageProfilePlugin implements PluginBase, ProfileInte
|
||||||
return convertedProfile;
|
return convertedProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUnits() {
|
||||||
|
return mgdl ? Constants.MGDL : Constants.MMOL;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getProfileName() {
|
public String getProfileName() {
|
||||||
performLimitCheck();
|
performLimitCheck();
|
||||||
|
|
|
@ -240,6 +240,11 @@ public class LocalProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
return convertedProfile;
|
return convertedProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUnits() {
|
||||||
|
return mgdl ? Constants.MGDL : Constants.MMOL;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getProfileName() {
|
public String getProfileName() {
|
||||||
return convertedProfileName;
|
return convertedProfileName;
|
||||||
|
|
|
@ -153,6 +153,11 @@ public class NSProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUnits() {
|
||||||
|
return profile.getUnits();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getProfileName() {
|
public String getProfileName() {
|
||||||
return profile.getDefaultProfileName();
|
return profile.getDefaultProfileName();
|
||||||
|
|
|
@ -201,6 +201,11 @@ public class SimpleProfilePlugin implements PluginBase, ProfileInterface {
|
||||||
return convertedProfile;
|
return convertedProfile;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUnits() {
|
||||||
|
return mgdl ? Constants.MGDL : Constants.MMOL;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getProfileName() {
|
public String getProfileName() {
|
||||||
return "SimpleProfile";
|
return "SimpleProfile";
|
||||||
|
|
|
@ -798,6 +798,11 @@ public class DanaRPlugin implements PluginBase, PumpInterface, DanaRInterface, C
|
||||||
return pump.createConvertedProfile();
|
return pump.createConvertedProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUnits() {
|
||||||
|
return pump.getUnits();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getProfileName() {
|
public String getProfileName() {
|
||||||
return pump.createConvertedProfileName();
|
return pump.createConvertedProfileName();
|
||||||
|
|
|
@ -132,6 +132,10 @@ public class DanaRPump {
|
||||||
public double maxBolus;
|
public double maxBolus;
|
||||||
public double maxBasal;
|
public double maxBasal;
|
||||||
|
|
||||||
|
public String getUnits() {
|
||||||
|
return units == UNITS_MGDL ? Constants.MGDL : Constants.MMOL;
|
||||||
|
}
|
||||||
|
|
||||||
public ProfileStore createConvertedProfile() {
|
public ProfileStore createConvertedProfile() {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
JSONObject store = new JSONObject();
|
JSONObject store = new JSONObject();
|
||||||
|
|
|
@ -46,12 +46,6 @@ public class DanaRNSHistorySync {
|
||||||
|
|
||||||
public void sync(int what) {
|
public void sync(int what) {
|
||||||
try {
|
try {
|
||||||
ConfigBuilderPlugin ConfigBuilderPlugin = MainApp.getConfigBuilder();
|
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
|
||||||
if (profile == null) {
|
|
||||||
ToastUtils.showToastInUiThread(MainApp.instance().getApplicationContext(), MainApp.sResources.getString(R.string.noprofile));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Calendar cal = Calendar.getInstance();
|
Calendar cal = Calendar.getInstance();
|
||||||
long records = historyRecords.size();
|
long records = historyRecords.size();
|
||||||
long processing = 0;
|
long processing = 0;
|
||||||
|
@ -179,7 +173,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, profile.getUnits()));
|
nsrec.put("glucose", Profile.fromMgdlToUnits(record.recordValue, MainApp.getConfigBuilder().getProfileUnits()));
|
||||||
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.sResources.getString(R.string.app_name));
|
nsrec.put("enteredBy", "openaps://" + MainApp.sResources.getString(R.string.app_name));
|
||||||
|
|
|
@ -802,6 +802,11 @@ public class DanaRKoreanPlugin implements PluginBase, PumpInterface, DanaRInterf
|
||||||
return pump.createConvertedProfile();
|
return pump.createConvertedProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUnits() {
|
||||||
|
return pump.getUnits();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getProfileName() {
|
public String getProfileName() {
|
||||||
return pump.createConvertedProfileName();
|
return pump.createConvertedProfileName();
|
||||||
|
|
|
@ -715,6 +715,11 @@ public class DanaRv2Plugin implements PluginBase, PumpInterface, DanaRInterface,
|
||||||
return pump.createConvertedProfile();
|
return pump.createConvertedProfile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUnits() {
|
||||||
|
return pump.getUnits();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getProfileName() {
|
public String getProfileName() {
|
||||||
return pump.createConvertedProfileName();
|
return pump.createConvertedProfileName();
|
||||||
|
|
|
@ -28,6 +28,7 @@ import info.nightscout.androidaps.plugins.Overview.events.EventOverviewBolusProg
|
||||||
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
|
import info.nightscout.androidaps.plugins.PumpVirtual.events.EventVirtualPumpUpdateGui;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.NSUpload;
|
import info.nightscout.utils.NSUpload;
|
||||||
|
import info.nightscout.utils.SP;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mike on 05.08.2016.
|
* Created by mike on 05.08.2016.
|
||||||
|
@ -45,12 +46,26 @@ public class VirtualPumpPlugin implements PluginBase, PumpInterface {
|
||||||
boolean fragmentEnabled = true;
|
boolean fragmentEnabled = true;
|
||||||
boolean fragmentVisible = true;
|
boolean fragmentVisible = true;
|
||||||
|
|
||||||
public static boolean fromNSAreCommingFakedExtendedBoluses = false;
|
private static boolean fromNSAreCommingFakedExtendedBoluses = false;
|
||||||
|
|
||||||
PumpDescription pumpDescription = new PumpDescription();
|
PumpDescription pumpDescription = new PumpDescription();
|
||||||
|
|
||||||
|
static void loadFakingStatus() {
|
||||||
|
fromNSAreCommingFakedExtendedBoluses = SP.getBoolean("fromNSAreCommingFakedExtendedBoluses", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setFakingStatus(boolean newStatus) {
|
||||||
|
fromNSAreCommingFakedExtendedBoluses = newStatus;
|
||||||
|
SP.putBoolean("fromNSAreCommingFakedExtendedBoluses", fromNSAreCommingFakedExtendedBoluses);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getFakingStatus() {
|
||||||
|
return fromNSAreCommingFakedExtendedBoluses;
|
||||||
|
}
|
||||||
|
|
||||||
static VirtualPumpPlugin instance = null;
|
static VirtualPumpPlugin instance = null;
|
||||||
public static VirtualPumpPlugin getInstance() {
|
public static VirtualPumpPlugin getInstance() {
|
||||||
|
loadFakingStatus();
|
||||||
if (instance == null)
|
if (instance == null)
|
||||||
instance = new VirtualPumpPlugin();
|
instance = new VirtualPumpPlugin();
|
||||||
return instance;
|
return instance;
|
||||||
|
|
|
@ -238,8 +238,7 @@ public class SmsCommunicatorPlugin implements PluginBase {
|
||||||
BgReading actualBG = DatabaseHelper.actualBg();
|
BgReading actualBG = DatabaseHelper.actualBg();
|
||||||
BgReading lastBG = DatabaseHelper.lastBg();
|
BgReading lastBG = DatabaseHelper.lastBg();
|
||||||
|
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||||
String units = profile.getUnits();
|
|
||||||
|
|
||||||
if (actualBG != null) {
|
if (actualBG != null) {
|
||||||
reply = MainApp.sResources.getString(R.string.sms_actualbg) + " " + actualBG.valueToUnitsToString(units) + ", ";
|
reply = MainApp.sResources.getString(R.string.sms_actualbg) + " " + actualBG.valueToUnitsToString(units) + ", ";
|
||||||
|
|
|
@ -62,16 +62,15 @@ public class TreatmentsTempTargetFragment extends Fragment implements View.OnCli
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onBindViewHolder(TempTargetsViewHolder holder, int position) {
|
public void onBindViewHolder(TempTargetsViewHolder holder, int position) {
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||||
if (profile == null) return;
|
|
||||||
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(tempTarget._id != null ? View.VISIBLE : View.GONE);
|
holder.ns.setVisibility(tempTarget._id != null ? View.VISIBLE : View.GONE);
|
||||||
if (!tempTarget.isEndingEvent()) {
|
if (!tempTarget.isEndingEvent()) {
|
||||||
holder.date.setText(DateUtil.dateAndTimeString(tempTarget.date) + " - " + DateUtil.timeString(tempTarget.originalEnd()));
|
holder.date.setText(DateUtil.dateAndTimeString(tempTarget.date) + " - " + DateUtil.timeString(tempTarget.originalEnd()));
|
||||||
holder.duration.setText(DecimalFormatter.to0Decimal(tempTarget.durationInMinutes) + " min");
|
holder.duration.setText(DecimalFormatter.to0Decimal(tempTarget.durationInMinutes) + " min");
|
||||||
holder.low.setText(tempTarget.lowValueToUnitsToString(profile.getUnits()));
|
holder.low.setText(tempTarget.lowValueToUnitsToString(units));
|
||||||
holder.high.setText(tempTarget.highValueToUnitsToString(profile.getUnits()));
|
holder.high.setText(tempTarget.highValueToUnitsToString(units));
|
||||||
holder.reason.setText(tempTarget.reason);
|
holder.reason.setText(tempTarget.reason);
|
||||||
} else {
|
} else {
|
||||||
holder.date.setText(DateUtil.dateAndTimeString(tempTarget.date));
|
holder.date.setText(DateUtil.dateAndTimeString(tempTarget.date));
|
||||||
|
|
|
@ -209,14 +209,13 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
}
|
}
|
||||||
|
|
||||||
private DataMap dataMapSingleBG(BgReading lastBG, GlucoseStatus glucoseStatus) {
|
private DataMap dataMapSingleBG(BgReading lastBG, GlucoseStatus glucoseStatus) {
|
||||||
Profile profile = MainApp.getConfigBuilder().getProfile();
|
String units = MainApp.getConfigBuilder().getProfileUnits();
|
||||||
if (profile == null) return null;
|
|
||||||
|
|
||||||
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"));
|
||||||
|
|
||||||
//convert to mg/dl
|
//convert to mg/dl
|
||||||
if (!profile.getUnits().equals(Constants.MGDL)) {
|
if (!units.equals(Constants.MGDL)) {
|
||||||
lowLine *= Constants.MMOLL_TO_MGDL;
|
lowLine *= Constants.MMOLL_TO_MGDL;
|
||||||
highLine *= Constants.MMOLL_TO_MGDL;
|
highLine *= Constants.MMOLL_TO_MGDL;
|
||||||
|
|
||||||
|
@ -239,7 +238,7 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
DataMap dataMap = new DataMap();
|
DataMap dataMap = new DataMap();
|
||||||
|
|
||||||
int battery = getBatteryLevel(getApplicationContext());
|
int battery = getBatteryLevel(getApplicationContext());
|
||||||
dataMap.putString("sgvString", lastBG.valueToUnitsToString(profile.getUnits()));
|
dataMap.putString("sgvString", lastBG.valueToUnitsToString(units));
|
||||||
dataMap.putDouble("timestamp", lastBG.date);
|
dataMap.putDouble("timestamp", lastBG.date);
|
||||||
if (glucoseStatus == null) {
|
if (glucoseStatus == null) {
|
||||||
dataMap.putString("slopeArrow", "");
|
dataMap.putString("slopeArrow", "");
|
||||||
|
@ -247,8 +246,8 @@ public class WatchUpdaterService extends WearableListenerService implements
|
||||||
dataMap.putString("avgDelta", "");
|
dataMap.putString("avgDelta", "");
|
||||||
} else {
|
} else {
|
||||||
dataMap.putString("slopeArrow", slopeArrow(glucoseStatus.delta));
|
dataMap.putString("slopeArrow", slopeArrow(glucoseStatus.delta));
|
||||||
dataMap.putString("delta", deltastring(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, profile.getUnits()));
|
dataMap.putString("delta", deltastring(glucoseStatus.delta, glucoseStatus.delta * Constants.MGDL_TO_MMOLL, units));
|
||||||
dataMap.putString("avgDelta", deltastring(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, profile.getUnits()));
|
dataMap.putString("avgDelta", deltastring(glucoseStatus.avgdelta, glucoseStatus.avgdelta * Constants.MGDL_TO_MMOLL, units));
|
||||||
}
|
}
|
||||||
dataMap.putString("battery", "" + battery);
|
dataMap.putString("battery", "" + battery);
|
||||||
dataMap.putLong("sgvLevel", sgvLevel);
|
dataMap.putLong("sgvLevel", sgvLevel);
|
||||||
|
|
|
@ -44,12 +44,10 @@ public class XdripCalibrations {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean sendIntent(Double bg) {
|
public static boolean sendIntent(Double bg) {
|
||||||
final Profile profile = MainApp.getConfigBuilder().getProfile();
|
|
||||||
|
|
||||||
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", profile.getUnits().equals(Constants.MGDL) ? "mgdl" : "mmol");
|
bundle.putString("units", MainApp.getConfigBuilder().getProfileUnits().equals(Constants.MGDL) ? "mgdl" : "mmol");
|
||||||
bundle.putLong("timestamp", new Date().getTime());
|
bundle.putLong("timestamp", new Date().getTime());
|
||||||
Intent intent = new Intent(Intents.ACTION_REMOTE_CALIBRATION);
|
Intent intent = new Intent(Intents.ACTION_REMOTE_CALIBRATION);
|
||||||
intent.putExtras(bundle);
|
intent.putExtras(bundle);
|
||||||
|
|
Loading…
Reference in a new issue