Search in sources :

Example 1 with ThermalStatusInfo

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

the class TraceDataReaderImpl method readFileUtil.

/**
 * some of the trace files read here
 *
 * Parses the user event trace
 *
 * @throws IOException
 *
 *             Reads the screen rotations information contained in the
 *             "screen_rotations" file found inside the trace directory and adds
 *             them to the user events list.
 * @throws IOException
 *             Reads the CPU trace information from the CPU file.
 *
 * @throws IOException
 *             Method to read the GPS data from the trace file and store it in
 *             the gpsInfos list. It also updates the active duration for GPS.
 *             Method to read the Bluetooth data from the trace file and store
 *             it in the bluetoothInfos list. It also updates the active
 *             duration for Bluetooth.
 *
 * @throws IOException
 *             Method to read the Camera data from the trace file and store it
 *             in the cameraInfos list. It also updates the active duration for
 *             Camera.
 *
 *             Method to read the WIFI data from the trace file and store it in
 *             the wifiInfos list. It also updates the active duration for Wifi.
 *
 *             Method to read the Screen State data from the trace file and
 *             store it in the ScreenStateInfos list.
 *
 *             Method to read the Battery data from the trace file and store it
 *             in the batteryInfos list.
 *
 *             Method to read the alarm event from the trace file and store it
 *             in the alarmInfos list.
 *
 *             Reads the Radio data from the file and stores it in the
 *             RadioInfo.
 * @param result
 */
public void readFileUtil(TraceDirectoryResult result) {
    NetworkTypeObject obj = networktypereader.readData(result.getTraceDirectory(), result.getPcapTime0(), result.getTraceDuration());
    if (obj != null) {
        result.setNetworkTypeInfos(obj.getNetworkTypeInfos());
        result.setNetworkTypesList(obj.getNetworkTypesList());
    }
    CollectOptions collectOptions = collectOptionsReader.readData(result.getTraceDirectory());
    result.setCollectOptions(collectOptions);
    List<UserEvent> userEvents = usereventreader.readData(result.getTraceDirectory(), result.getEventTime0(), result.getPcapTime0());
    result.setUserEvents(userEvents);
    List<UserEvent> list = this.screenrotationreader.readData(result.getTraceDirectory(), result.getPcapTime0());
    result.setScreenRotationCounter(list.size());
    result.getUserEvents().addAll(list);
    List<TemperatureEvent> temperatureEvents = cputemperaturereader.readData(result.getTraceDirectory(), result.getPcapTime0());
    result.setTemperatureInfos(temperatureEvents);
    List<LocationEvent> locationEvents = locationreader.readData(result.getTraceDirectory(), result.getPcapTime0());
    result.setLocationEventInfos(locationEvents);
    CpuActivityList cpuActivityList = cpureader.readData(result.getTraceDirectory(), result.getPcapTime0());
    result.setCpuActivityList(cpuActivityList);
    List<GpsInfo> gpsInfos = gpsreader.readData(result.getTraceDirectory(), result.getPcapTime0(), result.getTraceDuration());
    result.setGpsInfos(gpsInfos);
    result.setGpsActiveDuration(gpsreader.getGpsActiveDuration());
    List<BluetoothInfo> bluetoothInfos = bluetoothreader.readData(result.getTraceDirectory(), result.getPcapTime0(), result.getTraceDuration());
    result.setBluetoothInfos(bluetoothInfos);
    result.setBluetoothActiveDuration(bluetoothreader.getBluetoothActiveDuration());
    List<WifiInfo> wifiInfos = wifireader.readData(result.getTraceDirectory(), result.getPcapTime0(), result.getTraceDuration());
    result.setWifiInfos(wifiInfos);
    result.setWifiActiveDuration(wifireader.getWifiActiveDuration());
    List<CameraInfo> cameraInfos = camerareader.readData(result.getTraceDirectory(), result.getPcapTime0(), result.getTraceDuration());
    result.setCameraInfos(cameraInfos);
    result.setCameraActiveDuration(camerareader.getActiveDuration());
    List<ThermalStatusInfo> thermalStatusInfos = new ThermalStatusReaderImpl(filereader).readData(result.getTraceDirectory(), result.getPcapTime0(), result.getTraceDuration());
    result.setThermalstatusInfos(thermalStatusInfos);
    List<ScreenStateInfo> screenStateInfos = screenstatereader.readData(result.getTraceDirectory(), result.getPcapTime0(), result.getTraceDuration());
    result.setScreenStateInfos(screenStateInfos);
    List<BatteryInfo> batteryInfos = batteryinforeader.readData(result.getTraceDirectory(), result.getPcapTime0());
    result.setBatteryInfos(batteryInfos);
    // alarm info from kernel log file
    List<AlarmInfo> alarmInfos = alarminforeader.readData(result.getTraceDirectory(), result.getDumpsysEpochTimestamp(), result.getDumpsysElapsedTimestamp(), result.getTraceDateTime());
    result.setAlarmInfos(alarmInfos);
    List<RadioInfo> radioInfos = radioinforeader.readData(result.getTraceDirectory(), result.getPcapTime0());
    result.setRadioInfos(radioInfos);
    VideoStreamStartupData videoStreamStartupData = videoStartupReader.readData(result.getTraceDirectory());
    result.setVideoStartupData(videoStreamStartupData);
    result.setMetaData(metaDataReadWrite.readData(result.getTraceDirectory()));
}
Also used : CpuActivityList(com.att.aro.core.peripheral.pojo.CpuActivityList) NetworkTypeObject(com.att.aro.core.peripheral.pojo.NetworkTypeObject) BatteryInfo(com.att.aro.core.peripheral.pojo.BatteryInfo) ScreenStateInfo(com.att.aro.core.peripheral.pojo.ScreenStateInfo) CameraInfo(com.att.aro.core.peripheral.pojo.CameraInfo) LocationEvent(com.att.aro.core.peripheral.pojo.LocationEvent) BluetoothInfo(com.att.aro.core.peripheral.pojo.BluetoothInfo) TemperatureEvent(com.att.aro.core.peripheral.pojo.TemperatureEvent) VideoStreamStartupData(com.att.aro.core.peripheral.pojo.VideoStreamStartupData) GpsInfo(com.att.aro.core.peripheral.pojo.GpsInfo) ThermalStatusInfo(com.att.aro.core.peripheral.pojo.ThermalStatusInfo) UserEvent(com.att.aro.core.peripheral.pojo.UserEvent) WifiInfo(com.att.aro.core.peripheral.pojo.WifiInfo) RadioInfo(com.att.aro.core.peripheral.pojo.RadioInfo) CollectOptions(com.att.aro.core.peripheral.pojo.CollectOptions) AlarmInfo(com.att.aro.core.peripheral.pojo.AlarmInfo) ThermalStatusReaderImpl(com.att.aro.core.peripheral.impl.ThermalStatusReaderImpl)

