Neil Pate Posted November 1, 2018 Report Share Posted November 1, 2018 (edited) 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. 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. 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. 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 Edited November 1, 2018 by Neil Pate Quote Link to comment
Neil Pate Posted November 1, 2018 Author Report Share Posted November 1, 2018 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. Quote Link to comment
shoneill Posted November 1, 2018 Report Share Posted November 1, 2018 (edited) 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 November 1, 2018 by shoneill 2 Quote Link to comment
Neil Pate Posted November 1, 2018 Author Report Share Posted November 1, 2018 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! 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.