Search in sources :

Example 1 with ITmfTimestamp

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

the class LamiReportViewTabPage method updateSelection.

// ------------------------------------------------------------------------
// Signals
// ------------------------------------------------------------------------
// Custom chart signals
/**
 * Signal handler for a chart selection update. It will try to propagate a
 * {@link TmfSelectionRangeUpdatedSignal} if possible.
 *
 * @param signal
 *            The selection update signal
 */
@TmfSignalHandler
public void updateSelection(ChartSelectionUpdateSignal signal) {
    /* Make sure we are not sending a signal to ourself */
    if (signal.getSource() == this) {
        return;
    }
    /* Make sure the signal comes from the data provider's scope */
    if (fResultTable.hashCode() != signal.getDataProvider().hashCode()) {
        return;
    }
    /* Find which index row has been selected */
    Set<Object> entries = signal.getSelectedObject();
    /* Update the selection */
    fSelection = entries;
    /* Only propagate to all TraceCompass if there is a single selection */
    if (entries.size() == 1) {
        LamiTableEntry entry = (LamiTableEntry) Iterables.getOnlyElement(entries);
        /* Make sure the selection represent a time range */
        LamiTimeRange timeRange = entry.getCorrespondingTimeRange();
        if (timeRange == null) {
            return;
        }
        /* Get the timestamps from the time range */
        /**
         * TODO: Consider low and high limits of timestamps here.
         */
        Number tsBeginValueNumber = timeRange.getBegin().getValue();
        Number tsEndValueNumber = timeRange.getEnd().getValue();
        if (tsBeginValueNumber == null || tsEndValueNumber == null) {
            return;
        }
        /* Send Range update to other views */
        ITmfTimestamp start = TmfTimestamp.fromNanos(tsBeginValueNumber.longValue());
        ITmfTimestamp end = TmfTimestamp.fromNanos(tsEndValueNumber.longValue());
        TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, start, end));
    }
}
Also used : TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) LamiTableEntry(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) LamiTimeRange(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimeRange) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 2 with ITmfTimestamp

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

the class CtfTmfLostEventsTest method testLostEventWithTransform.

/**
 * Test getting a lost event from a trace that has a timestamp transform.
 */
@Test
public void testLostEventWithTransform() {
    CtfTmfTrace trace = CtfTmfTestTraceUtils.getTrace(testTrace);
    long offset = 1234567890L;
    trace.setTimestampTransform(TimestampTransformFactory.createWithOffset(offset));
    trace.indexTrace(true);
    final long rank = 190;
    final ITmfTimestamp start = TmfTimestamp.fromNanos(1376592664828900165L + offset);
    final ITmfTimestamp end = TmfTimestamp.fromNanos(1376592664828900165L + 502911L + offset);
    final long nbLost = 859;
    ITmfContext context = trace.seekEvent(rank);
    final CtfTmfEvent ev = trace.getNext(context);
    context.dispose();
    assertTrue(ev instanceof ITmfLostEvent);
    ITmfLostEvent event = (ITmfLostEvent) ev;
    assertEquals(start, event.getTimestamp());
    assertEquals(start, event.getTimeRange().getStartTime());
    assertEquals(end, event.getTimeRange().getEndTime());
    assertEquals(nbLost, event.getNbLostEvents());
    trace.setTimestampTransform(null);
    trace.dispose();
}
Also used : ITmfContext(org.eclipse.tracecompass.tmf.core.trace.ITmfContext) CtfTmfEvent(org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) ITmfLostEvent(org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent) CtfTmfTrace(org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace) Test(org.junit.Test)

Example 3 with ITmfTimestamp

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

the class ResourcesViewTest method testMarkerAxis.

/**
 * Test the marker axis
 */
