06-30-2016 09:34 AM
Norbert_B and aputman,
Thanks for the suggestions. I will visit my design with both or your suggestion in mind.
06-30-2016 09:35 AM
Try adding a timeout condition to your bottom loop. The way it looks now, the bottom loop would have to receive another event after the STOP event for the loop end condition to resolve to true. Alternatively, you could remove the Shutdown local variable from the end condition of the bottom loop, and simply wire a constant T for only the STOP case, set default (F) for all other cases (if they do not stop the loop).
However, I do agree with the others that using your queue to propogate the STOP event to the top loop would be better than using a local variable.
06-30-2016 09:39 AM - edited 06-30-2016 09:46 AM
Also,
I goal is to have three loops: One for reading in data, one for processing the data, and one for sending the data out...
06-30-2016 09:39 AM
I'm not sure what a CAN frame is....but ok. Can you pass an empty CAN frame (if there is such a thing) and exit the loop when one is detected?
Where is the queue wire going that wraps around the bottom loop? Are you using that reference somwhere else or are you destroying the queue? If the latter, destroy your queue reference in the STOP event and check queue status in the top loop. If the queue status returns an error, exit the loop.
06-30-2016 09:41 AM
Just use a User Event to have the Consumer send a message to the producer and properly shut down, your queue type may need to change to account for Messages instead of just CAN Frames, but this works robustly..
Open up this snippet in LV or see attached code..
06-30-2016 09:43 AM
What function does the large sequence structure have?
Why are you using the shutdown local in your event loop? Pass the value out of the structure. When you can use a wire, do so. In this case, you can do so.
You should include some error handling. At a minimum, display the error while you're developing.
06-30-2016 10:10 AM
I wired an indicator to the index box for each while loop...the bottom indicator does not increment
06-30-2016 10:21 AM
Found this:
http://digital.ni.com/public.nsf/allkb/267704CDE91156D186256F6D00711AAE
Tried it out. Wired indicators to each while loop. Watched for a while. Then hit the stop button. Worked as I would expect.
Again, this noob appreciates everyones input...
06-30-2016 10:56 AM
@swbpnole wrote:Here is the meat of it:
No, these are just the potatoes. You have local variables all over the place and I see at least one race codition that prevents your code from stopping.
The race condition is cause by the fact that the shutdown local variables is read before the event occurs, thus does not yet contain the TRUE value and the lower loop will happily continue after the stop event has fired.
There is no need for any local variables for the stop button. Wire the stop button terminal into the upper loop in place of the shutdown local variable and generate a fake error in the stop event and everything will fall into place. No need for aditional boolean logic.
06-30-2016 11:06 AM
Thanks for the suggestion. In the post above this one, I found something workable...