Search in sources :

Example 1 with BatteryInfo

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

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

the class BatteryPlot method populate.

@Override
public void populate(XYPlot plot, AROTraceData analysis) {
    XYSeries series = new XYSeries(0);
    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();
            batteryInfos = traceresult.getBatteryInfos();
            if (batteryInfos.size() > 0 && filter.getTimeRange() != null) {
                BatteryInfo first = batteryInfos.get(0);
                series.add(filter.getTimeRange().getBeginTime().doubleValue(), first.getBatteryLevel());
            }
            for (BatteryInfo bi : batteryInfos) {
                series.add(bi.getBatteryTimeStamp(), bi.getBatteryLevel());
            }
            if (batteryInfos.size() > 0) {
                BatteryInfo last = batteryInfos.get(batteryInfos.size() - 1);
                if (filter.getTimeRange() != null) {
                    series.add(filter.getTimeRange().getEndTime().doubleValue(), last.getBatteryLevel());
                } else {
                    series.add(traceresult.getTraceDuration(), last.getBatteryLevel());
                }
            }
            XYItemRenderer renderer = plot.getRenderer();
            renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {

                @Override
                public String generateToolTip(XYDataset dataset, int series, int item) {
                    BatteryInfo bi = batteryInfos.get(Math.min(item, batteryInfos.size() - 1));
                    StringBuffer displayInfo = new StringBuffer(ResourceBundleHelper.getMessageString("battery.tooltip.prefix"));
                    displayInfo.append(MessageFormat.format(ResourceBundleHelper.getMessageString("battery.tooltip.content"), bi.getBatteryLevel(), bi.getBatteryTemp(), bi.isBatteryState() ? ResourceBundleHelper.getMessageString("battery.tooltip.connected") : ResourceBundleHelper.getMessageString("battery.tooltip.disconnected")));
                    displayInfo.append(ResourceBundleHelper.getMessageString("battery.tooltip.suffix"));
                    return displayInfo.toString();
                }
            });
        }
        plot.setDataset(new XYSeriesCollection(series));
    }
// return plot;
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) BatteryInfo(com.att.aro.core.peripheral.pojo.BatteryInfo) AnalysisFilter(com.att.aro.core.packetanalysis.pojo.AnalysisFilter) 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)

Example 3 with BatteryInfo

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

the class BatteryInfoReaderImpl method readData.

@Override
public List<BatteryInfo> readData(String directory, double startTime) {
    List<BatteryInfo> batteryInfos = new ArrayList<BatteryInfo>();
    int previousLevel = 0;
    int previousTemp = 0;
    boolean previousState = false;
    String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.BATTERY_FILE;
    if (!filereader.fileExist(filepath)) {
        return batteryInfos;
    }
    String[] lines = null;
    try {
        lines = filereader.readAllLine(filepath);
    } catch (IOException e1) {
        LOGGER.error("failed to open file for battery info: " + filepath);
    }
    if (lines != null) {
        for (String strLineBuf : lines) {
            String[] strFields = strLineBuf.split(" ");
            if (strFields.length == 4) {
                try {
                    double bTimeStamp = Util.normalizeTime(Double.parseDouble(strFields[0]), startTime);
                    int bLevel = Integer.parseInt(strFields[1]);
                    int bTemp = Integer.parseInt(strFields[2]);
                    boolean bState = Boolean.valueOf(strFields[3]);
                    // plotted
                    if ((bLevel != previousLevel) || (bTemp != previousTemp) || (bState != previousState)) {
                        batteryInfos.add(new BatteryInfo(bTimeStamp, bState, bLevel, bTemp));
                    }
                    previousLevel = Integer.parseInt(strFields[1]);
                    previousTemp = Integer.parseInt(strFields[2]);
                    previousState = Boolean.valueOf(strFields[3]);
                } catch (Exception e) {
                    LOGGER.warn("Unexpected error parsing battery event: " + strLineBuf, e);
                }
            } else {
                LOGGER.warn("Invalid battery_events entry: " + strLineBuf);
            }
        }
    }
    return batteryInfos;
}
Also used : BatteryInfo(com.att.aro.core.peripheral.pojo.BatteryInfo) ArrayList(java.util.ArrayList) IOException(java.io.IOException) IOException(java.io.IOException)

Example 4 with BatteryInfo

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

the class PktAnazlyzerTimeRangeImpl method getBatteryInfosForTheTimeRange.

