Search in sources :

Example 21 with LamiTableEntry

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

the class LamiReportViewTabPage method getEntriesIntersectingTimerange.

// ------------------------------------------------------------------------
// Util methods
// ------------------------------------------------------------------------
/**
 * Util method that returns {@link LamiTableEntry} that intersects a
 * {@link TmfTimeRange}.
 *
 * @param table
 *            The result table to search for entries
 * @param range
 *            The time range itself
 * @return The set of entries that intersect with the time range
 */
private static Set<Object> getEntriesIntersectingTimerange(LamiResultTable table, TmfTimeRange range) {
    Set<Object> entries = new HashSet<>();
    for (LamiTableEntry entry : table.getEntries()) {
        LamiTimeRange lamiTimeRange = entry.getCorrespondingTimeRange();
        /* Make sure the table has time ranges */
        if (lamiTimeRange == null) {
            return entries;
        }
        /* Get the timestamps from the time range */
        /**
         * TODO: Consider low and high limits of timestamps here.
         */
        Number tsBeginValueNumber = lamiTimeRange.getBegin().getValue();
        Number tsEndValueNumber = lamiTimeRange.getEnd().getValue();
        if (tsBeginValueNumber == null || tsEndValueNumber == null) {
            return entries;
        }
        /* Convert the timestamps into TMF timestamps */
        ITmfTimestamp start = TmfTimestamp.fromNanos(tsBeginValueNumber.longValue());
        ITmfTimestamp end = TmfTimestamp.fromNanos(tsEndValueNumber.longValue());
        /* Add iff the time range intersects the the signal */
        TmfTimeRange tempTimeRange = new TmfTimeRange(start, end);
        if (tempTimeRange.getIntersection(range) != null) {
            entries.add(entry);
        }
    }
    return entries;
}
Also used : LamiTableEntry(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) LamiTimeRange(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimeRange) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) HashSet(java.util.HashSet)

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