Fix copyright notice
[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.event.LttngEvent;
18 import org.eclipse.linuxtools.lttng.state.StateStrings.Events;
19 import org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor;
20 import org.eclipse.linuxtools.lttng.state.model.LttngProcessState;
21 import org.eclipse.linuxtools.lttng.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 @Override
42 public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
43 // The end of the last state is unknown since it's beyond the requested time range window. Create this last
44 // event to half page after the visible window but not beyond the end of trace
45 long endOfTrace = traceSt.getContext().getTraceTimeWindow().getEndTime().getValue();
46 long halfWindow = (params.getEndTime() - params.getStartTime()) / 2;
47
48 // End of event common to all processes within the trace for this specific request
49 long endOfEvent = params.getEndTime() + halfWindow;
50 if (endOfEvent > endOfTrace) {
51 endOfEvent = endOfTrace;
52 }
53
54 TraceDebug.debug("Number of localProcesses: " + procContainer.readItems().length); //$NON-NLS-1$
55 // to identify the process relevant to the traceState
56 String traceId = traceSt.getTraceId();
57 int numLocalFound = 0;
58 int numLocalNotFound = 0;
59 int numWithNoChildren = 0;
60 for (TimeRangeEventProcess localProcess : procContainer.readItems()) {
61 LttngProcessState stateProcess = lttv_state_find_process(traceSt,
62 localProcess.getCpu(), localProcess.getPid());
63
64 // Drawing the last state for processes related to the current trace
65 // id.
66 if (!localProcess.getTraceID().equals(traceId)) {
67 continue;
68 }
69
70 // Check if the process is in the state provider, it is the case
71 // when the requested time frame did not include any events for a
72 // process
73 if (stateProcess == null) {
74 // Get Start time from the end time of previous event
75 Vector<TimeRangeComponent> childrenEvents = localProcess
76 .getTraceEvents();
77 long nextGoodTime;
78 String stateMode;
79 if (childrenEvents.size() > 0) {
80 TimeRangeComponent prevEvent = childrenEvents
81 .get(childrenEvents.size() - 1);
82 if (prevEvent instanceof TimeRangeEvent) {
83 TimeRangeEvent prevTimeRange = (TimeRangeEvent) prevEvent;
84 // calculate the next good time to draw the event
85 // nextGoodTime = prevTimeRange.getStopTime() + 1;
86 nextGoodTime = localProcess.getNext_good_time();
87 stateMode = prevTimeRange.getStateMode();
88
89 // Draw with the Local information since the current
90 // request did
91 // not contain events related to this process
92 makeDraw(traceSt, nextGoodTime, endOfEvent, localProcess, params, stateMode);
93 } else {
94 TraceDebug.debug("previous event not instance of TimeRangeEvent?: " //$NON-NLS-1$
95 + prevEvent.getClass().getSimpleName());
96 }
97 } else {
98 numWithNoChildren++;
99 }
100
101 numLocalNotFound++;
102 continue;
103 }
104
105 numLocalFound++;
106 // Draw the last state for this process
107 makeDraw(traceSt, endOfEvent, stateProcess, localProcess, params);
108 }
109
110 TraceDebug.debug("Print Last Event: NumLocalFound " + numLocalFound //$NON-NLS-1$
111 + "; NumLocalNotFound: " + numLocalNotFound //$NON-NLS-1$
112 + "; NumWithNoChildren: " + numWithNoChildren); //$NON-NLS-1$
113
114 return false;
115 }
116
117 }
This page took 0.034503 seconds and 6 git commands to generate.