use of org.yamcs.protobuf.Pvalue.ParameterValue in project yamcs-studio by yamcs.
the class PVComposite method onParameterData.
// TODO move this onto a digest thread. We shouldn't update GUI for _every_ value.
@Override
public void onParameterData(ParameterData pdata) {
if (isDisposed()) {
return;
}
getDisplay().asyncExec(() -> {
if (isDisposed()) {
return;
}
for (ParameterValue pval : pdata.getParameterList()) {
if (pval.getId().getName().equals(pvInfo.getDisplayName())) {
gentimeField.setText(pval.getGenerationTimeUTC());
rectimeField.setText(pval.getAcquisitionTimeUTC());
String engValue = StringConverter.toString(pval.getEngValue(), false);
if (pvInfo.getParameterInfo().hasType()) {
ParameterTypeInfo ptype = pvInfo.getParameterInfo().getType();
if (ptype.getUnitSetCount() > 0) {
for (UnitInfo unitInfo : ptype.getUnitSetList()) {
engValue += " " + unitInfo.getUnit();
}
}
}
engValueField.setText(engValue);
engTypeField.setText(capitalize(pval.getEngValue().getType().toString()));
if (pval.hasAcquisitionStatus()) {
statusField.setText(pval.getAcquisitionStatus().toString());
} else {
statusField.setText("---");
}
if (pval.hasRawValue()) {
rawValueField.setText(StringConverter.toString(pval.getRawValue(), false));
rawTypeField.setText(capitalize(pval.getRawValue().getType().toString()));
} else {
rawValueField.setText("---");
rawTypeField.setText("---");
}
}
}
});
}
use of org.yamcs.protobuf.Pvalue.ParameterValue in project yamcs-studio by yamcs.
the class SeverityHandlerSound method onParameterData.
@Override
public void onParameterData(ParameterData pdata) {
for (ParameterValue pval : pdata.getParameterList()) {
// Do not beep
if ("NONE".equals(triggerCondition))
return;
// Beep only at the first occurrence of the parameter out-of-limit
boolean shouldBeep = pval.getMonitoringResult() != null && pval.getMonitoringResult().getNumber() >= beepLevel;
if ("FIRST".equals(triggerCondition)) {
ParameterValue previousPval = pvals.get(pval.getId().getName());
if (previousPval != null) {
pvals.remove(previousPval);
if (previousPval.getMonitoringResult() != null && pval.getMonitoringResult() != null && previousPval.getMonitoringResult().getNumber() >= pval.getMonitoringResult().getNumber())
shouldBeep = false;
}
pvals.put(pval.getId().getName(), pval);
}
// Beep at each occurrence of the parameter out-of-limit
if (shouldBeep) {
// System.out.println("beeping for parameter "
// + pval.getId().getName());
SoundSystem.beep();
}
}
}
use of org.yamcs.protobuf.Pvalue.ParameterValue in project yamcs-studio by yamcs.
the class ParameterTableViewer method addFixedColumns.
private void addFixedColumns(TableColumnLayout tcl) {
TableViewerColumn nameColumn = new TableViewerColumn(this, SWT.LEFT);
nameColumn.getColumn().setText(COL_NAME);
tcl.setColumnData(nameColumn.getColumn(), new ColumnWeightData(40));
nameColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ParameterInfo cnt = (ParameterInfo) element;
return cnt.getQualifiedName();
}
});
TableViewerColumn engValueColumn = new TableViewerColumn(this, SWT.RIGHT);
engValueColumn.getColumn().setText(COL_ENG);
tcl.setColumnData(engValueColumn.getColumn(), new ColumnWeightData(10));
engValueColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ParameterReader reader = readers.get(element);
if (reader == null || reader.getValue() == null)
return "-";
ParameterValue value = reader.getValue();
return String.valueOf(getValue(value.getEngValue()));
}
});
TableViewerColumn rawValueColumn = new TableViewerColumn(this, SWT.RIGHT);
rawValueColumn.getColumn().setText(COL_RAW);
tcl.setColumnData(rawValueColumn.getColumn(), new ColumnWeightData(10));
rawValueColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ParameterReader reader = readers.get(element);
if (reader == null || reader.getValue() == null)
return "-";
ParameterValue value = reader.getValue();
return String.valueOf(getValue(value.getRawValue()));
}
});
TableViewerColumn gentimeValueColumn = new TableViewerColumn(this, SWT.LEFT);
gentimeValueColumn.getColumn().setText(COL_TIME);
tcl.setColumnData(gentimeValueColumn.getColumn(), new ColumnWeightData(20));
gentimeValueColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ParameterReader reader = readers.get(element);
if (reader == null || reader.getValue() == null)
return "-";
ParameterValue value = reader.getValue();
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Date time = new Date(value.getGenerationTime());
String strDate = sdfDate.format(time);
return strDate;
}
});
TableViewerColumn aqutimeValueColumn = new TableViewerColumn(this, SWT.LEFT);
aqutimeValueColumn.getColumn().setText(COL_AQU_TIME);
tcl.setColumnData(aqutimeValueColumn.getColumn(), new ColumnWeightData(20));
aqutimeValueColumn.setLabelProvider(new ColumnLabelProvider() {
@Override
public String getText(Object element) {
ParameterReader reader = readers.get(element);
if (reader == null || reader.getValue() == null)
return "-";
ParameterValue value = reader.getValue();
SimpleDateFormat sdfDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
Date time = new Date(value.getAcquisitionTime());
String strDate = sdfDate.format(time);
return strDate;
}
});
// Common properties to all columns
List<TableViewerColumn> columns = new ArrayList<>();
columns.add(nameColumn);
columns.add(engValueColumn);
columns.add(rawValueColumn);
columns.add(gentimeValueColumn);
columns.add(aqutimeValueColumn);
for (TableViewerColumn column : columns) {
// prevent resize to 0
column.getColumn().addControlListener(new ControlListener() {
@Override
public void controlMoved(ControlEvent e) {
}
@Override
public void controlResized(ControlEvent e) {
if (column.getColumn().getWidth() < 5)
column.getColumn().setWidth(5);
}
});
}
}
use of org.yamcs.protobuf.Pvalue.ParameterValue in project yamcs-studio by yamcs.
the class ActiveAlarmsContentProvider method processActiveAlarm.
/**
* Fits the new or updated alarm data in the current model
*/
void processActiveAlarm(AlarmData alarmData) {
ParameterValue triggerValue = alarmData.getTriggerValue();
String qname = triggerValue.getId().getName();
if (!qname.startsWith("/")) {
throw new IllegalArgumentException("Unexpected alarm id " + qname);
}
String[] parts = qname.split("\\/");
boolean isDirectLeaf = parts.length == 1;
if (isDirectLeaf) {
String name = parts[1];
roots.put(name, new XtceAlarmNode(null, name, alarmData));
} else {
XtceSubSystemNode root = findOrCreateRootSpaceSystem(parts[1]);
XtceSubSystemNode parent = root;
for (int i = 2; i < parts.length - 1; i++) {
XtceTreeNode node = parent.getChild(parts[i]);
if (node == null) {
node = new XtceSubSystemNode(parent, parts[i]);
parent.addChild(node);
}
parent = (XtceSubSystemNode) node;
}
String name = parts[parts.length - 1];
parent.addChild(new XtceAlarmNode(parent, name, alarmData));
}
}
Aggregations