LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop Notifier in event case fails to stop VI

Solved!
Go to solution

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

Download All
0 Kudos
Message 1 of 13
(3,043 Views)

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.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 2 of 13
(3,030 Views)

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.

0 Kudos
Message 3 of 13
(3,023 Views)

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)


"Should be" isn't "Is" -Jay
0 Kudos
Message 4 of 13
(3,010 Views)

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 

0 Kudos
Message 5 of 13
(3,009 Views)

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?

0 Kudos
Message 6 of 13
(3,003 Views)

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.

0 Kudos
Message 7 of 13
(2,991 Views)

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

0 Kudos
Message 8 of 13
(2,987 Views)
Solution
Accepted by topic author djroseman

@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.

Message 9 of 13
(2,981 Views)

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.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 10 of 13
(2,972 Views)