RS,Rv2: load only recent history

This commit is contained in:
Milos Kozak 2018-07-18 17:02:28 +02:00
parent e6baf3ff47
commit dd687fbb40
2 changed files with 5 additions and 5 deletions

View file

@ -240,7 +240,7 @@ public class DanaRSService extends Service {
SystemClock.sleep(100);
}
if (DanaRS_Packet_APS_History_Events.lastEventTimeLoaded != 0)
lastHistoryFetched = DanaRS_Packet_APS_History_Events.lastEventTimeLoaded - 45 * 60 * 1000L; // always load last 45 min
lastHistoryFetched = DanaRS_Packet_APS_History_Events.lastEventTimeLoaded - T.mins(1).msecs();
else
lastHistoryFetched = 0;
log.debug("Events loaded");
@ -272,7 +272,7 @@ public class DanaRSService extends Service {
// bleComm.sendMessage(msg);
DanaRS_Packet_APS_Set_Event_History msgSetHistoryEntry_v2 = new DanaRS_Packet_APS_Set_Event_History(DanaRPump.CARBS, carbtime, carbs, 0);
bleComm.sendMessage(msgSetHistoryEntry_v2);
lastHistoryFetched = carbtime - 60000;
lastHistoryFetched = Math.min(lastHistoryFetched, carbtime - T.mins(1).msecs());
}
final long bolusStart = System.currentTimeMillis();

View file

@ -371,7 +371,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
mSerialIOThread.sendMessage(msg);
MsgSetHistoryEntry_v2 msgSetHistoryEntry_v2 = new MsgSetHistoryEntry_v2(DanaRPump.CARBS, carbtime, carbs, 0);
mSerialIOThread.sendMessage(msgSetHistoryEntry_v2);
lastHistoryFetched = carbtime - 60000;
lastHistoryFetched = Math.min(lastHistoryFetched, carbtime - T.mins(1).msecs());
}
final long bolusStart = System.currentTimeMillis();
@ -455,7 +455,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
mSerialIOThread.sendMessage(msg);
MsgSetHistoryEntry_v2 msgSetHistoryEntry_v2 = new MsgSetHistoryEntry_v2(DanaRPump.CARBS, time, amount, 0);
mSerialIOThread.sendMessage(msgSetHistoryEntry_v2);
lastHistoryFetched = time - 1;
lastHistoryFetched = Math.min(lastHistoryFetched, time - T.mins(1).msecs());
return true;
}
@ -485,7 +485,7 @@ public class DanaRv2ExecutionService extends AbstractDanaRExecutionService {
}
SystemClock.sleep(200);
if (MsgHistoryEvents_v2.lastEventTimeLoaded != 0)
lastHistoryFetched = MsgHistoryEvents_v2.lastEventTimeLoaded - 45 * 60 * 1000L; //always load last 45 min;
lastHistoryFetched = MsgHistoryEvents_v2.lastEventTimeLoaded - T.mins(1).msecs();
else
lastHistoryFetched = 0;
mDanaRPump.lastConnection = System.currentTimeMillis();