06-02-2016 09:03 AM
Hello,
Here is simplified realisation of a real setup.
Here are keypoints:
Here are keypoints of realisation:
Is such approach the only one to communicate between VIs ?
Thanks
Pavel
06-02-2016 09:07 AM
Pavel,
you should learn about queues and architectures based on queues (Producer/Consumer, Queued Message Handler, ...).
No variable needed at all!!!!!
Norbert
06-02-2016 09:22 AM
Norbert_B a écrit :Pavel,
you should learn about queues and architectures based on queues (Producer/Consumer, Queued Message Handler, ...).
No variable needed at all!!!!!
Norbert
Thanks Norbert,
It seems that Producer/Consummer architectures is for communicate data between loops that run inside the same VI, whereas in my case the two loops that run in different VIs.
At least I understood Producer/Consummer concept in this way while trying to create new VI from template.
Or I missed something
06-02-2016 09:26 AM
@Pavel_47 wrote:It seems that Producer/Consummer architectures is for communicate data between loops that run inside the same VI, whereas in my case the two loops that run in different VIs.
At least I understood Producer/Consummer concept in this way while trying to create new VI from template.
Or I missed something
You missed something. Imagine the consumer loop being in a subVI and you have your situation.
You should also look into the Queued Message Handler, which is a very useful architecture. Just do a search on the forums. There have been plenty of discussions about them lately.
06-02-2016 09:45 AM
crossrulz a écrit :
@Pavel_47 wrote:It seems that Producer/Consummer architectures is for communicate data between loops that run inside the same VI, whereas in my case the two loops that run in different VIs.
At least I understood Producer/Consummer concept in this way while trying to create new VI from template.
Or I missed something
You missed something. Imagine the consumer loop being in a subVI and you have your situation.
You should also look into the Queued Message Handler, which is a very useful architecture. Just do a search on the forums. There have been plenty of discussions about them lately.
Here is producer-consumer template
In this single VI example 2 loops are connetcted by queout wire.
In the case when 2 loops are located in different VIs how they are connected ?
06-02-2016 09:46 AM
You can pass the queue reference per conntector pane. Or use named queues and each VI obtains the same queue.
Norbert
06-02-2016 10:16 AM
If you don't want to use a producer-consumer architecture, you can instead implement functional global variables and use those.
06-02-2016 10:24 AM
@Daikataro wrote:If you don't want to use a producer-consumer architecture, you can instead implement functional global variables and use those.
Might as well use Global Variables if you go that route. FGVs still have the race condition issues and are slower.
06-02-2016 10:32 AM
Really? I thought the reason to go FGV was specifically to avoid race conditions. How and why is that still an issue with FGV?
06-02-2016 10:44 AM
There is a term called "critical section". If the FGV does not only contain (encapsulate) the data but also the critical section, the FGV is thread save and won't create race conditions.
However, experience shows that most developers do not include the critical section in the FGV or this is not possible at all. In that cases, Tim's statement is correct: FGV does not protect from race conditions and are simply a (negative) performance impact.
Norbert