LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cluster Element Names

I have a few clusters that contain data that I am putting in a database using a Python script. I want to label things as they go into the database based off of what the element name in the cluster is and I want to do this dynamically so that if I change the name of the elements in the cluster it will change what I am sending to the python script and go in with the new name. I can not find a way to dynamically create an array or any data structure that holds the name of the elements in a cluster. In short I want to grab a cluster and output some data structure with the list of element names from the cluster. Any information on this would be great!

 

Thanks!

0 Kudos
Message 1 of 10
(2,174 Views)

Use the Get Cluster Information VI to get an array of cluster elements and then Get Type Information to get the name of each array element.

Message 2 of 10
(2,158 Views)

You can flatten a cluster to JSON or XML and parse the names from there.

Matt J | National Instruments | CLA
0 Kudos
Message 3 of 10
(2,155 Views)

The OpenG toolkit has "Get cluster element names":

 

BertMcMahan_0-1650040078965.png

 

Edit: Dang, lots of posts. Use Kyle's suggestion, it doesn't require an external toolkit. I didn't know that one was there.

 

Message 4 of 10
(2,148 Views)

@BertMcMahan wrote:

The OpenG toolkit has "Get cluster element names":

 

BertMcMahan_0-1650040078965.png

 

Edit: Dang, lots of posts. Use Kyle's suggestion, it doesn't require an external toolkit. I didn't know that one was there.

 


Nope, Kyle's method will get a list of datatype names not element names.

 

Try showing us the BD of the OpenG vi


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 10
(2,119 Views)

@JÞB wrote:

@BertMcMahan wrote:

The OpenG toolkit has "Get cluster element names":

 

 

Edit: Dang, lots of posts. Use Kyle's suggestion, it doesn't require an external toolkit. I didn't know that one was there.

 


Nope, Kyle's method will get a list of datatype names not element names.

 

Try showing us the BD of the OpenG vi


Kyle's method returns the same thing OpenG does:

 

Example_VI.png

 

The OpenG method uses a bunch of other OpenG VI's internally, so posting just that one's block diagram isn't very useful. At its core though it uses Variant to Flattened String and parses the result.

Message 6 of 10
(2,104 Views)

Thanks Bert,

 

I'll have to submit feedback on the help for Get Type Information.vi.  

 

The help clearly states Name is the Name of the data type not the Lable of the Variant.


"Should be" isn't "Is" -Jay
0 Kudos
Message 7 of 10
(2,098 Views)

Yeah, the data type (U8, String, etc) is returned as an enum in the "type" output and the label of the data is given in the "name" output. In the Help file it does specifically say "name returns the name of the data type stored in variant". Definitely not the right language.

0 Kudos
Message 8 of 10
(2,092 Views)

Since you are passing the data to Python I would recommend flattening your clusters to JSON.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
0 Kudos
Message 9 of 10
(2,043 Views)

Flattening to JSON seems to be the clear answer here.

Cluster to JSON.png

 

Note that the label of the cluster itself is not included in the JSON string, though.

_______________________________________________________________
"Computers are useless. They can only give you answers." - Pablo Picasso
0 Kudos
Message 10 of 10
(1,997 Views)