Search in sources :

Example 16 with IAnalysisModule

use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.

the class TmfTraceTest method testGetModules.

// ------------------------------------------------------------------------
// State system, statistics and modules methods
// ------------------------------------------------------------------------
@Test
public void testGetModules() {
    /* There should not be any modules at this point */
    Iterable<IAnalysisModule> modules = fTrace.getAnalysisModules();
    assertFalse(modules.iterator().hasNext());
    /* Open the trace, the modules should be populated */
    fTrace.traceOpened(new TmfTraceOpenedSignal(this, fTrace, null));
    modules = fTrace.getAnalysisModules();
    assertTrue(modules.iterator().hasNext());
    /*
         * Make sure all modules of type TestAnalysis are returned in the second
         * call
         */
    int count = 0;
    for (IAnalysisModule module : modules) {
        if (module instanceof TestAnalysis) {
            count++;
            IAnalysisModule otherModule = fTrace.getAnalysisModule(module.getId());
            assertNotNull(otherModule);
            assertEquals(otherModule, module);
        }
    }
    /*
         * FIXME: The exact count depends on the context the test is run (full
         * test suite or this file only), but there must be at least 2 modules
         */
    assertTrue(count >= 2);
}
Also used : TestAnalysis(org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) Test(org.junit.Test)

Example 17 with IAnalysisModule

use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.

the class TmfTrace method executeAnalysis.

/**
 * Instantiate the applicable analysis modules and executes the analysis
 * modules that are meant to be automatically executed
 *
 * @return An IStatus indicating whether the analysis could be run
 *         successfully or not
 */
protected IStatus executeAnalysis() {
    MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK, null, null);
    /* First modules are initialized */
    Map<String, IAnalysisModuleHelper> modules = TmfAnalysisManager.getAnalysisModules(this.getClass());
    for (IAnalysisModuleHelper helper : modules.values()) {
        try {
            IAnalysisModule module = helper.newModule(this);
            if (module == null) {
                continue;
            }
            fAnalysisModules.put(module.getId(), module);
        } catch (TmfAnalysisException e) {
            status.add(new Status(IStatus.WARNING, Activator.PLUGIN_ID, e.getMessage()));
        }
    }
    /* Once all modules are initialized, automatic modules are executed */
    for (IAnalysisModule module : getAnalysisModules()) {
        if (module.isAutomatic()) {
            status.add(module.schedule());
        }
    }
    return status;
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) TmfAnalysisException(org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException) MultiStatus(org.eclipse.core.runtime.MultiStatus) IAnalysisModuleHelper(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModuleHelper)

Example 18 with IAnalysisModule

use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.

the class TmfAnalysisElement method getAnalysisProperties.

/**
 * Get the analysis properties of this analysisElement if the corresponding
 * analysis exists for the current trace
 *
 * @return a map with the names and values of the trace properties
 *         respectively as keys and values
 */
private Map<String, String> getAnalysisProperties() {
    ITmfProjectModelElement parent = getParent();
    if (!(parent instanceof TmfViewsElement)) {
        return Collections.emptyMap();
    }
    parent = parent.getParent();
    if (parent instanceof TmfCommonProjectElement) {
        ITmfTrace trace = ((TmfCommonProjectElement) parent).getTrace();
        if (trace == null) {
            return Collections.emptyMap();
        }
        IAnalysisModule module = trace.getAnalysisModule(fAnalysisHelper.getId());
        if (module instanceof ITmfPropertiesProvider) {
            return ((ITmfPropertiesProvider) module).getProperties();
        }
    }
    return Collections.emptyMap();
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) ITmfPropertiesProvider(org.eclipse.tracecompass.tmf.core.project.model.ITmfPropertiesProvider)

Example 19 with IAnalysisModule

use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.

the class TmfAnalysisElement method getHelpMessage.

/**
 * Gets the help message for this analysis
 *
 * @return The help message
 */
public String getHelpMessage() {
    TmfCommonProjectElement parentTrace = getParent().getParent();
    ITmfTrace trace = null;
    if (parentTrace instanceof TmfTraceElement) {
        TmfTraceElement traceElement = (TmfTraceElement) parentTrace;
        trace = traceElement.getTrace();
        if (trace != null) {
            IAnalysisModule module = trace.getAnalysisModule(fAnalysisHelper.getId());
            if (module != null) {
                return module.getHelpText(trace);
            }
        }
    }
    if (trace != null) {
        return fAnalysisHelper.getHelpText(trace);
    }
    return fAnalysisHelper.getHelpText();
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)

Example 20 with IAnalysisModule

use of org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule in project tracecompass by tracecompass.

the class TmfAnalysisElement method getAnalysisModule.

private IAnalysisModule getAnalysisModule() {
    /*
         * We can get a list of available outputs once the analysis is
         * instantiated when the trace is opened
         */
    IResource parentTraceResource = getParent().getParent().getResource();
    /*
         * Find any trace instantiated with the same resource as the parent trace
         */
    ITmfTrace trace = null;
    for (ITmfTrace openedTrace : TmfTraceManager.getInstance().getOpenedTraces()) {
        for (ITmfTrace t : TmfTraceManager.getTraceSetWithExperiment(openedTrace)) {
            if (parentTraceResource.equals(t.getResource())) {
                trace = t;
                break;
            }
        }
    }
    if (trace == null) {
        deleteOutputs();
        return null;
    }
    IAnalysisModule module = trace.getAnalysisModule(fAnalysisHelper.getId());
    if (module == null) {
        deleteOutputs();
        /*
             * Trace is opened, but the analysis is null, so it does not
             * apply
             */
        fCanExecute = false;
        return null;
    }
    return module;
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) IResource(org.eclipse.core.resources.IResource)

Aggregations

IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)71 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)28 Test (org.junit.Test)18 TmfTraceOpenedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal)17 TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)15 ArrayList (java.util.ArrayList)12 ISegmentStoreProvider (org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider)11 HashSet (java.util.HashSet)10 Nullable (org.eclipse.jdt.annotation.Nullable)9 TmfTraceException (org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException)8 TmfTrace (org.eclipse.tracecompass.tmf.core.trace.TmfTrace)7 TmfExperiment (org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment)7 TestAnalysis (org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis)7 File (java.io.File)6 IStatus (org.eclipse.core.runtime.IStatus)6 ISegment (org.eclipse.tracecompass.segmentstore.core.ISegment)6 Before (org.junit.Before)6 IPath (org.eclipse.core.runtime.IPath)5 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)5 HashMap (java.util.HashMap)4