Search in sources :

Example 1 with ParameterTypeInfo

use of org.yamcs.protobuf.Mdb.ParameterTypeInfo 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 ParameterTypeInfo

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

the class PVComposite method createYamcsProperties.

private void createYamcsProperties(ParameterInfo pinfo) {
    createKeyValueTextPair("Yamcs Data Source", capitalize(pinfo.getDataSource().toString()));
    createKeyValueTextPair("Qualified Name", pinfo.getQualifiedName());
    for (int i = 0; i < pinfo.getAliasCount(); i++) {
        NamedObjectId alias = pinfo.getAlias(i);
        String key = (i == 0) ? "Aliases" : null;
        createKeyValueTextPair(key, alias.getNamespace() + "; " + alias.getName());
    }
    if (pinfo.hasShortDescription()) {
        createKeyValueTextPair("Short Description", pinfo.getShortDescription());
    }
    if (pinfo.hasLongDescription()) {
        createKeyValueTextPair("Long Description", pinfo.getLongDescription());
    }
    createSeparator();
    createHeader("MDB");
    ParameterTypeInfo type = pinfo.getType();
    createKeyValueTextPair("Data Encoding", capitalize(type.getDataEncoding().getType().toString()));
    createKeyValueTextPair("Engineering Type", capitalize(type.getEngType()));
    if (type.getUnitSetCount() > 0) {
        String units = "";
        for (UnitInfo unit : type.getUnitSetList()) {
            units += unit.getUnit() + " ";
        }
        createKeyValueTextPair("Units", units);
    }
    if (type.getDefaultAlarm() != null && type.getDefaultAlarm().getStaticAlarmRangeCount() > 0) {
        createSeparator();
        createHeader("Default Alarm");
        AlarmInfo defaultAlarm = type.getDefaultAlarm();
        createKeyValueTextPair("Min. Violations", "" + defaultAlarm.getMinViolations());
        // Backwards for lower limits
        for (int i = defaultAlarm.getStaticAlarmRangeCount() - 1; i >= 0; i--) {
            AlarmRange range = defaultAlarm.getStaticAlarmRange(i);
            if (range.hasMinInclusive()) {
                String label = capitalize(range.getLevel().toString()) + " Low";
                String limit = new DecimalFormat("#.############").format(range.getMinInclusive());
                createKeyValueTextPair(label, limit);
            }
        }
        // Now forwards for upper limits
        for (AlarmRange range : defaultAlarm.getStaticAlarmRangeList()) {
            if (range.hasMaxInclusive()) {
                String label = capitalize(range.getLevel().toString()) + " High";
                String limit = new DecimalFormat("#.############").format(range.getMaxInclusive());
                createKeyValueTextPair(label, limit);
            }
        }
    }
    createSeparator();
    createHeader("Last Received Value");
    // Anybody knows better way to reserve space??
    gentimeField = createKeyValueTextPair("Generation Time", "---                                             ");
    rectimeField = createKeyValueTextPair("Reception Time", "---                                             ");
    statusField = createKeyValueTextPair("Status", "---                                             ");
    engValueField = createKeyValueTextPair("Engineering Value", "---                                             ");
    engTypeField = createKeyValueTextPair("Engineering Type", "---                                             ");
    rawValueField = createKeyValueTextPair("Raw Value", "---                                             ");
    rawTypeField = createKeyValueTextPair("Raw Type", "---                                             ");
}
Also used : UnitInfo(org.yamcs.protobuf.Mdb.UnitInfo) AlarmRange(org.yamcs.protobuf.Mdb.AlarmRange) ParameterTypeInfo(org.yamcs.protobuf.Mdb.ParameterTypeInfo) DecimalFormat(java.text.DecimalFormat) AlarmInfo(org.yamcs.protobuf.Mdb.AlarmInfo) NamedObjectId(org.yamcs.protobuf.Yamcs.NamedObjectId)

Aggregations

ParameterTypeInfo (org.yamcs.protobuf.Mdb.ParameterTypeInfo)2 UnitInfo (org.yamcs.protobuf.Mdb.UnitInfo)2 DecimalFormat (java.text.DecimalFormat)1 AlarmInfo (org.yamcs.protobuf.Mdb.AlarmInfo)1 AlarmRange (org.yamcs.protobuf.Mdb.AlarmRange)1 ParameterValue (org.yamcs.protobuf.Pvalue.ParameterValue)1 NamedObjectId (org.yamcs.protobuf.Yamcs.NamedObjectId)1