24b389ef27d94808d755ab1f36c660ae56ead5eb
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / latency / model / LatencyEventRequest.java
1 /*******************************************************************************
2 * Copyright (c) 2011 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 * Bernd Hufmann - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.lttng.ui.views.latency.model;
14
15 import org.eclipse.linuxtools.internal.lttng.core.LttngConstants;
16 import org.eclipse.linuxtools.internal.lttng.core.event.LttngEvent;
17 import org.eclipse.linuxtools.internal.lttng.core.latency.analyzer.EventMatcher;
18 import org.eclipse.linuxtools.tmf.core.event.TmfTimeRange;
19 import org.eclipse.linuxtools.tmf.core.request.ITmfDataRequest;
20 import org.eclipse.linuxtools.tmf.core.request.TmfEventRequest;
21
22 /**
23 * <b><u>LatencyEventRequest</u></b>
24 * <p>
25 */
26 public class LatencyEventRequest extends TmfEventRequest<LttngEvent> {
27
28 // ------------------------------------------------------------------------
29 // Attributes
30 // ------------------------------------------------------------------------
31 final private LatencyController fController;
32
33 // ------------------------------------------------------------------------
34 // Constructor
35 // ------------------------------------------------------------------------
36
37 public LatencyEventRequest(LatencyController controller, TmfTimeRange range, int rank, int nbEvents, ITmfDataRequest.ExecutionType execType) {
38 super(LttngEvent.class, range, rank, nbEvents, LttngConstants.DEFAULT_BLOCK_SIZE, execType);
39 fController = controller;
40 EventMatcher.getInstance().clearStack();
41 }
42
43 public LatencyEventRequest(LatencyController controller, TmfTimeRange range, ITmfDataRequest.ExecutionType execType) {
44 this(controller, range, 0, ALL_DATA, execType);
45 }
46
47 public LatencyEventRequest(LatencyController controller, TmfTimeRange range, int rank, ITmfDataRequest.ExecutionType execType) {
48 this(controller, range, rank, ALL_DATA, execType);
49 }
50
51 // ------------------------------------------------------------------------
52 // Operations
53 // ------------------------------------------------------------------------
54
55 /*
56 * (non-Javadoc)
57 * @see org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleData(org.eclipse.linuxtools.tmf.event.TmfData)
58 */
59 @Override
60 public void handleData(LttngEvent event) {
61 super.handleData(event);
62
63 LttngEvent startEvent = EventMatcher.getInstance().process(event);
64
65 if (startEvent != null) {
66 long latency = event.getTimestamp().getValue() - startEvent.getTimestamp().getValue();
67 fController.handleData(getNbRead(), startEvent.getTimestamp().getValue(), latency);
68 }
69 }
70
71 /*
72 * (non-Javadoc)
73 * @see org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleCompleted()
74 */
75 @Override
76 public void handleCompleted() {
77 fController.handleCompleted();
78 super.handleCompleted();
79 }
80
81 /*
82 * (non-Javadoc)
83 * @see org.eclipse.linuxtools.tmf.request.TmfDataRequest#handleCancel()
84 */
85 @Override
86 public void handleCancel() {
87 EventMatcher.getInstance().clearStack();
88 fController.handleCancel();
89 super.handleCancel();
90 }
91 }
This page took 0.032221 seconds and 4 git commands to generate.