c441c5d0f14637a3f294013d42de738a64811c67
[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: Alvaro Sanchez-Leon - Initial implementation
10 *******************************************************************************/
11 package org.eclipse.linuxtools.lttng.ui.views.controlflow.evProcessor;
12
13 import java.util.Vector;
14
15 import org.eclipse.linuxtools.lttng.event.LttngEvent;
16 import org.eclipse.linuxtools.lttng.state.StateStrings.Events;
17 import org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor;
18 import org.eclipse.linuxtools.lttng.state.model.LttngProcessState;
19 import org.eclipse.linuxtools.lttng.state.model.LttngTraceState;
20 import org.eclipse.linuxtools.lttng.ui.TraceDebug;
21 import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeComponent;
22 import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEvent;
23 import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventProcess;
24
25 /**
26 * Creates specific finish state data request
27 *
28 * @author alvaro
29 *
30 */
31 public class FlowFinishUpdateHandler extends AbsFlowTRangeUpdate
32 implements ILttngEventProcessor {
33
34 public Events getEventHandleType() {
35 // No specific event
36 return null;
37 }
38
39 public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
40 // Draw a last known state to the end of the trace
41 long endReqTime = traceSt.getContext().getTraceTimeWindow()
42 .getEndTime().getValue();
43 TraceDebug.debug("Number of localProcesses: "
44 + procContainer.readItems().length);
45 // to identify the process relevant to the traceState
46 String traceId = traceSt.getTraceId();
47 int numLocalFound = 0;
48 int numLocalNotFound = 0;
49 int numWithNoChildren = 0;
50 for (TimeRangeEventProcess localProcess : procContainer.readItems()) {
51 LttngProcessState stateProcess = lttv_state_find_process(traceSt,
52 localProcess.getCpu(), localProcess.getPid());
53
54 // Drawing the last state for processes related to the current trace
55 // id.
56 if (!localProcess.getTraceID().equals(traceId)) {
57 continue;
58 }
59
60 // Check if the process is in the state provider, it is the case
61 // when the requested time frame did not include any events for a
62 // process
63 if (stateProcess == null) {
64 // Get Start time from the end time of previous event
65 Vector<TimeRangeComponent> childrenEvents = localProcess
66 .getTraceEvents();
67 long nextGoodTime;
68 String stateMode;
69 if (childrenEvents.size() > 0) {
70 TimeRangeComponent prevEvent = childrenEvents
71 .get(childrenEvents.size() - 1);
72 if (prevEvent instanceof TimeRangeEvent) {
73 TimeRangeEvent prevTimeRange = (TimeRangeEvent) prevEvent;
74 // calculate the next good time to draw the event
75 // nextGoodTime = prevTimeRange.getStopTime() + 1;
76 nextGoodTime = localProcess.getNext_good_time();
77 stateMode = prevTimeRange.getStateMode();
78
79 // Draw with the Local information since the current
80 // request did
81 // not contain events related to this process
82 makeDraw(traceSt, nextGoodTime,
83 endReqTime, localProcess, params, stateMode);
84 } else {
85 TraceDebug
86 .debug("previous event not instance of TimeRangeEvent?: "
87 + prevEvent.getClass().getSimpleName());
88 }
89 } else {
90 numWithNoChildren++;
91 }
92
93 numLocalNotFound++;
94 continue;
95 }
96 numLocalFound++;
97 // Draw the last state for this process
98
99 makeDraw(traceSt, endReqTime, stateProcess, localProcess, params);
100 }
101
102 TraceDebug.debug("Print Last Event: NumLocalFound " + numLocalFound
103 + "; NumLocalNotFound: " + numLocalNotFound
104 + "; NumWithNoChildren: " + numWithNoChildren);
105
106 return false;
107 }
108
109 }
This page took 0.032528 seconds and 4 git commands to generate.