Search in sources :

Example 11 with IAnalysisModule

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

the class XmlTimeGraphDataProvider method create.

/**
 * {@link XmlTimeGraphDataProvider} create method
 *
 * @param trace
 *            the trace for which the provider will return data
 * @param viewElement
 *            the XML view {@link Element}.
 * @return the relevant {@link XmlTimeGraphDataProvider}
 */
public static XmlTimeGraphDataProvider create(@NonNull ITmfTrace trace, Element viewElement) {
    Set<@NonNull String> analysisIds = TmfXmlUtils.getViewAnalysisIds(viewElement);
    List<Element> entries = TmfXmlUtils.getChildElements(viewElement, TmfXmlStrings.ENTRY_ELEMENT);
    Set<@NonNull ITmfAnalysisModuleWithStateSystems> stateSystemModules = new HashSet<>();
    if (analysisIds.isEmpty()) {
        /*
             * No analysis specified, take all state system analysis modules
             */
        Iterables.addAll(stateSystemModules, TmfTraceUtils.getAnalysisModulesOfClass(trace, ITmfAnalysisModuleWithStateSystems.class));
    } else {
        for (String moduleId : analysisIds) {
            // Get the module for the current trace only. The caller will take care of
            // generating composite providers with experiments
            IAnalysisModule module = trace.getAnalysisModule(moduleId);
            if (module instanceof ITmfAnalysisModuleWithStateSystems) {
                stateSystemModules.add((ITmfAnalysisModuleWithStateSystems) module);
            }
        }
    }
    List<ITmfStateSystem> sss = new ArrayList<>();
    for (ITmfAnalysisModuleWithStateSystems module : stateSystemModules) {
        if (module.schedule().isOK() && module.waitForInitialization()) {
            module.getStateSystems().forEach(sss::add);
        }
    }
    return (sss.isEmpty() ? null : new XmlTimeGraphDataProvider(trace, sss, entries));
}
Also used : Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) ITmfAnalysisModuleWithStateSystems(org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems) HashSet(java.util.HashSet) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)

Example 12 with IAnalysisModule

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

the class DataDrivenXYProviderFactory method create.

/**
 * Create an XY data provider for a trace
 *
 * @param trace
 *            The trace for which to create the data provider
 * @return The XY data provider or <code>null</code> if no such provider is
 *         available for that trace
 */
@Nullable
public ITmfTreeXYDataProvider<ITmfTreeDataModel> create(ITmfTrace trace) {
    Set<@NonNull ITmfAnalysisModuleWithStateSystems> stateSystemModules = new HashSet<>();
    List<ITmfStateSystem> sss = new ArrayList<>();
    if (fAnalysisIds.isEmpty()) {
        /*
             * No analysis specified, take all state system analysis modules
             */
        Iterables.addAll(stateSystemModules, TmfTraceUtils.getAnalysisModulesOfClass(trace, ITmfAnalysisModuleWithStateSystems.class));
    } else {
        for (String moduleId : fAnalysisIds) {
            // Get the module for the current trace only. The caller will
            // take care of
            // generating composite providers with experiments
            IAnalysisModule module = trace.getAnalysisModule(moduleId);
            if (module instanceof ITmfAnalysisModuleWithStateSystems) {
                stateSystemModules.add((ITmfAnalysisModuleWithStateSystems) module);
            }
        }
    }
    for (ITmfAnalysisModuleWithStateSystems module : stateSystemModules) {
        if (module.schedule().isOK() && module.waitForInitialization()) {
            module.getStateSystems().forEach(sss::add);
        }
    }
    return (sss.isEmpty() ? null : create(trace, sss, fEntries, null));
}
Also used : IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) ArrayList(java.util.ArrayList) ITmfAnalysisModuleWithStateSystems(org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems) HashSet(java.util.HashSet) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 13 with IAnalysisModule

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

the class TmfAnalysisModuleHelperXml method newModule.

