Search in sources :

Example 41 with TraceDirectoryResult

use of com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult in project VideoOptimzer by attdevsupport.

the class TemperaturePlot method populate.

@Override
public void populate(XYPlot plot, AROTraceData analysis) {
    XYSeries series = new XYSeries(0);
    XYIntervalSeriesCollection thermalDataSeries = new XYIntervalSeriesCollection();
    if (analysis == null) {
        LOGGER.info("analysis data is null");
    } else {
        TraceResultType resultType = analysis.getAnalyzerResult().getTraceresult().getTraceResultType();
        if (resultType.equals(TraceResultType.TRACE_FILE)) {
            LOGGER.info("didn't get analysis trace data!");
        } else {
            TraceDirectoryResult traceresult = (TraceDirectoryResult) analysis.getAnalyzerResult().getTraceresult();
            AnalysisFilter filter = analysis.getAnalyzerResult().getFilter();
            temperatureInfos = traceresult.getTemperatureInfos();
            thermalStatusInfos = traceresult.getThermalstatusInfos();
            NumberAxis axis = new NumberAxis();
            axis.setAutoRange(true);
            // Calculate max and min temperature
            List<Integer> tempLists = new ArrayList<>();
            if (CollectionUtils.isNotEmpty(temperatureInfos)) {
                for (TemperatureEvent bi : temperatureInfos) {
                    series.add(bi.getTimeRecorded(), bi.getcelciusTemperature());
                    tempLists.add(bi.getcelciusTemperature());
                }
                TemperatureEvent last = temperatureInfos.get(temperatureInfos.size() - 1);
                if (filter.getTimeRange() != null) {
                    series.add(filter.getTimeRange().getEndTime().doubleValue(), last.getcelciusTemperature());
                } else {
                    series.add(traceresult.getTraceDuration(), last.getcelciusTemperature());
                }
                XYItemRenderer renderer = plot.getRenderer(0);
                renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {

                    @Override
                    public String generateToolTip(XYDataset dataset, int series, int item) {
                        return toolTipContent(item);
                    }
                });
                Collections.sort(tempLists);
                axis.setRange(Math.round(tempLists.get(0) / 1.2), Math.round(tempLists.get(tempLists.size() - 1) * 1.2));
                axis.setAutoRange(false);
                plot.setRenderer(0, renderer);
            }
            if (CollectionUtils.isNotEmpty(thermalStatusInfos)) {
                Map<ThermalStatus, XYIntervalSeries> seriesMap = new EnumMap<ThermalStatus, XYIntervalSeries>(ThermalStatus.class);
                for (ThermalStatus tstatus : ThermalStatus.values()) {
                    XYIntervalSeries series2 = new XYIntervalSeries(tstatus);
                    seriesMap.put(tstatus, series2);
                    thermalDataSeries.addSeries(series2);
                }
                Iterator<ThermalStatusInfo> iter = thermalStatusInfos.iterator();
                if (iter.hasNext()) {
                    while (iter.hasNext()) {
                        ThermalStatusInfo info = iter.next();
                        seriesMap.get(info.getThermalStatus()).add(info.getBeginTimeStamp(), info.getBeginTimeStamp(), info.getEndTimeStamp(), 0.5, 0, 100);
                    }
                }
                XYBarRenderer barRenderer = new XYBarRenderer();
                barRenderer.setDrawBarOutline(false);
                barRenderer.setUseYInterval(true);
                barRenderer.setAutoPopulateSeriesPaint(false);
                barRenderer.setShadowVisible(false);
                barRenderer.setGradientPaintTransformer(null);
                barRenderer.setBarPainter(new StandardXYBarPainter());
                setRenderingColorForDataSeries(barRenderer, thermalDataSeries);
                barRenderer.setBaseToolTipGenerator(new XYToolTipGenerator() {

                    @Override
                    public String generateToolTip(XYDataset dataset, int series, int item) {
                        ThermalStatus info = (ThermalStatus) thermalDataSeries.getSeries(series).getKey();
                        return MessageFormat.format(ResourceBundleHelper.getMessageString("network.tooltip"), dataset.getX(series, item), ResourceBundleHelper.getEnumString(info));
                    }
                });
                plot.setRenderer(1, barRenderer);
                plot.setRangeAxis(axis);
            }
        }
        plot.setDataset(0, new XYSeriesCollection(series));
        plot.setDataset(1, thermalDataSeries);
    }
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) NumberAxis(org.jfree.chart.axis.NumberAxis) AnalysisFilter(com.att.aro.core.packetanalysis.pojo.AnalysisFilter) ArrayList(java.util.ArrayList) XYIntervalSeriesCollection(org.jfree.data.xy.XYIntervalSeriesCollection) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) EnumMap(java.util.EnumMap) StandardXYBarPainter(org.jfree.chart.renderer.xy.StandardXYBarPainter) XYBarRenderer(org.jfree.chart.renderer.xy.XYBarRenderer) TemperatureEvent(com.att.aro.core.peripheral.pojo.TemperatureEvent) ThermalStatus(com.att.aro.core.peripheral.pojo.ThermalStatus) ThermalStatusInfo(com.att.aro.core.peripheral.pojo.ThermalStatusInfo) TraceResultType(com.att.aro.core.packetanalysis.pojo.TraceResultType) XYIntervalSeries(org.jfree.data.xy.XYIntervalSeries) XYDataset(org.jfree.data.xy.XYDataset) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection)

