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