Timeline : bug fix timeline chart redrawing and apply DB to ScreenshotView 31/26731/1
authorjungwook.ryu <jungwook.ryu@samsung.com>
Thu, 28 Aug 2014 11:07:24 +0000 (20:07 +0900)
committerjungwook.ryu <jungwook.ryu@samsung.com>
Thu, 28 Aug 2014 11:21:19 +0000 (20:21 +0900)
Change-Id: Ie5a519b0060093004b2cfb38b0f26a13b93d8e14
Signed-off-by: jungwook.ryu <jungwook.ryu@samsung.com>
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/screenshot/ScreenshotView.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/common/TimelineChartManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/common/TimelineView.java

index 5ca618e..a89a52e 100644 (file)
@@ -49,18 +49,17 @@ import org.eclipse.swt.widgets.Event;
 import org.eclipse.swt.widgets.Listener;
 import org.tizen.dynamicanalyzer.common.AnalyzerManager;
 import org.tizen.dynamicanalyzer.common.DASelectionData;
-import org.tizen.dynamicanalyzer.constant.CommonConstants;
 import org.tizen.dynamicanalyzer.nl.InformationViewLabels;
 import org.tizen.dynamicanalyzer.project.Project;
 import org.tizen.dynamicanalyzer.resources.ColorResources;
 import org.tizen.dynamicanalyzer.resources.FontResources;
 import org.tizen.dynamicanalyzer.resources.ImageResources;
-import org.tizen.dynamicanalyzer.sql.SqlManager;
 import org.tizen.dynamicanalyzer.swap.logparser.DataManagerRegistry;
 import org.tizen.dynamicanalyzer.swap.model.data.LogData;
-import org.tizen.dynamicanalyzer.swap.model.data.SystemData;
 import org.tizen.dynamicanalyzer.ui.opengl.GLPage;
 import org.tizen.dynamicanalyzer.ui.page.ScreenshotTabComposite;
+import org.tizen.dynamicanalyzer.ui.timeline.SystemDataDBTable;
+import org.tizen.dynamicanalyzer.ui.timeline.common.TimelineChartManager;
 import org.tizen.dynamicanalyzer.ui.toolbar.ToolbarArea;
 import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
 import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;
@@ -280,21 +279,20 @@ public class ScreenshotView extends DAViewComposite {
        }
 
        private void computeData() {
-               LogData input = SqlManager.getInstance().getCpuRates(startTime, 1);
-               if (null == input) {
-                       input = SqlManager.getInstance().getCpuRates(startTime, 2);
-                       if (null == input) {
-                               return;
-                       }
+               List<Object> row = TimelineChartManager.getInstance().getSystemDataFromDB(startTime);
+               if (row.isEmpty()) {
+                       return;
                }
-               String[] cpuRates = ((SystemData) input).getCpuLoad().split(CommonConstants.COMMA);
-               cpuUsage.clear();
-               for (int i = 0; i < cpuRates.length; i++) {
-                       String cpu = cpuRates[i].trim();
-                       long value = (long) Float.parseFloat(cpu);
+       
+               @SuppressWarnings("unchecked")
+               List<Object> cpuLoadList = (List<Object>) row.get(SystemDataDBTable.COLUMN.CPU_LOAD
+                               .ordinal());
+               for (int ii = 0; ii < cpuLoadList.size(); ii++) {
+                       double cpu = (Double)cpuLoadList.get(ii);
+                       long value = (long)cpu;
                        cpuUsage.add(value);
                }
-
+               
                long totalMem = AnalyzerManager.getProject().getDeviceStatusInfo().getSystemMemorySize();
                maxMem = totalMem;
 
index 6bf4c06..3d5cf5a 100644 (file)
@@ -671,6 +671,23 @@ public class TimelineChartManager extends PageDataManager implements IDAChartSer
                        return new ArrayList<List<Object>>();
                }
        }
+       
+       public List<Object> getSystemDataFromDB(long time) {
+               String where = "where TIME = (SELECT MAX(TIME) FROM TIMELINE_SYSTEM_DATA WHERE TIME <= " + time + ")";
+               List<List<Object>> result = systemDataTable.selectData(null, where);
+               
+               if (result == null || result.isEmpty()) {
+                       where = "where TIME = (SELECT MIN(time) FROM TIMELINE_SYSTEM_DATA)";
+                       result = systemDataTable.selectData(null, where);
+                       if (result == null || result.isEmpty()) {
+                               return new ArrayList<Object>();
+                       } else {
+                               return result.get(0);
+                       }
+               } else {
+                       return result.get(0);
+               }
+       }
 
        public List<List<Object>> getUIEventDataFromDB(long start, long end) {
                String where = "where TIME BETWEEN " + start + " AND " + end + " ORDER BY " + UIEventDBTable.TIME;
index 0ac3125..bf9a5ac 100644 (file)
@@ -140,9 +140,6 @@ public class TimelineView extends DAViewComposite {
        @Override
        public void updateView(DAViewData data) {
                if (data instanceof DASelectionData) {
-                       timelineChartManager.makeChartSeries(AnalyzerUtil.translateSecToMicroSec(chartBoard.getVisibleStartTime()), 
-                                       AnalyzerUtil.translateSecToMicroSec(chartBoard.getVisibleEndTime()));
-                       
                        DASelectionData selData = (DASelectionData) data;
 
                        long start = selData.getStartTime();
@@ -159,6 +156,9 @@ public class TimelineView extends DAViewComposite {
                        DAChartPlotIntervalMarker intervalMarker = (DAChartPlotIntervalMarker) chartBoard
                                        .getMarkers().get(UICommonConstants.SELECTION_MARKER_INDEX);
                        intervalMarker.setInterval(startTime, endTime);
+                       
+                       timelineChartManager.makeChartSeries(AnalyzerUtil.translateSecToMicroSec(chartBoard.getVisibleStartTime()), 
+                                       AnalyzerUtil.translateSecToMicroSec(chartBoard.getVisibleEndTime()));
                }
        }