Search in sources :

Example 1 with LocationEvent

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

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

the class GpsPlot method populate.

@Override
public void populate(XYPlot plot, AROTraceData analysis) {
    if (analysis == null) {
        LOGGER.info("analysis data is null");
        return;
    }
    gpsData.removeAllSeries();
    locationData.removeAllSeries();
    TraceResultType resultType = analysis.getAnalyzerResult().getTraceresult().getTraceResultType();
    if (resultType.equals(TraceResultType.TRACE_FILE)) {
        LOGGER.info("didn't get analysis trace data!");
    } else {
        try {
            image = ImageIO.read(GpsPlot.class.getResourceAsStream("/images/location.png"));
            image = ImageHelper.resize(image, 12, 12);
        } catch (IOException e) {
            e.printStackTrace();
        }
        // create the GPS dataset...
        Map<GpsState, XYIntervalSeries> seriesMap = new EnumMap<GpsState, XYIntervalSeries>(GpsState.class);
        for (GpsState eventType : GpsState.values()) {
            XYIntervalSeries series = new XYIntervalSeries(eventType);
            seriesMap.put(eventType, series);
            gpsData.addSeries(series);
        }
        series = new XYSeries("location");
        TraceDirectoryResult traceresult = (TraceDirectoryResult) analysis.getAnalyzerResult().getTraceresult();
        listLocationEvent = (ArrayList<LocationEvent>) traceresult.getLocationEventInfos();
        for (int idx = 0; idx < listLocationEvent.size(); idx++) {
            series.add(listLocationEvent.get(idx).getTimeRecorded(), 0.5);
        }
        locationData.addSeries(series);
        Iterator<GpsInfo> iter = analysis.getAnalyzerResult().getTraceresult().getGpsInfos().iterator();
        if (iter.hasNext()) {
            while (iter.hasNext()) {
                GpsInfo gpsEvent = iter.next();
                if (gpsEvent.getGpsState() != GpsState.GPS_DISABLED) {
                    seriesMap.get(gpsEvent.getGpsState()).add(gpsEvent.getBeginTimeStamp(), gpsEvent.getBeginTimeStamp(), gpsEvent.getEndTimeStamp(), 0.5, 0, 1);
                }
            }
        }
        XYItemRenderer renderer = plot.getRenderer(0);
        // Looks like renderer is using the index descending order, so setting the index of the GPS background as 2 & location information index as 1.
        if (renderer == null) {
            renderer = plot.getRenderer(2);
        }
        renderer.setSeriesPaint(gpsData.indexOf(GpsState.GPS_STANDBY), Color.YELLOW);
        renderer.setSeriesPaint(gpsData.indexOf(GpsState.GPS_ACTIVE), new Color(34, 177, 76));
        // Assign ToolTip to renderer
        renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {

            @Override
            public String generateToolTip(XYDataset dataset, int series, int item) {
                GpsState eventType = (GpsState) gpsData.getSeries(series).getKey();
                return MessageFormat.format(ResourceBundleHelper.getMessageString("gps.tooltip"), dataset.getX(series, item), ResourceBundleHelper.getEnumString(eventType));
            }
        });
        plot.setRenderer(2, renderer);
        // Assign ToolTip to renderer
        LocationImageRenderer renderer_loc = new LocationImageRenderer();
        plot.setRenderer(1, renderer_loc);
        renderer_loc.setBaseToolTipGenerator(new XYToolTipGenerator() {

            @Override
            public String generateToolTip(XYDataset dataset, int series, int item) {
                // Update tooltip of location data
                LocationEvent event = listLocationEvent.get(item);
                StringBuffer displayInfo = new StringBuffer(ResourceBundleHelper.getMessageString("location.tooltip.prefix"));
                displayInfo.append(MessageFormat.format(ResourceBundleHelper.getMessageString("location.tooltip.content"), event.getTimeRecorded(), event.getLatitude(), event.getLongitude(), event.getProvider(), event.getLocality()));
                displayInfo.append(ResourceBundleHelper.getMessageString("location.tooltip.suffix"));
                return displayInfo.toString();
            }
        });
    }
    plot.setDataset(2, gpsData);
    plot.setDataset(1, locationData);
}
Also used : XYSeries(org.jfree.data.xy.XYSeries) Color(java.awt.Color) GpsInfo(com.att.aro.core.peripheral.pojo.GpsInfo) IOException(java.io.IOException) TraceResultType(com.att.aro.core.packetanalysis.pojo.TraceResultType) GpsState(com.att.aro.core.peripheral.pojo.GpsInfo.GpsState) XYIntervalSeries(org.jfree.data.xy.XYIntervalSeries) TraceDirectoryResult(com.att.aro.core.packetanalysis.pojo.TraceDirectoryResult) XYDataset(org.jfree.data.xy.XYDataset) StandardXYItemRenderer(org.jfree.chart.renderer.xy.StandardXYItemRenderer) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator) EnumMap(java.util.EnumMap) LocationEvent(com.att.aro.core.peripheral.pojo.LocationEvent)

