Search in sources :

Example 1 with CommandId

use of org.yamcs.protobuf.Commanding.CommandId in project yamcs-studio by yamcs.

the class CommandFateDialog method main.

public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell();
    shell.setText("dialog test");
    shell.open();
    CommandId cmdId = CommandId.newBuilder().setSequenceNumber(0).setGenerationTime(0).setOrigin("test").build();
    int result = CommandFateDialog.showDialog2(shell);
    System.out.println("result = " + result);
    result = CommandFateDialog.showDialog(shell, cmdId);
    System.out.println("result = " + result);
    result = CommandFateDialog.showDialog2(shell);
    System.out.println("result = " + result);
    result = CommandFateDialog.showDialog(shell, cmdId);
    System.out.println("result = " + result);
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) CommandId(org.yamcs.protobuf.Commanding.CommandId) Display(org.eclipse.swt.widgets.Display)

Example 2 with CommandId

use of org.yamcs.protobuf.Commanding.CommandId in project yamcs-studio by yamcs.

the class CommandHistoryRecordContentProvider method processCommandHistoryEntry.

public void processCommandHistoryEntry(CommandHistoryEntry entry) {
    CommandId commandId = entry.getCommandId();
    CommandHistoryRecord rec;
    boolean create;
    if (recordsByCommandId.containsKey(commandId)) {
        rec = recordsByCommandId.get(commandId);
        create = false;
    } else {
        rec = new CommandHistoryRecord(commandId);
        recordsByCommandId.put(commandId, rec);
        create = true;
    }
    // Autoprocess attributes for additional columns
    for (CommandHistoryAttribute attr : entry.getAttrList()) {
        String shortName = toHumanReadableName(attr);
        if (attr.getName().startsWith(ACKNOWLEDGE_PREFIX)) {
            if (attr.getName().endsWith(ACKNOWLEDGE_STATUS_SUFFIX)) {
                if (attr.getValue().getStringValue().contains("OK")) {
                    rec.addCellImage(shortName, GREEN);
                } else {
                    rec.addCellImage(shortName, RED);
                }
            }
        }
        if (attr.getName().startsWith(VERIFIER_PREFIX)) {
            if (attr.getName().endsWith(VERIFIER_STATUS_SUFFIX)) {
                rec.addVerificationStep(new VerificationStep(rec, shortName, attr));
                if (attr.getValue().getStringValue().contains("OK")) {
                    rec.addCellImage(shortName, GREEN);
                } else {
                    rec.addCellImage(shortName, RED);
                }
            } else if (attr.getName().endsWith(VERIFIER_TIME_SUFFIX)) {
                rec.updateVerificationStepTime(shortName, attr);
            }
        }
        if (attr.getName().equals(ATTR_COMMAND_COMPLETE)) {
            if (attr.getValue().getStringValue().equals("OK")) {
                rec.setCommandState(CommandState.COMPLETED);
            } else {
                rec.setCommandState(CommandState.FAILED);
            }
        } else if (attr.getName().equals(ATTR_FINAL_SEQUENCE_COUNT)) {
            rec.setFinalSequenceCount(attr.getValue());
        } else if (attr.getName().equals(ATTR_SOURCE)) {
            rec.setCommandString(attr.getValue());
        } else if (attr.getName().equals(ATTR_USERNAME)) {
            rec.setUsername(attr.getValue());
        } else if (attr.getName().equals(ATTR_TRANSMISSION_CONSTRAINTS)) {
            rec.getPTVInfo().setState(PTVInfo.State.fromYamcsValue(attr.getValue()));
        } else if (attr.getName().equals(ATTR_COMMAND_FAILED)) {
            rec.getPTVInfo().setFailureMessage(attr.getValue().getStringValue());
        } else if (attr.getName().equals(ATTR_BINARY)) {
            rec.setBinary(attr.getValue().getBinaryValue());
        } else {
            rec.addCellValue(shortName, attr.getValue());
        }
    }
    // All done, make changes visible
    if (create) {
        tableViewer.add(rec);
        maybeSelectAndReveal(rec);
    } else {
        // Null, means all properties
        tableViewer.update(rec, null);
        maybeSelectAndReveal(rec);
    }
}
Also used : CommandId(org.yamcs.protobuf.Commanding.CommandId) CommandHistoryAttribute(org.yamcs.protobuf.Commanding.CommandHistoryAttribute)

Aggregations

CommandId (org.yamcs.protobuf.Commanding.CommandId)2 Display (org.eclipse.swt.widgets.Display)1 Shell (org.eclipse.swt.widgets.Shell)1 CommandHistoryAttribute (org.yamcs.protobuf.Commanding.CommandHistoryAttribute)1