Search in sources :

Example 46 with TmfTimeRange

use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.

the class HistogramView method sendTimeRangeRequest.

private void sendTimeRangeRequest(long startTime, long endTime) {
    if ((fTimeRangeRequest != null) && !fTimeRangeRequest.isCompleted()) {
        fTimeRangeRequest.cancel();
    }
    ITmfTimestamp startTS = TmfTimestamp.fromNanos(startTime);
    ITmfTimestamp endTS = TmfTimestamp.fromNanos(endTime);
    TmfTimeRange timeRange = new TmfTimeRange(startTS, endTS);
    fTimeRangeHistogram.clear();
    fTimeRangeHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
    fTimeRangeHistogram.setTimeRange(startTime, endTime - startTime);
    int cacheSize = fTrace.getCacheSize();
    fTimeRangeRequest = new HistogramRequest(fTimeRangeHistogram.getDataModel(), timeRange, 0, ITmfEventRequest.ALL_DATA, cacheSize, ExecutionType.FOREGROUND, false);
    fTrace.sendRequest(fTimeRangeRequest);
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Point(org.eclipse.swt.graphics.Point)

Example 47 with TmfTimeRange

use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.

the class HistogramView method updateTraceTimeRange.

private TmfTimeRange updateTraceTimeRange() {
    fTraceStartTime = 0L;
    fTraceEndTime = 0L;
    TmfTimeRange timeRange = fTrace.getTimeRange();
    if (!timeRange.equals(TmfTimeRange.NULL_RANGE)) {
        fTraceStartTime = timeRange.getStartTime().toNanos();
        fTraceEndTime = timeRange.getEndTime().toNanos();
    }
    return timeRange;
}
Also used : TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)

Example 48 with TmfTimeRange

use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.

the class TimeChartView method timeRangeUpdated.

// ------------------------------------------------------------------------
// Listeners
// ------------------------------------------------------------------------
@Override
public void timeRangeUpdated(TimeGraphRangeUpdateEvent event) {
    fStartTime = event.getStartTime();
    fStopTime = event.getEndTime();
    itemize(fStartTime, fStopTime);
    final ITmfTimestamp startTimestamp = TmfTimestamp.fromNanos(event.getStartTime());
    final ITmfTimestamp endTimestamp = TmfTimestamp.fromNanos(event.getEndTime());
    TmfTimeRange range = new TmfTimeRange(startTimestamp, endTimestamp);
    broadcast(new TmfWindowRangeUpdatedSignal(this, range));
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)

Example 49 with TmfTimeRange

use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.

the class AbstractTimeGraphView method createPartControl.

