954,558 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

displaying labview graph on vb6 form

hii all
yet another question from me..
i have written a code in vb6 to call a labview7.1 vi and run it. the labview code acquires data and plots the data continuously as long as the program is running. now i want this graph to be plotted on vb6 form.
any ideas how i can do it?
thanks.

Shefali
Light Poster
36 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

Eak, does labview write a .txt file, or some means in which VB can read the data?

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

yea labview can write a text file or excel data file.

Shefali
Light Poster
36 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

Then, if you can past an example of that file.... I can see about how to go about reading it. What I'm guessing you'll have to do, is have labview write a file (either one, text or excel, vb can work with both) and then get a list of points out of that file, and plot them using pset or something.....

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

ok i got ur point.
in that case i wud like, as the labview program wud continuously add/save data to a excel/text file... vb wud continously read this file and plot the graph in its form or mschart control or whatever is suitable.
now i dont think i know how to do it. i guess i can use some array and save some data points in it and keepon updating that. i m not sure though. can u give me any example of plotting realtime graph in vb?
the excel/text file have 3 columns first one time, 2nd column depth and the third is distance. now depth and distance needs to be plotted in y axis and time in x axis.
the data file can be really large.

Shefali
Light Poster
36 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

guys... can u plz give me some ideas about this real time plotting thing.
i have a text/excel data file where data is being continously added. i want to plot this data wrt time on a vb form.
i m stuck.. plz help me. thanks.

Shefali
Light Poster
36 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

Is the textfile constantly being "ADDED" to, or is it constantly being UPDATED (there is a difference, ya know... added to means that it leaves the data alone that's already in the file, and just adds more data to the end, while updated means that it's possibly changing the data already in the file)

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

no its just adding the data..

Shefali
Light Poster
36 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

So, what you'll need to do, is open the text file, and read in the data. Keep a count of how many lines there are. Then, in a loop, read any added data (any lines greater than the last read) and plot them. Do this over and over until the file is done updating, and you should be good to go. Something to keep in mind, is that file is going to get big probably, so... you may want to check it's size every so often, and if it reaches a certain size, delete the file, and reset your count. I don't know what kind of effect that's going to have on labview though..... it might get pretty pissed about you deleting the file.....

Is it necessary to actually have the VB app plot the data, or would having the VB app kidnap the graph area work?

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

well i have checked with labview and found that labview doesnt allow vb to get its graph. that is the graph object of labview isnt accessible to vb.
i understand what u said abt the vb coding stuff... but can u give me some similar example code.. it seems to me pretty daunting (for my capabilities).
thanks.

Shefali
Light Poster
36 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

You'll need to post the text file (a portion of it) so I know the format we are dealing with.....

FYI: I wasn't talking about asking for their permission. I was actually talking about taking it..... without permission. So that Labview would still be running, and it would still be plotting the things to the graph, but the graph would be kidnapped into the VB form.

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

ok i will post the data file.. just give me a few mins.
and regarding the kidnap thing.. that was exactly my idea to begin with... but cudnt find a way to do it. if that cud have been done.. wow.. all probs solved.

Shefali
Light Poster
36 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

First, you'll need to get the class name of that window.... I have a program that does this: http://www.aftermath.net/~coma/downloads/getclass/getclass.zip , once you download and install that, run the "Getclass" program, and it will show you a textbox and a button. The textbox will contain the windows current hWnd (The number assigned to it by windows), The class name of the window, The caption (title) of the window, and it's thread id. The only crucial one that we need is the Class, but if it has a caption, then both would be even better. So, once you are running the program, hold your mouse over the graph, and write down the class name (and caption if applicable) and post it here..... then we'll write code to do it.

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

here is the text file. the values are seperated by comma. the first data is date and isnt needed. now the second is time of measurement and the rests are some measurement value. new data will be added continously to this file. now i need to plot the 3 data after the time (ie in fisrt row: 4.8, 135 and 6.2) i dont need the last data for plotting.
if needed the time of measurement can include seconds as well so that there wudnt be multiple data for a single time.
labview can also save the data as excel file.

Attachments labview.txt (12.47KB)
Shefali
Light Poster
36 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

thanks comatose for taking so much interest and helping me out. i really appreciate this. i have run the program and here is what i got:
hwnd: 13239932
class: LVDChild
Caption: Acquire Data and Plot 2.vi Front Panel
Window Thread: 2912

Shefali
Light Poster
36 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

Just to make sure, that's JUST the graph that we want to steal right? Not it's parent, or anything like that, the mouse directly over the plotting area, right?

Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

actually i wud like only the graph to steal.. but ur program doesnt differentiates between the graph or the labview window(front panel). whenever i take the mouse over the labview window(front panel) it shows the same caption and class.
in that case wud be the stealing of only the graph possible?

Shefali
Light Poster
36 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

sorry forgot to add this in the previous post:
if capturing the graph isnt possible.. then i wud be glad even to capture the complete front panel of the labview.. only thing is that it needs to show the continuous realtime plot of the data.

Shefali
Light Poster
36 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

K, Try this and let me know what happens.

Attachments GrabPlot.zip (1.77KB)
Comatose
Taboo Programmer
Team Colleague
2,910 posts since Dec 2004
Reputation Points: 361
Solved Threads: 215
 

i run ur code. i first started labview manually and run the labview program. then i run ur vb code. when i run the vb code it displays the labview window infront of the form (not on the form) as a seperate window.
what i though after running the code is it puts the labview front panel at the foreground. am i missing something?

Shefali
Light Poster
36 posts since Apr 2006
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You