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