|
65 | 65 | import org.eclipse.tracecompass.tmf.core.event.aspect.TmfBaseAspects; |
66 | 66 | import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException; |
67 | 67 | import org.eclipse.tracecompass.tmf.core.project.model.ITmfPropertiesProvider; |
| 68 | +import org.eclipse.tracecompass.tmf.core.synchronization.ITmfTimestampTransform; |
68 | 69 | import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp; |
69 | 70 | import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange; |
70 | 71 | import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; |
@@ -218,18 +219,11 @@ public void initTrace(final IResource resource, final String path, final Class<? |
218 | 219 |
|
219 | 220 | try { |
220 | 221 | this.fTrace = new CTFTrace(path); |
221 | | - CtfTmfContext ctx; |
222 | 222 | /* Set the start and (current) end times for this trace */ |
223 | | - ctx = (CtfTmfContext) seekEvent(0L); |
224 | | - CtfTmfEvent event = getNext(ctx); |
225 | | - if ((ctx.getLocation().equals(CtfIterator.NULL_LOCATION)) || (ctx.getCurrentEvent() == null)) { |
226 | | - /* Handle the case where the trace is empty */ |
227 | | - this.setStartTime(TmfTimestamp.BIG_BANG); |
228 | | - } else { |
229 | | - final ITmfTimestamp curTime = event.getTimestamp(); |
230 | | - this.setStartTime(curTime); |
231 | | - long endTime = Math.max(curTime.getValue(), fTrace.getCurrentEndTime()); |
232 | | - this.setEndTime(TmfTimestamp.fromNanos(endTime)); |
| 223 | + CtfTmfContext ctx = resetTimes(); |
| 224 | + |
| 225 | + if (ctx == null) { |
| 226 | + return; |
233 | 227 | } |
234 | 228 | /* |
235 | 229 | * Register every event type. When you call getType, it will register a trace to |
@@ -913,4 +907,30 @@ public Path trim(@NonNull TmfTimeRange range, @NonNull Path destinationPath, @No |
913 | 907 | return null; |
914 | 908 | } |
915 | 909 |
|
| 910 | + @Override |
| 911 | + public void setTimestampTransform(final ITmfTimestampTransform tt) { |
| 912 | + super.setTimestampTransform(tt); |
| 913 | + resetTimes(); |
| 914 | + } |
| 915 | + |
| 916 | + private @Nullable CtfTmfContext resetTimes() { |
| 917 | + /* Set the start and (current) end times for this trace */ |
| 918 | + CtfTmfContext ctx = (CtfTmfContext) seekEvent(0L); |
| 919 | + CtfTmfEvent event = getNext(ctx); |
| 920 | + /* Verify context is valid. It's only invalid trace if trace.init() hasn't been called) */ |
| 921 | + if ((ctx != null) && (ctx.getLocation() != null)) { |
| 922 | + if ((ctx.getLocation().equals(CtfIterator.NULL_LOCATION)) || (ctx.getCurrentEvent() == null)) { |
| 923 | + /* Handle the case where the trace is empty */ |
| 924 | + this.setStartTime(TmfTimestamp.BIG_BANG); |
| 925 | + } else { |
| 926 | + final ITmfTimestamp curTime = event.getTimestamp(); |
| 927 | + this.setStartTime(curTime); |
| 928 | + long endTime = createTimestamp(fTrace.getCurrentEndTime()).getValue(); |
| 929 | + endTime = Math.max(curTime.getValue(), endTime); |
| 930 | + this.setEndTime(TmfTimestamp.fromNanos(endTime)); |
| 931 | + } |
| 932 | + return ctx; |
| 933 | + } |
| 934 | + return null; |
| 935 | + } |
916 | 936 | } |
0 commit comments