Re-structure LTTng sub-project as per the Linux Tools guidelines
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / controlflow / evProcessor / AbsFlowTRangeUpdate.java
index eeec2ee04390725813c9879f94ddea51f8966e62..3e920c97cf1c723086c1f6b6925368e21b47fc05 100644 (file)
@@ -6,26 +6,29 @@
  * accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
  * 
- * Contributors: Alvaro Sanchez-Leon - Initial implementation
+ * Contributors:
+ *   Alvaro Sanchez-Leon - Initial implementation
+ *   Michel Dagenais (michel.dagenais@polymtl.ca) - Reference C implementation, used with permission
  *******************************************************************************/
 package org.eclipse.linuxtools.lttng.ui.views.controlflow.evProcessor;
 
 import java.util.Vector;
 
-import org.eclipse.linuxtools.lttng.state.StateStrings.ProcessStatus;
-import org.eclipse.linuxtools.lttng.state.evProcessor.IEventProcessing;
-import org.eclipse.linuxtools.lttng.state.model.LttngProcessState;
-import org.eclipse.linuxtools.lttng.state.model.LttngTraceState;
+import org.eclipse.linuxtools.lttng.core.state.StateStrings.ProcessStatus;
+import org.eclipse.linuxtools.lttng.core.state.evProcessor.ILttngEventProcessor;
+import org.eclipse.linuxtools.lttng.core.state.model.LttngProcessState;
+import org.eclipse.linuxtools.lttng.core.state.model.LttngTraceState;
+import org.eclipse.linuxtools.lttng.ui.TraceDebug;
 import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeComponent;
 import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEvent;
-import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventProcess;
 import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEvent.Type;
+import org.eclipse.linuxtools.lttng.ui.model.trange.TimeRangeEventProcess;
 import org.eclipse.linuxtools.lttng.ui.views.common.AbsTRangeUpdate;
 import org.eclipse.linuxtools.lttng.ui.views.common.ParamsUpdater;
 import org.eclipse.linuxtools.lttng.ui.views.controlflow.model.FlowModelFactory;
 import org.eclipse.linuxtools.lttng.ui.views.controlflow.model.FlowProcessContainer;
 