Example 42 with TraceDirectoryResult

use of com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult in project VideoOptimzer by attdevsupport.

the class CpuPlot method populate.

@Override
public void populate(XYPlot plot, AROTraceData analysis) {
    XYSeries series = new XYSeries(0);
    if (analysis == null) {
        LOGGER.info("didn't get analysis trace data!");
    } else {
        TraceResultType resultType = analysis.getAnalyzerResult().getTraceresult().getTraceResultType();
        if (resultType.equals(TraceResultType.TRACE_FILE)) {
            LOGGER.info("didn't get analysis trace folder!");
        } else {
            TraceDirectoryResult traceresult = (TraceDirectoryResult) analysis.getAnalyzerResult().getTraceresult();
            cpuAList = traceresult.getCpuActivityList();
            boolean filterByTime = cpuAList.isFilterByTime();
            double beginTime = 0;
            double endTime = 0;
            if (filterByTime) {
                beginTime = cpuAList.getBeginTraceTime();
                endTime = cpuAList.getEndTraceTime();
            }
            cpuData = cpuAList.getCpuActivities();
            LOGGER.debug("Size of CPU data: " + cpuData.size());
            if (cpuData.size() > 0) {
                for (CpuActivity cpu : cpuData) {
                    if (filterByTime) {
                        // logger.debug("timestamp: {0}" + cpu.getTimeStamp());
                        if (cpu.getTimeStamp() >= beginTime && cpu.getTimeStamp() <= endTime) {
                            // logger.debug("CPU usage: {0}"+ cpu.getCpuUsageTotalFiltered());
                            series.add(cpu.getTimeStamp(), cpu.getCpuUsageTotalFiltered());
                        }
                    } else {
                        // logger.debug("CPU usage: {0}"+ cpu.getCpuUsageTotalFiltered());
                        series.add(cpu.getTimeStamp(), cpu.getCpuUsageTotalFiltered());
                    }
                }
            }
            // Assign ToolTip to renderer
            XYItemRenderer renderer = plot.getRenderer();
            renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {

                @Override
                public String generateToolTip(XYDataset dataset, int series, int item) {
                    return constructCpuToolTipText(cpuAList, cpuData, item);
                }
            });
        }
    }
    plot.setDataset(new XYSeriesCollection(series));
// return plot;
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) TraceResultType(com.att.aro.core.packetanalysis.pojo.TraceResultType) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) XYDataset(org.jfree.data.xy.XYDataset) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator) XYSeriesCollection(org.jfree.data.xy.XYSeriesCollection) CpuActivity(com.att.aro.core.peripheral.pojo.CpuActivity)

Example 43 with TraceDirectoryResult

use of com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult in project VideoOptimzer by attdevsupport.

the class ScreenStatePlot method populate.

@Override
public void populate(XYPlot plot, AROTraceData analysis) {
    if (analysis == null) {
        LOGGER.info("analysis data is null");
    } else {
        screenData.removeAllSeries();
        TraceResultType resultType = analysis.getAnalyzerResult().getTraceresult().getTraceResultType();
        if (resultType.equals(TraceResultType.TRACE_FILE)) {
            LOGGER.info("didn't get analysis trace data!");
        } else {
            TraceDirectoryResult traceresult = (TraceDirectoryResult) analysis.getAnalyzerResult().getTraceresult();
            XYIntervalSeries series = new XYIntervalSeries(ScreenState.SCREEN_ON);
            screenData.addSeries(series);
            // Populate the data set
            final Map<Double, ScreenStateInfo> dataMap = new HashMap<Double, ScreenStateInfo>();
            Iterator<ScreenStateInfo> iter = traceresult.getScreenStateInfos().iterator();
            if (iter.hasNext()) {
                while (iter.hasNext()) {
                    ScreenStateInfo screenEvent = iter.next();
                    if (screenEvent.getScreenState() == ScreenState.SCREEN_ON) {
                        series.add(screenEvent.getBeginTimeStamp(), screenEvent.getBeginTimeStamp(), screenEvent.getEndTimeStamp(), 0.5, 0, 1);
                        dataMap.put(screenEvent.getBeginTimeStamp(), screenEvent);
                    }
                }
            }
            // Assign ToolTip to renderer
            XYItemRenderer renderer = plot.getRenderer();
            renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {

                @Override
                public String generateToolTip(XYDataset dataset, int series, int item) {
                    ScreenStateInfo si = dataMap.get(dataset.getXValue(series, item));
                    if (si != null) {
                        StringBuffer displayInfo = new StringBuffer(ResourceBundleHelper.getMessageString("screenstate.tooltip.prefix"));
                        int timeout = si.getScreenTimeout();
                        displayInfo.append(MessageFormat.format(ResourceBundleHelper.getMessageString("screenstate.tooltip.content"), ResourceBundleHelper.getEnumString(si.getScreenState()), si.getScreenBrightness(), timeout > 0 ? timeout : ResourceBundleHelper.getMessageString("screenstate.noTimeout")));
                        displayInfo.append(ResourceBundleHelper.getMessageString("screenstate.tooltip.suffix"));
                        return displayInfo.toString();
                    }
                    return null;
                }
            });
        }
    }
    plot.setDataset(screenData);
