Search in sources :

Example 16 with EcuDataPv

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++;
    }
}
Also used : XYSeries(org.achartengine.model.XYSeries) EcuDataPv(com.fr3ts0n.ecu.EcuDataPv) XYSeriesRenderer(org.achartengine.renderer.XYSeriesRenderer)

Aggregations

EcuDataPv (com.fr3ts0n.ecu.EcuDataPv)16 EcuDataItem (com.fr3ts0n.ecu.EcuDataItem)4 Conversion (com.fr3ts0n.ecu.Conversion)3 IOException (java.io.IOException)3 Vector (java.util.Vector)3 TimeSeries (org.jfree.data.time.TimeSeries)3 EcuCodeItem (com.fr3ts0n.ecu.EcuCodeItem)2 PvList (com.fr3ts0n.pvs.PvList)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)2 Intent (android.content.Intent)1 ProgressBar (android.widget.ProgressBar)1 TextView (android.widget.TextView)1 NumericConversion (com.fr3ts0n.ecu.NumericConversion)1 VagConversion (com.fr3ts0n.ecu.VagConversion)1 ProcessVar (com.fr3ts0n.pvs.ProcessVar)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1 FileWriter (java.io.FileWriter)1 HashMap (java.util.HashMap)1