LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Editing (or "turning off") single dynamic event registration in cluster

I have a VI that has a few different user events registered to it in two different groups- some are set up in a subVI and are bundled together, and some are created on the block diagram for use within that VI.

 

I need to be able to selectively "turn on" or "turn off" the external user events, as sometimes this VI needs to subscribe to them and other times not. Normally, this is done by using the Register For Events node on the inside Dynamic Events terminal, and modifying the reference to which that event points. This works fine, except for when the incoming user events are bundled. I can't seem to find a way to edit just ONE of the clustered elements instead of all of them. The Register For Events function populates with a datatype of a clustered pair of references.

 

What I'd like to do is wire in a Constant reference when I don't need to listen to anything, then wire in a specified User Event when I do need to listen to that event queue.

 

How do I go about changing just ONE of the bundled references? I have attached a snippet showing what I mean. Thanks for the help.

 

Editing dynamic event registrations.png

 

(As an aside, are the shift registers in this required, or would it work to stop after the Register for Events node inside the Event structure?)

0 Kudos
Message 1 of 9
(3,763 Views)

Here is how I do it.

 

For my case, I have a user event and a DAQmx event in the sluster. At times when the DAQmx task changes I need to update the event. The image belows shows my method. It works and I do not appear to have any reference leaks.

 

Cheers,

mcduff

Snap8.png

 

 

 

0 Kudos
Message 2 of 9
(3,712 Views)

Just use an unbundler (or Unbundle by Name) on the inside Dynamic Events terminal.

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 3 of 9
(3,710 Views)

Paul, I'm not certain I'm following you- I already have an Unbundle By Name on the primary event registration wire. The problem is that when I unbundle it I get two more Event Registration Refnums; one of the two came from a bundled pair of user events. I need to be able to change just ONE of those, but the Refnum that comes from the Unbundle By Name contains both of them, and I can't find a way to overwrite just ONE of the refnums in that bundle.

 

In the snippet I posted, try to find a way to overwrite "Listener Event" with something without changing "MyOtherEvent" inside the Event structure. I can't find a way to do that.

 

Mcduff, I am trying to do something similar, but again I can't actually get at the single User Event Registration refnum inside the cluster. If I wanted to change the "Start Listening" event I could do that easily, as the Register For Events presents a terminal to write a single Event Registration Refnum, but when I do it on a clustered input I can only write the whole cluster- not an individual element, and I can't find a way to *read* the Event Registration Refnum contents.

 

0 Kudos
Message 4 of 9
(3,700 Views)

Use unbundle/bundle by name.

Snap9.png

 

 

 

0 Kudos
Message 5 of 9
(3,681 Views)

OK.  Just a little extra wiring:

redo.png

"If you weren't supposed to push it, it wouldn't be a button."
0 Kudos
Message 6 of 9
(3,672 Views)

Edit: Paul replied while I was typing this out, this is in response to mcduff's post:

 

That's still not quite what I'm trying to do. "Register for Events" can take a bundle of events, which generates a single Event Registration refnum. That refnum can then be bundled with more refnums, all of which can be fed into the dynamic input terminal. Your method lets me access a single event registration refnum that was bundled with other event registration refnums, but not a single event that was bundled with other events BEFORE being registered. Editing dynamic 2.png

 

Regarding Paul's comment, I had stumbled across that this morning, but was hoping to not have to run two wires from my subVI. It works in this case since I'm only changing one event, but if I had to change BOTH events then I would have to keep up with all of my events manually in a shift register or FGV or something, which is a pain and has potential for silly programmer mistakes. Assuming I have to edit Event A *and* event B above, then I'd end up resetting one when I set the other unless I kept track of it separately. It would certainly *work* but it's not very tidy; what we need is a way to "read" the events tied to an event registration refnum, instead of only writing them.

0 Kudos
Message 7 of 9
(3,669 Views)

For anyone reading this in the future, I found an older discussion from 2010 with someone suggesting the same "read" version of Register for Events:

 

https://forums.ni.com/t5/LabVIEW-Idea-Exchange/Don-t-expose-the-Refnum-to-a-pre-registered-User-Even...

 

Looks like it's still not something that can be done 😕

0 Kudos
Message 8 of 9
(3,653 Views)

I ended up throwing this idea into the Idea Exchange. I know you can work around it with shift registers or FGV's or similar but those all introduce new points of failure without giving you any functionality in return (when compared to being able to just "read" the refnum).

 

https://forums.ni.com/t5/LabVIEW-Idea-Exchange/Allow-quot-Register-for-Events-quot-to-have-a-quot-Re...

 

(This is mostly to inform Googler's in the future as to the result of this post: at the time of writing there doesn't APPEAR to be a way to do this without implementing the functionality yourself, which isn't too hard to do but isn't my favorite task either.)

Thanks for the help everyone.

0 Kudos
Message 9 of 9
(3,616 Views)