Search in sources :

Example 11 with TraceResultType

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

the class AlarmPlot method populate.

@Override
public void populate(XYPlot plot, AROTraceData analysis) {
    if (analysis == null) {
        LOGGER.info("analysis data is null");
    } else {
        alarmDataCollection.removeAllSeries();
        pointerAnnotation.clear();
        TraceResultType resultType = analysis.getAnalyzerResult().getTraceresult().getTraceResultType();
        if (resultType.equals(TraceResultType.TRACE_FILE)) {
            LOGGER.info("didn't get analysis trace data!");
        } else {
            // Remove old annotation from previous plots
            Iterator<XYPointerAnnotation> pointers = pointerAnnotation.iterator();
            while (pointers.hasNext()) {
                plot.removeAnnotation(pointers.next());
            }
            for (AlarmType eventType : AlarmType.values()) {
                XYIntervalSeries series = new XYIntervalSeries(eventType);
                seriesMap.put(eventType, series);
                alarmDataCollection.addSeries(series);
            }
            TraceDirectoryResult traceresult = (TraceDirectoryResult) analysis.getAnalyzerResult().getTraceresult();
            List<AlarmInfo> alarmInfos = traceresult.getAlarmInfos();
            List<ScheduledAlarmInfo> pendingAlarms = getHasFiredAlarms(traceresult.getScheduledAlarms());
            Iterator<ScheduledAlarmInfo> iterPendingAlarms = pendingAlarms.iterator();
            double firedTime = 0;
            while (iterPendingAlarms.hasNext()) {
                ScheduledAlarmInfo scheduledEvent = iterPendingAlarms.next();
                AlarmType pendingAlarmType = scheduledEvent.getAlarmType();
                if (pendingAlarmType != null) {
                    firedTime = (scheduledEvent.getTimeStamp() - scheduledEvent.getRepeatInterval()) / 1000;
                    seriesMap.get(pendingAlarmType).add(firedTime, firedTime, firedTime, 1, 0.8, 1);
                    eventMapPending.put(firedTime, scheduledEvent);
                // logger.fine("populateAlarmScheduledPlot type:\n" +
                // pendingAlarmType
                // + "\ntime " + scheduledEvent.getTimeStamp()
                // + "\nrepeating " + firedTime);
                }
            }
            Iterator<AlarmInfo> iter = alarmInfos.iterator();
            while (iter.hasNext()) {
                AlarmInfo currEvent = iter.next();
                if (currEvent != null) {
                    AlarmType alarmType = currEvent.getAlarmType();
                    if (alarmType != null) {
                        firedTime = currEvent.getTimeStamp() / 1000;
                        /*
							 * Catching any alarms align to quanta as being
							 * inexactRepeating alarms
							 */
                        if ((currEvent.getTimestampElapsed() / 1000) % 900 < 1) {
                            seriesMap.get(alarmType).add(firedTime, firedTime, firedTime, 1, 0, 0.7);
                            // Adding an arrow to mark these
                            // inexactRepeating alarms
                            XYPointerAnnotation xypointerannotation = new XYPointerAnnotation(alarmType.name(), firedTime, 0.6, 3.92699082D);
                            xypointerannotation.setBaseRadius(20D);
                            xypointerannotation.setTipRadius(1D);
                            pointerAnnotation.add(xypointerannotation);
                            plot.addAnnotation(xypointerannotation);
                        // logger.info("SetInexactRepeating alarm type: "
                        // + alarmType
                        // + " time " + firedTime
                        // + " epoch " + currEvent.getTimestampEpoch()
                        // + " elapsed:\n" +
                        // currEvent.getTimestampElapsed()/1000);
                        } else {
                            seriesMap.get(alarmType).add(firedTime, firedTime, firedTime, 1, 0, 0.5);
                        }
                        eventMap.put(firedTime, currEvent);
                    }
                }
            }
            XYItemRenderer renderer = plot.getRenderer();
            renderer.setSeriesPaint(alarmDataCollection.indexOf(AlarmType.RTC_WAKEUP), Color.red);
            renderer.setSeriesPaint(alarmDataCollection.indexOf(AlarmType.RTC), Color.pink);
            renderer.setSeriesPaint(alarmDataCollection.indexOf(AlarmType.ELAPSED_REALTIME_WAKEUP), Color.blue);
            renderer.setSeriesPaint(alarmDataCollection.indexOf(AlarmType.ELAPSED_REALTIME), Color.cyan);
            renderer.setSeriesPaint(alarmDataCollection.indexOf(AlarmType.UNKNOWN), Color.black);
            // Assign ToolTip to renderer
            renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {

                @Override
                public String generateToolTip(XYDataset dataset, int series, int item) {
                    AlarmInfo info = eventMap.get(dataset.getX(series, item));
                    Date epochTime = new Date();
                    if (info != null) {
                        epochTime.setTime((long) info.getTimestampEpoch());
                        StringBuffer displayInfo = new StringBuffer(ResourceBundleHelper.getMessageString("alarm.tooltip.prefix"));
                        displayInfo.append(MessageFormat.format(ResourceBundleHelper.getMessageString("alarm.tooltip.content"), info.getAlarmType(), info.getTimeStamp() / 1000, epochTime.toString()));
                        if ((info.getTimestampElapsed() / 1000) % 900 < 1) {
                            displayInfo.append(ResourceBundleHelper.getMessageString("alarm.tooltip.setInexactRepeating"));
                        }
                        displayInfo.append(ResourceBundleHelper.getMessageString("alarm.tooltip.suffix"));
                        return displayInfo.toString();
                    }
                    ScheduledAlarmInfo infoPending = eventMapPending.get(dataset.getX(series, item));
                    if (infoPending != null) {
                        epochTime.setTime((long) (infoPending.getTimestampEpoch() - infoPending.getRepeatInterval()));
                        StringBuffer displayInfo = new StringBuffer(ResourceBundleHelper.getMessageString("alarm.tooltip.prefix"));
                        displayInfo.append(MessageFormat.format(ResourceBundleHelper.getMessageString("alarm.tooltip.contentWithName"), infoPending.getAlarmType(), (infoPending.getTimeStamp() - infoPending.getRepeatInterval()) / 1000, epochTime.toString(), infoPending.getApplication(), infoPending.getRepeatInterval() / 1000));
                        displayInfo.append(ResourceBundleHelper.getMessageString("alarm.tooltip.suffix"));
                        return displayInfo.toString();
                    }
                    return null;
                }
            });
        }
    }
    plot.setDataset(alarmDataCollection);
