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));
}
}
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;
}
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);
}
});
}
Aggregations