// ------------------------------------------------------------------------
// ViewPart
// ------------------------------------------------------------------------
@Override
public void createPartControl(Composite parent) {
    super.createPartControl(parent);
    TimeGraphViewer timeGraphViewer = new TimeGraphViewer(parent, SWT.NONE);
    fTimeGraphViewer = timeGraphViewer;
    if (fLabelProvider != null) {
        timeGraphViewer.setTimeGraphLabelProvider(fLabelProvider);
    }
    if (fLegendProvider != null) {
        timeGraphViewer.setLegendProvider(fLegendProvider);
    }
    if (fColumns != null) {
        timeGraphViewer.setColumns(fColumns);
        if (fColumnComparators != null) {
            createColumnSelectionListener(timeGraphViewer.getTree());
        }
    }
    timeGraphViewer.setTimeGraphContentProvider(fTimeGraphContentProvider);
    timeGraphViewer.setFilterContentProvider(fFilterContentProvider != null ? fFilterContentProvider : fTimeGraphContentProvider);
    timeGraphViewer.setFilterLabelProvider(fFilterLabelProvider);
    timeGraphViewer.setFilterColumns(fFilterColumns);
    timeGraphViewer.addSelectionListener(fMetadataSelectionListener);
    ITimeGraphPresentationProvider presentationProvider = getPresentationProvider();
    timeGraphViewer.setTimeGraphProvider(presentationProvider);
    presentationProvider.addColorListener(stateItems -> TimeGraphStyleUtil.loadValues(getPresentationProvider()));
    presentationProvider.refresh();
    timeGraphViewer.setAutoExpandLevel(fAutoExpandLevel);
    timeGraphViewer.setWeights(fWeight);
    TimeGraphControl timeGraphControl = timeGraphViewer.getTimeGraphControl();
    Action timeEventFilterAction = new Action() {

        @Override
        public void run() {
            int xCoord = timeGraphControl.toControl(timeGraphControl.getDisplay().getCursorLocation()).x;
            if ((timeGraphViewer.getNameSpace() < xCoord) && (xCoord < timeGraphControl.getSize().x)) {
                if (fTimeEventFilterDialog != null) {
                    fTimeEventFilterDialog.close();
                    fTimeEventFilterDialog = null;
                }
                fTimeEventFilterDialog = new TimeEventFilterDialog(timeGraphControl.getShell(), AbstractTimeGraphView.this, getTimeGraphViewer().getTimeGraphControl());
                fTimeEventFilterDialog.open();
            }
        }
    };
    fTimeEventFilterAction = timeEventFilterAction;
    timeGraphViewer.addRangeListener(event -> {
        final long startTime = event.getStartTime();
        final long endTime = event.getEndTime();
        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromNanos(startTime), TmfTimestamp.fromNanos(endTime));
        broadcast(new TmfWindowRangeUpdatedSignal(AbstractTimeGraphView.this, range, fTrace));
        startZoomThread(startTime, endTime);
    });
    timeGraphViewer.addTimeListener(event -> {
        ITmfTimestamp startTime = TmfTimestamp.fromNanos(event.getBeginTime());
        ITmfTimestamp endTime = TmfTimestamp.fromNanos(event.getEndTime());
        broadcast(new TmfSelectionRangeUpdatedSignal(AbstractTimeGraphView.this, startTime, endTime, fTrace));
    });
    timeGraphViewer.addBookmarkListener(new ITimeGraphBookmarkListener() {

        @Override
        public void bookmarkAdded(final TimeGraphBookmarkEvent event) {
            try {
                ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {

                    @Override
                    public void run(IProgressMonitor monitor) throws CoreException {
                        IMarkerEvent bookmark = event.getBookmark();
                        IFile editorFile = fEditorFile;
                        if (editorFile == null) {
                            return;
                        }
                        IMarker marker = editorFile.createMarker(IMarker.BOOKMARK);
                        marker.setAttribute(IMarker.MESSAGE, bookmark.getLabel());
                        marker.setAttribute(ITmfMarker.MARKER_TIME, Long.toString(bookmark.getTime()));
                        if (bookmark.getDuration() > 0) {
                            marker.setAttribute(ITmfMarker.MARKER_DURATION, Long.toString(bookmark.getDuration()));
                            marker.setAttribute(IMarker.LOCATION, NLS.bind(org.eclipse.tracecompass.internal.tmf.ui.Messages.TmfMarker_LocationTimeRange, TmfTimestamp.fromNanos(bookmark.getTime()), TmfTimestamp.fromNanos(bookmark.getTime() + bookmark.getDuration())));
                        } else {
                            marker.setAttribute(IMarker.LOCATION, NLS.bind(org.eclipse.tracecompass.internal.tmf.ui.Messages.TmfMarker_LocationTime, TmfTimestamp.fromNanos(bookmark.getTime())));
                        }
                        marker.setAttribute(ITmfMarker.MARKER_COLOR, bookmark.getColor().toString());
                    }
                }, null);
            } catch (CoreException e) {
                Activator.getDefault().logError(e.getMessage());
            }
        }

        @Override
        public void bookmarkRemoved(TimeGraphBookmarkEvent event) {
            try {
                IMarkerEvent bookmark = event.getBookmark();
                IFile editorFile = fEditorFile;
                if (editorFile == null) {
                    return;
                }
                IMarker[] markers = editorFile.findMarkers(IMarker.BOOKMARK, false, IResource.DEPTH_ZERO);
                for (IMarker marker : markers) {
                    if (bookmark.getLabel().equals(marker.getAttribute(IMarker.MESSAGE)) && Long.toString(bookmark.getTime()).equals(marker.getAttribute(ITmfMarker.MARKER_TIME, (String) null)) && Long.toString(bookmark.getDuration()).equals(marker.getAttribute(ITmfMarker.MARKER_DURATION, Long.toString(0))) && bookmark.getColor().toString().equals(marker.getAttribute(ITmfMarker.MARKER_COLOR))) {
                        marker.delete();
                        break;
                    }
                }
            } catch (CoreException e) {
                Activator.getDefault().logError(e.getMessage());
            }
        }
    });
    fTimeGraphViewer.addMarkerListener(() -> restartZoomThread());
    timeGraphControl.addPaintListener(new PaintListener() {

        /**
         * This paint control allows the virtual time graph refresh to occur on paint
         * events instead of just scrolling the time axis or zooming. To avoid
         * refreshing the model on every paint event, we use a TmfUiRefreshHandler to
         * coalesce requests and only execute the last one, we also check if the entries
         * have changed to avoid useless model refresh.
         *
         * @param e
         *            paint event on the visible area
         */
        @Override
        public void paintControl(PaintEvent e) {
            TmfUiRefreshHandler.getInstance().queueUpdate(this, () -> {
                if (timeGraphControl.isDisposed()) {
                    return;
                }
                int timeSpace = getTimeGraphViewer().getTimeSpace();
                Set<@NonNull TimeGraphEntry> newSet = getVisibleItems(DEFAULT_BUFFER_SIZE);
                if (fPrevTimeSpace != timeSpace || !fVisibleEntries.equals(newSet)) {
                    /*
                         * Start a zoom thread if the set of visible entries has changed. We do not use
                         * lists as the order is not important. We cannot use the start index / size of
                         * the visible entries as we can collapse / reorder events.
                         */
                    fVisibleEntries = newSet;
                    fPrevTimeSpace = timeSpace;
                    startZoomThread(getTimeGraphViewer().getTime0(), getTimeGraphViewer().getTime1());
                }
            });
        }
    });
    IStatusLineManager statusLineManager = getViewSite().getActionBars().getStatusLineManager();
    timeGraphControl.setStatusLineManager(statusLineManager);
    // View Action Handling
    makeActions();
    contributeToActionBars();
    ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace();
    if (trace != null) {
        traceSelected(new TmfTraceSelectedSignal(this, trace));
    }
    // make selection available to other views
    IWorkbenchPartSite site = getSite();
    site.setSelectionProvider(timeGraphViewer.getSelectionProvider());
    ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
    createContextMenu();
    fPartListener = new TimeGraphPartListener();
    site.getPage().addPartListener(fPartListener);
    fPartListener2 = new TimeGraphPartListener2();
    site.getPage().addPartListener(fPartListener2);
    fOriginalTabLabel = getPartName();
    fContextService = site.getWorkbenchWindow().getService(IContextService.class);
    if (timeGraphControl.isInFocus()) {
        activateContextService();
    }
    timeGraphControl.addFocusListener(new FocusListener() {

        @Override
        public void focusLost(FocusEvent e) {
            deactivateContextService();
        }

        @Override
        public void focusGained(FocusEvent e) {
            activateContextService();
        }
    });
    updateTimeFormat();
}
Also used : IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) IFile(org.eclipse.core.resources.IFile) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) ImmutableSet(com.google.common.collect.ImmutableSet) MarkerSet(org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet) HashSet(java.util.HashSet) IMarkerEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent) TimeEventFilterDialog(org.eclipse.tracecompass.internal.tmf.ui.views.timegraph.TimeEventFilterDialog) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) FocusEvent(org.eclipse.swt.events.FocusEvent) ITimeGraphPresentationProvider(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphPresentationProvider) IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) TimeGraphBookmarkEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphBookmarkEvent) NonNull(org.eclipse.jdt.annotation.NonNull) TmfTraceSelectedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal) IContextService(org.eclipse.ui.contexts.IContextService) IWorkspaceRunnable(org.eclipse.core.resources.IWorkspaceRunnable) PaintEvent(org.eclipse.swt.events.PaintEvent) PaintListener(org.eclipse.swt.events.PaintListener) IStatusLineManager(org.eclipse.jface.action.IStatusLineManager) Point(org.eclipse.swt.graphics.Point) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) CoreException(org.eclipse.core.runtime.CoreException) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) ITimeGraphBookmarkListener(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.ITimeGraphBookmarkListener) TimeGraphViewer(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphViewer) TimeGraphControl(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl) IMarker(org.eclipse.core.resources.IMarker) FocusListener(org.eclipse.swt.events.FocusListener)

