Merge pull request #1290 from MarkMpn/temp-basal-rate

Autotune compatibility change
This commit is contained in:
Milos Kozak 2018-08-02 13:50:00 +02:00 committed by GitHub
commit 76625e2a70
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -57,6 +57,7 @@ public class NSUpload {
data.put("eventType", CareportalEvent.TEMPBASAL); data.put("eventType", CareportalEvent.TEMPBASAL);
data.put("duration", temporaryBasal.durationInMinutes); data.put("duration", temporaryBasal.durationInMinutes);
data.put("absolute", temporaryBasal.absoluteRate); data.put("absolute", temporaryBasal.absoluteRate);
data.put("rate", temporaryBasal.absoluteRate);
if (temporaryBasal.pumpId != 0) if (temporaryBasal.pumpId != 0)
data.put("pumpId", temporaryBasal.pumpId); data.put("pumpId", temporaryBasal.pumpId);
data.put("created_at", DateUtil.toISOString(temporaryBasal.date)); data.put("created_at", DateUtil.toISOString(temporaryBasal.date));
@ -81,12 +82,16 @@ public class NSUpload {
try { try {
SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext()); SharedPreferences SP = PreferenceManager.getDefaultSharedPreferences(MainApp.instance().getApplicationContext());
boolean useAbsolute = SP.getBoolean("ns_sync_use_absolute", false); boolean useAbsolute = SP.getBoolean("ns_sync_use_absolute", false);
Profile profile = ProfileFunctions.getInstance().getProfile(temporaryBasal.date);
double absoluteRate = 0;
if (profile != null) {
absoluteRate = profile.getBasal(temporaryBasal.date) * temporaryBasal.percentRate / 100d;
}
if (useAbsolute) { if (useAbsolute) {
TemporaryBasal t = temporaryBasal.clone(); TemporaryBasal t = temporaryBasal.clone();
t.isAbsolute = true; t.isAbsolute = true;
Profile profile = ProfileFunctions.getInstance().getProfile();
if (profile != null) { if (profile != null) {
t.absoluteRate = profile.getBasal(temporaryBasal.date) * temporaryBasal.percentRate / 100d; t.absoluteRate = absoluteRate;
uploadTempBasalStartAbsolute(t, null); uploadTempBasalStartAbsolute(t, null);
} }
} else { } else {
@ -95,6 +100,8 @@ public class NSUpload {
data.put("eventType", CareportalEvent.TEMPBASAL); data.put("eventType", CareportalEvent.TEMPBASAL);
data.put("duration", temporaryBasal.durationInMinutes); data.put("duration", temporaryBasal.durationInMinutes);
data.put("percent", temporaryBasal.percentRate - 100); data.put("percent", temporaryBasal.percentRate - 100);
if (profile != null)
data.put("rate", absoluteRate);
if (temporaryBasal.pumpId != 0) if (temporaryBasal.pumpId != 0)
data.put("pumpId", temporaryBasal.pumpId); data.put("pumpId", temporaryBasal.pumpId);
data.put("created_at", DateUtil.toISOString(temporaryBasal.date)); data.put("created_at", DateUtil.toISOString(temporaryBasal.date));