analysis: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / views / histogram / HistogramRequest.java
CommitLineData
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
2bdf0193 18package org.eclipse.tracecompass.tmf.ui.views.histogram;
6e512b93 19
2bdf0193
AM
20import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
21import org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent;
22import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest;
23import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
24import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
25import org.eclipse.tracecompass.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 35public 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
95aa81ef
JCK
69 */
70 public HistogramRequest(HistogramDataModel histogram, TmfTimeRange range,
71 int rank, int nbEvents, int blockSize,
fd3f1eff 72 ITmfEventRequest.ExecutionType execType, boolean fullRange) {
5cc0453a 73 super(ITmfEvent.class, range, rank, nbEvents, execType);
95aa81ef
JCK
74 fHistogram = histogram;
75 fFullRange = fullRange;
c392540b
FC
76 }
77
c392540b
FC
78 // ------------------------------------------------------------------------
79 // TmfEventRequest
80 // ------------------------------------------------------------------------
20ff3b75 81
b544077e
BH
82 /**
83 * Handle the event from the trace by updating the histogram data model.
20ff3b75 84 *
95aa81ef
JCK
85 * @param event
86 * a event from the trace
2bdf0193 87 * @see org.eclipse.tracecompass.tmf.core.request.TmfEventRequest#handleData(org.eclipse.tracecompass.tmf.core.event.ITmfEvent)
b544077e 88 */
c392540b 89 @Override
e0752744 90 public void handleData(ITmfEvent event) {
c392540b 91 super.handleData(event);
4540412a
PT
92 synchronized (fHistogram) {
93 if (!isCancelled()) {
94 if (event instanceof ITmfLostEvent) {
95 ITmfLostEvent lostEvents = (ITmfLostEvent) event;
96 /* clear the old data when it is a new request */
97 fHistogram.countLostEvent(lostEvents.getTimeRange(), lostEvents.getNbLostEvents(), fFullRange);
95aa81ef 98
4540412a
PT
99 } else { /* handle lost event */
100 long timestamp = event.getTimestamp().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
101 fHistogram.countEvent(getNbRead(), timestamp, event.getTrace());
102 }
103 }
7ef9ae3f 104 }
6e512b93 105 }
c392540b 106
b544077e 107 /**
95aa81ef
JCK
108 * Complete the request. It also notifies the histogram model about the
109 * completion.
20ff3b75 110 *
2bdf0193 111 * @see org.eclipse.tracecompass.tmf.core.request.TmfEventRequest#handleCompleted()
b544077e 112 */
6e512b93 113 @Override
5419a136 114 public void handleCompleted() {
fbd124dd 115 fHistogram.complete();
c392540b 116 super.handleCompleted();
6e512b93 117 }
6e512b93 118}
This page took 0.096397 seconds and 5 git commands to generate.