-public abstract class AbsFlowTRangeUpdate extends AbsTRangeUpdate implements IEventProcessing {
+public abstract class AbsFlowTRangeUpdate extends AbsTRangeUpdate implements ILttngEventProcessor {
 
        // ========================================================================
        // Data
@@ -42,11 +45,13 @@ public abstract class AbsFlowTRangeUpdate extends AbsTRangeUpdate implements IEv
        protected TimeRangeEventProcess addLocalProcess(LttngProcessState stateProcess, long traceStartTime, long traceEndTime, String traceId) {
                // TimeRangeEventProcess localProcess = new TimeRangeEventProcess(id, name, startTime, stopTime, groupName, className)
                TimeRangeEventProcess localProcess = new TimeRangeEventProcess(
-                               procContainer.bookProcId(), stateProcess.getName(),
-                               traceStartTime, traceEndTime, "", stateProcess.getType()
+                               procContainer.getUniqueId(), stateProcess.getName(),
+                               traceStartTime, traceEndTime, "", stateProcess.getType() //$NON-NLS-1$
                                                .getInName(), stateProcess.getCpu(), stateProcess
-                                               .getInsertion_time().getValue());
-               localProcess.setCreationTime(stateProcess.getCreation_time().getValue());
+                                               .getInsertion_time());
+               
+               
+               localProcess.setCreationTime(stateProcess.getCreation_time());
                localProcess.setPid(stateProcess.getPid());
                localProcess.setTgid(stateProcess.getTgid());
                localProcess.setPpid(stateProcess.getPpid());
@@ -54,7 +59,12 @@ public abstract class AbsFlowTRangeUpdate extends AbsTRangeUpdate implements IEv
                localProcess.setBrand(stateProcess.getBrand());
                localProcess.setTraceID(traceId);
                localProcess.setProcessType(stateProcess.getType().getInName());
-               procContainer.addProcesse(localProcess);
+               procContainer.addItem(localProcess);
+
+               if (TraceDebug.isCFV()) {
+                       TraceDebug.traceCFV("addLocalProcess():" + localProcess); //$NON-NLS-1$
+               }
+
                return localProcess;
        }
        
@@ -99,25 +109,56 @@ public abstract class AbsFlowTRangeUpdate extends AbsTRangeUpdate implements IEv
         * @param stateMode
         * @return
         */
+       @SuppressWarnings("deprecation")
        protected boolean makeDraw(LttngTraceState traceSt, long startTime,
                        long endTime, TimeRangeEventProcess localProcess,
                        ParamsUpdater params, String stateMode) {
 
+               if (TraceDebug.isCFV()) {
+                       TraceDebug.traceCFV("makeDraw():[" + localProcess + //$NON-NLS-1$ 
+                                       ",candidate=[stime=" + startTime +  //$NON-NLS-1$
+                                       ",etime=" + endTime +  //$NON-NLS-1$
+                                       ",state=" + stateMode + "]]"); //$NON-NLS-1$ //$NON-NLS-2$
+               }
+
                // Determine start and end times to establish duration
                Long stime = startTime;
                Long etime = endTime;
 
+               if (!withinViewRange(stime, etime)) {
+                       // No use to process the event since it's outside
+                       // the visible time range of the window
+                       params.incrementEventsDiscarded(ParamsUpdater.OUT_OF_VIEWRANGE);
+                       return false;
+               }
+
                if (etime < stime) {
                        // Validate the sequential order of events
                        params.incrementEventsDiscardedWrongOrder();
                        return false;
                }
 
-               if (!withinViewRange(stime, etime)) {
-                       // No use to process the event since it's outside
-                       // the visible time range of the window
-                       params.incrementEventsDiscarded();
-                       return false;
+               // Store the next good time to start drawing the next event
+               // this is done this early to display an accurate start time of the
+               // first event
+               // within the display window
+               // ****** moved at the end since it produces gaps among the coloured rectangles
+               // localProcess.setNext_good_time(etime);
+
+               // If First event of a process, initialise start time half page before to enable pagination to the left
+               if (stime < params.getStartTime()) {
+                       // event start time is before the visible time window
+                       long insertion = localProcess.getInsertionTime();
+                       if (stime.longValue() == insertion) {
+                               // if start time is equal to insertion this is the first event to be drawn for this process
+                               long halfPage = (params.getEndTime() - params.getStartTime()) / 2;
+                               long initTime = params.getStartTime() - halfPage;
+                               if (initTime > insertion) {
+                                       // start time of this event is unknown, place it half page before visible window to allow left side
+                                       // pagination when selecting previous event
+                                       stime = initTime;
+                               }
+                       }
                }
 
                // Determine if the time range event will fit it the current
@@ -126,15 +167,11 @@ public abstract class AbsFlowTRangeUpdate extends AbsTRangeUpdate implements IEv
                double k = getPixelsPerNs(traceSt, params);
                double pixels = duration * k;
 
-               // ***VERIFY***
-               // Is all this equivalent to this call in C??
-               // if(ltt_time_compare(hashed_process_data->next_good_time,evtime) > 0)
-               // ***
                // Visibility check
                // Display a "more information" indication by allowing non visible event
                // as long as its previous event is visible.
                boolean visible = true;
-               if (pixels < 1) {
+               if (pixels < 1.0) {
                        boolean prevEventVisibility = true;
                        // Get the visibility indication on previous event for
                        // this process
@@ -145,12 +182,6 @@ public abstract class AbsFlowTRangeUpdate extends AbsTRangeUpdate implements IEv
                                                .size() - 1);
                                prevEventVisibility = prevEvent.isVisible();
 
-                               // ***VERIFY***
-                               // This replace all C Call like this one ?
-                               // #ifdef EXTRA_CHECK if(ltt_time_compare(evtime,
-                               // time_window.start_time) == -1 || ltt_time_compare(evtime,
-                               // time_window.end_time) == 1)
-
                                // if previous event visibility is false and the time span
                                // between events less than two pixels, there is no need to
                                // load it in memory i.e. not visible and a more indicator is
@@ -158,10 +189,10 @@ public abstract class AbsFlowTRangeUpdate extends AbsTRangeUpdate implements IEv
                                // return i.e. event discarded to free up memory
                                Long eventSpan = stime - prevEvent.getStartTime();
                                if (prevEventVisibility == false
-                                               && ((double) eventSpan * k) < 2) {
+                                               && ((double) eventSpan * k) < 2.0) {
 
                                        // discard the item
-                                       params.incrementEventsDiscarded();
+                                       params.incrementEventsDiscarded(ParamsUpdater.NOT_VISIBLE);
                                        return false;
 
                                }
@@ -173,26 +204,13 @@ public abstract class AbsFlowTRangeUpdate extends AbsTRangeUpdate implements IEv
                }
 
                // Create the time-range event
-               // *** VERIFY ***
-               // This should replace this C call, right?
-               // TimeWindow time_window =
-               // lttvwindow_get_time_window(control_flow_data->tab);
                TimeRangeEvent time_window = new TimeRangeEvent(stime, etime,
                                localProcess, Type.PROCESS_MODE, stateMode);
 
-               // *** VERIFY ***
-               // This is added to replace the multiple draw and gtk/glib command but
-               // I'm not sure about it
                time_window.setVisible(visible);
                localProcess.getTraceEvents().add(time_window);
                localProcess.setNext_good_time(etime);
 
-               // *** VERIFY ***
-               // Missing checks like this one?
-               // #ifdef EXTRA_CHECK if(ltt_time_compare(evtime,
-               // time_window.start_time) == -1 || ltt_time_compare(evtime,
-               // time_window.end_time) == 1)
-
                return false;
        }
 
This page took 0.026123 seconds and 5 git commands to generate.