Search in sources :

Example 36 with TmfTimeRange

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

the class TmfCoalescedEventRequest method merge.

private void merge(ITmfEventRequest request) {
    long start = request.getIndex();
    long end = Math.min(start + request.getNbRequested(), ITmfEventRequest.ALL_DATA);
    if (start < fIndex) {
        if (fNbRequested != ITmfEventRequest.ALL_DATA) {
            fNbRequested += (fIndex - start);
        }
        fIndex = start;
    }
    if ((request.getNbRequested() == ITmfEventRequest.ALL_DATA) || (fNbRequested == ITmfEventRequest.ALL_DATA)) {
        fNbRequested = ITmfEventRequest.ALL_DATA;
    } else {
        fNbRequested = (int) Math.max(end - fIndex, fNbRequested);
    }
    ITmfTimestamp startTime = request.getRange().getStartTime();
    ITmfTimestamp endTime = request.getRange().getEndTime();
    if (!fRange.contains(startTime) && fRange.getStartTime().compareTo(startTime) > 0) {
        fRange = new TmfTimeRange(startTime, fRange.getEndTime());
    }
    if (!fRange.contains(endTime) && fRange.getEndTime().compareTo(endTime) < 0) {
        fRange = new TmfTimeRange(fRange.getStartTime(), endTime);
    }
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)

Example 37 with TmfTimeRange

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

the class TmfTraceManager method selectionRangeUpdated.

/**
 * Signal handler for the selection range signal.
 *
 * If the signal trace is null, the time selection of *all* traces whose
 * range contains the requested new selection time range will be updated. If
 * the signal contains a trace, the signal trace and time-synchronized
 * traces will be updated, but not other instances of the signal trace.
 *
 * @param signal
 *            The incoming signal
 * @since 1.0
 */
@TmfSignalHandler
public synchronized void selectionRangeUpdated(final TmfSelectionRangeUpdatedSignal signal) {
    final ITmfTimestamp beginTs = signal.getBeginTime();
    final ITmfTimestamp endTs = signal.getEndTime();
    final ITmfTrace signalTrace = signal.getTrace();
    for (ITmfTrace trace : fTraces.keySet()) {
        if ((beginTs.intersects(getValidTimeRange(trace)) || endTs.intersects(getValidTimeRange(trace))) && (signalTrace == null || isSynchronized(trace, signalTrace))) {
            updateTraceContext(trace, builder -> builder.setSelection(new TmfTimeRange(beginTs, endTs)));
        }
    }
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 38 with TmfTimeRange

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

the class PinAndCloneTest method testPinTwoTraces.

/**
 * Test the behavior with two traces.
 */
@Ignore
@Test
public void testPinTwoTraces() {
    ITmfTrace ust = TmfTraceManager.getInstance().getActiveTrace();
    assertNotNull(ust);
    ITmfTrace kernelTestTrace = CtfTmfTestTraceUtils.getTrace(CtfTestTrace.CONTEXT_SWITCHES_KERNEL);
    SWTBotUtils.openTrace(TRACE_PROJECT_NAME, kernelTestTrace.getPath(), TRACETYPE_ID);
    /* Finish waiting for the trace to index */
    WaitUtils.waitForJobs();
    SWTBotEditor kernelEditor = SWTBotUtils.activateEditor(fBot, kernelTestTrace.getName());
    // wait for the editor to be ready.
    fBot.editorByTitle(kernelTestTrace.getName());
    // assert that the pin to drop down menuItems are present for both traces.
    fBot.waitUntil(new DefaultCondition() {

        WidgetNotFoundException fException;

        @Override
        public boolean test() throws Exception {
            try {
                SWTBotToolbarDropDownButton toolbarDropDownButton = fOriginalViewBot.toolbarDropDownButton(PIN_VIEW_BUTTON_NAME);
                toolbarDropDownButton.menuItem(PIN_TO_PREFIX + kernelTestTrace.getName());
                toolbarDropDownButton.menuItem(PIN_TO_PREFIX + fUstTestTrace.getName()).click();
                return true;
            } catch (WidgetNotFoundException e) {
                fException = e;
                return false;
            }
        }

        @Override
        public String getFailureMessage() {
            return "Traces not available in toolbar drop down menu: " + fException;
        }
    });
    /*
         * assert that the pinned view is the UST trace despite the active trace being
         * the kernel trace.
         */
    assertOriginalViewTitle(PINNED_TO_UST_TIME_GRAPH_VIEW_TITLE);
    ITmfTrace activeTrace = TmfTraceManager.getInstance().getActiveTrace();
    assertNotNull("There should be an active trace", activeTrace);
    assertEquals("context-switches-kernel should be the active trace", kernelTestTrace.getName(), activeTrace.getName());
    // Get the window range of the kernel trace
    TmfTraceManager traceManager = TmfTraceManager.getInstance();
    ITmfTrace kernelTrace = traceManager.getActiveTrace();
    assertNotNull(kernelTrace);
    // switch back and forth
    SWTBotUtils.activateEditor(fBot, fUstTestTrace.getName());
    assertOriginalViewTitle(PINNED_TO_UST_TIME_GRAPH_VIEW_TITLE);
    SWTBotUtils.activateEditor(fBot, kernelTestTrace.getName());
    assertOriginalViewTitle(PINNED_TO_UST_TIME_GRAPH_VIEW_TITLE);
    IWorkbenchPart part = fOriginalViewBot.getViewReference().getPart(false);
    assertTrue(part instanceof AbstractTimeGraphView);
    AbstractTimeGraphView abstractTimeGraphView = (AbstractTimeGraphView) part;
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, RANGE, kernelTrace));
    // assert that the ust trace's window range did not change
    SWTBotUtils.activateEditor(fBot, fUstTestTrace.getName());
    fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, ust, INITIAL_UST_RANGE));
    // unpin from another active trace
    SWTBotUtils.activateEditor(fBot, kernelTrace.getName());
    fOriginalViewBot.toolbarButton(UNPIN_VIEW_BUTTON_NAME).click();
    assertOriginalViewTitle(TIME_GRAPH_VIEW_TITLE);
    fOriginalViewBot.toolbarButton(PIN_VIEW_BUTTON_NAME).click();
    assertOriginalViewTitle(PINNED_TO_KERNEL_TIME_GRAPH_VIEW_TITLE);
    SWTBotTable kernelEventTable = kernelEditor.bot().table();
    SWTBotTableItem kernelEvent = kernelEventTable.getTableItem(5);
    kernelEvent.contextMenu(FOLLOW_TIME_UPDATES_FROM_OTHER_TRACES).click();
    TmfTimeRange expectedUstWindowRange = new TmfTimeRange(TmfTimestamp.fromNanos(UST_START + SECOND), TmfTimestamp.fromNanos(UST_END - SECOND));
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, expectedUstWindowRange, ust));
    fBot.waitUntil(ConditionHelpers.timeGraphRangeCondition(abstractTimeGraphView, kernelTrace, expectedUstWindowRange));
    // close the pinned trace
    SWTBotEditor kernelTable = fBot.editorByTitle(kernelTestTrace.getName());
    kernelTable.close();
    assertOriginalViewTitle(TIME_GRAPH_VIEW_TITLE);
    kernelTestTrace.dispose();
}
Also used : AbstractTimeGraphView(org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractTimeGraphView) SWTBotTable(org.eclipse.swtbot.swt.finder.widgets.SWTBotTable) SWTBotToolbarDropDownButton(org.eclipse.swtbot.swt.finder.widgets.SWTBotToolbarDropDownButton) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) SWTBotTableItem(org.eclipse.swtbot.swt.finder.widgets.SWTBotTableItem) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) SWTBotEditor(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotEditor) WidgetNotFoundException(org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException) TmfTraceManager(org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) DefaultCondition(org.eclipse.swtbot.swt.finder.waits.DefaultCondition) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 39 with TmfTimeRange

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

