12-14-2017 06:28 PM - edited 12-14-2017 06:38 PM
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.
(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?)
12-15-2017 10:09 AM
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
12-15-2017 10:10 AM
Just use an unbundler (or Unbundle by Name) on the inside Dynamic Events terminal.
12-15-2017 10:49 AM
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.
12-15-2017 12:57 PM
Use unbundle/bundle by name.
12-15-2017 01:11 PM
OK. Just a little extra wiring:
12-15-2017 01:13 PM - edited 12-15-2017 01:17 PM
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.
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.
12-15-2017 05:36 PM
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:
Looks like it's still not something that can be done 😕
12-19-2017 11:01 AM
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).
(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.