Search in sources :

Example 21 with ITmfStateSystem

use of org.eclipse.tracecompass.statesystem.core.ITmfStateSystem 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 22 with ITmfStateSystem

use of org.eclipse.tracecompass.statesystem.core.ITmfStateSystem in project tracecompass by tracecompass.

the class DataDrivenScenarioInfo method getStateStartTime.

/**
 * Get the start time of a state
 *
 * FIXME: For the first iteration (no data driven patterns yet), this method
 * is here, but may move to a class responsible of scenario history, like
 * current code
 *
 * @param container
 *            The analysis data container
 * @param state
 *            The state for which to get the start time
 * @return The start time of the requested state or <code>-1L</code> if this
 *         state has not been reached
 */
public long getStateStartTime(IAnalysisDataContainer container, String state) {
    ITmfStateSystem stateSystem = container.getStateSystem();
    int stateQuark = stateSystem.optQuarkRelative(fQuark, TmfXmlStrings.STATE, state, START_TIME);
    if (stateQuark < 0) {
        return -1L;
    }
    Object startTs = stateSystem.queryOngoing(stateQuark);
    if (startTs instanceof Long) {
        return (long) startTs;
    }
    return -1L;
}
Also used : ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)

Example 23 with ITmfStateSystem

use of org.eclipse.tracecompass.statesystem.core.ITmfStateSystem in project tracecompass by tracecompass.

the class DataDrivenValuePool method resolveValue.

@Override
@Nullable
protected Object resolveValue(ITmfEvent event, int baseQuark, DataDrivenScenarioInfo scenarioInfo, IAnalysisDataContainer container) {
    TmfAttributePool pool = container.getAttributePool(baseQuark);
    if (pool == null) {
        // $NON-NLS-1$
        Activator.logWarning("Attribute type pool: No pool was assigned for quark");
        return null;
    }
    int quark = scenarioInfo.getAttributeFromPool(pool);
    ITmfStateSystem ss = container.getStateSystem();
    return ss.getAttributeName(quark);
}
Also used : TmfAttributePool(org.eclipse.tracecompass.tmf.core.statesystem.TmfAttributePool) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 24 with ITmfStateSystem

use of org.eclipse.tracecompass.statesystem.core.ITmfStateSystem in project tracecompass by tracecompass.

the class DataDrivenValueQuery method executeQuery.

@Nullable
private static Object executeQuery(Supplier<Integer> function, IAnalysisDataContainer container) {
    /* Query the state system for the value */
    Object value = null;
    ITmfStateSystem ss = container.getStateSystem();
    @SuppressWarnings("null") int quarkQuery = function.get();
    /*
         * the query can fail : for example, if a value is requested but has not been
         * set yet
         */
    if (quarkQuery >= 0) {
        value = ss.queryOngoing(quarkQuery);
    }
    return value;
}
Also used : ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 25 with ITmfStateSystem

use of org.eclipse.tracecompass.statesystem.core.ITmfStateSystem in project tracecompass by tracecompass.

the class DataDrivenValueStackPeek method resolveValue.

@Override
@Nullable
protected Object resolveValue(ITmfEvent event, int baseQuark, DataDrivenScenarioInfo scenarioInfo, IAnalysisDataContainer container) {
    final long ts = event.getTimestamp().toNanos();
    /* Query the state system for the value */
    Object value = null;
    ITmfStateSystem ss = container.getStateSystem();
    int quarkQuery = fPath.getQuark(event, baseQuark, scenarioInfo, container);
    /*
         * the query can fail : for example, if a value is requested but has not been
         * set yet
         */
    if (quarkQuery >= 0) {
        try {
            @Nullable ITmfStateInterval stackTopInterval = StateSystemUtils.querySingleStackTop(ss, ts, quarkQuery);
            return (stackTopInterval != null ? stackTopInterval.getStateValue().unboxValue() : null);
        } catch (AttributeNotFoundException | StateSystemDisposedException e) {
            // $NON-NLS-1$
            throw new DataDrivenException("Resolving stack peek: " + e.getMessage(), event);
        }
    }
    return value;
}
Also used : StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) AttributeNotFoundException(org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) DataDrivenException(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenException) Nullable(org.eclipse.jdt.annotation.Nullable) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem) Nullable(org.eclipse.jdt.annotation.Nullable)

Aggregations

ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)137 ITmfStateInterval (org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval)52 Test (org.junit.Test)52 StateSystemDisposedException (org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException)51 NonNull (org.eclipse.jdt.annotation.NonNull)32 AttributeNotFoundException (org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException)30 Nullable (org.eclipse.jdt.annotation.Nullable)26 ArrayList (java.util.ArrayList)25 TmfModelResponse (org.eclipse.tracecompass.tmf.core.response.TmfModelResponse)23 TimeRangeException (org.eclipse.tracecompass.statesystem.core.exceptions.TimeRangeException)22 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)22 HashMap (java.util.HashMap)18 ITmfStateValue (org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue)16 XmlUtilsTest (org.eclipse.tracecompass.tmf.analysis.xml.core.tests.module.XmlUtilsTest)16 AtomicLong (java.util.concurrent.atomic.AtomicLong)15 DataDrivenAnalysisModule (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.module.DataDrivenAnalysisModule)10 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)10 List (java.util.List)9 QuarkIterator (org.eclipse.tracecompass.statesystem.core.StateSystemUtils.QuarkIterator)9 TmfAnalysisException (org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException)9