Merge remote-tracking branch 'remotes/origin/dev' into dev
This commit is contained in:
commit
ac3b15135e
|
@ -33,6 +33,7 @@ import info.nightscout.androidaps.plugins.Overview.notifications.Notification;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.connector.AbsoluteTBRTaskRunner;
|
import info.nightscout.androidaps.plugins.PumpInsight.connector.AbsoluteTBRTaskRunner;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.connector.CancelBolusTaskRunner;
|
import info.nightscout.androidaps.plugins.PumpInsight.connector.CancelBolusTaskRunner;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.connector.Connector;
|
import info.nightscout.androidaps.plugins.PumpInsight.connector.Connector;
|
||||||
|
import info.nightscout.androidaps.plugins.PumpInsight.connector.SetTBRTaskRunner;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.events.EventInsightPumpCallback;
|
import info.nightscout.androidaps.plugins.PumpInsight.events.EventInsightPumpCallback;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.events.EventInsightPumpUpdateGui;
|
import info.nightscout.androidaps.plugins.PumpInsight.events.EventInsightPumpUpdateGui;
|
||||||
import info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver;
|
import info.nightscout.androidaps.plugins.PumpInsight.history.HistoryReceiver;
|
||||||
|
@ -52,7 +53,6 @@ import sugar.free.sightparser.applayer.messages.remote_control.ExtendedBolusMess
|
||||||
import sugar.free.sightparser.applayer.messages.remote_control.StandardBolusMessage;
|
import sugar.free.sightparser.applayer.messages.remote_control.StandardBolusMessage;
|
||||||
import sugar.free.sightparser.handling.SingleMessageTaskRunner;
|
import sugar.free.sightparser.handling.SingleMessageTaskRunner;
|
||||||
import sugar.free.sightparser.handling.TaskRunner;
|
import sugar.free.sightparser.handling.TaskRunner;
|
||||||
import sugar.free.sightparser.handling.taskrunners.SetTBRTaskRunner;
|
|
||||||
import sugar.free.sightparser.handling.taskrunners.StatusTaskRunner;
|
import sugar.free.sightparser.handling.taskrunners.StatusTaskRunner;
|
||||||
|
|
||||||
import static info.nightscout.androidaps.plugins.PumpInsight.history.PumpIdCache.getRecordUniqueID;
|
import static info.nightscout.androidaps.plugins.PumpInsight.history.PumpIdCache.getRecordUniqueID;
|
||||||
|
@ -85,8 +85,8 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface, Constraints
|
||||||
private long statusResultTime = -1;
|
private long statusResultTime = -1;
|
||||||
private Date lastDataTime = new Date(0);
|
private Date lastDataTime = new Date(0);
|
||||||
private TaskRunner taskRunner;
|
private TaskRunner taskRunner;
|
||||||
private boolean fragmentEnabled = true;
|
private boolean fragmentEnabled = false;
|
||||||
private boolean fragmentVisible = true;
|
private boolean fragmentVisible = false;
|
||||||
private boolean fauxTBRcancel = true;
|
private boolean fauxTBRcancel = true;
|
||||||
private PumpDescription pumpDescription = new PumpDescription();
|
private PumpDescription pumpDescription = new PumpDescription();
|
||||||
private double basalRate = 0;
|
private double basalRate = 0;
|
||||||
|
@ -463,6 +463,11 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface, Constraints
|
||||||
log("Calculated requested rate: " + absoluteRate + " base rate: " + base_basal + " percentage: " + amount + "%");
|
log("Calculated requested rate: " + absoluteRate + " base rate: " + base_basal + " percentage: " + amount + "%");
|
||||||
amount = (int) Math.round(((double) amount) / 10d) * 10;
|
amount = (int) Math.round(((double) amount) / 10d) * 10;
|
||||||
log("Calculated final rate: " + amount + "%");
|
log("Calculated final rate: " + amount + "%");
|
||||||
|
|
||||||
|
if (amount == 100) {
|
||||||
|
return cancelTempBasal(false);
|
||||||
|
}
|
||||||
|
|
||||||
if (amount > 250) amount = 250;
|
if (amount > 250) amount = 250;
|
||||||
|
|
||||||
final SetTBRTaskRunner task = new SetTBRTaskRunner(connector.getServiceConnector(), amount, durationInMinutes);
|
final SetTBRTaskRunner task = new SetTBRTaskRunner(connector.getServiceConnector(), amount, durationInMinutes);
|
||||||
|
@ -610,15 +615,7 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface, Constraints
|
||||||
final UUID cmd;
|
final UUID cmd;
|
||||||
|
|
||||||
if (fauxTBRcancel) {
|
if (fauxTBRcancel) {
|
||||||
final TemporaryBasal activeTemp = MainApp.getConfigBuilder().getTempBasalFromHistory(System.currentTimeMillis());
|
cmd = aSyncTaskRunner(new SetTBRTaskRunner(connector.getServiceConnector(), 100, 1), "Faux Cancel TBR - setting " + "90%" + " 1m");
|
||||||
// I'm not totally sure whether based on the times that this cancellation will occur
|
|
||||||
// whether the logic should actually be inverted as we are reversing a decision.
|
|
||||||
// I believe it also affects at most 2.5% of an hourly basal rate and the pump only
|
|
||||||
// delivers basal every 3 minutes when > 0.19U per hour, below that unspecified.
|
|
||||||
final int faux_percent = (activeTemp == null) ? 90 : (activeTemp.percentRate > 100) ? 110 : 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 {
|
} else {
|
||||||
cmd = aSyncSingleCommand(new CancelTBRMessage(), "Cancel Temp Basal");
|
cmd = aSyncSingleCommand(new CancelTBRMessage(), "Cancel Temp Basal");
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
package info.nightscout.androidaps.plugins.PumpInsight.connector;
|
||||||
|
|
||||||
|
import sugar.free.sightparser.applayer.messages.AppLayerMessage;
|
||||||
|
import sugar.free.sightparser.applayer.messages.remote_control.ChangeTBRMessage;
|
||||||
|
import sugar.free.sightparser.applayer.messages.remote_control.SetTBRMessage;
|
||||||
|
import sugar.free.sightparser.applayer.messages.status.CurrentTBRMessage;
|
||||||
|
import sugar.free.sightparser.handling.SightServiceConnector;
|
||||||
|
import sugar.free.sightparser.handling.TaskRunner;
|
||||||
|
|
||||||
|
// from Tebbe - note this uses 1 minute duration to silently cancel existing TBR
|
||||||
|
|
||||||
|
public class SetTBRTaskRunner extends TaskRunner {
|
||||||
|
|
||||||
|
private int amount;
|
||||||
|
private int duration;
|
||||||
|
|
||||||
|
public SetTBRTaskRunner(SightServiceConnector serviceConnector, int amount, int duration) {
|
||||||
|
super(serviceConnector);
|
||||||
|
this.amount = amount;
|
||||||
|
this.duration = duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected AppLayerMessage run(AppLayerMessage message) throws Exception {
|
||||||
|
if (message == null) return new CurrentTBRMessage();
|
||||||
|
else if (message instanceof CurrentTBRMessage) {
|
||||||
|
if (((CurrentTBRMessage) message).getPercentage() == 100) {
|
||||||
|
if (amount == 100) finish(amount);
|
||||||
|
else {
|
||||||
|
SetTBRMessage setTBRMessage = new SetTBRMessage();
|
||||||
|
setTBRMessage.setDuration((short) duration);
|
||||||
|
setTBRMessage.setAmount((short) amount);
|
||||||
|
return setTBRMessage;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (amount == 100) {
|
||||||
|
ChangeTBRMessage changeTBRMessage = new ChangeTBRMessage();
|
||||||
|
changeTBRMessage.setDuration((short) 1);
|
||||||
|
changeTBRMessage.setAmount((short) 90);
|
||||||
|
return changeTBRMessage;
|
||||||
|
} else {
|
||||||
|
ChangeTBRMessage changeTBRMessage = new ChangeTBRMessage();
|
||||||
|
changeTBRMessage.setDuration((short) duration);
|
||||||
|
changeTBRMessage.setAmount((short) amount);
|
||||||
|
return changeTBRMessage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (message instanceof SetTBRMessage) finish(amount);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue