Search in sources :

Example 16 with LamiTableEntry

use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry in project tracecompass by tracecompass.

the class LamiAspectTest method lamiMixedAspectTest.

/**
 * Test the mixed aspect
 *
 * @throws JSONException
 *             won't happen
 */
@Test
public void lamiMixedAspectTest() throws JSONException {
    LamiTableEntryAspect aspect = new LamiMixedAspect(ASPECT_NAME, 0);
    LamiTableEntry entry1 = createLamiData(1);
    LamiTableEntry entry2 = createLamiData(2);
    assertEquals(ASPECT_NAME, aspect.getLabel());
    assertEquals(ASPECT_NAME, aspect.getName());
    assertEquals(0, aspect.getComparator().compare(entry1, entry2));
    assertNull(aspect.resolveString(entry1));
    assertNull(aspect.resolveNumber(entry1));
}
Also used : LamiTableEntryAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect) LamiTableEntry(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry) LamiMixedAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiMixedAspect) Test(org.junit.Test)

Example 17 with LamiTableEntry

use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry in project tracecompass by tracecompass.

the class LamiChartViewerTest method testScatterMultipleRow.

/**
 * Test a few scatter charts with the multiple row dataset.
 *
 * @throws SecurityException
 *             If a security manager is present and any the wrong class is
 *             loaded or the class loader is not the same as its ancestor's
 *             loader.
 *
 * @throws IllegalArgumentException
 *             the object is not the correct class type
 */
@Test
public void testScatterMultipleRow() throws SecurityException, IllegalArgumentException {
    SWTBotView viewBot = executeAnalysis(LamiAnalyses.MULTIPLE_ROW);
    // Get the expected maximum and minimum values of each axis
    LamiResultTable resultTable = LamiAnalyses.MULTIPLE_ROW.getAnalysis().getResultTable(0);
    Long minX = Long.MAX_VALUE;
    Long maxX = Long.MIN_VALUE;
    Long minY = Long.MAX_VALUE;
    Long maxY = Long.MIN_VALUE;
    for (LamiTableEntry entry : resultTable.getEntries()) {
        Long wakeupTs = ((LamiLongNumber) entry.getValue(0)).getValue();
        Long switchTs = ((LamiLongNumber) entry.getValue(1)).getValue();
        Long latency = ((LamiLongNumber) entry.getValue(2)).getValue();
        if (wakeupTs != null) {
            minX = Math.min(minX, wakeupTs);
            maxX = Math.max(maxX, wakeupTs);
        }
        if (switchTs != null) {
            minX = Math.min(minX, switchTs);
            maxX = Math.max(maxX, switchTs);
        }
        if (latency != null) {
            minY = Math.min(minY, latency);
            maxY = Math.max(maxY, latency);
        }
    }
    // Create a new chart
    SWTBotRootMenu viewMenu = viewBot.viewMenu();
    SWTBotMenu menu = viewMenu.menu("New custom chart");
    menu.click();
    // Create a scatter chart of Wakeup timestamp vs scheduling latency
    // and Switch timestamp vs scheduling latency
    SWTBotCustomChartUtils.selectChartType(fBot, ChartType.SCATTER_CHART);
    SWTBotCustomChartUtils.addSeries(fBot, "Wakeup timestamp", Collections.singleton("Scheduling latency (ns)"));
    SWTBotCustomChartUtils.addSeries(fBot, "Switch timestamp", Collections.singleton("Scheduling latency (ns)"));
    SWTBotCustomChartUtils.confirmDialog(fBot);
    WaitUtils.waitForJobs();
    // Wait for the viewer and verify its parameters
    @Nullable Chart customChart = viewBot.bot().widget(WidgetOfType.widgetOfType(Chart.class), 0);
    Event mouseMove = new Event();
    mouseMove.type = SWT.MouseEnter;
    customChart.getDisplay().post(mouseMove);
    assertNotNull(customChart);
    fBot.waitUntil(ConditionHelpers.numberOfSeries(customChart, 2));
    SWTBotChart chartBot = new SWTBotChart(customChart);
    assertVisible(chartBot);
    // Verify the titles
    SWTBotCustomChartUtils.assertTitles(customChart, "Scheduling log", "Value (ss.SSS)", "Scheduling latency (ns)");
    // Make sure the axis formatters have the right range
    SWTBotCustomChartUtils.assertAxisRange(customChart, AxisType.X, minX, maxX);
    SWTBotCustomChartUtils.assertAxisRange(customChart, AxisType.Y, minY, maxY);
    SWTBotCustomChartUtils.assertAxisLogscale(customChart, AxisType.Y, false);
    // Verify the series titles
    SWTBotCustomChartUtils.assertSeriesTitle(customChart, ImmutableList.of("Scheduling latency by Wakeup timestamp", "Scheduling latency by Switch timestamp"));
    closeCharts();
    // Create the same chart, but with log scale enabled in Y. Make sure
    // the results are the same
    menu.click();
    SWTBotCustomChartUtils.selectChartType(fBot, ChartType.SCATTER_CHART);
    SWTBotCustomChartUtils.addSeries(fBot, "Wakeup timestamp", Collections.singleton("Scheduling latency (ns)"));
    SWTBotCustomChartUtils.addSeries(fBot, "Switch timestamp", Collections.singleton("Scheduling latency (ns)"));
    SWTBotCustomChartUtils.setLogScale(fBot, AxisType.Y);
    SWTBotCustomChartUtils.confirmDialog(fBot);
    WaitUtils.waitForJobs();
    // Wait for the viewer and verify its parameters
    customChart = viewBot.bot().widget(WidgetOfType.widgetOfType(Chart.class), 0);
    assertNotNull(customChart);
    customChart.getDisplay().post(mouseMove);
    fBot.waitUntil(ConditionHelpers.numberOfSeries(customChart, 2));
    chartBot = new SWTBotChart(customChart);
    assertVisible(chartBot);
    // Verify the titles
    SWTBotCustomChartUtils.assertTitles(customChart, "Scheduling log", "Value (ss.SSS)", "Scheduling latency (ns)");
    // Make sure the axis formatter have the right range
    SWTBotCustomChartUtils.assertAxisRange(customChart, AxisType.X, minX, maxX);
    // Logscale charts are clamped to 0
    SWTBotCustomChartUtils.assertAxisRange(customChart, AxisType.Y, 0, maxY);
    SWTBotCustomChartUtils.assertAxisLogscale(customChart, AxisType.Y, true);
    // Verify the series titles
    SWTBotCustomChartUtils.assertSeriesTitle(customChart, ImmutableList.of("Scheduling latency by Wakeup timestamp", "Scheduling latency by Switch timestamp"));
    closeCharts();
}
Also used : LamiResultTable(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiResultTable) SWTBotMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotMenu) LamiTableEntry(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry) SWTBotRootMenu(org.eclipse.swtbot.swt.finder.widgets.SWTBotRootMenu) SWTBotView(org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView) Event(org.eclipse.swt.widgets.Event) LamiLongNumber(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiLongNumber) Nullable(org.eclipse.jdt.annotation.Nullable) Chart(org.eclipse.swtchart.Chart) Test(org.junit.Test)

Example 18 with LamiTableEntry

use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry in project tracecompass by tracecompass.

the class LamiTableContentProvider method updateElement.

@Override
public void updateElement(int index) {
    final TableViewer tableViewer = fTableViewer;
    final List<LamiTableEntry> entries = fCurrentEntries;
    if ((tableViewer != null) && (entries.size() > index) && !fOngoingUpdate) {
        fOngoingUpdate = true;
        tableViewer.replace(entries.get(index), index);
        fOngoingUpdate = false;
    }
}
Also used : LamiTableEntry(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 19 with LamiTableEntry

use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry in project tracecompass by tracecompass.

the class LamiTableContentProvider method setSortOrder.

@Override
public void setSortOrder(@Nullable Comparator<?> comparator) {
    if (comparator == null) {
        return;
    }
    final TableViewer tableViewer = fTableViewer;
    if (tableViewer == null) {
        return;
    }
    @SuppressWarnings("unchecked") Comparator<LamiTableEntry> entryComparator = (Comparator<LamiTableEntry>) comparator;
    fComparator = entryComparator;
    Collections.sort(fCurrentEntries, fComparator);
    tableViewer.refresh();
}
Also used : LamiTableEntry(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry) TableViewer(org.eclipse.jface.viewers.TableViewer) Comparator(java.util.Comparator)

Example 20 with LamiTableEntry

use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry in project tracecompass by tracecompass.

the class LamiTableViewer method fillData.

/**
 * Update the data in the table viewer
 *
 * @param dataInput
 *            New data input
 */
private void fillData() {
    final TableViewer tableViewer = getTableViewer();
    Display.getDefault().asyncExec(() -> {
        if (tableViewer.getTable().isDisposed()) {
            return;
        }
        // Go to the top of the table
        tableViewer.getTable().setTopIndex(0);
        // Reset selected row
        tableViewer.setSelection(StructuredSelection.EMPTY);
        /* Fill the table data */
        tableViewer.setInput(fPage.getResultTable().getEntries());
        LamiTableContentProvider latencyContentProvider = (LamiTableContentProvider) getTableViewer().getContentProvider();
        tableViewer.setItemCount(latencyContentProvider.getNbEntries());
        /* Set the column's alignment and pack them */
        TableColumn[] cols = tableViewer.getTable().getColumns();
        for (int i = 0; i < cols.length; i++) {
            LamiTableEntryAspect colAspect = fPage.getResultTable().getTableClass().getAspects().get(i);
            int alignment = (colAspect.isContinuous() ? SWT.RIGHT : SWT.LEFT);
            cols[i].setAlignment(alignment);
        }
        /*
             * On creation check if there is selections if so update the table
             * selections here. Selections needs the ContentProvider for valid
             * index lookup and since the content provider is set in an
             * asynchronous task we cannot use the normal signal handler since
             * we have no guarantee of time of execution of the fill data.
             */
        if (!fSelection.isEmpty()) {
            LamiTableContentProvider provider = (LamiTableContentProvider) getTableViewer().getContentProvider();
            /* Find the indexes in the UI table of the selected objects */
            int[] selectionsIndexes = fSelection.stream().map(obj -> (LamiTableEntry) obj).mapToInt(entry -> provider.getIndexOf(checkNotNull(entry))).toArray();
            /* Update the selection in the UI table */
            Display.getDefault().asyncExec(() -> {
                getTableViewer().getTable().setSelection(selectionsIndexes);
                getTableViewer().getTable().redraw();
            });
        }
    });
    Display.getDefault().asyncExec(() -> {
        if (tableViewer.getTable().isDisposed()) {
            return;
        }
        TableColumn[] cols = tableViewer.getTable().getColumns();
        for (int i = 0; i < cols.length; i++) {
            cols[i].pack();
        }
    });
}
Also used : TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn) ExportToTsvUtils(org.eclipse.tracecompass.internal.tmf.ui.commands.ExportToTsvUtils) Table(org.eclipse.swt.widgets.Table) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) TmfSimpleTableViewer(org.eclipse.tracecompass.tmf.ui.viewers.table.TmfSimpleTableViewer) HashSet(java.util.HashSet) Nullable(org.eclipse.jdt.annotation.Nullable) Composite(org.eclipse.swt.widgets.Composite) ChartSelectionUpdateSignal(org.eclipse.tracecompass.internal.provisional.tmf.chart.core.signal.ChartSelectionUpdateSignal) NonNullUtils.checkNotNull(org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull) OutputStream(java.io.OutputStream) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler) NonNullUtils.nullToEmptyString(org.eclipse.tracecompass.common.core.NonNullUtils.nullToEmptyString) LamiReportViewTabPage(org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.views.LamiReportViewTabPage) Set(java.util.Set) Display(org.eclipse.swt.widgets.Display) ColumnLabelProvider(org.eclipse.jface.viewers.ColumnLabelProvider) LamiReportView(org.eclipse.tracecompass.internal.provisional.analysis.lami.ui.views.LamiReportView) List(java.util.List) SWT(org.eclipse.swt.SWT) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TmfSignalManager(org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager) LamiTableEntry(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry) LamiTableEntryAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect) LamiTableEntryAspect(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect) TableViewer(org.eclipse.jface.viewers.TableViewer) TmfSimpleTableViewer(org.eclipse.tracecompass.tmf.ui.viewers.table.TmfSimpleTableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn)

Aggregations

LamiTableEntry (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry)21 LamiTableEntryAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect)15 Test (org.junit.Test)15 TableViewer (org.eclipse.jface.viewers.TableViewer)3 HashSet (java.util.HashSet)2 Nullable (org.eclipse.jdt.annotation.Nullable)2 LamiResultTable (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiResultTable)2 LamiData (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiData)2 LamiTimeRange (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimeRange)2 OutputStream (java.io.OutputStream)1 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Set (java.util.Set)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 ColumnLabelProvider (org.eclipse.jface.viewers.ColumnLabelProvider)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 SWT (org.eclipse.swt.SWT)1