LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Extracting names of data from a global variable

I'm developing a rather large application.
In this application I have a global variable containing all relevant data (histogram, std dev etc)
The reason I chose a global is so that I don't need to change all my controls in all my programs whenever I add a new data set to this global variable.
Now the only program I still need to do this is the program which makes plots of these data sets.
Now as my work grows, more and more data sets will be stored in this global variable.
And I don't want to keep having to change stuff in this vi, which has two controls stating what should be plotted versus what.
x-axis vs y-axis so to speak. These controls are enums, so the user can easily select which data to plot versus which other data.
Is there a way for this program to automatically adept to the content of my global.

Example:
Say my global contains 4 data sets in the relevant "output data" cluster (all always of the same size):
cluster (data1 (1:100), data2 (1:100), data3 (1:100), data4 (1:100)).
And my enums:
enum1 (data1=1, data2=2, data3=3, data4=4)
enum2 (data1=1, data2=2, data3=3, data4=4)
This way I can convert the cluster to an array and use "index array" to get the relevant data set.
Now the user can select from the two enums to plot data1 vs data2 for instance.

Now I add two more sets, data5 (1:100) and data6 (1:100) to the global variable.
cluster (data1 (1:100), data2 (1:100), data3 (1:100), data4 (1:100), data5 (1:100), data6 (1:100)).
Is there a way for these two enums to check how many sets of data are present in the global, and what their names are?
So that they now automatically become:
enum1 (data1=1, data2=2, data3=3, data4=4, data5=5, data6=6)
enum2 (data1=1, data2=2, data3=3, data4=4, data5=5, data6=6)

If anybody knows how to do this than that would be great.

Thanks in advance.

Best regards,
Arend Hiddema
0 Kudos
Message 1 of 4
(2,601 Views)
Because I couldn't even understand my own question, I decided to give a simpler example: see attachment.
What I want is to the part with the question marks.
How do I get the appropriate data from the global.


Thanks,
Arend
0 Kudos
Message 2 of 4
(2,589 Views)
Hello Arend,

here comes a half-way solution to your problem.
At least it shows how to extract the names of the controls of your cluster and create the "strings&values" for the ring.
But it needs a reference to the cluster and so I only created a cluster control. At the moment I don't know how to get a reference to a global cluster. Perhaps someone else?
Another idea: Do you want to change the ring at runtime? At runtime the cluster is/should be constant (regarding the name and number of controls in it). So you only have to set your ring at development, but not in runtime... Or you should use an array[Dataset] instead, especially if all your datasets are the same in size (and type). Then you have a 2D-array and the user interface is also easier to program: from the array size you know the number of datasets, you can easily add or delete datasets (even at runtime). You only have to make a second array[strings] to contain the names of the datasets.

Hope this helps,
GerdW
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 4
(2,585 Views)
Thanks, that will get me a good start.
I figured I would need something with a reference but didn't know how to do this.
At least now I know how to retreave the names of the cluster and thats a big help.

The ring does noet need to be changed at runtime.
The idea is that multiple people will be able to contribute their relevant vi's and global data and the main program accomodates their needs.

I'll have another go with your suggestion.

Thanks again.

best regards,
Arend
0 Kudos
Message 4 of 4
(2,564 Views)