Search in sources :

Example 1 with ArgumentAssignmentInfo

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

the class StackedCommand method getEffectiveAssignments.

public Collection<TelecommandArgument> getEffectiveAssignments() {
    // We want this to be top-down, as-defined in mdb
    Map<String, TelecommandArgument> argumentsByName = new LinkedHashMap<>();
    List<CommandInfo> hierarchy = new ArrayList<>();
    hierarchy.add(meta);
    CommandInfo base = meta;
    while (base.getBaseCommand() != null) {
        base = base.getBaseCommand();
        hierarchy.add(0, base);
    }
    // From parent to child. Children can override initial values (= defaults)
    for (CommandInfo cmd : hierarchy) {
        // Set all values, even if null initial value. This gives us consistent ordering
        for (ArgumentInfo argument : cmd.getArgumentList()) {
            String name = argument.getName();
            String value = argument.hasInitialValue() ? argument.getInitialValue() : null;
            boolean editable = true;
            argumentsByName.put(name, new TelecommandArgument(name, value, editable));
        }
        // TODO this should return an empty list in yamcs. Not null
        if (cmd.getArgumentAssignmentList() != null)
            for (ArgumentAssignmentInfo argumentAssignment : cmd.getArgumentAssignmentList()) {
                String name = argumentAssignment.getName();
                String value = argumentAssignment.getValue();
                boolean editable = (cmd == meta);
                argumentsByName.put(name, new TelecommandArgument(name, value, editable));
            }
    }
    return argumentsByName.values();
}
Also used : CommandInfo(org.yamcs.protobuf.Mdb.CommandInfo) ArrayList(java.util.ArrayList) StyledString(org.eclipse.jface.viewers.StyledString) ArgumentAssignmentInfo(org.yamcs.protobuf.Mdb.ArgumentAssignmentInfo) ArgumentInfo(org.yamcs.protobuf.Mdb.ArgumentInfo) LinkedHashMap(java.util.LinkedHashMap)

Aggregations

ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 StyledString (org.eclipse.jface.viewers.StyledString)1 ArgumentAssignmentInfo (org.yamcs.protobuf.Mdb.ArgumentAssignmentInfo)1 ArgumentInfo (org.yamcs.protobuf.Mdb.ArgumentInfo)1 CommandInfo (org.yamcs.protobuf.Mdb.CommandInfo)1