// return plot;
}
Also used : HashMap(java.util.HashMap) ScreenStateInfo(com.att.aro.core.peripheral.pojo.ScreenStateInfo) TraceResultType(com.att.aro.core.packetanalysis.pojo.TraceResultType) XYIntervalSeries(org.jfree.data.xy.XYIntervalSeries) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) XYDataset(org.jfree.data.xy.XYDataset) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator)

Example 44 with TraceDirectoryResult

use of com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult in project VideoOptimzer by attdevsupport.

the class TraceDataReaderImpl method readTimeAndPcap.

/**
 * Reads the PCAP file and the trace times from the time trace file.
 *
 * @throws IOException
 */
private TraceDirectoryResult readTimeAndPcap(TraceDirectoryResult dresult) throws IOException {
    TraceDirectoryResult result = dresult;
    String filepath = result.getTraceDirectory() + Util.FILE_SEPARATOR + TraceDataConst.FileName.TIME_FILE;
    Double startTime = null;
    Double duration = null;
    if (filereader.fileExist(filepath)) {
        TraceTime times = readTimes(result);
        startTime = times.getStartTime();
        if (times.getEventTime() != null) {
            result.setEventTime0(times.getEventTime());
        }
        if (times.getTimezoneOffset() != null) {
            result.setCaptureOffset(times.getTimezoneOffset());
        }
        duration = times.getDuration();
    }
    // Read the pcap files to get default times
    List<Integer> appIds = readAppIDs(result);
    result.setAppIds(appIds);
    result.setTotalNoPackets(appIds.size());
    if (dresult.getTraceFile() != null && !dresult.getTraceFile().equals("")) {
        filepath = result.getTraceFile();
    } else {
        filepath = result.getTraceDirectory() + Util.FILE_SEPARATOR + TraceDataConst.FileName.TRAFFIC + TraceDataConst.FileName.CAP_EXT;
    }
    this.init();
    this.ipCountMap = result.getIpCountMap();
    result = (TraceDirectoryResult) this.readPcapTraceFile(filepath, startTime, duration, result);
    if (result == null) {
        return new TraceDirectoryResult();
    }
    for (int i = 1; ; i++) {
        filepath = result.getTraceDirectory() + Util.FILE_SEPARATOR + TraceDataConst.FileName.TRAFFIC + i + TraceDataConst.FileName.CAP_EXT;
        if (filereader.fileExist(filepath)) {
            result = (TraceDirectoryResult) this.readPcapTraceFile(filepath, startTime, duration, result);
        } else {
            break;
        }
    }
    if (result != null) {
        String secureFilePath = result.getTraceDirectory() + Util.FILE_SEPARATOR + TraceDataConst.FileName.SECURE_PCAP_FILE;
        if (filereader.fileExist(secureFilePath)) {
            try {
                isSecurePcap = true;
                result.setSecureTrace(isSecurePcap);
                this.readSecurePcapTraceFile(secureFilePath, result);
            } finally {
                isSecurePcap = false;
            }
        }
    }
    if (result == null) {
        result = new TraceDirectoryResult();
    }
    result.setAllpackets(this.allPackets);
    this.checkExternalVideoAndTime(result, startTime, duration);
    return result;
}
Also used : TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) TraceTime(com.att.aro.core.packetanalysis.pojo.TraceTime)

Example 45 with TraceDirectoryResult

use of com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult in project VideoOptimzer by attdevsupport.

the class MissingTraceFiles method retrieveMissingFiles.

