LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reference Functional Global Variable

Solved!
Go to solution

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.

0 Kudos
Message 1 of 25
(7,239 Views)

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.

Sabri JATLAOUI - Certified LabVIEW Architect - Certified LabVIEW Developer
0 Kudos
Message 2 of 25
(7,217 Views)

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.

0 Kudos
Message 3 of 25
(7,207 Views)
Solution
Accepted by alre

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 4 of 25
(7,190 Views)

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.

0 Kudos
Message 5 of 25
(7,157 Views)
Solution
Accepted by alre

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 6 of 25
(7,147 Views)

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.

Glad to answer questions. Thanks for any KUDOS or marked solutions 😉
0 Kudos
Message 7 of 25
(7,127 Views)

I hate it when I do that...

@ crossrulz

Do you have a sample of the user event passing data and registering in multiple places?

Glad to answer questions. Thanks for any KUDOS or marked solutions 😉
0 Kudos
Message 8 of 25
(7,122 Views)

Hi Patrick,

 

You can take a look at the DQMH toolkit on the tools network for a nice use of User Events

0 Kudos
Message 9 of 25
(7,117 Views)
You can check here too...

http://www.notatamelion.com/2014/10/23/making-udes-easy/

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 10 of 25
(7,096 Views)