LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Why doesn't the notification system work correctly?

I build a program such that opens the instant message.vi by notify, delay by 10 sec, close instant message.vi by call reference, again do the same thing. It lasts for 2 messages. But it does not work correctly. What could be the problem?
0 Kudos
Message 1 of 2
(2,452 Views)
Astroboy,

Perhaps the best way for you to get a sense for why the program isn't behaving as you expect is to put it into execution highlighting mode (the light bulb icon above the block diagram) and run it in that mode.

This should help reveal a number of problems, among them:

1. With the way you've coded things, there's no guarantee that your while loop will begin to execute before the first frame of your sequence structure executes; the LabVIEW compiler is free to choose either order (this is often referred to as a LabVIEW "race condition") unless you force the issue by connecting the components with wires somehow. And, if the receive block in your while loop happens to execute before the send block in your sequence structure, you are going to miss that initial notification.

This problem is actually a bit difficult to solve with simple wiring changes to your existing code, but you could force the issue by adding a delay frame to the beginning of your existing sequence structure. Many LabVIEW programmers frown upon any use of sequence structures and might make suggestions to allow you to eliminate them. In my opinion, though, you can solve that problem later. Your best next move would be to separate your two pieces of functionality (send and receive) into two separate VIs and make sure to run the receiver VI before you start the sender. Then you'll avoid the execution-order problem that you currently have.

2. More fundamentally, you will notice that your while loop hangs in its first iteration at the point where the instant message display VI is called. As a result, although the sequence structure at top continues to execute from left to right, the while loop never gets back around to a second iteration and a second call to the receive notifier VI.

The reason for this is that, while you are programmatically hiding the instant message VI window in your sequence structure, you are not stopping the actual execution of the VI. Though its diagram is password-protected, I would guess that it's got a while loop that is continuing to run even after its panel is closed. What you need is a button on the front of that instant message display window that the user can click to actually stop the underlying while loop and finish the execution of the VI. Then the main program's while loop can reach a second, third, etc, iteration.

These sorts of LabVIEW fundamentals are really driven home in NI's LabVIEW Basics training classes (ni.com/training). I would strongly urge you to invest the time to take a class or two; I believe that your subsequent increase in productivity would more than offset the time and expense of the class.

Regards,
John Lum
0 Kudos
Message 2 of 2
(2,452 Views)