LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
timtamslam

Allow the addition of new event sources to the Event Registration Refnum

Status: New

With how event source references are currently handled, it is not possible to add any additional event sources to an existing Even Registration Refnum. The user is required to know the number of events needed and statically configure the Register for Events block at the beginning. The Register for Events block is resizable when you have not wired an input for the Event Registration Refnum, as shown,

 
EventRegister.JPG

But this presents a problem whenever you are working with a preconfigured refnum. If you're working with an application that defines the events within a subVI and then passes out that Event refnum, there is no way to append new events to that refnum.

 

EventregistersubVI.JPG

 

The new Register for Events is not resizable and there is no way to combine the previous refnum with a new refnum you have created. This really limits the capability to expand and continue using the refnum throughout your code.

 

The only ways to work around this would be,

 

Preallocate many readdressable events that you can later overwrite,

 

  • Use a datatype that has multiple elements (cluster/array) and use the different array indices as needed

 

  • Preregister many event sources on first creation of the refnum, and then rewrite over those sources later

 

preregister.JPG

The last way to approach would be to just create another Event structure to handle the new refnum.

 

Has anyone else run into something like this and has a recommended way to approach? Any other approaches and recommendations to help make the Event refnum more flexible would be great!

 

 

 

Tim A.
8 Comments
Call_Me_Vinny
Member

This would make user events WAY more usable in LabVIEW.

 

This is definitely a use case that I would take advantage of often.

Chris
Project Engineer
Certified LabVIEW Architect
Certified TestStand Architect
GregSands
Active Participant

You are able to bundle multiple Event Registrations Refnums together and wire into a single Dynamic Event. I'm not sure whether this is documented, and I also don't know where I learnt it 🙂

Call_Me_Vinny
Member

@GregS - Amazing!  That works perfectly, thanks GregS!!!

 

               "and I also don't know where I learnt it :smileyhappy:"

 

Those are always the best nuggets.

Chris
Project Engineer
Certified LabVIEW Architect
Certified TestStand Architect
GregSands
Active Participant

Found the source, so I should reference it: http://forums.ni.com/t5/LabVIEW/Nugget-of-the-week-Dynamic-event-registration/m-p/1170399#M509947

 

So I think this idea can be closed as "Already Implemented".

ouadji
Trusted Enthusiast
TurboPhil
Active Participant

The bundled event refnums nugget is super helpful! Thanks!

 

However, that does not help for dynamic registration (or does it? Am I missing something?). It seems as though you must still knowall the events you want registered before you start the even structure. It would be nice to have a way to add new events on the fly, particularly for situations like when you know you can't register at startup because the VI front panel is not open.

GregSands
Active Participant

Even if you could add new events on the fly, how would you define the event case for those events at run-time?  I think what you actually want to be able to do (based on your original idea) is already possible, but do clarify if you're thinking of some other features.

AristosQueue (NI)
NI Employee (retired)

TurboPhil: The key to the full dynamic situation is recognizing that *this* panel is not going to execute the code for the event. Instead, you're going to create an object that you initialize with all the control refnums needed to respond to the event and then pass that object to a VI that has the full dynamic event registered, and it will call some sort of "handle event.vi" on your object.