Search in sources :

Example 1 with CameraInfo

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

the class EnergyModelFactoryImplTest method create_Test.

@Test
public void create_Test() {
    Date date = new Date();
    Profile profile = Mockito.mock(Profile.class);
    Mockito.when(profile.getPowerGpsActive()).thenReturn(1.0);
    GpsInfo gpsInfo01 = Mockito.mock(GpsInfo.class);
    Mockito.when(gpsInfo01.getBeginTimeStamp()).thenReturn(date.getTime() + 0.0);
    Mockito.when(gpsInfo01.getEndTimeStamp()).thenReturn(date.getTime() + 1000.0);
    Mockito.when(gpsInfo01.getGpsState()).thenReturn(GpsState.GPS_ACTIVE);
    GpsInfo gpsInfo02 = Mockito.mock(GpsInfo.class);
    Mockito.when(profile.getPowerGpsStandby()).thenReturn(0.5);
    Mockito.when(gpsInfo02.getBeginTimeStamp()).thenReturn(date.getTime() + 0.0);
    Mockito.when(gpsInfo02.getEndTimeStamp()).thenReturn(date.getTime() + 1000.0);
    Mockito.when(gpsInfo02.getGpsState()).thenReturn(GpsState.GPS_STANDBY);
    List<GpsInfo> gpsList = new ArrayList<GpsInfo>();
    gpsList.add(gpsInfo01);
    gpsList.add(gpsInfo02);
    CameraInfo cameraInfo01 = Mockito.mock(CameraInfo.class);
    Mockito.when(cameraInfo01.getBeginTimeStamp()).thenReturn(date.getTime() + 0.0);
    Mockito.when(cameraInfo01.getEndTimeStamp()).thenReturn(date.getTime() + 1000.0);
    Mockito.when(cameraInfo01.getCameraState()).thenReturn(CameraState.CAMERA_ON);
    Mockito.when(profile.getPowerCameraOn()).thenReturn(0.3);
    List<CameraInfo> cameraList = new ArrayList<CameraInfo>();
    cameraList.add(cameraInfo01);
    BluetoothInfo bluetoothInfo01 = Mockito.mock(BluetoothInfo.class);
    Mockito.when(bluetoothInfo01.getBeginTimeStamp()).thenReturn(date.getTime() + 0.0);
    Mockito.when(bluetoothInfo01.getEndTimeStamp()).thenReturn(date.getTime() + 1000.0);
    Mockito.when(bluetoothInfo01.getBluetoothState()).thenReturn(BluetoothState.BLUETOOTH_CONNECTED);
    BluetoothInfo bluetoothInfo02 = Mockito.mock(BluetoothInfo.class);
    Mockito.when(bluetoothInfo02.getBeginTimeStamp()).thenReturn(date.getTime() + 0.0);
    Mockito.when(bluetoothInfo02.getEndTimeStamp()).thenReturn(date.getTime() + 1000.0);
    Mockito.when(bluetoothInfo02.getBluetoothState()).thenReturn(BluetoothState.BLUETOOTH_DISCONNECTED);
    List<BluetoothInfo> bluetoothList = new ArrayList<BluetoothInfo>();
    bluetoothList.add(bluetoothInfo01);
    bluetoothList.add(bluetoothInfo02);
    Mockito.when(profile.getPowerBluetoothActive()).thenReturn(1.0);
    Mockito.when(profile.getPowerBluetoothStandby()).thenReturn(0.5);
    ScreenStateInfo screenStateInfo01 = Mockito.mock(ScreenStateInfo.class);
    Mockito.when(screenStateInfo01.getBeginTimeStamp()).thenReturn(date.getTime() + 0.0);
    Mockito.when(screenStateInfo01.getEndTimeStamp()).thenReturn(date.getTime() + 1000.0);
    Mockito.when(screenStateInfo01.getScreenState()).thenReturn(ScreenState.SCREEN_ON);
    List<ScreenStateInfo> screenStateList = new ArrayList<ScreenStateInfo>();
    screenStateList.add(screenStateInfo01);
    Mockito.when(profile.getPowerScreenOn()).thenReturn(0.3);
    EnergyModel model = eMdlFctr.create(profile, 0.0, gpsList, cameraList, bluetoothList, screenStateList);
    assertEquals(1000.0, model.getGpsActiveEnergy(), 0.0);
    assertEquals(500.0, model.getGpsStandbyEnergy(), 0.0);
    assertEquals(1500.0, model.getTotalGpsEnergy(), 0.0);
    assertEquals(300.0, model.getTotalCameraEnergy(), 0.0);
    assertEquals(1000.0, model.getBluetoothActiveEnergy(), 0.0);
    assertEquals(500.0, model.getBluetoothStandbyEnergy(), 0.0);
    assertEquals(1500.0, model.getTotalBluetoothEnergy(), 0.0);
    assertEquals(300.0, model.getTotalScreenEnergy(), 0.0);
}
Also used : BluetoothInfo(com.att.aro.core.peripheral.pojo.BluetoothInfo) EnergyModel(com.att.aro.core.packetanalysis.pojo.EnergyModel) GpsInfo(com.att.aro.core.peripheral.pojo.GpsInfo) ArrayList(java.util.ArrayList) ScreenStateInfo(com.att.aro.core.peripheral.pojo.ScreenStateInfo) CameraInfo(com.att.aro.core.peripheral.pojo.CameraInfo) Date(java.util.Date) Profile(com.att.aro.core.configuration.pojo.Profile) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Example 2 with CameraInfo

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

