Page 1 of 1

Access Violation during real-time monitoring

Posted: Fri Mar 28, 2008 10:52 am
by 10047047
Hi,

I am writting a real-time monitoring program. The live data is added to data series via a separate thread. The program stops after running couple hours with exception error message "Access violation at address 0050921F in module, Read of address 7F6E3794". The address 005921F is related to the funtion 'Series::TFastLineSeries::CalcPosition:' when using CPU view in C++ Builder debug window. What doe the CalcPosition function calculate? Any suggestion on fixing this problem?

Thanks in advance.

Xia

Posted: Fri Mar 28, 2008 11:13 am
by narcis
Hi Xia,

First of all I strongly recommend you to read the Real-time charting article at http://www.teechart.net/reference/articles/index.php

Regarding your inquiry, could you please send us a simple example project we can run "as-is", let us know the exact steps we should follow to reproduce the problem here and the exact TeeChart version you are using?

You can either post your files at news://www.steema.net/steema.public.attachments newsgroup or at our upload page.

Thanks in advance.

Posted: Mon Apr 14, 2008 4:33 pm
by 10047047
Hi Narcis,

Sorry for not sending you a test program as it needs a hardware to transmit live data. However, I think that the problem was caused by asynchronizing when using a separate thread to add live data to several data series. It seems work fine after I set Chart->AutoRepaint = false before new data to be added, and then set Chart->AutoRepaint = true after all data are added.

I tried to use Chart->Repaint(), Chart->Refresh() and Series->Repaint() functions to replot the new data after all data are added, but chart is not repainted. So I have to set Chart->AutoRepaint = true. Do I have to set Chart->AutoRepaint = true before call Repaint() function?

Thanks.

Regards

Xia

Posted: Wed Apr 16, 2008 9:50 pm
by 10047047
Hi Narcis,

I have uploaded a test project to your server.

As you can see that the traces are ploted at a correct speed when the number of recorded data points is small (e.g. 1000 points). But after a large number of data points (e.g. 500,000 by clicking the checkbox) is recorded, the traces are displayed very slow although the number of points displayed on the screen is same (i.e. 1000 points per screen).

How can I speed up the scroll mode display when a large number of data has been recorded during real-time monitoring?

Thanks

Xia

Posted: Thu Apr 17, 2008 9:01 am
by narcis
Hi Xia,

Thanks for the example project.

I could enhance it's performance just not calling the Clear method for each series on the CheckBox1Click event, FillSampleValues already clears the series.

You may also be interested in using DoScrollPoints method. I've implemented it on your example but at the moment it's not being used. I'm going to send you the example with the modifications I've made.

Hope this helps!

Posted: Thu Apr 17, 2008 3:09 pm
by 10047047
Hi Narcis,

Thanks for your modified example.

The checkbox for 500,000 sample points was used to demonstrate how the display time is affected by the different number of data points stored in the data series. When you have a large number of points recorded, Time label is updated much slower (it takes 5 or more seconds for the actual 1 second time). As the number of data shown on the screen is kept the same (BottomAxis->Maximum - BottomAxis->Minimum = 1000), why does it take longer to plot the same amount of data on screen when the data series has a large number of data stored? In other word, why is the time to scroll the traces by using the Chart->BottomAxis->Scroll(1, false) function affected by the number of data recorded? Is it due to some internal calculations? Can it be disabled?

Using DoScrollPoints will speed up display, but it deletes previous data when new data is added to the series. We need to record several days data during real-time monitoring.

Thanks

Regards

Xia

Posted: Mon Apr 21, 2008 10:39 am
by 10047047
Dear Narcis,

I uploaded a modified example project to your server and I have few questions regarding the display speed in zoom in/out speed test and run time speed test.

If you open a new child window and click the Speed Test button. It shows approx 0.5sec to plot 1000 points 61 times. But if you move the bottom time scrollbar to the end and then click the Speed Test button. It shows 1.8sec. Why does it take longer to plot the same amount of points for the end part of a large data series (1,000,000 points)? Please note the actual time may vary from PC to PC.

If you click the Start button and wait for the message box displayed. It shows approx. 13sec to record and scroll 100 points data. However if you scroll the chart by dragging the right mouse button inside chart space and then click the Start button. It only takes 3sec to record and scroll 100 points data. If you then click the Speed Test button and click the Start button again, it will take 13sec. Why does it vary?

The other question is that if you click the loNone checkbox (set Series->XValues->Order = loNone) and then click the Speed Test and Start buttons. It takes much longer to plot the chart. It was suggested in the real-time charting article to use loNone for fast charting, but the test results show opposite.

Your advice are very much appreciated.

Xia

Posted: Tue May 06, 2008 10:55 am
by narcis
Dear Xia,

Sorry for the delayed reply. We have been doing some tests here and the only way to speed up the application is deleting points in the OnTimer event and after adding points to the series, for example:

Code: Select all

for (int i=0; i < Chart1->SeriesCount(); i++)
{
Chart1->Series[i]->Delete(0,1);
}

Re: Access Violation during real-time monitoring

Posted: Fri Mar 19, 2010 2:37 am
by 12049531
Hi Narcis

I've tried to resolve this issue by doing the same thing Xia did but I am still getting the exception. Can you tell me when is the following method called and what does it do?

; Series.TFastLineSeries.CalcPosition (Line=0 - Offset=0)
; -------------------------------------------------------
0058E50D mov ebp, esp
0058E50F push ecx
0058E510 push ebx
0058E511 push esi
0058E512 push edi
0058E513 mov [ebp-$04], ecx
0058E516 mov esi, edx
0058E518 mov ebx, eax
0058E51A mov eax, [ebx+$0094]
0058E520 mov eax, [eax+$54]
0058E523 push dword ptr [eax+esi*8+$04] ; <-- EXCEPTION
0058E527 push dword ptr [eax+esi*8]
0058E52A mov edi, [ebx+$70]
0058E52D mov eax, [edi+$017C]
0058E533 call dword ptr [edi+$0178]
0058E539 mov edx, [ebp-$04]
0058E53C mov [edx], eax
0058E53E mov eax, [ebx+$009C]
0058E544 mov eax, [eax+$54]
0058E547 push dword ptr [eax+esi*8+$04]
0058E54B push dword ptr [eax+esi*8]

Re: Access Violation during real-time monitoring

Posted: Fri Mar 19, 2010 3:36 pm
by narcis
Hi QTech,

CalcPosition in TFastLineSeries is called when painting series values to calculate pixels position of each point in the chart.

If the problem persists please attach a simple example project we can run "as-is" to reproduce the problem here.

Thanks in advance.

Re: Access Violation during real-time monitoring

Posted: Mon Mar 22, 2010 8:39 pm
by 12049531
Hi NarcĂ­s

I've worked around the issue by removing the code that calls the TFastLineSeries.Repaint method from within the thread that repopulates the TFastLineSeries. Instead, I call DBChart.Repaint in the main form to redraw the chart.

Thanks.