trouble changing DATA_3DR real-time plot to DATA_3DS

Q&A for Visual Basic, Visual Basic .NET, and PowerBasic developers using DPlot
Post Reply
mikeb
Posts: 36
Joined: Wed Aug 18, 2004 5:23 pm

trouble changing DATA_3DR real-time plot to DATA_3DS

Post by mikeb »

Hi David,

I am currently streaming live data to a DPLOT windows to create a 3DR contour surface (shaded band). My code is somewhat based on example BTEST3. It works well, but as more data is added, the more time it takes to draw the surface.

I think a simple solution for me is to just draw a scatter plot in real-time instead, then convert it to shaded band (add surface) after completion.

I thought I could just replace this line which works fine

Code: Select all

ret = DPlot_AddData(DocNum, DATA_3DR, ptctr, 1, j, Zout(0))
with this line

Code: Select all

ret = DPlot_AddData(DocNum, DATA_3DS, ptctr, 1, j, Zout(0))
but it doesn't work as expected. The function returns -16395 the first time, then returns -16390 for every cycle afterwards.

I am first creating a blank plot with

Code: Select all

DocNum = DPlot_Command(0, "[FileNew(3)]")
Using Evisive branded version 2.3.2.7
Any suggestions?
thanks.
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Mike,
Unfortunately DPlot_AddData will only work for adding points to an existing 3D scatter plot. And there is not a way to create a blank document set up to accept DATA_3DS points. FileNew(3), for example, creates an empty plot set up to receive random 3D points for a surface plot.

The only way at present to make DPlot_AddData work with a 3D scatter plot is to first create a document (using DPlot_Plot or whatever) with 3D scatter plot points, and then use DPlot_AddData for additional points.

I need to add a new setting for FileNew to create a blank 3D scatter plot document.
Visualize Your Data
support@dplot.com
mikeb
Posts: 36
Joined: Wed Aug 18, 2004 5:23 pm

Post by mikeb »

Using DPlot_Plot can I set up an empty plot with zero data points? If not, I suppose I can create a new plot with one data point at (0,0)? I have some confusion on DPLOT structure regarding maximum number of data points. Do you have a real-time example using scatter plot? Any language would suffice.
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Yes, I do have an example. But this is now moot. I've changed the FileNew command to include support for creating an empty 3D scatter plot, and DPlot_AddData will now work as expected.

I'll e-mail you with a link to an updated EVImage tomorrow.
Visualize Your Data
support@dplot.com
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Mike,
You've got mail.
Visualize Your Data
support@dplot.com
mikeb
Posts: 36
Joined: Wed Aug 18, 2004 5:23 pm

Dplot_AddData with 3D scatter plot

Post by mikeb »

Thanks, David.
I just started with it.
Creating a 3D scatter plot with FileNew(7) and the first several Dplot_AddData statements appear to work as expected, then DPLOT crashes and reopens full screen.
It seems to do this after a random amount of iterations. Sometimes immediately - sometimes after several minutes.

I am using the line of code to update:

Code: Select all

ret = DPlot_AddData(DocNum, DATA_3DS, ptctr, 1, j, Zout(0)) 


The return value when responding properly is 1, but changes to -16395 for one cycle, then -16390 for remaining cycles when DPLOT restarts - surely b/c DocNum is now invalid.

Am I sending corrupt data to cause DPLOT to crash? It doesn't appear corrupt to me, and this didn't occur when sending data to 3DR surface.

Any specific setting differences between 3DR and 3DS that I may be configuring incorrectly?
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

VB with the real-time examples had a big problem with overrunning the DDE management library (or something). See the btest3 and vbnettest3 examples. They both set a "Busy" flag that gets reset once the call to DPlot_AddData returns, and refuse to do anything until Busy=0.
Visualize Your Data
support@dplot.com
mikeb
Posts: 36
Joined: Wed Aug 18, 2004 5:23 pm

Post by mikeb »

