12-14-2010 11:28 AM
Hi, I have a case structure within a while loop which displays various outputs, I then have an identical case structure in a different while loop that needs to replicate what the first case structure is doing. I tried using semaphores but with no luck. Any help on how to get the second case to copy the first would be greatful.
Thanks
12-14-2010 11:33 AM
One way would be to use queues to signal between the two, see the producer consumer examples in LabVIEW
12-14-2010 11:37 AM
I currently use queues to select which case to run in the first structure, however when I link this queue to the second it fails to run.
12-14-2010 11:42 AM
You should be 'Previewing' the queue in one of the cases, otherwise it is a race to see which one pulls the element off first.
12-14-2010 12:12 PM - edited 12-14-2010 12:18 PM
Hi, I've attached a rough example of the VI. Even when I use the preview the second case structure does not do anything. At what point would I attach link the preview queue function from, also within the first case structure there are operations which decide which queue to go next. Thanks
(In the example, the thick blue line is the queue and the thin blue is the element going into the case selector. The queue is fed from an enum of states into the obtain queue function at the start)
12-14-2010 12:19 PM
We need to see both loops and both case structures to identify your problem. Please post the actual IV or a simplified version of it.
In general queues are best used to send information to only one place. An Action Engine might be a better choice if the same data is to be delivered to multiple locations.
I am having a hard time visualizing a need to replicate a case structure and loop. Can you tell us more about what you want to do (rather than how you are trying to do it)? Perhaps someone can offer a better architecture.
Lynn
12-14-2010 12:19 PM
If you dequeue an element in one while loop before the other while loop gets a chance to preview it, then the 2nd loop will never see it.
You should be using two queues. One for each while loop. When you enqueue your duplicate data, put one copy in each queue.
12-14-2010 12:29 PM
Hi Lynn, I want to create a lighting system for a building. The different cases set different lights as on or off based on sensors. The second case is for a control panel to show which lights are currently on or off. I used the case it could select various options (only some lights can be on at the same time) and assumed the second case could simply be a replica of the first. I put them in a seperate while loops so they can run on different cores of the cpu.
Ravens Fan - I shall give that a go now, thanks!
12-14-2010 12:42 PM
I suspect that you only need one loop. Just put indicators for the display at the output of the single case structure.
Lynn
12-14-2010 12:43 PM
Attached is my project to make my question easier to understand. The top case structure simply should replicate what the case structure in the bottom while loop is doing. thanks.