Re-structure LTTng sub-project as per the Linux Tools guidelines
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / controlflow / evProcessor / FlowFinishUpdateHandler.java
1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are made
5 * 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 * Alvaro Sanchez-Leon - Initial implementation
11 * Michel Dagenais (michel.dagenais@polymtl.ca) - Reference C implementation, used with permission
12 *******************************************************************************/
13 package org.eclipse.linuxtools.lttng.ui.views.controlflow.evProcessor;
14
15 import java.util.Vector;
16
17 import org.eclipse.linuxtools.lttng.core.event.LttngEvent;
18 import org.eclipse.linuxtools.lttng.core.state.StateStrings.Events;
19 import org.eclipse.linuxtools.lttng.core.state.evProcessor.ILttngEventProcessor;
20 import org.eclipse.linuxtools.lttng.core.state.model.LttngProcessState;
21 import org.eclipse.linuxtools.lttng.core.state.model.LttngTraceState;
22 import org.eclipse.linuxtools.lttng.ui.TraceDebug;
23 import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeComponent;
24 import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEvent;
25 import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventProcess;
26
27 /**
28 * Creates specific finish state data request
29 *
30 * @author alvaro
31 *
32 */
33 public class FlowFinishUpdateHandler extends AbsFlowTRangeUpdate
34 implements ILttngEventProcessor {
35
36 public Events getEventHandleType() {
37 // No specific event
38 return null;
39 }
40
41 @SuppressWarnings("deprecation")
42 @Override
43 public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
44 // The end of the last state is unknown since it's beyond the requested time range window. Create this last
45 // event to half page after the visible window but not beyond the end of trace
46 long endOfTrace = traceSt.getContext().getTraceTimeWindow().getEndTime().getValue();
47 long halfWindow = (params.getEndTime() - params.getStartTime()) / 2;
48
49 // End of event common to all processes within the trace for this specific request
50 long endOfEvent = params.getEndTime() + halfWindow;
51 if (endOfEvent > endOfTrace) {
52 endOfEvent = endOfTrace;
53 }
54
55 TraceDebug.debug("Number of localProcesses: " + procContainer.readItems().length); //$NON-NLS-1$
56 // to identify the process relevant to the traceState
57 String traceId = traceSt.getTraceId();
58 int numLocalFound = 0;
59 int numLocalNotFound = 0;
60 int numWithNoChildren = 0;
61 for (TimeRangeEventProcess localProcess : procContainer.readItems()) {
62 LttngProcessState stateProcess = lttv_state_find_process(traceSt,
63 localProcess.getCpu(), localProcess.getPid());
64
65 // Drawing the last state for processes related to the current trace
66 // id.
67 if (!localProcess.getTraceID().equals(traceId)) {
68 continue;
69 }
70
71 // Check if the process is in the state provider, it is the case
72 // when the requested time frame did not include any events for a
73 // process
74 if (stateProcess == null) {
75 // Get Start time from the end time of previous event
76 Vector<TimeRangeComponent> childrenEvents = localProcess
77 .getTraceEvents();
78 long nextGoodTime;
79 String stateMode;
80 if (childrenEvents.size() > 0) {
81 TimeRangeComponent prevEvent = childrenEvents
82 .get(childrenEvents.size() - 1);
83 if (prevEvent instanceof TimeRangeEvent) {
84 TimeRangeEvent prevTimeRange = (TimeRangeEvent) prevEvent;
85 // calculate the next good time to draw the event
86 // nextGoodTime = prevTimeRange.getStopTime() + 1;
87 nextGoodTime = localProcess.getNext_good_time();
88 stateMode = prevTimeRange.getStateMode();
89
90 // Draw with the Local information since the current
91 // request did
92 // not contain events related to this process
93 makeDraw(traceSt, nextGoodTime, endOfEvent, localProcess, params, stateMode);
94 } else {
95 TraceDebug.debug("previous event not instance of TimeRangeEvent?: " //$NON-NLS-1$
96 + prevEvent.getClass().getSimpleName());
97 }
98 } else {
99 numWithNoChildren++;
100 }
101
102 numLocalNotFound++;
103 continue;
104 }
105
106 numLocalFound++;
107 // Draw the last state for this process
108 makeDraw(traceSt, endOfEvent, stateProcess, localProcess, params);
109 }
110
111 TraceDebug.debug("Print Last Event: NumLocalFound " + numLocalFound //$NON-NLS-1$
112 + "; NumLocalNotFound: " + numLocalNotFound //$NON-NLS-1$
113 + "; NumWithNoChildren: " + numWithNoChildren); //$NON-NLS-1$
114
115 return false;
116 }
117
118 }
This page took 0.038641 seconds and 5 git commands to generate.