ni.com is currently undergoing scheduled maintenance.

Some services may be unavailable at this time. Please contact us for help or try again later.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

variant data from data socket to 2d array

Solved!
Go to solution

I am trying to use data socket server to send and receive data from my device (a wavefront sensor) in the same computer. The data I received is in variant type, and I need to convert the variant to other data type I can use in Labview for furthur processing and computation.

 

The data variant I received has a lot of attributes, and the attribute I need is a 2D array. However, I can only see the size of my array in Labview, but not the numerical values. The indicator shows me

 

4 Attribute(s):
   'Centroid_Pos_X' -> [33x41]

   'Centroid_Pos_Y' -> [33x41]

   'Centroids_X' -> 15
   'Centroids_Y' -> 15

 

These four attribute should all return me an array, but they all return me the size of the array...

I tried "get variant attribute",  and also "variant to data".. but couldn't get the correct data.

 

anyone can give me some advice?

0 Kudos
Message 1 of 6
(4,738 Views)

Try wiring cluster of 4 arrays to data type of variant to data.

0 Kudos
Message 2 of 6
(4,724 Views)

 


@KateB wrote:

Try wiring cluster of 4 arrays to data type of variant to data.


 

That won't work since you're dealing with the attributes of the variant, and not the actual datatype of the variant.

 

To poster: You said you tried "Get Variant Attribute". What exactly did you try? Did you wire a 2D array of the appropriate datatype to the "default value" input of the Get Variant Attribute function?

0 Kudos
Message 3 of 6
(4,719 Views)

Hi, I have solved the problem. I used a "Convert variant to data" vi, and wired a 2D array to the type. I attached a snapshot of the connection.

 

 

0 Kudos
Message 4 of 6
(4,702 Views)

Hi, the problem is solved by wiring a 2D array to the "variant to data" type terminal. you can refer to the screen snap I attached in the post above. Thanks for ur attention!

0 Kudos
Message 5 of 6
(4,701 Views)
Solution
Accepted by topic author orangeCHEN

You are performing an extra step that's not necessary. As I pointed out, the Get Variant Attribute function has a default value input, to which you can wire a 2D array to get your array directly:

 

0 Kudos
Message 6 of 6
(4,692 Views)