- 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;
|
package info.nightscout.androidaps.plugins.pump.common.data;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import org.joda.time.LocalDateTime;
|
import org.joda.time.LocalDateTime;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
import info.nightscout.androidaps.data.ProfileStore;
|
import info.nightscout.androidaps.data.ProfileStore;
|
||||||
import info.nightscout.androidaps.interfaces.PumpDescription;
|
import info.nightscout.androidaps.interfaces.PumpDescription;
|
||||||
import info.nightscout.androidaps.plugins.pump.common.defs.PumpStatusType;
|
import info.nightscout.androidaps.plugins.pump.common.defs.PumpStatusType;
|
||||||
|
@ -21,6 +21,8 @@ public abstract class PumpStatus {
|
||||||
public long previousConnection = 0L; // here should be stored last connection of previous session (so needs to be
|
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
|
// last bolus
|
||||||
public Date lastBolusTime;
|
public Date lastBolusTime;
|
||||||
public Double lastBolusAmount;
|
public Double lastBolusAmount;
|
||||||
|
@ -68,6 +70,10 @@ public abstract class PumpStatus {
|
||||||
this.lastConnection = System.currentTimeMillis();
|
this.lastConnection = System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setLastFailedCommunicationToNow() {
|
||||||
|
this.lastErrorConnection = System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public abstract String getErrorInfo();
|
public abstract String getErrorInfo();
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class OmnipodUITask {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SetBolus: {
|
case SetBolus: {
|
||||||
DetailedBolusInfo detailedBolusInfo = (DetailedBolusInfo)parameters[0];
|
DetailedBolusInfo detailedBolusInfo = (DetailedBolusInfo) parameters[0];
|
||||||
|
|
||||||
if (detailedBolusInfo != null)
|
if (detailedBolusInfo != null)
|
||||||
returnData = communicationManager.setBolus(detailedBolusInfo);
|
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
|
// 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
|
// 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
|
// And will not be used by normal users
|
||||||
for(int i = 0; 3 > i; i++) {
|
for (int i = 0; 3 > i; i++) {
|
||||||
try {
|
try {
|
||||||
returnDataObject = communicationManager.readPulseLog();
|
returnDataObject = communicationManager.readPulseLog();
|
||||||
responseType = PodResponseType.Acknowledgment;
|
responseType = PodResponseType.Acknowledgment;
|
||||||
|
@ -135,7 +135,7 @@ public class OmnipodUITask {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (returnData!=null) {
|
if (returnData != null) {
|
||||||
responseType = returnData.success ? PodResponseType.Acknowledgment : PodResponseType.Error;
|
responseType = returnData.success ? PodResponseType.Acknowledgment : PodResponseType.Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,10 +197,12 @@ public class OmnipodUITask {
|
||||||
if (responseType == PodResponseType.Invalid) {
|
if (responseType == PodResponseType.Invalid) {
|
||||||
statusChange = new EventOmnipodDeviceStatusChange(PodDeviceState.ErrorWhenCommunicating,
|
statusChange = new EventOmnipodDeviceStatusChange(PodDeviceState.ErrorWhenCommunicating,
|
||||||
"Unsupported command in OmnipodUITask");
|
"Unsupported command in OmnipodUITask");
|
||||||
|
OmnipodUtil.getPumpStatus().setLastFailedCommunicationToNow();
|
||||||
RxBus.INSTANCE.send(statusChange);
|
RxBus.INSTANCE.send(statusChange);
|
||||||
} else if (responseType == PodResponseType.Error) {
|
} else if (responseType == PodResponseType.Error) {
|
||||||
statusChange = new EventOmnipodDeviceStatusChange(PodDeviceState.ErrorWhenCommunicating,
|
statusChange = new EventOmnipodDeviceStatusChange(PodDeviceState.ErrorWhenCommunicating,
|
||||||
errorDescription);
|
errorDescription);
|
||||||
|
OmnipodUtil.getPumpStatus().setLastFailedCommunicationToNow();
|
||||||
RxBus.INSTANCE.send(statusChange);
|
RxBus.INSTANCE.send(statusChange);
|
||||||
} else {
|
} else {
|
||||||
OmnipodUtil.getPumpStatus().setLastCommunicationToNow();
|
OmnipodUtil.getPumpStatus().setLastCommunicationToNow();
|
||||||
|
|
Loading…
Reference in a new issue