Search in sources :

Example 6 with CameraInfo

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

the class CameraInfoReaderImpl method readData.

@Override
public List<CameraInfo> readData(String directory, double startTime, double traceDuration) {
    this.activeDuration = 0;
    List<CameraInfo> cameraInfos = new ArrayList<CameraInfo>();
    String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.CAMERA_FILE;
    if (!filereader.fileExist(filepath)) {
        return cameraInfos;
    }
    double beginTime = 0.0;
    double endTime;
    double dLastActiveTimeStamp = 0.0;
    double dActiveDuration = 0.0;
    CameraState prevCameraState = null;
    CameraState cameraState = null;
    String firstLine;
    String strLineBuf;
    String[] lines = null;
    try {
        lines = filereader.readAllLine(filepath);
    } catch (IOException e1) {
        LOGGER.error("failed to read Camera info file: " + filepath);
    }
    if (lines != null && lines.length > 0) {
        firstLine = lines[0];
        String[] strFieldsFirstLine = firstLine.split(" ");
        if (strFieldsFirstLine.length == 2) {
            try {
                beginTime = Util.normalizeTime(Double.parseDouble(strFieldsFirstLine[0]), startTime);
                if (TraceDataConst.CAMERA_ON.equals(strFieldsFirstLine[1])) {
                    prevCameraState = CameraState.CAMERA_ON;
                    if (0.0 == dLastActiveTimeStamp) {
                        dLastActiveTimeStamp = beginTime;
                    }
                } else if (TraceDataConst.CAMERA_OFF.equals(strFieldsFirstLine[1])) {
                    prevCameraState = CameraState.CAMERA_OFF;
                } else {
                    LOGGER.warn("Unknown camera state: " + firstLine);
                    prevCameraState = CameraState.CAMERA_UNKNOWN;
                }
                if ((!TraceDataConst.CAMERA_ON.equals(strFieldsFirstLine[1])) && dLastActiveTimeStamp > 0.0) {
                    dActiveDuration += (beginTime - dLastActiveTimeStamp);
                    dLastActiveTimeStamp = 0.0;
                }
            } catch (Exception e) {
                LOGGER.warn("Unexpected error in camera events: " + firstLine, e);
            }
        } else {
            LOGGER.warn("Unrecognized camera event: " + firstLine);
        }
        for (int i = 1; i < lines.length; i++) {
            strLineBuf = lines[i];
            String[] strFields = strLineBuf.split(" ");
            if (strFields.length == 2) {
                try {
                    endTime = Util.normalizeTime(Double.parseDouble(strFields[0]), startTime);
                    if (TraceDataConst.CAMERA_ON.equals(strFields[1])) {
                        cameraState = CameraState.CAMERA_ON;
                        if (0.0 == dLastActiveTimeStamp) {
                            dLastActiveTimeStamp = endTime;
                        }
                    } else if (TraceDataConst.CAMERA_OFF.equals(strFields[1])) {
                        cameraState = CameraState.CAMERA_OFF;
                    } else {
                        LOGGER.warn("Unknown camera state: " + strLineBuf);
                        cameraState = CameraState.CAMERA_UNKNOWN;
                    }
                    cameraInfos.add(new CameraInfo(beginTime, endTime, prevCameraState));
                    if ((!TraceDataConst.CAMERA_ON.equals(strFields[1])) && dLastActiveTimeStamp > 0.0) {
                        dActiveDuration += (endTime - dLastActiveTimeStamp);
                        dLastActiveTimeStamp = 0.0;
                    }
                    prevCameraState = cameraState;
                    beginTime = endTime;
                } catch (Exception e) {
                    LOGGER.warn("Unexpected error in camera events: " + strLineBuf, e);
                }
            } else {
                LOGGER.warn("Unrecognized camera event: " + strLineBuf);
            }
        }
        cameraInfos.add(new CameraInfo(beginTime, traceDuration, prevCameraState));
        // Duration calculation should probably be done in analysis
        if (cameraState == CameraState.CAMERA_ON) {
            dActiveDuration += Math.max(0, traceDuration - dLastActiveTimeStamp);
        }
        this.activeDuration = dActiveDuration;
    }
    return cameraInfos;
}
Also used : CameraState(com.att.aro.core.peripheral.pojo.CameraInfo.CameraState) ArrayList(java.util.ArrayList) IOException(java.io.IOException) CameraInfo(com.att.aro.core.peripheral.pojo.CameraInfo) IOException(java.io.IOException)

Example 7 with CameraInfo

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

CameraInfo (com.att.aro.core.peripheral.pojo.CameraInfo)7 BluetoothInfo (com.att.aro.core.peripheral.pojo.BluetoothInfo)4 GpsInfo (com.att.aro.core.peripheral.pojo.GpsInfo)4 ScreenStateInfo (com.att.aro.core.peripheral.pojo.ScreenStateInfo)4 ArrayList (java.util.ArrayList)4 BaseTest (com.att.aro.core.BaseTest)2 EnergyModel (com.att.aro.core.packetanalysis.pojo.EnergyModel)2 BatteryInfo (com.att.aro.core.peripheral.pojo.BatteryInfo)2 RadioInfo (com.att.aro.core.peripheral.pojo.RadioInfo)2 UserEvent (com.att.aro.core.peripheral.pojo.UserEvent)2 WifiInfo (com.att.aro.core.peripheral.pojo.WifiInfo)2 Test (org.junit.Test)2 Profile (com.att.aro.core.configuration.pojo.Profile)1 NetworkBearerTypeInfo (com.att.aro.core.packetanalysis.pojo.NetworkBearerTypeInfo)1 TimeRange (com.att.aro.core.packetanalysis.pojo.TimeRange)1 TraceDirectoryResult (com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult)1 ThermalStatusReaderImpl (com.att.aro.core.peripheral.impl.ThermalStatusReaderImpl)1 AlarmInfo (com.att.aro.core.peripheral.pojo.AlarmInfo)1 CameraState (com.att.aro.core.peripheral.pojo.CameraInfo.CameraState)1 CollectOptions (com.att.aro.core.peripheral.pojo.CollectOptions)1