Search in sources :

Example 6 with LamiTimestamp

use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimestamp in project tracecompass by tracecompass.

the class LamiTimestampAspect method resolveString.

@Override
@Nullable
public String resolveString(LamiTableEntry entry) {
    LamiData data = entry.getValue(getColIndex());
    if (data instanceof LamiTimestamp) {
        LamiTimestamp ts = (LamiTimestamp) data;
        // TODO: Consider low and high limits here.
        Number timestamp = ts.getValue();
        if (timestamp != null) {
            return TmfTimestampFormat.getDefaulTimeFormat().format(timestamp.longValue());
        }
    }
    return data.toString();
}
Also used : LamiData(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiData) LamiTimestamp(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimestamp) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 7 with LamiTimestamp

use of org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimestamp in project tracecompass by tracecompass.

the class LamiTableEntry method getCorrespondingTimeRange.

/**
 * Get the time range represented by this row.
 *
 * If more than one exists, one of them (usually the first) is returned.
 *
 * If there are no time ranges in this row, null is returned.
 *
 * @return The time range of this row
 */
@Nullable
public LamiTimeRange getCorrespondingTimeRange() {
    /*
         * If there is one or more time range(s) in the values, return the first
         * one we find directly.
         */
    Optional<LamiTimeRange> oTimerange = fValues.stream().filter(LamiTimeRange.class::isInstance).map(LamiTimeRange.class::cast).findFirst();
    if (oTimerange.isPresent()) {
        return oTimerange.get();
    }
    /* Look for individual timestamps instead  */
    List<LamiTimestamp> timestamps = fValues.stream().filter(LamiTimestamp.class::isInstance).map(LamiTimestamp.class::cast).collect(Collectors.toList());
    if (timestamps.size() > 1) {
        /* We can try using the first two timestamps to create a range (making sure it's valid) */
        LamiTimestamp firstTs = timestamps.get(0);
        LamiTimestamp secondTs = timestamps.get(1);
        Number firstTsValue = firstTs.getValue();
        Number secondTsValue = secondTs.getValue();
        // TODO: Consider low and high limits in comparisons.
        if (firstTsValue != null && secondTsValue != null && Long.compare(firstTsValue.longValue(), secondTsValue.longValue()) <= 0) {
            return new LamiTimeRange(firstTs, secondTs);
        }
    }
    if (!timestamps.isEmpty()) {
        /* If there is only one timestamp, use it to create a punctual range */
        LamiTimestamp ts = timestamps.get(0);
        return new LamiTimeRange(ts, ts);
    }
    /* Didn't find any timestamp we can't use */
    return null;
}
Also used : LamiTimestamp(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimestamp) LamiTimeRange(org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimeRange) Nullable(org.eclipse.jdt.annotation.Nullable)

Aggregations

LamiTimestamp (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimestamp)7 Nullable (org.eclipse.jdt.annotation.Nullable)6 LamiData (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiData)6 LamiTimeRange (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiTimeRange)6 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 LamiAnalysisStub (org.eclipse.tracecompass.analysis.lami.core.tests.shared.analysis.LamiAnalysisStub)1 LamiTableEntryAspect (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.aspect.LamiTableEntryAspect)1 LamiResultTable (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiResultTable)1 LamiTableClass (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableClass)1 LamiTableEntry (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.module.LamiTableEntry)1 LamiBitrate (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiBitrate)1 LamiDuration (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiDuration)1 LamiSize (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiSize)1 LamiSystemCall (org.eclipse.tracecompass.internal.provisional.analysis.lami.core.types.LamiSystemCall)1 Test (org.junit.Test)1