Search in sources :

Example 1 with ThermalStatus

use of com.att.aro.core.peripheral.pojo.ThermalStatus in project VideoOptimzer by attdevsupport.

the class ThermalStatusReaderImpl method readData.

public List<ThermalStatusInfo> readData(String directory, double startTime, double traceDuration) {
    List<ThermalStatusInfo> thermalStatusInfos = new ArrayList<ThermalStatusInfo>();
    String filePath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.THERMAL_STATUS;
    if (!filereader.fileExist(filePath)) {
        return thermalStatusInfos;
    }
    String[] lines = null;
    try {
        lines = filereader.readAllLine(filePath);
    } catch (IOException e1) {
        LOGGER.error("failed to read Thermal status file: " + filePath);
    }
    String line;
    if (lines != null && lines.length > 0) {
        line = lines[0];
        double beginTime = 0.0;
        double endTime = 0.0;
        ThermalStatus preThermalStatus = ThermalStatus.UNKNOWN;
        ThermalStatus currThermalStatus = ThermalStatus.UNKNOWN;
        String[] fields = line.split(" ");
        if (fields.length == 2) {
            beginTime = Util.normalizeTime(Double.parseDouble(fields[0]), startTime);
            try {
                preThermalStatus = ThermalStatus.getByCode(Integer.parseInt(fields[1]));
            } catch (NumberFormatException | ArrayIndexOutOfBoundsException ex) {
                preThermalStatus = ThermalStatus.UNKNOWN;
                LOGGER.error("failed to read Thermal status code: " + fields[1], ex);
            }
        }
        for (int i = 1; i < lines.length; i++) {
            line = lines[i];
            fields = line.split(" ");
            if (fields.length == 2) {
                endTime = Util.normalizeTime(Double.parseDouble(fields[0]), startTime);
                try {
                    currThermalStatus = ThermalStatus.getByCode(Integer.parseInt(fields[1]));
                } catch (NumberFormatException | ArrayIndexOutOfBoundsException ex) {
                    currThermalStatus = ThermalStatus.UNKNOWN;
                    LOGGER.error("failed to read Thermal status code: " + fields[1], ex);
                }
                thermalStatusInfos.add(new ThermalStatusInfo(beginTime, endTime, preThermalStatus));
                beginTime = endTime;
                preThermalStatus = currThermalStatus;
            }
        }
        thermalStatusInfos.add(new ThermalStatusInfo(beginTime, traceDuration, preThermalStatus));
    }
    return thermalStatusInfos;
}
Also used : ArrayList(java.util.ArrayList) ThermalStatus(com.att.aro.core.peripheral.pojo.ThermalStatus) ThermalStatusInfo(com.att.aro.core.peripheral.pojo.ThermalStatusInfo) IOException(java.io.IOException)

Example 2 with ThermalStatus

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

Aggregations

ThermalStatus (com.att.aro.core.peripheral.pojo.ThermalStatus)2 ThermalStatusInfo (com.att.aro.core.peripheral.pojo.ThermalStatusInfo)2 ArrayList (java.util.ArrayList)2 AnalysisFilter (com.att.aro.core.packetanalysis.pojo.AnalysisFilter)1 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)1 TraceResultType (com.att.aro.core.packetanalysis.pojo.TraceResultType)1 TemperatureEvent (com.att.aro.core.peripheral.pojo.TemperatureEvent)1 IOException (java.io.IOException)1 EnumMap (java.util.EnumMap)1 NumberAxis (org.jfree.chart.axis.NumberAxis)1 XYToolTipGenerator (org.jfree.chart.labels.XYToolTipGenerator)1 StandardXYBarPainter (org.jfree.chart.renderer.xy.StandardXYBarPainter)1 XYBarRenderer (org.jfree.chart.renderer.xy.XYBarRenderer)1 XYItemRenderer (org.jfree.chart.renderer.xy.XYItemRenderer)1 XYDataset (org.jfree.data.xy.XYDataset)1 XYIntervalSeries (org.jfree.data.xy.XYIntervalSeries)1 XYIntervalSeriesCollection (org.jfree.data.xy.XYIntervalSeriesCollection)1 XYSeries (org.jfree.data.xy.XYSeries)1 XYSeriesCollection (org.jfree.data.xy.XYSeriesCollection)1