Disconnect after issuing comand to Combo.
This commit is contained in:
parent
3280092566
commit
7cb0268afc
|
@ -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;
|
||||||
|
@ -94,7 +95,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
};
|
};
|
||||||
|
|
||||||
boolean success = context.bindService(intent, mRuffyServiceConnection, Context.BIND_AUTO_CREATE);
|
boolean success = context.bindService(intent, mRuffyServiceConnection, Context.BIND_AUTO_CREATE);
|
||||||
if(!success) {
|
if (!success) {
|
||||||
log.error("Binding to ruffy service failed");
|
log.error("Binding to ruffy service failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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,16 +241,19 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
public PumpEnactResult deliverTreatment(DetailedBolusInfo detailedBolusInfo) {
|
||||||
Command command = new BolusCommand(detailedBolusInfo.insulin);
|
try {
|
||||||
CommandResult commandResult = ruffyScripter.runCommand(command);
|
Command command = new BolusCommand(detailedBolusInfo.insulin);
|
||||||
|
CommandResult commandResult = ruffyScripter.runCommand(command);
|
||||||
|
|
||||||
PumpEnactResult pumpEnactResult = new PumpEnactResult();
|
PumpEnactResult pumpEnactResult = new PumpEnactResult();
|
||||||
pumpEnactResult.success = commandResult.success;
|
pumpEnactResult.success = commandResult.success;
|
||||||
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,19 +272,24 @@ 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 ?
|
||||||
Command command = new SetTbrCommand(percent, durationInMinutes);
|
try {
|
||||||
CommandResult commandResult = ruffyScripter.runCommand(command);
|
Command command = new SetTbrCommand(percent, durationInMinutes);
|
||||||
|
CommandResult commandResult = ruffyScripter.runCommand(command);
|
||||||
|
|
||||||
PumpEnactResult pumpEnactResult = new PumpEnactResult();
|
PumpEnactResult pumpEnactResult = new PumpEnactResult();
|
||||||
pumpEnactResult.success = commandResult.success;
|
pumpEnactResult.success = commandResult.success;
|
||||||
pumpEnactResult.enacted = commandResult.enacted;
|
pumpEnactResult.enacted = commandResult.enacted;
|
||||||
pumpEnactResult.comment = commandResult.message;
|
pumpEnactResult.comment = commandResult.message;
|
||||||
pumpEnactResult.isPercent = true;
|
pumpEnactResult.isPercent = true;
|
||||||
pumpEnactResult.percent = percent;
|
pumpEnactResult.percent = percent;
|
||||||
|
|
||||||
fakeBasalRate = fakeBasalRate * percent / 100;
|
//TODO
|
||||||
|
fakeBasalRate = fakeBasalRate * percent / 100;
|
||||||
|
|
||||||
return pumpEnactResult;
|
return pumpEnactResult;
|
||||||
|
} finally {
|
||||||
|
ruffyScripter.disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
@ -291,18 +301,23 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
// TODO
|
// TODO
|
||||||
@Override
|
@Override
|
||||||
public PumpEnactResult cancelTempBasal() {
|
public PumpEnactResult cancelTempBasal() {
|
||||||
Command command = new CancelTbrCommand();
|
try {
|
||||||
CommandResult commandResult = ruffyScripter.runCommand(command);
|
Command command = new CancelTbrCommand();
|
||||||
|
CommandResult commandResult = ruffyScripter.runCommand(command);
|
||||||
|
|
||||||
PumpEnactResult pumpEnactResult = new PumpEnactResult();
|
PumpEnactResult pumpEnactResult = new PumpEnactResult();
|
||||||
pumpEnactResult.success = commandResult.success;
|
pumpEnactResult.success = commandResult.success;
|
||||||
pumpEnactResult.enacted = commandResult.enacted;
|
pumpEnactResult.enacted = commandResult.enacted;
|
||||||
pumpEnactResult.comment = commandResult.message;
|
pumpEnactResult.comment = commandResult.message;
|
||||||
pumpEnactResult.isTempCancel = true;
|
pumpEnactResult.isTempCancel = true;
|
||||||
|
|
||||||
fakeBasalRate = 0.5d;
|
//TODO
|
||||||
|
fakeBasalRate = 0.5d;
|
||||||
|
|
||||||
return pumpEnactResult;
|
return pumpEnactResult;
|
||||||
|
} finally {
|
||||||
|
ruffyScripter.disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
|
|
Loading…
Reference in a new issue