@Test
public void testMarkerAxis() {
    SWTBotView viewBot = getViewBot();
    /* center window range of first lost event range */
    ITmfTimestamp startTime = LOST_EVENT_TIME1.normalize(-10000000L, ITmfTimestamp.NANOSECOND_SCALE);
    ITmfTimestamp endTime = LOST_EVENT_END1.normalize(10000000L, ITmfTimestamp.NANOSECOND_SCALE);
    TmfTimeRange range = new TmfTimeRange(startTime, endTime);
    TmfSignalManager.dispatchSignal(new TmfWindowRangeUpdatedSignal(this, range));
    fBot.waitUntil(ConditionHelpers.windowRange(range));
    /* set selection to window start time */
    TmfSignalManager.dispatchSignal(new TmfSelectionRangeUpdatedSignal(this, startTime));
    timeGraphIsReadyCondition(new TmfTimeRange(startTime, startTime), startTime);
    /* get marker axis size with one category */
    final TimeGraphMarkerAxis markerAxis = viewBot.bot().widget(WidgetOfType.widgetOfType(TimeGraphMarkerAxis.class));
    final Point size1 = getSize(markerAxis);
    /* add bookmark at window start time */
    viewBot.toolbarButton(ADD_BOOKMARK).click();
    SWTBot dialogBot = fBot.shell(ADD_BOOKMARK_DIALOG).bot();
    dialogBot.text().setText("B");
    dialogBot.button(OK).click();
    /* get marker axis size with two categories */
    final Point size2 = getSize(markerAxis);
    final int rowHeight = size2.y - size1.y;
    /*
         * get the state area bounds, since we don't know the name space width
         */
    final TimeGraphControl timeGraph = viewBot.bot().widget(WidgetOfType.widgetOfType(TimeGraphControl.class));
    int x0 = getXForTime(timeGraph, startTime.toNanos());
    int x1 = getXForTime(timeGraph, endTime.toNanos());
    /*
         * click at the center of the marker axis width and first row height, it
         * should be within the lost event range
         */
    final SWTBotCanvas markerAxisCanvas = new SWTBotCanvas(markerAxis);
    markerAxisCanvas.click((x0 + x1) / 2, TOP_MARGIN + rowHeight / 2);
    fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(LOST_EVENT_TIME1, LOST_EVENT_END1)));
    /*
         * click near the left of the marker axis width and center of second row
         * height, it should be on the bookmark label
         */
    markerAxisCanvas.click(x0 + 2, TOP_MARGIN + rowHeight + rowHeight / 2);
    fBot.waitUntil(ConditionHelpers.selectionRange(new TmfTimeRange(startTime, startTime)));
    /* click "Remove Bookmark" */
    viewBot.toolbarButton(REMOVE_BOOKMARK).click();
    assertEquals(size1, getSize(markerAxis));
    /* click the 'expanded' icon to collapse */
    markerAxisCanvas.click(TOGGLE_SIZE.x / 2, TOGGLE_SIZE.y / 2);
    assertEquals(TOGGLE_SIZE.y, getSize(markerAxis).y);
    /* click the 'collapsed' icon to expand */
    markerAxisCanvas.click(TOGGLE_SIZE.x / 2, TOGGLE_SIZE.y / 2);
    assertEquals(size1, getSize(markerAxis));
    /* click on the 'X' icon to hide the 'Lost Events' marker category */
    markerAxisCanvas.click(TOGGLE_SIZE.x + HIDE_SIZE.x / 2, TOP_MARGIN + HIDE_SIZE.y / 2);
    assertEquals(0, getSize(markerAxis).y);
    /* show Lost Events markers */
    viewBot.viewMenu(LOST_EVENTS).click();
    SWTBotUtils.waitUntil(ma -> size1.equals(getSize(ma)), markerAxis, "Lost Events did not reappear");
}
Also used : TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) SWTBot(org.eclipse.swtbot.swt.finder.SWTBot) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) TimeGraphControl(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) TimeGraphMarkerAxis(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphMarkerAxis) Point(org.eclipse.swt.graphics.Point) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) SWTBotCanvas(org.eclipse.swtbot.swt.finder.widgets.SWTBotCanvas) Point(org.eclipse.swt.graphics.Point) Test(org.junit.Test)

Example 4 with ITmfTimestamp

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

the class TmfNanoTimestampTest method testEqualsSymmetry.

@Test
public void testEqualsSymmetry() {
    final ITmfTimestamp ts0copy = TmfTimestamp.fromNanos(ts0.toNanos());
    assertTrue("equals", ts0.equals(ts0copy));
    assertTrue("equals", ts0copy.equals(ts0));
    final ITmfTimestamp ts1copy = TmfTimestamp.fromNanos(ts1.toNanos());
    assertTrue("equals", ts1.equals(ts1copy));
    assertTrue("equals", ts1copy.equals(ts1));
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) Test(org.junit.Test)

Example 5 with ITmfTimestamp

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

the class TmfNanoTimestampTest method testNormalizeScale0.

// ------------------------------------------------------------------------
// normalize
// ------------------------------------------------------------------------
@Test
public void testNormalizeScale0() {
    ITmfTimestamp ts = ts0.normalize(0, 0);
    assertEquals("getValue", 0, ts.getValue());
    assertEquals("getscale", 0, ts.getScale());
    ts = ts0.normalize(12345, 0);
    assertEquals("getValue", 12345, ts.getValue());
    assertEquals("getscale", 0, ts.getScale());
    ts = ts0.normalize(10, 0);
    assertEquals("getValue", 10, ts.getValue());
    assertEquals("getscale", 0, ts.getScale());
    ts = ts0.normalize(-10, 0);
    assertEquals("getValue", -10, ts.getValue());
    assertEquals("getscale", 0, ts.getScale());
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) Test(org.junit.Test)

Aggregations

ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)162 Test (org.junit.Test)102 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)52 TmfSelectionRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal)12 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)11 ITmfContext (org.eclipse.tracecompass.tmf.core.trace.ITmfContext)10 Point (org.eclipse.swt.graphics.Point)8 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)8 ArrayList (java.util.ArrayList)6 NonNull (org.eclipse.jdt.annotation.NonNull)5 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)5 TmfWindowRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal)5 CtfTmfTrace (org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace)5 IOException (java.io.IOException)4 IStatus (org.eclipse.core.runtime.IStatus)4 File (java.io.File)3 Path (java.nio.file.Path)3 HashSet (java.util.HashSet)3 CoreException (org.eclipse.core.runtime.CoreException)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3