Example 50 with TmfTimeRange

use of org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange in project tracecompass by tracecompass.

the class SystemCallLatencyScatterChartViewTest method testWithTrace.

/**
 * Test to check the System Call Scatter view. When trace opens, there are a few
 * syscalls present, then we move to the zone without system calls, the tree
 * should be empty.
 *
 * TODO: Test the data
 */
@Test
public void testWithTrace() {
    // Wait for analysis to finish.
    WaitUtils.waitForJobs();
    IViewPart viewPart = getSWTBotView().getViewReference().getView(true);
    assertTrue(viewPart instanceof SystemCallLatencyScatterView);
    final TmfCommonXAxisChartViewer chartViewer = (TmfCommonXAxisChartViewer) getChartViewer(viewPart);
    assertNotNull(chartViewer);
    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
    final Chart chart = getChart();
    assertNotNull(chart);
    SWTBotUtils.waitUntil(bot -> bot.tree().visibleRowCount() >= 25, getSWTBotView().bot(), "Missing rows, expected 25, was " + getSWTBotView().bot().tree().visibleRowCount());
    SWTBotTreeItem[] items = getSWTBotView().bot().tree().getAllItems();
    for (SWTBotTreeItem item : items) {
        item.check();
    }
    SWTBotUtils.waitUntil(c -> c.getSeriesSet().getSeries().length >= 24, chart, "No data available");
    /* Test type, style and color of series */
    verifyChartStyle();
    // Update the time range to a range where there is no data
    long noDataStart = 1412670961274443542L;
    long noDataEnd = 1412670961298823940L;
    TmfTimeRange windowRange = new TmfTimeRange(TmfTimestamp.fromNanos(noDataStart), TmfTimestamp.fromNanos(noDataEnd));
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, windowRange));
    fBot.waitUntil(ConditionHelpers.windowRange(windowRange));
    fBot.waitUntil(ConditionHelpers.xyViewerIsReadyCondition(chartViewer));
    // Only the root item should be present
    items = getSWTBotView().bot().tree().getAllItems();
    assertEquals(1, items.length);
}
Also used : IViewPart(org.eclipse.ui.IViewPart) SystemCallLatencyScatterView(org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.latency.SystemCallLatencyScatterView) SWTBotTreeItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem) TmfCommonXAxisChartViewer(org.eclipse.tracecompass.tmf.ui.viewers.xychart.linechart.TmfCommonXAxisChartViewer) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) Chart(org.eclipse.swtchart.Chart) Test(org.junit.Test) XYDataProviderBaseTest(org.eclipse.tracecompass.tmf.ui.swtbot.tests.views.xychart.XYDataProviderBaseTest)

Aggregations

TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)168 Test (org.junit.Test)98 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)53 TmfWindowRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal)29 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)24 TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)24 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)21 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)20 TmfSelectionRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal)19 ITmfEventRequest (org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest)16 SWTBotTimeGraph (org.eclipse.tracecompass.tmf.ui.swtbot.tests.shared.SWTBotTimeGraph)16 Vector (java.util.Vector)13 SWTBotView (org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView)12 TmfTraceManager (org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager)10 ITmfEventProvider (org.eclipse.tracecompass.tmf.core.component.ITmfEventProvider)9 AbstractTimeGraphView (org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView)9 TmfTraceContext (org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext)8 TmfExperiment (org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment)8 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)8 Point (org.eclipse.swt.graphics.Point)7