Search in sources :

Example 6 with TmfSignalHandler

use of org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler in project tracecompass by tracecompass.

the class TmfTraceManager method selectionRangeUpdated.

/**
 * Signal handler for the selection range signal.
 *
 * If the signal trace is null, the time selection of *all* traces whose
 * range contains the requested new selection time range will be updated. If
 * the signal contains a trace, the signal trace and time-synchronized
 * traces will be updated, but not other instances of the signal trace.
 *
 * @param signal
 *            The incoming signal
 * @since 1.0
 */
@TmfSignalHandler
public synchronized void selectionRangeUpdated(final TmfSelectionRangeUpdatedSignal signal) {
    final ITmfTimestamp beginTs = signal.getBeginTime();
    final ITmfTimestamp endTs = signal.getEndTime();
    final ITmfTrace signalTrace = signal.getTrace();
    for (ITmfTrace trace : fTraces.keySet()) {
        if ((beginTs.intersects(getValidTimeRange(trace)) || endTs.intersects(getValidTimeRange(trace))) && (signalTrace == null || isSynchronized(trace, signalTrace))) {
            updateTraceContext(trace, builder -> builder.setSelection(new TmfTimeRange(beginTs, endTs)));
        }
    }
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 7 with TmfSignalHandler

use of org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler in project tracecompass by tracecompass.

the class TmfTraceManager method traceClosed.

/**
 * Signal handler for the traceClosed signal.
 *
 * @param signal
 *            The incoming signal
 */
@TmfSignalHandler
public synchronized void traceClosed(final TmfTraceClosedSignal signal) {
    fTraces.remove(signal.getTrace());
    IResource resource = signal.getTrace().getResource();
    if (resource != null && fTraces.keySet().stream().noneMatch(trace -> resource.equals(trace.getResource()))) {
        /* Reset the instance count only when no other instance remains */
        fInstanceCounts.setCount(resource, 0);
    }
    if (fTraces.size() == 0) {
        fCurrentTrace = null;
    /*
             * In other cases, we should receive a traceSelected signal that
             * will indicate which trace is the new one.
             */
    }
}
Also used : TmfTraceOpenedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceOpenedSignal) Iterables(com.google.common.collect.Iterables) IFolder(org.eclipse.core.resources.IFolder) Multiset(com.google.common.collect.Multiset) URISyntaxException(java.net.URISyntaxException) UnaryOperator(java.util.function.UnaryOperator) CoreException(org.eclipse.core.runtime.CoreException) TmfTraceClosedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal) TmfExperiment(org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment) TmfEventFilterAppliedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfEventFilterAppliedSignal) StringUtils(org.apache.commons.lang3.StringUtils) NonNullUtils(org.eclipse.tracecompass.common.core.NonNullUtils) LinkedHashMap(java.util.LinkedHashMap) TmfSelectionRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal) URIUtil(org.eclipse.core.runtime.URIUtil) Activator(org.eclipse.tracecompass.internal.tmf.core.Activator) IProject(org.eclipse.core.resources.IProject) Nullable(org.eclipse.jdt.annotation.Nullable) HashMultiset(com.google.common.collect.HashMultiset) Map(java.util.Map) IFile(org.eclipse.core.resources.IFile) NonNullUtils.checkNotNull(org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull) TmfTraceSelectedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal) NonNullByDefault(org.eclipse.jdt.annotation.NonNullByDefault) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler) ImmutableSet(com.google.common.collect.ImmutableSet) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) FileUtils(org.apache.commons.io.FileUtils) Collectors(java.util.stream.Collectors) TmfCommonConstants(org.eclipse.tracecompass.tmf.core.TmfCommonConstants) File(java.io.File) Objects(java.util.Objects) ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) List(java.util.List) IResource(org.eclipse.core.resources.IResource) Path(org.eclipse.core.runtime.Path) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) TmfTraceModelSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceModelSignal) TmfSignalManager(org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) Collections(java.util.Collections) NonNull(org.eclipse.jdt.annotation.NonNull) IResource(org.eclipse.core.resources.IResource) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 8 with TmfSignalHandler

