03-13-2012 03:33 PM
Hello all
I have a rather ridculous VI with a while loop in a state machine in a state machine and I spent a long time trying to work out how to use a single stop button to stop whichever loops are running. I eventually did this by using a parallel running event structure to set a "stopping" local variable, which I can then use in any loop. However, whenever the user clicks the stop button I normally present a second chance dialog and if they choose to stop, then I generate a custom error message which is picked up and handled in my main state machine. So, currently, this error message is generated in my event structure, but I already have an error path through my main loop and state machines...
I can't see the wood for the trees, so I would be very grateful for any advice on how to incorporate the error handling into the main error path - if this is possible. I have been looking here and here for a good way of handling errors in event structures, amongst other threads, and I figure I can do it by moving the error generating VI out of the event structure and using a second local variable, but is there a better / simpler way?
Thanks for any advice
Ray
03-14-2012 04:56 AM
I forgot to mention that my event structure only exists in order to indicate that the stop button has been pressed to all the other loops.
03-14-2012 06:45 AM
Hey Tarsel
What I suggest you do is scrap the event structure as this is added complexity. I would have each state check for stop button being pressed and if it is change to a new state in your state machine that brings the user dialog up and creates the error code.
Thats what I would do.
If you wanted other events to happen apart from the stop button I would suggest changing your architecture to an event driven producer/consumer architecture. Ther is a template for this included in labview if you select new instead of new vi when making a vi.
Cheers