LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Wait on Notification

Solved!
Go to solution
Highlighted

I have taken over a LabVIEW program.

The main VI has two WHILE loops.

One WHILE loop is reading the serial port. When 127 bytes are received, the Send Notification function is called.

The other WHILE loop has a Wait for Notification function where the timeout is set to 200ms. This WHILE loop also has a Wait of 10ms.

 

What happens in this WHILE loop is a notification is not received? Does it wait 200 ms + 10 ms ?

 

 

 

 

 

 

0 Kudos
Message 1 of 11
(267 Views)

@psuedonym wrote:

What happens in this WHILE loop is a notification is not received? Does it wait 200 ms + 10 ms ?


That depends if the wait is in parallel with everything else in the loop.  If so, then the loop should be ~200ms.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 2 of 11
(258 Views)

My guess is 200 ms, but it's impossible to know without seeing the code. Do you really even need the 10 ms wait? It would seem to me that you want to read the notifications as fast as they come (and presumably that means that it's waiting some small time for notification).

0 Kudos
Message 3 of 11
(246 Views)

@crossrulz wrote:

@psuedonym wrote:

What happens in this WHILE loop is a notification is not received? Does it wait 200 ms + 10 ms ?


That depends if the wait is in parallel with everything else in the loop.  If so, then the loop should be ~200ms.


The rest of the WHILE loop decodes the bytes and displays on LEDs on the front panel.

If the objective is to process the notifier (which are the bytes) as quickly as possible, what changes do I need to make to the Wait for Notification? Do I keep the timeout?

0 Kudos
Message 4 of 11
(237 Views)

@johntrich1971 wrote:

My guess is 200 ms, but it's impossible to know without seeing the code. Do you really even need the 10 ms wait? It would seem to me that you want to read the notifications as fast as they come (and presumably that means that it's waiting some small time for notification).


I am guessing the original programmer wanted to WHILE loop to not "hog" the resources.

0 Kudos
Message 5 of 11
(235 Views)

Any wait, or timeout will allow the scheduler to evaluate if other code can run so there is no need to have an extra Wait if you have a notifier or queue in the loop. The timeout on the notifier/queue allows the scheduler to evaluate if other code can run. In fact, if you have a loop that you want to process as fast as possible but still allow the scheduler to task switch, a Wait with a value of 0 is sufficient.

 

Now, I would ask why you have a timeout on the notifier at all if the intent is to simply process the data as quickly as possible why do you have a timeout at all? Simply have the notifier wait with an infinite timeout and it will always process the data as soon as it arrives.



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
0 Kudos
Message 6 of 11
(220 Views)

@Mark_Yedinak wrote:

Any wait, or timeout will allow the scheduler to evaluate if other code can run so there is no need to have an extra Wait if you have a notifier or queue in the loop. The timeout on the notifier/queue allows the scheduler to evaluate if other code can run. In fact, if you have a loop that you want to process as fast as possible but still allow the scheduler to task switch, a Wait with a value of 0 is sufficient.

 

Now, I would ask why you have a timeout on the notifier at all if the intent is to simply process the data as quickly as possible why do you have a timeout at all? Simply have the notifier wait with an infinite timeout and it will always process the data as soon as it arrives.


I just now tried removing the timeout.

Now if I click on the Stop button in the program which is wired to the stop condition for both WHILE loops, the VI does not stop.

0 Kudos
Message 7 of 11
(216 Views)
Solution
Accepted by topic author psuedonym

External to the loop with the Wait on Notification, you will need to destroy the notifier. In your UI loop that is monitoring the Stop button it should release the notifier after it has detected the stop.  Your consumer loop will get an error on the notifier. This will be your indication to stop that loop.



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 8 of 11
(206 Views)

@psuedonym wrote:

@johntrich1971 wrote:

My guess is 200 ms, but it's impossible to know without seeing the code. Do you really even need the 10 ms wait? It would seem to me that you want to read the notifications as fast as they come (and presumably that means that it's waiting some small time for notification).


I am guessing the original programmer wanted to WHILE loop to not "hog" the resources.


Yes, but the Wait on notifier will effectively do the same task. There is no need for the additional wait.

Message 9 of 11
(199 Views)

@Mark_Yedinak wrote:

External to the loop with the Wait on Notification, you will need to destroy the notifier. In your UI loop that is monitoring the Stop button it should release the notifier after it has detected the stop.  Your consumer loop will get an error on the notifier. This will be your indication to stop that loop.


If it was a Queue, I would be screaming at you.  If you want to process all of the data, then you need to send a sentinel of some sort through the queue to tell the consumer loop to stop (destroying the queue would destroy any data that has not yet been processed).  But since we are dealing with a Notifier, it is safe to assume we only care about the latest received data.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
0 Kudos
Message 10 of 11
(196 Views)