public class StateProviderModelTest {
private static final @NonNull String testTrace1 = "test_traces/testTrace1.xml";
- /* Factor to convert seconds to nanoseconds */
- private static final long TO_NS = 1000000000L;
private static @NonNull ITmfTrace initializeTrace(String traceFile) {
/* Initialize the trace */
private static void verifyStateIntervals(String testId, @NonNull ITmfStateSystem ss, Integer quark, int[] expectedStarts, ITmfStateValue[] expectedValues) throws AttributeNotFoundException, StateSystemDisposedException {
int expectedCount = expectedStarts.length - 1;
- List<ITmfStateInterval> intervals = StateSystemUtils.queryHistoryRange(ss, quark, expectedStarts[0] * TO_NS, expectedStarts[expectedCount] * TO_NS);
+ List<ITmfStateInterval> intervals = StateSystemUtils.queryHistoryRange(ss, quark, expectedStarts[0], expectedStarts[expectedCount]);
assertEquals(testId + ": Interval count", expectedCount, intervals.size());
for (int i = 0; i < expectedCount; i++) {
ITmfStateInterval interval = intervals.get(i);
- assertEquals(testId + ": Start time of interval " + i, expectedStarts[i] * TO_NS, interval.getStartTime());
- long actualEnd = (i == expectedCount - 1) ? (expectedStarts[i + 1] * TO_NS) : (expectedStarts[i + 1] * TO_NS) - 1;
+ assertEquals(testId + ": Start time of interval " + i, expectedStarts[i], interval.getStartTime());
+ long actualEnd = (i == expectedCount - 1) ? (expectedStarts[i + 1]) : (expectedStarts[i + 1]) - 1;
assertEquals(testId + ": End time of interval " + i, actualEnd, interval.getEndTime());
assertEquals(testId + ": Expected value of interval " + i, expectedValues[i], interval.getStateValue());
}
import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition;
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfNanoTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.core.trace.TmfContext;
import org.eclipse.tracecompass.tmf.core.trace.TmfTrace;
private static final String ASPECT_SPECIAL_EVENT = "set_aspects";
private static final String ASPECT_CPU = "cpu";
+ private static final Long SECONDS_TO_NS = 1000000000L;
+
private final CustomXmlTrace fTrace;
private Collection<ITmfEventAspect> fAspects;
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, NLS.bind(org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.Messages.TmfDevelopmentTrace_IoError, path), e);
}
@SuppressWarnings("null")
- @NonNull IStatus status = Status.OK_STATUS;
+ @NonNull
+ IStatus status = Status.OK_STATUS;
return status;
}
ITmfEventType customEventType = event.getType();
TmfEventType eventType = new TmfEventType(eventName, customEventType.getRootField());
ITmfEventField eventFields = new CustomEventContent(content.getName(), content.getValue(), fieldsArray);
- // FIXME We used to use getSource() to get the CPU. Now this will have
- // to be done differently.
- TmfEvent newEvent = new TmfEvent(this, ITmfContext.UNKNOWN_RANK, event.getTimestamp(), eventType, eventFields);
+ /*
+ * TODO: Timestamps for these traces are in nanos, but since the
+ * CustomXmlTrace does not support this format, the timestamp of the
+ * original is in second and we need to convert it. We should do that at
+ * the source when it is supported
+ */
+ ITmfTimestamp timestamp = new TmfNanoTimestamp(event.getTimestamp().getValue() / SECONDS_TO_NS);
+ TmfEvent newEvent = new TmfEvent(this, ITmfContext.UNKNOWN_RANK, timestamp, eventType, eventFields);
updateAttributes(savedContext, event.getTimestamp());
context.increaseRank();
return fAspects;
}
-
-
}