12-17-2015 01:46 AM
Hello everyone,
I want to refresh the value of the Indicator Element in the main VI, I don't want to use the global variable, because of the race condition problem. So I build a functional global variable with control reference. Is it reliable and can I avoid the race condition?
I have attached two Test VI.
Thanks for your advice.
Solved! Go to Solution.
12-17-2015 02:47 AM
Hello Alre,
I'm not sure you understand the point of using FGV.
G mean global so the bahavior is close to a global variable. An FGV should contain is own control (variable).
You don't have to use reference to a specific object an change is value with property node. The race condition is preserve with the shift register and the check option "Non-reentrant execution of the VI. The shift register store the last variable value, and the Non-reentrant execution only provide acces to one caller at time.
Store reverence in your shift register didn't preserve your variable to be written by several sources at the same time.
You shoudl use a cluster connected to your shift register and insert all the data you want to share.
Here an example.
12-17-2015 03:23 AM
Hallo Sabri,
Thanks for your reply. Ihave built an project with OOP and I want to use the FGV in the Child method to refresh the value in the main VI. As you see, I can bundeln the state and alarm in a cluster.
My LabVIEW version is 2011, can you post the code with version 2011?
regards.
12-17-2015 05:44 AM
Personally, I use User Events to send the data to the main VI and then it can update the indicator. This usually work extremely well since most GUI VIs are using an Event Structure anyways.
12-17-2015 09:22 AM
Thanks for your reply. I have also built some Test VI with user event to transfer data. As Test VIs, the control reference and the user event all work very well. So I just don't know which is better and more reliable. The old program used a lot of global variable and lokale variable. I want to avoid using them in the new program.
12-17-2015 09:48 AM
A major issue with using the control reference is that each time you write to the property node, you are forcing the front panel to be redrawn. This can slow down your code considerably.
Another benefit of the User Event is that you may find another process that needs that data and all you will have to do is register for that User Event. Every place that is registered for the event will see it.
12-17-2015 11:15 AM
Do you have a sample vi where you have done this. I'd like to look it over. It sounds simpler than what I've been doing.
12-17-2015 11:17 AM
I hate it when I do that...
@ crossrulz
Do you have a sample of the user event passing data and registering in multiple places?
12-17-2015 11:20 AM
Hi Patrick,
You can take a look at the DQMH toolkit on the tools network for a nice use of User Events
12-17-2015 12:30 PM