Class TraceScriptingModule

java.lang.Object
org.eclipse.ease.modules.AbstractScriptModule
org.eclipse.tracecompass.incubator.scripting.core.trace.TraceScriptingModule
All Implemented Interfaces:
org.eclipse.ease.modules.IScriptModule

public class TraceScriptingModule extends org.eclipse.ease.modules.AbstractScriptModule
Scripting modules to open and manipulate traces
Author:
Benjamin Saint-Cyr
  • Constructor Details

    • TraceScriptingModule

      public TraceScriptingModule()
  • Method Details

    • openMinimalTrace

      public @Nullable ITmfTrace openMinimalTrace(String projectName, String traceName, @ScriptParameter(defaultValue="false") 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 ITmfComponent.dispose() method.

      Parameters:
      projectName - The name of the project
      traceName - the trace to open
      isExperiment - is the trace an experiment
      Returns:
      The trace
      Throws:
      FileNotFoundException - if the file or the trace doesn't exist
    • getActiveTrace

      public @Nullable ITmfTrace getActiveTrace()
      Get the currently active trace, ie the last trace opened in the UI
      Returns:
      The current trace or null if no trace is opened
    • getEventIterator

      public ScriptEventsIterator getEventIterator(@Nullable 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
       }
       
      Parameters:
      trace - The trace for which to get the event iterator
      Returns:
      The event iterator, starting from the first event
    • getEventFieldValue

      public @Nullable 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.
      Parameters:
      event - The event for which to get the field
      fieldName - The name of the field to fetch
      Returns:
      The field value object, or null if the field is not found