tmf: Rename packages to org.eclipse.tracecompass.*
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / views / histogram / HistogramRequest.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2014 Ericsson
3 *
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
8 *
9 * Contributors:
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 * Xavier Raynaud - Support multi-trace coloring
16 *******************************************************************************/
17
18 package org.eclipse.tracecompass.tmf.ui.views.histogram;
19
20 import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
21 import org.eclipse.tracecompass.tmf.core.event.ITmfLostEvent;
22 import org.eclipse.tracecompass.tmf.core.request.ITmfEventRequest;
23 import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
24 import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
25 import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
26
27 /**
28 * Class to request events for given time range from a trace to fill a
29 * HistogramDataModel and HistogramView.
30 *
31 * @version 1.0
32 * @author Francois Chouinard
33 * <p>
34 */
35 public class HistogramRequest extends TmfEventRequest {
36
37 // ------------------------------------------------------------------------
38 // Attributes
39 // ------------------------------------------------------------------------
40
41 /**
42 * The histogram data model to fill.
43 */
44 protected final HistogramDataModel fHistogram;
45
46 private final boolean fFullRange;
47
48 // ------------------------------------------------------------------------
49 // Constructor
50 // ------------------------------------------------------------------------
51
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
69 * @since 3.0
70 */
71 public HistogramRequest(HistogramDataModel histogram, TmfTimeRange range,
72 int rank, int nbEvents, int blockSize,
73 ITmfEventRequest.ExecutionType execType, boolean fullRange) {
74 super(ITmfEvent.class, range, rank, nbEvents, execType);
75 fHistogram = histogram;
76 fFullRange = fullRange;
77 }
78
79 // ------------------------------------------------------------------------
80 // TmfEventRequest
81 // ------------------------------------------------------------------------
82
83 /**
84 * Handle the event from the trace by updating the histogram data model.
85 *
86 * @param event
87 * a event from the trace
88 * @see org.eclipse.tracecompass.tmf.core.request.TmfEventRequest#handleData(org.eclipse.tracecompass.tmf.core.event.ITmfEvent)
89 */
90 @Override
91 public void handleData(ITmfEvent event) {
92 super.handleData(event);
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);
97
98 } else { /* handle lost event */
99 long timestamp = event.getTimestamp().normalize(0, ITmfTimestamp.NANOSECOND_SCALE).getValue();
100 fHistogram.countEvent(getNbRead(), timestamp, event.getTrace());
101 }
102 }
103
104 /**
105 * Complete the request. It also notifies the histogram model about the
106 * completion.
107 *
108 * @see org.eclipse.tracecompass.tmf.core.request.TmfEventRequest#handleCompleted()
109 */
110 @Override
111 public void handleCompleted() {
112 fHistogram.complete();
113 super.handleCompleted();
114 }
115 }
This page took 0.035623 seconds and 5 git commands to generate.