Commit | Line | Data |
---|---|---|
378e7718 | 1 | /******************************************************************************* |
576f0a4e | 2 | * Copyright (c) 2009, 2014 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 |
95aa81ef | 14 | * Simon Delisle - Added a new parameter to the constructor |
2fc582d2 | 15 | * Xavier Raynaud - Support multi-trace coloring |
378e7718 | 16 | *******************************************************************************/ |
c392540b | 17 | |
e0752744 | 18 | package org.eclipse.linuxtools.tmf.ui.views.histogram; |
6e512b93 | 19 | |
e0752744 | 20 | import org.eclipse.linuxtools.tmf.core.event.ITmfEvent; |
95aa81ef | 21 | import org.eclipse.linuxtools.tmf.core.event.ITmfLostEvent; |
fd3f1eff | 22 | import org.eclipse.linuxtools.tmf.core.request.ITmfEventRequest; |
6c13869b | 23 | import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest; |
3bd46eef AM |
24 | import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp; |
25 | import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimeRange; | |
6e512b93 | 26 | |
378e7718 | 27 | /** |
95aa81ef JCK |
28 | * Class to request events for given time range from a trace to fill a |
29 | * HistogramDataModel and HistogramView. | |
20ff3b75 | 30 | * |
b544077e BH |
31 | * @version 1.0 |
32 | * @author Francois Chouinard | |
95aa81ef | 33 | * <p> |
378e7718 | 34 | */ |
6256d8ad | 35 | public class HistogramRequest extends TmfEventRequest { |
c392540b FC |
36 | |
37 | // ------------------------------------------------------------------------ | |
38 | // Attributes | |
39 | // ------------------------------------------------------------------------ | |
40 | ||
b544077e BH |
41 | /** |
42 | * The histogram data model to fill. | |
43 | */ | |
fbd124dd | 44 | protected final HistogramDataModel fHistogram; |
c392540b | 45 | |
95aa81ef JCK |
46 | private final boolean fFullRange; |
47 | ||
c392540b FC |
48 | // ------------------------------------------------------------------------ |
49 | // Constructor | |
50 | // ------------------------------------------------------------------------ | |
51 | ||
95aa81ef JCK |
52 | /** |
53 | * Constructor | |
54 | * | |
55 | * @param histogram | |
56 | * The histogram data model | |
57 | * @param range | |
58 | * The time range to request data | |
59 | * @param rank | |
60 | * The index of the first event to retrieve | |
61 | * @param nbEvents | |
62 | * The number of events requested | |
63 | * @param blockSize | |
64 | * The number of events per block | |
65 | * @param execType | |
66 | * The requested execution priority | |
67 | * @param fullRange | |
68 | * Full range or time range for histogram request | |
c4767854 | 69 | * @since 3.0 |
95aa81ef JCK |
70 | */ |
71 | public HistogramRequest(HistogramDataModel histogram, TmfTimeRange range, | |
72 | int rank, int nbEvents, int blockSize, | |
fd3f1eff | 73 | ITmfEventRequest.ExecutionType execType, boolean fullRange) { |
5cc0453a | 74 | super(ITmfEvent.class, range, rank, nbEvents, execType); |
95aa81ef JCK |
75 | fHistogram = histogram; |
76 | fFullRange = fullRange; | |
c392540b FC |
77 | } |
78 | ||
c392540b FC |
79 | // ------------------------------------------------------------------------ |
80 | // TmfEventRequest | |
81 | // ------------------------------------------------------------------------ | |
20ff3b75 | 82 | |
b544077e BH |
83 | /** |
84 | * Handle the event from the trace by updating the histogram data model. | |
20ff3b75 | 85 | * |
95aa81ef JCK |
86 | * @param event |
87 | * a event from the trace | |
fd3f1eff | 88 | * @see org.eclipse.linuxtools.tmf.core.request.TmfEventRequest#handleData(org.eclipse.linuxtools.tmf.core.event.ITmfEvent) |
b544077e | 89 | */ |
c392540b | 90 | @Override |
e0752744 | 91 | public void handleData(ITmfEvent event) { |
c392540b | 92 | super.handleData(event); |
41f3b36b AM |
93 | if (event instanceof ITmfLostEvent) { |
94 | ITmfLostEvent lostEvents = (ITmfLostEvent) event; | |
95 | /* clear the old data when it is a new request */ | |
96 | fHistogram.countLostEvent(lostEvents.getTimeRange(), lostEvents.getNbLostEvents(), fFullRange); | |
95aa81ef | 97 | |
41f3b36b AM |
98 | } else { /* handle lost event */ |
99 | long timestamp = event.getTimestamp().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue(); | |
100 | fHistogram.countEvent(getNbRead(), timestamp, event.getTrace()); | |
7ef9ae3f | 101 | } |
6e512b93 | 102 | } |
c392540b | 103 | |
b544077e | 104 | /** |
95aa81ef JCK |
105 | * Complete the request. It also notifies the histogram model about the |
106 | * completion. | |
20ff3b75 | 107 | * |
fd3f1eff | 108 | * @see org.eclipse.linuxtools.tmf.core.request.TmfEventRequest#handleCompleted() |
b544077e | 109 | */ |
6e512b93 | 110 | @Override |
5419a136 | 111 | public void handleCompleted() { |
fbd124dd | 112 | fHistogram.complete(); |
c392540b | 113 | super.handleCompleted(); |
6e512b93 | 114 | } |
6e512b93 | 115 | } |