Search in sources :

Example 1 with ParameterValue

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("---");
                }
            }
        }
    });
}
Also used : UnitInfo(org.yamcs.protobuf.Mdb.UnitInfo) ParameterTypeInfo(org.yamcs.protobuf.Mdb.ParameterTypeInfo) ParameterValue(org.yamcs.protobuf.Pvalue.ParameterValue)

Example 2 with ParameterValue

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();
        }
    }
}
Also used : ParameterValue(org.yamcs.protobuf.Pvalue.ParameterValue)

Example 3 with ParameterValue

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);
            }
        });
    }
}
Also used : ColumnWeightData(org.eclipse.jface.viewers.ColumnWeightData) ParameterValue(org.yamcs.protobuf.Pvalue.ParameterValue) ArrayList(java.util.ArrayList) ParameterInfo(org.yamcs.protobuf.Mdb.ParameterInfo) Date(java.util.Date) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) ControlListener(org.eclipse.swt.events.ControlListener) ControlEvent(org.eclipse.swt.events.ControlEvent) SimpleDateFormat(java.text.SimpleDateFormat) TableViewerColumn(org.eclipse.jface.viewers.TableViewerColumn)

Example 4 with ParameterValue

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));
    }
}
Also used : ParameterValue(org.yamcs.protobuf.Pvalue.ParameterValue)

Aggregations

ParameterValue (org.yamcs.protobuf.Pvalue.ParameterValue)4 SimpleDateFormat (java.text.SimpleDateFormat)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)1 ColumnWeightData (org.eclipse.jface.viewers.ColumnWeightData)1 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)1 ControlEvent (org.eclipse.swt.events.ControlEvent)1 ControlListener (org.eclipse.swt.events.ControlListener)1 ParameterInfo (org.yamcs.protobuf.Mdb.ParameterInfo)1 ParameterTypeInfo (org.yamcs.protobuf.Mdb.ParameterTypeInfo)1 UnitInfo (org.yamcs.protobuf.Mdb.UnitInfo)1