private void getBatteryInfosForTheTimeRange(TraceDirectoryResult result, double beginTime, double endTime) {
    List<BatteryInfo> orifilteredBatteryInfos = result.getBatteryInfos();
    List<BatteryInfo> filteredBatteryInfos = new ArrayList<BatteryInfo>();
    for (BatteryInfo batteryInfo : orifilteredBatteryInfos) {
        if (batteryInfo.getBatteryTimeStamp() >= beginTime && batteryInfo.getBatteryTimeStamp() <= endTime) {
            filteredBatteryInfos.add(batteryInfo);
        }
    }
    result.setBatteryInfos(filteredBatteryInfos);
// return filteredBatteryInfos;
}
Also used : BatteryInfo(com.att.aro.core.peripheral.pojo.BatteryInfo) ArrayList(java.util.ArrayList)

Example 5 with BatteryInfo

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

the class PktAnazlyzerTimeRangeImplTest method getTimeRangeResultTest.

@Test
public void getTimeRangeResultTest() {
    TraceDirectoryResult result = new TraceDirectoryResult();
    List<UserEvent> userEvents = new ArrayList<UserEvent>();
    userEvents.add(new UserEvent(UserEventType.KEY_HOME, 4.0, 3.0));
    result.setUserEvents(userEvents);
    List<GpsInfo> gpsInfos = new ArrayList<GpsInfo>();
    gpsInfos.add(new GpsInfo(0.0, 0.9, GpsState.GPS_ACTIVE));
    gpsInfos.add(new GpsInfo(1.0, 4.0, GpsState.GPS_ACTIVE));
    gpsInfos.add(new GpsInfo(1.4, 12.0, GpsState.GPS_ACTIVE));
    gpsInfos.add(new GpsInfo(12.4, 14.0, GpsState.GPS_ACTIVE));
    result.setGpsInfos(gpsInfos);
    List<BluetoothInfo> bluetoothInfos = new ArrayList<BluetoothInfo>();
    bluetoothInfos.add(new BluetoothInfo(0.0, 3.0, BluetoothState.BLUETOOTH_CONNECTED));
    bluetoothInfos.add(new BluetoothInfo(4.0, 10.0, BluetoothState.BLUETOOTH_CONNECTED));
    bluetoothInfos.add(new BluetoothInfo(1.0, 13.0, BluetoothState.BLUETOOTH_DISCONNECTED));
    bluetoothInfos.add(new BluetoothInfo(11.0, 16.0, BluetoothState.BLUETOOTH_CONNECTED));
    result.setBluetoothInfos(bluetoothInfos);
    List<CameraInfo> cameraInfos = new ArrayList<CameraInfo>();
    cameraInfos.add(new CameraInfo(0.0, 1.0, CameraState.CAMERA_ON));
    cameraInfos.add(new CameraInfo(3.0, 7.0, CameraState.CAMERA_ON));
    cameraInfos.add(new CameraInfo(8.0, 14.0, CameraState.CAMERA_ON));
    cameraInfos.add(new CameraInfo(1.0, 14.0, CameraState.CAMERA_ON));
    cameraInfos.add(new CameraInfo(12.0, 15.0, CameraState.CAMERA_ON));
    result.setCameraInfos(cameraInfos);
    List<ScreenStateInfo> screenStateInfos = new ArrayList<ScreenStateInfo>();
    ScreenStateInfo screenInfo01 = new ScreenStateInfo(0.0, 1.0, ScreenState.SCREEN_ON, " ", 5);
    ScreenStateInfo screenInfo02 = new ScreenStateInfo(1.0, 12.0, ScreenState.SCREEN_ON, "", 3);
    ScreenStateInfo screenInfo03 = new ScreenStateInfo(5.0, 9.0, ScreenState.SCREEN_ON, "", 2);
    ScreenStateInfo screenInfo04 = new ScreenStateInfo(12.0, 15.0, ScreenState.SCREEN_ON, "", 4);
    screenStateInfos.add(screenInfo01);
    screenStateInfos.add(screenInfo02);
    screenStateInfos.add(screenInfo03);
    screenStateInfos.add(screenInfo04);
    result.setScreenStateInfos(screenStateInfos);
    List<RadioInfo> radioInfos = new ArrayList<RadioInfo>();
    radioInfos.add(new RadioInfo(0.0, 3.0));
    radioInfos.add(new RadioInfo(4.0, 8.0));
    result.setRadioInfos(radioInfos);
    List<BatteryInfo> batteryInfos = new ArrayList<BatteryInfo>();
    batteryInfos.add(new BatteryInfo(3.0, true, 2, 3));
    result.setBatteryInfos(batteryInfos);
    List<WifiInfo> wifiInfos = new ArrayList<WifiInfo>();
    wifiInfos.add(new WifiInfo(1.0, 2.0, WifiState.WIFI_CONNECTED, "", "", ""));
    wifiInfos.add(new WifiInfo(1.0, 5.0, WifiState.WIFI_CONNECTING, "", "", ""));
    wifiInfos.add(new WifiInfo(1.4, 13.0, WifiState.WIFI_CONNECTING, "", "", ""));
    wifiInfos.add(new WifiInfo(9.0, 13.0, WifiState.WIFI_CONNECTING, "", "", ""));
    result.setWifiInfos(wifiInfos);
    List<NetworkType> networkTypesList = new ArrayList<NetworkType>();
    networkTypesList.add(NetworkType.LTE);
    result.setNetworkTypesList(networkTypesList);
    List<NetworkBearerTypeInfo> networkTypeInfos = new ArrayList<NetworkBearerTypeInfo>();
    networkTypeInfos.add(new NetworkBearerTypeInfo(1.0, 3.0, NetworkType.HSPA, NetworkType.OVERRIDE_NETWORK_TYPE_NONE));
    networkTypeInfos.add(new NetworkBearerTypeInfo(8.0, 12.0, NetworkType.HSPA, NetworkType.OVERRIDE_NETWORK_TYPE_NONE));
    result.setNetworkTypeInfos(networkTypeInfos);
    TimeRange timeRange = new TimeRange(2.00, 11.00);
    TraceDirectoryResult testResult = (TraceDirectoryResult) pktTimeUtil.getTimeRangeResult(result, timeRange);
    assertEquals(1, testResult.getBatteryInfos().size());
    assertEquals(2, testResult.getGpsInfos().size());
    assertEquals(1, testResult.getBatteryInfos().size());
    assertEquals(5, testResult.getCameraInfos().size());
    assertEquals(2, testResult.getScreenStateInfos().size());
    assertEquals(1, testResult.getRadioInfos().size());
    assertEquals(3, testResult.getWifiInfos().size());
    assertEquals(2, testResult.getNetworkTypeInfos().size());
}
Also used : BluetoothInfo(com.att.aro.core.peripheral.pojo.BluetoothInfo) BatteryInfo(com.att.aro.core.peripheral.pojo.BatteryInfo) ArrayList(java.util.ArrayList) GpsInfo(com.att.aro.core.peripheral.pojo.GpsInfo) ScreenStateInfo(com.att.aro.core.peripheral.pojo.ScreenStateInfo) CameraInfo(com.att.aro.core.peripheral.pojo.CameraInfo) UserEvent(com.att.aro.core.peripheral.pojo.UserEvent) WifiInfo(com.att.aro.core.peripheral.pojo.WifiInfo) RadioInfo(com.att.aro.core.peripheral.pojo.RadioInfo) TimeRange(com.att.aro.core.packetanalysis.pojo.TimeRange) NetworkType(com.att.aro.core.peripheral.pojo.NetworkType) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) NetworkBearerTypeInfo(com.att.aro.core.packetanalysis.pojo.NetworkBearerTypeInfo) BaseTest(com.att.aro.core.BaseTest) Test(org.junit.Test)

