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 | */ |
8584dc20 | 32 | @SuppressWarnings("deprecation") |
6256d8ad | 33 | public class HistogramRequest extends TmfEventRequest { |
c392540b FC |
34 | |
35 | // ------------------------------------------------------------------------ | |
36 | // Attributes | |
37 | // ------------------------------------------------------------------------ | |
38 | ||
b544077e BH |
39 | /** |
40 | * The histogram data model to fill. | |
41 | */ | |
fbd124dd | 42 | protected final HistogramDataModel fHistogram; |
c392540b FC |
43 | |
44 | // ------------------------------------------------------------------------ | |
45 | // Constructor | |
46 | // ------------------------------------------------------------------------ | |
47 | ||
b544077e BH |
48 | /** |
49 | * Constructor | |
20ff3b75 AM |
50 | * |
51 | * @param histogram | |
52 | * The histogram data model | |
53 | * @param range | |
54 | * The time range to request data | |
55 | * @param rank | |
56 | * The index of the first event to retrieve | |
57 | * @param nbEvents | |
58 | * The number of events requested | |
59 | * @param blockSize | |
60 | * The number of events per block | |
61 | * @param execType | |
62 | * The requested execution priority | |
63 | * | |
b544077e | 64 | */ |
20ff3b75 AM |
65 | public HistogramRequest(HistogramDataModel histogram, TmfTimeRange range, |
66 | int rank, int nbEvents, int blockSize, | |
67 | ITmfDataRequest.ExecutionType execType) { | |
68 | super(ITmfEvent.class, range, rank, nbEvents, | |
69 | (blockSize > 0) ? blockSize : ITmfTrace.DEFAULT_TRACE_CACHE_SIZE, | |
70 | execType); | |
c392540b FC |
71 | fHistogram = histogram; |
72 | } | |
73 | ||
c392540b FC |
74 | // ------------------------------------------------------------------------ |
75 | // TmfEventRequest | |
76 | // ------------------------------------------------------------------------ | |
20ff3b75 | 77 | |
b544077e BH |
78 | /** |
79 | * Handle the event from the trace by updating the histogram data model. | |
20ff3b75 | 80 | * |
b544077e BH |
81 | * @param event a event from the trace |
82 | * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleData(org.eclipse.linuxtools.tmf.core.event.ITmfEvent) | |
83 | */ | |
c392540b | 84 | @Override |
8584dc20 | 85 | @SuppressWarnings("javadoc") |
e0752744 | 86 | public void handleData(ITmfEvent event) { |
c392540b | 87 | super.handleData(event); |
cb866e08 | 88 | if (event != null) { |
faa38350 | 89 | long timestamp = event.getTimestamp().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue(); |
fbd124dd | 90 | fHistogram.countEvent(getNbRead(), timestamp); |
7ef9ae3f | 91 | } |
6e512b93 | 92 | } |
c392540b | 93 | |
b544077e BH |
94 | /** |
95 | * Complete the request. It also notifies the histogram model about the completion. | |
20ff3b75 | 96 | * |
b544077e BH |
97 | * @see org.eclipse.linuxtools.tmf.core.request.TmfDataRequest#handleCompleted() |
98 | */ | |
6e512b93 | 99 | @Override |
8584dc20 FC |
100 | @SuppressWarnings("javadoc") |
101 | public synchronized void handleCompleted() { | |
fbd124dd | 102 | fHistogram.complete(); |
c392540b | 103 | super.handleCompleted(); |
6e512b93 | 104 | } |
6e512b93 | 105 | } |