02-07-2011 04:28 PM
I have a state machine using a queued 1d array to change states, because there are numerous tests that need to be completed in order.
My problem is I cannot seem to interrupt the array if the user needs to stop the tests.
What would be the best way to remove all of the elements of the array and insert my test stop? The elements have to be purged so that when the new test is started, so the old tests are not started first.
02-07-2011 04:33 PM
What I generally do is insert your high priority message in the front of the queue. Then have your state machine process that message and take the correct action. If you need to dump all messages from the queue then simply use the Flush Queue VI. If you need to preserve any messages you can look at the queue elements using the Queue Status VI. Search for any messages you want to keep, flush the queue and then requeue the ones you want to be processed.
02-07-2011 04:36 PM
Are you actually working with queues or just an array? It is hard to tell from your description. There is a Flush Queue function to empty a queue if you are really working with queues.
If you are using an array that you are maintaining to keep a list of things to do, then you will either need to delete from array, or just build your new item onto an empty array.