02-17-2011 12:50 PM
Hello all,
I got a SubVI which checks if an Input Time Value has passed, when it did the SubVI returns a True.
I would also like to see the passing time in a "Count Down" Indicator. The Indicator is in the while loop
I use, so I cannot see this value in the VI that calls the SubVI, because data out of the SubVI is only passed
out when the SubVi finishes execution (at least this is what I know...) When the SubVi is runs on its own it works
fine. Do iI need a variable to pass that data out of the SubVI into the main VI?
SubVI is attached
Thanks
Patrick
02-17-2011 01:10 PM
There are several options for achieving what you want. Using a local or global variable would be the least appealing option. It is usually the first choice for people who are new to LabVIEW. A second option would be to pass a reference to the subVI to the control you want updated. This has the disadvantage of forcing the processing of the subVI to the UI thread since it will need to use a property node to update the control. Both of these options also have the disadvantage of coupling this subVI to the particular UI you are using. This is generally not a good thing to do since it dramatically reduces code reuse.
The preferred methods would be to use an action engine or pass the data out via a queue or notifier. You could also use an user event to pass the data from the subVI to the UI task. I would recommend using either a queue, a notifier or a user event. This has the advantage of decoupling your processing task from the UI. The subVI will still function fine if there is no one listening on the queue or notifier. I haven't experimented with firing user events with no event handler but I imagine the event is simply tossed in the bit bucket. If you use the queue or notifier have your subVI obtain the queue/notifier by name. Do not have it create the queue or notifier is it does not exist. Ignore the error from the queue/notifier when you obtain it and when you add a message to it. If you use this approach you should use a very small or a timeout value of 0 when posting the message. The subVI will operate fine even if no one is there to get the message. This helps to make this type of utility VI general purpose and reusable.
02-18-2011 09:30 AM - edited 02-18-2011 09:31 AM
Hello,
Thanks for your answer, I am going to try it out.
What does UI stand for and what exactly is a thread?
02-18-2011 09:55 AM
UI is an abbreviation for "user interface". The UI is the part of the application the user interacts with. A thread is a computer term refering to a portion of code execution on the CPU. Modern computers allow mutliprocessing, meaning that more than one thing can be running at the same time within the computer/CPU. A thread is one stream of execution. Each thread can have its own priority which determines how mucg CPU time it gets. In LabVIEW the UI thread is a lower priority thread of execution which means tasks that run on that thread may be delayed to allow higher priority tasks to execute.
02-18-2011 12:01 PM - edited 02-18-2011 12:05 PM
Hi Mark,
I tried to implement the notifier but could not make it really work the way I want. The problem I still have is that the notifier passed the Time Count Down Value once to the main VI. That means that when Time to Elapse is 10, the notifier just passes a 10 to the time count down of the main VI. I would like this value to count down from 10 to 0, like it does when the sub VI is run alone.
Please find a screenshot of the subVI (Elapsed Time 2) and the the call in the mainVI attached.
Thanks
Patrick