From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help using invoke node 'Ctrl Val.Set' with cluster elements

Greetings all!

 

I need help creating a vi that is able to set the value of a control (using Ctrl Val.Set) within a cluster without prior knowledge of the cluster's data type.

 

More specifically, I have a cluster called "Test Setup", I don't know its datatype, but I do know that there is a control within the cluster called "Test Paramter" that i want to set. I really don't care about the rest of the cluster except for setting the value of that one particular element. i've tried various approachs to get this to work, but to no avail. Attached is some short code to better illustrate what i am trying to do. Thanks for the help!

 

Download All
0 Kudos
Message 1 of 11
(4,778 Views)
I'm assuming that the VI reference is from a dynamic load, otherwise your premise makes no sense. That said, you need to work with references, not values. In other words you need to go through the list of control references for the VI until you find the control called "Test Setup". Then use the To More Specific Class to cast this to a cluster. Then get the list of control references for this cluster reference and look for the control called "Test Parameter". Then use the Value property to set the value. I'd write you up the code, but it seems you know what you're doing so I figure you can pretty much follow my description. If it's not clear post back and I can whip up an example.
0 Kudos
Message 2 of 11
(4,761 Views)

I think I have an idea of what you are suggesting. I tried to implement this by first creating a variant indicator directly after using the invoke node (CTRL Val.Get). Once I try to convert the variant to a more specific class (cluster), I get the error code, ERROR 1057, type mismatch. I am not sure why this is happening. I've included some code and screenshots of my exact problem.

 

Thanks again!

Download All
0 Kudos
Message 3 of 11
(4,728 Views)

That wasn't quite what I meant. What I was referring to was doing the same thing you're doing on the right for the list of front panel controls of the VI that you are loading dynamically.

 

Normally this is what you would need to do ....  unless you have the Variant library from OpenG. In this case it's much easier. So, head over to OpenG.org and get yourself VIPM and get the variant library. Then you only need to do this (using the "Set Cluster Element By Name" VI):

Message Edited by smercurio_fc on 04-10-2009 01:59 PM
Message 4 of 11
(4,723 Views)
Thanks. That seems to ve a very straightforward and elegant solution. My problem is that I may not be able to install any software add-ons/plug-ins to the machines I am using in the lab. Is there perhaps an alternative solution to this? Also, I am confused about why the variant reference cannot be converted to a cluster (the original data type of the control). What is the reason behind the error?
0 Kudos
Message 5 of 11
(4,716 Views)

You can't take a control reference for a Variant control on the front panel and cast that to a Cluster control reference...those are two different types of controls.  What you want to do is take the value of the variant and use the Variant To Data function to convert its value into a cluster of the desired type.

Message 6 of 11
(4,711 Views)
I see, thanks for the clarification. The problem is I won't be able to use the Variant to Data function because the program won't know beforehand all the data types that are contained within the cluster. They will most likely be dynamic and changing with each call. I just know that there will be one element of particular interest, whose data type is known, that I want to change.
0 Kudos
Message 7 of 11
(4,706 Views)
The OpenG VI are just VIs and they don't have to be installed within the LabVIEW directory, although if you use VIPM that is where they will go. Technically, they're just VIs so you can have them within your own project hierarchy without touching a LabVIEW installation. Attached is the VI with the OpenG VIs saved as a distribution.
Message Edited by smercurio_fc on 04-10-2009 02:40 PM
0 Kudos
Message 8 of 11
(4,702 Views)

In that case, you could probably use the VIs in vi.lib\utility\VariantDataType to get the types of controls within a cluster, find the one you want, and change its value (using GetClusterInfo.vi and SetClusterInfo.vi).  I'm assuming these VIs function similarly to the afore-mentioned OpenG VIs.

0 Kudos
Message 9 of 11
(4,700 Views)

Great! Thank you guys so much. I'm looking forward to getting this program up and running now. Smiley Very Happy

0 Kudos
Message 10 of 11
(4,696 Views)