Disconnect after issuing comand to Combo.

This commit is contained in:
Johannes Mockenhaupt 2017-07-13 20:17:20 +02:00
parent 3280092566
commit 7cb0268afc
No known key found for this signature in database
GPG key ID: 9E1EA6AF7BBBB0D1

View file

@ -50,6 +50,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
private ServiceConnection mRuffyServiceConnection;
private static PumpEnactResult OPERATION_NOT_SUPPORTED = new PumpEnactResult();
static {
OPERATION_NOT_SUPPORTED.success = false;
OPERATION_NOT_SUPPORTED.enacted = false;
@ -94,7 +95,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
};
boolean success = context.bindService(intent, mRuffyServiceConnection, Context.BIND_AUTO_CREATE);
if(!success) {
if (!success) {
log.error("Binding to ruffy service failed");
}
}
@ -189,7 +190,8 @@ public class ComboPlugin implements PluginBase, PumpInterface {
@Override
public boolean isInitialized() {
// TODO
return ruffyScripter != null;
// hm, lastCmdDate > 0, like the DanaR does it?
return true; // scripter does this as needed; ruffyScripter != null;
}
@Override
@ -239,6 +241,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
@Override
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
try {
Command command = new BolusCommand(detailedBolusInfo.insulin);
CommandResult commandResult = ruffyScripter.runCommand(command);
@ -247,8 +250,10 @@ public class ComboPlugin implements PluginBase, PumpInterface {
pumpEnactResult.enacted = commandResult.enacted;
pumpEnactResult.comment = commandResult.message;
pumpEnactResult.bolusDelivered = detailedBolusInfo.insulin;
return pumpEnactResult;
} finally {
ruffyScripter.disconnect();
}
}
@Override
@ -267,6 +272,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
@Override
public PumpEnactResult setTempBasalPercent(Integer percent, Integer durationInMinutes) {
// TODO make each cmd return all the data the main screen displays and cache here ?
try {
Command command = new SetTbrCommand(percent, durationInMinutes);
CommandResult commandResult = ruffyScripter.runCommand(command);
@ -277,9 +283,13 @@ public class ComboPlugin implements PluginBase, PumpInterface {
pumpEnactResult.isPercent = true;
pumpEnactResult.percent = percent;
//TODO
fakeBasalRate = fakeBasalRate * percent / 100;
return pumpEnactResult;
} finally {
ruffyScripter.disconnect();
}
}
// TODO
@ -291,6 +301,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
// TODO
@Override
public PumpEnactResult cancelTempBasal() {
try {
Command command = new CancelTbrCommand();
CommandResult commandResult = ruffyScripter.runCommand(command);
@ -300,9 +311,13 @@ public class ComboPlugin implements PluginBase, PumpInterface {
pumpEnactResult.comment = commandResult.message;
pumpEnactResult.isTempCancel = true;
//TODO
fakeBasalRate = 0.5d;
return pumpEnactResult;
} finally {
ruffyScripter.disconnect();
}
}
// TODO