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.

Recommended Answers

All 25 Replies

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

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

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.....

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.

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.

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)

no its just adding the data..

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?

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.

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.

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.

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.

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.

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

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?

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?

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.

K, Try this and let me know what happens.

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?

if you minimize the VB form, does it minimize the labview window too?

no.. it doesnt

Hmn.... for some reason it's not setting the labview parent...... I don't have labview, so I can't test it, but the same code works for notepad (if I change the class to "Notepad", and then run notepad).... maybe we'll have to go to the text file way.... I can give you code to open the file, and read in the values, and I can give you info on PSET, but I don't know much about graphing or plotting, so after that you will be on your own..... I wish I knew why it won't kidnap labview :(

hmm.. ok i was really upbeat abt getting this kidnapping thing done. bad for me it didnt work.
yea maybe u r rite.. maybe i have to go via the textfile/excel file way. i can plot a graph from given values.. but i m not sure how to get this realtime thing going.
hope ur examples wud help me.
thanks a lot comatose.

comatose.. can u plz give me some code example of graphing from text/excel data file. thanks in advance.

why not pass the data over local host? TCP/IP....

it would solve this text file issue as that isn't a good way to do it.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.