Commit | Line | Data |
---|---|---|
378e7718 | 1 | /******************************************************************************* |
e0752744 | 2 | * Copyright (c) 2009, 2011, 2012 Ericsson |
20ff3b75 | 3 | * |
378e7718 WB |
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 | |
20ff3b75 | 8 | * |
378e7718 WB |
9 | * Contributors: |
10 | * William Bourque - Initial API and implementation | |
c392540b FC |
11 | * Yuriy Vashchuk - Heritage correction. |
12 | * Francois Chouinard - Cleanup and refactoring | |
e0752744 | 13 | * Francois Chouinard - Moved from LTTng to TMF |
378e7718 | 14 | *******************************************************************************/ |
c392540b | 15 | |
e0752744 | 16 | package org.eclipse.linuxtools.tmf.ui.views.histogram; |
6e512b93 | 17 | |
e0752744 | 18 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; |
faa38350 | 19 | import org.eclipse.linuxtools.tmf.core.event.ITmfTimestamp; |
6c13869b FC |
20 | import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange; |
21 | import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest; | |
22 | import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; | |
0316808c | 23 | import org.eclipse.linuxtools.tmf.core.trace.ITmfTrace; |
6e512b93 | 24 | |
378e7718 | 25 | /** |
b544077e | 26 | * Class to request events for given time range from a trace to fill a HistogramDataModel and HistogramView. |
20ff3b75 | 27 | * |
b544077e BH |
28 | * @version 1.0 |
29 | * @author Francois Chouinard | |
378e7718 | 30 | * <p> |
378e7718 | 31 | */ |
6256d8ad | 32 | public class HistogramRequest extends TmfEventRequest { |
c392540b FC |
33 | |
34 | // ------------------------------------------------------------------------ | |
35 | // Attributes | |
36 | // ------------------------------------------------------------------------ | |
37 | ||
b544077e BH |
38 | /** |
39 | * The histogram data model to fill. | |
40 | */ | |
fbd124dd | 41 | protected final HistogramDataModel fHistogram; |
c392540b FC |
42 | |
43 | // ------------------------------------------------------------------------ | |
44 | // Constructor | |
45 | // ------------------------------------------------------------------------ | |
46 | ||
b544077e BH |
47 | /** |
48 | * Constructor | |
20ff3b75 AM |
49 | * |
50 | * @param histogram | |
51 | * The histogram data model | |
52 | * @param range | |
53 | * The time range to request data | |
54 | * @param rank | |
55 | * The index of the first event to retrieve | |
56 | * @param nbEvents | |
57 | * The number of events requested | |
58 | * @param blockSize | |
59 | * The number of events per block | |
60 | * @param execType | |
61 | * The requested execution priority | |
62 | * | |
b544077e | 63 | */ |
20ff3b75 AM |
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, | |
68 | (blockSize > 0) ? blockSize : ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, | |
69 | execType); | |
c392540b FC |
70 | fHistogram = histogram; |
71 | } | |
72 | ||
c392540b FC |
73 | // ------------------------------------------------------------------------ |
74 | // TmfEventRequest | |
75 | // ------------------------------------------------------------------------ | |
20ff3b75 | 76 | |
b544077e BH |
77 | /** |
78 | * Handle the event from the trace by updating the histogram data model. | |
20ff3b75 | 79 | * |
b544077e BH |
80 | * @param event a event from the trace |
81 | * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleData(org.eclipse.linuxtools.tmf.core.event.ITmfEvent) | |
82 | */ | |
c392540b | 83 | @Override |
e0752744 | 84 | public void handleData(ITmfEvent event) { |
c392540b | 85 | super.handleData(event); |
cb866e08 | 86 | if (event != null) { |
faa38350 | 87 | long timestamp = event.getTimestamp().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue(); |
fbd124dd | 88 | fHistogram.countEvent(getNbRead(), timestamp); |
7ef9ae3f | 89 | } |
6e512b93 | 90 | } |
c392540b | 91 | |
b544077e BH |
92 | /** |
93 | * Complete the request. It also notifies the histogram model about the completion. | |
20ff3b75 | 94 | * |
b544077e BH |
95 | * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleCompleted() |
96 | */ | |
6e512b93 ASL |
97 | @Override |
98 | public void handleCompleted() { | |
fbd124dd | 99 | fHistogram.complete(); |
c392540b | 100 | super.handleCompleted(); |
6e512b93 | 101 | } |
6e512b93 | 102 | } |