Search in sources :

Example 6 with AnalysisCompilationData

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

the class TmfXmlFsmCuTest method testFsm.

/**
 * Test the compilation of a valid action strings
 *
 * @throws SAXException
 *             Exception thrown by parser
 * @throws IOException
 *             Exception thrown by parser
 * @throws ParserConfigurationException
 *             Exception thrown by parser
 */
@Test
public void testFsm() throws SAXException, IOException, ParserConfigurationException {
    AnalysisCompilationData data = new AnalysisCompilationData();
    compileActionsAndTests(fExpected.getXmlString(), data);
    Element xmlElement = TmfXmlTestUtils.getXmlElement(TmfXmlStrings.FSM, fExpected.getXmlString());
    assertNotNull(xmlElement);
    TmfXmlFsmCu compiledFsm = TmfXmlFsmStateCu.compileFsm(data, xmlElement);
    if (fExpected.getResult() == null) {
        assertNull("Expected null action" + fExpected.getName(), compiledFsm);
    } else {
        assertNotNull("Expected non null " + fExpected.getName(), compiledFsm);
        assertEquals(fExpected.getName() + " generated", fExpected.getResult(), compiledFsm.generate());
    }
}
Also used : TmfXmlFsmCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlFsmStateCu.TmfXmlFsmCu) Element(org.w3c.dom.Element) AnalysisCompilationData(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData) Test(org.junit.Test)

Example 7 with AnalysisCompilationData

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData 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 8 with AnalysisCompilationData

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

the class XmlXyDataProviderTest method testXYFactory.

/**
 * Test the {@link DataDrivenXYProviderFactory} class
 */
@Test
public void testXYFactory() {
    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.XY_VIEW, XY_VIEW_ID_DELTA);
        assertNotNull(viewElement);
        TmfXmlXYViewCu tgViewCu = TmfXmlXYViewCu.compile(new AnalysisCompilationData(), viewElement);
        assertNotNull(tgViewCu);
        DataDrivenXYProviderFactory XYFactory = tgViewCu.generate();
        // Test the factory with a simple trace
        ITmfTreeXYDataProvider<@NonNull ITmfTreeDataModel> provider = XYFactory.create(trace);
        assertNotNull(provider);
        assertEquals(DataDrivenXYDataProvider.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 = DataDrivenXYProviderFactory.create(trace, Objects.requireNonNull(Lists.newArrayList(stateSystems)), getEntries(new AnalysisCompilationData(), viewElement), ANALYSIS_ID);
        assertNotNull(provider);
        assertEquals(ANALYSIS_ID, provider.getId());
    } finally {
        trace.dispose();
        TmfTraceManager.getInstance().traceClosed(new TmfTraceClosedSignal(this, trace));
    }
}
Also used : DataDrivenXYProviderFactory(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenXYProviderFactory) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfXmlXYViewCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlXYViewCu) ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) Element(org.w3c.dom.Element) 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 9 with AnalysisCompilationData

use of org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData 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)9 Element (org.w3c.dom.Element)6 Test (org.junit.Test)5 Nullable (org.eclipse.jdt.annotation.Nullable)4 TmfXmlTimeGraphViewCu (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlTimeGraphViewCu)3 ITmfAnalysisModuleWithStateSystems (org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems)3 TmfXmlXYViewCu (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlXYViewCu)2 DataDrivenStateSystemPath (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.DataDrivenStateSystemPath)2 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)2 TimeGraphEntryModel (org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel)2 TmfTraceClosedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal)2 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)2 ImmutableList (com.google.common.collect.ImmutableList)1 IOException (java.io.IOException)1 Arrays (java.util.Arrays)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 ParserConfigurationException (javax.xml.parsers.ParserConfigurationException)1 NonNull (org.eclipse.jdt.annotation.NonNull)1 TmfXmlActionCu (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlActionCu)1