LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Stop and Quit LabVIEW Vi

Solved!
Go to solution

crossrulz,

My code consists of a main VI, with several Sub VIs nested within one another. I would like one of the deepest Sub VIs to quit early (safely) when I press a stop button on the main VI front panel. It sounds like you are saying this is possible with a notifier. Can you please elaborate. I have a little experience with queues and producer/consumer type architecture, but have never used notifiers, nor queues to sub VIs. Any example code would be extremely helpful.

0 Kudos
Message 31 of 33
(925 Views)

@accuairjohnathan wrote:

crossrulz,

My code consists of a main VI, with several Sub VIs nested within one another. I would like one of the deepest Sub VIs to quit early (safely) when I press a stop button on the main VI front panel. It sounds like you are saying this is possible with a notifier. Can you please elaborate. I have a little experience with queues and producer/consumer type architecture, but have never used notifiers, nor queues to sub VIs. Any example code would be extremely helpful.


I wish I had an example ready.  I would use a Queue to send messages to your subVI and then you can send a specific Stop message to it using the queue.  I recommend playing around with the Producer/Consumer until you get used to how queues work.  Then you can create a control for the queue reference and use that to pass the queue reference into a subVI and everything just works.


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 32 of 33
(913 Views)

Here's an example with code patterns you can use. The notifier is created at the top level and passed to all callers. Processes in the callers run until the notifier is invalid. To quit the app, release the notifier. (In this code pattern, "notification" is never actually sent; we just release the notifier.) We call this pattern "scuttling."

 

To run a process as fast as possible, just check the refnum status. To run it periodically (once every sec etc), wait on notification with a timeout. This is very valuable; it allows you to have a process do a task once per day while still quitting promply on user request.

 

Every other process should be constructed so that it will quit when this "quit notifier" is released. To do a processing task, throw it in a queue and have a queue processing process it. Set the queue up so that it is released by the notifier release. All of these will fall like dominoes when you release the quit notifier.

 

Any task that is many to one should be a queue. Any task that is one to many should be notifier. (Many to many is either a queue if you are load-balancing, or a notifier if you are broadcasting.)

 

LabView queues and notifiers are very similar internally. They are the best feature of the language; they makes safe parallel processing trivially easy, and they are much easier to develop and debug than the callbacks used in many languages.

 

scuttle-example.png

0 Kudos
Message 33 of 33
(889 Views)