Search in sources :

Example 1 with AnalysisCompilationData

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

the class XmlXYDataProvider method create.

/**
 * Create an instance of {@link XmlXYDataProvider}. Returns null if statesystem
 * is null.
 *
 * @param trace
 *            A trace on which we are interested to fetch a model
 * @param analysisIds
 *            A list of analysis ids used for retrieving Analysis objects
 * @param entryElement
 *            An XML entry element
 * @return A XmlDataProvider
 */
@Nullable
public static XmlXYDataProvider create(ITmfTrace trace, Set<String> analysisIds, Element entryElement) {
    ITmfAnalysisModuleWithStateSystems ss = getStateSystemFromAnalyses(analysisIds, trace);
    if (ss == null) {
        return null;
    }
    AnalysisCompilationData compilationData = new AnalysisCompilationData();
    /*
         * Initialize state attributes. There should be only one entry element for XY
         * charts.
         */
    String path = entryElement.hasAttribute(TmfXmlStrings.PATH) ? entryElement.getAttribute(TmfXmlStrings.PATH) : TmfXmlStrings.WILDCARD;
    XmlXYEntry entry = new XmlXYEntry(ss, path, entryElement, compilationData);
    /* Get the display element to use */
    List<@NonNull Element> displayElements = TmfXmlUtils.getChildElements(entryElement, TmfXmlStrings.DISPLAY_ELEMENT);
    if (displayElements.isEmpty()) {
        return null;
    }
    Element displayElement = displayElements.get(0);
    TmfXmlStateSystemPathCu display = TmfXmlStateSystemPathCu.compile(entry.getAnalysisCompilationData(), Collections.singletonList(displayElement));
    if (display == null) {
        return null;
    }
    /* Get the series name element to use */
    List<Element> seriesNameElements = TmfXmlUtils.getChildElements(entryElement, TmfXmlStrings.NAME_ELEMENT);
    DataDrivenStateSystemPath seriesName = null;
    if (!seriesNameElements.isEmpty()) {
        Element seriesNameElement = seriesNameElements.get(0);
        TmfXmlStateSystemPathCu seriesNameCu = TmfXmlStateSystemPathCu.compile(entry.getAnalysisCompilationData(), Collections.singletonList(seriesNameElement));
        if (seriesNameCu != null) {
            seriesName = seriesNameCu.generate();
        }
    }
    return new XmlXYDataProvider(trace, entry, display.generate(), seriesName);
}
Also used : Element(org.w3c.dom.Element) TmfXmlStateSystemPathCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateSystemPathCu) AnalysisCompilationData(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData) ITmfAnalysisModuleWithStateSystems(org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems) DataDrivenStateSystemPath(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.DataDrivenStateSystemPath) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 2 with AnalysisCompilationData

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

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

the class XmlDataProviderManager method getXyProviderFactory.

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

Example 4 with AnalysisCompilationData

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

the class TmfXmlStateAttributeAndLocationCuTest method testValidLocationCompilation.

/**
 * Test the compilation of a valid state location strings, and states
 * attributes that use it
 *
 * @throws SAXException
 *             Exception thrown by parser
 * @throws IOException
 *             Exception thrown by parser
 * @throws ParserConfigurationException
 *             Exception thrown by parser
 */
