Search in sources :

Example 1 with YamcsInstance

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

the class ManagementCatalogue method onMessage.

@Override
public void onMessage(WebSocketSubscriptionData msg) {
    if (msg.hasConnectionInfo()) {
        ConnectionInfo connectionInfo = msg.getConnectionInfo();
        YamcsInstance instance = connectionInfo.getInstance();
        log.fine("Instance " + instance.getName() + ": " + instance.getState());
        managementListeners.forEach(l -> l.instanceUpdated(connectionInfo));
    }
    if (msg.hasClientInfo()) {
        ClientInfo clientInfo = msg.getClientInfo();
        if (clientInfo.getState() == ClientState.DISCONNECTED) {
            ClientInfo previousClientInfo = clientInfoById.remove(clientInfo.getId());
            checkOwnClientState(previousClientInfo, clientInfo);
            managementListeners.forEach(l -> l.clientDisconnected(clientInfo));
        } else {
            ClientInfo previousClientInfo = clientInfoById.put(clientInfo.getId(), clientInfo);
            checkOwnClientState(previousClientInfo, clientInfo);
            managementListeners.forEach(l -> l.clientUpdated(clientInfo));
        }
    }
    if (msg.hasProcessorInfo()) {
        ProcessorInfo processorInfo = msg.getProcessorInfo();
        String instance = processorInfo.getInstance();
        Map<String, ProcessorInfo> instanceProcessors = processorInfoByInstance.get(instance);
        if (instanceProcessors == null) {
            instanceProcessors = new ConcurrentHashMap<>();
            processorInfoByInstance.put(instance, instanceProcessors);
        }
        if (processorInfo.getState() == ServiceState.TERMINATED) {
            instanceProcessors.remove(processorInfo.getName());
        } else {
            instanceProcessors.put(processorInfo.getName(), processorInfo);
        }
        managementListeners.forEach(l -> l.processorUpdated(processorInfo));
    }
    if (msg.hasStatistics()) {
        Statistics statistics = msg.getStatistics();
        managementListeners.forEach(l -> l.statisticsUpdated(statistics));
    }
}
Also used : ProcessorInfo(org.yamcs.protobuf.YamcsManagement.ProcessorInfo) YamcsInstance(org.yamcs.protobuf.YamcsManagement.YamcsInstance) ConnectionInfo(org.yamcs.protobuf.Web.ConnectionInfo) ClientInfo(org.yamcs.protobuf.YamcsManagement.ClientInfo) Statistics(org.yamcs.protobuf.YamcsManagement.Statistics)

Example 2 with YamcsInstance

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

the class ProcessingInfoDialogHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    Shell shell = HandlerUtil.getActiveShellChecked(event);
    ManagementCatalogue catalogue = ManagementCatalogue.getInstance();
    ProcessorInfo processor = catalogue.getCurrentProcessorInfo();
    if (processor != null) {
        catalogue.fetchInstanceInformationRequest(processor.getInstance()).whenComplete((data, exc) -> {
            if (exc == null) {
                Display display = Display.getDefault();
                if (!display.isDisposed()) {
                    display.asyncExec(() -> {
                        try {
                            YamcsInstance instance = YamcsInstance.parseFrom(data);
                            new ProcessingInfoDialog(shell, instance, processor).open();
                        } catch (InvalidProtocolBufferException e) {
                            log.log(Level.SEVERE, "Failed to decode server message", e);
                        }
                    });
                }
            }
        });
    }
    return null;
}
Also used : ManagementCatalogue(org.yamcs.studio.core.model.ManagementCatalogue) Shell(org.eclipse.swt.widgets.Shell) ProcessorInfo(org.yamcs.protobuf.YamcsManagement.ProcessorInfo) YamcsInstance(org.yamcs.protobuf.YamcsManagement.YamcsInstance) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) Display(org.eclipse.swt.widgets.Display)

Example 3 with YamcsInstance

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

the class ProcessorStatusLineContributionItem method instanceUpdated.

@Override
public void instanceUpdated(ConnectionInfo connectionInfo) {
    Display.getDefault().asyncExec(() -> {
        YamcsInstance instance = connectionInfo.getInstance();
        // TODO don't get processor??
        String baseText = instance.getName();
        switch(instance.getState()) {
            case NEW:
            case STARTING:
                // setText("Starting " + instance.getName()); // TODO text currently managed by processorInfo events
                break;
            case STOPPING:
                setErrorText(baseText + " (stopping...)", null);
                break;
            case TERMINATED:
                setErrorText(baseText + " (terminated)", null);
                break;
            case FAILED:
                String detail = (instance.hasFailureCause() ? instance.getFailureCause() : null);
                setErrorText(baseText + " (start failure)", detail);
                break;
            case RUNNING:
                setErrorText(null, null);
                break;
            default:
                log.warning("Unexpected instance state " + instance.getState());
                setErrorText(null, null);
        }
    });
}
Also used : YamcsInstance(org.yamcs.protobuf.YamcsManagement.YamcsInstance)

Aggregations

YamcsInstance (org.yamcs.protobuf.YamcsManagement.YamcsInstance)3 ProcessorInfo (org.yamcs.protobuf.YamcsManagement.ProcessorInfo)2 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 Display (org.eclipse.swt.widgets.Display)1 Shell (org.eclipse.swt.widgets.Shell)1 ConnectionInfo (org.yamcs.protobuf.Web.ConnectionInfo)1 ClientInfo (org.yamcs.protobuf.YamcsManagement.ClientInfo)1 Statistics (org.yamcs.protobuf.YamcsManagement.Statistics)1 ManagementCatalogue (org.yamcs.studio.core.model.ManagementCatalogue)1