Search in sources :

Example 1 with SignificanceInfo

use of org.yamcs.protobuf.Mdb.SignificanceInfo in project yamcs-studio by yamcs.

the class AddToStackWizardPage1 method getMessage.

public static String getMessage(CommandInfo cmd) {
    if (cmd == null)
        return null;
    StringBuilder buf = new StringBuilder();
    buf.append(cmd.getQualifiedName());
    SignificanceInfo significance = cmd.getSignificance();
    if (significance != null) {
        buf.append("\n");
        if (significance.getConsequenceLevel() != SignificanceLevelType.NONE) {
            buf.append("[");
            buf.append(significance.getConsequenceLevel().toString());
            buf.append("] ");
        }
        if (significance.getReasonForWarning() != null) {
            buf.append(significance.getReasonForWarning());
        }
        return buf.toString();
    } else {
        return null;
    }
}
Also used : SignificanceInfo(org.yamcs.protobuf.Mdb.SignificanceInfo)

Example 2 with SignificanceInfo

use of org.yamcs.protobuf.Mdb.SignificanceInfo 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();
            });
        }
    });
}
Also used : SignificanceInfo(org.yamcs.protobuf.Mdb.SignificanceInfo) UnsupportedEncodingException(java.io.UnsupportedEncodingException) CommandingCatalogue(org.yamcs.studio.core.model.CommandingCatalogue) ExecutionException(org.eclipse.core.commands.ExecutionException) IssueCommandRequest(org.yamcs.protobuf.Rest.IssueCommandRequest)

Aggregations

SignificanceInfo (org.yamcs.protobuf.Mdb.SignificanceInfo)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 ExecutionException (org.eclipse.core.commands.ExecutionException)1 IssueCommandRequest (org.yamcs.protobuf.Rest.IssueCommandRequest)1 CommandingCatalogue (org.yamcs.studio.core.model.CommandingCatalogue)1