Insight faux cancel tbr option
This commit is contained in:
parent
742ee5b762
commit
ef2189fec6
|
@ -83,6 +83,8 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
||||||
private TaskRunner taskRunner;
|
private TaskRunner taskRunner;
|
||||||
private boolean fragmentEnabled = true;
|
private boolean fragmentEnabled = true;
|
||||||
private boolean fragmentVisible = true;
|
private boolean fragmentVisible = true;
|
||||||
|
private boolean fauxTBRcancel = true;
|
||||||
|
private static final long BUSY_WAIT_TIME = 20000;
|
||||||
private PumpDescription pumpDescription = new PumpDescription();
|
private PumpDescription pumpDescription = new PumpDescription();
|
||||||
private double basalRate = 0;
|
private double basalRate = 0;
|
||||||
private Connector connector;
|
private Connector connector;
|
||||||
|
@ -297,8 +299,6 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
||||||
public void disconnect(String reason) {
|
public void disconnect(String reason) {
|
||||||
log("InsightPumpPlugin::disconnect()");
|
log("InsightPumpPlugin::disconnect()");
|
||||||
try {
|
try {
|
||||||
|
|
||||||
// TODO Timeout timer?
|
|
||||||
if (!SP.getBoolean("insight_always_connected", false)) {
|
if (!SP.getBoolean("insight_always_connected", false)) {
|
||||||
log("Requesting disconnect");
|
log("Requesting disconnect");
|
||||||
connector.getServiceConnector().disconnect();
|
connector.getServiceConnector().disconnect();
|
||||||
|
@ -383,7 +383,7 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
||||||
if (cmd == null) {
|
if (cmd == null) {
|
||||||
return pumpEnactFailure();
|
return pumpEnactFailure();
|
||||||
}
|
}
|
||||||
final Cstatus cs = async.busyWaitForCommandResult(cmd, 10000);
|
final Cstatus cs = async.busyWaitForCommandResult(cmd, BUSY_WAIT_TIME);
|
||||||
result.success = cs.success();
|
result.success = cs.success();
|
||||||
} else {
|
} else {
|
||||||
result.success = true; // always true with carb only treatments
|
result.success = true; // always true with carb only treatments
|
||||||
|
@ -431,7 +431,7 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
||||||
return pumpEnactFailure();
|
return pumpEnactFailure();
|
||||||
}
|
}
|
||||||
|
|
||||||
Cstatus cs = async.busyWaitForCommandResult(cmd, 10000);
|
Cstatus cs = async.busyWaitForCommandResult(cmd, BUSY_WAIT_TIME);
|
||||||
log("Got command status: " + cs);
|
log("Got command status: " + cs);
|
||||||
|
|
||||||
PumpEnactResult pumpEnactResult = new PumpEnactResult().enacted(true).isPercent(false).duration(durationInMinutes);
|
PumpEnactResult pumpEnactResult = new PumpEnactResult().enacted(true).isPercent(false).duration(durationInMinutes);
|
||||||
|
@ -473,7 +473,7 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
||||||
return pumpEnactFailure();
|
return pumpEnactFailure();
|
||||||
}
|
}
|
||||||
|
|
||||||
Cstatus cs = async.busyWaitForCommandResult(cmd, 10000);
|
Cstatus cs = async.busyWaitForCommandResult(cmd, BUSY_WAIT_TIME);
|
||||||
log("Got command status: " + cs);
|
log("Got command status: " + cs);
|
||||||
|
|
||||||
PumpEnactResult pumpEnactResult = new PumpEnactResult().enacted(true).isPercent(true).duration(durationInMinutes);
|
PumpEnactResult pumpEnactResult = new PumpEnactResult().enacted(true).isPercent(true).duration(durationInMinutes);
|
||||||
|
@ -507,15 +507,26 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelTempBasal(boolean enforceNew) {
|
public PumpEnactResult cancelTempBasal(boolean enforceNew) {
|
||||||
log("Cancel TBR");
|
log("Cancel TBR");
|
||||||
final UUID cmd = aSyncSingleCommand(new CancelTBRMessage(), "Cancel Temp Basal");
|
|
||||||
|
|
||||||
|
|
||||||
|
fauxTBRcancel = !SP.getBoolean("insight_real_tbr_cancel", false);
|
||||||
|
|
||||||
|
final UUID cmd;
|
||||||
|
|
||||||
|
if (fauxTBRcancel) {
|
||||||
|
final int faux_percent = 90;
|
||||||
|
final int faux_duration = 15;
|
||||||
|
cmd = aSyncTaskRunner(new SetTBRTaskRunner(connector.getServiceConnector(), faux_percent, 15), "Faux Cancel TBR - setting " + faux_percent + "%" + " " + faux_duration + "m");
|
||||||
|
} else {
|
||||||
|
cmd = aSyncSingleCommand(new CancelTBRMessage(), "Cancel Temp Basal");
|
||||||
|
}
|
||||||
if (cmd == null) {
|
if (cmd == null) {
|
||||||
return pumpEnactFailure();
|
return pumpEnactFailure();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO isn't conditional on one apparently being in progress only the history change
|
// TODO isn't conditional on one apparently being in progress only the history change
|
||||||
boolean enacted = false;
|
boolean enacted = false;
|
||||||
final Cstatus cs = async.busyWaitForCommandResult(cmd, 10000);
|
final Cstatus cs = async.busyWaitForCommandResult(cmd, BUSY_WAIT_TIME);
|
||||||
|
|
||||||
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
if (MainApp.getConfigBuilder().isTempBasalInProgress()) {
|
||||||
enacted = true;
|
enacted = true;
|
||||||
|
@ -547,7 +558,7 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
||||||
return pumpEnactFailure();
|
return pumpEnactFailure();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Cstatus cs = async.busyWaitForCommandResult(cmd, 10000);
|
final Cstatus cs = async.busyWaitForCommandResult(cmd, BUSY_WAIT_TIME);
|
||||||
log("Got command status: " + cs);
|
log("Got command status: " + cs);
|
||||||
|
|
||||||
PumpEnactResult pumpEnactResult = new PumpEnactResult().enacted(true).bolusDelivered(insulin).duration(durationInMinutes);
|
PumpEnactResult pumpEnactResult = new PumpEnactResult().enacted(true).bolusDelivered(insulin).duration(durationInMinutes);
|
||||||
|
@ -587,7 +598,7 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
||||||
return pumpEnactFailure();
|
return pumpEnactFailure();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Cstatus cs = async.busyWaitForCommandResult(cmd, 10000);
|
final Cstatus cs = async.busyWaitForCommandResult(cmd, BUSY_WAIT_TIME);
|
||||||
|
|
||||||
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
|
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
|
||||||
ExtendedBolus exStop = new ExtendedBolus(System.currentTimeMillis());
|
ExtendedBolus exStop = new ExtendedBolus(System.currentTimeMillis());
|
||||||
|
|
|
@ -8,4 +8,9 @@
|
||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="insight_always_connected"
|
android:key="insight_always_connected"
|
||||||
android:title="Stay always connected" />
|
android:title="Stay always connected" />
|
||||||
</PreferenceScreen>
|
<SwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="insight_real_tbr_cancel"
|
||||||
|
android:title="Use Real TBR cancels"
|
||||||
|
android:summary="Actually cancel a TBR (creates pump alarm) instead of setting 90% or 110% TBR for 15 minutes"/>
|
||||||
|
</PreferenceScreen >
|
Loading…
Reference in a new issue