- saving last error data, when error comes
This commit is contained in:
parent
db117bf736
commit
adf1d892da
|
@ -1,9 +1,9 @@
|
|||
package info.nightscout.androidaps.plugins.pump.common.data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.joda.time.LocalDateTime;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import info.nightscout.androidaps.data.ProfileStore;
|
||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpStatusType;
|
||||
|
@ -19,7 +19,9 @@ public abstract class PumpStatus {
|
|||
public LocalDateTime lastDataTime;
|
||||
public long lastConnection = 0L;
|
||||
public long previousConnection = 0L; // here should be stored last connection of previous session (so needs to be
|
||||
// read before lastConnection is modified for first time).
|
||||
// read before lastConnection is modified for first time).
|
||||
|
||||
public long lastErrorConnection = 0L;
|
||||
|
||||
// last bolus
|
||||
public Date lastBolusTime;
|
||||
|
@ -68,6 +70,10 @@ public abstract class PumpStatus {
|
|||
this.lastConnection = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void setLastFailedCommunicationToNow() {
|
||||
this.lastErrorConnection = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
|
||||
public abstract String getErrorInfo();
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ public class OmnipodUITask {
|
|||
break;
|
||||
|
||||
case SetBolus: {
|
||||
DetailedBolusInfo detailedBolusInfo = (DetailedBolusInfo)parameters[0];
|
||||
DetailedBolusInfo detailedBolusInfo = (DetailedBolusInfo) parameters[0];
|
||||
|
||||
if (detailedBolusInfo != null)
|
||||
returnData = communicationManager.setBolus(detailedBolusInfo);
|
||||
|
@ -85,7 +85,7 @@ public class OmnipodUITask {
|
|||
// This command is very error prone, so retry a few times if it fails
|
||||
// Can take some time, but that's ok since this is a very specific feature for experts
|
||||
// And will not be used by normal users
|
||||
for(int i = 0; 3 > i; i++) {
|
||||
for (int i = 0; 3 > i; i++) {
|
||||
try {
|
||||
returnDataObject = communicationManager.readPulseLog();
|
||||
responseType = PodResponseType.Acknowledgment;
|
||||
|
@ -135,7 +135,7 @@ public class OmnipodUITask {
|
|||
|
||||
}
|
||||
|
||||
if (returnData!=null) {
|
||||
if (returnData != null) {
|
||||
responseType = returnData.success ? PodResponseType.Acknowledgment : PodResponseType.Error;
|
||||
}
|
||||
|
||||
|
@ -197,10 +197,12 @@ public class OmnipodUITask {
|
|||
if (responseType == PodResponseType.Invalid) {
|
||||
statusChange = new EventOmnipodDeviceStatusChange(PodDeviceState.ErrorWhenCommunicating,
|
||||
"Unsupported command in OmnipodUITask");
|
||||
OmnipodUtil.getPumpStatus().setLastFailedCommunicationToNow();
|
||||
RxBus.INSTANCE.send(statusChange);
|
||||
} else if (responseType == PodResponseType.Error) {
|
||||
statusChange = new EventOmnipodDeviceStatusChange(PodDeviceState.ErrorWhenCommunicating,
|
||||
errorDescription);
|
||||
OmnipodUtil.getPumpStatus().setLastFailedCommunicationToNow();
|
||||
RxBus.INSTANCE.send(statusChange);
|
||||
} else {
|
||||
OmnipodUtil.getPumpStatus().setLastCommunicationToNow();
|
||||
|
|
Loading…
Reference in a new issue