Search in sources :

Example 1 with TimeInterval

use of org.yamcs.studio.core.TimeInterval in project yamcs-studio by yamcs.

the class ArchiveIndexReceiver method getIndex.

public void getIndex(TimeInterval interval) {
    if (receiving) {
        log.info("already receiving data");
        return;
    }
    ArchiveCatalogue catalogue = ArchiveCatalogue.getInstance();
    catalogue.downloadIndexes(interval, data -> {
        try {
            IndexResult response = IndexResult.parseFrom(data);
            log.fine(String.format("Received %d archive records", response.getRecordsCount()));
            archiveView.receiveArchiveRecords(response);
        } catch (InvalidProtocolBufferException e) {
            throw new YamcsApiException("Failed to decode server message", e);
        }
    }).whenComplete((data, exc) -> {
        if (exc == null) {
            log.info("Done receiving archive records.");
            archiveView.receiveArchiveRecordsFinished();
            receiving = false;
        } else {
            archiveView.receiveArchiveRecordsError(exc.toString());
        }
    });
}
Also used : EditTagRequest(org.yamcs.protobuf.Rest.EditTagRequest) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) YamcsApiException(org.yamcs.api.YamcsApiException) ArchiveTag(org.yamcs.protobuf.Yamcs.ArchiveTag) TimeInterval(org.yamcs.studio.core.TimeInterval) TimeEncoding(org.yamcs.utils.TimeEncoding) ListTagsResponse(org.yamcs.protobuf.Rest.ListTagsResponse) Logger(java.util.logging.Logger) CreateTagRequest(org.yamcs.protobuf.Rest.CreateTagRequest) IndexResult(org.yamcs.protobuf.Yamcs.IndexResult) ArchiveCatalogue(org.yamcs.studio.core.model.ArchiveCatalogue) Level(java.util.logging.Level) YamcsApiException(org.yamcs.api.YamcsApiException) InvalidProtocolBufferException(com.google.protobuf.InvalidProtocolBufferException) IndexResult(org.yamcs.protobuf.Yamcs.IndexResult) ArchiveCatalogue(org.yamcs.studio.core.model.ArchiveCatalogue)

Example 2 with TimeInterval

use of org.yamcs.studio.core.TimeInterval in project yamcs-studio by yamcs.

the class ArchiveView method createActions.

private void createActions() {
    IActionBars bars = getViewSite().getActionBars();
    IMenuManager mgr = bars.getMenuManager();
    mgr.add(new Action("Last day", IAction.AS_RADIO_BUTTON) {

        @Override
        public void run() {
            if (isChecked()) {
                Calendar cal = TimeCatalogue.getInstance().getMissionTimeAsCalendar(true);
                cal.add(Calendar.DAY_OF_MONTH, -1);
                cal.set(Calendar.HOUR_OF_DAY, 0);
                cal.set(Calendar.MINUTE, 0);
                cal.set(Calendar.SECOND, 0);
                cal.set(Calendar.MILLISECOND, 0);
                doFilter(TimeInterval.starting(TimeEncoding.fromCalendar(cal)));
            }
        }
    });
    mgr.add(new Action("Last week", IAction.AS_RADIO_BUTTON) {

        @Override
        public void run() {
            if (isChecked()) {
                Calendar cal = TimeCatalogue.getInstance().getMissionTimeAsCalendar(true);
                cal.add(Calendar.DAY_OF_MONTH, -7);
                cal.set(Calendar.HOUR_OF_DAY, 0);
                cal.set(Calendar.MINUTE, 0);
                cal.set(Calendar.SECOND, 0);
                cal.set(Calendar.MILLISECOND, 0);
                doFilter(TimeInterval.starting(TimeEncoding.fromCalendar(cal)));
            }
        }
    });
    mgr.add(new Action("Last month", IAction.AS_RADIO_BUTTON) {

        @Override
        public void run() {
            if (isChecked()) {
                Calendar cal = TimeCatalogue.getInstance().getMissionTimeAsCalendar(true);
                cal.add(Calendar.MONTH, -1);
                cal.set(Calendar.HOUR_OF_DAY, 0);
                cal.set(Calendar.MINUTE, 0);
                cal.set(Calendar.SECOND, 0);
                cal.set(Calendar.MILLISECOND, 0);
                doFilter(TimeInterval.starting(TimeEncoding.fromCalendar(cal)));
            }
        }
    });
    mgr.add(new Action("Last 3 months", IAction.AS_RADIO_BUTTON) {

        @Override
        public void run() {
            if (isChecked()) {
                Calendar cal = TimeCatalogue.getInstance().getMissionTimeAsCalendar(true);
                cal.add(Calendar.MONTH, -3);
                cal.set(Calendar.HOUR_OF_DAY, 0);
                cal.set(Calendar.MINUTE, 0);
                cal.set(Calendar.SECOND, 0);
                cal.set(Calendar.MILLISECOND, 0);
                doFilter(TimeInterval.starting(TimeEncoding.fromCalendar(cal)));
            }
        }
    });
    mgr.add(new Action("Last 12 months", IAction.AS_RADIO_BUTTON) {

        @Override
        public void run() {
            if (isChecked()) {
                Calendar cal = TimeCatalogue.getInstance().getMissionTimeAsCalendar(true);
                cal.add(Calendar.MONTH, -12);
                cal.set(Calendar.HOUR_OF_DAY, 0);
                cal.set(Calendar.MINUTE, 0);
                cal.set(Calendar.SECOND, 0);
                cal.set(Calendar.MILLISECOND, 0);
                doFilter(TimeInterval.starting(TimeEncoding.fromCalendar(cal)));
            }
        }
    });
    mgr.add(new Action("Custom...", IAction.AS_RADIO_BUTTON) {

        @Override
        public void run() {
            if (isChecked()) {
                CustomizeRangeDialog dialog = new CustomizeRangeDialog(Display.getCurrent().getActiveShell());
                dialog.setInitialRange(archivePanel.prefs.getInterval());
                if (dialog.open() == Window.OK) {
                    TimeInterval range = new TimeInterval();
                    if (dialog.hasStartTime())
                        range.setStart(dialog.getStartTime());
                    if (dialog.hasStopTime())
                        range.setStop(dialog.getStopTime());
                    doFilter(range);
                }
            }
        }
    });
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) TimeInterval(org.yamcs.studio.core.TimeInterval) Calendar(java.util.Calendar) IMenuManager(org.eclipse.jface.action.IMenuManager) IActionBars(org.eclipse.ui.IActionBars)

