use of com.att.aro.core.peripheral.pojo.AlarmInfo 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()));
}
use of com.att.aro.core.peripheral.pojo.AlarmInfo in project VideoOptimzer by attdevsupport.
the class AlarmInfoReaderImpl method readData.
@Override
public List<AlarmInfo> readData(String directory, double dumpsysEpochTimestamp, double dumpsysElapsedTimestamp, Date traceDateTime) {
List<AlarmInfo> alarmInfos = new ArrayList<AlarmInfo>();
String filepath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.KERNEL_LOG_FILE;
double timestamp;
double timestampElapsed;
double timestampEpoch;
double timeDeltaEpochElapsed = dumpsysEpochTimestamp - dumpsysElapsedTimestamp;
AlarmType alarmType;
String[] lines = null;
if (!filereader.fileExist(filepath)) {
return alarmInfos;
}
try {
lines = filereader.readAllLine(filepath);
} catch (IOException e1) {
LOGGER.error("failed to read kernal log file for Alarm Info data: " + filepath);
return alarmInfos;
}
for (String strLineBuf : lines) {
if (strLineBuf.indexOf("alarm_timer_triggered") > 0) {
String[] strFields = strLineBuf.split(" ");
if (strFields.length > 1) {
try {
timestamp = 0;
switch(Integer.parseInt(strFields[strFields.length - 3])) {
case 0:
alarmType = AlarmType.RTC_WAKEUP;
break;
case 1:
alarmType = AlarmType.RTC;
break;
case 2:
alarmType = AlarmType.ELAPSED_REALTIME_WAKEUP;
timestamp = timeDeltaEpochElapsed;
break;
case 3:
alarmType = AlarmType.ELAPSED_REALTIME;
timestamp = timeDeltaEpochElapsed;
break;
default:
// should not arrive here
LOGGER.warn("cannot resolve alarm type: " + timestamp + " type " + Double.parseDouble(strFields[strFields.length - 3]));
alarmType = AlarmType.UNKNOWN;
break;
}
// convert ns to milliseconds
timestamp += Double.parseDouble(strFields[strFields.length - 1]) / 1000000;
timestampEpoch = timestamp;
timestamp = timestamp - traceDateTime.getTime();
timestampElapsed = timestampEpoch - dumpsysEpochTimestamp + dumpsysElapsedTimestamp;
alarmInfos.add(new AlarmInfo(timestamp, timestampEpoch, timestampElapsed, alarmType));
// logger.info("Time: " + timestamp
// + "Alarm type: " + alarmType
// + "\nEpoch: " + timestampEpoch
// + "\nElapsed: " + timestampElapsed);
} catch (Exception e) {
LOGGER.warn("Unexpected error parsing alarm event: " + strLineBuf, e);
}
}
}
}
return alarmInfos;
}
use of com.att.aro.core.peripheral.pojo.AlarmInfo in project VideoOptimzer by attdevsupport.
the class AlarmPlot method populate.
@Override
public void populate(XYPlot plot, AROTraceData analysis) {
if (analysis == null) {
LOGGER.info("analysis data is null");
} else {
alarmDataCollection.removeAllSeries();
pointerAnnotation.clear();
TraceResultType resultType = analysis.getAnalyzerResult().getTraceresult().getTraceResultType();
if (resultType.equals(TraceResultType.TRACE_FILE)) {
LOGGER.info("didn't get analysis trace data!");
} else {
// Remove old annotation from previous plots
Iterator<XYPointerAnnotation> pointers = pointerAnnotation.iterator();
while (pointers.hasNext()) {
plot.removeAnnotation(pointers.next());
}
for (AlarmType eventType : AlarmType.values()) {
XYIntervalSeries series = new XYIntervalSeries(eventType);
seriesMap.put(eventType, series);
alarmDataCollection.addSeries(series);
}
TraceDirectoryResult traceresult = (TraceDirectoryResult) analysis.getAnalyzerResult().getTraceresult();
List<AlarmInfo> alarmInfos = traceresult.getAlarmInfos();
List<ScheduledAlarmInfo> pendingAlarms = getHasFiredAlarms(traceresult.getScheduledAlarms());
Iterator<ScheduledAlarmInfo> iterPendingAlarms = pendingAlarms.iterator();
double firedTime = 0;
while (iterPendingAlarms.hasNext()) {
ScheduledAlarmInfo scheduledEvent = iterPendingAlarms.next();
AlarmType pendingAlarmType = scheduledEvent.getAlarmType();
if (pendingAlarmType != null) {
firedTime = (scheduledEvent.getTimeStamp() - scheduledEvent.getRepeatInterval()) / 1000;
seriesMap.get(pendingAlarmType).add(firedTime, firedTime, firedTime, 1, 0.8, 1);
eventMapPending.put(firedTime, scheduledEvent);
// logger.fine("populateAlarmScheduledPlot type:\n" +
// pendingAlarmType
// + "\ntime " + scheduledEvent.getTimeStamp()
// + "\nrepeating " + firedTime);
}
}
Iterator<AlarmInfo> iter = alarmInfos.iterator();
while (iter.hasNext()) {
AlarmInfo currEvent = iter.next();
if (currEvent != null) {
AlarmType alarmType = currEvent.getAlarmType();
if (alarmType != null) {
firedTime = currEvent.getTimeStamp() / 1000;
/*
* Catching any alarms align to quanta as being
* inexactRepeating alarms
*/
if ((currEvent.getTimestampElapsed() / 1000) % 900 < 1) {
seriesMap.get(alarmType).add(firedTime, firedTime, firedTime, 1, 0, 0.7);
// Adding an arrow to mark these
// inexactRepeating alarms
XYPointerAnnotation xypointerannotation = new XYPointerAnnotation(alarmType.name(), firedTime, 0.6, 3.92699082D);
xypointerannotation.setBaseRadius(20D);
xypointerannotation.setTipRadius(1D);
pointerAnnotation.add(xypointerannotation);
plot.addAnnotation(xypointerannotation);
// logger.info("SetInexactRepeating alarm type: "
// + alarmType
// + " time " + firedTime
// + " epoch " + currEvent.getTimestampEpoch()
// + " elapsed:\n" +
// currEvent.getTimestampElapsed()/1000);
} else {
seriesMap.get(alarmType).add(firedTime, firedTime, firedTime, 1, 0, 0.5);
}
eventMap.put(firedTime, currEvent);
}
}
}
XYItemRenderer renderer = plot.getRenderer();
renderer.setSeriesPaint(alarmDataCollection.indexOf(AlarmType.RTC_WAKEUP), Color.red);
renderer.setSeriesPaint(alarmDataCollection.indexOf(AlarmType.RTC), Color.pink);
renderer.setSeriesPaint(alarmDataCollection.indexOf(AlarmType.ELAPSED_REALTIME_WAKEUP), Color.blue);
renderer.setSeriesPaint(alarmDataCollection.indexOf(AlarmType.ELAPSED_REALTIME), Color.cyan);
renderer.setSeriesPaint(alarmDataCollection.indexOf(AlarmType.UNKNOWN), Color.black);
// Assign ToolTip to renderer
renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {
@Override
public String generateToolTip(XYDataset dataset, int series, int item) {
AlarmInfo info = eventMap.get(dataset.getX(series, item));
Date epochTime = new Date();
if (info != null) {
epochTime.setTime((long) info.getTimestampEpoch());
StringBuffer displayInfo = new StringBuffer(ResourceBundleHelper.getMessageString("alarm.tooltip.prefix"));
displayInfo.append(MessageFormat.format(ResourceBundleHelper.getMessageString("alarm.tooltip.content"), info.getAlarmType(), info.getTimeStamp() / 1000, epochTime.toString()));
if ((info.getTimestampElapsed() / 1000) % 900 < 1) {
displayInfo.append(ResourceBundleHelper.getMessageString("alarm.tooltip.setInexactRepeating"));
}
displayInfo.append(ResourceBundleHelper.getMessageString("alarm.tooltip.suffix"));
return displayInfo.toString();
}
ScheduledAlarmInfo infoPending = eventMapPending.get(dataset.getX(series, item));
if (infoPending != null) {
epochTime.setTime((long) (infoPending.getTimestampEpoch() - infoPending.getRepeatInterval()));
StringBuffer displayInfo = new StringBuffer(ResourceBundleHelper.getMessageString("alarm.tooltip.prefix"));
displayInfo.append(MessageFormat.format(ResourceBundleHelper.getMessageString("alarm.tooltip.contentWithName"), infoPending.getAlarmType(), (infoPending.getTimeStamp() - infoPending.getRepeatInterval()) / 1000, epochTime.toString(), infoPending.getApplication(), infoPending.getRepeatInterval() / 1000));
displayInfo.append(ResourceBundleHelper.getMessageString("alarm.tooltip.suffix"));
return displayInfo.toString();
}
return null;
}
});
}
}
plot.setDataset(alarmDataCollection);
// return plot;
}
use of com.att.aro.core.peripheral.pojo.AlarmInfo in project VideoOptimzer by attdevsupport.
the class AlarmInfoReaderImplTest method readData_noFile.
@Test
public void readData_noFile() throws IOException {
// reader = context.getBean(AlarmInfoReaderImpl.class);
// IFileManager filereader = Mockito.mock(IFileManager.class);
String[] arr = getAlarmData();
Mockito.when(filereader.readAllLine(Mockito.anyString())).thenReturn(arr);
Date traceDateTime = new Date();
Mockito.when(filereader.fileExist(Mockito.anyString())).thenReturn(false);
List<AlarmInfo> list = reader.readData(traceFolder, 123, 124, traceDateTime);
assertTrue(list.size() == 0);
}
use of com.att.aro.core.peripheral.pojo.AlarmInfo in project VideoOptimzer by attdevsupport.
the class AlarmInfoReaderImplTest method readData_IOException.
@Test
public void readData_IOException() throws IOException {
Mockito.when(filereader.readAllLine(Mockito.anyString())).thenThrow(new IOException("test exception"));
Date traceDateTime = new Date();
Mockito.when(filereader.fileExist(traceFolder + Util.FILE_SEPARATOR + TraceDataConst.FileName.KERNEL_LOG_FILE)).thenReturn(true);
List<AlarmInfo> list = reader.readData(traceFolder, 123, 124, traceDateTime);
assertTrue(list.size() == 0);
}
Aggregations