LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

set control method and get control method

If I have one main VI and a bunch of sub-VI's that do different things. Each sub-VI outputs to a cluster of indicators, each sub-VI has a different cluster indicator. Is it better to send in the cluster control[] property to each corresponding sub-VI and let the sub-VI handles the cluster indicator in the main VI as the main VI runs, or is it better to use the get control method to get each indicator in the sub-VI, and then bundle them to the corresponding result cluster? Thanks
0 Kudos
Message 1 of 9
(3,590 Views)
> Is it better to send in the
> cluster control[] property to each corresponding sub-VI and let the
> sub-VI handles the cluster indicator in the main VI as the main VI
> runs, or is it better to use the get control method to get each
> indicator in the sub-VI, and then bundle them to the corresponding
> result cluster? Thanks

Mileage may vary, but if you must have the indicators update from inside
of the subVI, I'd say your code is more reuseable if you pass in a
cluster of control references to update. Changes to the main panel are
then handled in the main diagram and the subVI may not need to change at
all. If the name of the controls on the main panel and some constants
on the diagram of the subVI have to stay in sink? Forget about it.

Ideally,
your subVI doesn't need to loop and you pass the values in and
the values out of the subVI, no references at all, then update the UI in
yor main panel using terminals or property nodes. Remember, controls
aren't variables, they are UI elements. Data flows down wires just fine
and don't use references where you really want the value of the control.

Greg McKaskle
0 Kudos
Message 2 of 9
(3,590 Views)
I don't understand your last two statements, "Remember, controls aren't variables, they are UI elements. Data flows down wires just fine and don't use references where you really want the value of the control." What does UI stands for? I want to have my main indicators update as my sub-VI's indicators update, so I used six different get control method in my main VI to update each of the controls in a cluster. I am considering just sending in the control[] property of the output cluster and let the sub-VI handles everything. But this would require the use of indexing and to specific class. My sub-VI has 3 graphs. The graphs are in nested while loop. So graph one in while loop#1 updates, then graph 2 updates in while loop #2, then graph 3 updates in whi
le loop #3. So loop #3, is outside loop#2, and loop #1 is the innermost loop. If I just send in the control[], I would have to use six different index array and 6 different to more specific class to update each control. (The other 3 controls are tables, error out, and a number). So I thought if I handle this in the sub-VI, that might be kind of tedious and might be a lot for the sub-VI to handle. But for some reason when I use 6 different get control method, my VI froze when I tried to stop in the middle of the program. But if I let it finish. It stops at a decent rate. What do you think?
0 Kudos
Message 3 of 9
(3,590 Views)
Hello,

From your comment "I want to have my main indicators update as my sub-VI's indicators update", it sounds like you may want to make use of LabVIEW's ability to pass information between VIs without having to open a reference to the VI. Please take a look at my attached programs to see an example of a mainVI getting information from a subVI through the connector pane of that subVI. The method it sounds like you are using will probably work, but it uses way more system resources and overhead than necessary.

"UI" stands for "User Interface". I think Greg was referring to the fact that you can just pass data along wires from main VI to sub VI without having to use a control reference.

I hope this helps! Let me know if I can b
e of further assistance.

Liz Fausak
National Instruments
Download All
0 Kudos
Message 4 of 9
(3,590 Views)
I have a few questions about your VI. Isn't it in your example VI's, the sub-VI has to finished running before the data is reported back to the main VI? In my VI, I have to have the sub-VI running in the background, and the user can still control the main VI. My subVI takes a long time to run. I cannot think of another way of doing this other than call the VI server, and this is why I ran into problem with what to send in for my set control method....I hope I didn't confuse you.
0 Kudos
Message 5 of 9
(3,590 Views)
Hello,

Thanks for the clarification. I see what you mean. Yes, when you call a subVI, it does not pass the data along until it has finished executing. You can see this more clearly using highlight execution.

So, if I understand correctly, you need to have a subVI continuously running in the background, and periodically pass data from the subVI to the main VI. And yes, in this case the only way to do so would be through VI server. I attached a modified set of VIs to show this behavior in action. You can use the "Set Control Value" method for any data type using the "Flatten to String" function as I have. You could pass cluster data in this fashion as well.

I hope this helps! If I am still not helping you s
olve the problem, perhaps it would help for you to post a VI with an example of the problem here so that we can more easily troubleshoot. Thanks!

Liz Fausak
National Instruments
Download All
0 Kudos
Message 6 of 9
(3,589 Views)
Thanks for the help and for being very patient with my question, and sorry for any confusion. But do you think that it is better if I just use the get control method to get every sub-VI indicator into the main VI; or is it better to just use the set control method to send the cluster's control[] property to the sub-vi, and then let the sub-VI outputs to the indicators in the main VI? I have 6 different indicators so that's why I ask this questions. Which way do you think is better for the computer to handle? I have tried to use the get control method. But the program runs slower as time passes...and then it eventually stop in the middle. I wonder if this is because I use 6 different get control method, or is it becaus
e of a hanging reference somewhere.
0 Kudos
Message 7 of 9
(3,589 Views)
> I don't understand your last two statements, "Remember, controls
> aren't variables, they are UI elements. Data flows down wires just
> fine and don't use references where you really want the value of the
> control." What does UI stands for?

The last two statements were thrown in just because many times
programmers familiar with other languages try to pass data around by
handing around control references and reading/writing to the control
instead of just using wires to pass the value.

UI stands for User Interface, and if you are using control references
for UI programming, then that was their intent. I'm not clear on why
you are using the Set Control Value method via the invoke node instead
of the Value property via the property n
ode. My suggestion would be to
bundle up the references to the controls into a cluster in the calling
VI. Pass in the references than need to be updated inside your subVI
loops, then use the property nodes to update the values.

If you are continually reading the Controls[] property of the panel,
then older versions of LV expect you to close them or that is considered
a leak. LV7 handles this for you.

Greg McKaskle
0 Kudos
Message 8 of 9
(3,589 Views)
So what if my controls are alreday in a cluster? Are you suggesting to send in the cluster control[] property? Then index each indicator and then use to more specific class? Is that a lot of memory for LabView to handle? Is that a better method than using six different get control method, and then bundle the result together and output to the main's output cluster? Which method is more memory efficient? And also, after I am done using the control[] property, I use a for loop to close all of the reference, is that ok or is it better to just let LV handle it? And if I have something like the example below inside of my main-VI and I passed it to my sub-VI, do I have to close those references as well? Thanks for the help.
0 Kudos
Message 9 of 9
(3,589 Views)