2010-10-26 Francois Chouinard <fchouinard@gmail.com> Contribution for Bug309042
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / resources / evProcessor / ResourcesFinishUpdateHandler.java
1 /*******************************************************************************
2 * Copyright (c) 2009 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 * Alvaro Sanchez-Leon (alvsan09@gmail.com) - Initial API and implementation
11 *******************************************************************************/
12 package org.eclipse.linuxtools.lttng.ui.views.resources.evProcessor;
13
14 import org.eclipse.linuxtools.lttng.event.LttngEvent;
15 import org.eclipse.linuxtools.lttng.state.StateStrings.Events;
16 import org.eclipse.linuxtools.lttng.state.evProcessor.ILttngEventProcessor;
17 import org.eclipse.linuxtools.lttng.state.model.LttngTraceState;
18 import org.eclipse.linuxtools.lttng.ui.TraceDebug;
19 import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventResource;
20
21 /**
22 * Creates specific finish state data request
23 *
24 * @author alvaro
25 *
26 */
27 public class ResourcesFinishUpdateHandler extends
28 AbsResourcesTRangeUpdate
29 implements ILttngEventProcessor {
30
31 public Events getEventHandleType() {
32 // No specific event
33 return null;
34 }
35
36 @Override
37 public boolean process(LttngEvent trcEvent, LttngTraceState traceSt) {
38 // The end of the last state is unknown since it's beyond the requested time range window. Create this last
39 // event to half page after the visible window but not beyond the end of trace
40 long endOfTrace = traceSt.getContext().getTraceTimeWindow().getEndTime().getValue();
41 long halfWindow = (params.getEndTime() - params.getStartTime()) / 2;
42
43 // End of event common to all resources within the trace for this specific request
44 long endOfEvent = params.getEndTime() + halfWindow;
45 if (endOfEvent > endOfTrace) {
46 endOfEvent = endOfTrace;
47 }
48
49 TraceDebug.debug("Number of localResources: "
50 + resContainer.readItems().length);
51
52 // for each existing resource
53 for (TimeRangeEventResource localResource : resContainer
54 .readItems()) {
55
56 // get the start time
57 long stime = localResource.getNext_good_time();
58
59 // Get the resource state mode
60 String stateMode = localResource.getStateMode(traceSt);
61
62 // Insert an instance from previous time to end request time with
63 // the current state
64 makeDraw(traceSt, stime, endOfEvent, localResource, params, stateMode);
65 }
66
67 return false;
68 }
69
70 }
This page took 0.038397 seconds and 5 git commands to generate.