-org.eclipse.linuxtools.lttng/debug=false
-org.eclipse.linuxtools.lttng/info=false
-org.eclipse.linuxtools.lttng/warn=false
+org.eclipse.linuxtools.lttng.core/debug=false
+org.eclipse.linuxtools.lttng.core/info=false
+org.eclipse.linuxtools.lttng.core/warn=false
// ========================================================================
// The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.linuxtools.lttng"; //$NON-NLS-1$
+ public static final String PLUGIN_ID = "org.eclipse.linuxtools.lttng.core"; //$NON-NLS-1$
// The shared instance
private static LTTngCorePlugin plugin;
package org.eclipse.linuxtools.lttng.core.event;
+import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
/**
*/
public class LttngTimestamp extends TmfTimestamp {
- // Required by Serializable
- private static final long serialVersionUID = -7016853105162491273L;
-
/**
* Default Constructor.<p>
*
*/
public LttngTimestamp() {
- super(Long.MIN_VALUE, (byte) -9);
+ this(Long.MIN_VALUE);
}
/**
* @param newEventTime Time as long, unit expected to be nanoseconds
*/
public LttngTimestamp(long newEventTime) {
- super(newEventTime, (byte) -9);
+ super(newEventTime, -9, 0);
}
/**
this(oldEventTime.getValue());
}
- @Override
- public long getValue() {
- return fValue;
- }
-
public void setValue(long newValue) {
fValue = newValue;
}
* @throws ArithmeticException
*/
@Override
- public LttngTimestamp getDelta(TmfTimestamp other) throws ArithmeticException {
- TmfTimestamp delta = super.getDelta(other);
+ public LttngTimestamp getDelta(ITmfTimestamp other) {
+ TmfTimestamp delta = (TmfTimestamp) super.getDelta(other);
return new LttngTimestamp(delta);
}
}
}
public TmfTimestamp getSpan() {
- TmfTimestamp span = new TmfTimestamp(startTime.getAdjustment(endTime, NS_SCALING_FACTOR), NS_SCALING_FACTOR, 0);
+ TmfTimestamp span = (TmfTimestamp) startTime.getDelta(endTime);
return span;
}
public void setStartTime(TmfTimestamp ts) {
try {
- startTime = ts.synchronize(0, NS_SCALING_FACTOR);
+ startTime = (TmfTimestamp) ts.getDelta(new TmfTimestamp(0, NS_SCALING_FACTOR));
startSeconds = (int) (startTime.getValue() / NS_PER_SECOND);
startNanosec = (int) (startTime.getValue() % NS_PER_SECOND);
}
public void setEndTime(TmfTimestamp ts) {
try {
- endTime = ts.synchronize(0, NS_SCALING_FACTOR);
+ endTime = (TmfTimestamp) ts.getDelta(new TmfTimestamp(0, NS_SCALING_FACTOR));
endSeconds = (int) (endTime.getValue() / NS_PER_SECOND);
endNanosec = (int) (endTime.getValue() % NS_PER_SECOND);
}
public void setCurrentTime(TmfTimestamp ts) {
try {
- currentTime = ts.synchronize(0, NS_SCALING_FACTOR);
+ currentTime = (TmfTimestamp) ts.getDelta(new TmfTimestamp(0, NS_SCALING_FACTOR));
currentSeconds = (int) (currentTime.getValue() / NS_PER_SECOND);
currentNanosec = (int) (currentTime.getValue() % NS_PER_SECOND);
}
private TmfTimeRange fTraceTimeRange = new TmfTimeRange(fTraceStartTime, fTraceEndTime);
private TmfTimeRange fTraceSpan = new TmfTimeRange(fTraceStartTime, fTraceEndTime);
- private byte fScale = 0;
+ private int fScale = 0;
// Labels
private static final String START_TIME_LABEL = Messages.TimeFrameView_WindowStartTime;
long span = timeRange.getValue();
TmfTimestamp ts = new TmfTimestamp(start + span, startTime.getScale(), 0);
if (ts.compareTo(fTraceEndTime, false) > 0) {
- ts = fTraceEndTime.synchronize(fTraceEndTime.getValue(), startTime.getScale());
+ ts = fTraceEndTime.clone();
}
endTime = ts;
trangeUpdated = true;
// Compute the new time range
TmfTimeRange subrange = new TmfTimeRange(startTime, endTime);
- byte scale = startTime.getScale();
- TmfTimestamp interval = new TmfTimestamp(startTime.getAdjustment(endTime, scale), scale, 0);
+ int scale = startTime.getScale();
+ TmfTimestamp interval = (TmfTimestamp) startTime.getDelta(endTime);
// Update the spinner groups
fStartGroup.setContent(fTraceTimeRange, startTime);
return;
// Determine the new relative position
- byte scale = range.getEndTime().getScale();
- long total = range.getStartTime().getAdjustment(range.getEndTime(), scale);
- long relative = range.getStartTime().getAdjustment(timestamp, scale);
+ int scale = range.getEndTime().getScale();
+ long total = range.getStartTime().getDelta(range.getEndTime()).getValue();
+ long relative = range.getStartTime().getDelta(timestamp).getValue();
// Set the slider value
final long position = (total > 0) ? (relative * SLIDER_RANGE / total) : 0;
fCurrentTime = fTraceStartTime;
- TmfTimestamp delta = new TmfTimestamp(fTraceStartTime.getAdjustment(fTraceEndTime, fScale), fScale, 0);
+ TmfTimestamp delta = (TmfTimestamp) fTraceStartTime.getDelta(fTraceEndTime);
fTraceSpan = new TmfTimeRange(new TmfTimestamp(0, fScale, 0), delta);
// fRangeGroup.setContent(fTraceSpan, delta);
TmfTimestamp start = new TmfTimestamp(1, (byte) -1, 0);
fEndGroup.setContent(fTraceTimeRange, fTraceEndTime);
fCurrentGroup.setContent(fTraceTimeRange, fCurrentGroup.getCurrentTime());
- TmfTimestamp delta = new TmfTimestamp(fTraceStartTime.getAdjustment(fTraceEndTime, fScale), fScale, 0);
+ TmfTimestamp delta = (TmfTimestamp) fTraceStartTime.getDelta(fTraceEndTime);
fTraceSpan = new TmfTimeRange(new TmfTimestamp(0, fScale, 0), delta);
fRangeGroup.setContent(fTraceSpan, delta);
}
if (signal.getSource() != this) {
// Update the time frame
TmfTimeRange selTimeRange = signal.getCurrentRange();
- TmfTimestamp selStart = selTimeRange.getStartTime().synchronize(0, fScale);
- TmfTimestamp selEnd = selTimeRange.getEndTime().synchronize(0, fScale);
+ TmfTimestamp selStart = (TmfTimestamp) selTimeRange.getStartTime().normalize(0, fScale);
+ TmfTimestamp selEnd = (TmfTimestamp) selTimeRange.getEndTime().normalize(0, fScale);
fupdateExternalListeners = false;
// Update the widgets and prevent broadcast notifications to
fStartGroup.setContent(fTraceTimeRange, selStart);
fEndGroup.setContent(fTraceTimeRange, selEnd);
- TmfTimestamp delta = new TmfTimestamp(selStart.getAdjustment(selEnd, fScale), fScale, 0);
+ TmfTimestamp delta = (TmfTimestamp) selStart.getDelta(selEnd);
fRangeGroup.setContent(fTraceSpan, delta);
}
if (signal.getSource() != this) {
// prevent loop to external notifications
fupdateExternalListeners = false;
- fCurrentTime = signal.getCurrentTime().synchronize(0, fStartGroup.getCurrentTime().getScale());
+ fCurrentTime = (TmfTimestamp) signal.getCurrentTime().normalize(0, fStartGroup.getCurrentTime().getScale());
if (fStartGroup.getCurrentTime().compareTo(fCurrentTime, false) > 0) {
fStartGroup.setContent(new TmfTimeRange(fCurrentTime, fEndGroup.getCurrentTime()), fCurrentTime);
}
// ------------------------------------------------------------------------
public void testTmfCorePluginId() throws Exception {
- assertEquals("Plugin ID", "org.eclipse.linuxtools.tmf", TmfCorePlugin.PLUGIN_ID);
+ assertEquals("Plugin ID", "org.eclipse.linuxtools.tmf.core", TmfCorePlugin.PLUGIN_ID);
}
public void testGetDefault() throws Exception {
}
public void testToString2() {
- String expected = "[TmfEventContent(1,-10,true,some string,[TmfTimestamp(1,2,3)])]";
+ String expected = "[TmfEventContent(1,-10,true,some string,TmfTimestamp [fValue=1, fScale=2, fPrecision=3])]";
TmfEventContentStub content = new TmfEventContentStub(fEvent, fRawContent0);
assertEquals("toString", expected, content.toString());
}
import junit.framework.TestCase;
+import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp;
import org.eclipse.linuxtools.tmf.core.event.TmfTimestamp;
/**
private final TmfTimestamp ts0 = new TmfTimestamp();
private final TmfTimestamp ts1 = new TmfTimestamp(12345);
- private final TmfTimestamp ts2 = new TmfTimestamp(12345, (byte) -1);
- private final TmfTimestamp ts3 = new TmfTimestamp(12345, (byte) 2, 5);
+ private final TmfTimestamp ts2 = new TmfTimestamp(12345, -1);
+ private final TmfTimestamp ts3 = new TmfTimestamp(12345, 2, 5);
private final TmfTimestamp ts0copy = new TmfTimestamp();
private final TmfTimestamp ts1copy = new TmfTimestamp(12345);
}
public void testCopyConstructor() throws Exception {
- TmfTimestamp ts0 = new TmfTimestamp(12345, (byte) 2, 5);
+ TmfTimestamp ts0 = new TmfTimestamp(12345, 2, 5);
TmfTimestamp ts = new TmfTimestamp(ts0);
assertEquals("getValue", 12345, ts.getValue());
assertEquals("getscale", 2, ts.getScale());
// ------------------------------------------------------------------------
public void testToString() throws Exception {
- assertEquals("toString", "[TmfTimestamp(0,0,0)]", ts0.toString());
- assertEquals("toString", "[TmfTimestamp(12345,0,0)]", ts1.toString());
- assertEquals("toString", "[TmfTimestamp(12345,-1,0)]", ts2.toString());
- assertEquals("toString", "[TmfTimestamp(12345,2,5)]", ts3.toString());
+ assertEquals("toString", "TmfTimestamp [fValue=0, fScale=0, fPrecision=0]", ts0.toString());
+ assertEquals("toString", "TmfTimestamp [fValue=12345, fScale=0, fPrecision=0]", ts1.toString());
+ assertEquals("toString", "TmfTimestamp [fValue=12345, fScale=-1, fPrecision=0]", ts2.toString());
+ assertEquals("toString", "TmfTimestamp [fValue=12345, fScale=2, fPrecision=5]", ts3.toString());
}
// ------------------------------------------------------------------------
}
// ------------------------------------------------------------------------
- // synchronize
+ // normalize
// ------------------------------------------------------------------------
- public void testSynchronizeOffset() throws Exception {
+ public void testNormalizeOffset() throws Exception {
- TmfTimestamp ts = ts0.synchronize(0, (byte) 0);
+ ITmfTimestamp ts = ts0.normalize(0, 0);
assertEquals("getValue", 0, ts.getValue());
assertEquals("getscale", 0, ts.getScale());
assertEquals("getPrecision", 0, ts.getPrecision());
- ts = ts0.synchronize(12345, (byte) 0);
+ ts = ts0.normalize(12345, 0);
assertEquals("getValue", 12345, ts.getValue());
assertEquals("getscale", 0, ts.getScale());
assertEquals("getPrecision", 0, ts.getPrecision());
- ts = ts0.synchronize(10, (byte) 0);
+ ts = ts0.normalize(10, 0);
assertEquals("getValue", 10, ts.getValue());
assertEquals("getscale", 0, ts.getScale());
assertEquals("getPrecision", 0, ts.getPrecision());
- ts = ts0.synchronize(-10, (byte) 0);
+ ts = ts0.normalize(-10, 0);
assertEquals("getValue", -10, ts.getValue());
assertEquals("getscale", 0, ts.getScale());
assertEquals("getPrecision", 0, ts.getPrecision());
}
- public void testSynchronizeScale() throws Exception {
+ public void testNormalizeScale() throws Exception {
- TmfTimestamp ts = ts0.synchronize(0, (byte) 10);
+ ITmfTimestamp ts = ts0.normalize(0, 10);
assertEquals("getValue", 0, ts.getValue());
assertEquals("getscale", 10, ts.getScale());
assertEquals("getPrecision", 0, ts.getPrecision());
- ts = ts0.synchronize(0, (byte) -10);
+ ts = ts0.normalize(0, -10);
assertEquals("getValue", 0, ts.getValue());
assertEquals("getscale", -10, ts.getScale());
assertEquals("getPrecision", 0, ts.getPrecision());
}
- public void testSynchronizeOffsetAndScale() throws Exception {
- byte SCALE = 12;
+ public void testNormalizeOffsetAndScale() throws Exception {
+ int SCALE = 12;
- TmfTimestamp ts = ts0.synchronize(0, SCALE);
+ ITmfTimestamp ts = ts0.normalize(0, SCALE);
assertEquals("getValue", 0, ts.getValue());
assertEquals("getscale", SCALE, ts.getScale());
assertEquals("getPrecision", 0, ts.getPrecision());
- ts = ts0.synchronize(12345, SCALE);
+ ts = ts0.normalize(12345, SCALE);
assertEquals("getValue", 12345, ts.getValue());
assertEquals("getscale", SCALE, ts.getScale());
assertEquals("getPrecision", 0, ts.getPrecision());
- ts = ts0.synchronize(10, SCALE);
+ ts = ts0.normalize(10, SCALE);
assertEquals("getValue", 10, ts.getValue());
assertEquals("getscale", SCALE, ts.getScale());
assertEquals("getPrecision", 0, ts.getPrecision());
- ts = ts0.synchronize(-10, SCALE);
+ ts = ts0.normalize(-10, SCALE);
assertEquals("getValue", -10, ts.getValue());
assertEquals("getscale", SCALE, ts.getScale());
assertEquals("getPrecision", 0, ts.getPrecision());
}
// ------------------------------------------------------------------------
- // getAdjustment
- // ------------------------------------------------------------------------
-
- public void testGetAdjustmentSameScale() throws Exception {
- long delta = ts0.getAdjustment(ts0 , ts0.getScale());
- assertEquals("delta", 0, delta);
-
- delta = ts1.getAdjustment(ts1, ts1.getScale());
- assertEquals("delta", 0, delta);
-
- delta = ts0.getAdjustment(ts1, ts1.getScale());
- assertEquals("delta", 12345, delta);
-
- delta = ts1.getAdjustment(ts0, ts0.getScale());
- assertEquals("delta", -12345, delta);
- }
-
- public void testGetAdjustmentDifferentScales() throws Exception {
- long delta = ts0.getAdjustment(ts2, ts2.getScale());
- assertEquals("delta", 12345, delta);
-
- delta = ts2.getAdjustment(ts0, ts0.getScale());
- assertEquals("delta", -1234, delta);
- }
-
- // ------------------------------------------------------------------------
- // CompareTo
+ // compareTo
// ------------------------------------------------------------------------
public void testCompareToSameScale() throws Exception {
- TmfTimestamp ts1 = new TmfTimestamp(900, (byte) 0, 50);
- TmfTimestamp ts2 = new TmfTimestamp(1000, (byte) 0, 50);
- TmfTimestamp ts3 = new TmfTimestamp(1100, (byte) 0, 50);
- TmfTimestamp ts4 = new TmfTimestamp(1000, (byte) 0, 75);
+ TmfTimestamp ts1 = new TmfTimestamp(900, 0, 50);
+ TmfTimestamp ts2 = new TmfTimestamp(1000, 0, 50);
+ TmfTimestamp ts3 = new TmfTimestamp(1100, 0, 50);
+ TmfTimestamp ts4 = new TmfTimestamp(1000, 0, 75);
assertTrue(ts1.compareTo(ts1, false) == 0);
}
public void testCompareToDifferentScale() throws Exception {
- TmfTimestamp ts1 = new TmfTimestamp(9000, (byte) -1, 50);
- TmfTimestamp ts2 = new TmfTimestamp(1000, (byte) 0, 50);
- TmfTimestamp ts3 = new TmfTimestamp(110, (byte) 1, 50);
- TmfTimestamp ts4 = new TmfTimestamp(1, (byte) 3, 75);
+ TmfTimestamp ts1 = new TmfTimestamp(9000, -1, 50);
+ TmfTimestamp ts2 = new TmfTimestamp(1000, 0, 50);
+ TmfTimestamp ts3 = new TmfTimestamp(110, 1, 50);
+ TmfTimestamp ts4 = new TmfTimestamp(1, 3, 75);
assertTrue("CompareTo", ts1.compareTo(ts1, false) == 0);
}
public void testCompareToWithinPrecision() throws Exception {
- TmfTimestamp ts1 = new TmfTimestamp(900, (byte) 0, 50);
- TmfTimestamp ts2 = new TmfTimestamp(1000, (byte) 0, 50);
- TmfTimestamp ts3 = new TmfTimestamp(1100, (byte) 0, 50);
- TmfTimestamp ts4 = new TmfTimestamp(1000, (byte) 0, 75);
+ TmfTimestamp ts1 = new TmfTimestamp(900, 0, 50);
+ TmfTimestamp ts2 = new TmfTimestamp(1000, 0, 50);
+ TmfTimestamp ts3 = new TmfTimestamp(1100, 0, 50);
+ TmfTimestamp ts4 = new TmfTimestamp(1000, 0, 75);
assertTrue("CompareTo", ts1.compareTo(ts1, true) == 0);
}
public void testCompareToLargeScale() throws Exception {
- TmfTimestamp ts1 = new TmfTimestamp(-1, (byte) 100);
- TmfTimestamp ts2 = new TmfTimestamp(-1000, (byte) -100);
- TmfTimestamp ts3 = new TmfTimestamp(1, (byte) 100);
- TmfTimestamp ts4 = new TmfTimestamp(1000, (byte) -100);
+ TmfTimestamp ts1 = new TmfTimestamp(-1, 100);
+ TmfTimestamp ts2 = new TmfTimestamp(-1000, -100);
+ TmfTimestamp ts3 = new TmfTimestamp(1, 100);
+ TmfTimestamp ts4 = new TmfTimestamp(1000, -100);
assertTrue("CompareTo", ts1.compareTo(ts2, false) < 0);
assertTrue("CompareTo", ts1.compareTo(ts3, false) < 0);
}
public void testCompareToBigRanges() throws Exception {
- TmfTimestamp ts0a = new TmfTimestamp( 0, Byte.MAX_VALUE);
- TmfTimestamp ts0b = new TmfTimestamp( 0, Byte.MIN_VALUE);
- TmfTimestamp ts1 = new TmfTimestamp(-1, Byte.MAX_VALUE);
- TmfTimestamp ts2 = new TmfTimestamp(-1, Byte.MIN_VALUE);
- TmfTimestamp ts3 = new TmfTimestamp( 1, Byte.MAX_VALUE);
- TmfTimestamp ts4 = new TmfTimestamp( 1, Byte.MIN_VALUE);
+ TmfTimestamp ts0a = new TmfTimestamp( 0, Integer.MAX_VALUE);
+ TmfTimestamp ts0b = new TmfTimestamp( 0, Integer.MIN_VALUE);
+ TmfTimestamp ts1 = new TmfTimestamp(-1, Integer.MAX_VALUE);
+ TmfTimestamp ts2 = new TmfTimestamp(-1, Integer.MIN_VALUE);
+ TmfTimestamp ts3 = new TmfTimestamp( 1, Integer.MAX_VALUE);
+ TmfTimestamp ts4 = new TmfTimestamp( 1, Integer.MIN_VALUE);
assertEquals("CompareTo", 1, ts0a.compareTo(TmfTimestamp.BigBang, false));
assertEquals("CompareTo", -1, ts0a.compareTo(TmfTimestamp.BigCrunch, false));
public void testDelta() throws Exception {
// Delta for same scale and precision (delta > 0)
- TmfTimestamp ts0 = new TmfTimestamp(10, (byte)9);
- TmfTimestamp ts1 = new TmfTimestamp(5, (byte)9);
- TmfTimestamp exp = new TmfTimestamp(5, (byte)9);
+ TmfTimestamp ts0 = new TmfTimestamp(10, 9);
+ TmfTimestamp ts1 = new TmfTimestamp(5, 9);
+ TmfTimestamp exp = new TmfTimestamp(5, 9);
- TmfTimestamp delta = ts0.getDelta(ts1);
+ ITmfTimestamp delta = ts0.getDelta(ts1);
assertEquals("getDelta", 0, delta.compareTo(exp, false));
// Delta for same scale and precision (delta < 0)
- ts0 = new TmfTimestamp(5, (byte)9);
- ts1 = new TmfTimestamp(10, (byte)9);
- exp = new TmfTimestamp(-5, (byte)9);
+ ts0 = new TmfTimestamp( 5, 9);
+ ts1 = new TmfTimestamp(10, 9);
+ exp = new TmfTimestamp(-5, 9);
delta = ts0.getDelta(ts1);
assertEquals("getDelta", 0, delta.compareTo(exp, false));
// Delta for different scale and same precision (delta > 0)
- ts0 = new TmfTimestamp(5, (byte)9);
- ts1 = new TmfTimestamp(10, (byte)8);
- exp = new TmfTimestamp(4, (byte)9);
+ ts0 = new TmfTimestamp( 5, 9);
+ ts1 = new TmfTimestamp(10, 8);
+ exp = new TmfTimestamp( 4, 9);
delta = ts0.getDelta(ts1);
assertEquals("getDelta", 0, delta.compareTo(exp, false));
// Delta for different scale and same precision (delta > 0)
- ts0 = new TmfTimestamp(5, (byte)9);
- ts1 = new TmfTimestamp(10, (byte)7);
- exp = new TmfTimestamp(5, (byte)9);
+ ts0 = new TmfTimestamp( 5, 9);
+ ts1 = new TmfTimestamp(10, 7);
+ exp = new TmfTimestamp( 5, 9);
delta = ts0.getDelta(ts1);
assertEquals("getDelta", 0, delta.compareTo(exp, false));
// Delta for different scale and same precision
- ts0 = new TmfTimestamp(10, (byte)9);
- ts1 = new TmfTimestamp(5, (byte)8);
- exp = new TmfTimestamp(10, (byte)9);
+ ts0 = new TmfTimestamp(10, 9);
+ ts1 = new TmfTimestamp( 5, 8);
+ exp = new TmfTimestamp(10, 9);
delta = ts0.getDelta(ts1);
assertEquals("getDelta", 0, delta.compareTo(exp, false));
// Delta for same scale and different precision
- ts0 = new TmfTimestamp(10, (byte)9,1);
- ts1 = new TmfTimestamp(5, (byte)9, 2);
- exp = new TmfTimestamp(5, (byte)9, 2);
+ ts0 = new TmfTimestamp(10, 9, 1);
+ ts1 = new TmfTimestamp( 5, 9, 2);
+ exp = new TmfTimestamp( 5, 9, 3);
delta = ts0.getDelta(ts1);
assertEquals("getDelta", 0, delta.compareTo(exp, true));
- assertEquals("precision", 2, delta.getPrecision());
+ assertEquals("precision", 3, delta.getPrecision());
// Delta for same scale and different precision
- ts0 = new TmfTimestamp(5, (byte)9, 2);
- ts1 = new TmfTimestamp(10, (byte)9, 1);
- exp = new TmfTimestamp(-5, (byte)9, 2);
+ ts0 = new TmfTimestamp( 5, 9, 2);
+ ts1 = new TmfTimestamp(10, 9, 1);
+ exp = new TmfTimestamp(-5, 9, 3);
delta = ts0.getDelta(ts1);
- assertEquals("getDelta", 0, delta.compareTo(exp, true));
- assertEquals("precision", 2, delta.getPrecision());
+ assertEquals("getDelta", 0, delta.compareTo(exp, true));
+ assertEquals("precision", 3, delta.getPrecision());
// Delta for different scale and different precision
- ts0 = new TmfTimestamp(5, (byte)9, 2);
- ts1 = new TmfTimestamp(10, (byte)8, 1);
- exp = new TmfTimestamp(4, (byte)9, 2);
- assertEquals("precision", 2, delta.getPrecision());
- assertEquals("precision", 2, delta.getPrecision());
-
+ ts0 = new TmfTimestamp( 5, 9, 2);
+ ts1 = new TmfTimestamp(10, 8, 1);
+ exp = new TmfTimestamp( 4, 9, 3);
delta = ts0.getDelta(ts1);
assertEquals("getDelta", 0, delta.compareTo(exp, true));
assertEquals("precision", 2, delta.getPrecision());
-org.eclipse.linuxtools.tmf/error=false
-org.eclipse.linuxtools.tmf/warning=false
-org.eclipse.linuxtools.tmf/info=false
+org.eclipse.linuxtools.tmf.core/error=false
+org.eclipse.linuxtools.tmf.core/warning=false
+org.eclipse.linuxtools.tmf.core/info=false
-org.eclipse.linuxtools.tmf/component=false
-org.eclipse.linuxtools.tmf/request=false
-org.eclipse.linuxtools.tmf/signal=false
-org.eclipse.linuxtools.tmf/event=false
+org.eclipse.linuxtools.tmf.core/component=false
+org.eclipse.linuxtools.tmf.core/request=false
+org.eclipse.linuxtools.tmf.core/signal=false
+org.eclipse.linuxtools.tmf.core/event=false
// ------------------------------------------------------------------------
// The plug-in ID
- public static final String PLUGIN_ID = "org.eclipse.linuxtools.tmf"; //$NON-NLS-1$
+ public static final String PLUGIN_ID = "org.eclipse.linuxtools.tmf.core"; //$NON-NLS-1$
// The shared instance
private static TmfCorePlugin fPlugin;
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event;
+
+import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace;
+
+/**
+ * <b><u>ITmfDataEvent</u></b>
+ * <p>
+ * The basic event structure in the TMF. In its canonical form, an event has:
+ * <ul>
+ * <li> a parent trace
+ * <li> a rank (order within the trace)
+ * <li> a source (reporting component)
+ * <li> a type
+ * <li> a content
+ * </ul>
+ * For convenience, a free-form reference field is also provided. It could be
+ * used as e.g. a location marker (filename:lineno) to indicate where the event
+ * was generated.
+ */
+public interface ITmfDataEvent {
+
+ /**
+ * @return the trace that 'owns' the event
+ */
+ public ITmfTrace<?> getTrace();
+
+ /**
+ * @return the event rank within the parent trace
+ */
+ public long getRank();
+
+ /**
+ * @return the event source
+ */
+ public String getSource();
+
+ /**
+ * @return the event type
+ */
+ public ITmfEventType getType();
+
+ /**
+ * @return the event content
+ */
+ public ITmfEventContent getContent();
+
+ /**
+ * @return the event reference
+ */
+ public String getReference();
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event;
+
+/**
+ * <b><u>ITmfEvent</u></b>
+ * <p>
+ * The ITmfEvent is essentially an ITmfDataEvent with a timestamp.
+*/
+public interface ITmfEvent extends ITmfDataEvent {
+
+ /**
+ * @return the event timestamp
+ */
+ public ITmfTimestamp getTimestamp();
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event;
+
+/**
+ * <b><u>ITmfEventContent</u></b>
+ * <p>
+ */
+public interface ITmfEventContent extends Cloneable {
+
+ /**
+ * @return the raw event content
+ */
+ public Object getRawContent();
+
+ /**
+ * @return the formatted event content (string'ified)
+ */
+ public String getFmtContent();
+
+ /**
+ * @return the event type
+ */
+ public ITmfEventType getType();
+
+ /**
+ * @return the list of event fields
+ */
+ public ITmfEventField[] getFields();
+
+ /**
+ * @param name the field name
+ * @return the corresponding field
+ */
+ public ITmfEventField getField(String name) throws TmfNoSuchFieldException;
+
+ /**
+ * @return a clone of the event content
+ */
+ public ITmfEventContent clone();
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event;
+
+/**
+ * <b><u>ITmfEventField</u></b>
+ * <p>
+ */
+public interface ITmfEventField {
+
+ /**
+ * @return the field name
+ */
+ public String getName();
+
+ /**
+ * @return the field value
+ */
+ public Object getValue();
+
+ /**
+ * @return the list of subfields (if any)
+ */
+ public ITmfEventField[] getSubFields();
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event;
+
+/**
+ * <b><u>ITmfEventType</u></b>
+ * <p>
+ */
+public interface ITmfEventType extends Cloneable {
+
+ /**
+ * @return the event type context
+ */
+ public String getContext();
+
+ /**
+ * @return the event type name
+ */
+ public String getName();
+
+ /**
+ * @return the event fields
+ */
+ public ITmfEventField[] getFields();
+
+ /**
+ * @return a clone of the event content
+ */
+ public ITmfEventType clone();
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2012 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Francois Chouinard - Initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.linuxtools.tmf.core.event;
+
+/**
+ * <b><u>ITmfTimestamp</u></b>
+ * <p>
+ */
+public interface ITmfTimestamp {
+
+ /**
+ * @return the timestamp value (magnitude)
+ */
+ public long getValue();
+
+ /**
+ * @return the timestamp scale (exponent)
+ */
+ public int getScale();
+
+ /**
+ * @return the timestamp precision (measurement tolerance)
+ */
+ public int getPrecision();
+
+ /**
+ * Normalize (adjust scale and offset) of the timerstamp
+ *
+ * @param offset the offset to apply to the timestamp value (after scaling)
+ * @param scale the new timestamp scale
+ * @return a new 'adjusted' ITmfTimestamp
+ */
+ public ITmfTimestamp normalize(long offset, int scale) throws ArithmeticException;
+
+ /**
+ * Compares [this] and [ts] within timestamp precision
+ *
+ * @param ts the other timestamp
+ * @param withinPrecision consider the precision when testing for equality
+ * @return -1, 0 or 1 (less than, equals, greater than)
+ */
+ public int compareTo(ITmfTimestamp ts, boolean withinPrecision);
+
+ /**
+ * Returns the difference between [this] and [ts] as a timestamp
+ *
+ * @param ts the other timestamp
+ * @return the time difference (this - other) as an ITmfTimestamp
+ */
+ public ITmfTimestamp getDelta(ITmfTimestamp ts);
+
+}
/**
* <b><u>TmfDataEvent</u></b>
* <p>
- * The basic event structure in the TMF. In its canonical form, an event has:
- * <ul>
- * <li> a parent trace
- * <li> a rank (order within the trace)
- * <li> a source (reporting component)
- * <li> a type
- * <li> a content
- * </ul>
- * For convenience, a free-form reference field is also provided. It could be
- * used as e.g. a location marker (filename:lineno) to indicate where the event
- * was generated.
+ * A basic implementation of ITmfDataEvent.
*
* Notice that for performance reasons TmfDataEvent is NOT immutable. If a copy
- * of an event is needed, use the copy constructor (shallow copy) or the
- * clone() method (deep copy).
+ * of an event is needed, use the copy constructor (shallow copy) or the clone()
+ * method (deep copy).
*/
public class TmfDataEvent implements Cloneable {
@Override
@SuppressWarnings("nls")
public String toString() {
- return "TmfDataEvent [fTrace=" + fTrace + ", fRank=" + fRank
- + ", fSource=" + fSource + ", fType=" + fType + ", fContent="
+ return "TmfDataEvent [fTrace=" + fTrace + ", fRank=" + fRank
+ + ", fSource=" + fSource + ", fType=" + fType + ", fContent="
+ fContent + ", fReference=" + fReference + "]";
}
* @param reference the event reference
*/
public TmfEvent(ITmfTrace<?> trace, long rank, TmfTimestamp timestamp, String source,
- TmfEventType type, String reference) {
+ TmfEventType type, String reference)
+ {
super(trace, rank, source, type, null, reference);
fTimestamp = timestamp;
}
* Constructor - no rank
*/
public TmfEvent(ITmfTrace<?> parentTrace, TmfTimestamp timestamp, String source,
- TmfEventType type, String reference) {
+ TmfEventType type, String reference)
+ {
this(parentTrace, -1, timestamp, source, type, reference);
}
/*******************************************************************************
- * Copyright (c) 2009, 2010 Ericsson
+ * Copyright (c) 2009, 2010, 2012 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
* Contributors:
* Francois Chouinard - Initial API and implementation
* Thomas Gatterweh - Updated scaling / synchronization
+ * Francois Chouinard - Refactoring to align with TMF Event Model 1.0
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.event;
/**
* <b><u>TmfTimestamp</u></b>
* <p>
- * The fundamental time reference in the TMF.
- * <p>
- * It provides a generic timestamp implementation in its most basic form:
- * <ul>
- * <li>timestamp = [value] * 10**[scale] +/- [precision]
- * </ul>
- * Where:
- * <ul>
- * <li>[value] is an unstructured integer value
- * <li>[scale] is the magnitude of the value wrt some application-specific
- * base unit (e.g. the second)
- * <li>[precision] indicates the error on the value (useful for comparing
- * timestamps in different scales). Default: 0.
- * </ul>
- * In short:
- * <ul>
- * </ul>
- * To allow synchronization of timestamps from different reference clocks,
- * there is a possibility to "adjust" the timestamp by changing its scale
- * (traces of different time scale) and/or by adding an offset to its value
- * (clock drift between traces).
- * <p>
- * Notice that the adjusted timestamp value could be negative e.g. for events
- * that occurred before t0 wrt the reference clock.
+ * A generic implementation of ITmfTimestamp.
*/
-public class TmfTimestamp implements Cloneable, Comparable<TmfTimestamp> {
-
- // ------------------------------------------------------------------------
- // Attributes
- // ------------------------------------------------------------------------
+public class TmfTimestamp implements ITmfTimestamp, Cloneable, Comparable<TmfTimestamp> {
- protected long fValue; // The timestamp raw value
- protected byte fScale; // The time scale
- protected long fPrecision; // The value precision (tolerance)
-
- // ------------------------------------------------------------------------
+ // ------------------------------------------------------------------------
// Constants
- // ------------------------------------------------------------------------
+ // ------------------------------------------------------------------------
// The beginning and end of time
- public static final TmfTimestamp BigBang = new TmfTimestamp(Long.MIN_VALUE, Byte.MAX_VALUE, 0);
- public static final TmfTimestamp BigCrunch = new TmfTimestamp(Long.MAX_VALUE, Byte.MAX_VALUE, 0);
- public static final TmfTimestamp Zero = new TmfTimestamp(0, (byte) 0, 0);
+ public static final TmfTimestamp BigBang = new TmfTimestamp(Long.MIN_VALUE, Integer.MAX_VALUE, 0);
+ public static final TmfTimestamp BigCrunch = new TmfTimestamp(Long.MAX_VALUE, Integer.MAX_VALUE, 0);
+ public static final TmfTimestamp Zero = new TmfTimestamp(0, 0, 0);
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
- // ------------------------------------------------------------------------
+ protected long fValue; // The timestamp raw value
+ protected int fScale; // The time scale
+ protected int fPrecision; // The value precision (tolerance)
+
+ // ------------------------------------------------------------------------
// Constructors
- // ------------------------------------------------------------------------
+ // ------------------------------------------------------------------------
/**
* Default constructor
*/
public TmfTimestamp() {
- this(0, (byte) 0, 0);
+ this(0, 0, 0);
}
/**
- * Simple constructor with value only
+ * Simple constructor (scale = precision = 0)
+ *
+ * @param value the timestamp value
*/
public TmfTimestamp(long value) {
- this(value, (byte) 0, 0);
+ this(value, 0, 0);
}
/**
- * Simple constructor with value and scale
+ * Simple constructor (precision = 0)
*
- * @param value
- * @param scale
+ * @param value the timestamp value
+ * @param scale the timestamp scale
*/
- public TmfTimestamp(long value, byte scale) {
+ public TmfTimestamp(long value, int scale) {
this(value, scale, 0);
}
/**
- * Constructor with value, scale and precision
+ * Full constructor
*
- * @param value
- * @param scale
- * @param precision
+ * @param value the timestamp value
+ * @param scale the timestamp scale
+ * @param precision the timestamp precision
*/
- public TmfTimestamp(long value, byte scale, long precision) {
+ public TmfTimestamp(long value, int scale, int precision) {
fValue = value;
fScale = scale;
fPrecision = Math.abs(precision);
/**
* Copy constructor
*
- * @param other
+ * @param timestamp the timestamp to copy
*/
- public TmfTimestamp(TmfTimestamp other) {
- if (other == null)
- throw new IllegalArgumentException();
- fValue = other.fValue;
- fScale = other.fScale;
- fPrecision = other.fPrecision;
+ public TmfTimestamp(TmfTimestamp timestamp) {
+ if (timestamp == null)
+ throw new IllegalArgumentException();
+ fValue = timestamp.fValue;
+ fScale = timestamp.fScale;
+ fPrecision = timestamp.fPrecision;
}
- // ------------------------------------------------------------------------
- // Accessors
- // ------------------------------------------------------------------------
+ // ------------------------------------------------------------------------
+ // ITmfTimestamp
+ // ------------------------------------------------------------------------
- /**
- * @return the timestamp value
- */
public long getValue() {
return fValue;
}
- /**
- * @return the timestamp scale
- */
- public byte getScale() {
+ public int getScale() {
return fScale;
}
- /**
- * @return the timestamp value precision
- */
- public long getPrecision() {
+ public int getPrecision() {
return fPrecision;
}
- // ------------------------------------------------------------------------
- // Operators
- // ------------------------------------------------------------------------
+ private static final long scalingFactors[] = new long[] {
+ 1L,
+ 10L,
+ 100L,
+ 1000L,
+ 10000L,
+ 100000L,
+ 1000000L,
+ 10000000L,
+ 100000000L,
+ 1000000000L,
+ 10000000000L,
+ 100000000000L,
+ 1000000000000L,
+ 10000000000000L,
+ 100000000000000L,
+ 1000000000000000L,
+ 10000000000000000L,
+ 100000000000000000L,
+ 1000000000000000000L,
+ };
- /**
- * Return a shifted and scaled timestamp.
- *
- * Limitation: The scaling is limited to MAX_SCALING orders of magnitude.
- * The main reason is that the 64 bits value starts to lose any significance
- * meaning beyond that scale difference and it's not even worth the trouble
- * to switch to BigDecimal arithmetics.
- *
- * @param offset the shift value (in the same scale as newScale)
- * @param newScale the new timestamp scale
- * @return the synchronized timestamp in the new scale
- * @throws ArithmeticException
- */
- public TmfTimestamp synchronize(long offset, byte newScale) throws ArithmeticException {
+ public ITmfTimestamp normalize(long offset, int scale) throws ArithmeticException {
- long newValue = fValue;
- long newPrecision = fPrecision;
+ long value = fValue;
+ int precision = fPrecision;
- // Handle the easy case
- if (fScale == newScale && offset == 0)
- return this;
-
- // Determine the scaling factor
- if (fScale != newScale) {
- int scaleDiff = Math.abs(fScale - newScale);
- // Let's try to be realistic...
+ // Handle the trivial case
+ if (fScale == scale && offset == 0)
+ return new TmfTimestamp(this);
+
+ // First, scale the timestamp
+ if (fScale != scale) {
+ int scaleDiff = Math.abs(fScale - scale);
if (scaleDiff >= scalingFactors.length) {
throw new ArithmeticException("Scaling exception"); //$NON-NLS-1$
}
- // Adjust the timestamp
+
long scalingFactor = scalingFactors[scaleDiff];
- if (newScale < fScale) {
- newValue *= scalingFactor;
- newPrecision *= scalingFactor;
+ if (scale < fScale) {
+ value *= scalingFactor;
+ precision *= scalingFactor;
} else {
- newValue /= scalingFactor;
- newPrecision /= scalingFactor;
+ value /= scalingFactor;
+ precision /= scalingFactor;
}
}
+ // Then, apply the offset
if (offset < 0) {
- newValue = (newValue < Long.MIN_VALUE - offset) ? Long.MIN_VALUE : newValue + offset;
+ value = (value < Long.MIN_VALUE - offset) ? Long.MIN_VALUE : value + offset;
} else {
- newValue = (newValue > Long.MAX_VALUE - offset) ? Long.MAX_VALUE : newValue + offset;
+ value = (value > Long.MAX_VALUE - offset) ? Long.MAX_VALUE : value + offset;
}
- return new TmfTimestamp(newValue, newScale, newPrecision);
+ return new TmfTimestamp(value, scale, precision);
}
- private static final long scalingFactors[] = new long[] {
- 1L,
- 10L,
- 100L,
- 1000L,
- 10000L,
- 100000L,
- 1000000L,
- 10000000L,
- 100000000L,
- 1000000000L,
- 10000000000L,
- 100000000000L,
- 1000000000000L,
- 10000000000000L,
- 100000000000000L,
- 1000000000000000L,
- 10000000000000000L,
- 100000000000000000L,
- 1000000000000000000L,
- };
+ public int compareTo(ITmfTimestamp ts, boolean withinPrecision) {
- private static final long scalingLimits[] = new long[] {
- Long.MAX_VALUE / 1L,
- Long.MAX_VALUE / 10L,
- Long.MAX_VALUE / 100L,
- Long.MAX_VALUE / 1000L,
- Long.MAX_VALUE / 10000L,
- Long.MAX_VALUE / 100000L,
- Long.MAX_VALUE / 1000000L,
- Long.MAX_VALUE / 10000000L,
- Long.MAX_VALUE / 100000000L,
- Long.MAX_VALUE / 1000000000L,
- Long.MAX_VALUE / 10000000000L,
- Long.MAX_VALUE / 100000000000L,
- Long.MAX_VALUE / 1000000000000L,
- Long.MAX_VALUE / 10000000000000L,
- Long.MAX_VALUE / 100000000000000L,
- Long.MAX_VALUE / 1000000000000000L,
- Long.MAX_VALUE / 10000000000000000L,
- Long.MAX_VALUE / 100000000000000000L,
- Long.MAX_VALUE / 1000000000000000000L,
- };
-
- public static long getScalingFactor(byte scale)
- {
- return scalingFactors[scale];
- }
-
- /**
- * Compute the adjustment, in the reference scale, needed to synchronize
- * this timestamp with a reference timestamp.
- *
- * @param reference the reference timestamp to synchronize with
- * @param scale the scale of the adjustment
- * @return the adjustment term in the reference time scale
- * @throws ArithmeticException
- */
- public long getAdjustment(TmfTimestamp reference, byte scale) throws ArithmeticException {
- TmfTimestamp ts1 = synchronize(0, scale);
- TmfTimestamp ts2 = reference.synchronize(0, scale);
- return ts2.fValue - ts1.fValue;
+ // Check the corner cases (we can't use equals() because it uses compareTo()...)
+ if (this == ts || (fValue == ts.getValue() && fScale == ts.getScale()))
+ return 0;
+ if ((fValue == BigBang.fValue && fScale == BigBang.fScale) || (ts.getValue() == BigCrunch.fValue && ts.getScale() == BigCrunch.fScale))
+ return -1;
+ if ((fValue == BigCrunch.fValue && fScale == BigCrunch.fScale) || (ts.getValue() == BigBang.fValue && ts.getScale() == BigBang.fScale))
+ return 1;
+
+ try {
+ ITmfTimestamp nts = ts.normalize(0, fScale);
+ long delta = fValue - nts.getValue();
+ if ((delta == 0) || (withinPrecision && (Math.abs(delta) <= (fPrecision + nts.getPrecision())))) {
+ return 0;
+ }
+ return (delta > 0) ? 1 : -1;
+ }
+ catch (ArithmeticException e) {
+ // Scaling error. We can figure it out nonetheless.
+
+ // First, look at the sign of the mantissa
+ long value = ts.getValue();
+ if (fValue == 0 && value == 0)
+ return 0;
+ if (fValue < 0 && value >= 0)
+ return -1;
+ if (fValue >= 0 && value < 0)
+ return 1;
+
+ // Otherwise, just compare the scales
+ int scale = ts.getScale();
+ return (fScale > scale) ? (fValue > 0) ? 1 : -1 : (fValue > 0) ? -1 : 1;
+ }
}
- /**
- * Compute the delta between two timestamps (adjusted to scale of current timestamp).
- *
- * @param reference the reference timestamp to synchronize with
- * @return the delta timestamp
- * @throws ArithmeticException
- */
- public TmfTimestamp getDelta(TmfTimestamp other) throws ArithmeticException {
- TmfTimestamp newSecond = other;
- if ((fScale != other.fScale) || (fPrecision != other.fPrecision)) {
- newSecond = other.synchronize(0, fScale);
- }
- return new TmfTimestamp(fValue - newSecond.fValue,
- fScale,
- newSecond.fPrecision > fPrecision ? newSecond.fPrecision : fPrecision);
+ @Override
+ public ITmfTimestamp getDelta(ITmfTimestamp ts) {
+ ITmfTimestamp nts = ts.normalize(0, fScale);
+ long value = fValue - nts.getValue();
+ return new TmfTimestamp(value, fScale, fPrecision + nts.getPrecision());
}
- /**
- * Compare with another timestamp
- *
- * @param other the other timestamp
- * @param withinPrecision indicates if precision is to be take into consideration
- * @return -1: this timestamp is lower (i.e. anterior)
- * 0: timestamps are equal (within precision if requested)
- * 1: this timestamp is higher (i.e. posterior)
- */
- public int compareTo(final TmfTimestamp other, boolean withinPrecision) {
-
- // If values have the same time scale, perform the comparison
- if (fScale == other.fScale) {
- if (withinPrecision)
- return compareWithinPrecision(this.fValue, this.fPrecision, other.fValue, other.fPrecision);
- else
- return compareNoPrecision(this.fValue, other.fValue);
- }
-
- // If values have different time scales, adjust to the finest one and
- // then compare. If the scaling difference is too large, revert to
- // some heuristics. Hopefully, nobody will try to compare galactic and
- // quantic clock events...
- int scaleDiff = Math.abs(fScale - other.fScale);
- long factor, limit;
- if (scaleDiff < scalingFactors.length) {
- factor = scalingFactors[scaleDiff];
- limit = scalingLimits[scaleDiff];
- } else {
- factor = 0;
- limit = 0; // !!! 0 can always be scaled!!!
- }
-
- if (fScale < other.fScale) {
- // this has finer scale, so other should be scaled
- if (withinPrecision)
- if (other.fValue > limit || other.fValue < -limit
- || other.fPrecision > limit
- || other.fPrecision < -limit)
- return other.fValue > 0 ? -1 : +1; // other exceeds scaling limit
- else
- return compareWithinPrecision(this.fValue, this.fPrecision,
- other.fValue * factor, other.fPrecision * factor);
- else if (other.fValue > limit || other.fValue < -limit)
- return other.fValue > 0 ? -1 : +1; // other exceeds scaling limit
- else
- return compareNoPrecision(this.fValue, other.fValue * factor);
- } else {
- // other has finer scale, so this should be scaled
- if (withinPrecision)
- if (this.fValue > limit || this.fValue < -limit
- || this.fPrecision > limit || this.fPrecision < -limit)
- return this.fValue > 0 ? +1 : -1; // we exceed scaling limit
- else
- return compareWithinPrecision(this.fValue * factor,
- this.fPrecision * factor, other.fValue,
- other.fPrecision);
- else if (this.fValue > limit || this.fValue < -limit)
- return this.fValue > 0 ? +1 : -1; // we exceed scaling limit
- else
- return compareNoPrecision(this.fValue * factor, other.fValue);
- }
+ // ------------------------------------------------------------------------
+ // Cloneable
+ // ------------------------------------------------------------------------
+
+ @Override
+ public TmfTimestamp clone() {
+ TmfTimestamp clone = null;
+ try {
+ clone = (TmfTimestamp) super.clone();
+ clone.fValue = fValue;
+ clone.fScale = fScale;
+ clone.fPrecision = fPrecision;
+ } catch (CloneNotSupportedException e) {
+ }
+ return clone;
}
- private static int compareNoPrecision(long thisValue, long otherValue) {
- return (thisValue == otherValue) ? 0 : (thisValue < otherValue) ? -1 : 1;
- }
+ // ------------------------------------------------------------------------
+ // Comparable
+ // ------------------------------------------------------------------------
- private static int compareWithinPrecision(long thisValue, long thisPrecision, long otherValue, long otherPrecision) {
- if ((thisValue + thisPrecision) < (otherValue - otherPrecision))
- return -1;
- if ((thisValue - thisPrecision) > (otherValue + otherPrecision))
- return 1;
- return 0;
- }
+ @Override
+ public int compareTo(TmfTimestamp o) {
+ return compareTo(o, false);
+ }
- // ------------------------------------------------------------------------
+ // ------------------------------------------------------------------------
// Object
- // ------------------------------------------------------------------------
+ // ------------------------------------------------------------------------
@Override
public int hashCode() {
- int result = 17;
- result = 37 * result + (int) (fValue ^ (fValue >>> 32));
- result = 37 * result + fScale;
- result = 37 * result + (int) (fPrecision ^ (fPrecision >>> 32));
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + (int) (fValue ^ (fValue >>> 32));
+ result = prime * result + fScale;
+ result = prime * result + fPrecision;
return result;
}
- @Override
+ @Override
public boolean equals(Object other) {
+ if (this == other)
+ return true;
+ if (other == null)
+ return false;
if (!(other instanceof TmfTimestamp))
- return false;
- TmfTimestamp o = (TmfTimestamp) other;
- return compareTo(o, false) == 0;
+ return false;
+ TmfTimestamp ts = (TmfTimestamp) other;
+ return compareTo(ts, false) == 0;
}
@Override
@SuppressWarnings("nls")
public String toString() {
- return "[TmfTimestamp(" + fValue + "," + fScale + "," + fPrecision + ")]";
- }
-
- @Override
- public TmfTimestamp clone() {
- TmfTimestamp clone = null;
- try {
- clone = (TmfTimestamp) super.clone();
- clone.fValue = fValue;
- clone.fScale = fScale;
- clone.fPrecision = fPrecision;
- } catch (CloneNotSupportedException e) {
- }
- return clone;
+ return "TmfTimestamp [fValue=" + fValue + ", fScale=" + fScale + ", fPrecision=" + fPrecision + "]";
}
- @Override
- public int compareTo(TmfTimestamp o) {
- return compareTo(o, false);
- }
-
}
TmfTimeRange range = new TmfTimeRange(new Uml2SDTestTimestamp(9789689220871L), new Uml2SDTestTimestamp(9789773881426L));
// Get range window for tests below
- TmfTimestamp rangeWindow = range.getEndTime().getDelta(range.getStartTime());
+ TmfTimestamp rangeWindow = (TmfTimestamp) range.getEndTime().getDelta(range.getStartTime());
TmfTimestamp currentTime = new Uml2SDTestTimestamp(9789773782043L);
fFacility.getTrace().broadcast(new TmfRangeSynchSignal(this, range, currentTime));
\r
public TimeChartEvent(TimeChartAnalysisEntry parentEntry, TmfEvent event, long rank, TimeChartDecorationProvider decorationProvider) {\r
fParentEntry = parentEntry;\r
- fTime = event.getTimestamp().synchronize((long) 0, TIMESTAMP_SCALE).getValue();\r
+ fTime = event.getTimestamp().normalize(0, TIMESTAMP_SCALE).getValue();\r
fDuration = 0;\r
fFirstRank = fLastRank = rank;\r
fRankRangeList = new RankRangeList(rank);\r
\r
public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.timechart"; //$NON-NLS-1$\r
\r
- private static final byte TIMESTAMP_SCALE = -9;\r
+ private static final int TIMESTAMP_SCALE = -9;\r
\r
private final int fDisplayWidth;\r
private Composite fComposite;\r
private ITimeAnalysisViewer fViewer;\r
private final ArrayList<TimeChartAnalysisEntry> fTimeAnalysisEntries = new ArrayList<TimeChartAnalysisEntry>();\r
- private final Map<ITmfTrace, TimeChartDecorationProvider> fDecorationProviders = new HashMap<ITmfTrace, TimeChartDecorationProvider>();\r
+ private final Map<ITmfTrace<?>, TimeChartDecorationProvider> fDecorationProviders = new HashMap<ITmfTrace<?>, TimeChartDecorationProvider>();\r
private ArrayList<DecorateThread> fDecorateThreads;\r
private long fStartTime = 0;\r
private long fStopTime = Long.MAX_VALUE;\r
for (IEditorReference editorReference : editorReferences) {\r
IEditorPart editor = editorReference.getEditor(false);\r
if (editor instanceof ITmfTraceEditor) {\r
- ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();\r
+ ITmfTrace<?> trace = ((ITmfTraceEditor) editor).getTrace();\r
if (trace != null) {\r
IResource resource = ((ITmfTraceEditor) editor).getResource();\r
TimeChartAnalysisEntry timeAnalysisEntry = new TimeChartAnalysisEntry(trace, fDisplayWidth * 2);\r
}\r
\r
private void updateTraceEntry(TimeChartAnalysisEntry timeAnalysisEntry, long stopRank, long startTime, long stopTime) {\r
- ITmfTrace trace = timeAnalysisEntry.getTrace();\r
+ ITmfTrace<?> trace = timeAnalysisEntry.getTrace();\r
TimeChartDecorationProvider decorationProvider = fDecorationProviders.get(trace);\r
if (decorationProvider == null) {\r
return; // the trace has been closed\r
public void decorateEvent(TimeChartEvent timeChartEvent) {\r
// TODO possible concurrency problem here with ItemizeJob\r
TimeChartAnalysisEntry timeAnalysisEntry = (TimeChartAnalysisEntry) timeChartEvent.getEntry();\r
- ITmfTrace trace = timeAnalysisEntry.getTrace();\r
+ ITmfTrace<?> trace = timeAnalysisEntry.getTrace();\r
int priority = ColorSettingsManager.PRIORITY_NONE;\r
boolean isBookmarked = false;\r
boolean isVisible = false;\r
if (event == null) {\r
break;\r
}\r
- long eventTime = event.getTimestamp().synchronize(0, (byte) -9).getValue();\r
+ long eventTime = event.getTimestamp().normalize(0, -9).getValue();\r
if (eventTime >= timeChartEvent.getTime() && eventTime <= timeChartEvent.getTime() + timeChartEvent.getDuration()) {\r
priority = Math.min(priority, ColorSettingsManager.getColorSettingPriority(event));\r
}\r
}\r
\r
@Override\r
- public void filterApplied(ITmfFilter filter, ITmfTrace trace) {\r
+ public void filterApplied(ITmfFilter filter, ITmfTrace<?> trace) {\r
TimeChartDecorationProvider decorationProvider = fDecorationProviders.get(trace);\r
decorationProvider.filterApplied(filter);\r
redecorate();\r
}\r
\r
@Override\r
- public void searchApplied(ITmfFilter filter, ITmfTrace trace) {\r
+ public void searchApplied(ITmfFilter filter, ITmfTrace<?> trace) {\r
TimeChartDecorationProvider decorationProvider = fDecorationProviders.get(trace);\r
decorationProvider.searchApplied(filter);\r
redecorate();\r
public void traceOpened(TmfTraceOpenedSignal signal) {\r
if (fTimeAnalysisEntries == null)\r
return;\r
- final ITmfTrace trace = signal.getTrace();\r
+ final ITmfTrace<?> trace = signal.getTrace();\r
final IResource resource = signal.getResource();\r
final ITmfEventsFilterProvider eventsFilterProvider = signal.getEventsFilterProvider();\r
TimeChartAnalysisEntry timeAnalysisEntry = null;\r
public void traceClosed(TmfTraceClosedSignal signal) {\r
if (fTimeAnalysisEntries == null)\r
return;\r
- final ITmfTrace trace = signal.getTrace();\r
+ final ITmfTrace<?> trace = signal.getTrace();\r
for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {\r
if (fTimeAnalysisEntries.get(i).getTrace().equals(trace)) {\r
fTimeAnalysisEntries.remove(i);\r
@TmfSignalHandler\r
public void traceSelected(TmfTraceSelectedSignal signal) {\r
if (signal.getSource() != this && fTimeAnalysisEntries != null) {\r
- ITmfTrace trace = signal.getTrace();\r
+ ITmfTrace<?> trace = signal.getTrace();\r
for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {\r
if (fTimeAnalysisEntries.get(i).getTrace().equals(trace)) {\r
fViewer.setSelectedTrace(fTimeAnalysisEntries.get(i));\r
public void traceUpdated(TmfTraceUpdatedSignal signal) {\r
if (fTimeAnalysisEntries == null)\r
return;\r
- final ITmfTrace trace = signal.getTrace();\r
+ final ITmfTrace<?> trace = signal.getTrace();\r
for (int i = 0; i < fTimeAnalysisEntries.size(); i++) {\r
TimeChartAnalysisEntry timeAnalysisEntry = fTimeAnalysisEntries.get(i);\r
if (timeAnalysisEntry.getTrace().equals(trace)) {\r
\r
@TmfSignalHandler\r
public void currentTimeUpdated(TmfTimeSynchSignal signal) {\r
- long time = signal.getCurrentTime().synchronize(0, TIMESTAMP_SCALE).getValue();\r
+ long time = signal.getCurrentTime().normalize(0, TIMESTAMP_SCALE).getValue();\r
fViewer.setSelectedTime(time, true, this);\r
}\r
\r
int step = SCALE_LENGTH / 10;
// double gr = (max - min) / 10;
- TmfTimestamp minMaxdelta = minMaxRange.getEndTime().getDelta(minMaxRange.getStartTime());
+ TmfTimestamp minMaxdelta = (TmfTimestamp) minMaxRange.getEndTime().getDelta(minMaxRange.getStartTime());
double gr = (minMaxdelta.getValue()) / (double) 10;
// double delta = currentValue-min;
- TmfTimestamp delta = currentValue.getDelta(minMaxRange.getStartTime());
+ TmfTimestamp delta = (TmfTimestamp) currentValue.getDelta(minMaxRange.getStartTime());
long absDelta = Math.abs(delta.getValue());
int colIndex = 0;
//double delta = ((ITimeRange)toolTipNode).getLastTime()-((ITimeRange)currentGraphNode).getLastTime();
TmfTimestamp firstTime = ((ITimeRange) currentGraphNode).getEndTime();
TmfTimestamp lastTime = ((ITimeRange) toolTipNode).getEndTime();
- TmfTimestamp delta = lastTime.getDelta(firstTime);
+ TmfTimestamp delta = (TmfTimestamp) lastTime.getDelta(firstTime);
postfix += delta.toString();
} else {
if ((toolTipNode instanceof ITimeRange) && ((ITimeRange) toolTipNode).hasTimeInfo()) {
min = frame.getMinTime();
max = frame.getMaxTime();
- TmfTimestamp minMaxdelta = max.getDelta(min);
+ TmfTimestamp minMaxdelta = (TmfTimestamp) max.getDelta(min);
double gr = (minMaxdelta.getValue()) / (double) 10;
- TmfTimestamp delta = m2.getTime().getDelta(m1.getTime()).getDelta(min);
+ TmfTimestamp delta = (TmfTimestamp) m2.getTime().getDelta(m1.getTime()).getDelta(min);
long absDelta = Math.abs(delta.getValue());
ColorImpl color;
int m1Y = Math.round(y1 * zoomValue);
int m2Y = Math.round(y2 * zoomValue);
if ((m1Y < e.y) && (m2Y >= e.y)) {
- TmfTimestamp delta = m2.getTime().getDelta(m1.getTime());
+ TmfTimestamp delta = (TmfTimestamp) m2.getTime().getDelta(m1.getTime());
tooltip.showToolTip(delta, min, max);
}
}
}
}
- TmfTimestamp minMaxdelta = max.getDelta(min);
+ TmfTimestamp minMaxdelta = (TmfTimestamp) max.getDelta(min);
double gr = (minMaxdelta.getValue()) / (double) 10;
- TmfTimestamp delta = time2.getDelta(time1).getDelta(min);
+ TmfTimestamp delta = (TmfTimestamp) time2.getDelta(time1).getDelta(min);
long absDelta = Math.abs(delta.getValue());
int colIndex = 0;
done = true;
prevNodeY = m1Y;
nextNodeY = m2Y;
- TmfTimestamp minMaxdelta = max.getDelta(min);
+ TmfTimestamp minMaxdelta = (TmfTimestamp) max.getDelta(min);
double gr = (minMaxdelta.getValue()) / (double) 10;
- TmfTimestamp delta = m2.getTime().getDelta(m1.getTime()).getDelta(min);
+ TmfTimestamp delta = (TmfTimestamp) m2.getTime().getDelta(m1.getTime()).getDelta(min);
long absDelta = Math.abs(delta.getValue());
int colIndex = 0;
int m1Y = Math.round(y1 * zoomValue);
int m2Y = Math.round(y2 * zoomValue);
if ((m1Y < prevNodeY + 1) && (m2Y >= prevNodeY + 1)) {
- TmfTimestamp delta = m2.getTime().getDelta(m1.getTime());
+ TmfTimestamp delta = (TmfTimestamp) m2.getTime().getDelta(m1.getTime());
tooltip.showToolTip(delta, min, max);
tooltip.hideToolTip();
}
}
protected void updateMinMax(SDTimeEvent m1, SDTimeEvent m2) {
- TmfTimestamp delta = m2.getTime().getDelta(m1.getTime());
+ TmfTimestamp delta = (TmfTimestamp) m2.getTime().getDelta(m1.getTime());
if (computeMinMax) {
minTime = delta.clone();
if (minTime.compareTo(TmfTimestamp.Zero, false) < 0) {
try {
if ((signal.getSource() != this) && (fFrame != null) && !fIsSignalSent) {
TmfTimeRange newTimeRange = signal.getCurrentRange();
- TmfTimestamp delta = newTimeRange.getEndTime().getDelta(newTimeRange.getStartTime());
+ TmfTimestamp delta = (TmfTimestamp) newTimeRange.getEndTime().getDelta(newTimeRange.getStartTime());
fInitialWindow = delta.getValue();
fIsSelect = false;
// double max=0;
long min = 0;
long max = 0;
- byte scale = 0;
- long precision = 0;
+ int scale = 0;
+ int precision = 0;
try {
min = Long.parseLong(minText.getText());
max = Long.parseLong(maxText.getText());
- scale = Byte.parseByte(scaleText.getText());
- precision = Long.parseLong(precisionText.getText());
+ scale = Integer.parseInt(scaleText.getText());
+ precision = Integer.parseInt(precisionText.getText());
sdWidget.getFrame().setMax(new TmfTimestamp(max, scale, precision));
sdWidget.getFrame().setMin(new TmfTimestamp(min, scale, precision));