disconnect state
This commit is contained in:
parent
ccad0c18b1
commit
b9ad90a51b
|
@ -63,6 +63,8 @@ public class LoopPlugin implements PluginBase {
|
|||
|
||||
private long loopSuspendedTill = 0L; // end of manual loop suspend
|
||||
private boolean isSuperBolus = false;
|
||||
private boolean isDisconnected = false;
|
||||
|
||||
|
||||
public class LastRun {
|
||||
public APSResult request = null;
|
||||
|
@ -85,6 +87,7 @@ public class LoopPlugin implements PluginBase {
|
|||
MainApp.bus().register(this);
|
||||
loopSuspendedTill = SP.getLong("loopSuspendedTill", 0L);
|
||||
isSuperBolus = SP.getBoolean("isSuperBolus", false);
|
||||
isDisconnected = SP.getBoolean("isDisconnected", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -170,13 +173,28 @@ public class LoopPlugin implements PluginBase {
|
|||
public void suspendTo(long endTime) {
|
||||
loopSuspendedTill = endTime;
|
||||
isSuperBolus = false;
|
||||
isDisconnected = false;
|
||||
SP.putLong("loopSuspendedTill", loopSuspendedTill);
|
||||
SP.putBoolean("isSuperBolus", isSuperBolus);
|
||||
SP.putBoolean("isDisconnected", isDisconnected);
|
||||
}
|
||||
|
||||
public void superBolusTo(long endTime) {
|
||||
loopSuspendedTill = endTime;
|
||||
isSuperBolus = true;
|
||||
isDisconnected = false;
|
||||
SP.putLong("loopSuspendedTill", loopSuspendedTill);
|
||||
SP.putBoolean("isSuperBolus", isSuperBolus);
|
||||
SP.putBoolean("isDisconnected", isDisconnected);
|
||||
}
|
||||
|
||||
public void disconnectTo(long endTime) {
|
||||
loopSuspendedTill = endTime;
|
||||
isSuperBolus = false;
|
||||
isDisconnected = true;
|
||||
SP.putLong("loopSuspendedTill", loopSuspendedTill);
|
||||
SP.putBoolean("isSuperBolus", isSuperBolus);
|
||||
SP.putBoolean("isDisconnected", isDisconnected);
|
||||
}
|
||||
|
||||
public int minutesToEndOfSuspend() {
|
||||
|
@ -222,6 +240,20 @@ public class LoopPlugin implements PluginBase {
|
|||
return isSuperBolus;
|
||||
}
|
||||
|
||||
public boolean isDisconnected() {
|
||||
if (loopSuspendedTill == 0)
|
||||
return false;
|
||||
|
||||
long now = System.currentTimeMillis();
|
||||
|
||||
if (loopSuspendedTill <= now) { // time exceeded
|
||||
suspendTo(0L);
|
||||
return false;
|
||||
}
|
||||
|
||||
return isDisconnected;
|
||||
}
|
||||
|
||||
public void invoke(String initiator, boolean allowNotification) {
|
||||
try {
|
||||
if (Config.logFunctionCalls)
|
||||
|
|
|
@ -491,7 +491,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
NSUpload.uploadOpenAPSOffline(600);
|
||||
return true;
|
||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor30m))) {
|
||||
activeloop.suspendTo(System.currentTimeMillis() + 30L * 60 * 1000);
|
||||
activeloop.disconnectTo(System.currentTimeMillis() + 30L * 60 * 1000);
|
||||
updateGUI("suspendmenu");
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
|
@ -505,7 +505,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
NSUpload.uploadOpenAPSOffline(30);
|
||||
return true;
|
||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor1h))) {
|
||||
activeloop.suspendTo(System.currentTimeMillis() + 1 * 60L * 60 * 1000);
|
||||
activeloop.disconnectTo(System.currentTimeMillis() + 1 * 60L * 60 * 1000);
|
||||
updateGUI("suspendmenu");
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
|
@ -519,7 +519,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
NSUpload.uploadOpenAPSOffline(60);
|
||||
return true;
|
||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor2h))) {
|
||||
activeloop.suspendTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
|
||||
activeloop.disconnectTo(System.currentTimeMillis() + 2 * 60L * 60 * 1000);
|
||||
updateGUI("suspendmenu");
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
|
@ -533,7 +533,7 @@ public class OverviewFragment extends Fragment implements View.OnClickListener,
|
|||
NSUpload.uploadOpenAPSOffline(120);
|
||||
return true;
|
||||
} else if (item.getTitle().equals(MainApp.sResources.getString(R.string.disconnectpumpfor3h))) {
|
||||
activeloop.suspendTo(System.currentTimeMillis() + 3 * 60L * 60 * 1000);
|
||||
activeloop.disconnectTo(System.currentTimeMillis() + 3 * 60L * 60 * 1000);
|
||||
updateGUI("suspendmenu");
|
||||
sHandler.post(new Runnable() {
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue