Disable reading history while incomplete.

This commit is contained in:
Johannes Mockenhaupt 2017-10-30 16:20:43 +01:00
parent 550ed57ca5
commit bffd1239c0
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1
2 changed files with 17 additions and 3 deletions

View file

@ -234,7 +234,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
// TODO fuse the below into 'sync'? or make checkForTbrMismatch jut a trigger to issue a sync if needed; don't run sync twice as is nice
// checkForTbrMismatch();
checkPumpHistory();
// checkPumpHistory();
}
/**
@ -582,21 +582,34 @@ public class ComboPlugin implements PluginBase, PumpInterface {
private synchronized CommandResult runCommand(String activity, CommandExecution commandExecution) {
if (activity != null) {
// danar has this is message on the overview screen, no?
pump.activity = activity;
MainApp.bus().post(new EventComboPumpUpdateGUI());
}
// TODO should probably specialize this:
// smb, tbr stuff can be retried.
// non-smb bolus shall be blocked if same amount already delivered within last 1 min
// i need a version of this which sets activity, updates local state etc and one
// which just does something, read history etc.
// retrying: separate r/o and r/w commands? flag for it?
// CommandResult precheck = ruffyScripter.readPumpState();
// tbrcheck?
// check for active alert; if warning confirm; on warning confirm, read history (bolus, errors), which shall raise alerts if appropriate
//
// precheck.
// todo don't send out commands requining run mode if pump is suspended
//
CommandResult commandResult = commandExecution.execute();
pump.lastCmdResult = commandResult;
pump.lastConnectionAttempt = System.currentTimeMillis();
if (commandResult.success) {
pump.lastSuccessfulConnection = System.currentTimeMillis();
} else {
// TODO set flag to force sync on next connect; try to run immediately? or would this make things worse and we should just wait till the next iteratio?L
}
// copy over state (as supplied) so it will still be available when another command runs that doesn't return that data
@ -694,6 +707,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
}
}
if (sync) {
// todo just return the PHR?
runFullSync(new PumpHistoryRequest().tbrHistory(System.currentTimeMillis() - 3 * 60 * 60 * 1000));
}

View file

@ -43,7 +43,7 @@ public class ReadHistoryCommand extends BaseCommand {
if (request.bolusHistory != PumpHistoryRequest.SKIP) {
int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD);
if (totalRecords > 0) {
if (true || request.bolusHistory == PumpHistoryRequest.LAST) {
if (request.bolusHistory == PumpHistoryRequest.LAST) {
Bolus bolus = readBolusRecord();
history.bolusHistory.add(bolus);
} else {
@ -58,7 +58,7 @@ public class ReadHistoryCommand extends BaseCommand {
if (request.pumpErrorHistory != PumpHistoryRequest.SKIP) {
int totalRecords = (int) scripter.getCurrentMenu().getAttribute(MenuAttribute.TOTAL_RECORD);
if (totalRecords > 0) {
if (true || request.pumpErrorHistory == PumpHistoryRequest.LAST) {
if (request.pumpErrorHistory == PumpHistoryRequest.LAST) {
PumpError error = readErrorRecord();
history.pumpErrorHistory.add(error);
} else {