Search in sources :

Example 1 with MarkerSet

use of org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet in project tracecompass by tracecompass.

the class MarkerConfigXmlParserTest method testParseInvalidContent.

private static void testParseInvalidContent(String content) throws IOException {
    File file = File.createTempFile("markers", "xml");
    try (FileWriter fw = new FileWriter(file)) {
        fw.write(content);
        fw.flush();
        List<MarkerSet> markerSets = MarkerConfigXmlParser.parse(file.getAbsolutePath());
        assertEquals(0, markerSets.size());
    } finally {
        file.delete();
    }
}
Also used : MarkerSet(org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet) FileWriter(java.io.FileWriter) File(java.io.File)

Example 2 with MarkerSet

use of org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet in project tracecompass by tracecompass.

the class MarkerConfigXmlParserTest method testParse.

/**
 * Test the parse method
 *
 * @throws IOException if an exception occurs
 */
@Test
public void testParse() throws IOException {
    File file = File.createTempFile("markers", "xml");
    try (FileWriter fw = new FileWriter(file)) {
        fw.write(XML_CONTENT);
        fw.flush();
        List<MarkerSet> markerSets = MarkerConfigXmlParser.parse(file.getAbsolutePath());
        assertEquals(2, markerSets.size());
        MarkerSet setA = markerSets.get(0);
        assertEquals("Set A", setA.getName());
        assertEquals("set.a", setA.getId());
        assertEquals(3, setA.getMarkers().size());
        PeriodicMarker markerA1 = (PeriodicMarker) setA.getMarkers().get(0);
        assertEquals("Marker A-1", markerA1.getName());
        assertEquals("A-1 %d", markerA1.getLabel());
        assertEquals("marker.a.1", markerA1.getId());
        assertEquals("ref.a.1", markerA1.getReferenceId());
        assertEquals("#0000ff", markerA1.getColor());
        assertEquals(10.0, markerA1.getPeriod(), 0);
        assertEquals("ms", markerA1.getUnit());
        assertEquals(Range.closed(0L, 4095L), markerA1.getRange());
        assertEquals(0, markerA1.getOffset());
        assertEquals(1, markerA1.getSubMarkers().size());
        SplitMarker submarkerA11 = (SplitMarker) markerA1.getSubMarkers().get(0);
        assertEquals("Submarker A-1-1", submarkerA11.getName());
        assertEquals("A-1-1 %d", submarkerA11.getLabel());
        assertEquals("submarker.a.1.1", submarkerA11.getId());
        assertEquals("#000000", submarkerA11.getColor());
        assertEquals(Range.closed(0L, 99L), submarkerA11.getRange());
        assertEquals(1, submarkerA11.getSubMarkers().size());
        SplitMarker submarkerA111 = (SplitMarker) submarkerA11.getSubMarkers().get(0);
        assertEquals("Submarker A-1-1-1", submarkerA111.getName());
        assertEquals("A-1-1-1 %d", submarkerA111.getLabel());
        assertEquals("submarker.a.1.1.1", submarkerA111.getId());
        assertEquals("#000000", submarkerA111.getColor());
        assertEquals(Range.closed(0L, 9L), submarkerA111.getRange());
        assertEquals(0, submarkerA111.getSubMarkers().size());
        PeriodicMarker markerA2 = (PeriodicMarker) setA.getMarkers().get(1);
        assertEquals("Marker A-2", markerA2.getName());
        assertEquals("A-2 %d", markerA2.getLabel());
        assertEquals("marker.a.2", markerA2.getId());
        assertEquals("ref.a.2", markerA2.getReferenceId());
        assertEquals("#ff0000", markerA2.getColor());
        assertEquals(20.0, markerA2.getPeriod(), 0);
        assertEquals("us", markerA2.getUnit());
        assertEquals(Range.atLeast(0L), markerA2.getRange());
        assertEquals(0, markerA2.getOffset());
        assertEquals(0, markerA2.getSubMarkers().size());
        PeriodicMarker markerA3 = (PeriodicMarker) setA.getMarkers().get(2);
        assertEquals("Marker A-3", markerA3.getName());
        assertEquals("A-3 %d", markerA3.getLabel());
        assertEquals("marker.a.3", markerA3.getId());
        assertEquals("ref.a.3", markerA3.getReferenceId());
        assertEquals("#00ff00", markerA3.getColor());
        assertEquals(2.5, markerA3.getPeriod(), 0);
        assertEquals("ns", markerA3.getUnit());
        assertEquals(Range.atLeast(0L), markerA3.getRange());
        assertEquals(0, markerA3.getOffset());
        assertEquals(1, markerA3.getSubMarkers().size());
        WeightedMarker submarkerA31 = (WeightedMarker) markerA3.getSubMarkers().get(0);
        assertEquals("Submarker A-3-1", submarkerA31.getName());
        assertEquals(0, submarkerA31.getSubMarkers().size());
        assertEquals(2, submarkerA31.getSegments().size());
        MarkerSegment submarkerA31a = submarkerA31.getSegments().get(0);
        assertEquals(null, submarkerA31a.getName());
        assertEquals("A-3-1-a %d", submarkerA31a.getLabel());
        assertEquals("marker.a.3.1.a", submarkerA31a.getId());
        assertEquals("#aaaaaa", submarkerA31a.getColor());
        assertEquals(1, submarkerA31a.getLength());
        assertEquals(0, submarkerA31a.getSubMarkers().size());
        MarkerSegment submarkerA31b = submarkerA31.getSegments().get(1);
        assertEquals(null, submarkerA31b.getName());
        assertEquals("A-3-1-b %d", submarkerA31b.getLabel());
        assertEquals("marker.a.3.1.b", submarkerA31b.getId());
        assertEquals("#bbbbbb", submarkerA31b.getColor());
        assertEquals(2, submarkerA31b.getLength());
        assertEquals(0, submarkerA31b.getSubMarkers().size());
        MarkerSet setB = markerSets.get(1);
        assertEquals("Set B", setB.getName());
        assertEquals("set.b", setB.getId());
        assertEquals(1, setB.getMarkers().size());
        PeriodicMarker markerB1 = (PeriodicMarker) setB.getMarkers().get(0);
        assertEquals("Marker B-1", markerB1.getName());
        assertEquals("B-1 %d", markerB1.getLabel());
        assertEquals("marker.b.1", markerB1.getId());
        assertEquals("ref.b.1", markerB1.getReferenceId());
        assertEquals("#010203", markerB1.getColor());
        assertEquals(1000.0, markerB1.getPeriod(), 0);
        assertEquals("cycles", markerB1.getUnit());
        assertEquals(Range.atLeast(1L), markerB1.getRange());
        assertEquals(5, markerB1.getOffset());
        assertEquals(2, markerB1.getSubMarkers().size());
        SplitMarker submarkerB11 = (SplitMarker) markerB1.getSubMarkers().get(0);
        assertEquals("Submarker B-1-1", submarkerB11.getName());
        assertEquals("submarker.b.1.1", submarkerB11.getId());
        assertEquals("#010203", submarkerB11.getColor());
        assertEquals(Range.closed(1L, 10L), submarkerB11.getRange());
        assertEquals(0, submarkerB11.getSubMarkers().size());
        SplitMarker submarkerB12 = (SplitMarker) markerB1.getSubMarkers().get(1);
        assertEquals("Submarker B-1-2", submarkerB12.getName());
        assertEquals("submarker.b.1.2", submarkerB12.getId());
        assertEquals("#010203", submarkerB12.getColor());
        assertEquals(Range.closed(1L, 100L), submarkerB12.getRange());
        assertEquals(0, submarkerB12.getSubMarkers().size());
    } finally {
        file.delete();
    }
}
Also used : MarkerSet(org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet) WeightedMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.WeightedMarker) SplitMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.SplitMarker) FileWriter(java.io.FileWriter) PeriodicMarker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker) MarkerSegment(org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSegment) File(java.io.File) Test(org.junit.Test)