use of org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler in project tracecompass by tracecompass.

the class TmfExperiment method traceOpened.

// ------------------------------------------------------------------------
// Signal handlers
// ------------------------------------------------------------------------
@Override
@TmfSignalHandler
public void traceOpened(TmfTraceOpenedSignal signal) {
    if (signal.getTrace() == this) {
        initializeStreamingMonitor();
        /* Initialize the analysis */
        MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK, null, null);
        status.add(executeAnalysis());
        if (!status.isOK()) {
            Activator.log(status);
        }
        /* Refresh supplementary files in separate thread to prevent deadlock */
        new // $NON-NLS-1$
        Thread(// $NON-NLS-1$
        "Refresh supplementary files") {

            @Override
            public void run() {
                TmfTraceManager.refreshSupplementaryFiles(TmfExperiment.this);
            }
        }.start();
    }
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 9 with TmfSignalHandler

use of org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler in project tracecompass by tracecompass.

the class TmfStatisticsViewer method traceRangeUpdated.

// ------------------------------------------------------------------------
// Signal handlers
// ------------------------------------------------------------------------
/**
 * Handles the signal about new trace range.
 *
 * @param signal
 *            The trace range updated signal
 */
@TmfSignalHandler
public void traceRangeUpdated(TmfTraceRangeUpdatedSignal signal) {
    ITmfTrace trace = signal.getTrace();
    // validate
    if (!isListeningTo(trace)) {
        return;
    }
    synchronized (fStatisticsRangeUpdateSyncObj) {
        // Sends the time range request only once from this method.
        if (fSendRangeRequest) {
            fSendRangeRequest = false;
            TmfTraceContext ctx = TmfTraceManager.getInstance().getCurrentTraceContext();
            TmfTimeRange timeRange = ctx.getSelectionRange();
            requestTimeRangeData(trace, timeRange);
        }
    }
    requestData(trace, signal.getRange());
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTraceContext(org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 10 with TmfSignalHandler

use of org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler in project tracecompass by tracecompass.

the class TmfStatisticsViewer method timeSynchUpdated.

/**
 * Handles the time synch updated signal. It updates the time range
 * statistics.
 *
 * @param signal
 *            Contains the information about the new selected time range.
 * @since 1.0
 */
@TmfSignalHandler
public void timeSynchUpdated(TmfSelectionRangeUpdatedSignal signal) {
    if (fTrace == null) {
        return;
    }
    ITmfTimestamp begin = signal.getBeginTime();
    ITmfTimestamp end = signal.getEndTime();
    TmfTimeRange timeRange;
    if (begin.compareTo(end) <= 0) {
        timeRange = new TmfTimeRange(begin, end);
    } else {
        timeRange = new TmfTimeRange(end, begin);
    }
    requestTimeRangeData(fTrace, timeRange);
}
Also used : ITmfTimestamp(org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Aggregations

TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)53 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)22 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)19 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)6 TmfTraceContext (org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext)6 Job (org.eclipse.core.runtime.jobs.Job)4 IFile (org.eclipse.core.resources.IFile)3 IAnalysisModule (org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule)3 TmfTraceElement (org.eclipse.tracecompass.tmf.ui.project.model.TmfTraceElement)3 Collection (java.util.Collection)2 LinkedHashMap (java.util.LinkedHashMap)2 Map (java.util.Map)2 Set (java.util.Set)2 IResource (org.eclipse.core.resources.IResource)2 IStatus (org.eclipse.core.runtime.IStatus)2 ITmfEvent (org.eclipse.tracecompass.tmf.core.event.ITmfEvent)2 TmfEventRequest (org.eclipse.tracecompass.tmf.core.request.TmfEventRequest)2 TmfSelectionRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal)2 TmfTraceStub (org.eclipse.tracecompass.tmf.tests.stubs.trace.TmfTraceStub)2 HashMultiset (com.google.common.collect.HashMultiset)1