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 * Simon Delisle - Added a new parameter to the constructor
15 *******************************************************************************/
17 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.histogram
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfLostEvent
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.request
.ITmfDataRequest
;
22 import org
.eclipse
.linuxtools
.tmf
.core
.request
.TmfEventRequest
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.timestamp
.ITmfTimestamp
;
24 import org
.eclipse
.linuxtools
.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
70 public HistogramRequest(HistogramDataModel histogram
, TmfTimeRange range
,
71 int rank
, int nbEvents
, int blockSize
,
72 ITmfDataRequest
.ExecutionType execType
) {
73 super(ITmfEvent
.class, range
, rank
, nbEvents
, execType
);
74 fHistogram
= histogram
;
75 if (execType
== ExecutionType
.FOREGROUND
) {
86 * The histogram data model
88 * The time range to request data
90 * The index of the first event to retrieve
92 * The number of events requested
94 * The number of events per block
96 * The requested execution priority
98 * Full range or time range for histogram request
102 public HistogramRequest(HistogramDataModel histogram
, TmfTimeRange range
,
103 int rank
, int nbEvents
, int blockSize
,
104 ITmfDataRequest
.ExecutionType execType
, boolean fullRange
) {
105 super(ITmfEvent
.class, range
, rank
, nbEvents
, execType
);
106 fHistogram
= histogram
;
107 fFullRange
= fullRange
;
110 // ------------------------------------------------------------------------
112 // ------------------------------------------------------------------------
115 * Handle the event from the trace by updating the histogram data model.
118 * a event from the trace
119 * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleData(org.eclipse.linuxtools.tmf.core.event.ITmfEvent)
122 public void handleData(ITmfEvent event
) {
123 super.handleData(event
);
125 if (event
instanceof ITmfLostEvent
) {
126 ITmfLostEvent lostEvents
= (ITmfLostEvent
) event
;
127 /* clear the old data when it is a new request */
128 fHistogram
.countLostEvent(lostEvents
.getTimeRange(), lostEvents
.getNbLostEvents(), fFullRange
);
130 } else { /* handle lost event */
131 long timestamp
= event
.getTimestamp().normalize(0, ITmfTimestamp
.NANOSECOND_SCALE
).getValue();
132 fHistogram
.countEvent(getNbRead(), timestamp
);
138 * Complete the request. It also notifies the histogram model about the
141 * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleCompleted()
144 public void handleCompleted() {
145 fHistogram
.complete();
146 super.handleCompleted();