use of org.yamcs.protobuf.Rest.IssueCommandRequest in project yamcs-studio by yamcs.
the class ArmCommandHandler method armCommand.
private void armCommand(Shell activeShell, CommandStackView view, StackedCommand command) throws ExecutionException {
IssueCommandRequest req = command.toIssueCommandRequest().setDryRun(true).build();
CommandingCatalogue catalogue = CommandingCatalogue.getInstance();
String qname;
try {
qname = command.getSelectedAliasEncoded();
} catch (UnsupportedEncodingException e1) {
throw new ExecutionException(e1.getMessage());
}
catalogue.sendCommand("realtime", qname, req).whenComplete((data, exc) -> {
if (exc == null) {
Display.getDefault().asyncExec(() -> {
boolean doArm = false;
SignificanceInfo significance = command.getMetaCommand().getSignificance();
switch(significance.getConsequenceLevel()) {
case WATCH:
case WARNING:
case DISTRESS:
case CRITICAL:
case SEVERE:
String level = Character.toUpperCase(significance.getConsequenceLevel().toString().charAt(0)) + significance.getConsequenceLevel().toString().substring(1);
if (MessageDialog.openConfirm(activeShell, "Confirm", level + ": Are you sure you want to arm this command?\n" + " " + command.toStyledString(view).getString() + "\n\n" + significance.getReasonForWarning())) {
doArm = true;
}
break;
case NONE:
doArm = true;
break;
default:
throw new IllegalStateException("Unexpected significance level " + significance.getConsequenceLevel());
}
if (doArm) {
log.info(String.format("Command armed %s", command));
command.setStackedState(StackedState.ARMED);
view.refreshState();
}
});
} else {
Display.getDefault().asyncExec(() -> {
command.setStackedState(StackedState.REJECTED);
view.clearArm();
view.refreshState();
});
}
});
}
use of org.yamcs.protobuf.Rest.IssueCommandRequest in project yamcs-studio by yamcs.
the class IssueCommandHandler method issueCommand.
private void issueCommand(Shell activeShell, CommandStackView view, StackedCommand command) throws ExecutionException {
IssueCommandRequest req = command.toIssueCommandRequest().build();
CommandingCatalogue catalogue = CommandingCatalogue.getInstance();
String qname;
try {
qname = command.getSelectedAliasEncoded();
} catch (UnsupportedEncodingException e1) {
throw new ExecutionException(e1.getMessage());
}
catalogue.sendCommand("realtime", qname, req).whenComplete((data, exc) -> {
if (exc == null) {
Display.getDefault().asyncExec(() -> {
log.info(String.format("Command issued. %s", req));
command.setStackedState(StackedState.ISSUED);
view.selectActiveCommand();
view.refreshState();
});
} else {
Display.getDefault().asyncExec(() -> {
command.setStackedState(StackedState.REJECTED);
view.refreshState();
});
}
});
}
Aggregations