Jump to content
News about the LabVIEW Wiki! Read more... ×
Sign in to follow this  
Neil Pate

User Event weirdness

Recommended Posts

I have some behaviour in an application I cannot understand and wonder if anybody can share some light. I can't really post an example as its part of quite a large framework, but I think I can discuss the issue reasonably succinctly.

  1. There is an "actor" that generates some data on a User Event. The main loop VI of that "actor" is the bit of code that also creates and "owns" the actual User Event, and it never stops running so should never go out of scope.
  2. There is a second "actor" that registers for this User Event and receives the data. This VI gets dynamically loaded into and out of a subpanel. This is all working well and is a technique I have used successfully for a long time.
  3. When I insert a different VI into the subpanel (or rather as soon as I remove the first VI and stop the loop) the Generate User Event in (1.) errors out with Error 1 and if I validate the User Event reference it transitions to Not A Reference at the same time.

What I do not understand is why a consumer of the User Event (i.e. registered for it) can cause the underlying User Event to become invalid.

Edit 1:Even weirder, if I try and Register again using this same User Event (exactly the same refnum number) there is no error (yet if I test for Not A Reference at the exact same place I am registering it gives True), see picture.

Edit 2: Today I learned that the Register Event node does not seem to do any checking on the input refnum, as can be seen in the second picture you can register a NULL reference which seems strange to me.

As I said I have used this technique many times in the past and cannot recall seeing this behaviour.

Any ideas?

Using LV2015 SP1 on Win 10

 

Capture.PNG

Capture1.PNG

Edited by Neil Pate

Share this post


Link to post
Share on other sites

OK, figured it out.

Turns out the actor I thought was Creating the User Event was not actually doing it. In my code the first time the reference is requested it is Created and then reused from that point onwards. Due to some clever stupid logic my second actor (the one using the data) was actually running before the producer of the data actor, so when the consumer shutdown the reference went stale. 

Share this post


Link to post
Share on other sites

BTW, the ability to connect a NULL reference is intended.  This way, you can switch off certain events by modifying the Event Registration Refnum entries with NULL values.

I have code where I register for certain events outside of a loop with exclusively NULL references, only to have a different event actually deliver the correct event references to listen to.  This way the Event registration refnum is created at initialisation but remains essentially inactive until "primed".

Edited by shoneill
  • Like 2

Share this post


Link to post
Share on other sites
52 minutes ago, shoneill said:

BTW, the ability to connect a NULL reference is intended.  This way, you can switch off certain events by modifying the Event Registration Refnum entries with NULL values.

I have code where I register for certain events outside of a loop with exclusively NULL references, only to have a different event actually deliver the correct event references to listen to.  This way the Event registration refnum is created at initialisation but remains essentially inactive until "primed".

Ah yes thanks for the reminder. I have actually done this myself in the past to dynamically register FP controls but wanted to do it "inside" the event structure, so I registered the event outside (of course) and then had a different event to populate with actual refs inside. This was actually my first introduction to User Events and totally did not understand why I needed to do this!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

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