Search in sources :

Example 1 with ITmfAnalysisModuleWithStateSystems

use of org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems in project tracecompass by tracecompass.

the class PatternProvidersTest method testSegmentStore.

/**
 * Test the generated segment store
 */
@Test
public void testSegmentStore() {
    TmfAbstractAnalysisModule module = getModule();
    if (module instanceof ITmfAnalysisModuleWithStateSystems) {
        // In this test, the module will be XmlPatternAnalysis which is an instance of ITmfAnalysisModuleWithStateSystems
        assertTrue(((ITmfAnalysisModuleWithStateSystems) module).waitForInitialization());
    }
    assertTrue(module.waitForCompletion());
    ISegmentStore<@NonNull ISegment> ss = ((ISegmentStoreProvider) module).getSegmentStore();
    assertNotNull(ss);
    assertFalse(ss.isEmpty());
}
Also used : ISegmentStoreProvider(org.eclipse.tracecompass.analysis.timing.core.segmentstore.ISegmentStoreProvider) ISegment(org.eclipse.tracecompass.segmentstore.core.ISegment) TmfAbstractAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule) ITmfAnalysisModuleWithStateSystems(org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems) Test(org.junit.Test)

Example 2 with ITmfAnalysisModuleWithStateSystems

use of org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems in project tracecompass by tracecompass.

the class XmlProviderTestBase method testStateSystem.

/**
 * Test the building of the state system
 */
@Test
public void testStateSystem() {
    assertTrue(fModule instanceof ITmfAnalysisModuleWithStateSystems);
    assertTrue(((ITmfAnalysisModuleWithStateSystems) fModule).waitForInitialization());
    assertTrue(fModule.waitForCompletion(new NullProgressMonitor()));
    ITmfStateSystem ss = ((ITmfAnalysisModuleWithStateSystems) fModule).getStateSystem(fModule.getId());
    assertNotNull(ss);
    List<Integer> quarks = ss.getQuarks("*");
    assertFalse(quarks.isEmpty());
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ITmfAnalysisModuleWithStateSystems(org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Test(org.junit.Test)

Example 3 with ITmfAnalysisModuleWithStateSystems

use of org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems 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 4 with ITmfAnalysisModuleWithStateSystems

use of org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems 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 5 with ITmfAnalysisModuleWithStateSystems

use of org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems 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)

Aggregations

ITmfAnalysisModuleWithStateSystems (org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems)13 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)6 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)4 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)4 Test (org.junit.Test)4 Element (org.w3c.dom.Element)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3 Nullable (org.eclipse.jdt.annotation.Nullable)3 AnalysisCompilationData (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.compile.AnalysisCompilationData)3 TmfAbstractAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule)3 ITmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel)3 ModuleEntryModel (org.eclipse.tracecompass.internal.tmf.core.statesystem.provider.StateSystemDataProvider.ModuleEntryModel)2 TmfTraceClosedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal)2 ITimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)2 TimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry)2 LinkedHashMap (java.util.LinkedHashMap)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1