سؤال

I'm working on a small C# program, which using the interface provided by LabVIEW. And I know that, using lv.SetControlValue(name, value) can set a variable just on the front panel. But in my case, there're several clusters on the front panel. So it confused me how to set the variables in these clusters. For example there's a cluster named clusterA, and a variable in it named valueA, I've tried something like this:

lv.SetControlValue("clusterA.valueA", 1); 

But it totally not work. Anyone has some experience about this stuff?

هل كانت مفيدة؟

المحلول

thanks a lot for all your reply. I just find a simply way to solve this problem. For example, there a cluster named ClusterA, and there are only two control values in it, which are: an int value named "IntA" (default value IntA = 10)and a string value named StringA (default value StringA = "abc"). In C# if you invoke the method:

var clusterA = (Array) vi.GetControlValue("ClusterA");

you will get an Array looks like: clusterA = {10, "abc"}; Then if you want to change IntA to 123, you just need to do:

clusterA.SetValue(123, 0); 
// 123 is the value, 0 is the index of IntA in the array clusterA
// after this clusterA = {123, "abc"}

After this, you just need to give the array back to LabVIEW by using:

vi.SetControlValue("ClusterA", clusterA);

and now see the panel in you LabVIEW, the IntA is changed.

نصائح أخرى

LabVIEW does not directly expose the SetControlValue for an element in a cluster via the ActiveX/.Net interface (which one are you using?)
However you can expose the sub-cluster element reference like this:

SetClusterElementValue

Getting the correct Cluster control can be diffcult if it's located on a tab-control.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top