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
.IEventProcessing
;
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 IEventProcessing
{
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
.bookProcId(), stateProcess
.getName(),
46 traceStartTime
, traceEndTime
, "", stateProcess
.getType()
47 .getInName(), stateProcess
.getCpu(), stateProcess
48 .getInsertion_time().getValue());
49 localProcess
.setCreationTime(stateProcess
.getCreation_time().getValue());
50 localProcess
.setPid(stateProcess
.getPid());
51 localProcess
.setTgid(stateProcess
.getTgid());
52 localProcess
.setPpid(stateProcess
.getPpid());
53 localProcess
.setName(stateProcess
.getName());
54 localProcess
.setBrand(stateProcess
.getBrand());
55 localProcess
.setTraceID(traceId
);
56 localProcess
.setProcessType(stateProcess
.getType().getInName());
57 procContainer
.addProcesse(localProcess
);
62 * Used to check if the event is visible within the current visible time
67 protected boolean withinViewRange(long stime
, long etime
) {
68 long windowStartTime
= params
.getStartTime();
69 long windowEndTime
= params
.getEndTime();
71 // start time is within window
72 if (stime
>= windowStartTime
&& stime
<= windowEndTime
) {
73 // The event or part of it shall be displayed.
77 // end time is within window
78 if (etime
>= windowStartTime
&& etime
<= windowEndTime
) {
79 // The event or part of it shall be displayed.
83 // check that a portion is within the window
84 if (stime
< windowStartTime
&& etime
> windowEndTime
) {
85 // The time range is bigger than the selected time window and
102 protected boolean makeDraw(LttngTraceState traceSt
, long startTime
,
103 long endTime
, TimeRangeEventProcess localProcess
,
104 ParamsUpdater params
, String stateMode
) {
106 // Determine start and end times to establish duration
107 Long stime
= startTime
;
108 Long etime
= endTime
;
111 // Validate the sequential order of events
112 params
.incrementEventsDiscardedWrongOrder();
116 if (!withinViewRange(stime
, etime
)) {
117 // No use to process the event since it's outside
118 // the visible time range of the window
119 params
.incrementEventsDiscarded();
123 // Determine if the time range event will fit it the current
125 double duration
= etime
- stime
;
126 double k
= getPixelsPerNs(traceSt
, params
);
127 double pixels
= duration
* k
;
130 // Is all this equivalent to this call in C??
131 // if(ltt_time_compare(hashed_process_data->next_good_time,evtime) > 0)
134 // Display a "more information" indication by allowing non visible event
135 // as long as its previous event is visible.
136 boolean visible
= true;
138 boolean prevEventVisibility
= true;
139 // Get the visibility indication on previous event for
141 Vector
<TimeRangeComponent
> inMemEvents
= localProcess
143 if (inMemEvents
.size() != 0) {
144 TimeRangeComponent prevEvent
= inMemEvents
.get(inMemEvents
146 prevEventVisibility
= prevEvent
.isVisible();
149 // This replace all C Call like this one ?
150 // #ifdef EXTRA_CHECK if(ltt_time_compare(evtime,
151 // time_window.start_time) == -1 || ltt_time_compare(evtime,
152 // time_window.end_time) == 1)
154 // if previous event visibility is false and the time span
155 // between events less than two pixels, there is no need to
156 // load it in memory i.e. not visible and a more indicator is
157 // within two pixels.
158 // return i.e. event discarded to free up memory
159 Long eventSpan
= stime
- prevEvent
.getStartTime();
160 if (prevEventVisibility
== false
161 && ((double) eventSpan
* k
) < 2) {
164 params
.incrementEventsDiscarded();
170 // if previous event is visible, set this one to not
171 // visible and continue
175 // Create the time-range event
177 // This should replace this C call, right?
178 // TimeWindow time_window =
179 // lttvwindow_get_time_window(control_flow_data->tab);
180 TimeRangeEvent time_window
= new TimeRangeEvent(stime
, etime
,
181 localProcess
, Type
.PROCESS_MODE
, stateMode
);
184 // This is added to replace the multiple draw and gtk/glib command but
185 // I'm not sure about it
186 time_window
.setVisible(visible
);
187 localProcess
.getTraceEvents().add(time_window
);
188 localProcess
.setNext_good_time(etime
);
191 // Missing checks like this one?
192 // #ifdef EXTRA_CHECK if(ltt_time_compare(evtime,
193 // time_window.start_time) == -1 || ltt_time_compare(evtime,
194 // time_window.end_time) == 1)
203 * @param localProcess
207 protected boolean makeDraw(LttngTraceState traceSt
, long evTime
,
208 LttngProcessState process
, TimeRangeEventProcess localProcess
,
209 ParamsUpdater params
) {
211 // TmfTimestamp stime = process.getState().getChange_LttTime();
212 long stime
= localProcess
.getNext_good_time();
215 ProcessStatus procStatus
= process
.getState().getProc_status();
216 // Use Execution mode if process state is RUN otherwise use the actual
218 // this selection will determine the actual color selected for the event
219 if (procStatus
== ProcessStatus
.LTTV_STATE_RUN
) {
220 stateMode
= process
.getState().getExec_mode().getInName();
222 stateMode
= procStatus
.getInName();
225 return makeDraw(traceSt
, stime
, evTime
, localProcess
, params
, stateMode
);