LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can the output of a Generate Occurrence be passed in Local/Global Variable?

Can the output of a Generate Occurrence function, which is a refnum, be passed in Local/Global Variable so that it does not need to be wired to all parties directly?

 

Can more than one party be waiting on the same Occurrence and will all waiting function be released together?

 

 

 

0 Kudos
Message 1 of 10
(3,065 Views)

Using locals or globals to avoid wires is just a very bad habit to get into.

 

Yes, you can have multiple wait on occurances and they will complete at the same time.

0 Kudos
Message 2 of 10
(3,060 Views)

Wiring data together is good if the objects are located in the same vicinity and in the same VI.

 

Local and Global variables are good when the objects are not easily represented on the same block diagram or are in different VI's

 

Answer was not given:

Can the output of a Generate Occurrence function, which is a refnum, be passed in Local/Global Variable so that it does not need to be wired to all parties directly? Is this possible?

0 Kudos
Message 3 of 10
(3,054 Views)

 


@dbaechtel wrote:

Wiring data together is good if the objects are located in the same vicinity and in the same VI.

 

Local and Global variables are good when the objects are not easily represented on the same block diagram or are in different VI's

 

Answer was not given:

Can the output of a Generate Occurrence function, which is a refnum, be passed in Local/Global Variable so that it does not need to be wired to all parties directly? Is this possible?


Wiring is always the best, even if they are not in the same vicinity. Not doing a clean job of wiring is just lazy.

 

0 Kudos
Message 4 of 10
(3,049 Views)

Answer was not given:

Can the output of a Generate Occurrence function, which is a refnum, be passed in Local/Global Variable so that it does not need to be wired to all parties directly? Is this possible?

 

I am not worried about whether it is bad form or not, as yet. That is for me to decide on a case by case basis.

0 Kudos
Message 5 of 10
(3,046 Views)

It looks like you can create an indicator of an occurrence wire.  So sure, I guess you can pass it through local variables.

 

The best way to know is to try it.

 

But don't get an attitude about the answers you were given.  Dennis is an experienced LabVIEW programmer with years of experience warning you that it is not a good idea.  You may think it is okay and can decide on a case by case basis, but I bet that once you decide it is okay in a particular case, it will be just a matter of time before it bites you and you realize it was a bad idea.

0 Kudos
Message 6 of 10
(3,035 Views)

@dbaechtel wrote:

Answer was not given:

Can the output of a Generate Occurrence function, which is a refnum, be passed in Local/Global Variable so that it does not need to be wired to all parties directly? Is this possible?

 

I am not worried about whether it is bad form or not, as yet. That is for me to decide on a case by case basis.


Yikes! That is not a very good way to learn.

 

Anyways, to avoid any more bold emphasis on words, I will answer your question. Locals can only be linked to controls/indicators not individual wires. If you want to get the effect of a local/global variable with a wire value, search the forum for action engines or functional globals. Those will work for passing a wire value between threads.

 

That said, what are you trying to use occurences for? There may be (and probably is) a more accepted way to implement what you are trying to do instead of using local variables

0 Kudos
Message 7 of 10
(3,032 Views)

I happen to agree that in this case Dennis' answer was lacking. Wiring is not always possible (e.g. if a VI is launched dynamically) and categorically saying "globals are bad" without explaining leads to people not listening to you, regardless of the actual danger in using this method.

 

In any case, I assume RF's assumption is correct and wiring the value of an occurrence into a global will work, since an occurrence is a global resource. As he suggested, trying it is the best way to know. Personally, I never used occurrences (there are other synchronization tools which are easier to use and more powerful), but you can have a look at Ben's nugget here for an example of cross-VI use (which uses wires to pass the occurrence, incidentally)


___________________
Try to take over the world!
0 Kudos
Message 8 of 10
(3,021 Views)

I don't know if it's of any use, but   wrote a nugget on passing around occurrences.

 

edit: I just noticed tst sneaking the link into his post

_____________________________
- Cheers, Ed
0 Kudos
Message 9 of 10
(3,002 Views)

@dbaechtel wrote:

Answer was not given:

Can the output of a Generate Occurrence function, which is a refnum, be passed in Local/Global Variable so that it does not need to be wired to all parties directly? Is this possible?

 

I am not worried about whether it is bad form or not, as yet. That is for me to decide on a case by case basis.


Yes it can be wired and passed via local/global but there are better ways.

 

Also keep in mind the Occurnce will only be valid as long as the creator of it is alive.

 

As linked above this Nugget talks about Occurneces.

 

THis Nuget talks about sharing between threads using Action Engines.

 

I believe your question has been answered and you have been double-Nuggeted.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
0 Kudos
Message 10 of 10
(2,980 Views)