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();
}
Aggregations