09-18-2008 04:13 PM
09-18-2008 08:32 PM
I got a little bit confused as I read towards the end of your paragraph. Perhaps you could post your VI so we can have a clearer idea how your loops are setup now.
In my opinion, the best way to stop the consumer loop is for the producer loop to pass it a "stop command" as part of its message queue. That way the queue still exists so that the consumer can continue processing all of the data in the queue. When it hits the final queue item of the stop command, then it executes a case structure that stops the consumer loop. Then the consumer loop can release the now empty queue.
09-19-2008 10:03 AM
09-19-2008 01:37 PM
Sophia,
The idea of passing the stop command via the queue is that it will be at the end of the queue - after all the data. The consumer loop will see the stop command after it processes all the earlier data. In this case it might be better called "End of Data" rather than "Stop."
The sequence structure is totally unnecessary. Use dataflow to handle the initialization and completion code. The sequence structure will definitely proceed to the next frame when all the code within the current frame completes execution. If the iteration counts have stopped increasing it may mean that the loops have stopped running or that the producer is blocked, waiting for something within it to finish so it can go to the next iteration. It is also possible that the consumer loop has started an iteration but no data is in the queue. Since the timeout is default at -1 the Dequeue will wait forever for data.
Please look at the style guides. Use left to right wiring and avoid hiding wires behind other objects. Also try to keep the diagram to the size of one screen.
Parallel loops should always have some kind of wait or delay to allow CPU resource sharing. In the producer loop the data acquisition VI may provide that function. In the consumer loop the easiest way to get a delay would be to change the Dequeue wait time to something other than -1. You also should check the Dequeue Timed out? line if you use timeout for the delay. If it is true, then the data is not valid and should not be analyzed in the for loop.
You probably only see the last of the 10 spectra. Unless the datasets are rather large, the loop will probably run too fast to see the others.
Lynn