1 /*******************************************************************************
2 * Copyright (c) 2009, 2013 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 *******************************************************************************/
16 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.histogram
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.request
.ITmfDataRequest
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.request
.TmfEventRequest
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.ITmfTimestamp
;
22 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.TmfTimeRange
;
25 * Class to request events for given time range from a trace to fill a HistogramDataModel and HistogramView.
28 * @author Francois Chouinard
31 public class HistogramRequest
extends TmfEventRequest
{
33 // ------------------------------------------------------------------------
35 // ------------------------------------------------------------------------
38 * The histogram data model to fill.
40 protected final HistogramDataModel fHistogram
;
42 // ------------------------------------------------------------------------
44 // ------------------------------------------------------------------------
50 * The histogram data model
52 * The time range to request data
54 * The index of the first event to retrieve
56 * The number of events requested
58 * The number of events per block
60 * The requested execution priority
64 public HistogramRequest(HistogramDataModel histogram
, TmfTimeRange range
,
65 int rank
, int nbEvents
, int blockSize
,
66 ITmfDataRequest
.ExecutionType execType
) {
67 super(ITmfEvent
.class, range
, rank
, nbEvents
, execType
);
68 fHistogram
= histogram
;
71 // ------------------------------------------------------------------------
73 // ------------------------------------------------------------------------
76 * Handle the event from the trace by updating the histogram data model.
78 * @param event a event from the trace
79 * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleData(org.eclipse.linuxtools.tmf.core.event.ITmfEvent)
82 public void handleData(ITmfEvent event
) {
83 super.handleData(event
);
85 long timestamp
= event
.getTimestamp().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
86 fHistogram
.countEvent(getNbRead(), timestamp
);
91 * Complete the request. It also notifies the histogram model about the completion.
93 * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleCompleted()
96 public void handleCompleted() {
97 fHistogram
.complete();
98 super.handleCompleted();