Search in sources :

Example 11 with NamedObjectId

use of org.yamcs.protobuf.Yamcs.NamedObjectId in project yamcs-studio by yamcs.

the class ParameterSubscriptionBundler method run.

@Override
public void run() {
    if (!yamcsClient.isConnected()) {
        return;
    }
    ParameterWebSocketRequest a;
    while ((a = pendingMessages.poll()) != null) {
        while (pendingMessages.peek() != null && isMergeable(a, pendingMessages.peek())) {
            ParameterWebSocketRequest b = pendingMessages.poll();
            a.merge(b);
        }
        CompletableFuture<WebSocketReplyData> future = yamcsClient.getWebSocketClient().sendRequest(a);
        future.whenComplete((reply, exc) -> {
            if (exc != null) {
                log.log(Level.SEVERE, "Server exception while subscribing to parameters", exc);
            } else {
                try {
                    ParameterSubscriptionResponse response = ParameterSubscriptionResponse.parseFrom(reply.getData());
                    for (NamedObjectId id : response.getInvalidList()) {
                        log.fine("No parameter for id " + id);
                    }
                } catch (InvalidProtocolBufferException e) {
                    log.log(Level.WARNING, "Failed to decode parameter subscription response", e);
                }
            }
        });
    }
}
Also used : WebSocketReplyData(org.yamcs.protobuf.Web.WebSocketServerMessage.WebSocketReplyData) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) NamedObjectId(org.yamcs.protobuf.Yamcs.NamedObjectId) ParameterSubscriptionResponse(org.yamcs.protobuf.Web.ParameterSubscriptionResponse)

Example 12 with NamedObjectId

use of org.yamcs.protobuf.Yamcs.NamedObjectId 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

NamedObjectId (org.yamcs.protobuf.Yamcs.NamedObjectId)12 ArrayList (java.util.ArrayList)4 CommandInfo (org.yamcs.protobuf.Mdb.CommandInfo)4 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)3 ColumnPixelData (org.eclipse.jface.viewers.ColumnPixelData)3 TreeViewerColumn (org.eclipse.jface.viewers.TreeViewerColumn)3 GridData (org.eclipse.swt.layout.GridData)3 GridLayout (org.eclipse.swt.layout.GridLayout)3 Composite (org.eclipse.swt.widgets.Composite)3 List (java.util.List)2 TreeColumnLayout (org.eclipse.jface.layout.TreeColumnLayout)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 Viewer (org.eclipse.jface.viewers.Viewer)2 ViewerComparator (org.eclipse.jface.viewers.ViewerComparator)2 Text (org.eclipse.swt.widgets.Text)2 ParameterInfo (org.yamcs.protobuf.Mdb.ParameterInfo)2 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 GradientPaint (java.awt.GradientPaint)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1