@Test
public void testValidLocationCompilation() throws SAXException, IOException, ParserConfigurationException {
    String locName = "loc";
    String location = "<location id=\"" + locName + "\">" + "<stateAttribute type=\"constant\" value=\"abc\" />" + "<stateAttribute type=\"eventField\" value=\"myField\" />" + "</location>";
    AnalysisCompilationData data = new AnalysisCompilationData();
    Element xmlElement = TmfXmlTestUtils.getXmlElement(TmfXmlStrings.LOCATION, location);
    assertNotNull(xmlElement);
    TmfXmlLocationCu locationCu = TmfXmlLocationCu.compile(data, xmlElement);
    assertNotNull("location", locationCu);
    // Add the location to the compilation data
    data.addLocation(locName, locationCu);
    // Compile a location state attribute
    String attributeXml = "<stateAttribute type=\"location\" value=\"" + locName + "\" />";
    xmlElement = TmfXmlTestUtils.getXmlElement(TmfXmlStrings.STATE_ATTRIBUTE, attributeXml);
    assertNotNull(xmlElement);
    List<@NonNull TmfXmlStateValueCu> attribute = TmfXmlStateValueCu.compileAttribute(data, xmlElement);
    assertNotNull("Location attribute compilation", attribute);
    assertEquals("Attribute count", 2, attribute.size());
    List<DataDrivenValue> expected = ImmutableList.of(new DataDrivenValueConstant(null, ITmfStateValue.Type.NULL, "abc"), new DataDrivenValueEventField(null, ITmfStateValue.Type.NULL, "myField"));
    List<DataDrivenValue> actual = attribute.stream().map(a -> a.generate()).collect(Collectors.toList());
    assertEquals("Location generated", expected, actual);
}
Also used : Arrays(java.util.Arrays) TmfXmlStateValueCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateValueCu) Parameters(org.junit.runners.Parameterized.Parameters) TmfXmlTestUtils(org.eclipse.tracecompass.tmf.analysis.xml.core.tests.common.TmfXmlTestUtils) DataDrivenValuePool(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValuePool) TmfXmlLocationCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlLocationCu) ImmutableList(com.google.common.collect.ImmutableList) AnalysisCompilationData(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData) DataDrivenStateSystemPath(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.DataDrivenStateSystemPath) DataDrivenValueQuery(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValueQuery) DataDrivenValueConstant(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValueConstant) TmfXmlStrings(org.eclipse.tracecompass.tmf.analysis.xml.core.module.TmfXmlStrings) DataDrivenValue(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValue) IBaseQuarkProvider(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.IBaseQuarkProvider) DataDrivenValueEventName(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValueEventName) ITmfStateValue(org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue) DataDrivenValueSelf(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValueSelf) Assert.assertNotNull(org.junit.Assert.assertNotNull) IOException(java.io.IOException) Test(org.junit.Test) Collectors(java.util.stream.Collectors) List(java.util.List) Assert.assertNull(org.junit.Assert.assertNull) DataDrivenValueEventField(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValueEventField) Element(org.w3c.dom.Element) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) SAXException(org.xml.sax.SAXException) NonNull(org.eclipse.jdt.annotation.NonNull) Assert.assertEquals(org.junit.Assert.assertEquals) TmfXmlStateValueCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlStateValueCu) Element(org.w3c.dom.Element) DataDrivenValue(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValue) TmfXmlLocationCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlLocationCu) DataDrivenValueEventField(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValueEventField) AnalysisCompilationData(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData) DataDrivenValueConstant(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.values.DataDrivenValueConstant) Test(org.junit.Test)

Example 5 with AnalysisCompilationData

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

the class TmfXmlActionCuTest method testAction.

/**
 * 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 testAction() throws SAXException, IOException, ParserConfigurationException {
    AnalysisCompilationData data = new AnalysisCompilationData();
    Element xmlElement = TmfXmlTestUtils.getXmlElement(TmfXmlStrings.ACTION, fExpected.getXmlString());
    assertNotNull(xmlElement);
    TmfXmlActionCu compiledAction = TmfXmlActionCu.compileNamedAction(data, xmlElement);
    if (fExpected.getResult() == null) {
        assertNull("Expected null action" + fExpected.getName(), compiledAction);
    } else {
        assertNotNull("Expected non null " + fExpected.getName(), compiledAction);
        assertEquals(fExpected.getName() + " generated", fExpected.getResult(), compiledAction.generate());
    }
}
Also used : Element(org.w3c.dom.Element) AnalysisCompilationData(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData) TmfXmlActionCu(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.TmfXmlActionCu) Test(org.junit.Test)

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