12-06-2016 09:42 AM - edited 12-06-2016 09:44 AM
I wrote a very simple vi that displays a selected message using an event structure to react to a button on the front panel.
If I write an upper level vi that calls this subvi multiple times (one case in a state machine for instance), the first instance of the subvi behaves correctly and waits for the event. But when the second instance gets called it blasts right through as if the event had already been triggered. Out of curiosity I put a FOR loop around the second instance and for some reason it executes properly every other time. If I set up for four loops, it skips on 1 and 3 and runs on 2 and 4. If you run the attached file you can watch the vi open and close very rapidly on every other run. It is open for maybe 100 msec.
Any hints?
The file called Double Event Skip is the upper level vi. Any hints would be greatly appreciated.
Solved! Go to Solution.
12-06-2016 09:48 AM
Could this be an issue with the mechanical action of the button?
Ben
12-06-2016 09:49 AM - edited 12-06-2016 09:55 AM
Hi rimfire,
when I change the event case settings to "block UI until event case handled" and disable the event queue manipulation your VI works as intended (I guess)…
@Ben: The button is set to "latch when pressed" without any key binding, so it should be ok! (But it was also the first place I checked…)
12-06-2016 09:58 AM
The problem is that the way your code is structured, it will generate 2 events every time someone enters a data: One event for the value change of "Controls" when the input string is entered (gets triggered when key focus moves away from "Input String), and the second when a button is clicked. Since you only process one event in your dialog box, the second event remains queued up and gets handled immediately on the next call.
12-06-2016 10:40 AM
Paul,
I need some education. I am getting a hint of what you are saying, but I didn't realize events would get buffered from call to call. What I am confused by if that is the case, is that if I use this vi just once in seperate cases of a state machine, I haven't see the problem. Whereas if I call it multiple times in a single case, it always happens as it does in the example. If the events are carried over, why wouldn't I see the skip occurring no matter where the vi lives?
12-06-2016 10:48 AM
Can you provide example code of the skip not occurring?
12-06-2016 11:01 AM
Paul,
Now I have egg on my face. I built the example of what I swore was working and of course it made a liar out of me. It is going to take some digging in stuff that "I am sure is working" and see what little detail my old grey matter is overlooking.
Thanks for your help. Now I just have to figure out how to fix it. Should be interesting.
12-06-2016 12:29 PM
Just change your event case to handle value changes of the buttons instead of a value change on the entire cluster.
12-06-2016 12:44 PM
Paul already gave you the fix. I'll give you the little detail that escaped your grey matter. So, I change a value of Cluster.boolean How many VC Events take place? 2 Cluster.boolean changes value and Cluster changes value
That would thow %90 of developers the first time it happened to them