Implement additional methods
This commit is contained in:
parent
ce0650a495
commit
d07d9d309e
|
@ -41,10 +41,10 @@ import info.nightscout.androidaps.plugins.PumpInsight.utils.StatusItem;
|
||||||
import info.nightscout.utils.DateUtil;
|
import info.nightscout.utils.DateUtil;
|
||||||
import info.nightscout.utils.NSUpload;
|
import info.nightscout.utils.NSUpload;
|
||||||
import info.nightscout.utils.SP;
|
import info.nightscout.utils.SP;
|
||||||
import sugar.free.sightparser.applayer.messages.AppLayerMessage;
|
|
||||||
import sugar.free.sightparser.applayer.descriptors.ActiveBolus;
|
import sugar.free.sightparser.applayer.descriptors.ActiveBolus;
|
||||||
import sugar.free.sightparser.applayer.descriptors.ActiveBolusType;
|
import sugar.free.sightparser.applayer.descriptors.ActiveBolusType;
|
||||||
import sugar.free.sightparser.applayer.descriptors.PumpStatus;
|
import sugar.free.sightparser.applayer.descriptors.PumpStatus;
|
||||||
|
import sugar.free.sightparser.applayer.messages.AppLayerMessage;
|
||||||
import sugar.free.sightparser.applayer.messages.remote_control.CancelTBRMessage;
|
import sugar.free.sightparser.applayer.messages.remote_control.CancelTBRMessage;
|
||||||
import sugar.free.sightparser.applayer.messages.remote_control.ExtendedBolusMessage;
|
import sugar.free.sightparser.applayer.messages.remote_control.ExtendedBolusMessage;
|
||||||
import sugar.free.sightparser.applayer.messages.remote_control.StandardBolusMessage;
|
import sugar.free.sightparser.applayer.messages.remote_control.StandardBolusMessage;
|
||||||
|
@ -134,7 +134,6 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
||||||
pumpDescription.tempDurationStep = 15; // 15 minutes up to 24 hours
|
pumpDescription.tempDurationStep = 15; // 15 minutes up to 24 hours
|
||||||
pumpDescription.tempMaxDuration = 24 * 60;
|
pumpDescription.tempMaxDuration = 24 * 60;
|
||||||
|
|
||||||
|
|
||||||
pumpDescription.isSetBasalProfileCapable = false; // leave this for now
|
pumpDescription.isSetBasalProfileCapable = false; // leave this for now
|
||||||
pumpDescription.basalStep = 0.01d;
|
pumpDescription.basalStep = 0.01d;
|
||||||
pumpDescription.basalMinimumRate = 0.02d;
|
pumpDescription.basalMinimumRate = 0.02d;
|
||||||
|
@ -253,7 +252,7 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSuspended() {
|
public boolean isSuspended() {
|
||||||
return false;
|
return !isPumpRunning();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -266,10 +265,9 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
||||||
return Connector.get().isPumpConnected();
|
return Connector.get().isPumpConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO implement
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isConnecting() {
|
public boolean isConnecting() {
|
||||||
return false;
|
return Connector.get().isPumpConnecting();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -311,6 +309,21 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void stopConnecting() {
|
public void stopConnecting() {
|
||||||
|
log("InsightPumpPlugin::stopConnecting()");
|
||||||
|
try {
|
||||||
|
if (isConnecting()) {
|
||||||
|
if (!SP.getBoolean("insight_always_connected", false)) {
|
||||||
|
log("Requesting disconnect");
|
||||||
|
connector.getServiceConnector().disconnect();
|
||||||
|
} else {
|
||||||
|
log("Not disconnecting due to preference");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
log("Not currently trying to connect so not stopping connection");
|
||||||
|
}
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
log("Could not stop connecting - null pointer: " + e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -411,10 +424,16 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO implement
|
|
||||||
@Override
|
@Override
|
||||||
public void stopBolusDelivering() {
|
public void stopBolusDelivering() {
|
||||||
|
final UUID cmd = aSyncTaskRunner(new CancelBolusTaskRunner(connector.getServiceConnector(), ActiveBolusType.STANDARD), "Cancel standard bolus");
|
||||||
|
|
||||||
|
if (cmd == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Cstatus cs = async.busyWaitForCommandResult(cmd, BUSY_WAIT_TIME);
|
||||||
|
log("Got command status: " + cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporary Basals
|
// Temporary Basals
|
||||||
|
@ -574,7 +593,7 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
||||||
extendedBolus.date = System.currentTimeMillis();
|
extendedBolus.date = System.currentTimeMillis();
|
||||||
extendedBolus.insulin = insulin;
|
extendedBolus.insulin = insulin;
|
||||||
extendedBolus.durationInMinutes = durationInMinutes;
|
extendedBolus.durationInMinutes = durationInMinutes;
|
||||||
extendedBolus.source = Source.USER; // TODO check this is correct
|
extendedBolus.source = Source.USER;
|
||||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
MainApp.getConfigBuilder().addToHistoryExtendedBolus(extendedBolus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -607,7 +626,6 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
||||||
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
|
if (MainApp.getConfigBuilder().isInHistoryExtendedBoluslInProgress()) {
|
||||||
ExtendedBolus exStop = new ExtendedBolus(System.currentTimeMillis());
|
ExtendedBolus exStop = new ExtendedBolus(System.currentTimeMillis());
|
||||||
exStop.source = Source.USER;
|
exStop.source = Source.USER;
|
||||||
// TODO does this need any specific cancel flag?
|
|
||||||
MainApp.getConfigBuilder().addToHistoryExtendedBolus(exStop);
|
MainApp.getConfigBuilder().addToHistoryExtendedBolus(exStop);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -710,6 +728,11 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
||||||
return MainApp.instance().getString(id);
|
return MainApp.instance().getString(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean isPumpRunning() {
|
||||||
|
if (statusResult == null) return true; // assume running if we have no information
|
||||||
|
return statusResult.getPumpStatusMessage().getPumpStatus() == PumpStatus.STARTED;
|
||||||
|
}
|
||||||
|
|
||||||
List<StatusItem> getStatusItems() {
|
List<StatusItem> getStatusItems() {
|
||||||
final List<StatusItem> l = new ArrayList<>();
|
final List<StatusItem> l = new ArrayList<>();
|
||||||
|
|
||||||
|
@ -722,7 +745,7 @@ public class InsightPumpPlugin implements PluginBase, PumpInterface {
|
||||||
// also check time since received
|
// also check time since received
|
||||||
if (statusResult != null) {
|
if (statusResult != null) {
|
||||||
|
|
||||||
pumpRunning = statusResult.getPumpStatusMessage().getPumpStatus() == PumpStatus.STARTED;
|
pumpRunning = isPumpRunning();
|
||||||
if (pumpRunning) {
|
if (pumpRunning) {
|
||||||
l.add(new StatusItem(gs(R.string.pump_basebasalrate_label), getBaseBasalRateString() + "U"));
|
l.add(new StatusItem(gs(R.string.pump_basebasalrate_label), getBaseBasalRateString() + "U"));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -30,7 +30,6 @@ import static sugar.free.sightparser.handling.SightService.COMPATIBILITY_VERSION
|
||||||
|
|
||||||
public class Connector {
|
public class Connector {
|
||||||
|
|
||||||
//public static final String ACTION_START_RESYNC = "sugar.free.sightremote.services.HistorySyncService.START_RESYNC";
|
|
||||||
private static final String TAG = "InsightConnector";
|
private static final String TAG = "InsightConnector";
|
||||||
private static final String COMPANION_APP_PACKAGE = "sugar.free.sightremote";
|
private static final String COMPANION_APP_PACKAGE = "sugar.free.sightremote";
|
||||||
private final static long FRESH_MS = 70000;
|
private final static long FRESH_MS = 70000;
|
||||||
|
@ -194,6 +193,10 @@ public class Connector {
|
||||||
return isConnected() && getLastStatus() == Status.CONNECTED;
|
return isConnected() && getLastStatus() == Status.CONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isPumpConnecting() {
|
||||||
|
return isConnected() && getLastStatus() == Status.CONNECTING;
|
||||||
|
}
|
||||||
|
|
||||||
public String getLastStatusMessage() {
|
public String getLastStatusMessage() {
|
||||||
|
|
||||||
if (!companionAppInstalled) {
|
if (!companionAppInstalled) {
|
||||||
|
|
Loading…
Reference in a new issue