Scripting modules to open and manipulate traces
Method | Description |
---|---|
getActiveTrace() | Get the currently active trace, ie the last trace opened in the UI |
getEventFieldValue() | A wrapper method to get the value of an event field. |
getEventIterator() | Get an iterator to iterate chronologically through the events of the trace. |
openMinimalTrace() | The trace will be opened, its events can be queried, but the analyses will not have been run on it, they will not be available. |
openTrace() | Deprecated: Fully open a trace in the Trace Compass application, ie it will open as if the user had opened it in the UI, running all automatic analyses, etc. |
ITmfTrace getActiveTrace()
Get the currently active trace, ie the last trace opened in the UI
The current trace or null
if no trace is opened
Object getEventFieldValue(ITmfEvent event, String fieldName)
A wrapper method to get the value of an event field. If the field itself does not exist, it will try to resolve an aspect from the trace the event is from.
The field value object, or null
if the field is not
found
org.eclipse.tracecompass.incubator.scripting.core.trace.ScriptEventsIterator getEventIterator(ITmfTrace trace)
Get an iterator to iterate chronologically through the events of the trace. To reduce overhead of passing all events to/from the script when only a subset of events is requested, the ScriptEventsIterator.addEvent(String) method can be used to set the events to filter. Thus, to iterate through the events of a trace in a scripted analysis, one can just do the following snippet (javascript)
var trace = getActiveTrace(); var iter = getEventIterator(trace); var event = null; while (iter.hasNext()) { event = iter.next(); // Do something with the event }
The event iterator, starting from the first event
ITmfTrace openMinimalTrace(String projectName, String traceName, [boolean isExperiment]) throws FileNotFoundException
The trace will be opened, its events can be queried, but the analyses will not have been run on it, they will not be available. The trace content will not be opened in the UI and it won't be able to populate any view. Typical use is for stand-alone scripts who want to run and export content without interacting with the UI. The trace must have been previously imported in trace compass as it needs to be in a project.
The trace will not be attached to the workspace, so it is important after using to dispose of it by calling the ITmfTrace.dispose() method.
The trace
ITmfTrace openTrace(String projectName, String traceName, [boolean isExperiment])
Fully open a trace in the Trace Compass application, ie it will open as if the user had opened it in the UI, running all automatic analyses, etc. If the trace is successfully opened, it becomes the currently active trace.
Deprecated: This method was never supported, to open a trace in Trace
Compass, use the openTrace
method from the
'/TraceCompass/TraceUI'
module
The trace