From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Data transfer from one-to-N asynchronous VIs

Solved!
Go to solution

Hello, 

 

I am trying to implement a program where I want to let multiple asynchronously running VIs read the same data from a single VI that reads from an instrument via GPIB. 

I am under the impression that using a notifier for one-to-many communication might cause data loss if the VIs aren't properly synchronized, and have been warned away from using Global Variables, so I was trying to implement a kind of queue-based message handling system (which I am pretty new to).

 

The list of VIs which need to access the data will change during operation, so I am wondering if there was some nifty way to accomplish this using queues; will I have to programmatically obtain a new queue for each new VI that needs data? 

 

Thanks! I'm pretty new to this, so I appreciate any help. 

0 Kudos
Message 1 of 6
(3,167 Views)
Solution
Accepted by topic author smallmediumlarge

The easiest thing for you would probably be a user event - you define the event in one place and each VI registers to recieve it. Once it does that, it will essentially create its own queue.

 

There's a good presentation on events here, although keep in mind it was not meant as a primer for events. You can find the code for it here - https://github.com/wirebirdlabs/LabVIEW-User-Events-Tips-Tricks-and-Sundry/archive/master.zip


___________________
Try to take over the world!
0 Kudos
Message 2 of 6
(3,151 Views)

Great, thank you!

0 Kudos
Message 3 of 6
(3,140 Views)

Thank you for your previous answer, it helps a lot, although I was unable to download the video for some reason. 

 

I was wondering if you could answer a follow-up question. 

 

Let's say I wanted to expand my application to have multiple data-taking VIs, so some of the processing VIs would need to read data from multiple places, so I would not be able to prespecify which events each VI would need to register before operation. 

 

Is there an easy way to dynamically register for a number of user events that are fed programmatically to a VI during run-time, and not pre-specified?

 

Thanks a lot!

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

The syntax LV has for dealing with events is actually quite permissive, although this isn't obvious at first sight. You can do things like register for the same event on a cluster of references. You can create multiple registrations, bundle them and wire that bundle into an event structure. You can change the events you're registered for by calling the Register for Events node again and feeding it the structure's registration reference.

 

Specifically in your case, it's possible to wire an array of user events into the register node. I haven't checked how this behaves, but because the syntax is valid I'm guessing this will simply let you get all the events you registered for in the same case. You might need to add some ID info to the data itself to identify where it came from.

 

And like I said, you can reregister for other events by adding their references to the array, if that's something that you need. Note that the event handling mechanism has some opacity to it, so you should verify that this works correctly before you build too much on it. For instance, you should probably verify that reregistering for the events doesn't cause events currently in the queue to be flushed or other things of that nature.

 

I'm not sure why you can't download the video (maybe the FTP download is blocked by your IT people), but you should make an effort, because it has a lot of important details. You can find details on it here - https://lavag.org/topic/17040-niweek-2013-videos/   It's Jack Dunaway's NIWeek 2013 presentation.


___________________
Try to take over the world!
0 Kudos
Message 5 of 6
(3,062 Views)

 

 

I tested this method with a couple of simple test VIs, and it appears to work. 

 

Thanks! This is exactly what I need. 

0 Kudos
Message 6 of 6
(3,035 Views)