use of org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet in project tracecompass by tracecompass.
the class CustomAnnotationProviderTest method testOffset.
/**
* Test offset
*/
@Test
public void testOffset() {
List<Annotation> annotationList;
MarkerSet set = new MarkerSet("name", "id");
fProvider.configure(set);
assertAnnotationCategoriesModelResponse(Collections.emptyList(), fProvider.fetchAnnotationCategories(Collections.emptyMap(), new NullProgressMonitor()));
/*
* period: 10 cycles (40ns), offset: -10 cycles (-40ns), reference:
* 1000ns[0], range: 0..
*
* requested range: 1000 ns-2000 ns
*
* expected annotations: 960 ns[0] 1000 ns[1] 1040 ns[2] ... 2000 ns[26]
* 2040 ns[27]
*/
Marker markerC = new PeriodicMarker("C", "C %d", "c", "ref.c", COLOR_STR, 10.0, "cycles", Range.atLeast(0L), -10L, ImmutableRangeSet.of(Range.all()));
set.addMarker(markerC);
fProvider.configure(set);
assertAnnotationCategoriesModelResponse(Arrays.asList("C"), fProvider.fetchAnnotationCategories(Collections.emptyMap(), new NullProgressMonitor()));
annotationList = getAnnotationList("C", 1000L, 2000L, 1L, new NullProgressMonitor());
assertEquals(28, annotationList.size());
for (int i = 0; i < annotationList.size(); i++) {
long t = (i + 24) * 40L;
// -25 +1 for offset
int index = i + 24 - 25 + 1;
RGBAColor color = index % 2 == 0 ? COLOR : ODD_COLOR;
validateAnnotation(annotationList.get(i), t, 40L, "C", String.format("C %d", index), color);
}
}
use of org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet in project tracecompass by tracecompass.
the class CustomAnnotationProviderTest method testIrregular.
/**
* Test irregular
*/
@Test
public void testIrregular() {
List<Annotation> annotationList;
MarkerSet set = new MarkerSet("name", "id");
fProvider.configure(set);
assertAnnotationCategoriesModelResponse(Collections.emptyList(), fProvider.fetchAnnotationCategories(Collections.emptyMap(), new NullProgressMonitor()));
/*
* period: 40 ns, offset: 0 ns, range: 0..49, indexRange: 30..31,40
*
* requested range: 0 ns-4000 ns
*
* expected annotations: 1200 ns[30] 1240 ns[31] 1600 ns[40] 3200 ns[30]
* 3240 ns[31] 3600 ns[40]
*/
Marker markerD = new PeriodicMarker("D", "D %d", "d", "ref.d", COLOR_STR, 40.0, "ns", Range.closed(0L, 49L), 0L, ImmutableRangeSet.<Long>builder().add(Range.closed(30L, 31L)).add(Range.singleton(40L)).build());
set.addMarker(markerD);
fProvider.configure(set);
assertAnnotationCategoriesModelResponse(Arrays.asList("D"), fProvider.fetchAnnotationCategories(Collections.emptyMap(), new NullProgressMonitor()));
annotationList = getAnnotationList("D", 0L, 4000L, 1L, new NullProgressMonitor());
assertEquals(6, annotationList.size());
int i = 0;
for (long t = 0L; t < 4000L; t += 40L) {
int index = (int) (t / 40L) % 50;
if (index == 30L || index == 31L || index == 40L) {
Annotation annotation = annotationList.get(i++);
RGBAColor color = index % 2 == 0 ? COLOR : ODD_COLOR;
validateAnnotation(annotation, t, 40L, "D", String.format("D %d", index), color);
}
}
}
use of org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet in project tracecompass by tracecompass.
the class CustomAnnotationProviderTest method testSubmarkers.
/**
* Test submarkers
*/
@Test
public void testSubmarkers() {
List<Annotation> annotationList;
MarkerSet set = new MarkerSet("name", "id");
fProvider.configure(set);
assertAnnotationCategoriesModelResponse(Collections.emptyList(), fProvider.fetchAnnotationCategories(Collections.emptyMap(), new NullProgressMonitor()));
/*
* period: 10 ms, offset: 20 ms, range: 0..4
*
* requested range: 100 ms-200 ms
*
* expected annotations: 90 ms[2] 100 ms[3] 110 ms[4] 120 ms[0] ... 200
* ms[3] 210 ms[4]
*/
Marker markerA = new PeriodicMarker("A", "A %d", "a", "ref.a", COLOR_STR, 10.0, "ms", Range.closed(0L, 4L), 20L, ImmutableRangeSet.of(Range.all()));
set.addMarker(markerA);
fProvider.configure(set);
/*
* period: 10 us, offset: 20 ms, range: 1..1000
*
* requested range: 100 ms-200 ms
*
* expected annotations: 99.99 ms[1000] 100.00 ms[1] 100.01 ms[2] 100.02
* ms[2] ... 200.00 ms[1]
*/
SubMarker markerB = new SplitMarker("B", "B %d", "b", COLOR_STR, Range.closed(1L, 1000L), ImmutableRangeSet.of(Range.all()));
markerA.addSubMarker(markerB);
fProvider.configure(set);
assertAnnotationCategoriesModelResponse(Arrays.asList("A", "B"), fProvider.fetchAnnotationCategories(Collections.emptyMap(), new NullProgressMonitor()));
annotationList = getAnnotationList("B", 100000000L, 200000000L, 10000L, new NullProgressMonitor());
assertEquals(0, annotationList.size());
annotationList = getAnnotationList("B", 100000000L, 200000000L, 1000L, new NullProgressMonitor());
assertEquals(10002, annotationList.size());
for (int i = 0; i < annotationList.size(); i++) {
long t = (i + 9999) * 10000L;
int index = (i + 9999) - 2000;
int labelIndex = 1 + index % 1000;
RGBAColor color = labelIndex % 2 == 0 ? COLOR : ODD_COLOR;
validateAnnotation(annotationList.get(i), t, 10000L, "B", String.format("B %d", labelIndex), color);
}
}
use of org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet in project tracecompass by tracecompass.
the class CustomOutputAnnotationProvider method fetchAnnotations.
@Override
public TmfModelResponse<AnnotationModel> fetchAnnotations(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
Object markerID = fetchParameters.get(DataProviderParameterUtils.REQUESTED_MARKER_SET_KEY);
Object hostID = fetchParameters.get(DataProviderParameterUtils.REQUESTED_TRACE_KEY);
Optional<ITmfTrace> requestedTrace = getTrace(hostID);
/*
* Ignore if trace is not the requested trace, or if no requested trace,
* if the trace is not the first element of its trace set.
*/
if ((requestedTrace.isPresent() && !requestedTrace.get().equals(fTrace)) || (!requestedTrace.isPresent() && !isFirstTrace())) {
// $NON-NLS-1$
return new TmfModelResponse<>(null, Status.COMPLETED, "");
}
if (markerID == null) {
return new TmfModelResponse<>(null, Status.FAILED, NO_MARKER_ID);
}
MarkerSet ms = getMarkerSet(markerID);
if (ms == null) {
return new TmfModelResponse<>(null, Status.FAILED, formatError(markerID));
}
return getAnnotationProvider(requestedTrace.isPresent() ? requestedTrace.get() : null, ms).fetchAnnotations(fetchParameters, monitor);
}
Aggregations