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));
}
}
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();
}
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");
}
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));
}
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());
}
Aggregations