use of com.att.aro.core.peripheral.pojo.ThermalStatus in project VideoOptimzer by attdevsupport.
the class ThermalStatusReaderImpl method readData.
public List<ThermalStatusInfo> readData(String directory, double startTime, double traceDuration) {
List<ThermalStatusInfo> thermalStatusInfos = new ArrayList<ThermalStatusInfo>();
String filePath = directory + Util.FILE_SEPARATOR + TraceDataConst.FileName.THERMAL_STATUS;
if (!filereader.fileExist(filePath)) {
return thermalStatusInfos;
}
String[] lines = null;
try {
lines = filereader.readAllLine(filePath);
} catch (IOException e1) {
LOGGER.error("failed to read Thermal status file: " + filePath);
}
String line;
if (lines != null && lines.length > 0) {
line = lines[0];
double beginTime = 0.0;
double endTime = 0.0;
ThermalStatus preThermalStatus = ThermalStatus.UNKNOWN;
ThermalStatus currThermalStatus = ThermalStatus.UNKNOWN;
String[] fields = line.split(" ");
if (fields.length == 2) {
beginTime = Util.normalizeTime(Double.parseDouble(fields[0]), startTime);
try {
preThermalStatus = ThermalStatus.getByCode(Integer.parseInt(fields[1]));
} catch (NumberFormatException | ArrayIndexOutOfBoundsException ex) {
preThermalStatus = ThermalStatus.UNKNOWN;
LOGGER.error("failed to read Thermal status code: " + fields[1], ex);
}
}
for (int i = 1; i < lines.length; i++) {
line = lines[i];
fields = line.split(" ");
if (fields.length == 2) {
endTime = Util.normalizeTime(Double.parseDouble(fields[0]), startTime);
try {
currThermalStatus = ThermalStatus.getByCode(Integer.parseInt(fields[1]));
} catch (NumberFormatException | ArrayIndexOutOfBoundsException ex) {
currThermalStatus = ThermalStatus.UNKNOWN;
LOGGER.error("failed to read Thermal status code: " + fields[1], ex);
}
thermalStatusInfos.add(new ThermalStatusInfo(beginTime, endTime, preThermalStatus));
beginTime = endTime;
preThermalStatus = currThermalStatus;
}
}
thermalStatusInfos.add(new ThermalStatusInfo(beginTime, traceDuration, preThermalStatus));
}
return thermalStatusInfos;
}
use of com.att.aro.core.peripheral.pojo.ThermalStatus in project VideoOptimzer by attdevsupport.
the class TemperaturePlot method populate.
@Override
public void populate(XYPlot plot, AROTraceData analysis) {
XYSeries series = new XYSeries(0);
XYIntervalSeriesCollection thermalDataSeries = new XYIntervalSeriesCollection();
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();
temperatureInfos = traceresult.getTemperatureInfos();
thermalStatusInfos = traceresult.getThermalstatusInfos();
NumberAxis axis = new NumberAxis();
axis.setAutoRange(true);
// Calculate max and min temperature
List<Integer> tempLists = new ArrayList<>();
if (CollectionUtils.isNotEmpty(temperatureInfos)) {
for (TemperatureEvent bi : temperatureInfos) {
series.add(bi.getTimeRecorded(), bi.getcelciusTemperature());
tempLists.add(bi.getcelciusTemperature());
}
TemperatureEvent last = temperatureInfos.get(temperatureInfos.size() - 1);
if (filter.getTimeRange() != null) {
series.add(filter.getTimeRange().getEndTime().doubleValue(), last.getcelciusTemperature());
} else {
series.add(traceresult.getTraceDuration(), last.getcelciusTemperature());
}
XYItemRenderer renderer = plot.getRenderer(0);
renderer.setBaseToolTipGenerator(new XYToolTipGenerator() {
@Override
public String generateToolTip(XYDataset dataset, int series, int item) {
return toolTipContent(item);
}
});
Collections.sort(tempLists);
axis.setRange(Math.round(tempLists.get(0) / 1.2), Math.round(tempLists.get(tempLists.size() - 1) * 1.2));
axis.setAutoRange(false);
plot.setRenderer(0, renderer);
}
if (CollectionUtils.isNotEmpty(thermalStatusInfos)) {
Map<ThermalStatus, XYIntervalSeries> seriesMap = new EnumMap<ThermalStatus, XYIntervalSeries>(ThermalStatus.class);
for (ThermalStatus tstatus : ThermalStatus.values()) {
XYIntervalSeries series2 = new XYIntervalSeries(tstatus);
seriesMap.put(tstatus, series2);
thermalDataSeries.addSeries(series2);
}
Iterator<ThermalStatusInfo> iter = thermalStatusInfos.iterator();
if (iter.hasNext()) {
while (iter.hasNext()) {
ThermalStatusInfo info = iter.next();
seriesMap.get(info.getThermalStatus()).add(info.getBeginTimeStamp(), info.getBeginTimeStamp(), info.getEndTimeStamp(), 0.5, 0, 100);
}
}
XYBarRenderer barRenderer = new XYBarRenderer();
barRenderer.setDrawBarOutline(false);
barRenderer.setUseYInterval(true);
barRenderer.setAutoPopulateSeriesPaint(false);
barRenderer.setShadowVisible(false);
barRenderer.setGradientPaintTransformer(null);
barRenderer.setBarPainter(new StandardXYBarPainter());
setRenderingColorForDataSeries(barRenderer, thermalDataSeries);
barRenderer.setBaseToolTipGenerator(new XYToolTipGenerator() {
@Override
public String generateToolTip(XYDataset dataset, int series, int item) {
ThermalStatus info = (ThermalStatus) thermalDataSeries.getSeries(series).getKey();
return MessageFormat.format(ResourceBundleHelper.getMessageString("network.tooltip"), dataset.getX(series, item), ResourceBundleHelper.getEnumString(info));
}
});
plot.setRenderer(1, barRenderer);
plot.setRangeAxis(axis);
}
}
plot.setDataset(0, new XYSeriesCollection(series));
plot.setDataset(1, thermalDataSeries);
}
}
Aggregations