Search in sources :

Example 1 with CommandHistoryEntry

use of org.yamcs.protobuf.Commanding.CommandHistoryEntry in project yamcs-studio by yamcs.

the class CommandingCatalogue method onMessage.

@Override
public void onMessage(WebSocketSubscriptionData msg) {
    if (msg.hasCommand()) {
        CommandHistoryEntry cmdhistEntry = msg.getCommand();
        cmdhistListeners.forEach(l -> l.processCommandHistoryEntry(cmdhistEntry));
    }
    if (msg.hasCommandQueueEvent()) {
        CommandQueueEvent queueEvent = msg.getCommandQueueEvent();
        switch(queueEvent.getType()) {
            case COMMAND_ADDED:
                queueListeners.forEach(l -> l.commandAdded(queueEvent.getData()));
                break;
            case COMMAND_REJECTED:
                queueListeners.forEach(l -> l.commandRejected(queueEvent.getData()));
                break;
            case COMMAND_SENT:
                queueListeners.forEach(l -> l.commandSent(queueEvent.getData()));
                break;
            default:
                log.log(Level.SEVERE, "Unsupported queue event type " + queueEvent.getType());
        }
    }
    if (msg.hasCommandQueueInfo()) {
        CommandQueueInfo queueInfo = msg.getCommandQueueInfo();
        queuesByName.put(queueInfo.getName(), queueInfo);
        queueListeners.forEach(l -> l.updateQueue(queueInfo));
    }
}
Also used : CommandHistoryEntry(org.yamcs.protobuf.Commanding.CommandHistoryEntry) CommandQueueEvent(org.yamcs.protobuf.Commanding.CommandQueueEvent) CommandQueueInfo(org.yamcs.protobuf.Commanding.CommandQueueInfo)

Example 2 with CommandHistoryEntry

use of org.yamcs.protobuf.Commanding.CommandHistoryEntry in project yamcs-studio by yamcs.

the class ImportPastCommandsDialog method okPressed.

@Override
protected void okPressed() {
    YamcsClient yamcsClient = YamcsPlugin.getYamcsClient();
    if (yamcsClient == null) {
        MessageDialog.openError(Display.getCurrent().getActiveShell(), "Could not import commands\n", "Disconnected from Yamcs");
        return;
    }
    getButton(IDialogConstants.OK_ID).setEnabled(false);
    long start = TimeEncoding.fromCalendar(RCPUtils.toCalendar(startDate, startTime));
    long stop = TimeEncoding.fromCalendar(RCPUtils.toCalendar(stopDate, stopTime));
    TimeInterval interval = new TimeInterval(start, stop);
    ArchiveCatalogue catalogue = ArchiveCatalogue.getInstance();
    catalogue.downloadCommands(interval, data -> {
        try {
            CommandHistoryEntry commandHistoryEntry = CommandHistoryEntry.parseFrom(data);
            Display.getDefault().asyncExec(() -> {
                cmdhistView.processCommandHistoryEntry(commandHistoryEntry);
            });
        } catch (InvalidProtocolBufferException e) {
            throw new YamcsApiException("Failed to decode server message", e);
        }
    }).whenComplete((data, exc) -> {
        if (exc == null) {
            Display.getDefault().asyncExec(() -> {
                ImportPastCommandsDialog.super.okPressed();
            });
        } else {
            getButton(IDialogConstants.OK_ID).setEnabled(true);
        }
    });
}
Also used : YamcsApiException(org.yamcs.api.YamcsApiException) IDialogConstants(org.eclipse.jface.dialogs.IDialogConstants) CommandHistoryEntry(org.yamcs.protobuf.Commanding.CommandHistoryEntry) YamcsClient(org.yamcs.studio.core.client.YamcsClient) Calendar(java.util.Calendar) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) DateTime(org.eclipse.swt.widgets.DateTime) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) YamcsPlugin(org.yamcs.studio.core.YamcsPlugin) ArchiveCatalogue(org.yamcs.studio.core.model.ArchiveCatalogue) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) Shell(org.eclipse.swt.widgets.Shell) TimeCatalogue(org.yamcs.studio.core.model.TimeCatalogue) TimeInterval(org.yamcs.studio.core.TimeInterval) Display(org.eclipse.swt.widgets.Display) List(java.util.List) RowLayout(org.eclipse.swt.layout.RowLayout) TitleAreaDialog(org.eclipse.jface.dialogs.TitleAreaDialog) TimeEncoding(org.yamcs.utils.TimeEncoding) SWT(org.eclipse.swt.SWT) RCPUtils(org.yamcs.studio.core.ui.utils.RCPUtils) Label(org.eclipse.swt.widgets.Label) Control(org.eclipse.swt.widgets.Control) GridLayout(org.eclipse.swt.layout.GridLayout) YamcsApiException(org.yamcs.api.YamcsApiException) YamcsClient(org.yamcs.studio.core.client.YamcsClient) TimeInterval(org.yamcs.studio.core.TimeInterval) CommandHistoryEntry(org.yamcs.protobuf.Commanding.CommandHistoryEntry) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) ArchiveCatalogue(org.yamcs.studio.core.model.ArchiveCatalogue)

Aggregations

CommandHistoryEntry (org.yamcs.protobuf.Commanding.CommandHistoryEntry)2 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)1 Calendar (java.util.Calendar)1 List (java.util.List)1 IDialogConstants (org.eclipse.jface.dialogs.IDialogConstants)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1 TitleAreaDialog (org.eclipse.jface.dialogs.TitleAreaDialog)1 SWT (org.eclipse.swt.SWT)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 RowLayout (org.eclipse.swt.layout.RowLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Control (org.eclipse.swt.widgets.Control)1 DateTime (org.eclipse.swt.widgets.DateTime)1 Display (org.eclipse.swt.widgets.Display)1 Label (org.eclipse.swt.widgets.Label)1 Shell (org.eclipse.swt.widgets.Shell)1 YamcsApiException (org.yamcs.api.YamcsApiException)1 CommandQueueEvent (org.yamcs.protobuf.Commanding.CommandQueueEvent)1 CommandQueueInfo (org.yamcs.protobuf.Commanding.CommandQueueInfo)1