Example 3 with MarkerSet

use of org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet in project tracecompass by tracecompass.

the class CustomOutputAnnotationProvider method fetchAnnotationCategories.

@Override
public TmfModelResponse<AnnotationCategoriesModel> fetchAnnotationCategories(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
    Object markerID = fetchParameters.get(DataProviderParameterUtils.REQUESTED_MARKER_SET_KEY);
    /* Ignore if trace is not the first element of its trace set. */
    if (!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(null, ms).fetchAnnotationCategories(fetchParameters, monitor);
}
Also used : MarkerSet(org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)

Example 4 with MarkerSet

use of org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet in project tracecompass by tracecompass.

the class AbstractTimeGraphView method getMarkerSetMenu.

/**
 * Get the marker set menu
 *
 * @return the menu manager object
 * @since 3.0
 */
protected MenuManager getMarkerSetMenu() {
    if (fMarkerSetMenu != null) {
        return fMarkerSetMenu;
    }
    fMarkerSetMenu = new MenuManager(Messages.AbstractTimeGraphView_MarkerSetMenuText);
    fMarkerSetMenu.setRemoveAllWhenShown(true);
    fMarkerSetMenu.addMenuListener(mgr -> {
        Action noneAction = new MarkerSetAction(null);
        MarkerSet defaultMarkerSet = MarkerUtils.getDefaultMarkerSet();
        String defaultMarkerSetId = (defaultMarkerSet == null) ? null : defaultMarkerSet.getId();
        noneAction.setChecked(defaultMarkerSetId == null);
        mgr.add(noneAction);
        List<MarkerSet> markerSets = MarkerConfigXmlParser.getMarkerSets();
        for (MarkerSet markerSet : markerSets) {
            Action action = new MarkerSetAction(markerSet);
            action.setChecked(markerSet.getId().equals(defaultMarkerSetId));
            mgr.add(action);
        }
        mgr.add(new Separator());
        mgr.add(new Action(Messages.AbstractTimeGraphView_MarkerSetEditActionText) {

            @Override
            public void run() {
                MarkerConfigXmlParser.initMarkerSets();
                IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
                IFileStore fileStore = EFS.getLocalFileSystem().getStore(MarkerConfigXmlParser.MARKER_CONFIG_PATH);
                try {
                    // SWT doesn't send FocusOut from a popup menu
                    getTimeGraphViewer().getTimeGraphControl().notifyListeners(SWT.FocusOut, null);
                    IDE.openEditorOnFileStore(page, fileStore);
                } catch (PartInitException e) {
                    // $NON-NLS-1$
                    Activator.getDefault().logError("Error opening editor on " + MarkerConfigXmlParser.MARKER_CONFIG_PATH, e);
                }
            }
        });
    });
    return fMarkerSetMenu;
}
Also used : MarkerSet(org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet) IAction(org.eclipse.jface.action.IAction) Action(org.eclipse.jface.action.Action) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IFileStore(org.eclipse.core.filesystem.IFileStore) PartInitException(org.eclipse.ui.PartInitException) Separator(org.eclipse.jface.action.Separator)

Example 5 with MarkerSet

use of org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet in project tracecompass by tracecompass.

the class CustomAnnotationProviderTest method testWeightedWithSubmarkers.

/**
 * Test weighted with submarkers
 */
@Test
public void testWeightedWithSubmarkers() {
    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);
    /*
         * period: 40 ns with segment weights {2,1,3}, offset: 0 ns,
         * range:0..49, indexRange:30..31,40
         *
         * requested range: 0 ns-2000 ns
         *
         * expected annotations: 1200 ns[0] 1220[2] 1240 ns[0] 1260[2] 1600 ns[0]
         * 1620 ns[2]
         */
    WeightedMarker markerE = new WeightedMarker("E");
    markerD.addSubMarker(markerE);
    MarkerSegment segmentE1 = new MarkerSegment("E1 %d", "e1", RED_STR, 2);
    markerE.addSegment(segmentE1);
    MarkerSegment segmentE2 = new MarkerSegment("E2 %d", "e2", "", 1);
    markerE.addSegment(segmentE2);
    MarkerSegment segmentE3 = new MarkerSegment("E3 %d", "e3", INVALID_STR, 3);
    markerE.addSegment(segmentE3);
    fProvider.configure(set);
    assertAnnotationCategoriesModelResponse(Arrays.asList("D", "E"), fProvider.fetchAnnotationCategories(Collections.emptyMap(), new NullProgressMonitor()));
    annotationList = getAnnotationList("E", 0L, 2000L, 1L, new NullProgressMonitor());
    assertEquals(6, annotationList.size());
    int i = 0;
    for (long t = 0L; t < 2000L; t += 40L) {
        int index = (int) (t / 40L) % 50;
        if (index == 30L || index == 31L || index == 40L) {
            validateAnnotation(annotationList.get(i), t, 13L, "E", String.format("E1 %d", 0), RED);
            i++;
            /*
                 * segment 2 does not have visible annotation due to empty color
                 * name
                 */
            validateAnnotation(annotationList.get(i), t + 20L, 20L, "E", String.format("E3 %d", 2), DEFAULT);
            i++;
        }
    }
}
Also used : MarkerSet(org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet) WeightedMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.WeightedMarker) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) PeriodicMarker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker) Marker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker) PeriodicMarker(org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker) WeightedMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.WeightedMarker) SubMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker) SplitMarker(org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.SplitMarker) MarkerSegment(org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSegment) Annotation(org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation) Test(org.junit.Test)

Aggregations

MarkerSet (org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSet)14 Test (org.junit.Test)10 PeriodicMarker (org.eclipse.tracecompass.internal.tmf.core.markers.Marker.PeriodicMarker)7 Marker (org.eclipse.tracecompass.internal.tmf.core.markers.Marker)6 SplitMarker (org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.SplitMarker)6 WeightedMarker (org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker.WeightedMarker)6 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)5 Annotation (org.eclipse.tracecompass.internal.provisional.tmf.core.model.annotations.Annotation)5 SubMarker (org.eclipse.tracecompass.internal.tmf.core.markers.SubMarker)5 RGBAColor (org.eclipse.tracecompass.tmf.core.presentation.RGBAColor)4 File (java.io.File)3 FileWriter (java.io.FileWriter)2 MarkerSegment (org.eclipse.tracecompass.internal.tmf.core.markers.MarkerSegment)2 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)2 IFileStore (org.eclipse.core.filesystem.IFileStore)1 Action (org.eclipse.jface.action.Action)1 IAction (org.eclipse.jface.action.IAction)1 IMenuManager (org.eclipse.jface.action.IMenuManager)1 MenuManager (org.eclipse.jface.action.MenuManager)1 Separator (org.eclipse.jface.action.Separator)1