the class StatisticsUpdateJob method run.

@Override
protected IStatus run(IProgressMonitor monitor) {
    IStatus st = fStatsMod.schedule();
    if (!st.isOK()) {
        return st;
    }
    /* Wait until the analysis is ready to be queried */
    if (!fStatsMod.waitForInitialization()) {
        return Status.CANCEL_STATUS;
    }
    ITmfStatistics stats = fStatsMod.getStatistics();
    if (stats == null) {
        /* It should have worked, but didn't */
        throw new IllegalStateException();
    }
    /*
         * TODO Eventually this could be exposed through the
         * TmfStateSystemAnalysisModule directly.
         */
    ITmfStateSystem ss = fStatsMod.getStateSystem(TmfStatisticsEventTypesModule.ID);
    if (ss == null) {
        /*
             * It should be instantiated after the
             * statsMod.waitForInitialization() above.
             */
        throw new IllegalStateException();
    }
    /*
         * Periodically update the statistics while they are being built (or, if
         * the back-end is already completely built, it will skip over the
         * while() immediately.
         */
    long start = 0;
    long end = 0;
    boolean finished = false;
    do {
        /* This model update is done every second */
        if (monitor.isCanceled()) {
            fViewer.removeFromJobs(fIsGlobal, fJobTrace);
            return Status.CANCEL_STATUS;
        }
        finished = ss.waitUntilBuilt(LIVE_UPDATE_DELAY);
        TmfTimeRange localtimeRange = fTimerange;
        /*
             * The generic statistics are stored in nanoseconds, so we must make
             * sure the time range is scaled correctly.
             */
        start = localtimeRange.getStartTime().toNanos();
        end = localtimeRange.getEndTime().toNanos();
        Map<String, Long> map = stats.getEventTypesInRange(start, end);
        updateStats(map);
    } while (!finished);
    /* Query one last time for the final values */
    Map<String, Long> map = stats.getEventTypesInRange(start, end);
    updateStats(map);
    fViewer.refreshPieCharts(fIsGlobal, !fIsGlobal);
    /*
         * Remove job from map so that new range selection updates can be
         * processed.
         */
    fViewer.removeFromJobs(fIsGlobal, fJobTrace);
    return Status.OK_STATUS;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) ITmfStatistics(org.eclipse.tracecompass.tmf.core.statistics.ITmfStatistics) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)

Example 40 with TmfTimeRange

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

the class TmfStatisticsViewer method traceRangeUpdated.

// ------------------------------------------------------------------------
// Signal handlers
// ------------------------------------------------------------------------
/**
 * Handles the signal about new trace range.
 *
 * @param signal
 *            The trace range updated signal
 */
@TmfSignalHandler
public void traceRangeUpdated(TmfTraceRangeUpdatedSignal signal) {
    ITmfTrace trace = signal.getTrace();
    // validate
    if (!isListeningTo(trace)) {
        return;
    }
    synchronized (fStatisticsRangeUpdateSyncObj) {
        // Sends the time range request only once from this method.
        if (fSendRangeRequest) {
            fSendRangeRequest = false;
            TmfTraceContext ctx = TmfTraceManager.getInstance().getCurrentTraceContext();
            TmfTimeRange timeRange = ctx.getSelectionRange();
            requestTimeRangeData(trace, timeRange);
        }
    }
    requestData(trace, signal.getRange());
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTraceContext(org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

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