LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Refnums as Global Variables

Solved!
Go to solution

Hello all,

So I have a slightly odd question that I cannot seem to answer with available resources. Is there any reason I cannot write a Data vale reference refnum or notifier refnum to a global variable to be able to access it elsewhere in a project without calling the new DVR vi or obtain notifier VI? 

0 Kudos
Message 1 of 8
(3,920 Views)

That should work, yes.

/Y

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 8
(3,917 Views)
Solution
Accepted by topic author theSTEMkid

@theSTEMkid wrote:

Hello all,

So I have a slightly odd question that I cannot seem to answer with available resources. Is there any reason I cannot write a Data vale reference refnum or notifier refnum to a global variable to be able to access it elsewhere in a project without calling the new DVR vi or obtain notifier VI? 


Nope.  I have done it.  Though, I like to keep my Notifiers in an Action Engine where I can have a little more control over 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
Message 3 of 8
(3,912 Views)

Thanks so much for the answer! Could you explain what you mean by keeping notifiers in an action engine?

0 Kudos
Message 4 of 8
(3,857 Views)

@crossrulz wrote:

@theSTEMkid wrote:

Hello all,

So I have a slightly odd question that I cannot seem to answer with available resources. Is there any reason I cannot write a Data vale reference refnum or notifier refnum to a global variable to be able to access it elsewhere in a project without calling the new DVR vi or obtain notifier VI? 


Nope.  I have done it.  Though, I like to keep my Notifiers in an Action Engine where I can have a little more control over it.


I've gone both ways as well.  I like the AE because it's nice and tidy; I like the global way because it's easy to set up.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 5 of 8
(3,850 Views)

@theSTEMkid wrote:

Could you explain what you mean by keeping notifiers in an action engine?


1. Go read the article I linked earlier.

2. Now imagine one with a Obtain Reference (will create if necessary), Send, and Close states.


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
Message 6 of 8
(3,847 Views)

After reading the article you linked, very informative by the way, I took a stab at making a notifier action engine. However it doesn't seem to work as expected.  Would you mind taking a glance at the attached code?  I assume you can still use action engines to handle notifiers in parallel loops right?

0 Kudos
Message 7 of 8
(3,796 Views)

You made the classic mistake.  Don't worry about it, I did the same when I started down this path.

 

The point of an Action Engine is that it is non-reentrant so that the same reference can be used everywhere.  However, this also means that only 1 process can be running that VI at a time.  So when you have one process in the Wait case, nobody else can send anything since the VI is being blocked.  The solution is actually quite simple: Do not have a Read/Wait action.  Instead, whoever needs to read the notification should use the Obtain Reference case to get the Notifier reference and then use the Wait For Notification outside of the AE.  You will need to add an indicator for the Notifier reference to your AE.


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
Message 8 of 8
(3,790 Views)