From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event Structure Weirdness

Solved!
Go to solution

Last night, Seve posted an interesting question on his blog (The Daily CLAD).

 

In short, we create a dynamic event, register it, and generate two events with the data being 1 and 2.  We then start an event structure that is registerd to the dynamic event.  Inside of the event case is another event structure that is also registered to the dynamic event inside of a FOR loop set to run twice.  The data from the event was autoindexed and went straight to the final output.  Now logic would state that the output should be {1,2}.  But when I run it, I get {1,1}.  I thought that was really strange.  So of course I had to play.

 

I changed the FOR loop to run 3 times.  Oh, it sits there and waits for another event.  So it is seeing two events, as it should.  It is just that the data for the second event isn't passed properly.

 

But let's play some more.  I put another FOR loop around the outer event structure and made it run twice.  It doesn't see the second event at all (ie, sits there and waits for another event on the second iteration).  Why not?  It is registered for it?  It saw the first event?  Why shouldn't it have the second event in its queue?

 

Now if I remove the inner FOR loop and leave my outer FOR loop, everything works perfectly as I would expect.

 

Now it gets even weirder.  I added a button and the Value Change for that button to my outer event structure (both event structures with FOR loops to iterate twice).  The outer event structure is also ignoring my button's value change event.

 

NI, what the #*$&@* is happening here?


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 1 of 3
(2,289 Views)
Solution
Accepted by topic author crossrulz

The problem is not with the nested event structures, but with the shared registration refnum. An event registration refnum should only belong to a single event structure. As soon as you share it, you get undefined behavior. It might work fine, it might behave in completely random ways.

 

David's example is flawed for the same reason. It may have worked when he ran it, but it's not something that should be relied on. The bottom event structure should have had a separate registration node.


___________________
Try to take over the world!
Message 2 of 3
(2,272 Views)

I knew I was missing something stupid with it.  Good catch, Yair!


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 3 of 3
(2,260 Views)