use of com.fr3ts0n.ecu.EcuDataPv in project AndrOBD by fr3ts0n.
the class ChartActivity method setUpChartData.
/**
* Set up all the charting data series
*
* @param positions Positions of PIDs withn adapter
*/
private void setUpChartData(int[] positions) {
long startTime = System.currentTimeMillis();
int i = 0;
EcuDataPv currPv;
XYSeries currSeries;
pidNumbers.clear();
// loop through all PIDs
for (int position : positions) {
// get corresponding Process variable
currPv = (EcuDataPv) mAdapter.getItem(position);
if (currPv == null)
continue;
int pid = currPv.getAsInt(EcuDataPv.FID_PID);
// add PID to unique list of PIDs
pidNumbers.add(pid);
// get contained data series
currSeries = (XYSeries) currPv.get(ObdItemAdapter.FID_DATA_SERIES);
if (currSeries == null)
continue;
// at least one measurement is available
if (currSeries.getItemCount() < 1)
currSeries.add(startTime, (Float) currPv.get(EcuDataPv.FID_VALUE));
// set scale to display series
currSeries.setScaleNumber(i);
// register series to graph
sensorData.addSeries(i, currSeries);
/* set up series visual parameters */
renderer.setYTitle(String.valueOf(currPv.get(EcuDataPv.FID_UNITS)), i);
renderer.setYAxisAlign(((i % 2) == 0) ? Align.LEFT : Align.RIGHT, i);
renderer.setYLabelsAlign(((i % 2) == 0) ? Align.LEFT : Align.RIGHT, i);
renderer.setYLabelsColor(i, getItemColor(pid));
/* set up new line renderer */
XYSeriesRenderer r = new XYSeriesRenderer();
r.setColor(getItemColor(pid));
r.setStroke(getStroke(pid));
// register line renderer
renderer.addSeriesRenderer(i, r);
i++;
}
}
Aggregations