Search in sources :

Example 6 with ITmfAnalysisModuleWithStateSystems

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

the class TmfXmlAnalysisOutputSource method moduleCreated.

@Override
public void moduleCreated(IAnalysisModule module) {
    if (module instanceof ITmfAnalysisModuleWithStateSystems) {
        Multimap<String, XmlOutputElement> outputs = XmlUtils.getXmlOutputElements();
        for (Collection<XmlOutputElement> elements : outputs.asMap().values()) {
            for (ViewType viewType : ViewType.values()) {
                Iterable<XmlOutputElement> filteredElements = Iterables.filter(elements, element -> (element.getXmlElem().equals(viewType.getXmlElem()) && element.getAnalyses().contains(module.getId())));
                String viewId = viewType.getViewId();
                for (XmlOutputElement element : filteredElements) {
                    IAnalysisOutput output = new TmfXmlViewOutput(viewId, viewType);
                    output.setOutputProperty(TmfXmlStrings.XML_OUTPUT_DATA, element.getId() + DATA_SEPARATOR + element.getPath() + DATA_SEPARATOR + element.getLabel(), false);
                    module.registerOutput(output);
                }
            }
        }
    }
    // Add the latency views for pattern analysis
    if (module instanceof XmlPatternAnalysis) {
        for (LatencyViewType viewType : LatencyViewType.values()) {
            String viewLabelPrefix = ((XmlPatternAnalysis) module).getViewLabelPrefix();
            String label = viewLabelPrefix.isEmpty() ? viewType.getLabel() : viewType.getLabel().replaceFirst(LATENCY_STRING, viewLabelPrefix);
            IAnalysisOutput output = new TmfXmlLatencyViewOutput(viewType.getViewId(), label);
            output.setOutputProperty(TmfXmlStrings.XML_LATENCY_OUTPUT_DATA, module.getId() + DATA_SEPARATOR + output.getName(), false);
            module.registerOutput(output);
        }
    }
}
Also used : XmlPatternAnalysis(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.pattern.stateprovider.XmlPatternAnalysis) XmlOutputElement(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.module.XmlOutputElement) IAnalysisOutput(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisOutput) ITmfAnalysisModuleWithStateSystems(org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems)

Example 7 with ITmfAnalysisModuleWithStateSystems

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

the class StateSystemDataProvider method addTrace.

private boolean addTrace(@Nullable IProgressMonitor monitor) {
    boolean fetchTreeIsComplete = true;
    ITmfTrace trace = getTrace();
    // look if the trace entry already exist
    String traceName = Objects.requireNonNull(trace.getName());
    EntryModelBuilder entry = fEntryBuilder.get(-1L, traceName);
    TraceEntryModel.Builder traceEntry;
    if (entry instanceof TraceEntryModel.Builder) {
        traceEntry = (TraceEntryModel.Builder) entry;
    } else {
        long newId = ENTRY_ID.getAndIncrement();
        traceEntry = new TraceEntryModel.Builder(newId, -1, traceName, trace.getStartTime().toNanos(), trace);
        fEntryBuilder.put(-1L, traceName, traceEntry);
    }
    // add child entry
    long rootId = traceEntry.getId();
    for (Entry<ITmfAnalysisModuleWithStateSystems, Boolean> moduleWithStatus : fModulesToStatus.entrySet()) {
        if (monitor != null && monitor.isCanceled()) {
            return false;
        }
        ITmfAnalysisModuleWithStateSystems module = Objects.requireNonNull(moduleWithStatus.getKey());
        Boolean analysisIsDone = Objects.requireNonNull(moduleWithStatus.getValue());
        if (!analysisIsDone || fStartedAnalysis.contains(module)) {
            // Children entry of the trace are the modules
            fetchTreeIsComplete &= addModule(monitor, module, rootId, trace.getStartTime().toNanos());
            fStartedAnalysis.remove(module);
        }
    }
    // Update end Time
    long traceEnd = traceEntry.getEndTime();
    for (ModuleEntryModel moduleEntryModel : fModuleEntryModelList) {
        if (monitor != null && monitor.isCanceled()) {
            return false;
        }
        traceEnd = Long.max(traceEnd, moduleEntryModel.getEndTime());
    }
    traceEntry.setEndTime(traceEnd);
    return fetchTreeIsComplete;
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITmfAnalysisModuleWithStateSystems(org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems)

Example 8 with ITmfAnalysisModuleWithStateSystems

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

the class TmfStateSystemExplorer method handleAnalysisStarted.

/**
 * Rebuild the view's entry tree to ensure that entries from a newly started
 * trace are added.
 *
 * @param signal
 *            analysis started signal.
 * @since 3.3
 */
@TmfSignalHandler
public void handleAnalysisStarted(TmfStartAnalysisSignal signal) {
    IAnalysisModule module = signal.getAnalysisModule();
    if (module instanceof ITmfAnalysisModuleWithStateSystems && !module.isAutomatic()) {
        /*
             * use set to wait for initialization in build entry list to avoid
             * deadlocks.
             */
        final ITmfTrace viewTrace = getTrace();
        if (Iterables.contains(allModules(viewTrace), module)) {
            /*
                 * Rebuild only if the started analysis module is from the
                 * active trace/experiment.
                 */
            new Thread(() -> {
                /*
                     *  DataProviderManager#getDataProvider() (see getDataProvider() below) should never be called in a signal handler.
                     */
                synchronized (fStartedAnalysis) {
                    fStartedAnalysis.add((ITmfAnalysisModuleWithStateSystems) module);
                    // Every children of ITmfAnalysisModuleWithStateSystems extends TmfAbstractAnalysisModule
                    ITmfTrace moduleTrace = module instanceof TmfAbstractAnalysisModule ? ((TmfAbstractAnalysisModule) module).getTrace() : viewTrace;
                    if (moduleTrace != null) {
                        getDataProvider(moduleTrace).startedAnalysisSignalHandler((ITmfAnalysisModuleWithStateSystems) module);
                        rebuild();
                    }
                }
            }).start();
        } else {
            /*
                 * Reset the View for the relevant trace, ensuring that the
                 * entry list will be rebuilt when the view switches back.
                 */
            for (ITmfTrace trace : TmfTraceManager.getInstance().getOpenedTraces()) {
                if (Iterables.contains(allModules(trace), module)) {
                    synchronized (fStartedAnalysis) {
                        fStartedAnalysis.add((ITmfAnalysisModuleWithStateSystems) module);
                        resetView(trace);
                    }
                    break;
                }
            }
        }
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) IAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule) TmfAbstractAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule) ITmfAnalysisModuleWithStateSystems(org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 9 with ITmfAnalysisModuleWithStateSystems

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

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

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