LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can a subvi with a while loop be started and stopped from an event case?

Hello

 

I'm trying to add a case to the event structure where I would have a subvi with a while loop. This subvi basically grabs a GiGe camera image which I'd like to display live on the main vi. I would like a control like a boolean push button for example to be the event source for this case that starts the image capture subvi and keep displaying the live image till I push/set the button that would stop the live capture in the subvi ie stop the while loop inside it and return to the main vi, waiting for the next user event.

 

A simple way to achieve this would be to open the subvi front panel when called, with its stop button showing to stop it. But I was wondering if I can do the same without opening the subvi. Can the LV VI server be used to communicate both ways to achieve this that I described above, hopefully, clear enough to understand.

 

TIA

klk

0 Kudos
Message 1 of 4
(3,085 Views)

For starters I would look at thr producer/consumer architecture. Once inside a case in the event structure all other events will be queued until the processing for the current event is completed. What you want to achieve is not possible using only the single event structure. I also advise against using multiple event structures. However, if you have a parallel task running you can use the event structure to catch user events such as button presses and use messaging (such as queues) to instruct the parallel task what to do, i.e start, stop, pause, etc. This is basically what a producer/consumer architecture is.

 

As for displaying information from a subVI on the main front panel there are several  ways you can accomplish that. You can pass a reference to the control/indicator on the main front panel to the subVI and have the subVI update the control directly. You can also create a message passing scheme to pass the data to be displayed from the subVI to the main VI. You may also use a subpanel.



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 2 of 4
(3,072 Views)

Hi,

I think you can achieve this by calling the subVI dynamically (Call subVI from VI reference).

For stopping subVI and displaying image you can use global variable to pass the data from Main VI to subVI and from subVI to MainVI.

 

Hope this helps

Regards,

Santosh

0 Kudos
Message 3 of 4
(3,054 Views)

@klk:

If you do not wish to modify your code much, just place the logic inside the while loop from "Called VI" into your subVI. Place the logic inside while loop of "Calling VI" in the event structure. Be sure to give the control name same as that in your subVI and wire the "NewVal" value of event structure to the value input of invoke node.

 

I have attached both the VIs.

 

 

You need to wire the output of "Called VI" to the stop terminal of while loop.

 

Hope this helps:)

 

This would also help you avoid addition of global variable to your project 😄

Message Edited by Fragger Fox on 02-19-2010 12:46 PM
Message Edited by Fragger Fox on 02-19-2010 12:48 PM
-FraggerFox!
Certified LabVIEW Architect, Certified TestStand Developer
"What you think today is what you live tomorrow"
Download All
Message 4 of 4
(3,046 Views)