LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass data between "asynchronous" VIs

Hi!

 

I am looking for the right way on how to solve the following problem. Maybe you can show me what I should look into or what words to search for:

 

Let's imagine I have two VIs, A and B. Vi A is runnning and at some point starts Vi B through the use of a static VI reference and an invoke node. So, now both Vis are running what I would call "asynchronously". Neither Vi is waiting for the other Vi, they are independent. Now in Vi B data is obtained. This data - lets call it Data B - needs to be transferred to Vi A, when A needs it. To make things more complicated, Vi B can close at any time independently of Vi A. So, lets say Vi B produces Data B and closes. Vi A does something (whatever the user wants it to do). This is important, Vi A must not wait for Data B (It takes it when it needs it) . Then at some point, Data B is needed in Vi A. Vi A now needs Data B from the already closed Vi B...

How would this be possible to implement?

All I can think of is using a rather simple approach: Whenever Data B from Vi B gets available, write it to a text file on disk. Then, when Vi A needs the data at some point in time, Vi A can read the Text file and work with Data B even if Vi B is already closed. Now this might work for small things but if things get bigger (lets say e.g. huge image data) this might slow things down.

Is there a tool in Labview which allows for efficient data transfer between independent Vis even if the producer Vi (here Vi B) has been closed in the meantime? Maybe a tool which leaves thins in memory rather than on a text file on disc?

 

I looked at notifiers and queues and such but am a little puzzled if the can do what I need (E.G. The consumer - Vi A - waits for a notifier to occur which is not allowed in my example...). Could you point me in the right direction?

 

Ultimately, I want to have a main program and several "satellite" Vis which run at their own speed and produce data during their runtime. Then the main program picks up the data whenever the main program is ready to process the data from the satellite Vis. I am sure this is a rather usual request for a bigger Labview project. I hope I could explain my problem successfully... 🙂

 

Thanks a lot for your time!!!!

 

Christian

0 Kudos
Message 1 of 4
(6,913 Views)

Take a look at this. Queues are a very efficient way of transfering even large amounts of data. An enqueue just sends a pointer to the memory location of the data and the dequeue just receives this pointer. It doesn't make any copies.

=====================
LabVIEW 2012


Message 2 of 4
(6,908 Views)

Hi Steve,

 

thanks for your prompt reply. I will look into the link and queues.

 

Thanks a lot!

 

Christian

0 Kudos
Message 3 of 4
(6,896 Views)

I agree with Steve, Queues are definately the way to go, and they meet all your criteria. They can be created in your 'A' VI and the data will remain in there until A comes around to get it. If there is as yet no data available, the timeout can trigger and A moves right past. As long as A maintains the Queue reference, B can load and unload many times, and still write data into the Queue that is available in the order it was written. The queue memory space, as pointed out, serves as the 'satellite' VIs you mentioned, until explicitly destroyed by VI 'A'

 

The link above is the right way to do it, with proper Object Oriented classes and wrappers etc., what I described can be achieved with just the queue functions on the palette, but will be more rough and ready, with less data hiding or data protection.

 

-Mello


Data Science Automation

CTA, CLA, CLED
SHAZAM!
Message 4 of 4
(6,893 Views)