whitespace COMPANY whitespace SERVICES whitespace PRODUCTS whitespace PURCHASE whitespace SUPPORT whitespace CONTACTS whitespace Home whitespace Contact Us whitespace Site Map whitespace
whitespace
SUPPORT
whitespace
FORUM
whitespace
FAQS
whitespace
SUBSCRIPTION
whitespace
REQUEST ON-LINE
whitespace
whitespace

Technical Support Forum

Welcome Guest Search | Active Topics | Log In | Register

Practical ECG Chart Options · View
roshans124
#1 Posted : Thursday, January 20, 2011 10:52:39 AM
Rank: Newbie

Groups: Registered

Joined: 1/18/2011
Posts: 7
Location: Canada
Hello folks,

I am building a wireless ECG system that uses bluetooth (based on the Bluetooth Chat example) and AiCharts (based on ECG example).

There may be an easier way to do this, but I cant think of it!...Here's the logic Im using:

I have a main action called "MainClass". This action controls every other class.
One of the other class is RTPlotter. This is what RTPlotter looks like:

Code:


public class RTPlotter extends ChartView
{
    static final int POINTS_COUNT = 100;
    static final int UPDATE_STEP = 5;
    ArrayList<Double> DATA;
    private static final String TAG = "RTPlotter";
    protected static final String TOAST = "toast";
    protected static final int X_VALUE = 0;
    protected static final int Y_VALUE = 0;
    
    Handler m_handler = new Handler();
    ChartSeries m_series;
    ChartAxisStripLine m_updateLine = new ChartAxisStripLine(1, 0);
    
    int m_dataOffset = 1;
    int m_pointOffset = 0;
    
    public RTPlotter(Context context, ChartView c) {
        super(context);
        Log.d(TAG,"in RTPlotter(context)");
        Log.d(TAG,"setting up chartview");
        ChartView chartView = c;
        Log.d(TAG,"got chart view");
        Log.d(TAG,chartView.toString());
        Log.d(TAG,chartView.getAreas().toString());
        ChartArea area = chartView.getAreas().get(0);
        Log.d(TAG,"got chart area");
        area.getDefaultXAxis().getGridLinePaint().setColor(Color.DKGRAY);
        area.getDefaultYAxis().getGridLinePaint().setColor(Color.DKGRAY);
        Log.d(TAG,"finished setting gridlinepaint");
        area.getDefaultXAxis().getStripLines().add(m_updateLine);
        DATA = new ArrayList<Double>();    
        m_series = chartView.getSeries().get(0);
    //    this.mainProcessing();
    }

    
    public synchronized void setData(double data)
    {
        Log.d(TAG,"in setData");
        Log.e(TAG,"DATA=="+DATA);
        Log.e(TAG,"data=="+data);
        Log.e(TAG,"DATA.size()=="+DATA.size());
        Log.e(TAG,"abs(DATA.size()-1)=="+(Math.abs(DATA.size()-1)));
        Log.e(TAG,"(Math.abs(DATA.size()-1))%POINTS_COUNT=="+(Math.abs(DATA.size()-1)%POINTS_COUNT));
        if(DATA.size()>=100)
            {
                DATA.clear();
                m_series.getPoints().removeAt(0);
            }
        if(DATA.size()==0)
            {
                DATA.add(DATA.size(),data);
                m_series.getPoints().clear();
            }
        else
            DATA.add((DATA.size()-1)%POINTS_COUNT, data);
        
        m_series.getPoints().beginUpdate();
        Log.d(TAG,"updating m_series");
        for (int i = 0; i < DATA.size()%POINTS_COUNT; i++)
        {
                m_series.getPoints().addXY(i, DATA.get(i));
        }
        m_series.getPoints().endUpdate();
}


I call method setDATA from my MainActivity to pass it values to plot.
The issue I'm having is that when I send in values 0.1,0.2,0.3...0.9,0.8...0.1 I get the following:


Screenshot
The chart for some reason goes back to zero after every point. Could you please guide me, so i can get a graph that looks similar to your ECG example?

I have not changed the chart.xml file.

Thanks
roshans124 attached the following image(s):
device.png (33kb) downloaded 55 time(s).
roshans124
#2 Posted : Thursday, January 20, 2011 10:53:56 AM
Rank: Newbie

Groups: Registered

Joined: 1/18/2011
Posts: 7
Location: Canada
Yes, the time is exactly correct. Its quite late :P
Baydalka Volodymyr
#3 Posted : Thursday, January 20, 2011 8:07:16 PM
Rank: Developers Team


Groups: Registered, Administrators

Joined: 7/28/2009
Posts: 447
Hi,

Please note that axes range is set to fixed value in chart.xml file. Try to remove that values.
Also please check update sample.

Best regards,
File Attachment(s):
ECGGraphSample.zip (16kb) downloaded 15 time(s).
Volodymyr Baydalka
Andriod development and support team
roshans124
#4 Posted : Thursday, January 20, 2011 9:53:47 PM
Rank: Newbie

Groups: Registered

Joined: 1/18/2011
Posts: 7
Location: Canada
Thank you Baygalka.. It works like a charm.

Thanks again.
roshans124
#5 Posted : Monday, January 24, 2011 10:34:04 PM
Rank: Newbie

Groups: Registered

Joined: 1/18/2011
Posts: 7
Location: Canada
Another quick question..

Lets say I increase the x-axis to 1000 points. How to I increase the refresh rate? (So that the cursorLine (1,0) updates the data sooner) ?...
Baydalka Volodymyr
#6 Posted : Tuesday, January 25, 2011 12:26:59 PM
Rank: Developers Team


Groups: Registered, Administrators

Joined: 7/28/2009
Posts: 447
Hi,

Try to change value ECGAnimation.updateStep. However 1000 points it's large number and we don't sure that animation will be smooth on the all devices.

Best regards,
Volodymyr Baydalka
Andriod development and support team
roshans124
#7 Posted : Wednesday, March 02, 2011 8:31:14 AM
Rank: Newbie

Groups: Registered

Joined: 1/18/2011
Posts: 7
Location: Canada
Hello,
Looks like my bluetooth action is receiving about 100 new values/second.. How do I go about updating the graph with these values? I'm thinking of having an internal buffer of length - say 150 values... and send the buffer to my aichart program based on realtimeplot. Have you folks done anything like this before? Should I have an Asynctask to update the chart?

Thanks a lot
Users browsing this topic
Guest (2)
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

Company | Services | Practices | Technologies | Career | Contacts | Privacy
© 2005-2016 ArtfulBits. All rights reserved.