// return plot;
}
Also used : AlarmType(com.att.aro.core.peripheral.pojo.AlarmInfo.AlarmType) ScheduledAlarmInfo(com.att.aro.core.packetanalysis.pojo.ScheduledAlarmInfo) TraceResultType(com.att.aro.core.packetanalysis.pojo.TraceResultType) Date(java.util.Date) XYIntervalSeries(org.jfree.data.xy.XYIntervalSeries) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) ScheduledAlarmInfo(com.att.aro.core.packetanalysis.pojo.ScheduledAlarmInfo) AlarmInfo(com.att.aro.core.peripheral.pojo.AlarmInfo) XYDataset(org.jfree.data.xy.XYDataset) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator) XYPointerAnnotation(org.jfree.chart.annotations.XYPointerAnnotation)

Example 12 with TraceResultType

use of com.att.aro.core.packetanalysis.pojo.TraceResultType 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 13 with TraceResultType

use of com.att.aro.core.packetanalysis.pojo.TraceResultType 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 14 with TraceResultType

use of com.att.aro.core.packetanalysis.pojo.TraceResultType 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)

Aggregations

TraceResultType (com.att.aro.core.packetanalysis.pojo.TraceResultType)14 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)13 XYToolTipGenerator (org.jfree.chart.labels.XYToolTipGenerator)9 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)9 XYDataset (org.jfree.data.xy.XYDataset)9 XYSeries (org.jfree.data.xy.XYSeries)7 XYIntervalSeries (org.jfree.data.xy.XYIntervalSeries)6 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)4 EnumMap (java.util.EnumMap)3 XYIntervalSeriesCollection (org.jfree.data.xy.XYIntervalSeriesCollection)3 AnalysisFilter (com.att.aro.core.packetanalysis.pojo.AnalysisFilter)2 Color (java.awt.Color)2 HashMap (java.util.HashMap)2 AbstractTraceResult (com.att.aro.core.packetanalysis.pojo.AbstractTraceResult)1 ScheduledAlarmInfo (com.att.aro.core.packetanalysis.pojo.ScheduledAlarmInfo)1 AlarmInfo (com.att.aro.core.peripheral.pojo.AlarmInfo)1 AlarmType (com.att.aro.core.peripheral.pojo.AlarmInfo.AlarmType)1 AttenuatorEvent (com.att.aro.core.peripheral.pojo.AttenuatorEvent)1 BatteryInfo (com.att.aro.core.peripheral.pojo.BatteryInfo)1 CpuActivity (com.att.aro.core.peripheral.pojo.CpuActivity)1