The return value from DPlot_AddData was 1 until DPLOT crashed, and it returned -16395 on the call that crashed it.
How do I know when its busy before it crashes?
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

That's a timeout error, which is a little odd in this case. All of the dplotlib functions will wait up to 20 seconds before giving up, and you'd surely notice a 20 second delay.

My best guess is your code is calling DPlot_AddData multiple times before it returns. Tracking that sort of thing is difficult (is this me or is this the other me or the one after that?) and the best way to avoid associated problems is to not let it happen. Something like:

Code: Select all

	if(busy) return;
	busy=1;
	ret = DPlot_AddData(....);
	if(ret < 0) // stop and get out, something is wrong
	busy = 0;
Visualize Your Data
support@dplot.com
mikeb
Posts: 36
Joined: Wed Aug 18, 2004 5:23 pm

Post by mikeb »

I took the easy way out. I am using the same XY plot code that already works well for me.

The surface or scatter plot wasn't necessary for realtime feedback to the user - it was just flashy. Actually turns out the XY plot is better for user feedback during use.

I'll keep the "busy" part in mind in case I run into more errors.
mikeb
Posts: 36
Joined: Wed Aug 18, 2004 5:23 pm

Post by mikeb »

In my VB6 application sending data to the 3D Scatter plot gives me timeout errors quicker than when sending data to a 3D Surface plot.

It appears I can eliminate the timeout error sending to 3D surface plot by reducing how often I send data.

Is the timeout error related to how often the addData calls are made, or how much data is being transferred?

In other words, can I call DPlot_AddData twice as often with half the number of data sets?
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

In other words, can I call DPlot_AddData twice as often with half the number of data sets?
With a 3D scatter plot it should make little or no difference. With multiple calls there is a bit of additional overhead, but I would think this would be small relative to the time required to draw the plot.

You may save enough time to prevent timeout errors by turning off anti-aliasing with GeneralOptions(0x00000020,0). You can later turn that back on with GeneralOptions(0x00000020,0x00000020).

With a 3D surface plot you'll definitely be better off minimizing the number of calls and sending bigger chunks of data. Whether you're adding one point or 100,0000, the entire surface must be triangulated again, and triangulation is the biggest bottleneck.
Visualize Your Data
support@dplot.com
mikeb
Posts: 36
Joined: Wed Aug 18, 2004 5:23 pm

Post by mikeb »

Whether you're adding one point or 100,0000, the entire surface must be triangulated again, and triangulation is the biggest bottleneck
That was my reason to try the Scatter plot. I am turning off Anti-aliasing, and deferring MinMaxCheck

In my polling application, I am getting about 15 data points per sample, and am getting about 5-6 samples/sec. Sending every sample packet to a 3D contour plot keeps up until the number of data points to be triangulated starts to slow things down.

Sending the same to a 3D scatter plot will give me timeouts after 2-10 seconds. If I only send every 3rd packet(roughly 2 calls/second, sending 15 data points each time), I can go longer before timeouts occur, but they do still occur. It appears in my app that the 3D scatter plot is slower than 3D surface, but that makes no sense.

I must be doing something odd. Any suggestions on what to check?
mikeb
Posts: 36
Joined: Wed Aug 18, 2004 5:23 pm

Post by mikeb »

I'm now using a simpler solution using the 3D surface plot for my application. The visual effect is better than Scatter plot anyway.

I am only updating once every few seconds. DPlot has plenty of time to re-triangulate before getting the next data set. I do not need the sub-second updating of the plot like I was attempting.

My data sets won't be large enough for triangulation time to be an issue.
And my update rate is proportional to overall plot size, so larger images will update less frequent with larger data sets each update.

Snappy performance now.
Thanks for the support.
mike
User avatar
DPlotAdmin
Posts: 2312
Joined: Tue Jun 24, 2003 9:34 pm
Location: Vicksburg, Mississippi
Contact:

Post by DPlotAdmin »

Thanks for letting me know. I'm glad it is working well now.
Visualize Your Data
support@dplot.com
Post Reply