1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
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
9 * Contributors: Alvaro Sanchez-Leon - Initial implementation
10 *******************************************************************************/
11 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.controlflow
.evProcessor
;
13 import java
.util
.Vector
;
15 import org
.eclipse
.linuxtools
.lttng
.state
.StateStrings
.ProcessStatus
;
16 import org
.eclipse
.linuxtools
.lttng
.state
.evProcessor
.ILttngEventProcessor
;
17 import org
.eclipse
.linuxtools
.lttng
.state
.model
.LttngProcessState
;
18 import org
.eclipse
.linuxtools
.lttng
.state
.model
.LttngTraceState
;
19 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.TimeRangeComponent
;
20 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.TimeRangeEvent
;
21 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.TimeRangeEventProcess
;
22 import org
.eclipse
.linuxtools
.lttng
.ui
.model
.trange
.TimeRangeEvent
.Type
;
23 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.common
.AbsTRangeUpdate
;
24 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.common
.ParamsUpdater
;
25 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.controlflow
.model
.FlowModelFactory
;
26 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.controlflow
.model
.FlowProcessContainer
;
28 public abstract class AbsFlowTRangeUpdate
extends AbsTRangeUpdate
implements ILttngEventProcessor
{
30 // ========================================================================
32 // =======================================================================
34 protected FlowProcessContainer procContainer
= FlowModelFactory
.getProcContainer();
35 protected ParamsUpdater params
= FlowModelFactory
.getParamsUpdater();
36 protected static final Long ANY_CPU
= 0L;
39 // ========================================================================
41 // =======================================================================
42 protected TimeRangeEventProcess
addLocalProcess(LttngProcessState stateProcess
, long traceStartTime
, long traceEndTime
, String traceId
) {
43 // TimeRangeEventProcess localProcess = new TimeRangeEventProcess(id, name, startTime, stopTime, groupName, className)
44 TimeRangeEventProcess localProcess
= new TimeRangeEventProcess(
45 procContainer
.getUniqueId(), stateProcess
.getName(),
46 traceStartTime
, traceEndTime
, "", stateProcess
.getType()
47 .getInName(), stateProcess
.getCpu(), stateProcess
48 .getInsertion_time());
51 localProcess
.setCreationTime(stateProcess
.getCreation_time());
52 localProcess
.setPid(stateProcess
.getPid());
53 localProcess
.setTgid(stateProcess
.getTgid());
54 localProcess
.setPpid(stateProcess
.getPpid());
55 localProcess
.setName(stateProcess
.getName());
56 localProcess
.setBrand(stateProcess
.getBrand());
57 localProcess
.setTraceID(traceId
);
58 localProcess
.setProcessType(stateProcess
.getType().getInName());
59 procContainer
.addItem(localProcess
);
64 * Used to check if the event is visible within the current visible time
69 protected boolean withinViewRange(long stime
, long etime
) {
70 long windowStartTime
= params
.getStartTime();
71 long windowEndTime
= params
.getEndTime();
73 // start time is within window
74 if (stime
>= windowStartTime
&& stime
<= windowEndTime
) {
75 // The event or part of it shall be displayed.
79 // end time is within window
80 if (etime
>= windowStartTime
&& etime
<= windowEndTime
) {
81 // The event or part of it shall be displayed.
85 // check that a portion is within the window
86 if (stime
< windowStartTime
&& etime
> windowEndTime
) {
87 // The time range is bigger than the selected time window and
104 protected boolean makeDraw(LttngTraceState traceSt
, long startTime
,
105 long endTime
, TimeRangeEventProcess localProcess
,
106 ParamsUpdater params
, String stateMode
) {
108 // Determine start and end times to establish duration
109 Long stime
= startTime
;
110 Long etime
= endTime
;
113 // Validate the sequential order of events
114 params
.incrementEventsDiscardedWrongOrder();
118 // Store the next good time to start drawing the next event
119 // this is done this early to display an accurate start time of the
121 // within the display window
122 // ****** moved at the end since it produces gaps among the coloured rectangles
123 // localProcess.setNext_good_time(etime);
124 if (!withinViewRange(stime
, etime
)) {
125 // No use to process the event since it's outside
126 // the visible time range of the window
127 params
.incrementEventsDiscarded();
131 // Determine if the time range event will fit it the current
133 double duration
= etime
- stime
;
134 double k
= getPixelsPerNs(traceSt
, params
);
135 double pixels
= duration
* k
;
138 // Display a "more information" indication by allowing non visible event
139 // as long as its previous event is visible.
140 boolean visible
= true;
142 boolean prevEventVisibility
= true;
143 // Get the visibility indication on previous event for
145 Vector
<TimeRangeComponent
> inMemEvents
= localProcess
147 if (inMemEvents
.size() != 0) {
148 TimeRangeComponent prevEvent
= inMemEvents
.get(inMemEvents
150 prevEventVisibility
= prevEvent
.isVisible();
152 // if previous event visibility is false and the time span
153 // between events less than two pixels, there is no need to
154 // load it in memory i.e. not visible and a more indicator is
155 // within two pixels.
156 // return i.e. event discarded to free up memory
157 Long eventSpan
= stime
- prevEvent
.getStartTime();
158 if (prevEventVisibility
== false
159 && ((double) eventSpan
* k
) < 2) {
162 params
.incrementEventsDiscarded();
168 // if previous event is visible, set this one to not
169 // visible and continue
173 // Create the time-range event
174 TimeRangeEvent time_window
= new TimeRangeEvent(stime
, etime
,
175 localProcess
, Type
.PROCESS_MODE
, stateMode
);
177 time_window
.setVisible(visible
);
178 localProcess
.getTraceEvents().add(time_window
);
179 localProcess
.setNext_good_time(etime
);
188 * @param localProcess
192 protected boolean makeDraw(LttngTraceState traceSt
, long evTime
,
193 LttngProcessState process
, TimeRangeEventProcess localProcess
,
194 ParamsUpdater params
) {
196 // TmfTimestamp stime = process.getState().getChange_LttTime();
197 long stime
= localProcess
.getNext_good_time();
200 ProcessStatus procStatus
= process
.getState().getProc_status();
201 // Use Execution mode if process state is RUN otherwise use the actual
203 // this selection will determine the actual color selected for the event
204 if (procStatus
== ProcessStatus
.LTTV_STATE_RUN
) {
205 stateMode
= process
.getState().getExec_mode().getInName();
207 stateMode
= procStatus
.getInName();
210 return makeDraw(traceSt
, stime
, evTime
, localProcess
, params
, stateMode
);