linux: make KernelStateProvider handle aggregate prev_states of sched_switch
[deliverable/tracecompass.git] / tmf / 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 */
70 public HistogramRequest(HistogramDataModel histogram, TmfTimeRange range,
71 int rank, int nbEvents, int blockSize,
72 ITmfEventRequest.ExecutionType execType, boolean fullRange) {
73 super(ITmfEvent.class, range, rank, nbEvents, execType);
74 fHistogram = histogram;
75 fFullRange = fullRange;
76 }
77
78 // ------------------------------------------------------------------------
79 // TmfEventRequest
80 // ------------------------------------------------------------------------
81
82 /**
83 * Handle the event from the trace by updating the histogram data model.
84 *
85 * @param event
86 * a event from the trace
87 * @see org.eclipse.tracecompass.tmf.core.request.TmfEventRequest#handleData(org.eclipse.tracecompass.tmf.core.event.ITmfEvent)
88 */
89 @Override
90 public void handleData(ITmfEvent event) {
91 super.handleData(event);
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);
98
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 }
104 }
105 }
106
107 /**
108 * Complete the request. It also notifies the histogram model about the
109 * completion.
110 *
111 * @see org.eclipse.tracecompass.tmf.core.request.TmfEventRequest#handleCompleted()
112 */
113 @Override
114 public void handleCompleted() {
115 fHistogram.complete();
116 super.handleCompleted();
117 }
118 }
This page took 0.033814 seconds and 5 git commands to generate.