Aggregations

BatteryInfo (com.att.aro.core.peripheral.pojo.BatteryInfo)6 ArrayList (java.util.ArrayList)3 BaseTest (com.att.aro.core.BaseTest)2 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)2 BluetoothInfo (com.att.aro.core.peripheral.pojo.BluetoothInfo)2 CameraInfo (com.att.aro.core.peripheral.pojo.CameraInfo)2 GpsInfo (com.att.aro.core.peripheral.pojo.GpsInfo)2 RadioInfo (com.att.aro.core.peripheral.pojo.RadioInfo)2 ScreenStateInfo (com.att.aro.core.peripheral.pojo.ScreenStateInfo)2 UserEvent (com.att.aro.core.peripheral.pojo.UserEvent)2 WifiInfo (com.att.aro.core.peripheral.pojo.WifiInfo)2 IOException (java.io.IOException)2 Test (org.junit.Test)2 AnalysisFilter (com.att.aro.core.packetanalysis.pojo.AnalysisFilter)1 NetworkBearerTypeInfo (com.att.aro.core.packetanalysis.pojo.NetworkBearerTypeInfo)1 TimeRange (com.att.aro.core.packetanalysis.pojo.TimeRange)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 CollectOptions (com.att.aro.core.peripheral.pojo.CollectOptions)1