LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Unregistering events on a cluster without Unregistering for all dynamic events

Solved!
Go to solution

Hello Everyone

 

I have been playing around with dynamic event registering but I have hit a problem.

 

Normally if I want to stop firing events on a single control then I will wire a constant ref with the correct type into the register for events block. This means that I do not have to use the unregister for events block and then rebuild the entire register for events list when I only want to stop the events on one control.

 

However, if I try and bundle a group of refs (which may not necessarily be the same type) into a cluster then I can no longer unregister events on this cluster by passing the register for events function a cluster of control constants.

 

An alternative would be to use an array instead of a cluster but this has two drawbacks: It does not enable me to create an dynamic event case for each member of the array and all the controls have to be the same types or they are co-erced to a more generic control class.

 

I have attached an example VI (labVIEW 2011 SP1)

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

You need to update ONLY the cluster elements which are to be turned off.  Simply don't wire the others (don't connect anything) and they'll retain their values and remain active.

 

Seems counter-intuitive but it works fine.

 

Shane.

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

Hello Shane

 

Thank you for your quick response. I am not sure I quite explained what I am trying to do clearly.

 

I am aware of the technique that you mentioned for changing event registration when you have multiple dynamically registered event sources.

 

In my case, I am just trying to bundle references for individual controls into a cluster as I need to register/unregister them at the same time and it saves me wiring lots of individual control references to the "register for events" block.

 

I have attached an image of what I am trying to do below. Hopefully it makes it more clear.

 

 

 

Unregister_events_on_a_clusterd.png

 

Cheers

 

John

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

I should probably add that the error I recieve at the first "register for events block" is:

 

Error 1055 occurred at Register For Events in Unregister events on a cluster.vi

Possible reason(s):

LabVIEW: Object reference is invalid.

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

Hmm, ok.

 

instead of using References as you are currently in the cluster, why not place two FP objects of the reference type and cluster these pass these to the register node.  I know it's a PITA to have to do things like this, but that should get around your problem IIRC.

 

Shane.

Message 5 of 9
(3,384 Views)

Thanks for the help and words of soladarity.

 

LabVIEW is happy with your solution but it does mean that you can only have one dynamic event for any change on the cluster so you then have to determine which control has changed and then take the appropriate action.

 

I was hoping that the "ctrl ref" that is provided in the event structure would refernce the particular cluster element but it does not, so you need to use some other means - grumble.....

 

Cheers

0 Kudos
Message 6 of 9
(3,368 Views)
Solution
Accepted by topic author John_Neutron

I think I finally get the problem now.

 

You need to feed both references in seperately.  You can cluster the OUTPUT of the register for events I know, but I don't think what you want will work.  You DO know you can input the arrays as an array instead of a cluster, right?

 

Shane.

 

Ps To be more clear.

 

REgister for your enable button seperately to the rest.  Register all your "to be switched on" references -individually, not clustered- in a second "register for events" and then cluster together the two outputs (with the event registration refnums) before passing them into the Event structure.  Then you might have what you want.  So basically cluster AFTER registering, not before.

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

Great. Thanks for the help.

 

I have resorted to doing this sort of thing (see attached VI or below):

 

This has the benifit that I can use the more formal approach of unregistering for only paticular events. I do still have to wire each ref into the "Reg Events" block. Oh well.

 

 

 

Unregister_events_on_a_clusterd.png

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

I think in the "Register" block within the event structure it's OK if you only wire the inputs which change, the rest stay the same.  It used to be like that anyway.

 

Shane.

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