Aitor Solar Posted November 15, 2006 Report Share Posted November 15, 2006 I need to add new events to a previously defined event registration refnum, a task that's starting to seem impossible . Well, in fact I've managed to add two event refnums (from their typedesc, plus some scripting, etc). It works, but... the new event registration refnum, though it has the correct structure, it doesn't have specific controls registered on it (of course), so the events never trigger. I'm running out of ideas, so if anybody has one to offer... Saludos, Aitor Quote Link to comment
Ton Plomp Posted November 15, 2006 Report Share Posted November 15, 2006 I need to add new events to a previously defined event registration refnum, a task that's starting to seem impossible . Well, in fact I've managed to add two event refnums (from their typedesc, plus some scripting, etc). It works, but... the new event registration refnum, though it has the correct structure, it doesn't have specific controls registered on it (of course), so the events never trigger. I don't really understand what you want to do, but I take the snippet is a 'little sample' If you have an event registration refnum, you can expand it by just dragging down. But if you pass it around between VI's you will get problems. The best to do in that case is create a td. control containing the event registration refnum. Now the event registration refnum is just a container with specific events for specific control types. You have to fill it with control references to get the event node react on! Look at the following snippet: I first created the two event registration node, boolean and boolean ref. Then connected the two event registration nodes. Created a boolean typedef constant, connected it and set an event. Connected the boolean ref to the second node. Now the moment I add something to first node the second will follow. If I don't give an input to the second node, the container will hold the values from the first event node. Hope this helps Ton Quote Link to comment
JDave Posted November 15, 2006 Report Share Posted November 15, 2006 I need to add new events to a previously defined event registration refnum, a task that's starting to seem impossible . Well, in fact I've managed to add two event refnums (from their typedesc, plus some scripting, etc). It works, but... the new event registration refnum, though it has the correct structure, it doesn't have specific controls registered on it (of course), so the events never trigger. I tried to do the same thing once and ran into the restriction that ALL events must be specified in ONE (the first) event registration node. If I understand your situation, the workaround could be to register for all of your potential events upfront, using an empty reference constant for the ones that are not wanted yet. Then you would wire the correct control reference when you want to dynamically add that event. And you wire the empty constant to dynamically unregister the event. I have used this method successfully before. As Ton said, if you leave any of the events unwired they stay unchanged. David Quote Link to comment
Aitor Solar Posted November 16, 2006 Author Report Share Posted November 16, 2006 Yes, I think I'll go for the "all events in one registration" approach. But I'll explain my case further. I have several VIs that must monitor a series of dynamic events. And one additional VI that, apart from that events, has to monitor some more. So, I just see two possibilities: 1) As you say, register all the events once and pass that reference to all the VIs, keeping null references for the events a specific VI has not to control. But I don't really like this, because is not very elegant to have a VI with dynamic events it won't use ever, and furthermore, if I change my mind about an event, I must readapt manually all the controls and indicators in the subVIs, even if those VIs will not use the changed event . 2) Keep the references to the controls and create two event refnums, one "basic" and one "extended". I even like it less, because changes in the type of the registered events must be replicated in all the registrations. I hadn't thought about using a typedef, maybe is an improvement when rewiring . I hope to have explained it better . Saludos, Aitor Quote Link to comment
Ton Plomp Posted November 16, 2006 Report Share Posted November 16, 2006 But I don't really like this, because is not very elegant to have a VI with dynamic events it won't use ever, and furthermore, if I change my mind about an event, I must readapt manually all the controls and indicators in the subVIs, even if those VIs will not use the changed event I don't think you will pay a speed penalty for 'empty' events. And you should create a Type Def control for the event registration. If you do that you'll only have to edit the TD Ton Quote Link to comment
Ton Plomp Posted May 12, 2010 Report Share Posted May 12, 2010 Yes you can manipulate an event refnum: using a Cluster Bundle function allows you to wire two event refs into 1. Ton Quote Link to comment
Bean Posted May 13, 2010 Report Share Posted May 13, 2010 using a Cluster Bundle function allows you to wire two event refs into 1. Just make sure you only do one event per Event Registration Refnum when bundling the Event Registration Refnums into a cluster. I originally tried to group "sets" of events this way and revealed a bug. But, the way Ton has displayed will work since he just has 1 event (in this case, user event) per Event Registration Refnum. Quote Link to comment
ShaunR Posted May 14, 2010 Report Share Posted May 14, 2010 Thinking laterally (or is it vertically). You could create a single global event that each control can decide to register with or not. You can then filter the incoming events and take decisions based on either its type (boolen, numeric cluster etc) or a specific control. What this acheives is that changes to the system are consolodated into 1 vi. Quote Link to comment
Ton Plomp Posted May 15, 2010 Report Share Posted May 15, 2010 Just make sure you only do one event per Event Registration Refnum when bundling the Event Registration Refnums into a cluster. I originally tried to group "sets" of events this way and revealed a bug. But, the way Ton has displayed will work since he just has 1 event (in this case, user event) per Event Registration Refnum. Could you provide more info on this bug? What are the exact limitations? ton Quote Link to comment
Daklu Posted May 15, 2010 Report Share Posted May 15, 2010 Could you provide more info on this bug? Yeah, this concerns me too. Quote Link to comment
jgcode Posted May 16, 2010 Report Share Posted May 16, 2010 Just make sure you only do one event per Event Registration Refnum when bundling the Event Registration Refnums into a cluster. I originally tried to group "sets" of events this way and revealed a bug. But, the way Ton has displayed will work since he just has 1 event (in this case, user event) per Event Registration Refnum. I have seen remapping to other events, if you edit clusters. Are you referring to what Jim has posted here? Quote Link to comment
K-node Posted May 18, 2010 Report Share Posted May 18, 2010 I have seen remapping to other events, if you edit clusters. Are you referring to what Jim has posted here? Ah, so that is how my remapping may have happened. I have a little different scenario. In my case, I have a Class (MyObject) that has a UserEvent refnum as a member of its private data. For each instance of MyObject, a UserEvent is created with a Strict Type Def Control named MyEvent. When I register events from multiple unique instances of these objects, the event names are all the same ("MyEvent"). I have been using the order that they were listed in the RegEvents method as I add them to Event Structure. I have had cases where it seemed they got messed up - and even if they didn't I get confused as to which event is from which object. Is there a better way to do this? Thanks kugr Quote Link to comment
K-node Posted May 19, 2010 Report Share Posted May 19, 2010 (edited) Ah, so that is how my remapping may have happened. I have a little different scenario. In my case, I have a Class (MyObject) that has a UserEvent refnum as a member of its private data. For each instance of MyObject, a UserEvent is created with a Strict Type Def Control named MyEvent. When I register events from multiple unique instances of these objects, the event names are all the same ("MyEvent"). I have been using the order that they were listed in the RegEvents method as I add them to Event Structure. I have had cases where it seemed they got messed up - and even if they didn't I get confused as to which event is from which object. Is there a better way to do this? Thanks kugr I am going to move this question to the Object Oriented Programming forum. -kugr (edit: added link to topic) Edited May 19, 2010 by kugr Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.