Example 3 with TimeInterval

use of org.yamcs.studio.core.TimeInterval in project yamcs-studio by yamcs.

the class ArchiveView method refreshData.

public void refreshData() {
    archivePanel.startReloading();
    TimeInterval interval = archivePanel.getRequestedDataInterval();
    indexReceiver.getIndex(interval);
}
Also used : TimeInterval(org.yamcs.studio.core.TimeInterval)

Example 4 with TimeInterval

use of org.yamcs.studio.core.TimeInterval in project yamcs-studio by yamcs.

the class DataView method archiveLoadFinished.

public void archiveLoadFinished() {
    for (IndexBox ib : indexBoxes.values()) {
        ib.dataLoadFinished();
    }
    TimeInterval intv = archivePanel.getRequestedDataInterval();
    long intvStart = intv.calculateStart();
    long intvStop = intv.calculateStop();
    if (zoomStack.isEmpty() || intvStart != lastStartTimestamp || intvStop != lastEndTimestamp) {
        int w = getViewport().getExtentSize().width;
        zoomStack.clear();
        long reqStart = intvStart;
        long zstart = archivePanel.dataStart;
        if (reqStart != TimeEncoding.INVALID_INSTANT)
            zstart = Math.min(reqStart, zstart);
        long reqStop = intvStop;
        long zstop = archivePanel.dataStop;
        if (reqStop != TimeEncoding.INVALID_INSTANT)
            zstop = Math.max(reqStop, zstop);
        long range = zstop - zstart;
        zstart -= range / 100;
        zstop += range / 100;
        zoomStack.push(new ZoomSpec(zstart, zstop, w, zstop - zstart));
    }
    lastStartTimestamp = intvStart;
    lastEndTimestamp = intvStop;
    SwingUtilities.invokeLater(() -> {
        archivePanel.archiveView.setZoomInEnabled(true);
        archivePanel.archiveView.setZoomOutEnabled(false);
        archivePanel.archiveView.setZoomClearEnabled(true);
    });
    refreshDisplay();
}
Also used : TimeInterval(org.yamcs.studio.core.TimeInterval) Point(java.awt.Point)

Example 5 with TimeInterval

use of org.yamcs.studio.core.TimeInterval 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

TimeInterval (org.yamcs.studio.core.TimeInterval)8 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)2 Calendar (java.util.Calendar)2 YamcsApiException (org.yamcs.api.YamcsApiException)2 ArchiveCatalogue (org.yamcs.studio.core.model.ArchiveCatalogue)2 TimeEncoding (org.yamcs.utils.TimeEncoding)2 Point (java.awt.Point)1 List (java.util.List)1 Level (java.util.logging.Level)1 Logger (java.util.logging.Logger)1 Action (org.eclipse.jface.action.Action)1 IAction (org.eclipse.jface.action.IAction)1 IMenuManager (org.eclipse.jface.action.IMenuManager)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