the class EnergyModelFactoryImpl method create.

@Override
public EnergyModel create(Profile profile, double totalRrcEnergy, List<GpsInfo> gpsinfos, List<CameraInfo> camerainfos, List<BluetoothInfo> bluetoothinfos, List<ScreenStateInfo> screenstateinfos) {
    double gpsActiveEnergy = 0, gpsStandbyEnergy = 0, totalGpsEnergy = 0, totalCameraEnergy = 0;
    double bluetoothActiveEnergy = 0, bluetoothStandbyEnergy = 0, totalBluetoothEnergy = 0;
    double totalScreenEnergy = 0;
    EnergyModel model = new EnergyModel();
    model.setTotalRrcEnergy(totalRrcEnergy);
    // GPS Energy
    Iterator<GpsInfo> gpsIter = gpsinfos.iterator();
    if (gpsIter.hasNext()) {
        while (gpsIter.hasNext()) {
            GpsInfo gps = gpsIter.next();
            GpsState gpsState = gps.getGpsState();
            switch(gpsState) {
                case GPS_ACTIVE:
                    gpsActiveEnergy += profile.getPowerGpsActive() * (gps.getEndTimeStamp() - gps.getBeginTimeStamp());
                    break;
                case GPS_STANDBY:
                    gpsStandbyEnergy += profile.getPowerGpsStandby() * (gps.getEndTimeStamp() - gps.getBeginTimeStamp());
                    break;
                default:
                    break;
            }
        }
    }
    totalGpsEnergy = gpsActiveEnergy + gpsStandbyEnergy;
    // Camera Energy
    Iterator<CameraInfo> cameraIter = camerainfos.iterator();
    if (cameraIter.hasNext()) {
        while (cameraIter.hasNext()) {
            CameraInfo camera = cameraIter.next();
            CameraInfo.CameraState cameraState = camera.getCameraState();
            if (cameraState == CameraInfo.CameraState.CAMERA_ON) {
                totalCameraEnergy += profile.getPowerCameraOn() * (camera.getEndTimeStamp() - camera.getBeginTimeStamp());
            }
        }
    }
    // Bluetooth Energy
    Iterator<BluetoothInfo> bluetoothIter = bluetoothinfos.iterator();
    if (bluetoothIter.hasNext()) {
        while (bluetoothIter.hasNext()) {
            BluetoothInfo btInfo = bluetoothIter.next();
            if (btInfo == null || btInfo.getBluetoothState() == null) {
                continue;
            }
            switch(btInfo.getBluetoothState()) {
                case BLUETOOTH_CONNECTED:
                    bluetoothActiveEnergy += profile.getPowerBluetoothActive() * (btInfo.getEndTimeStamp() - btInfo.getBeginTimeStamp());
                    break;
                case BLUETOOTH_DISCONNECTED:
                    bluetoothStandbyEnergy += profile.getPowerBluetoothStandby() * (btInfo.getEndTimeStamp() - btInfo.getBeginTimeStamp());
                    break;
                default:
                    break;
            }
        }
    }
    totalBluetoothEnergy = bluetoothActiveEnergy + bluetoothStandbyEnergy;
    // Screen Energy
    Iterator<ScreenStateInfo> screenIter = screenstateinfos.iterator();
    if (screenIter.hasNext()) {
        while (screenIter.hasNext()) {
            ScreenStateInfo screenInfo = screenIter.next();
            if (screenInfo.getScreenState() == ScreenStateInfo.ScreenState.SCREEN_ON) {
                totalScreenEnergy += profile.getPowerScreenOn() * (screenInfo.getEndTimeStamp() - screenInfo.getBeginTimeStamp());
            }
        }
    }
    model.setBluetoothActiveEnergy(bluetoothActiveEnergy);
    model.setBluetoothStandbyEnergy(bluetoothStandbyEnergy);
    model.setGpsActiveEnergy(gpsActiveEnergy);
    model.setGpsStandbyEnergy(gpsStandbyEnergy);
    model.setTotalBluetoothEnergy(totalBluetoothEnergy);
    model.setTotalCameraEnergy(totalCameraEnergy);
    model.setTotalGpsEnergy(totalGpsEnergy);
    model.setTotalRrcEnergy(totalRrcEnergy);
    model.setTotalScreenEnergy(totalScreenEnergy);
    return model;
}
Also used : BluetoothInfo(com.att.aro.core.peripheral.pojo.BluetoothInfo) EnergyModel(com.att.aro.core.packetanalysis.pojo.EnergyModel) GpsState(com.att.aro.core.peripheral.pojo.GpsInfo.GpsState) GpsInfo(com.att.aro.core.peripheral.pojo.GpsInfo) ScreenStateInfo(com.att.aro.core.peripheral.pojo.ScreenStateInfo) CameraInfo(com.att.aro.core.peripheral.pojo.CameraInfo)

