取消
显示结果 
搜索替代 
您的意思是: 

Refnums as Global Variables

已解决!
转到解答

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 项奖励
1 条消息(共 8 条)
5,037 次查看

That should work, yes.

/Y

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

Qestit Systems
Certified-LabVIEW-Developer
0 项奖励
2 条消息(共 8 条)
5,034 次查看
解答
接受人 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.



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
3 条消息(共 8 条)
5,029 次查看

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

0 项奖励
4 条消息(共 8 条)
4,974 次查看

@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 项奖励
5 条消息(共 8 条)
4,967 次查看

@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.



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
6 条消息(共 8 条)
4,964 次查看

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 项奖励
7 条消息(共 8 条)
4,913 次查看

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.



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
8 条消息(共 8 条)
4,907 次查看