crichter Posted August 10, 2013 Report Share Posted August 10, 2013 I saw a clever and fairly simple piece of code this morning, where code to update a graph was written in the timeout case of an event structure. (It ran on LV7.0 and drats!!! I failed to save it). The timeout case was wired to timeout after 100 milliseconds. My question is, would not code such as I just described, defeat the whole point of using an event structure, since the while loop outside the event structure was running most of the time? Am I missing something? Quote Link to comment
hooovahh Posted August 10, 2013 Report Share Posted August 10, 2013 What if you want to reset the graph when the user resizes the window? Or right clicks on a control? Or. Double presses the escape key? How would you handle this without the event structure? The code you described is very common using the timeout case. The only thing I would do different (but isn't needed) is to set the timeout to 1ms, then use elapsed time to only update every 100ms. Any event generated will reset that timer so if a user spams the keyboard where the event structure handles key down, the timeout may never happen. This functionality slightly changed in 2013. I haven't tried it but I heard the timeout isn't reset with dynamic events anymore. 1 Quote Link to comment
drjdpowell Posted August 10, 2013 Report Share Posted August 10, 2013 If you want to update the graph only after events come in, but don’t want the overhead of updating every event in a “burst”, you can put a “-1” constant inside the timeout case and wire it back through shift register into the timeout, and set the tunnel out to “Use default if unwired” so that the timeout is zero after any event other than timeout. 1 Quote Link to comment
todd Posted August 10, 2013 Report Share Posted August 10, 2013 Any event generated will reset that timer so if a user spams the keyboard where the event structure handles key down, the timeout may never happen. This functionality slightly changed in 2013. I haven't tried it but I heard the timeout isn't reset with dynamic events anymore. Point of clarification: an event that is registered with an ES that DOES NOT have a case in the ES (unhandled), will not reset the timeout. In 2012, events that were registered but unhandled would reset the timeout. Quote Link to comment
crichter Posted August 11, 2013 Author Report Share Posted August 11, 2013 Thanks for the replies guys. drdjpowell, is my attachment correct? Reason I ask is it seems the tunnel went to "use default if unwired" automatically and I did not have to select it but usually I do. Learn about timeout..vi Quote Link to comment
drjdpowell Posted August 11, 2013 Report Share Posted August 11, 2013 Thanks for the replies guys. drdjpowell, is my attachment correct? Reason I ask is it seems the tunnel went to "use default if unwired" automatically and I did not have to select it but usually I do. Yes, that’s right. Quote Link to comment
hooovahh Posted August 12, 2013 Report Share Posted August 12, 2013 Point of clarification: an event that is registered with an ES that DOES NOT have a case in the ES (unhandled), will not reset the timeout. In 2012, events that were registered but unhandled would reset the timeout. Thank you for the clarification I knew there was some bug fix regarding how this was handled but I wasn't sure the specifics because I personally have that issue. Quote Link to comment
mje Posted August 12, 2013 Report Share Posted August 12, 2013 If you want to update the graph only after events come in, but don’t want the overhead of updating every event in a “burst”, you can put a “-1” constant inside the timeout case and wire it back through shift register into the timeout, and set the tunnel out to “Use default if unwired” so that the timeout is zero after any event other than timeout. This is probably the most common pattern I use for making simple user interfaces. I think it's a great way of handling any interface whose rendering state can be determined from a single call. Things get more complicated for complex interfaces if you can't just go blindly rendering everything all the time, but most of the time I find this recommendation is spot on. 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.