/*******************************************************************************
- * Copyright (c) 2009, 2010, 2011, 2012 Ericsson
+ * Copyright (c) 2009, 2013 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
package org.eclipse.linuxtools.tmf.ui.views.histogram;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
-import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
-import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest.ExecutionType;
import org.eclipse.linuxtools.tmf.core.request.TmfDataRequest;
import org.eclipse.linuxtools.tmf.core.signal.TmfRangeSynchSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceRangeUpdatedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceSelectedSignal;
import org.eclipse.linuxtools.tmf.core.signal.TmfTraceUpdatedSignal;
+import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
import org.eclipse.linuxtools.tmf.ui.editors.ITmfTraceEditor;
import org.eclipse.linuxtools.tmf.ui.views.TmfView;
*/
public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.histogram"; //$NON-NLS-1$
- /**
- * The initial window span (in nanoseconds)
- */
- public static final long INITIAL_WINDOW_SPAN = (1L * 100 * 1000 * 1000); // .1sec
-
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
private long fTraceEndTime;
private long fWindowStartTime;
private long fWindowEndTime;
- private long fWindowSpan = INITIAL_WINDOW_SPAN;
+ private long fWindowSpan;
private long fCurrentTimestamp;
// Time controls
gridData.verticalAlignment = SWT.CENTER;
fCurrentEventTimeControl = new HistogramCurrentTimeControl(this, controlsComposite, currentEventLabel, 0L);
fCurrentEventTimeControl.setLayoutData(gridData);
- fCurrentEventTimeControl.setValue(0L);
+ fCurrentEventTimeControl.setValue(Long.MIN_VALUE);
// Window span time control
gridData = new GridData();
gridData.verticalAlignment = SWT.CENTER;
fTimeSpanControl = new HistogramTimeRangeControl(this, controlsComposite, windowSpanLabel, 0L);
fTimeSpanControl.setLayoutData(gridData);
- fTimeSpanControl.setValue(0L);
+ fTimeSpanControl.setValue(Long.MIN_VALUE);
// --------------------------------------------------------------------
// Time range histogram
* Returns the time range of the current selected window (base on default time scale).
*
* @return the time range of current selected window.
+ * @since 2.0
*/
public TmfTimeRange getTimeRange() {
return new TmfTimeRange(
public synchronized void updateTimeRange(long newDuration) {
if (fTrace != null) {
long delta = newDuration - fWindowSpan;
- long newStartTime = fWindowStartTime + (delta / 2);
+ long newStartTime = fWindowStartTime - (delta / 2);
setNewRange(newStartTime, newDuration);
}
}
private void setNewRange(long startTime, long duration) {
- if (startTime < fTraceStartTime) {
- startTime = fTraceStartTime;
+ long realStart = startTime;
+
+ if (realStart < fTraceStartTime) {
+ realStart = fTraceStartTime;
}
- long endTime = startTime + duration;
+ long endTime = realStart + duration;
if (endTime > fTraceEndTime) {
endTime = fTraceEndTime;
- if ((endTime - duration) > fTraceEndTime) {
- startTime = endTime - duration;
+ if ((endTime - duration) > fTraceStartTime) {
+ realStart = endTime - duration;
} else {
- startTime = fTraceStartTime;
+ realStart = fTraceStartTime;
}
}
- updateTimeRange(startTime, endTime);
+ updateTimeRange(realStart, endTime);
}
// ------------------------------------------------------------------------
fTraceEndTime = 0L;
fWindowStartTime = 0L;
fWindowEndTime = 0L;
- fWindowSpan = INITIAL_WINDOW_SPAN;
+ fWindowSpan = 0L;
fCurrentTimestamp = 0L;
// Clear the UI widgets
fFullTraceHistogram.clear();
fTimeRangeHistogram.clear();
- fCurrentEventTimeControl.setValue(0L);
+ fCurrentEventTimeControl.setValue(Long.MIN_VALUE);
- fTimeSpanControl.setValue(0);
+ fTimeSpanControl.setValue(Long.MIN_VALUE);
}
/**
return;
}
- boolean drawTimeRangeHistogram = fTraceStartTime == 0;
TmfTimeRange fullRange = signal.getRange();
fTraceStartTime = fullRange.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
fFullTraceHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
fTimeRangeHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
- if (drawTimeRangeHistogram) {
- fCurrentTimestamp = fTraceStartTime;
- fCurrentEventTimeControl.setValue(fCurrentTimestamp);
- fFullTraceHistogram.setTimeRange(fTraceStartTime, INITIAL_WINDOW_SPAN);
- fTimeRangeHistogram.setTimeRange(fTraceStartTime, INITIAL_WINDOW_SPAN);
- sendTimeRangeRequest(fTraceStartTime, fTraceStartTime + INITIAL_WINDOW_SPAN);
- }
-
sendFullRangeRequest(fullRange);
}
fTimeRangeHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
fFullTraceHistogram.setTimeRange(fTimeRangeHistogram.getStartTime(), fWindowSpan);
+ fTimeRangeHistogram.setTimeRange(fTimeRangeHistogram.getStartTime(), fWindowSpan);
if ((fFullTraceRequest != null) && fFullTraceRequest.getRange().getEndTime().compareTo(signal.getRange().getEndTime()) < 0) {
sendFullRangeRequest(fullRange);
assert (signal != null);
if (fTrace != null) {
+ // Validate the time range
+ TmfTimeRange range = signal.getCurrentRange().getIntersection(fTrace.getTimeRange());
+ if (range == null) {
+ return;
+ }
+
// Update the time range
- fWindowStartTime = signal.getCurrentRange().getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
- fWindowEndTime = signal.getCurrentRange().getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
+ fWindowStartTime = range.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
+ fWindowEndTime = range.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
fWindowSpan = fWindowEndTime - fWindowStartTime;
// Notify the relevant widgets
private void initializeHistograms() {
TmfTimeRange fullRange = updateTraceTimeRange();
+ long timestamp = fTrace.getCurrentTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
+ long startTime = fTrace.getCurrentRange().getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
+ long duration = fTrace.getCurrentRange().getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue() - startTime;
if ((fTimeRangeRequest != null) && !fTimeRangeRequest.isCompleted()) {
fTimeRangeRequest.cancel();
}
fTimeRangeHistogram.clear();
fTimeRangeHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
- fTimeRangeHistogram.setTimeRange(fTraceStartTime, INITIAL_WINDOW_SPAN);
- fTimeRangeHistogram.setCurrentEvent(fTraceStartTime);
+ fTimeRangeHistogram.setTimeRange(startTime, duration);
+ fTimeRangeHistogram.setCurrentEvent(timestamp);
if ((fFullTraceRequest != null) && !fFullTraceRequest.isCompleted()) {
fFullTraceRequest.cancel();
}
fFullTraceHistogram.clear();
fFullTraceHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
- fFullTraceHistogram.setTimeRange(fTraceStartTime, INITIAL_WINDOW_SPAN);
- fFullTraceHistogram.setCurrentEvent(fTraceStartTime);
+ fFullTraceHistogram.setTimeRange(startTime, duration);
+ fFullTraceHistogram.setCurrentEvent(timestamp);
- fWindowStartTime = fTraceStartTime;
- fWindowSpan = INITIAL_WINDOW_SPAN;
- fWindowEndTime = fWindowStartTime + fWindowSpan;
+ fWindowStartTime = startTime;
+ fWindowSpan = duration;
+ fWindowEndTime = startTime + duration;
- fCurrentEventTimeControl.setValue(fTraceStartTime);
+ fCurrentTimestamp = timestamp;
+ fCurrentEventTimeControl.setValue(fCurrentTimestamp);
- fTimeSpanControl.setValue(fWindowSpan);
+ fTimeSpanControl.setValue(duration);
if (!fullRange.equals(TmfTimeRange.NULL_RANGE)) {
- sendTimeRangeRequest(fTraceStartTime, fTraceStartTime + fWindowSpan);
+ sendTimeRangeRequest(startTime, startTime + duration);
sendFullRangeRequest(fullRange);
}
}
private TmfTimeRange updateTraceTimeRange() {
fTraceStartTime = 0L;
fTraceEndTime = 0L;
- fCurrentTimestamp = 0L;
TmfTimeRange timeRange = fTrace.getTimeRange();
if (!timeRange.equals(TmfTimeRange.NULL_RANGE)) {
fTraceStartTime = timeRange.getStartTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
fTraceEndTime = timeRange.getEndTime().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
- fCurrentTimestamp = fTraceStartTime;
}
return timeRange;
}
TmfTimeRange timeRange = new TmfTimeRange(startTS, endTS);
fTimeRangeHistogram.clear();
+ fTimeRangeHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
fTimeRangeHistogram.setTimeRange(startTime, endTime - startTime);
int cacheSize = fTrace.getCacheSize();