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
.ITmfTimestamp
;
25 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimeRange
;
28 * Class to request events for given time range from a trace to fill a
29 * HistogramDataModel and HistogramView.
32 * @author Francois Chouinard
35 public class HistogramRequest
extends TmfEventRequest
{
37 // ------------------------------------------------------------------------
39 // ------------------------------------------------------------------------
42 * The histogram data model to fill.
44 protected final HistogramDataModel fHistogram
;
46 private final boolean fFullRange
;
48 // ------------------------------------------------------------------------
50 // ------------------------------------------------------------------------
56 * The histogram data model
58 * The time range to request data
60 * The index of the first event to retrieve
62 * The number of events requested
64 * The number of events per block
66 * The requested execution priority
68 * Full range or time range for histogram request
70 public HistogramRequest(HistogramDataModel histogram
, TmfTimeRange range
,
71 int rank
, int nbEvents
, int blockSize
,
72 ITmfEventRequest
.ExecutionType execType
, boolean fullRange
) {
73 super(ITmfEvent
.class, range
, rank
, nbEvents
, execType
);
74 fHistogram
= histogram
;
75 fFullRange
= fullRange
;
78 // ------------------------------------------------------------------------
80 // ------------------------------------------------------------------------
83 * Handle the event from the trace by updating the histogram data model.
86 * a event from the trace
87 * @see org.eclipse.tracecompass.tmf.core.request.TmfEventRequest#handleData(org.eclipse.tracecompass.tmf.core.event.ITmfEvent)
90 public void handleData(ITmfEvent event
) {
91 super.handleData(event
);
92 synchronized (fHistogram
) {
94 if (event
instanceof ITmfLostEvent
) {
95 ITmfLostEvent lostEvents
= (ITmfLostEvent
) event
;
96 /* clear the old data when it is a new request */
97 fHistogram
.countLostEvent(lostEvents
.getTimeRange(), lostEvents
.getNbLostEvents(), fFullRange
);
99 } else { /* handle lost event */
100 long timestamp
= event
.getTimestamp().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
101 fHistogram
.countEvent(getNbRead(), timestamp
, event
.getTrace());
108 * Complete the request. It also notifies the histogram model about the
111 * @see org.eclipse.tracecompass.tmf.core.request.TmfEventRequest#handleCompleted()
114 public void handleCompleted() {
115 fHistogram
.complete();
116 super.handleCompleted();