check for future timestamp while loading history (RS,Rv2)
This commit is contained in:
parent
512ceceeb8
commit
05dcb58f0a
3 changed files with 31 additions and 24 deletions
|
@ -45,6 +45,12 @@ public class DanaRS_Packet_APS_History_Events extends DanaRS_Packet {
|
||||||
public DanaRS_Packet_APS_History_Events(long from) {
|
public DanaRS_Packet_APS_History_Events(long from) {
|
||||||
this();
|
this();
|
||||||
GregorianCalendar cal = new GregorianCalendar();
|
GregorianCalendar cal = new GregorianCalendar();
|
||||||
|
|
||||||
|
if (from > DateUtil.now()) {
|
||||||
|
log.debug("Asked to load from the future");
|
||||||
|
from = 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (from != 0)
|
if (from != 0)
|
||||||
cal.setTimeInMillis(from);
|
cal.setTimeInMillis(from);
|
||||||
else
|
else
|
||||||
|
|
|
@ -26,23 +26,30 @@ public class MsgHistoryEvents_v2 extends MessageBase {
|
||||||
|
|
||||||
public static long lastEventTimeLoaded = 0;
|
public static long lastEventTimeLoaded = 0;
|
||||||
|
|
||||||
public MsgHistoryEvents_v2(long from) {
|
public MsgHistoryEvents_v2() {
|
||||||
SetCommand(0xE003);
|
this(0);
|
||||||
GregorianCalendar gfrom = new GregorianCalendar();
|
|
||||||
gfrom.setTimeInMillis(from);
|
|
||||||
AddParamDate(gfrom);
|
|
||||||
done = false;
|
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
|
||||||
log.debug("New message");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public MsgHistoryEvents_v2() {
|
public MsgHistoryEvents_v2(long from) {
|
||||||
SetCommand(0xE003);
|
SetCommand(0xE003);
|
||||||
AddParamByte((byte) 0);
|
|
||||||
AddParamByte((byte) 1);
|
if (from > DateUtil.now()) {
|
||||||
AddParamByte((byte) 1);
|
log.debug("Asked to load from the future");
|
||||||
AddParamByte((byte) 0);
|
from = 0;
|
||||||
AddParamByte((byte) 0);
|
}
|
||||||
|
|
||||||
|
if (from == 0) {
|
||||||
|
AddParamByte((byte) 0);
|
||||||
|
AddParamByte((byte) 1);
|
||||||
|
AddParamByte((byte) 1);
|
||||||
|
AddParamByte((byte) 0);
|
||||||
|
AddParamByte((byte) 0);
|
||||||
|
} else {
|
||||||
|
GregorianCalendar gfrom = new GregorianCalendar();
|
||||||
|
gfrom.setTimeInMillis(from);
|
||||||
|
AddParamDate(gfrom);
|
||||||
|
}
|
||||||
|
|
||||||
done = false;
|
done = false;
|
||||||
if (L.isEnabled(L.PUMPCOMM))
|
if (L.isEnabled(L.PUMPCOMM))
|
||||||
log.debug("New message");
|
log.debug("New message");
|
||||||
|
|
|
@ -465,16 +465,10 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
|
||||||
if (!isConnected())
|
if (!isConnected())
|
||||||
return new PumpEnactResult().success(false);
|
return new PumpEnactResult().success(false);
|
||||||
SystemClock.sleep(300);
|
SystemClock.sleep(300);
|
||||||
MsgHistoryEvents_v2 msg;
|
MsgHistoryEvents_v2 msg = new MsgHistoryEvents_v2(lastHistoryFetched);
|
||||||
if (lastHistoryFetched == 0) {
|
if (L.isEnabled(L.PUMP))
|
||||||
msg = new MsgHistoryEvents_v2();
|
log.debug("Loading event history from: " + DateUtil.dateAndTimeFullString(lastHistoryFetched));
|
||||||
if (L.isEnabled(L.PUMP))
|
|
||||||
log.debug("Loading complete event history");
|
|
||||||
} else {
|
|
||||||
msg = new MsgHistoryEvents_v2(lastHistoryFetched);
|
|
||||||
if (L.isEnabled(L.PUMP))
|
|
||||||
log.debug("Loading event history from: " + DateUtil.dateAndTimeFullString(lastHistoryFetched));
|
|
||||||
}
|
|
||||||
mSerialIOThread.sendMessage(msg);
|
mSerialIOThread.sendMessage(msg);
|
||||||
while (!msg.done && mRfcommSocket.isConnected()) {
|
while (!msg.done && mRfcommSocket.isConnected()) {
|
||||||
SystemClock.sleep(100);
|
SystemClock.sleep(100);
|
||||||
|
|
Loading…
Reference in a new issue