Example 2 with ThermalStatusInfo

use of com.att.aro.core.peripheral.pojo.ThermalStatusInfo 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 3 with ThermalStatusInfo

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

ThermalStatusInfo (com.att.aro.core.peripheral.pojo.ThermalStatusInfo)3 TemperatureEvent (com.att.aro.core.peripheral.pojo.TemperatureEvent)2 ThermalStatus (com.att.aro.core.peripheral.pojo.ThermalStatus)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 ThermalStatusReaderImpl (com.att.aro.core.peripheral.impl.ThermalStatusReaderImpl)1 AlarmInfo (com.att.aro.core.peripheral.pojo.AlarmInfo)1 BatteryInfo (com.att.aro.core.peripheral.pojo.BatteryInfo)1 BluetoothInfo (com.att.aro.core.peripheral.pojo.BluetoothInfo)1 CameraInfo (com.att.aro.core.peripheral.pojo.CameraInfo)1 CollectOptions (com.att.aro.core.peripheral.pojo.CollectOptions)1 CpuActivityList (com.att.aro.core.peripheral.pojo.CpuActivityList)1 GpsInfo (com.att.aro.core.peripheral.pojo.GpsInfo)1 LocationEvent (com.att.aro.core.peripheral.pojo.LocationEvent)1 NetworkTypeObject (com.att.aro.core.peripheral.pojo.NetworkTypeObject)1 RadioInfo (com.att.aro.core.peripheral.pojo.RadioInfo)1 ScreenStateInfo (com.att.aro.core.peripheral.pojo.ScreenStateInfo)1 UserEvent (com.att.aro.core.peripheral.pojo.UserEvent)1