Search in sources :

Example 11 with YamcsClient

use of org.yamcs.studio.core.client.YamcsClient in project yamcs-studio by yamcs.

the class YamcsAuthorizations method isAuthorizationEnabled.

public boolean isAuthorizationEnabled() {
    YamcsClient yamcsClient = YamcsPlugin.getYamcsClient();
    // TODO we should probably control this from the server, rather than here. Just because
    // the creds are null, does not really mean anything. We could also send creds to an
    // unsecured yamcs server. It would just ignore it, and then our client state would
    // be wrong
    YamcsConnectionProperties yprops = yamcsClient.getYamcsConnectionProperties();
    return (yprops == null) ? false : yprops.getAuthenticationToken() != null;
}
Also used : YamcsClient(org.yamcs.studio.core.client.YamcsClient) YamcsConnectionProperties(org.yamcs.api.YamcsConnectionProperties)

Example 12 with YamcsClient

use of org.yamcs.studio.core.client.YamcsClient 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)

Example 13 with YamcsClient

use of org.yamcs.studio.core.client.YamcsClient in project yamcs-studio by yamcs.

the class DisconnectHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    YamcsClient yamcsClient = YamcsPlugin.getYamcsClient();
    yamcsClient.disconnect();
    return null;
}
Also used : YamcsClient(org.yamcs.studio.core.client.YamcsClient)

Example 14 with YamcsClient

use of org.yamcs.studio.core.client.YamcsClient in project yamcs-studio by yamcs.

the class YamcsPlugin method start.

@Override
public void start(BundleContext context) throws Exception {
    super.start(context);
    plugin = this;
    TimeEncoding.setUp();
    yamcsClient = new YamcsClient(getProductString(), true);
    yamcsClient.addConnectionListener(new UIConnectionListener());
    ManagementCatalogue managementCatalogue = new ManagementCatalogue();
    catalogues.put(ManagementCatalogue.class, managementCatalogue);
    addYamcsConnectionListener(managementCatalogue);
    registerCatalogue(new TimeCatalogue());
    registerCatalogue(new ParameterCatalogue());
    registerCatalogue(new CommandingCatalogue());
    registerCatalogue(new AlarmCatalogue());
    registerCatalogue(new EventCatalogue());
    registerCatalogue(new LinkCatalogue());
    registerCatalogue(new ArchiveCatalogue());
}
Also used : ManagementCatalogue(org.yamcs.studio.core.model.ManagementCatalogue) YamcsClient(org.yamcs.studio.core.client.YamcsClient) TimeCatalogue(org.yamcs.studio.core.model.TimeCatalogue) ParameterCatalogue(org.yamcs.studio.core.model.ParameterCatalogue) AlarmCatalogue(org.yamcs.studio.core.model.AlarmCatalogue) EventCatalogue(org.yamcs.studio.core.model.EventCatalogue) CommandingCatalogue(org.yamcs.studio.core.model.CommandingCatalogue) LinkCatalogue(org.yamcs.studio.core.model.LinkCatalogue) ArchiveCatalogue(org.yamcs.studio.core.model.ArchiveCatalogue)

Example 15 with YamcsClient

use of org.yamcs.studio.core.client.YamcsClient in project yamcs-studio by yamcs.

the class AlarmCatalogue method onYamcsConnected.

@Override
public void onYamcsConnected() {
    YamcsClient yamcsClient = YamcsPlugin.getYamcsClient();
    yamcsClient.subscribe(new WebSocketRequest("alarms", "subscribe"), this);
}
Also used : YamcsClient(org.yamcs.studio.core.client.YamcsClient) WebSocketRequest(org.yamcs.api.ws.WebSocketRequest)

Aggregations

YamcsClient (org.yamcs.studio.core.client.YamcsClient)31 WebSocketRequest (org.yamcs.api.ws.WebSocketRequest)6 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)4 URLBuilder (org.yamcs.studio.core.client.URLBuilder)3 YamcsConnectionProperties (org.yamcs.api.YamcsConnectionProperties)2 EditLinkRequest (org.yamcs.protobuf.Rest.EditLinkRequest)2 ArchiveCatalogue (org.yamcs.studio.core.model.ArchiveCatalogue)2 TimeCatalogue (org.yamcs.studio.core.model.TimeCatalogue)2 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