I am trying to make a rather simple vi (Test VI.vi is attached) where i press a button to make an LED blink and then to stop it. I have an event structure in each of the three different states Init -> ON -> OFF. Init waits for either the Play button or the Exit button to be pressed. If the Play button is pressed it will go to the ON state and after a timeout (as decided by time On) it will go to the OFF state (and then back to the ON state after time OFF). If the Stop button is pressed in either of these states, the program goes to the init state and waits for further commands. While this works for the first run, it becomes erratic from the second run.
I figured the issue was that when I call the Stop button, the event structures in both ON and OFF states irrespective of which state the program was in was called. I assume the structure in the called state was processed and the other call went into the queue. I tried to find a way to forcefully flush the queue, but I couldn't find a proper way to do that. Can someone help me with this problem? I am rather new to the labVIEW programming environment. I would be happy to read up on the architectures if you could point me to one.
Thank you