Search in sources :

Example 1 with TmfXmlTimeGraphViewCu

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlTimeGraphViewCu in project tracecompass by tracecompass.

the class XmlDataProviderManager method getTimeGraphProviderFactory.

/**
 * Create (if necessary) and get the
 * {@link DataDrivenTimeGraphProviderFactory} from the viewElement.
 *
 * @param viewElement
 *            the XML time graph view element for which we are querying a
 *            provider
 * @return the unique instance of a time graph provider for the queried
 *         parameters
 */
@Nullable
public synchronized DataDrivenTimeGraphProviderFactory getTimeGraphProviderFactory(Element viewElement) {
    if (!viewElement.hasAttribute(ID_ATTRIBUTE)) {
        return null;
    }
    String viewId = viewElement.getAttribute(ID_ATTRIBUTE);
    // factory that can be null
    if (fTimeGraphFactories.containsKey(viewId)) {
        return fTimeGraphFactories.get(viewId);
    }
    // Create with the trace or experiment first
    DataDrivenTimeGraphProviderFactory factory = null;
    TmfXmlTimeGraphViewCu tgViewCu = TmfXmlTimeGraphViewCu.compile(new AnalysisCompilationData(), viewElement);
    if (tgViewCu != null) {
        factory = tgViewCu.generate();
    }
    fTimeGraphFactories.put(viewId, factory);
    return factory;
}
Also used : TmfXmlTimeGraphViewCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlTimeGraphViewCu) AnalysisCompilationData(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 2 with TmfXmlTimeGraphViewCu

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlTimeGraphViewCu in project tracecompass by tracecompass.

the class XmlTimeGraphDataProviderTest method testFactory.

/**
 * Test the {@link DataDrivenTimeGraphProviderFactory} class
 */
@Test
public void testFactory() {
    ITmfTrace trace = getTrace();
    assertNotNull(trace);
    try {
        runModule(trace);
        // Get the view element from the file
        Element viewElement = TmfXmlUtils.getElementInFile(TmfXmlTestFiles.DATA_PROVIDER_SIMPLE_FILE.getPath().toOSString(), TmfXmlStrings.TIME_GRAPH_VIEW, TIME_GRAPH_VIEW_ID);
        assertNotNull(viewElement);
        TmfXmlTimeGraphViewCu tgViewCu = TmfXmlTimeGraphViewCu.compile(new AnalysisCompilationData(), viewElement);
        assertNotNull(tgViewCu);
        DataDrivenTimeGraphProviderFactory timeGraphFactory = tgViewCu.generate();
        // Test the factory with a simple trace
        ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> provider = timeGraphFactory.create(trace);
        assertNotNull(provider);
        assertEquals(DataDrivenTimeGraphDataProvider.ID, provider.getId());
        // Test the factory with an ID and state system
        ITmfAnalysisModuleWithStateSystems module = TmfTraceUtils.getAnalysisModuleOfClass(trace, ITmfAnalysisModuleWithStateSystems.class, ANALYSIS_ID);
        assertNotNull(module);
        Iterable<@NonNull ITmfStateSystem> stateSystems = module.getStateSystems();
        assertNotNull(stateSystems);
        provider = DataDrivenTimeGraphProviderFactory.create(trace, Objects.requireNonNull(Lists.newArrayList(stateSystems)), getEntries(new AnalysisCompilationData(), viewElement), getvalues(viewElement), ANALYSIS_ID);
        assertNotNull(provider);
        assertEquals(ANALYSIS_ID, provider.getId());
    } finally {
        trace.dispose();
        TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, trace));
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) DataDrivenTimeGraphProviderFactory(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenTimeGraphProviderFactory) Element(org.w3c.dom.Element) TmfXmlTimeGraphViewCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlTimeGraphViewCu) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) AnalysisCompilationData(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) ITmfAnalysisModuleWithStateSystems(org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Test(org.junit.Test)

Example 3 with TmfXmlTimeGraphViewCu

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlTimeGraphViewCu in project tracecompass by tracecompass.

the class XmlDataProviderManager method getTimeGraphProvider.

/**
 * Create (if necessary) and get the time graph data provider for the
 * specified trace and viewElement.
 *
 * @param trace
 *            trace for which we are querying a provider
 * @param viewElement
 *            the XML time graph view element for which we are querying a
 *            provider
 * @return the unique instance of a time graph provider for the queried
 *         parameters
 */
@Nullable
public synchronized ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> getTimeGraphProvider(ITmfTrace trace, Element viewElement) {
    if (!viewElement.hasAttribute(ID_ATTRIBUTE)) {
        return null;
    }
    String viewId = viewElement.getAttribute(ID_ATTRIBUTE);
    ITimeGraphDataProvider<@NonNull TimeGraphEntryModel> provider = fTimeGraphProviders.get(trace, viewId);
    if (provider != null) {
        return provider;
    }
    if (Iterables.any(TmfTraceManager.getInstance().getOpenedTraces(), opened -> TmfTraceManager.getTraceSetWithExperiment(opened).contains(trace))) {
        // Create with the trace or experiment first
        TmfXmlTimeGraphViewCu tgViewCu = TmfXmlTimeGraphViewCu.compile(new AnalysisCompilationData(), viewElement);
        if (tgViewCu != null) {
            DataDrivenTimeGraphProviderFactory timeGraphFactory = tgViewCu.generate();
            provider = timeGraphFactory.create(trace);
            if (provider == null) {
                // composite if that's the case
                if (trace instanceof TmfExperiment) {
                    provider = generateExperimentProviderTimeGraph(TmfTraceManager.getTraceSet(trace), viewElement);
                }
            }
            if (provider != null) {
                fTimeGraphProviders.put(trace, viewId, provider);
            }
            return provider;
        }
    }
    return null;
}
Also used : TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) TmfXmlTimeGraphViewCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlTimeGraphViewCu) AnalysisCompilationData(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData) Nullable(org.eclipse.jdt.annotation.Nullable)

Aggregations

AnalysisCompilationData (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData)3 TmfXmlTimeGraphViewCu (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlTimeGraphViewCu)3 Nullable (org.eclipse.jdt.annotation.Nullable)2 TimeGraphEntryModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel)2 DataDrivenTimeGraphProviderFactory (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenTimeGraphProviderFactory)1 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)1 TmfTraceClosedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal)1 ITmfAnalysisModuleWithStateSystems (org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems)1 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)1 TmfExperiment (org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment)1 Test (org.junit.Test)1 Element (org.w3c.dom.Element)1