Jump to content

Manipulate an event refnum?


Recommended Posts

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... :wacko:

post-1450-1163604592.gif?width=400

Saludos,

Aitor

Link to comment
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:

post-2399-1163608026.png?width=400

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

Link to comment
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

Link to comment

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 :blink: .

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

Link to comment
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

Link to comment
  • 3 years later...

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.

Link to comment

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.

Link to comment

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

Link to comment

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?

Link to comment

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

post-16231-127420610938_thumb.png

Link to comment

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 by kugr
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.