Search in sources :

Example 1 with LinkEvent

use of org.yamcs.protobuf.YamcsManagement.LinkEvent in project yamcs-studio by yamcs.

the class LinkCatalogue method onMessage.

@Override
public void onMessage(WebSocketSubscriptionData msg) {
    if (msg.hasLinkEvent()) {
        LinkEvent linkEvent = msg.getLinkEvent();
        LinkInfo incoming = linkEvent.getLinkInfo();
        LinkId id = new LinkId(incoming);
        switch(linkEvent.getType()) {
            case REGISTERED:
                linksById.put(id, incoming);
                linkListeners.forEach(l -> l.linkRegistered(incoming));
                break;
            case UNREGISTERED:
                LinkInfo linkInfo = linksById.get(id);
                if (linkInfo == null) {
                    log.warning("Request to unregister unknown link " + incoming.getInstance() + "/" + incoming.getName());
                } else {
                    linksById.remove(id);
                    linkListeners.forEach(l -> l.linkUnregistered(incoming));
                }
                break;
            case UPDATED:
                LinkInfo oldLinkInfo = linksById.put(id, incoming);
                if (oldLinkInfo == null) {
                    log.warning("Request to update unknown link " + incoming.getInstance() + "/" + incoming.getName());
                }
                linkListeners.forEach(l -> l.linkUpdated(linkEvent.getLinkInfo()));
                break;
            default:
                log.warning("Unexpected link event " + linkEvent.getType());
        }
    }
}
Also used : LinkEvent(org.yamcs.protobuf.YamcsManagement.LinkEvent) LinkInfo(org.yamcs.protobuf.YamcsManagement.LinkInfo)

Aggregations

LinkEvent (org.yamcs.protobuf.YamcsManagement.LinkEvent)1 LinkInfo (org.yamcs.protobuf.YamcsManagement.LinkInfo)1