Be more cautious handling command failures.
This commit is contained in:
parent
8dd714b390
commit
3aecf0f58b
1 changed files with 19 additions and 6 deletions
|
@ -61,7 +61,7 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
@Nullable
|
@Nullable
|
||||||
volatile PumpState pumpState;
|
volatile PumpState pumpState;
|
||||||
|
|
||||||
volatile String statusSummary = "Initializing";
|
volatile String statusSummary = "No state received yet";
|
||||||
|
|
||||||
private static PumpEnactResult OPERATION_NOT_SUPPORTED = new PumpEnactResult();
|
private static PumpEnactResult OPERATION_NOT_SUPPORTED = new PumpEnactResult();
|
||||||
|
|
||||||
|
@ -311,21 +311,34 @@ public class ComboPlugin implements PluginBase, PumpInterface {
|
||||||
// TODO use this to dispatch methods to a service thread, like DanaRs executionService
|
// TODO use this to dispatch methods to a service thread, like DanaRs executionService
|
||||||
// will be required when doing multiple commands in sequence.
|
// will be required when doing multiple commands in sequence.
|
||||||
// Alternatively provide 'composite commands' to return everything needed in one go?
|
// Alternatively provide 'composite commands' to return everything needed in one go?
|
||||||
|
CommandResult commandResult = null;
|
||||||
try {
|
try {
|
||||||
statusSummary = "Busy running " + command;
|
statusSummary = "Busy running " + command;
|
||||||
pumpState = null;
|
pumpState = null;
|
||||||
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
||||||
CommandResult commandResult = ruffyScripter.runCommand(command);
|
commandResult = ruffyScripter.runCommand(command);
|
||||||
if (commandResult.success && commandResult.state != null) {
|
if (commandResult.success && commandResult.state != null) {
|
||||||
pumpState = commandResult.state;
|
pumpState = commandResult.state;
|
||||||
}
|
}
|
||||||
return commandResult;
|
return commandResult;
|
||||||
} finally {
|
} finally {
|
||||||
lastCmdTime = new Date();
|
lastCmdTime = new Date();
|
||||||
statusSummary = pumpState != null && !pumpState.isErrorOrWarning
|
statusSummary = "Idle";
|
||||||
? "Idle"
|
try {
|
||||||
: "Error: " + pumpState.errorMsg;
|
if (pumpState != null) {
|
||||||
ruffyScripter.disconnect();
|
if (pumpState.errorMsg != null) {
|
||||||
|
statusSummary = "Error: " + pumpState.errorMsg;
|
||||||
|
} else if (pumpState.isErrorOrWarning) {
|
||||||
|
statusSummary = "Error: pump is in error mode, please check pump display";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
statusSummary = "Error";
|
||||||
|
}
|
||||||
|
if (commandResult != null && commandResult.success) {
|
||||||
|
// just leave it open, to avoid more errors
|
||||||
|
ruffyScripter.disconnect();
|
||||||
|
}
|
||||||
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
MainApp.bus().post(new EventComboPumpUpdateGUI());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue