Clean up ComoPlugin a bit.
This commit is contained in:
parent
ccd81c67fd
commit
b954ddaa84
1 changed files with 34 additions and 40 deletions
|
@ -101,6 +101,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
|||
new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
log.debug("Querying pump for initial state");
|
||||
runCommand(new NoOpCommand());
|
||||
}
|
||||
}).start();
|
||||
|
@ -305,12 +306,20 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO if there was some clue as to what refreshDataFromPump would do with the data ...
|
||||
// that method calls NSUpload.uploadDeviceStatus(); in VirtualPump ...
|
||||
public PumpState fetchPumpState() {
|
||||
CommandResult commandResult = runCommand(new NoOpCommand());
|
||||
if (commandResult.success) {
|
||||
pumpState = commandResult.state;
|
||||
return commandResult.state;
|
||||
} else {
|
||||
return new PumpState().errorMsg("Failure reading state from pump: " + commandResult.message);
|
||||
}
|
||||
}
|
||||
|
||||
private CommandResult runCommand(Command command) {
|
||||
synchronized (this) {
|
||||
// TODO use this to dispatch methods to a service thread, like DanaRs executionService
|
||||
// will be required when doing multiple commands in sequence.
|
||||
// Alternatively provide 'composite commands' to return everything needed in one go?
|
||||
CommandResult commandResult = null;
|
||||
CommandResult commandResult;
|
||||
try {
|
||||
statusSummary = "Busy running " + command;
|
||||
pumpState = null;
|
||||
|
@ -331,12 +340,9 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
|||
statusSummary = "Error: pump is in error mode, please check pump display";
|
||||
}
|
||||
}
|
||||
|
||||
ruffyScripter.disconnect();
|
||||
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopBolusDelivering() {
|
||||
|
@ -354,17 +360,6 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
|||
if (unroundedPercentage != roundedPercentage) {
|
||||
log.debug("Rounded requested rate " + unroundedPercentage + "% -> " + roundedPercentage + "%");
|
||||
}
|
||||
PumpState ps = pumpState;
|
||||
int activeTbrPercentage = ps != null ? ps.tbrPercent : 100;
|
||||
if (activeTbrPercentage != -1 && Math.abs(activeTbrPercentage - roundedPercentage) <= 20) {
|
||||
log.debug("Not bothering the pump for a small TBR change from " + activeTbrPercentage + "% -> " + roundedPercentage + "%");
|
||||
PumpEnactResult pumpEnactResult = new PumpEnactResult();
|
||||
pumpEnactResult.success = true;
|
||||
pumpEnactResult.enacted = false;
|
||||
pumpEnactResult.percent = activeTbrPercentage;
|
||||
pumpEnactResult.comment = "TBR change too small, skipping change from " + activeTbrPercentage + "% -> " + roundedPercentage + "%";
|
||||
return pumpEnactResult;
|
||||
}
|
||||
int stepSize = pumpDescription.tempDurationStep;
|
||||
if (durationInMinutes > stepSize) {
|
||||
log.debug("Reducing requested duration of " + durationInMinutes + "m to minimal duration supported by the pump: " + stepSize + "m");
|
||||
|
@ -411,7 +406,6 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
|||
return OPERATION_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
// TODO untested, probably not working
|
||||
@Override
|
||||
public PumpEnactResult cancelTempBasal() {
|
||||
log.debug("cancelTempBasal called");
|
||||
|
|
Loading…
Reference in a new issue