Example 3 with CameraInfo

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

the class PktAnazlyzerTimeRangeImpl method getCameraInfosForTheTimeRange.

private void getCameraInfosForTheTimeRange(TraceDirectoryResult result, double beginTime, double endTime) {
    List<CameraInfo> cameraInfos = result.getCameraInfos();
    List<CameraInfo> filteredCameraInfos = new ArrayList<CameraInfo>();
    CameraInfo filteredCameraInfo = null;
    double tempCameraActiveDuration = 0.0;
    for (CameraInfo cameraInfo : cameraInfos) {
        if (cameraInfo.getBeginTimeStamp() >= beginTime && cameraInfo.getEndTimeStamp() <= endTime) {
            filteredCameraInfo = cameraInfo;
            filteredCameraInfos.add(filteredCameraInfo);
            if (filteredCameraInfo.getCameraState() == CameraState.CAMERA_ON) {
                tempCameraActiveDuration += filteredCameraInfo.getEndTimeStamp() - filteredCameraInfo.getBeginTimeStamp();
            }
        } else if (cameraInfo.getBeginTimeStamp() <= beginTime && cameraInfo.getEndTimeStamp() <= endTime && cameraInfo.getEndTimeStamp() > beginTime) {
            filteredCameraInfo = new CameraInfo(beginTime, cameraInfo.getEndTimeStamp(), cameraInfo.getCameraState());
            filteredCameraInfos.add(filteredCameraInfo);
            if (filteredCameraInfo.getCameraState() == CameraState.CAMERA_ON) {
                tempCameraActiveDuration += filteredCameraInfo.getEndTimeStamp() - filteredCameraInfo.getBeginTimeStamp();
            }
        } else if (cameraInfo.getBeginTimeStamp() <= beginTime && cameraInfo.getEndTimeStamp() >= endTime) {
            filteredCameraInfo = new CameraInfo(beginTime, endTime, cameraInfo.getCameraState());
            filteredCameraInfos.add(filteredCameraInfo);
            if (filteredCameraInfo.getCameraState() == CameraState.CAMERA_ON) {
                tempCameraActiveDuration += filteredCameraInfo.getEndTimeStamp() - filteredCameraInfo.getBeginTimeStamp();
            }
        } else if (cameraInfo.getBeginTimeStamp() >= beginTime && cameraInfo.getBeginTimeStamp() < endTime && cameraInfo.getEndTimeStamp() >= endTime) {
            filteredCameraInfo = new CameraInfo(cameraInfo.getBeginTimeStamp(), endTime, cameraInfo.getCameraState());
            filteredCameraInfos.add(filteredCameraInfo);
            if (filteredCameraInfo.getCameraState() == CameraState.CAMERA_ON) {
                tempCameraActiveDuration += filteredCameraInfo.getEndTimeStamp() - filteredCameraInfo.getBeginTimeStamp();
            }
        }
    }
    result.setCameraActiveDuration(tempCameraActiveDuration);
}
Also used : ArrayList(java.util.ArrayList) CameraInfo(com.att.aro.core.peripheral.pojo.CameraInfo)

Example 4 with CameraInfo

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

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

the class CameraPlot method populate.

@Override
public void populate(XYPlot plot, AROTraceData analysis) {
    XYIntervalSeriesCollection cameraData = new XYIntervalSeriesCollection();
    if (analysis != null) {
        XYIntervalSeries series = new XYIntervalSeries(CameraState.CAMERA_ON);
        cameraData.addSeries(series);
        // Populate the data set
        Iterator<CameraInfo> iter = analysis.getAnalyzerResult().getTraceresult().getCameraInfos().iterator();
        if (iter.hasNext()) {
            while (iter.hasNext()) {
                CameraInfo cameraEvent = iter.next();
                if (cameraEvent.getCameraState() == CameraState.CAMERA_ON) {
                    series.add(cameraEvent.getBeginTimeStamp(), cameraEvent.getBeginTimeStamp(), cameraEvent.getEndTimeStamp(), 0.5, 0, 1);
                }
            }
        }
        // Assign ToolTip to renderer
        XYItemRenderer renderer = plot.getRenderer();
        renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {

            @Override
            public String generateToolTip(XYDataset dataset, int series, int item) {
                return MessageFormat.format(ResourceBundleHelper.getMessageString("camera.tooltip"), dataset.getX(series, item), ResourceBundleHelper.getEnumString((Enum<?>) dataset.getSeriesKey(series)));
            }
        });
    }
    plot.setDataset(cameraData);
// return plot;
}
Also used : XYIntervalSeries(org.jfree.data.xy.XYIntervalSeries) XYDataset(org.jfree.data.xy.XYDataset) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator) CameraInfo(com.att.aro.core.peripheral.pojo.CameraInfo) XYIntervalSeriesCollection(org.jfree.data.xy.XYIntervalSeriesCollection)

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