LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Programmatically create new consumers in a QSM

Solved!
Go to solution

Howdy, I'm struggling with a concept for a QSM setup.  Say I have a main VI composed of a single producer and single consumer sharing one queue, which can be populated by inputs/actions from the main VI's front panel.  The consumer's sub-VIs call by reference reentrant VIs each of which open their own front panels and run their own QSM or other state machine until closed by the user.  This occupies the main VI's consumer until the loaded VI is closed, as the consumer would be waiting for the output of the call by reference node, even though the called VI may not have any outputs.  So the main VI would be able to queue further elements, but those elements wouldn't be excecuted until the first element's execution completed (the called VI), and further input from the main VI's front panel wouldn't be executed until the new front panel was closed.

 

To fix this, I figured adding more consumers (with the same sub-VIs) to the same producer, creating new queues for each consumer, and then when a new element is added from the event structure in the producer, it would poll each queue looking for a queue (and thus a consumer) with zero elements queued and add the new queues to that.  This should ensure that if more main VI front panel events occured, they would execute even with another front panel open.

 

But this means I can only have as many windows open as I do consumers in my main VI.  My question is, is there a way to call a VI in such a way that it does not occupy the while loop containing its call by reference node until the called VI's front panel is closed?

 

Thank you in advance!

0 Kudos
Message 1 of 5
(2,290 Views)

Do your called VIs ever return any data? You said the called VI "may not have any outputs" which implies some of them do.

 

If you do not need any outputs from any of the called VIs you can use the Run VI method and set Wait Until Done to false. If these VIs have input terminals you can use the Set Control Value

 

Example_VI_BD.png

 

If your called VIs do return values then you have to set some kind of interprocess communications messaging such as another queue.

 

If you are using LabVIEW 2011 it gets even easier. You can use the new Asynchronous Call By Reference feature.

=====================
LabVIEW 2012


0 Kudos
Message 2 of 5
(2,279 Views)

Jeanius,

The Call by reference node calls the VI, waits until it completes running, and then continues. The way I would get around this, is to use the Run VI method instead. Use an "Open VI reference" to your VI, and a invoke node. Select the Run VI method node, and wire a false to "Wait until finished?" input. That way, it doesnt wait until the subVI completes running.

 

Regards,

Prashanth N
National Instruments
0 Kudos
Message 3 of 5
(2,278 Views)
Solution
Accepted by topic author Jeanius

Also I just tried this. Setting the open front panel when called property on a VI is not enough. You have to explicitly open it with an invoke node. And you have to specify in the open VI reference that it is reentrant even though you have the VI properties set to reentrant.

 

caller_BD.png

=====================
LabVIEW 2012


Message 4 of 5
(2,275 Views)

Thanks very much, I'll also try the asynchronous call feature!

0 Kudos
Message 5 of 5
(2,252 Views)