Search in sources :

Example 1 with ParameterSubscriptionResponse

use of org.yamcs.protobuf.Web.ParameterSubscriptionResponse 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)

Aggregations

InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 ParameterSubscriptionResponse (org.yamcs.protobuf.Web.ParameterSubscriptionResponse)1 WebSocketReplyData (org.yamcs.protobuf.Web.WebSocketServerMessage.WebSocketReplyData)1 NamedObjectId (org.yamcs.protobuf.Yamcs.NamedObjectId)1