01-28-2013 11:26 AM
Hello,
I have a data acquisition system implemented as a producer / consumer architecture which currently works well. In my producer loop, I had a Master Stop boolean, triggering a Send Notification. Consumer loops containing Wait Notifications were used to stop all the loops simulataneously before implementing my cleanup code.
The problem occured when I moved the send notification to an event structure linked to value change on the Master Stop boolean (see attached snippet). Now, on starting the VI, the Timeout case is immediately called. Could anyone advise on the error of my approach, or offer up any improvements?
Thanks
Dave
Solved! Go to Solution.
01-28-2013 11:47 AM
The first thing I am noticing is that your loop with the event structure won't end. You need to wire out a boolean for stopping your loop.
01-28-2013 12:06 PM
What do you mean by "the Timeout case is called immediately"? The timeout for the event structure? You have a 1 second timeout, so unless something else happens, the event structure will hit the timeout case 1 second after the program starts. However, this has nothing to do with the notifier.
From your screenshots there's no way to see how this is used in the larger program, and verify that you've connected the same notifier reference to both the send and wait on notification.
01-28-2013 12:18 PM - edited 01-28-2013 12:20 PM
The Case structure Error/No error could likely be removed. (Just wire the error cluster to the conditional terminal its smart enough to unbundle the boolean for you)
01-28-2013 12:19 PM
From initial testing, I discovered that the acquisition loop would acquire one sample then cease operation. It was when I placed a stop function in the Timeout case of the event structure, I discovered that this was the case. I have confirmed that the notifiers are all connected together. Unfortunately, I cannot share my complete code.
I subsequently moved the notifier back to the acquisition loop, and found that it operated normally.
Could I be immediately stopping my event handling loop and causing this jump to timeout?
Dave
01-28-2013 12:21 PM
You have no timeout on the Wait on Notification, so it's going then sit there and wait until it receives a notification, after acquiring one sample. Of course, that notification is then going to stop the data acquistion loop. Does that explain the behavior you're seeing?
01-28-2013 12:26 PM
I finally put your snippet into a block diagram so I could see the whole event structure. Why would you put the STOP function in your timeout case? (Why would you ever use that function at all, really?) You have, as previously mentioned, a 1-second timeout on the event structure, so unless something is generating events constantly, you've told your program to Stop running 1 second after it starts. This has nothing to do with the notifier; the STOP function aborts all VIs in your program.
01-28-2013 12:32 PM
it was put in there, because my program was locking up and I suspected that it was going to the timeout event, and I wanted to see if I could prove that. As you correctly pointed out, my logic was flawed in that regard.
I'm looking into your previous suggestion about the data acquisition wait on notification. I am having a problem in understanding why the loop would get sent a TRUE notification if I hadn't already changed the value of the Master Stop boolean, but I need to test it.
Dave
01-28-2013 12:37 PM
@djroseman wrote:
I'm looking into your previous suggestion about the data acquisition wait on notification. I am having a problem in understanding why the loop would get sent a TRUE notification if I hadn't already changed the value of the Master Stop boolean, but I need to test it.
The notifier isn't getting sent a TRUE notification, it's just not getting sent anything at all until you press the stop button. Since it has no timeout value wired to it, it waits forever (until a notification is received). The acquisition while loop can't repeat until every node inside it executes, and the Wait on Notification doesn't terminate until: a) it receives a notification, b) it times out (which it will never do with no timeout wired), or c) the notifier is destroyed elsewhere, causing an error.
So you get one acquisition, and then the loop sits there waiting for a notification. When that notification finally arrives, it stops the acquisition loop. Try putting a timeout on the Wait on Notification.
01-28-2013 12:40 PM
You can use a timeout value of 0 on the Wait on Notification in your acquistion loop. This will not produce any unnecessary overhead and will get your stop notification when you send it. You don't need, and probably don't want, a longer timeout sinc that will impact your data collection.