@Override
@Nullable
public final IAnalysisModule newModule(ITmfTrace trace) throws TmfAnalysisException {
    String analysisid = getId();
    IAnalysisModule module = null;
    switch(fType) {
        case STATE_SYSTEM:
            TmfXmlStateProviderCu compile = TmfXmlStateProviderCu.compile(fSourceFile.toPath(), analysisid);
            if (compile == null) {
                return null;
            }
            module = new DataDrivenAnalysisModule(analysisid, compile);
            module.setName(getName());
            break;
        case PATTERN:
            TmfXmlPatternCu patternCu = TmfXmlPatternCu.compile(fSourceFile.toPath(), analysisid);
            if (patternCu == null) {
                return null;
            }
            module = new XmlPatternAnalysis(analysisid, patternCu);
            module.setName(getName());
            XmlPatternAnalysis paModule = (XmlPatternAnalysis) module;
            paModule.setViewLabelPrefix(getViewLabelPrefix());
            break;
        case OTHER:
            String name = getName();
            module = createOtherModule(analysisid, name);
            break;
        default:
            break;
    }
    if (module != null) {
        if (module.setTrace(trace)) {
            TmfAnalysisManager.analysisModuleCreated(module);
        } else {
            /*
                 * The analysis does not apply to the trace, dispose of the
                 * module
                 */
            module.dispose();
            module = null;
        }
    }
    return module;
}
Also used : TmfXmlPatternCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlPatternCu) TmfXmlStateProviderCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateProviderCu) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) XmlPatternAnalysis(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis) DataDrivenAnalysisModule(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 14 with IAnalysisModule

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

the class XmlAnalysisOutputSourceTest method testBuiltinOutput.

/**
 * Test the
 * {@link TmfXmlAnalysisOutputSource#moduleCreated(IAnalysisModule)} method
 */
@Test
public void testBuiltinOutput() {
    TmfTrace trace = new TmfXmlTraceStubNs();
    try {
        trace.traceOpened(new TmfTraceOpenedSignal(this, trace, null));
        IAnalysisModule module = trace.getAnalysisModule(BUILTIN_MODULE);
        assertNotNull(module);
        Iterator<IAnalysisOutput> iterator = module.getOutputs().iterator();
        assertTrue(iterator.hasNext());
        IAnalysisOutput output = iterator.next();
        assertEquals(BUILTIN_OUTPUT, output.getName());
    } finally {
        trace.dispose();
    }
}
Also used : TmfXmlTraceStubNs(org.eclipse.tracecompass.tmf.tests.stubs.trace.xml.TmfXmlTraceStubNs) TmfTrace(org.eclipse.tracecompass.tmf.core.trace.TmfTrace) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) IAnalysisOutput(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisOutput) Test(org.junit.Test)

Example 15 with IAnalysisModule

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

the class TmfExperimentUtilsTest method testGetModuleByClass.

/**
 * Test the
 * {@link TmfExperimentUtils#getAnalysisModuleOfClassForHost(TmfExperiment, String, Class)}
 * method
 */
@Test
public void testGetModuleByClass() {
    Class<@NonNull TestAnalysis> commonClass = TestAnalysis.class;
    Class<@NonNull TestAnalysis2> notCommonClass = TestAnalysis2.class;
    String host1 = TmfTestTrace.A_TEST_10K.getPath();
    String host2 = TmfTestTrace.A_TEST_10K2.getPath();
    TmfExperiment experiment = fExperiment;
    assertNotNull(experiment);
    /* Common module for trace 1 */
    TestAnalysis module1 = TmfExperimentUtils.getAnalysisModuleOfClassForHost(experiment, host1, commonClass);
    assertNotNull(module1);
    /* Make sure this module belongs to the trace */
    IAnalysisModule sameModule = null;
    for (IAnalysisModule mod : fTraces[0].getAnalysisModules()) {
        if (mod == module1) {
            sameModule = mod;
        }
    }
    assertNotNull(sameModule);
    /* Uncommon module from trace 1 */
    TestAnalysis2 module2 = TmfExperimentUtils.getAnalysisModuleOfClassForHost(experiment, host1, notCommonClass);
    assertNull(module2);
    /* Common module for trace 1 */
    module1 = TmfExperimentUtils.getAnalysisModuleOfClassForHost(experiment, host2, commonClass);
    assertNotNull(module1);
    /* Make sure this module belongs to the trace */
    sameModule = null;
    for (IAnalysisModule mod : fTraces[1].getAnalysisModules()) {
        if (mod == module1) {
            sameModule = mod;
        }
    }
    assertNotNull(sameModule);
    /* Uncommon module from trace 1 */
    module2 = TmfExperimentUtils.getAnalysisModuleOfClassForHost(experiment, host2, notCommonClass);
    assertNotNull(module2);
    /* Make sure this module belongs to the trace */
    sameModule = null;
    for (IAnalysisModule mod : fTraces[1].getAnalysisModules()) {
        if (mod == module1) {
            sameModule = mod;
        }
    }
    assertNotNull(sameModule);
}
Also used : TestAnalysis(org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis) TestAnalysis2(org.eclipse.tracecompass.tmf.tests.stubs.analysis.TestAnalysis2) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) AnalysisManagerTest(org.eclipse.tracecompass.tmf.core.tests.analysis.AnalysisManagerTest) Test(org.junit.Test)

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