1 /*******************************************************************************
2 * Copyright (c) 2009, 2014 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * William Bourque - Initial API and implementation
11 * Yuriy Vashchuk - Heritage correction.
12 * Francois Chouinard - Cleanup and refactoring
13 * Francois Chouinard - Moved from LTTng to TMF
14 * Simon Delisle - Added a new parameter to the constructor
15 * Xavier Raynaud - Support multi-trace coloring
16 *******************************************************************************/
18 package org
.eclipse
.tracecompass
.tmf
.ui
.views
.histogram
;
20 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfEvent
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.event
.ITmfLostEvent
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.request
.ITmfEventRequest
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.request
.TmfEventRequest
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimeRange
;
27 * Class to request events for given time range from a trace to fill a
28 * HistogramDataModel and HistogramView.
31 * @author Francois Chouinard
34 public class HistogramRequest
extends TmfEventRequest
{
36 // ------------------------------------------------------------------------
38 // ------------------------------------------------------------------------
41 * The histogram data model to fill.
43 protected final HistogramDataModel fHistogram
;
45 private final boolean fFullRange
;
47 // ------------------------------------------------------------------------
49 // ------------------------------------------------------------------------
55 * The histogram data model
57 * The time range to request data
59 * The index of the first event to retrieve
61 * The number of events requested
63 * The number of events per block
65 * The requested execution priority
67 * Full range or time range for histogram request
69 public HistogramRequest(HistogramDataModel histogram
, TmfTimeRange range
,
70 int rank
, int nbEvents
, int blockSize
,
71 ITmfEventRequest
.ExecutionType execType
, boolean fullRange
) {
72 super(ITmfEvent
.class, range
, rank
, nbEvents
, execType
);
73 fHistogram
= histogram
;
74 fFullRange
= fullRange
;
77 // ------------------------------------------------------------------------
79 // ------------------------------------------------------------------------
82 * Handle the event from the trace by updating the histogram data model.
85 * a event from the trace
86 * @see org.eclipse.tracecompass.tmf.core.request.TmfEventRequest#handleData(org.eclipse.tracecompass.tmf.core.event.ITmfEvent)
89 public void handleData(ITmfEvent event
) {
90 super.handleData(event
);
91 synchronized (fHistogram
) {
93 if (event
instanceof ITmfLostEvent
) {
94 ITmfLostEvent lostEvents
= (ITmfLostEvent
) event
;
95 /* clear the old data when it is a new request */
96 fHistogram
.countLostEvent(lostEvents
.getTimeRange(), lostEvents
.getNbLostEvents(), fFullRange
);
98 } else { /* handle lost event */
99 long timestamp
= event
.getTimestamp().toNanos();
100 fHistogram
.countEvent(getNbRead(), timestamp
, event
.getTrace());
107 * Complete the request. It also notifies the histogram model about the
110 * @see org.eclipse.tracecompass.tmf.core.request.TmfEventRequest#handleCompleted()
113 public void handleCompleted() {
114 fHistogram
.complete();
115 super.handleCompleted();