Search in sources :

Example 1 with AlarmRange

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

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