Example 3 with LocationEvent

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

the class LocationReaderImpl method readData.

@Override
public List<LocationEvent> readData(String directory, double startTime) {
    List<LocationEvent> locationEvents = new ArrayList<LocationEvent>();
    String filePath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.LOCATION_FILE;
    if (!filereader.fileExist(filePath)) {
        return locationEvents;
    }
    String[] contents = null;
    try {
        contents = filereader.readAllLine(filePath);
    } catch (IOException e) {
        LOGGER.error("failed to read user event file: " + filePath);
    }
    if (contents != null && contents.length > 0) {
        for (String contentBuf : contents) {
            // Ignore empty line
            if (contentBuf.trim().isEmpty()) {
                continue;
            }
            // Parse entry
            String[] splitContents = contentBuf.split(" ");
            if (splitContents.length <= 1) {
                LOGGER.warn("Found invalid event entry: " + contentBuf);
                continue;
            }
            // Get timestamp
            double timeStamp = Double.parseDouble(splitContents[0]);
            if (timeStamp > 1.0e9) {
                timeStamp = Util.normalizeTime(timeStamp, startTime);
            }
            // Get event
            double latitude = 0;
            double longitude = 0;
            String provider = "";
            StringBuffer locality = new StringBuffer();
            // EVENT_TIME LAT_VALUE LONG_VALUE LOCALITY PROVIDER
            if (splitContents.length >= 4) {
                try {
                    latitude = Double.parseDouble(splitContents[1]);
                    longitude = Double.parseDouble(splitContents[2]);
                    provider = splitContents[3];
                    for (int idx = 4; idx <= (splitContents.length - 1); idx++) {
                        if (locality.length() > 0) {
                            locality.append(' ');
                        }
                        locality.append(splitContents[idx]);
                    }
                    locationEvents.add(new LocationEvent(timeStamp, latitude, longitude, provider, locality.toString()));
                } catch (Exception e) {
                    LOGGER.warn("Found invalid event entry: " + contentBuf);
                    continue;
                }
            }
        }
    }
    return locationEvents;
}
Also used : ArrayList(java.util.ArrayList) IOException(java.io.IOException) LocationEvent(com.att.aro.core.peripheral.pojo.LocationEvent) IOException(java.io.IOException)

Example 4 with LocationEvent

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

the class LocationReaderImplTest method readData_IOException.

@Test
public void readData_IOException() throws IOException {
    Mockito.when(filereader.fileExist(Mockito.anyString())).thenReturn(true);
    Mockito.when(filereader.readAllLine(Mockito.anyString())).thenThrow(new IOException("test exception"));
    List<LocationEvent> listLocationEvent = null;
    listLocationEvent = traceDataReader.readData(traceFolder, 0.0);
    assertEquals(0, listLocationEvent.size(), 0);
}
Also used : IOException(java.io.IOException) LocationEvent(com.att.aro.core.peripheral.pojo.LocationEvent) Test(org.junit.Test) BaseTest(com.att.aro.core.BaseTest)

Aggregations

LocationEvent (com.att.aro.core.peripheral.pojo.LocationEvent)4 IOException (java.io.IOException)3 GpsInfo (com.att.aro.core.peripheral.pojo.GpsInfo)2 BaseTest (com.att.aro.core.BaseTest)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 GpsState (com.att.aro.core.peripheral.pojo.GpsInfo.GpsState)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 TemperatureEvent (com.att.aro.core.peripheral.pojo.TemperatureEvent)1 ThermalStatusInfo (com.att.aro.core.peripheral.pojo.ThermalStatusInfo)1 UserEvent (com.att.aro.core.peripheral.pojo.UserEvent)1