Search in sources :

Example 21 with TmfEvent

use of org.eclipse.tracecompass.tmf.core.event.TmfEvent in project tracecompass by tracecompass.

the class TmfMipmapStateProviderStub method createEvent.

/**
 * @param time
 *            The event type
 * @param longVal
 *            The event value or null
 * @return A new TmfEvent
 */
@NonNull
public ITmfEvent createEvent(long time, Long longVal) {
    ITmfStateValue value;
    if (longVal == null) {
        value = TmfStateValue.nullValue();
    } else if (type == ITmfStateValue.Type.LONG) {
        value = TmfStateValue.newValueLong(longVal);
    } else if (type == ITmfStateValue.Type.INTEGER) {
        value = TmfStateValue.newValueInt(longVal.intValue());
    } else if (type == ITmfStateValue.Type.DOUBLE) {
        value = TmfStateValue.newValueDouble(longVal.doubleValue());
    } else {
        value = TmfStateValue.nullValue();
    }
    ITmfTimestamp timestamp = TmfTimestamp.fromNanos(time);
    ITmfEventType eventType = new TmfEventType(MIPMAP_ID, null);
    ITmfEventField content = new TmfEventField(ITmfEventField.ROOT_FIELD_ID, value, null);
    ITmfEvent event = new TmfEvent(null, ITmfContext.UNKNOWN_RANK, timestamp, eventType, content);
    return event;
}
Also used : ITmfEventField(org.eclipse.tracecompass.tmf.core.event.ITmfEventField) ITmfEventField(org.eclipse.tracecompass.tmf.core.event.ITmfEventField) TmfEventField(org.eclipse.tracecompass.tmf.core.event.TmfEventField) TmfEvent(org.eclipse.tracecompass.tmf.core.event.TmfEvent) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) TmfEventType(org.eclipse.tracecompass.tmf.core.event.TmfEventType) ITmfEventType(org.eclipse.tracecompass.tmf.core.event.ITmfEventType) ITmfEvent(org.eclipse.tracecompass.tmf.core.event.ITmfEvent) ITmfEventType(org.eclipse.tracecompass.tmf.core.event.ITmfEventType) ITmfStateValue(org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue) NonNull(org.eclipse.jdt.annotation.NonNull)

Aggregations

TmfEvent (org.eclipse.tracecompass.tmf.core.event.TmfEvent)21 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)19 Test (org.junit.Test)16 ITmfEventField (org.eclipse.tracecompass.tmf.core.event.ITmfEventField)5 TmfEventField (org.eclipse.tracecompass.tmf.core.event.TmfEventField)5 TmfEventType (org.eclipse.tracecompass.tmf.core.event.TmfEventType)5 IOException (java.io.IOException)3 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)3 EOFException (java.io.EOFException)2 RandomAccessFile (java.io.RandomAccessFile)2 ITmfEventType (org.eclipse.tracecompass.tmf.core.event.ITmfEventType)2 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 Nullable (org.eclipse.jdt.annotation.Nullable)1 ITmfStateValue (org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue)1 CustomEventContent (org.eclipse.tracecompass.tmf.core.parsers.custom.CustomEventContent)1 CustomXmlEvent (org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlEvent)1 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)1 ITmfContext (org.eclipse.tracecompass.tmf.core.trace.ITmfContext)1