set pump time only if needed
This commit is contained in:
parent
e1d2c557af
commit
e005a6172b
5 changed files with 30 additions and 8 deletions
|
@ -13,9 +13,11 @@ import info.nightscout.androidaps.Config;
|
||||||
|
|
||||||
public class MsgSetTime extends MessageBase {
|
public class MsgSetTime extends MessageBase {
|
||||||
private static Logger log = LoggerFactory.getLogger(MsgSetTime.class);
|
private static Logger log = LoggerFactory.getLogger(MsgSetTime.class);
|
||||||
|
private static Date time;
|
||||||
|
|
||||||
public MsgSetTime(Date time) {
|
public MsgSetTime(Date time) {
|
||||||
SetCommand(0x330a);
|
SetCommand(0x330a);
|
||||||
|
this.time = time;
|
||||||
AddParamDateTime(time);
|
AddParamDateTime(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,6 +25,6 @@ public class MsgSetTime extends MessageBase {
|
||||||
int result = intFromBuff(bytes, 0, 1);
|
int result = intFromBuff(bytes, 0, 1);
|
||||||
|
|
||||||
if (Config.logDanaMessageDetail)
|
if (Config.logDanaMessageDetail)
|
||||||
log.debug("Result: " + result);
|
log.debug("Result of setting time: " + time + " is " + result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ public class MsgSettingPumpTime extends MessageBase {
|
||||||
);
|
);
|
||||||
|
|
||||||
if (Config.logDanaMessageDetail)
|
if (Config.logDanaMessageDetail)
|
||||||
log.debug("Pump time: " + time);
|
log.debug("Pump time: " + time + " Phone time: " + new Date());
|
||||||
|
|
||||||
DanaRPump.getInstance().pumpTime = time;
|
DanaRPump.getInstance().pumpTime = time;
|
||||||
}
|
}
|
||||||
|
|
|
@ -326,11 +326,18 @@ public class DanaRExecutionService extends Service {
|
||||||
//0x3201
|
//0x3201
|
||||||
mSerialIOThread.sendMessage(new MsgSettingMaxValues());
|
mSerialIOThread.sendMessage(new MsgSettingMaxValues());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingGlucose());
|
mSerialIOThread.sendMessage(new MsgSettingGlucose());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
|
||||||
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
|
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll());
|
mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll());
|
||||||
|
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||||
|
long timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||||
|
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||||
|
if (Math.abs(timeDiff) > 10) {
|
||||||
mSerialIOThread.sendMessage(new MsgSetTime(new Date()));
|
mSerialIOThread.sendMessage(new MsgSetTime(new Date()));
|
||||||
|
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||||
|
timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||||
|
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||||
|
}
|
||||||
danaRPump.lastSettingsRead = now;
|
danaRPump.lastSettingsRead = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -322,9 +322,15 @@ public class DanaRKoreanExecutionService extends Service {
|
||||||
//0x3201
|
//0x3201
|
||||||
mSerialIOThread.sendMessage(new MsgSettingMaxValues());
|
mSerialIOThread.sendMessage(new MsgSettingMaxValues());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingGlucose());
|
mSerialIOThread.sendMessage(new MsgSettingGlucose());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
|
||||||
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
||||||
|
long timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||||
|
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||||
|
if (Math.abs(timeDiff) > 10) {
|
||||||
mSerialIOThread.sendMessage(new MsgSetTime(new Date()));
|
mSerialIOThread.sendMessage(new MsgSetTime(new Date()));
|
||||||
|
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||||
|
timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||||
|
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||||
|
}
|
||||||
danaRPump.lastSettingsRead = now;
|
danaRPump.lastSettingsRead = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -297,11 +297,18 @@ public class DanaRv2ExecutionService extends Service {
|
||||||
//0x3201
|
//0x3201
|
||||||
mSerialIOThread.sendMessage(new MsgSettingMaxValues());
|
mSerialIOThread.sendMessage(new MsgSettingMaxValues());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingGlucose());
|
mSerialIOThread.sendMessage(new MsgSettingGlucose());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
|
||||||
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
|
mSerialIOThread.sendMessage(new MsgSettingActiveProfile());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
mSerialIOThread.sendMessage(new MsgSettingProfileRatios());
|
||||||
mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll());
|
mSerialIOThread.sendMessage(new MsgSettingProfileRatiosAll());
|
||||||
|
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||||
|
long timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||||
|
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||||
|
if (Math.abs(timeDiff) > 10) {
|
||||||
mSerialIOThread.sendMessage(new MsgSetTime(new Date()));
|
mSerialIOThread.sendMessage(new MsgSetTime(new Date()));
|
||||||
|
mSerialIOThread.sendMessage(new MsgSettingPumpTime());
|
||||||
|
timeDiff = (danaRPump.pumpTime.getTime() - System.currentTimeMillis()) / 1000L;
|
||||||
|
log.debug("Pump time difference: " + timeDiff + " seconds");
|
||||||
|
}
|
||||||
danaRPump.lastSettingsRead = now;
|
danaRPump.lastSettingsRead = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue