Merge remote-tracking branch 'origin/dev' into combo-scripter-v2

* origin/dev:
  missing return
  log profiles if different
  fix setting of TRB when low basal rate is running
  fix format and add test for fromISODateString
  use mills from status if available
This commit is contained in:
Johannes Mockenhaupt 2017-11-21 10:57:11 +01:00
commit bf52352224
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
4 changed files with 39 additions and 7 deletions

View file

@ -409,9 +409,14 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
@Override
public boolean isThisProfileSet(Profile profile) {
if (activePump != null)
return activePump.isThisProfileSet(profile);
else return true;
if (activePump != null) {
boolean result = activePump.isThisProfileSet(profile);
if (result == false) {
log.debug("Current profile: " + getProfile().getData().toString());
log.debug("New profile: " + profile.getData().toString());
}
return result;
} else return true;
}
@Override
@ -564,7 +569,7 @@ public class ConfigBuilderPlugin implements PluginBase, PumpInterface, Constrain
if (Config.logCongigBuilderActions)
log.debug("applyAPSRequest: " + request.toString());
if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - getBaseBasalRate()) < 0.05) {
if ((request.rate == 0 && request.duration == 0) || Math.abs(request.rate - getBaseBasalRate()) < getPumpDescription().basalStep) {
if (isTempBasalInProgress()) {
if (Config.logCongigBuilderActions)
log.debug("applyAPSRequest: cancelTempBasal()");

View file

@ -336,7 +336,9 @@ public class NSDeviceStatus {
try {
long clock = 0L;
if (object.has("created_at"))
if (object.has("mills"))
clock = object.getLong("mills");
else if (object.has("created_at"))
clock = DateUtil.fromISODateString(object.getString("created_at")).getTime();
String device = getDevice();
Integer battery = null;

View file

@ -27,8 +27,8 @@ public class DateUtil {
/**
* The date format in iso.
*/
private static String FORMAT_DATE_ISO = "yyyy-MM-dd'T'HH:mm:ss'Z'";
private static String FORMAT_DATE_ISO_MSEC = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'";
private static String FORMAT_DATE_ISO = "yyyy-MM-dd'T'HH:mm:ssZ";
private static String FORMAT_DATE_ISO_MSEC = "yyyy-MM-dd'T'HH:mm:ss.SSSZ";
/**
* Takes in an ISO date string of the following format:

View file

@ -0,0 +1,25 @@
package info.nightscout.utils;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Created by mike on 20.11.2017.
*/
public class DateUtilTest {
public DateUtilTest() {
super();
}
@Test
public void fromISODateStringTest() throws Exception {
assertEquals( 1511124634417L, DateUtil.fromISODateString("2017-11-19T22:50:34.417+0200").getTime());
assertEquals( 1511124634000L, DateUtil.fromISODateString("2017-11-19T22:50:34+0200").getTime());
}
}