use of org.yamcs.protobuf.Commanding.CommandHistoryAttribute 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);
}
}
use of org.yamcs.protobuf.Commanding.CommandHistoryAttribute in project yamcs-studio by yamcs.
the class CommandHistoryView method processCommandHistoryEntry.
public void processCommandHistoryEntry(CommandHistoryEntry cmdhistEntry) {
// Maybe we need to update structure
for (CommandHistoryAttribute attr : cmdhistEntry.getAttrList()) {
if (IGNORED_ATTRIBUTES.contains(attr.getName()))
continue;
String shortName = CommandHistoryRecordContentProvider.toHumanReadableName(attr);
if (!dynamicColumns.contains(shortName)) {
TableViewerColumn column = new TableViewerColumn(tableViewer, SWT.LEFT);
column.getColumn().setText(shortName);
column.getColumn().addSelectionListener(getSelectionAdapter(column.getColumn()));
column.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
return ((CommandHistoryRecord) element).getTextForColumn(shortName, showRelativeTime);
}
@Override
public String getToolTipText(Object element) {
return ((CommandHistoryRecord) element).getTooltipForColumn(shortName);
}
@Override
public Image getImage(Object element) {
String imgLoc = ((CommandHistoryRecord) element).getImageForColumn(shortName);
if (CommandHistoryRecordContentProvider.GREEN.equals(imgLoc))
return greenBubble;
else if (CommandHistoryRecordContentProvider.RED.equals(imgLoc))
return redBubble;
else
return null;
}
});
dynamicColumns.add(shortName);
tableLayout.addColumnData(new ColumnPixelData(90));
column.getColumn().setWidth(90);
column.getColumn().addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
checkMinWidth(column.getColumn());
}
});
}
}
// Now add content
tableContentProvider.processCommandHistoryEntry(cmdhistEntry);
updateSummaryLine();
}
Aggregations