public Set<File> retrieveMissingFiles() {
    Set<File> missingFiles = new LinkedHashSet<File>();
    addMissingFileMaybe(TraceDataConst.FileName.APPNAME_FILE, missingFiles);
    addMissingFileMaybe(TraceDataConst.FileName.DEVICEINFO_FILE, missingFiles);
    addMissingFileMaybe(TraceDataConst.FileName.DEVICEDETAILS_FILE, missingFiles);
    // addMissingFileMaybe(TraceDataConst.FileName.NETWORKINFO_FILE, missingFiles);
    addMissingFileMaybe(TraceDataConst.FileName.CPU_FILE, missingFiles);
    addMissingFileMaybe(TraceDataConst.FileName.GPS_FILE, missingFiles);
    addMissingFileMaybe(TraceDataConst.FileName.BLUETOOTH_FILE, missingFiles);
    addMissingFileMaybe(TraceDataConst.FileName.WIFI_FILE, missingFiles);
    addMissingFileMaybe(TraceDataConst.FileName.CAMERA_FILE, missingFiles);
    addMissingFileMaybe(TraceDataConst.FileName.SCREEN_STATE_FILE, missingFiles);
    addMissingFileMaybe(TraceDataConst.FileName.USER_EVENTS_FILE, missingFiles);
    // addMissingFileMaybe(TraceDataConst.FileName.SCREEN_ROTATIONS_FILE, missingFiles);
    addMissingFileMaybe(TraceDataConst.FileName.ALARM_END_FILE, missingFiles);
    addMissingFileMaybe(TraceDataConst.FileName.ALARM_START_FILE, missingFiles);
    addMissingFileMaybe(TraceDataConst.FileName.KERNEL_LOG_FILE, missingFiles);
    addMissingFileMaybe(TraceDataConst.FileName.BATTERY_FILE, missingFiles);
    addMissingFileMaybe(TraceDataConst.FileName.BATTERYINFO_FILE, missingFiles);
    addMissingFileMaybe(TraceDataConst.FileName.TEMPERATURE_FILE, missingFiles);
    addMissingFileMaybe(TraceDataConst.FileName.LOCATION_FILE, missingFiles);
    addMissingFileMaybe(TraceDataConst.FileName.RADIO_EVENTS_FILE, missingFiles);
    if (isFilePresent(ResourceBundleHelper.getMessageString("video.videoDisplayFile")) || isFilePresent(ResourceBundleHelper.getMessageString("video.videoFileOnDevice"))) {
        addMissingFileMaybe(TraceDataConst.FileName.VIDEO_TIME_FILE, missingFiles);
    }
    if (isFilePresent(ResourceBundleHelper.getMessageString("video.exVideoDisplayFile")) || isExternalVideoSourceFilePresent("video.mp4", "video.mov")) {
        addMissingFileMaybe(TraceDataConst.FileName.EXVIDEO_TIME_FILE, missingFiles);
    }
    // UI shoule not be doing this!!!
    if (model != null) {
        AbstractTraceResult traceResult = model.getAnalyzerResult().getTraceresult();
        if (traceResult instanceof TraceDirectoryResult) {
            ((TraceDirectoryResult) traceResult).setMissingFiles(getModelMissingFiles(missingFiles));
        }
    }
    return missingFiles;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) AbstractTraceResult(com.att.aro.core.packetanalysis.pojo.AbstractTraceResult) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) File(java.io.File)

Aggregations

TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)51 ArrayList (java.util.ArrayList)16 BaseTest (com.att.aro.core.BaseTest)14 Test (org.junit.Test)14 TraceResultType (com.att.aro.core.packetanalysis.pojo.TraceResultType)13 XYToolTipGenerator (org.jfree.chart.labels.XYToolTipGenerator)10 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)10 XYDataset (org.jfree.data.xy.XYDataset)10 Session (com.att.aro.core.packetanalysis.pojo.Session)9 PacketAnalyzerResult (com.att.aro.core.packetanalysis.pojo.PacketAnalyzerResult)8 CollectOptions (com.att.aro.core.peripheral.pojo.CollectOptions)7 XYIntervalSeries (org.jfree.data.xy.XYIntervalSeries)7 XYSeries (org.jfree.data.xy.XYSeries)7 AbstractTraceResult (com.att.aro.core.packetanalysis.pojo.AbstractTraceResult)5 HttpRequestResponseInfo (com.att.aro.core.packetanalysis.pojo.HttpRequestResponseInfo)5 File (java.io.File)5 IHttpRequestResponseHelper (com.att.aro.core.packetanalysis.IHttpRequestResponseHelper)4 AnalysisFilter (com.att.aro.core.packetanalysis.pojo.AnalysisFilter)4 TimeRange (com.att.aro.core.packetanalysis.pojo.TimeRange)4 IOException (java.io.IOException)4